How do I use JavaScript create a cumulative ceiling based on scores? | XM Community
Skip to main content

This is a repeat question with a more specific title….

I have created a survey that will act as a language assessment and I need to add basal and ceiling. Specifically, out of 60 questions, I need the first ten to always be answered. At the 11th question, I need to move to the next survey block after 6 consecutive wrong answers - there are four answer options for each question. When an answer is correct, the number of wrong answers is reset to zero. For example, if I answer questions 11-15 incorrectly, but get #16 right, the count is reset.

@vaz235 

  1. At the begining or survey flow you should set an embedded data name “wrongcount” = 0

     

  2. From question 11th to 60th, add this JavaScript for wrong answer tracking/reset (remember to replace correct choice according to each question)
    Qualtrics.SurveyEngine.addOnReady(function() {
    var correctChoice = 2; // Replace with your correct choice numbers
    var that = this;

    jQuery('#NextButton').on('click', function() {
    var selectedChoice = that.getSelectedChoices();
    console.log("Select: "+selectedChoice);
    console.log("Correct: "+correctChoice);
    if (selectedChoice != correctChoice) {
    var wrongCount = "${e://Field/wrongcount}";
    wrongCount = parseInt(wrongCount) + 1;
    Qualtrics.SurveyEngine.setEmbeddedData("wrongcount", wrongCount);
    console.log(wrongCount);
    } else {
    Qualtrics.SurveyEngine.setEmbeddedData("wrongcount", "0");
    console.log(wrongCount);
    }
    });
    });

     

  3. From question 17th to 60th, set display logic if embedded data wrongcount is less than 6. This will hide all the following question and direct respondent straight to the next block if the number of wrongcount is hit.

Hope this helps


Leave a Reply