Hi everyone,
I’m working on an experiment that requires typed responses from participants. I show participants pictures and then ask them questions about the pictures. The questions are in an input and I want the participants to be able to type their answers on the same page were the questions are presented.
I used the code below to add the responses to the question(also the text component on the builder view), and I can see the answers when I type them while running the experiments but the answers are not being saved in the data.
Does anyone know how can I fix that?
Code used:
Begin routine
cursorCounter=0
cursorVariable=’|’
captured_string=’’
subject_response_finished=False
trial_clock=core.Clock()
Each frame
if cursorCounter >= 30:
if cursorVariable==’|’:
cursorVariable=’ ’
else:
cursorVariable=’|’
cursorCounter=0
cursorCounter+=1
if trial_clock.getTime() >= 10:
subject_response_finished=True
if subject_response_finished:
final_response=captured_string
continueRoutine=False
for key in event.getKeys():
if key in [‘escape’]:
core.quit()
elif key in [‘delete’,‘backspace’]:
captured_string = captured_string[:-1]
elif key in [‘space’]:
captured_string = captured_string+’ ’
elif key in [‘period’]:
captured_string = captured_string+’.’
elif key in [‘comma’]:
captured_string = captured_string+’,’
elif key in [‘apostrophe’]:
captured_string = captured_string+"’"
elif key in [‘slash’]:
captured_string = captured_string+’/’
elif key in [‘minus’]:
captured_string = captured_string+’-’
elif key in [‘lshift’,‘rshift’,‘up’,‘down’,‘left’,‘right’,‘return’]:
pass
else:
captured_string = captured_string+key