| Reference | Downloads | Github

Cannot exit loop in online Pavlovia (Using JS code component)

Description of the problem:

We tried to exit a loop ( the loop is named “RepeatTestLoop”) once our counter reaches a certain number (the counter is named “number_correct”). However, this does not work in the online Pavlovia version. The loop continues even after the counter is larger than 5.

In our code component, we did translate this into JS (as listed below)

if (number_correct > 5){ RepeatTestLoop.finished = true; }

else {number_correct = 0; }

Could someone let us know what the problem could be?

Best Regards,

@katsuragiai, this will be fixed in the next release of PsychoPy (version 2020) - this issue and the solution has been reported here.

@dvbridges I have similar problem.

I’m creating an experiment ( with three training phases (eg. Routine:Telefon_Próba1_CIT) with feedback information (Telefon_Feedback_Proba1).

Each training phase has two loops - Inner (Sekw_tel_proba1), and outer (gdy_blad). Inner loop randomizes stimuli and outer loop is forcing repetition of each phase in the case of a wrong answer. I added code component in the end routine tab:

if k_resp_proba_1.corr == 0:

if ((k_resp_proba_1.corr === 0)) {
Sekw_tel_proba1.finished = true;
gdy_blad.finished = false;
} else {
gdy_blad.finished = true;

Everything works perfectly in PsychoPy, but it doesn’t work in the online Pavlovia version - errors don’t terminate an inner, and the correct answers don’t terminate an outer loop.
I have just downloaded Psychopy 2020 but it doesn’t help.

@Emiel_Regis, if you take a look at the link on GitHub, it shows the correct method for terminating loops using code.

@dvbridges Thank you for so quick response. Unfortunately, my problem is slightly different - I want to terminate each loop after all correct responses (outer loop) or after one wrong response (inner loop). I am a beginner at both PsychoPy and PsychoJS and I don’t know how to use your code in my experiment. I will be extremely grateful for a hint.