Calculating accuracy of first 10 trials and exiting out of trial if accuracy is too low to show instruction screen

What I am trying to achieve: My goal is to provide feedback to the participants after the first 10 trials only if their accuracy is too low. If they get above 70% accuracy in the first 10 trials, then they proceed through the rest of the trial as normal. If they get less than 70% accuracy, they are told their accuracy is too low and then they are redirected to the instruction screen and they would have to repeat the entire block again from the start. Here is what my builder routine looks like:
In this case, I have a nested inner loop with my trial and fixation cross and an outer loop that contains the feedback and the instruction screen.

What I did to make it work: I created a custom code that would terminate the inner block when the accuracy was too low. Otherwise, if their accuracy is greater than 70% then the inner loops continue as normal and at the end of the block, I would like it to terminate the outer loop (so they don’t see the feedback and instruction screen again).

What went wrong: Even if they get better than 70% and continue normally through the inner loop, at the end of the block, the instruction screen and feedback screens still appear (outer loop doesn’t terminate) so I’m not sure how to make this work.

This is what my code looks like:
#begin routine (feature_trial is the name of my inner loop and trials is the name of my outer loop)
if feature_trial.thisN == 0:
number_correct = 0

‘’‘end of routine (key_resp_2.corr is the correct answer)’’’
‘’’ update the number correct: key_resp_2.corr represents correct answers’’’
if key_resp_2.corr:
number_correct = number_correct + 1
‘’‘what happens if they get less than 70%’’’
‘’’ if this is the 10th repetition, check the proportion correct.’’’
if feature_trial.thisN == 10:
if number_correct/(feature_trial.thisN + 1) < 0.70:
masg=‘Your accuracy is too low. Accuracy = ’ + str(number_correct*100/feature_trial.thisN + 1) +’%. Please press space to continue to the instruction screen’
‘’’ terminate inner loop’’’
feature_trial.finished = True
‘’’ don’t terminate outer loop’’’
trials.finshed = False
‘’‘what happens if they get greater than 70%’’’
elif number_correct/(feature_trial.thisN + 1) >= 0.70:
‘’’ continue inner loop’’’
feature_trial.finished = False
trials.finshed = True

Did you just type this code or was it copied from your experiment. I say this because you have finshed instead of finished a couple of times as we’ll as having 10 instead of 9 (which. Hi would be the 10th iteration).

loops.finished are False by default so setting them to false doesn’t do anything… If performance is worse than 7/10 do you want the experiment to core.quit() or repeat?

Yes, I copied the code directly from the experiment. I’m not sure if this is what you were asking but I don’t want it to core.quit(), I just want to be able to redirect them to the instruction screen only if they get less than 7/10 in the first 10 trials, otherwise they can continue the experiment as usual (no break in routine). The nested loop was one way I thought I could make it work, but I assume I can’t quit the outer loop while keeping the inner loop going?

Just a bit more background about my experiment: I am asking my participants to complete two different tasks one after the other. However, just by the nature of the tasks, I found that sometimes my participants were forgetting which task they were completing (even after doing the practice trials), and so I want to include a safe guard method into my trials so if they forget, they are redirected to the instruction screen to remind them of the task.

Thank you for responding, and please let me know if there’s any other clarifications I can provide!

The way I set up repeating instructions / practice trials is to create a loop that assume that the criteria is not met (and therefore instructions will be repeated) and then a code component that breaks that loop is the score is high enough.