Millisecond Forums

surveypage if statement branching not working if there's a new line in the question answer

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

By nrouhani - 12/6/2017

hello, 

i've created a surveypage where you have to click on the right answer to move to the next page, but if i insert a new line into the correct answer (as well as to the if statement), it no longer registers as correct. do you know what i could do to make this work while including a new line within the question answer? 

for example: 
<surveypage questions>
/ caption = "Before starting the experiment, please answer the following questions and click submit. Once you've answered all questions correctly, the task will automatically load. If you do not answer correctly, you will see the instructions again."
/ fontstyle = ("Arial", 30)
/ txcolor = white
/ showquestionnumbers = false
/ questions = [1=question1; 2=question2; 3=question3]
/ branch = [
if (radiobuttons.question1.response=="c) the value of each image is determined by the average value of images within that room,~n and this average can change") surveypage.success else surveypage.fail
]
</surveypage>

<radiobuttons question1>
/ caption = "Which statement is true about the values of the images in each room?"
/ options = ("a) the value of each image is dependent on its quality", "b) the value of each image is determined by the average value of images within that room, and this average
doesn't change", "c) the value of each image is determined by the average value of images within that room,~n and this average can change")
</radiobuttons>

By Dave - 12/6/2017

nrouhani - Wednesday, December 6, 2017
hello, 

i've created a surveypage where you have to click on the right answer to move to the next page, but if i insert a new line into the correct answer (as well as to the if statement), it no longer registers as correct. do you know what i could do to make this work while including a new line within the question answer? 

for example: 
<surveypage questions>
/ caption = "Before starting the experiment, please answer the following questions and click submit. Once you've answered all questions correctly, the task will automatically load. If you do not answer correctly, you will see the instructions again."
/ fontstyle = ("Arial", 30)
/ txcolor = white
/ showquestionnumbers = false
/ questions = [1=question1; 2=question2; 3=question3]
/ branch = [
if (radiobuttons.question1.response=="c) the value of each image is determined by the average value of images within that room,~n and this average can change") surveypage.success else surveypage.fail
]
</surveypage>

<radiobuttons question1>
/ caption = "Which statement is true about the values of the images in each room?"
/ options = ("a) the value of each image is dependent on its quality", "b) the value of each image is determined by the average value of images within that room, and this average
doesn't change", "c) the value of each image is determined by the average value of images within that room,~n and this average can change")
</radiobuttons>


The best way is to define /optionvalues in your <radiobuttons> that do not contain the new line / line break, and base the /branch on that:

<radiobuttons question1>
/ caption = "Which statement is true about the values of the images in each room?"
/ options = ("a) the value of each image is dependent on its quality", "b) the value of each image is determined by the average value of images within that room, and this average
doesn't change", "c) the value of each image is determined by the average value of images within that room,~n and this average can change")
/ optionvalues = ("a", "b", "c")
</radiobuttons>

with

<surveypage questions>
...
/ questions = [1=question1; 2=question2; 3=question3]
/ branch = [
if (radiobuttons.question1.response=="c") surveypage.success else surveypage.fail
]
</surveypage>