I don't think this is possible via the default functionality in Qualtrics. However, with a little bit of JS, its doable:
Qualtrics.SurveyEngine.addOnReady(function () {
let counter = Number("${e://Field/counter}");
Qualtrics.SurveyEngine.setEmbeddedData("q_no_" + counter, this.questionContainer.innerText);
counter++;
Qualtrics.SurveyEngine.setEmbeddedData("counter", counter);
});
Have this in the JS of each of the 4 questions.
Then in the fifth question, you can have the choices as:
${e://Field/q_no_0}
${e://Field/q_no_1}
${e://Field/q_no_2}
${e://Field/q_no_3}
This will present them in the order they were initially displayed.
https://www.qualtrics.com/community/discussion/comment/35354#Comment_35354Sorry, but you don't want to do it that way because you'll have to decode the block2 answers on the backend.
This would be better:
Add a hidden span to the randomized block 1 questions' text with the corresponding choice id for the block2 question. For example:
1
Add JS to one of the block1 questions to save the question order to an embedded field:
Qualtrics.SurveyEngine.addOnload(function () {
var b1ro = =];
jQuery(".b2id").each(function() { b1ro.push(this.innerText) });
Qualtrics.SurveyEngine.setEmbeddedData("b1ro",b1ro.join(","));
});
Finally, reorder the choices in your block2 question:
Qualtrics.SurveyEngine.addOnload(function() {
var cs = jQuery("#"+this.questionId+" .ChoiceStructure");
jQuery.each("${e://Field/b1ro}".split(","), function(i,val) {
cs.append(cs.find("(choiceid="+val+"]").closest("li"));
});
});
https://www.qualtrics.com/community/discussion/comment/35356#Comment_35356Okay. I had missed the first line. I was working with the assumption that the first four questions need to be on different pages. With all the questions on the same page, this most probably wouldn't work at all, because all the questions will recieve the value of counter as 0.
Thanks for the correction.
Hi Tom,
I've entered the code into the first block as you instructed.
For the second block with the questions as responses, do I turn on choice randomization, or leave it for the Java to govern the display?
I think I'm missing something for the 2nd block.
For the block2 question there is no need to turn on randomization. The JS will reorder anyway.
Since you say you think you're missing something, I assume it isn't working. First, pipe b1ro into your block2 question text to make sure it is populated correctly. It should be a comma separate string with numbers 1 through 4 in some random order.
Tom,
Yep, the piped text is displayed correctly. However, how do I display only the one corresponding answer choice for each response option? See image below:
https://www.qualtrics.com/community/discussion/comment/35393#Comment_35393Aha, two problems:
- The values should be the choice ids of the choices in the the block2 question, not A,B,C,D. They are probably 1, 2, 3, 4, but you can use your browser's inspect feature to verify. Look at the choiceid attribute in the input tags.
- You should not be piping values into your block2 question choices. They should just be whatever text you want the respondent to see.
Thank you! Re-numbering the questions (removing the letters) did it!
Thanks so much for your help!
https://www.qualtrics.com/community/discussion/comment/35396#Comment_35396Based on your initial post, your block2 question is:
Which do you have?
A (choiceid = 1)
B (choiceid = 2)
C (choiceid = 3)
D (choiceid = 4)
(I'm assuming those are the choiceids, but they could be different based on how you have edited the question)
In block1, each question should have a hidden span with its corresponding block2 question choiceid. The A question would have:
1
Tom - I've got it figured out now.
However, I have one more question.
If I want to add a "don't know" option to the response options in Block 2, how can I do so and ensure it is in a fixed position at the end of my list?
https://www.qualtrics.com/community/discussion/comment/35403#Comment_35403Change the block2 script to:
Qualtrics.SurveyEngine.addOnload(function() {
var cs = jQuery("#"+this.questionId+" .ChoiceStructure");
jQuery.each("${e://Field/b1ro}".split(",").reverse(), function(i,val) {
cs.prepend(cs.find("[choiceid="+val+"]").closest("li"));
});
});