Millisecond Forums

How to prevent trial from moving on using incorrect response

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

By gondegoogoo - 11/2/2017

Hi, I'm trying to program a task that involves the participant inputting two integers that has to equate to 10. 
Since I couldn't write in two response options for one trial page, I've used two openended options.

<openended sunnyfarm>
/ buttonlabel = "Next"
/ mask = integer
/ charlimit = 2
/ range = (0,10)
/ position = (80%, 70%)
/ stimulustimes = [0=farm, sunny, seasoncount, sunnyweather, totalcreditfarm, totalcreditinsurance]
/ontrialend = [values.farmlatency = openended.sunnyfarm.latency]
/ ontrialend = [if (openended.sunnyfarm.trialcount <= values.totalseasons) values.seasoncount +=1]
/ ontrialend = [values.creditfarminput = openended.sunnyfarm.response]
/ branch = [openended.sunnyinsurance]
/ recorddata = true
</openended>

<openended sunnyinsurance>
/ buttonlabel = "End of Season"
/ mask = integer
/ charlimit = 2
/ range = (0,10)
/ position = (70%, 70%)
/ stimulustimes = [0=farm, sunny, sunnyweather, totalcreditfarm, totalcreditinsurance]
/ ontrialend = [values.insurancelatency = openended.sunnyinsurance.latency]
/ ontrialend = [values.creditinsuranceinput==openended.sunnyinsurance]
/ ontrialend = [values.creditinsuranceinput = openended.sunnyinsurance.response]
/ ontrialend = [if (values.creditinsuranceinput + values.creditfarminput ==10) values.totalcreditfarm += values.creditfarminput else]
/ ontrialend = [if (values.creditinsuranceinput + values.creditfarminput ==10) values.totalcreditinsurance += values.creditinsuranceinput]
/ branch = [trial.seasonfeedback]
/ recorddata = true
</openended>

My question is for / ontrialend = [if (values.creditinsuranceinput + values.creditfarminput ==10) values.totalcreditfarm += values.creditfarminput else]

If the total input values do not = 10, how do I get the trial to not accept the response so that it prompts the participant to reenter a correct value? Or is there a if/else statement I could use that introduces an error message? 

Alternatively, could I use an expression for /validresponse instead? 
if I had a appropriateinsuranceinput = (10-values.creditfarminput), can I put / validresponse = expressions.appropriateinsuranceinput? 

Thank you!
By Dave - 11/3/2017

gondegoogoo - Friday, November 3, 2017
Hi, I'm trying to program a task that involves the participant inputting two integers that has to equate to 10. 
Since I couldn't write in two response options for one trial page, I've used two openended options.

<openended sunnyfarm>
/ buttonlabel = "Next"
/ mask = integer
/ charlimit = 2
/ range = (0,10)
/ position = (80%, 70%)
/ stimulustimes = [0=farm, sunny, seasoncount, sunnyweather, totalcreditfarm, totalcreditinsurance]
/ontrialend = [values.farmlatency = openended.sunnyfarm.latency]
/ ontrialend = [if (openended.sunnyfarm.trialcount <= values.totalseasons) values.seasoncount +=1]
/ ontrialend = [values.creditfarminput = openended.sunnyfarm.response]
/ branch = [openended.sunnyinsurance]
/ recorddata = true
</openended>

<openended sunnyinsurance>
/ buttonlabel = "End of Season"
/ mask = integer
/ charlimit = 2
/ range = (0,10)
/ position = (70%, 70%)
/ stimulustimes = [0=farm, sunny, sunnyweather, totalcreditfarm, totalcreditinsurance]
/ ontrialend = [values.insurancelatency = openended.sunnyinsurance.latency]
/ ontrialend = [values.creditinsuranceinput==openended.sunnyinsurance]
/ ontrialend = [values.creditinsuranceinput = openended.sunnyinsurance.response]
/ ontrialend = [if (values.creditinsuranceinput + values.creditfarminput ==10) values.totalcreditfarm += values.creditfarminput else]
/ ontrialend = [if (values.creditinsuranceinput + values.creditfarminput ==10) values.totalcreditinsurance += values.creditinsuranceinput]
/ branch = [trial.seasonfeedback]
/ recorddata = true
</openended>

My question is for / ontrialend = [if (values.creditinsuranceinput + values.creditfarminput ==10) values.totalcreditfarm += values.creditfarminput else]

If the total input values do not = 10, how do I get the trial to not accept the response so that it prompts the participant to reenter a correct value? Or is there a if/else statement I could use that introduces an error message? 

Alternatively, could I use an expression for /validresponse instead? 
if I had a appropriateinsuranceinput = (10-values.creditfarminput), can I put / validresponse = expressions.appropriateinsuranceinput? 

Thank you!

You should not use /ontrialend, but /isvalidresponse to perform the check, as in

<openended a>
/ buttonlabel = "Next"
/ mask = integer
/ charlimit = 2
/ range = (0,10)
/ branch = [
    openended.b
]
</openended>

<openended b>
/ buttonlabel = "End of Season"
/ mask = integer
/ charlimit = 2
/ range = (0,10)
/ isvalidresponse = [
    openended.a.response + openended.b.response == 10
]

</openended>

<block myblock>
/ trials = [1-2 = a]
</block>