I am having trouble randomizing answer choices in Qualtrics. I want the randomization such that the order of the answer choices are preserved but the order is either ascending or descending.
For instance, I want to randomize between Order A and Order B
Order A)
Order B)
One way to do this is to use block randomization and create separate blocks for Order A and Order B. But I have many questions that I want to randomize in this way. I don't want to end up with too many blocks.
Does anyone have Javascript code so the randomization takes place within each question and one doesn't have to create two separate questions?
My solution was to include the responses twice in each question and use Javascript to hide one ordering or the other.
First, add a multiple choice question with the responses listed first in ascending order and then in descending order. For example,
Response 1
Response 2
Response 3
Response 3
Response 2
Response 1
Now, add this Javascript to each question where you would like to have random ordering.
var numChoices = this.getChoices( "radio" ).length;
var choices = this.getChoices( "radio" );
var pivot = parseInt(numChoices) / 2
var QID = this.getQuestionInfo().QuestionID;
var rand = Math.round(Math.random());
if (rand == 1) {
for (var i = 0; i < pivot; i++) {
var idString = ("QR~" + QID + "~" + choices[i]);
document.getElementById(idString).parentNode.style.display = "none";
}
} else {
for (var i = pivot; i < numChoices ; i++) {
console.log("i: " + i + "pivot: " + pivot);
var idString = ("QR~" + QID + "~" + choices[i]);
document.getElementById(idString).parentNode.style.display = "none";
}
}
This Javascript randomly hides one ordering or the other. The code is written programmatically so that you can enter any number of responses (as long as you include both orders).