Scoring questions inside of a loop/merge block | XM Community
Skip to main content

Hi everyone -
I am looking to score questions within a loop/merge block. This does not seem to work with the scoring feature so I am trying to use javascript but have been encountering great difficulty. They are simple Yes/No questions where Yes correlates to 1 and No correlates to 0. After they submit the page I need to display a question if their score is below 5 total and a different question if they score above 5 total (still inside the loop/merge block). I understand I need to use display logic and page breaks to do so. I cannot figure out how to A) get the question to score correctly, 😎 add all the question scores together, and then C) what to use in the display logic for the follow-up question.

Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var answer = this.questionContainer.querySelector(".q-checked").nextElementSibling.innerText;
 Qualtrics.SurveyEngine.setEmbeddedData('answer', answer);
if(answer = 0) Qualtrics.SurveyEngine.setEmbeddedData('mmm', '0');
 if(answer = 1) Qualtrics.SurveyEngine.setEmbeddedData('mmm', '1');

});
This code seems to always make their score 1 no matter if they answer Yes or No; I have used 'Recode Values' to make 1 - Yes and 0 - No. I also used the Scoring feature to set these same values. I have tried setting Embedded Data in Survey Flow prior to the loop/merge block as well. I have not attempted to figure out a way to total all the question scores together as I need the score to work first.
Thank you for any help.

Be the first to reply!

Leave a Reply