Accuracy Check and loop/routine skip

Hello Everyone,

I am trying to create a task where participants must decide if simple sentences are true or false. They do this in a practice round and are checked for accuracy before they either move on if they performed perfectly, or are forced to repeat the practice if they did not. I have created separate instructions and trials routines, and have used a loop inside a loop for the task, but no matter what the task seems to show the failure screen then repeat. I was hoping for some help making it skip the outer loop and routines in it if participants perform perfectly. Thanks!

Attached are pictures.

Hi @gageregier,

I think .nTotal represents the total number of trials a loop will run (based on PsychoPy’s docs). Your Accuracy_repeat line 5 (if number_correct/(PM_Practice_loop.nTotal+1) >= 1.0:), might always be false because of the +1. I would try removing that +1 and see if it makes a difference.

-shabkr

1 Like

It still takes me back through when I am 100% accurate unfortunately.

This won’t solve the behaviour, but you could add print statements to narrow down where the problem is, for example:

if PM_practice_response.corr:
  number_correct = number_correct + 1
  print(f'Num correct: {number_correct}') # is accuracy recording correctly?

if PM_Practice_loop.thisN +1 == PM_Practice_loop.nTotal:
   print("Finished a practice loop") # are thisN and nTotal matching when expected?
  if number_correct/(PM_Practice_loop.nTotal) >= 1.0:
    Accuracy_Check_Loop.finished = True
    print("Got the practice right") # are number_correct and nTotal matching when expected?
1 Like

Alright, so I got it to not do the outside loop, but it is still failing to skip the PM_Practice_Failure when accuracy is 100% and the loop is ending.

What ended up being the solution?

To skip PM_Practice_Failure, you would need a code component within that routine which sets continueRoutine=False if your Accuracy_Check_Loop is ending.

1 Like

what would the if look like? I seem to be doing it wrong somehow.

I got it! it works! thank you so much for your help!

1 Like

Awesome! If you post your solution code here, it might help someone with a similar problem in the future :slight_smile:
Good luck with the experiment!
-shabkr