This script allows you to carry forward the item that participants ranked first in a Rank Order question into a subsequent hidden Single Choice question.
Detailed Steps
- In your survey, add a Page element.
- Add a Rank Order question to the Page element.
- Set Number of items to rank as desired.
- Set Show items as as desired.
- Add your Rank Order items.
- Add a second Page element.
- Add a Single Choice question to the second Page element.
- Add the same answer options as the Rank Order items from step 2.
- You may want to temporarily leave this unhidden for testing.
- Open the first Page element for editing and click the Scripting button.
- Copy and paste the script below into the On Complete tab.
-
Replace Q_Rank with the Rank Order question name.
The replacement needs to be done twice in the script. - Replace Rank_Top_1 with the Single Choice question name.
- Click Save.
- Preview and test your survey.
Script
/* Script Name: How do I record the top-ranked item from a Rank Order
question in a hidden Single Choice question? (Modern Surveys) 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 rank = response.getDataPoint("Q_Rank"); const rr = response.getDataPoint("Rank_Top_1"); rr.set(rank.get()[0]);
Example
Sample survey structure:
First page with Rank Order question:
Second page with selected Single Choice answer reflecting the top-ranked Rank Order item:
Comments
0 comments
Article is closed for comments.