Randomizing two out of seven questions with timer and loop
Hi everyone,
I have a list of 80 items in a Loop & Merge that appear randomly in one block in several steps: first as just an item:
then in two questions:
Now, I want these two questions to be randomized (sometimes the YOU question should come first and sometimes the ON AVERAGE one). I can’t use two blocks because only one item should be used in each run (Field/1). I also can’t use advanced randomization for it ruins the timer and page breaks.
I have tried many other things but to no avail, so would appreciate your help.
Page 1 / 1
Add this JS to any ONE question on the page:
Qualtrics.SurveyEngine.addOnReady(function () { const randomize = function (arr) { const oldArr = [...arr]; const newArr = []; do { const index = Math.floor(Math.random() * oldArr.length); const val = oldArr.splice(index, 1); newArr.push(val[0]); } while (oldArr.length != 0);
The display order will be recorded in an ED named QuestionOrder add it to your survey flow if you want access to that data point.
Thanks for the code!
However, the problem persists, because what this code is doing is showing both questions in the same page and changing which one appears at the top or bottom at random, while what I want is for the questions to appear at different pages (with page breaks) but sometimes you see the YOU question first and sometimes the ON AVERAGE question. Is this possible?
Hi @HamidN7 I tried doing this with using different blocks and it works fine for me.
END!
Hi @HamidN7 I tried doing this with using different blocks and it works fine for me.
END!
Thanks for the response!
I will try this and come back to you, but I did play around with randomizer and the issue I had with it was that it randomized the questions for each participant, meaning that if person A did it they would see one question first and person B did it another question, but this was fixed throughout the entire experiment, while I want the questions to constantly change order for different trials.
@HamidN7 You’re complicating this too much using randomizer and what not.
Just repeat the question sets:
Page 1: Q1 Q2
Page 2: Q2 Q1
Add a field in your loop and merge and it sets value to random number between 0 and 100(see qualtrics support page for random number generation).
For page 1 Q1 and page 2 Q2, add display logic to only show if greater than 50.
For page 1 Q2 and page 2 Q1, add display logic to only show if less than or equal to 50.
Now you’ll only see one question per page and the order will be randomized.
In your field editor, create a new field that collapses both the Q1s into one and Q2s into another one. Simplifying your analysis.
@HamidN7,
I would take a different approach. It seems the reason you can’t use Advanced Randomization is because of the timing question on the first page. I’m not sure what the purpose of it is, but I would replace it with some JS on the first question. Then you can use Advanced Randomization and your data is clean.
This JS auto advances and records the time on page:
Qualtrics.SurveyEngine.addOnReady(function() { var qobj=this, start=new Date(); /*Auto advance after 10 secs */ var to = setTimeout(function() { qobj.clickNextButton(); },10000); Qualtrics.SurveyEngine.addOnPageSubmit(function() { clearTimeout(to); /*Record time in seconds w/ decimals, lm://Field/2 is an index of loops*/ Qualtrics.SurveyEngine.setEmbeddedData("time_${lm://Field/2}",(new Date()-start)/1000); }); });
You can remove the bits of JS you don’t need. If you need to record the times, define the embedded fields (e.g. time_1) in the survey flow before the loop.
@HamidN7 You’re complicating this too much using randomizer and what not.
Just repeat the question sets:
Page 1: Q1 Q2
Page 2: Q2 Q1
Add a field in your loop and merge and it sets value to random number between 0 and 100(see qualtrics support page for random number generation).
For page 1 Q1 and page 2 Q2, add display logic to only show if greater than 50.
For page 1 Q2 and page 2 Q1, add display logic to only show if less than or equal to 50.
Now you’ll only see one question per page and the order will be randomized.
In your field editor, create a new field that collapses both the Q1s into one and Q2s into another one. Simplifying your analysis.
That’s a neat solution, thanks, but I failed implementing it.
By “adding a field”, do you mean like this?
Also, in the display logic, I’m not sure how could I reference that random value (except for using Embedded data, which is useless in my case because you can’t use it inside the block for each loop) :
@HamidN7,
I would take a different approach. It seems the reason you can’t use Advanced Randomization is because of the timing question on the first page. I’m not sure what the purpose of it is, but I would replace it with some JS on the first question. Then you can use Advanced Randomization and your data is clean.
This JS auto advances and records the time on page:
Qualtrics.SurveyEngine.addOnReady(function() { var qobj=this, start=new Date(); /*Auto advance after 10 secs */ var to = setTimeout(function() { qobj.clickNextButton(); },10000); Qualtrics.SurveyEngine.addOnPageSubmit(function() { clearTimeout(to); /*Record time in seconds w/ decimals, lm://Field/2 is an index of loops*/ Qualtrics.SurveyEngine.setEmbeddedData("time_${lm://Field/2}",(new Date()-start)/1000); }); });
You can remove the bits of JS you don’t need. If you need to record the times, define the embedded fields (e.g. time_1) in the survey flow before the loop.
Thanks.
Yeah, that’s one reason, which would be solved with your suggestion, but another reason is the fact that in each loop I have to use one item, so one item should randomly appear in four questions and I’m using Loop and Merge for it, but if I use advanced randomization then it would mess with the order of the other questions.
This is the structure of the Loop & Merge block:
Q1
${lm://Field/1}
Q2
Estimation of happening to YOU?
${lm://Field/1}
Q3
Estimation of happening ON AVERAGE?
${lm://Field/1}
Q4
Actual Average-Likelihood
${lm://Field/1} ${lm://Field/2}
and I want to randomize the order of Q2 and Q3 in each loop without ruining the order of the others.
...
and I want to randomize the order of Q2 and Q3 in each loop without ruining the order of the others.
It depends on if you want Q2 and Q3 randomized per respondent or per loop. Advanced randomization will work on a per respondent basis, which is normally how one would want to do it. Switching the order of looped questions on a per loop basis can be confusing to the respondent.