Hello,
For my survey:
Q1 is a Matrix Table Likert "Drag and Drop" question where respondents are shown a list of 20 statements and asked to sort them equally into 2 groups (Group A & Group .
Q2 is a similar question except it carries forward the statements dropped into Group A, and respondents are asked to further sort those into 2 groups (Group A.1 & Group A.2)
Q3 asked them to do the same thing (Sort carried forward statements from Group B into Group B.1 & Group B.2).
I have managed to do till then. The difficulty I am having is for Q4, where I need to show Groups A.1, A.2, B.1 and B.2 and ask the respondents if they are happy with their groups or if they wish to change. I can't seem to bring forward the selected statements and display them within he correct box as per the image below.
Qualtrics Support told me that I would need to insert a Javascript in order to do this, and I am unsure as to how I should. I will really appreciate it if someone is able to help me with this.
Thank you!
This code should work for you:
Qualtrics.SurveyEngine.addOnReady(function () {
let ques = this;
let a1 = "${q://##QID of A##/ChoiceGroup/SelectedChoicesForAnswer/1}";
let a2 = "${q://##QID of A##/ChoiceGroup/SelectedChoicesForAnswer/2}";
let b1 = "${q://##QID of B##/ChoiceGroup/SelectedChoicesForAnswer/1}";
let b2 = "${q://##QID of B##/ChoiceGroup/SelectedChoicesForAnswer/2}";
let choice_text = ques.getChoiceContainer().innerText.split(/\\n/gm);
let all_choices = ques.getChoices();
let all_answers = ques.getAnswers();
for (let i = 0; i < choice_text.length; i++) {
let set_choice = -1;
switch (true) {
case a1.includes(choice_textii]):
set_choice = all_answersb0];
break;
case a2.includes(choice_texti]):
set_choice = all_answers[1];
break;
case b1.includes(choice_textci]):
set_choice = all_answers2];
break;
case b2.includes(choice_texti]):
set_choice = all_answerss3];
break;
}
ques.setChoiceValue(all_choices_i], set_choice, true);
}
});
Points to note:
##QID of A##
and##QID of A##
refer to questions where you are asking them to sort answers in A1, A2 and B1, B2.- Your scale points in this question should be in the order A1, A2, B1, B2. The name doesn't matter.
- Your statements should be all the statements from both the questions. The order doesn't matter.
Hi ahmedA,
Thank you so much for helping with the code.
I followed exactly what you said but somehow it's not working exactly.
This is the code:
Yet when I run it, nothing appears in the groups
Am I doing anything wrong perhaps?
Hi ahmedA,
I actually managed to get it to work. I realised I had to set it carry forward all the statements from the Q1 to Q4, and then when I ran the javascript, it automatically sorted it.
Thank you so much for your help!
Can I ask how you carried forward the statements after first sorting them into groups? E.g. I need to ask participants sort 46 statements into agree more, neutral, or agree less. Then I'd like to carry forward the statements within each category (agree more, neutral, and agree less) and then have them rank each statement from -5 to 5, where -5 to -1 is for the agree less pile, 0 is neutral and 1 to 5 is for the agree more pile.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.