Customize display of previous selected choice(s)? | Experience Community
Skip to main content
Solved

Customize display of previous selected choice(s)?

  • Apr 21, 2021 1:45 PM UTC
  • 3 replies
  • 450 views

GrumpyCivet

I have some multiple choice questions and would like to show participants their own choices after the questions.

I noticed that this can be done with piped text. However, I wonder if we can customize the display of slected choice. For example, the question can have 10 options, each of which is somehow wordy, and instead of showing all the options people chose, we only displayed something like "option 1, option 5, option 7, option 9" etc.

I found an ugly solution to this by using branch if in survey flow. But for some reason I want the question page and the display page in the same block so I can't insert branch if in between them.

Does anyone have any suggestions on how to achieve this?

Best answer by GrumpyCivet

I figure out:
var currentQuestionID = this.getQuestionInfo().QuestionID;
var questionObject  = Qualtrics.SurveyEngine.getInstance(currentQuestionID);

const translate = {
1: " option 1",
2: " option 2",
3: " option 3",
4: " option 4"
};

this.questionclick = function(event,element){
if (element.type == 'checkbox') {
var selectedChoices  = questionObject.getSelectedChoices();
selectedChoices = selectedChoices.map(myChoice => {
return translate[myChoice]
})

Qualtrics.SurveyEngine.setEmbeddedData("selectedChoices", selectedChoices);
}
};
Then just insert the embedded data

selectedChoices
as piped text.

View original

3 replies

pogi
Level 2 ●●
Forum|alt.badge.img+14
  • Level 2 ●●
  • Apr 21, 2021 7:35 PM UTC

You can recode the values of the selected responses and have that piped to display or you can use javascript to set embedded data variable to whatever you want and then display the embedded data.


GrumpyCivet

pogi Thank you for your response!
Recoding values does not work since it only allows entering number instead of text like "option 1".
Could you please elaborate on how to set embedded data conditional on which option(s) are chosen using javascript? I only know limited javascript and its application on Qualtrics - can't think of how we can actually do this now.


GrumpyCivet
  • Author
  • Answer
  • Apr 22, 2021 6:20 AM UTC

I figure out:
var currentQuestionID = this.getQuestionInfo().QuestionID;
var questionObject  = Qualtrics.SurveyEngine.getInstance(currentQuestionID);

const translate = {
1: " option 1",
2: " option 2",
3: " option 3",
4: " option 4"
};

this.questionclick = function(event,element){
if (element.type == 'checkbox') {
var selectedChoices  = questionObject.getSelectedChoices();
selectedChoices = selectedChoices.map(myChoice => {
return translate[myChoice]
})

Qualtrics.SurveyEngine.setEmbeddedData("selectedChoices", selectedChoices);
}
};
Then just insert the embedded data

selectedChoices
as piped text.