Building Operation Span Task- Ending experiment early if low accuracy

Hi Everyone,

Looking for help regarding an operation span task and sorting out a conditional loop with the aim to put it up on Pavlovia.

I’ve taken one from Pavlovia- J. Kirkwood’s and modified it a bit to get it to run a bit smoother and tidy up the data file. The key element I can’t seem to sort is conditionally ending the experiment.

In the experiment, gitlab here (excuse the mess of the folder) participants run through the 3 span operation task where they see a math problem, give an answer, then a letter. after 3 problems & 3 letters, they complete a recall task and it gives them an average of how many math problems they got right.

What I’m trying to do is create an average across all 3 trials for this, and if it’s below 85%, the experiment ends. If they are over 85, they move onto 4 span, and so on, the process repeats until they fail to get 85%, or the experiment ends naturally.

I’ve seemingly calculated accuracy across the inner loop, what I can’t seem to get my head around is how to check at the end of 3 trials of the outer loop see if the average across the 3 inner loops is <85 and if it is, end the experiment before they move onto 4 span. Then at four span it will check it after 12 trials, 5 at 15, etc,

Anyone with any insight on this? Spent 2 days so far and I don’t know if it’s just sleep deprivation but nothing is working. I will be eternally grateful!