This script allows participants to see Choice question answers in the same randomized or rotated order in a follow-up Grid question's rows. Here, "Choice question" and "Grid question" refer to the following question types:
Choice question | Grid question |
|
|
The Choice question will be referred to as the Original question/page. The follow-up Grid question that will be re-ordered according to the original will be referred to as the Follower.
Detailed Steps
-
In your survey, create the Original Choice question.
- From the Show answers in list, select Random order or Rotated order.
- Pin the answers you do not want to randomize or rotate.
Beside the answer option, click the options menu and select Pin answer.
-
Following the Original Choice question, on a new survey page, create a Short Answer Order question to store the order of the list.
- Hide the Short Answer Order question.
- Following the Short Answer Order question, on a new survey page, create the Follower Grid question.
You do not have to set this question to randomize or rotate rows. - Open the Page element that contains the Original Choice question for editing and click the Scripting button.
- Copy and paste the first script into the On Load tab.
- Change ORIGINAL to the name of your Original question.
- Change ORDERSTORAGE to the name of your Order question.
- Click Save.
- Open the Page element that contains the Follower Grid question for editing and click the Scripting button.
- Copy and paste the second script into the On Load tab.
- Change ORDERSTORAGE to the name of your Order question.
- Change FOLLOW to the name of your Follower question.
- Click Save.
- Preview and test your survey.
- Repeat steps 9 to 13 to maintain randomization or rotation order across subsequent Follower Grid questions.
First Script
/*
Script Name: How do I maintain randomization or rotation order going from Choice answers to
Grid rows? (Modern Surveys) (First Script)
To ensure your script works as expected, always copy the original script from the Script Library
found in the Alida Help Center. Failure to use the latest script from the script library may
cause unexpected results.
*/
const qOriginal = page.getElement('ORIGINAL');
const order = qOriginal.reorderElements([]);
const qOrder = response.getDataPoint('ORDERSTORAGE');
qOrder.set(JSON.stringify(order));
Second Script
/*
Script Name: How do I maintain randomization or rotation order going from Choice answers to
Grid rows? (Modern Surveys) (Second Script)
To ensure your script works as expected, always copy the original script from the Script Library
found in the Alida Help Center. Failure to use the latest script from the script library may
cause unexpected results.
*/
const qOrder= response.getDataPoint('ORDERSTORAGE');
const order = qOrder.get();
const qFollow= page.getElement('FOLLOW');
qFollow.elements[1].reorderElements(JSON.parse(order));
Example
Sample survey structure:
Original Multiple Choice question with randomized answers:
Follow-up Single Choice Grid question with rows that maintain the randomized answer order:
Comments
0 comments
Article is closed for comments.