Auto-Advance Not Working When Participants Enter Wrong Answer | XM Community
Skip to main content

I’m designing an anagram task and what to prevent participants from manually advancing if they submit an incorrect answer but be auto-advanced to the next anagram after 30 seconds. I have a timer question set up to auto-advance after 30 seconds and I’ve added a custom validation to the anagram question (a text entry question). The custom validation will only accept the correct answer for the anagram. If participants enter the correct answer they are able to manually advance, but if they leave the response field blank or enter an incorrect answer they are not auto-advanced to the next page after 30 seconds. 

 

Any advice on how to keep participants from manually advancing without entering the correct answer while also auto-advancing them after 30 seconds if they leave the response field blank or enter an incorrect answer?

Hi @Connor 
You can use the below code.

Qualtrics.SurveyEngine.addOnReady(function() {
    var text = document.querySelector("inputptype=text]");

    text.addEventListener("keyup", function() {
        console.log("text entered");
        if (text.value.toLowerCase() === "test") {
            // Autoadvance automatically if the correct answer is provided
            jQuery('#NextButton').click();
        }
    });

    // Use setTimeout to wait for 30 seconds and then click the Next button
    setTimeout(function() {
        // Autoadvance automatically after 30 seconds
        jQuery('#NextButton').click();
    }, 30000); // 30 seconds
});

Qualtrics.SurveyEngine.addOnUnload(function() {
    /*Place your JavaScript here to run when the page is unloaded*/
});


Here, I have keep the correct answer as ‘test’ (change the answer as per your requirement).
Also, the ”toLowerCase” is applied to the string "TeSt," and the result is a new string "test" with all characters converted to lowercase.


Leave a Reply