Actually I think I have a solution for this. Let’s see what you and the others think. This is kind of quick and dirty, I’m trying to keep it simple and keep it in the builder.
My solution was to create a dictionary at the beginning of the experiment that will keep track of number of times correct for each word. Words aren’t removed from the loop, rather if their score is 2 then the stimulus will not be presented. Lines for skipped items will still appear in your data output file, but with a response value of “LEARNED” so they can be easily filtered out later. Again, I’m thinking this may be a worthwhile price to pay for simplicity.
The next problem is that we don’t know how many times the loop will have to go through, (we would like a ‘while’ loop but psychopy will generate a ‘for’ loop). My solution was to set a ridiculously high number of loops (like a thousand or a million) but then break the loop when all words have a score of 2 (by setting .finished = True on the loop). An imperfect but simple solution.
In my examples below, I’m only going to include the code that’s relevant to this question. The complete code can be found in the file I’m attaching here.
This has two routines: trial and feedback. Here’s the code component for ‘trial’:
Begin experiment
# make a dictionary to hold scores for stimulus texts
# It will look like this (though instead of 'word1', it will
# be your stimulus text, I'm assuming they only
# appear once in your conditions file):
# scoreDict = {
# 'word1': 0,
# 'word2': 1, # after having gotten one right
# ...etc. }
scoreDict = {}
allData = data.importConditions(u'innerConditions.xlsx')
for dl in allData:
scoreDict[dl[u'stimText']] = 0
Begin routine
# This alreadyLearned variable will be
# used in the Feedback routine to determine
# whether or not feedback should be shown.
alreadyLearned = False
if scoreDict[stimText] >= 2:
continueRoutine = False
alreadyLearned = True
End Routine
if alreadyLearned:
block_1_loop.addData('response', 'LEARNED')
block_1_loop.addData('correct', 'LEARNED')
elif key_resp_1.keys == list(corrResp):
# increment the score for this word by 1
scoreDict[stimText] += 1
else:
# the rest of your code
# Loop through score dictionary, if any
# has a score less than two, break the loop
# and continue with the experiment.
haveTrialsLeft = False
for st in scoreDict:
if scoreDict[st] < 2:
haveTrialsLeft = True
break
if not haveTrialsLeft:
# All have a score of two, stop the loop
block_1_loop.finished = True
In the ‘feedback’ routine, I added a code component:
Begin routine
# this variable was set earlier
if alreadyLearned:
# don't show the feedback routine
continueRoutine = False
Here’s the experiment and conditions file. Let’s see what you all think.
innerConditions.xlsx (4.8 KB)
criterion2.psyexp (11.7 KB)