tpartner,
You are indeed generous with your contributions to this community.
The sample code works very well. (However, the positive subquestion values were leading to computational errors. Once I forced variable ans in the phrase [else { B1 = ans; }] to a number using a unary plus (+) operator, the errors went away. The matrix still evaluates to NaN for a subquestion value of zero, but I intend to include a validation sequence for the slider that prohibits a zero value.)
I had not considered invoking LEM developer functions. Also, thank you very much for the insight on limitations of using JS to write data in Equation-type questions.
Two follow-on questions, if I may:
1. Depending on options selected by the respondent, the respondent will answer 1, 3, or 6 slider subquestions, requiring computation of a 2x2, 3x3, or 4x4 matrix, respectively. How can this technique of invoking #question{QID} for thisQuestion be expanded to process 6 subquestions concurrently? I’m thinking of concatenating the 1, 3, or 6 slider subquestion answers into a single EM-format string, and then using JS to parse the variables out as needed for the cells in the correspondingly-sized matrix. Is there a better way?
2. Depending on the matrix size, the computations will result in 2, 3, or 4 priority values (for combinations of Alpha, Beta, Gamma, and Delta). I would like to populate the database with the multiple priority values and their associated labels. If the result was a single value, the question answer could be stored as a single accessible field. How can JS or EM be used to store multiple results of the Equation question computation as “previous fields” that can be queried later?
Thank you again,
BG2013
The topic has been locked.