OS (e.g. Win10): Win10 PsychoPy version (e.g. 1.84.x): 3.0.5 Standard Standalone? (y/n) If not then what?: yes What are you trying to achieve?: skip routine based on the value of a column in a .csv condition file What did you try to make it work?: I’ve added a code snippet to make it work offline:
if n_next < 1:
continueRoutine = False
where n_next is the header of the relevant column in a loaded .csv file.
To make it work online, I’ve added the following java snippet, but I imagine it is not 100% correct:
if (n_next < 1) {
continueRoutine = false;
}
What specifically went wrong when you tried that?:
The experiment does not crash and runs smoothly, but it does not skip the routine when needed. It always displays that routine, regardless of the value in the .csv file.
This only happens when running it online. If I run it locally, it works as desired.
Hi @carlos, where have you inserted the code? I think you will need to insert this into the “Every Frame” tab for it to actually end the routine, because if you look at the JS code, continueRoutine is defined as true at the beginning of every frame, unless told otherwise.
Hi,
I’m now trying to skip a routine once participants reach a given accuracy threshold during a practice block. What I’ve done is the following:
add a code component at the end of the practice block.
in the Begin experiment tab, create a variable that will track the number of correct responses:
nCorrect = 0;
in the End Routine tab, do the following:
if (go_response.corr==1) {
// if response is correct, increment value
nCorrect++;
}
if ((prac1.thisN+1)%10==0) {
// if is the 10th trial
if (nCorrect >= 8/10) {
// and if the participant got at least 8 out of 10 responses
prac1.finished = true;
//finish practice
} else{
// otherwise, restart counter
nCorrect = 0;
}
}
This is somehow not working online. Does anyone have any idea?
That’s a bit of a problem, in terms of inconsistency with the Python code. Builder used to do it this way in Python too, but it was changed to make it possible to quit the routine in the “begin routine” tab. Otherwise you can’t skip a routine entirely: if we can only exit the routine in the “each frame” code, at least one frame of it will get displayed. Thoughts @jon ?
Hi I encountered this similar problem, so far I solved this problem by locating this chunk of code in the Begin Routine component
if ((prac1.thisN+1)%10==0) { // if is the 10th trial if (nCorrect >= 8/10) { // and if the participant got at least 8 out of 10 responses prac1.finished = true; //finish practice } else{ // otherwise, restart counter nCorrect = 0; } }
whereas, this bit
if (go_response.corr==1) { // if response is correct, increment value nCorrect++;}
added in the End Routine component.
So it counts the correct answer at the end of the routines, and if the response rate is less than the threshold, it will end at the beginning of the routine. Hope it helps & welcomes for the suggestion