Solved
conditional loop?
Hi all,
I would appreciate any help in creating a conditional loop in Qualtrics.
Here is what I am trying to do:
I have a block of 40 questions, which I would like to present to participants randomly.
I would like to repeat the presentation of this block until participants get 25 questions right. In this case, participants will progress in the next block.
many thanks in advance
Best answer by TomG
Unfortunately, you can't use scoring in display logic. So, you'll have to use some JavaScript to keep a count of correct answers using the addOnPageSubmit function. Then you'll have to add display logic to each question in the block to only display it if the correct count is less than 25.
Initialize correctCount to 0 in the survey flow before the block. Then add JS something like this to each question:
```
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var correctChoice = "2" //change to match correct choice id
if(correctChoice == this.getSelectedChoices()) {
Qualtrics.SurveyEngine.setEmbeddedData("correctCount",parseInt("${e://Field/correctCount}")+1);
}
});
```
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
