psychopy.org | Reference | Downloads | Github

Repeat incorrect trials until correct

OS: MacOS 10.15.4
PsychoPy version (e.g. 1.84.x): v2020.1.2

What are you trying to achieve?:
I am running a vocabulary familiarization task where participants are presented with one word at a time (total of 60 words) and must select the correct translation for each word (option of 4 translations per word). They must reach 100% accuracy (60 correct answers) before ending the trial. I would like for participants to repeat the words they translated incorrectly until they answer them correctly. Since I am storing the “last key”, once they reach 60 correct, the loop ends.

This is what I currently have, which repeats the loop until participants reach 60 correct answers, but it repeats all trials, not just the incorrect ones.


Screen Shot 2020-06-03 at 6.38.33 PM

In the CODING I have the following:
Begin experiment
number_correct = 0

End routine
if(key_resp.corr == 1):
number_correct = number_correct + 1

if(number_correct >= 60):
LoopTrial.finished = True

What did you try to make it work?:
I have already set it up so that 60 correct answers ends the trial, but I do not want participants to have to repeat words that they already answered correctly, just so they can redo the ones they answered incorrectly (which is the way it is currently set up). I have read other posts which recommended adding an outer loop around the trial and also adding a “row_ID” to my conditions file to more easily detect the incorrect trials. I tried something like this, but it did not achieve the desired result (I am new to PsychoPy so I’m figuring out the coding as I go along):

Begin routine:
if LoopOuter.thisN == 0 and LoopTrial.thisN == 0:
wrong_list =

if LoopOuter.thisN == 1:
if row_ID not in wrong_list:
continueRoutine = False

End routine:
if key_resp.corr:
number_correct = number_correct + 1

if LoopTrial.thisN + 1 == LoopTrial.nTotal:
if number_correct/(LoopTrial.nTotal) >= 1:
LoopOuter.finished = True

if LoopOuter.thisN == 0 and key_resp.corr == 0:
wrong_list.append(row_ID)

What specifically went wrong when you tried that?:
When I tried this, I received the message that row_ID is not defined. I’m not sure if the row_ID approach is the appropriate approach to repeat only incorrectly answered trials. Any assistance would be appreciated as I am completely new to this!