psychopy.org | Reference | Downloads | Github

How to use loops for online experiments?

PsychoPy version: v2021.2.3

Intention: Have multiple routines with a video in each that participants can restart by clicking on a button to watch it again, with another button to continue to the next routine. (Some of the videos need to be shown multiple times, therefore the videos have to manually stopped so the experiment does not crash the next time the video is shown. As they also have custom video control buttons to pause and continue the video I cannot simply put the video length in the movie component as it then would be cut short if participants pause the video)

Implementation: Have a loop “replay” around the routine. At the beginning of the routine I declare replay.finished = True so that my continue button ends the routine and then add replay.finished = False and continueRoutine = False on click of the restart button.

Problem: I have two of those routines next to each other and when testing on Pavlovia when I use the restart button on the first routine the first one ends and the next one is skipped (see image 1).

Troubleshooting: I already tried using trials.finished (resulting in the error “trials is not declared” and currentLoop.finished (resulting in the same problem I have with custom names).
Noteworthy is also that later in the experiment I have a nested loop to restart the practice either including the instruction or without it by using practice_repeat.finished = True/False and instruction_repeat.finished= False/True combined with continueRoutine = False. Here it works that clicking the corresponding button only ends one loop and not the other.

Also I tried to add an empty routine and a second “replay” loop to my video routine to mimic the working nested set up to see if it then works, which it did not.

Images of the experiment flow:

image
Loops not working at all.


“practice_repeat” and “instruction_repeat” can be selectively finished, only the “replay”-loops do not work.