@vaz235 :
Here’s an example of the JavaScript code to reset the count:
if("${e://Field/YourAnswer}" == "CorrectAnswer") {
Qualtrics.SurveyEngine.setEmbeddedData("ConsecutiveWrongCount", 0);
} else {
var consecutiveWrongCount = parseInt("${e://Field/ConsecutiveWrongCount}");
Qualtrics.SurveyEngine.setEmbeddedData("ConsecutiveWrongCount", consecutiveWrongCount + 1);
}
Hello I am trying to help @vaz235 and I tried the following but I cannot get the ConsecutiveWrongCount to set.
I declared a “Score” and “ConsecutiveWrongCount” in a block above this scoring question block where the JS will run. I tried the follow JS code any help is much appreciated!
Here I am trying to tell it on question 11 answer choice 1 (the right answer) set the count to 0.
Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
if("${q://QID11}" == "${q://QID11/ChoiceDescription/1}") {
Qualtrics.SurveyEngine.setEmbeddedData("ConsecutiveWrongCount", 0);
} else {
var consecutiveWrongCount = parseInt("${e://Field/ConsecutiveWrongCount}");
Qualtrics.SurveyEngine.setEmbeddedData("ConsecutiveWrongCount", consecutiveWrongCount + 1);
}
});
Here I am using the scoring that is setup in the the block and if the score is 1 set the wrong count to 0.
Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
if("${e://Field/Score}" == "1") {
Qualtrics.SurveyEngine.setEmbeddedData("ConsecutiveWrongCount", 0);
} else {
var consecutiveWrongCount = parseInt("${e://Field/ConsecutiveWrongCount}");
Qualtrics.SurveyEngine.setEmbeddedData("ConsecutiveWrongCount", consecutiveWrongCount + 1);
}
});