I have an experiment in which participants are asked to give a key response ‘1’, ‘2’, or ‘3’, based on their response to a question.
For those who press 1 or 2 I’d like the loop to end. And for those who press 3 it should continue on to the next page, where a message comes up that they are ineligible and to press space to exit.
I have this working on psychopy, but on pavlovia I can’t figure it out.
I want it to record their response, and for those who respond 1 or 2 for the loop to end. I’ve set it up using trials.finished = true as I’ve read that it cannot be the name of the loop itself, and continueRoutine = false.
It should ideally then move to the next routine where I have coded:
in which those who respond with 1 or 2 should skip this routine and move on with the experiment. Then for those who responded with 3 should advance to this piece of code
In the latest versions (i.e. since 2020.2), this has been working online the same as offline. Your issue is that you have used trials.finished in your JS instead of visionloop.finished.
Hi there,
This what was originally in my code. I had visionloop.finished and it returned the same message, which is why after looking through the forums i tried trials.finished.
I have since fiddled around and created another solution!
Thanks for the help though!
I have encountered the same problem where ‘trials.finished=true’ in JS does not work with online experiments. Could you please help me with the another solution that you mentioned above?
I am trying to break out of the ‘pracLoop1’ if the %acc is 70 on a total of 24 trials. If not, the participant is redirected back to the practice and the max practice rounds = 3.
Begin routine:
//
for (eachResp=0; eachResp<psychoJS.experiment._trialsData.length; eachResp++)
{
if (‘practice_resp1.corr’ in psychoJS.experiment._trialsData[eachResp]) {
ncorr1 += psychoJS.experiment._trialsData[eachResp][‘practice_resp1.corr’];
}
}
if (PLoopTally <= 3)
{
varmsg1 = ‘Well done! Redirecting to the test trials.’;
trials.finished = true;
} else if (ncorr1 >= 17) {
varmsg1 = ‘Well done! Redirecting to the test trials.’;
trials.finished = true;
} else {
varmsg1 = ‘Your accuracy is low. Let us practice that one more time! Redirecting to the practice trials.’;
trials.finished = false;
PLoopTally = PLoopTally + 1;
ncorr1 = 0;
}
//
The same code was working online with a previous version of psychopy.
There used to be a bug in the online version which forced you to refer to all loops as trials. Since that has since been fixed, you need to use the appropriate loop name, e.g. practice_rounds1.finished
@wakecarter
The error message has disappeared now, but now the feedback text displays ‘Hello World’ instead of the intended message. Is there a bug with the code?
The syntax error is because you have put JS code in the Python Window. I would highly recommend programming primarily in Python (with the Auto translate switched on) and use Both or JS only components only when necessary.
I want to terminate the task_trials loop at the 4th trial (if task_trials.thisTrialN == 3) in the first repetition of practice_formal loop (if practice_formal.thisRepN == 0).
Although the code execute task_trials.finished = True, the program still goes to the next routine (show_player), which trigger the unrelated error.
The code runs well in local but not in the online version.