| Reference | Downloads | Github

Loop won't end online?

URL of experiment: Pavlovia

Description of the problem:
In my experiment, 5 practice trials are run. The participant is then asked if they want to start the real trials or repeat the practice trials (in the 'practiceCheck routine, see below for flow). These 2 options are presented as two clickable images.

if ((mouse2.clicked_name === ["Play"])) {
    trials.finished = true;
} else {
    if ((mouse2.clicked_name === ["Practice"])) {
        practiceAgain = 1;
        trials.finished = false;

Clicking the ‘Play’ image should break out of the loop and move on to the ‘practiceOver’ routine. This works offline, but not online.

I saw someone suggest moving the JS code to the endRoutine tab. This didn’t solve the issue for me.

Here’s a screenshot of my experiment’s flow:

How can I make this work?

Thank you!

I believe the issue is because I had an inner loop and an outer loop. I believe that trials.finished = true doesn’t work in an outer loop. Hence, the practice trials never ended. I have since removed the outer loop and made it so that there is no option to repeat the practice trials. Alternately, I’d have to move trials.finished = true to the inner loop. This would allow the participant to do one practice trial at a time before asking them if they wanted to continue.