mlleng13
|
|
Group: Forum Members
Posts: 14,
Visits: 71
|
I would like to have an image selected based on participant input--specifically I want an image named with the participants last name to be selected based on the participants input for their last name. My primary concern is that the image will be named wrong or will the participant will make a typo by accident and the intended image will not be found and will force the experiment to quit. I would like to, if possible, have my script resort to a default image in the event that the participant-specific image is not found.
Does anyone have any thoughts or insight?
|
|
|
Dave
|
|
Group: Administrators
Posts: 13K,
Visits: 105K
|
+xI would like to have an image selected based on participant input--specifically I want an image named with the participants last name to be selected based on the participants input for their last name. My primary concern is that the image will be named wrong or will the participant will make a typo by accident and the intended image will not be found and will force the experiment to quit. I would like to, if possible, have my script resort to a default image in the event that the participant-specific image is not found. Does anyone have any thoughts or insight? You can achieve that like this: <item myitems> / 1 = "default.jpg" / 2 = "smith.jpg" / 3 = "miller.jpg" / 4 = "jones.jpg" </item> <picture mypicture> / items = myitems / select = 1 </picture> <values> / participantimagename = "" </values> <text allimagenames> / items = ("<%item.myitems.item.2%>,<%item.myitems.item.3%>,<%item.myitems.item.4%>") </text> <openended myopenended> / ontrialend = [ values.participantimagename = concat(tolower(openended.myopenended.response),".jpg"); if(contains(text.allimagenames.item.1, values.participantimagename)) picture.mypicture.item.1 = values.participantimagename] / stimulusframes = [1=mytext] / position = (50%, 60%) </openended> <text mytext> / items = ("Last name:") </text> <trial mytrial> / stimulusframes = [1=mypicture] / validresponse = (57) </trial> <block myblock> / trials = [1=myopenended; 2=mytrial] </block>
|
|
|
mlleng13
|
|
Group: Forum Members
Posts: 14,
Visits: 71
|
+x+xI would like to have an image selected based on participant input--specifically I want an image named with the participants last name to be selected based on the participants input for their last name. My primary concern is that the image will be named wrong or will the participant will make a typo by accident and the intended image will not be found and will force the experiment to quit. I would like to, if possible, have my script resort to a default image in the event that the participant-specific image is not found. Does anyone have any thoughts or insight? You can achieve that like this: <item myitems> / 1 = "default.jpg" / 2 = "smith.jpg" / 3 = "miller.jpg" / 4 = "jones.jpg" </item> <picture mypicture> / items = myitems / select = 1 </picture> <values> / participantimagename = "" </values> <text allimagenames> / items = ("<%item.myitems.item.2%>,<%item.myitems.item.3%>,<%item.myitems.item.4%>") </text> <openended myopenended> / ontrialend = [ values.participantimagename = concat(tolower(openended.myopenended.response),".jpg"); if(contains(text.allimagenames.item.1, values.participantimagename)) picture.mypicture.item.1 = values.participantimagename] / stimulusframes = [1=mytext] / position = (50%, 60%) </openended> <text mytext> / items = ("Last name:") </text> <trial mytrial> / stimulusframes = [1=mypicture] / validresponse = (57) </trial> <block myblock> / trials = [1=myopenended; 2=mytrial] </block> Dave, Thanks for the solution. Is there any way I could do this without having to update the code itself (i.e., avoid the myitems step all together). Ideally, I would like to limit the things I have to do with the images to simply making sure that the image is in the right format and in the right folder. For example, what I would do if I could guarantee that an error did not occur is something along the lines of: <values> /participantInput = "" </values> <textbox Lname> / caption = "Please enter your last name" / required = true / mask = alphabetic / position = (30%, 25%) </textbox> <surveypage name> / showquestionnumbers = false / questions = [1=Fname] / ontrialend = [values.participantinput = textbox.Lname.response] </surveypage> <picture participant> / items = "<%values.participantinput%>.jpg" / position = (50%, 75%) / size = (6%,10%) / valign = bottom / erase = false </picture> Based on my own tests, this will work as long as everything is spelled correctly, the image is in the containing folder, and the image is in the right format. The reason I don't want to have to update the script itself is because I wont know the participants early enough in advance to guarantee having enough time to update the script. Is there anyway to accomplish what I am talking about/is it clear what I am talking about? Thanks again.
|
|
|
Dave
|
|
Group: Administrators
Posts: 13K,
Visits: 105K
|
+x+x+xI would like to have an image selected based on participant input--specifically I want an image named with the participants last name to be selected based on the participants input for their last name. My primary concern is that the image will be named wrong or will the participant will make a typo by accident and the intended image will not be found and will force the experiment to quit. I would like to, if possible, have my script resort to a default image in the event that the participant-specific image is not found. Does anyone have any thoughts or insight? You can achieve that like this: <item myitems> / 1 = "default.jpg" / 2 = "smith.jpg" / 3 = "miller.jpg" / 4 = "jones.jpg" </item> <picture mypicture> / items = myitems / select = 1 </picture> <values> / participantimagename = "" </values> <text allimagenames> / items = ("<%item.myitems.item.2%>,<%item.myitems.item.3%>,<%item.myitems.item.4%>") </text> <openended myopenended> / ontrialend = [ values.participantimagename = concat(tolower(openended.myopenended.response),".jpg"); if(contains(text.allimagenames.item.1, values.participantimagename)) picture.mypicture.item.1 = values.participantimagename] / stimulusframes = [1=mytext] / position = (50%, 60%) </openended> <text mytext> / items = ("Last name:") </text> <trial mytrial> / stimulusframes = [1=mypicture] / validresponse = (57) </trial> <block myblock> / trials = [1=myopenended; 2=mytrial] </block> Dave, Thanks for the solution. Is there any way I could do this without having to update the code itself (i.e., avoid the myitems step all together). Ideally, I would like to limit the things I have to do with the images to simply making sure that the image is in the right format and in the right folder. For example, what I would do if I could guarantee that an error did not occur is something along the lines of: <values> /participantInput = "" </values> <textbox Lname> / caption = "Please enter your last name" / required = true / mask = alphabetic / position = (30%, 25%) </textbox> <surveypage name> / showquestionnumbers = false / questions = [1=Fname] / ontrialend = [values.participantinput = textbox.Lname.response] </surveypage> <picture participant> / items = "<%values.participantinput%>.jpg" / position = (50%, 75%) / size = (6%,10%) / valign = bottom / erase = false </picture> Based on my own tests, this will work as long as everything is spelled correctly, the image is in the containing folder, and the image is in the right format. The reason I don't want to have to update the script itself is because I wont know the participants early enough in advance to guarantee having enough time to update the script. Is there anyway to accomplish what I am talking about/is it clear what I am talking about? Thanks again. > Is there any way I could do this without having to update the code itself? No. If you want things to be fail-safe, you need to build in the necessary checks, and that means the script *must* know which images do and do not exist. Otherwise it has no way of preventing failure. Does this make sense?
|
|
|
Dave
|
|
Group: Administrators
Posts: 13K,
Visits: 105K
|
+x+x+x+xI would like to have an image selected based on participant input--specifically I want an image named with the participants last name to be selected based on the participants input for their last name. My primary concern is that the image will be named wrong or will the participant will make a typo by accident and the intended image will not be found and will force the experiment to quit. I would like to, if possible, have my script resort to a default image in the event that the participant-specific image is not found. Does anyone have any thoughts or insight? You can achieve that like this: <item myitems> / 1 = "default.jpg" / 2 = "smith.jpg" / 3 = "miller.jpg" / 4 = "jones.jpg" </item> <picture mypicture> / items = myitems / select = 1 </picture> <values> / participantimagename = "" </values> <text allimagenames> / items = ("<%item.myitems.item.2%>,<%item.myitems.item.3%>,<%item.myitems.item.4%>") </text> <openended myopenended> / ontrialend = [ values.participantimagename = concat(tolower(openended.myopenended.response),".jpg"); if(contains(text.allimagenames.item.1, values.participantimagename)) picture.mypicture.item.1 = values.participantimagename] / stimulusframes = [1=mytext] / position = (50%, 60%) </openended> <text mytext> / items = ("Last name:") </text> <trial mytrial> / stimulusframes = [1=mypicture] / validresponse = (57) </trial> <block myblock> / trials = [1=myopenended; 2=mytrial] </block> Dave, Thanks for the solution. Is there any way I could do this without having to update the code itself (i.e., avoid the myitems step all together). Ideally, I would like to limit the things I have to do with the images to simply making sure that the image is in the right format and in the right folder. For example, what I would do if I could guarantee that an error did not occur is something along the lines of: <values> /participantInput = "" </values> <textbox Lname> / caption = "Please enter your last name" / required = true / mask = alphabetic / position = (30%, 25%) </textbox> <surveypage name> / showquestionnumbers = false / questions = [1=Fname] / ontrialend = [values.participantinput = textbox.Lname.response] </surveypage> <picture participant> / items = "<%values.participantinput%>.jpg" / position = (50%, 75%) / size = (6%,10%) / valign = bottom / erase = false </picture> Based on my own tests, this will work as long as everything is spelled correctly, the image is in the containing folder, and the image is in the right format. The reason I don't want to have to update the script itself is because I wont know the participants early enough in advance to guarantee having enough time to update the script. Is there anyway to accomplish what I am talking about/is it clear what I am talking about? Thanks again. > Is there any way I could do this without having to update the code itself? No. If you want things to be fail-safe, you need to build in the necessary checks, and that means the script *must* know which images do and do not exist. Otherwise it has no way of preventing failure. Does this make sense? Quick idea: Prompt the participant to enter her/his last name twice and check if the two responses match; if they do not, repeat. While this will not be 100% fail-safe, it should reduce the risk of typos and potential associated failures significantly.
|
|
|
mlleng13
|
|
Group: Forum Members
Posts: 14,
Visits: 71
|
+x+x+x+x+xI would like to have an image selected based on participant input--specifically I want an image named with the participants last name to be selected based on the participants input for their last name. My primary concern is that the image will be named wrong or will the participant will make a typo by accident and the intended image will not be found and will force the experiment to quit. I would like to, if possible, have my script resort to a default image in the event that the participant-specific image is not found. Does anyone have any thoughts or insight? You can achieve that like this: <item myitems> / 1 = "default.jpg" / 2 = "smith.jpg" / 3 = "miller.jpg" / 4 = "jones.jpg" </item> <picture mypicture> / items = myitems / select = 1 </picture> <values> / participantimagename = "" </values> <text allimagenames> / items = ("<%item.myitems.item.2%>,<%item.myitems.item.3%>,<%item.myitems.item.4%>") </text> <openended myopenended> / ontrialend = [ values.participantimagename = concat(tolower(openended.myopenended.response),".jpg"); if(contains(text.allimagenames.item.1, values.participantimagename)) picture.mypicture.item.1 = values.participantimagename] / stimulusframes = [1=mytext] / position = (50%, 60%) </openended> <text mytext> / items = ("Last name:") </text> <trial mytrial> / stimulusframes = [1=mypicture] / validresponse = (57) </trial> <block myblock> / trials = [1=myopenended; 2=mytrial] </block> Dave, Thanks for the solution. Is there any way I could do this without having to update the code itself (i.e., avoid the myitems step all together). Ideally, I would like to limit the things I have to do with the images to simply making sure that the image is in the right format and in the right folder. For example, what I would do if I could guarantee that an error did not occur is something along the lines of: <values> /participantInput = "" </values> <textbox Lname> / caption = "Please enter your last name" / required = true / mask = alphabetic / position = (30%, 25%) </textbox> <surveypage name> / showquestionnumbers = false / questions = [1=Fname] / ontrialend = [values.participantinput = textbox.Lname.response] </surveypage> <picture participant> / items = "<%values.participantinput%>.jpg" / position = (50%, 75%) / size = (6%,10%) / valign = bottom / erase = false </picture> Based on my own tests, this will work as long as everything is spelled correctly, the image is in the containing folder, and the image is in the right format. The reason I don't want to have to update the script itself is because I wont know the participants early enough in advance to guarantee having enough time to update the script. Is there anyway to accomplish what I am talking about/is it clear what I am talking about? Thanks again. > Is there any way I could do this without having to update the code itself? No. If you want things to be fail-safe, you need to build in the necessary checks, and that means the script *must* know which images do and do not exist. Otherwise it has no way of preventing failure. Does this make sense? Quick idea: Prompt the participant to enter her/his last name twice and check if the two responses match; if they do not, repeat. While this will not be 100% fail-safe, it should reduce the risk of typos and potential associated failures significantly. Dave, Sorry for not posting this sooner, I have been pretty busy. I actually found that if you use the <include> element and simply use code similar to the following you can set a default without having to list every possible image. <values> /response = kip </values <item playerimage> / 1 = "<%values.response%>.png" / 2 = "kip.png" </item>
|
|
|