Millisecond Forums

Append or remove file extension in response?

https://forums.millisecond.com/Topic19278.aspx

By gracethenoob - 6/20/2016

Hello,
I am programming an experiment in which the participant sees an image and must type in what they saw in. So far, I am able to record what exactly the participant saw (i.e., the stimulus item) but I don't want to require the participants to type in the file extension ".jpg" in order for the program to determine the correctness of the response. Is there a way to record the stimulus item without its file extension OR append the file extension to the participant response?

My code so far:

<picture target>
/items = ("eggplant.jpg",
"shorts.jpg",
"toydinosaur.jpg",
"swimgoggles.jpg")
/size = (25%, 25%)
</picture>

<trial stream_target>
/ontrialbegin = [list.fillers.reset();]
/stimulustimes = [0 = target; 500 = filler01; 1000 = filler02; 1500 = filler03]
/timeout = 2000
/ontrialend = [values.filler01 = list.fillers.nextvalue]
/ontrialend = [values.filler02 = list.fillers.nextvalue]
/ontrialend = [values.filler03 = list.fillers.nextvalue]
/ontrialend  = [values.target = picture.target.currentitem]
/branch = [openended.T1_question]
</trial>


<openended T1_question>
/stimulusframes = [1 = T1_question]
/recorddata = true
/iscorrectresponse = [openended.T1_question.response == values.target]
/monkeyresponse = ("eggplant.jpg", "shorts.jpg", "toydinosaur.jpg", "swimgoggles.jpg")
</openended>

By Dave - 6/20/2016

Sure, that's perfectly possible. You can either remove the extension or append it to the response using string functions. Options:

#1: To store the file name without the extension in values.target:
/ontrialend  = [values.target = (picture.target.currentitem, ".jpg", ""]

or

#2: Remove it inline when checking the response:
/iscorrectresponse = [openended.T1_question.response == replaceall(values.target, ".jpg", "")]

or

#3: Append extension to typed response:
/iscorrectresponse = [concat(openended.T1_question.response, ".jpg") == values.target]

Any one of those should work.

Hope this helps.