Hi all,
I'm trying to randomly change the text and the order of answer options in a single multiple-choice question using JavaScript.
Here's what I'm trying to do:
-
Randomly change the question text:
- Option 1: "Here is a 7-point scale on which the political views that people might hold are arranged from extremely liberal to extremely conservative."
- Option 2: "Here is a 7-point scale on which the political views that people might hold are arranged from extremely conservative to extremely liberal."
-
Reorder the multiple-choice options based on the question text:
- If the question starts with "extremely liberal", the options should be in this order:
- Extremely Liberal
- Liberal
- Slightly Liberal
- Moderate, Middle of the Road
- Slightly Conservative
- Conservative
- Extremely Conservative
- Don’t Know, Haven’t Thought (always last)
- If the question starts with "extremely conservative", the options should be:
- Extremely Conservative
- Conservative
- Slightly Conservative
- Moderate, Middle of the Road
- Slightly Liberal
- Liberal
- Extremely Liberal
- Don’t Know, Haven’t Thought (always last)
- If the question starts with "extremely liberal", the options should be in this order:
The problem:
- I can randomize the question text, but the options don’t reorder dynamically based on the text.
- I’m using
this.setChoiceLabel(i, label)
in JavaScript, but it seems like the changes aren’t being applied.
What I need help with:
- Can JavaScript dynamically reorder answer options in Qualtrics?
- Is there something that prevents the changes from taking effect after the question is loaded?
- What’s the best way to achieve this in a single question?
Thanks in advance for your help!