| Reference | Downloads | Github

Correct trials percentage threshold with multiple blocks

If this template helps then use it. If not then just delete and start from scratch.

**MacOS 10.13.6
**PsychoPy version: 3.2.4
**Standard Standalone? (y)

Hi everyone,

In my experiment, a participant has to complete 3 randomized blocks of 12 trials each. I want to make it so that participants must get at least 90% of the trials in the last block correct before they can finish. If the participant gets less than 90% correct in the last block, they have to do the entire experiment over again.

I’ve almost gotten it to work by making the second loop’s nReps=2 and using this code:

Begin Experiment

ACQkeyRespcorrs = []
minNrPractice = 36  # min number of trials to practice
considerNrTrials = 12  # number of trials to consider for accuracy calculation
minAccuracy = 0.9

End Routine

respcorrs.append(resp.corr)  # assumes your keyboard component is called "ACQkeyResp"

if len(respcorrs) >= minNrPractice:

    respcorrsRecent = respcorrs[-considerNrTrials:]
    respcorrsSum = sum(respcorrsRecent)  # only works if error=0 and correct=1
    accuracy = float(respcorrsSum)/considerNrTrials
    if accuracy >= minAccuracy:

However, when >=90% accuracy is achieved at the end of the third block, one trial from Block 1, 2, 3 follow before the experiment ends. How can I get the extra three trials not to run?

I’m not sure I understand the setup of your experiment correctly (feel free to post your experiment if I don’t), but have you considered something along these lines?:

    if accuracy >= minAccuracy:
        continueRoutine = False
        <name_of_your_inner_loop>.finished = True  # assuming you have an inner and an outer loop
        <name_of_your_outer_loop>.finished = True