This script allows participants to see Grid question columns in the same randomized or rotated order in a follow-up Grid question's rows. Here, "Grid question" refers to the following question types:
- Single Choice Grid
- Multiple Choice Grid
The first Grid 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 Grid question.
- From the Show columns in or Show answers in list, select Random order or Rotated order.
- Pin the columns you do not want to randomize or rotate.
Beside the column option, click the options menu and select Pin column.
-
Following the Original Grid 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 Grid 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 Grid columns 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.elements[0].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 Grid columns 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 Grid question with randomized columns:
Follow-up Single Choice Grid question with rows that maintain the randomized column order:
Comments
0 comments
Article is closed for comments.