Millisecond Forums

Showing picture conditional on text answer

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

By JuliaNo - 6/24/2017

Hey Dave,

I can't figure out how to show a picture stimulus dependent on a text anwer. So in the experiment people are asked which country they are from and they can click on the answer and then they get feedback on a new trial ("You have indicated that you are from Country xy" with a flag). In the code I wrote so far people always see the same flag. I tried making different trials and using the branch attribute to show them dependent on the answer before but that somehow didn't work.

I post the whole  code below, bascially what I need is that in trial CountryConfirmation one of the stimulusframes would be GermanFlagIni if they had chosen German, and PortugalFlagIni if they had chosen Portuguese in trial LanguagePickDual2.

------ code ------

<trial LanguagePickDual2>
/ stimulusframes = [1=languageQuestionDual2, EuropeMap, OtherCountryDual, German, Portuguese]
/ inputdevice = mouse
/ validresponse = ("OtherCountryDual", "German", "Portuguese")
</trial>

<text languageQuestionDual2>
/items = ("Within Europe, please indicate where you are from.")
/position = (50,12)
</text>

<picture EuropeMap>
/ items = ("EuropeMap.png")
/ position = (50, 58)
/ size = (75%, 75%)
</picture>

<picture German>
/ items = ("Flag_of_Germany.png")
/ position = (43.2, 54)
/ size = (5.5%, 5.5%)
</picture>

<picture Portuguese>
/ items = ("Flag_of_Portugal.png")
/ position = (23.5, 79)
/ size = (5.5%, 5.5%)
</picture>

<text OtherCountryDual>
/items = ("I am from another country")
/position = (50,95)
</text>

<picture GermanFlagIni>
/ items = ("Flag_of_Germany.png")
/ position = (56.5, 63)
/ size = (9%, 9%)
</picture>

<picture PortugalFlagIni>
/ items = ("Flag_of_Portugal.png")
/ position = (56.5, 63)
/ size = (9%, 9%)
</picture>

<picture EUFlagIni>
/ items = ("Flag_of_EU.png")
/ position = (44.5, 63)
/ size = (9%, 9%)
</picture>

<trial CountryConfirmation>
/ stimulusframes = [1=Confirmation, ClickToContinue, GermanFlagIni, EUFlagIni]
/ inputdevice = mouse
/ validresponse = ("ClickToContinue")
</trial>

<text Confirmation>
/items = ("You have indicated that you are ~n
   European and <% trial.LanguagePickDual2.response %>")
/position = (50,45)
/fontstyle = ("Calibri", 5.00%, false, false, false, false, 5, 1)
</text>

<text ClickToContinue>
/ items = ("Click here to continue")
/ position = (50,80)
/ txbgcolor = grey)
/ fontstyle = ("Calibri", 2.08%, false, true, false, false, 5, 1)
</text>

<block LanguagepickDual>
/trials = [1=LanguagePickDual2, CountryConfirmation]
</block>
By Dave - 6/26/2017

JuliaNo - Sunday, June 25, 2017
Hey Dave,

I can't figure out how to show a picture stimulus dependent on a text anwer. So in the experiment people are asked which country they are from and they can click on the answer and then they get feedback on a new trial ("You have indicated that you are from Country xy" with a flag). In the code I wrote so far people always see the same flag. I tried making different trials and using the branch attribute to show them dependent on the answer before but that somehow didn't work.

I post the whole  code below, bascially what I need is that in trial CountryConfirmation one of the stimulusframes would be GermanFlagIni if they had chosen German, and PortugalFlagIni if they had chosen Portuguese in trial LanguagePickDual2.

------ code ------

<trial LanguagePickDual2>
/ stimulusframes = [1=languageQuestionDual2, EuropeMap, OtherCountryDual, German, Portuguese]
/ inputdevice = mouse
/ validresponse = ("OtherCountryDual", "German", "Portuguese")
</trial>

<text languageQuestionDual2>
/items = ("Within Europe, please indicate where you are from.")
/position = (50,12)
</text>

<picture EuropeMap>
/ items = ("EuropeMap.png")
/ position = (50, 58)
/ size = (75%, 75%)
</picture>

<picture German>
/ items = ("Flag_of_Germany.png")
/ position = (43.2, 54)
/ size = (5.5%, 5.5%)
</picture>

<picture Portuguese>
/ items = ("Flag_of_Portugal.png")
/ position = (23.5, 79)
/ size = (5.5%, 5.5%)
</picture>

<text OtherCountryDual>
/items = ("I am from another country")
/position = (50,95)
</text>

<picture GermanFlagIni>
/ items = ("Flag_of_Germany.png")
/ position = (56.5, 63)
/ size = (9%, 9%)
</picture>

<picture PortugalFlagIni>
/ items = ("Flag_of_Portugal.png")
/ position = (56.5, 63)
/ size = (9%, 9%)
</picture>

<picture EUFlagIni>
/ items = ("Flag_of_EU.png")
/ position = (44.5, 63)
/ size = (9%, 9%)
</picture>

<trial CountryConfirmation>
/ stimulusframes = [1=Confirmation, ClickToContinue, GermanFlagIni, EUFlagIni]
/ inputdevice = mouse
/ validresponse = ("ClickToContinue")
</trial>

<text Confirmation>
/items = ("You have indicated that you are ~n
   European and <% trial.LanguagePickDual2.response %>")
/position = (50,45)
/fontstyle = ("Calibri", 5.00%, false, false, false, false, 5, 1)
</text>

<text ClickToContinue>
/ items = ("Click here to continue")
/ position = (50,80)
/ txbgcolor = grey)
/ fontstyle = ("Calibri", 2.08%, false, true, false, false, 5, 1)
</text>

<block LanguagepickDual>
/trials = [1=LanguagePickDual2, CountryConfirmation]
</block>

Set up a single <picture> element with the three flag images as its items.

<picture Flagini>
/ items = ("Flag_of_Germany.png", "Flag_of_Portugal.png", "Flag_of_EU.png")
/ select = values.flagitem
/ position = (56.5, 63)
/ size = (9%, 9%)
</picture>

<values>
/ flagitem = 3
</values>

Set the value to the item corresponding to the given response /ontrialend

<trial LanguagePickDual2>
/ ontrialend = [if (trial.LanguagePickDual2.response == "German") values.flagitem = 1;
    if (trial.languagepickdual2.response == "Portuguese") values.flagitem = 2;
]
/ stimulusframes = [1=languageQuestionDual2, EuropeMap, OtherCountryDual, German, Portuguese]
/ inputdevice = mouse
/ validresponse = ("OtherCountryDual", "German", "Portuguese")
</trial>

Display the flag picture.

<trial CountryConfirmation>
/ stimulusframes = [1=Confirmation, ClickToContinue, FlagIni]
/ inputdevice = mouse
/ validresponse = ("ClickToContinue")
</trial>