| Reference | Downloads | Github

Conditional loop termination works for one loop but not the other, despite using the same setup (routines, code etc. with adjusted variables)

PsychoPy v.2020.1.1

Description of the problem:

I’ve built a G-Maze Task (forced choice, self-paced reading) and it runs flawlessly in Builder but not online. More specifically, loop termination only works for the actual trial online but not the practice trial, although I’m using the same routines and code (variables have been adjusted accordingly) in both of them.

To see whether it has to do with any of my condition files I have re-created the task, starting with the actual trial and then add the practice run (in which case the trail works fine, but the practice run doesn’t) and then I built the practice run first and then added the actual trial (in which case the practice run worked fine, but the actual trial didn’t) > so, a first-come-first-served kind of deal. I couldn’t find any differences in the code between the two trials in the JS version, but then again, I know next to nothing about JS.

How it is supposed to work (as it does in Builder):

Trials continue until the end of a sentence as long as participants answer correctly. If not, participants receive feedback and the trial (or sentence) is terminated > they move on to the next sentence, i.e. the next block of rows as predetermined by the condition file in the outer loop.

How it actually runs online:

In the practice run, the trial doesn’t terminate after an incorrect response, but gives feedback and continues the sentence. In the actual trial (same setup) everything works fine.

Any ideas why that is???

I have attached the experiment and the condition files.

Thanks in advance for your help.

maze_task_test4.psyexp (62.0 KB) prac_rows1.xlsx (9.6 KB) prac_stimuli_maze.csv (452 Bytes) rows.xlsx (10.0 KB) stimuli_maze.csv (3.1 KB)


I’ve tried to narrow it down further. While I suspect the code components to cause the problem online, I can’t figure out why it would work for one trial but not the other. Is PsychoPy perhaps more forgiving than JS? That is, if my code in PsychoPy is ‘messy’, it’ll still work in Builder but not in JS.

I’m happy for any suggestions

I’m wondering what version of PsychoPy you are using, because I had similar issues when updating to PsychoPy 2020 from PsychoPy 3.something.something.
See this thread for more info: Loop.finished=true No longer working

But in summary I think you might need to change the code for how loops are ended since this was updated.
From that thread:

there a slight change to how you end loops in the latest version of PsychoPy/JS. To end a loop, use the following. In this example, we end the loop on the 2nd repetition of that current loop:

if (currentLoop.thisRepN == 2) 
    trials.finished = true;  // to end any loop, use 'trials'
1 Like

Thanks @Bobby_Thomas. That’s it.

1 Like