$nReps is not working online

URL of experiment: Pavlovia

Here is the experiment:
AU_pain_task_pilot_online.psyexp (138.6 KB)

Description of the problem:
Hello,

I’m having trouble using $nReps in the builder component to control the number of trial repetitions online. When I set $nReps to 0, this gets ignored, and the loop happens anyway:

Likewise, if I set $nReps to a number greater than 1, then it will still only go through each trial once. This goes for every loop in my experiment.

I’ve read a good deal about controlling whether or not a trial happens based on response from a previous trial, but I haven’t been able to get this to work, probably because I am new to JavaScript. For example, if a participant clicks left on a certain trial, I want trial 5 to happen. If they click right, then I want trial 6 to happen instead of 5. Here are some of the different things I have tried:
[the following is in “each frame” of the routine where the response determining what the following trial will be is made]:

let theseKeys = psychoJS.eventManager.getKeys({keyList:[‘left’]});
if (key_resp.status === PsychoJS.Status.STARTED) {
if (theseKeys.indexOf(‘left’) > -1) {
nReps_trial5 = 0;
nReps_trial6 = 1;
} else {
nReps_trial5 = 1;
nReps_trial6 = 0;
}

…or something along those lines, and then setting nReps of trial 5/6 to “$nReps_trial5”, e.g. Because nReps seems to be static for me for whatever reason, this does not work.

I’ve also tried storing the “left” arrow as the correct response, and using this to determine whether the next trial happens, e.g. (in each frame):

if (key_resp.corr === 1) {
nReps_trial5 = 0;
nReps_trial6 = 1;
}
else {
nReps_trial5 = 1;
nReps_trial6 = 0;
}

And then on the next routine:

if (nReps_trial6 === 1) {
continueRoutine = false;
}

But the routine happens regardless of my response on the preceding routine…

So, I’m wondering, if changing $nReps, even manually does not work, and continueRoutine based on a variable from the last routine does not work, how can I manipulate nReps based on feedback? None of the solutions I’ve read on Discourse have worked for me, and again I assume it’s because I’m new to Javascript and am missing something.

Any feedback is appreciated, and thank you very much for your help.

Cheers.

I was able to resolve this issue by reverting to Psychopy version 3.2.0. Thanks all.

Could I just clarify, was it 3.2.4 that wasn’t working? We’re working towards 3.3 and would like this fixed if we can track down the version that has it wrong. Thanks

Hi Jon,

Yes, this issue was occurring in version 3.2.4.

Best,
Carolyn

@cmamir, I do not think you can change the nReps dynamically, because the number of blocks has already been scheduled. The trial list is created based on the number of reps. What you can do though, is end the loop and routine based on some condition e.g.,

if (pain === 1) {
  continueRoutine = false;
  currentLoop.finished = true;
}