How can I set "matrix" question type (variation/selector "constant sum" + subselector "WOTB") values using the QX API? | XM Community
Skip to main content

I’ve a matrix question with the variation configuration stated in the question title. In the UI the question looks like this:

From the question object it seems like I can uniquely identify rows via choices (correspond to the 9 rows):

However I could not get any info about how I can uniquely identify single cells (row + column) using the QX API. It’s pretty similar to the question type “side-by-side” where I have the same challenge:
 


Does the QX API provide some functionality which allows it to uniquely identify single UI elements?
Is there some generically working workaround for a possible lack of QX API support?

If you haven't checked out the JavaScript Question API documentation yet, it touches on setting answer values for matrix questions.

For Matrix likert questions, to set the value of row choice 3 answer col 2 to "selected", try adding the below to the OnReady section of the question's JavaScript:

this.setChoiceValue(3,2,true);

Or, if using Matrix constant sum, to set the value of row choice 3 answer col 2 to "44", try adding the below to the OnReady section of the question's JavaScript:

this.setChoiceValue(3,2,"44");

 


@Tom_1842 Thanks a lot for this hint. I was really confused about how “choices” work for this question type.

Do choices have some real meaning for this question type actually other than indicating how many rows a matrix has?

Right now I don’t know how to get the complete shape (# rows + # cols) of the matrix.


I believe getChoices will return an array of choice ids and for matrix questions, choice ids will correspond to the row number. Matrix questions will also require the subId in order to set an answer, which will correspond to the column number.

 


@Tom_1842 Great. Thx for the hint. I’ll continue figuring out some way to get the overall shape of the matrix and col types then.


I believe getChoices will return an array of choice ids and for matrix questions, choice ids will correspond to the row number. Matrix questions will also require the subId in order to set an answer, which will correspond to the column number.

 

@Tom_1842 What API do you use BTW? The publicly available API does not contain any examples? https://api.qualtrics.com/82bd4d5c331f1-qualtrics-java-script-question-api-class Probably I should use your docs instead in the future.


The API documentation I linked to previously is the only official documentation that I know of that Qualtrics is keeping up to date.

There is another document from 2010 that contains a lot of the same information, which is where my screen shot is from. I was able to find it in a Google doc here.


Leave a Reply