Hey all,
I am trying to figure out a code for my experiment and can’t seem to get it right. In the experiment, participants are asked if they want to study an item again and told to press “y” for yes and “n” for no. Later in the experiment, I need to give the participant the opportunity to study the questions that they answered “y” to. I have gotten my loop to read from an excel file that is created during the experiment, so it knows which questions were answered “y” to and which ones have “n”. My issue is that it displays all items, regardless of the answer. What I want to know is, how can I get it to only display questions that were given a “y” answer? Here is the code I have tried so far.
set up handler to look after randomisation of conditions etc
trials = data.TrialHandler(nReps=1, method=‘random’,
extraInfo=expInfo, originPath=None,
trialList=data.importConditions(filename + ‘.xlsx’),
seed=None, name=‘trials’)
thisExp.addLoop(trials) # add the loop to the experiment
thisTrial = trials.trialList[0] # so we can initialise stimuli with some values
abbreviate parameter names if possible (e.g. rgb=thisTrial.rgb)
if thisTrial != None:
for paramName in thisTrial.keys():
exec(paramName + ‘= thisTrial.’ + paramName)
for thisTrial in trials:
currentLoop = trials
# abbreviate parameter names if possible (e.g. rgb = thisTrial.rgb)
if thisTrial != None:
for paramName in thisTrial.keys():
exec(paramName + ‘= thisTrial.’ + paramName)
#------Prepare to start Routine "Study_3"-------
t = 0
Study_3Clock.reset() # clock
frameN = -1
# update component parameters for each repeat
if key_resp_4keys_raw == ‘y’: #this is the code that I have tried. key_resp_4keys_raw is what the column is in excel.
text_6.setText(question)
text_7.setText(corrAns)
elif key_resp_4keys_raw ==‘n’:
text_6.setText()
text_7.setText()
key_resp_7 = event.BuilderKeyResponse() # create an object of type KeyResponse
key_resp_7.status = NOT_STARTED
# keep track of which components have finished
Study_3Components = []
Study_3Components.append(text_6)
Study_3Components.append(text_7)
Study_3Components.append(text_8)
Study_3Components.append(key_resp_7)
for thisComponent in Study_3Components:
if hasattr(thisComponent, ‘status’):
thisComponent.status = NOT_STARTED
Thanks!