Repeat loop if incorrect - JS

Description of the problem:

I am trying to repeat a loop of training trials till everything has been correct. I created (as recommended in other posts) a nested loop structure and inserted a code component. Offline everything works well, but I am struggling with the transition in JS. I appreciate every help.

Py:
if not resp1.corr:
trials.finished = True

JS:
if not (resp1.corr){
trials.finished = true;
}

Thank you very much!

I am no JS expert (I am still learning), but, if I am not mistaken, if not is not part of the JS syntax. Try:

if (! resp1.corr) {
      trials.finished = true;
}
if (!resp1.corr){
    trials.finished = true;
}

There is not any not operator in JavaScript.

Thank you very much for your suggestions. I implemented those changes, but it is still not working online.

Does anybody can tell me why it is not working? Thank you very much in advance!

Is there a reason why your commands are different for python and JS?

py: trainings.finished
JS: trials.finished

That was a mistake, but even when I fixed that, it does not work.

You should provide a description of the experiment and .psyexp file so that the JS experts can take a look at it.

In any case, did you look at this?
I also seem to remember that loop termination was going to be implemented in PsychoPy 3.1.0. Did you try to update to that version?

Hi @rob-linguistics13,

I am building a modified version of the stroop task. To begin with, participants will run some trials for training. This loop of training trials should run again and again, till everything has been correct, to make sure that every participant understood the logic of the task.

I am not sure, how to implement the code correctly. I just noted that the code above (If not…) does not work properly, because even when the participant answers everything correct, it does not skip the outerloop.

I created an example file:

example.psyexp (9.0 KB)

I appreciate any helpful suggestions!