Millisecond Forums

error message by the response sum of multiple textbox questions

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

By SWIECHE - 10/18/2022

Hi,
I am trying to construct a surveypage in which participants receive multiple answer options per question and have to bet probability points on each answer option ("how likely the response is"). I want them to place probability points across three options with 100 points in total.
I was trying to construct it in a way that if the sum of the points across the three options differ from 100, they get an error message. However, this code is not working. I am attaching it below.

<textbox before>
/ caption = "before"
/ range = (0,100)
/ required = true
/ position = (10%, 15%)
/ mask = positiveinteger
</textbox>

<textbox during>
/ caption = "during"
/ range = (0,100)
/ required = true
/ position = (40%, 15%)
/ mask = positiveinteger
</textbox>

<textbox after>
/ caption = "after"
/ range = (0,100)
/ required = true
/ position = (70%, 15%)
/ mask = positiveinteger
</textbox>

<text error>
/ items = ("This does not add up to 100!")
/ position = (49%, 50%)
/ fontstyle = ("Arial", 5%, true, false, false, false, 5, 1)
/ vjustify = center
</text>

<trial error>
/ stimulusframes = [1= error]
/ timeout = 1000
</trial>

<surveypage pg01>
/ questions = [1=before; 2=during; 3=after]
/ caption = "When was it?"
/ showquestionnumbers = false
/ showpagenumbers = false
/ branch = [
  if ((textbox.before.response + textbox.after.response + textbox.during.response) != 100) {
   trial.error
  }
]
</surveypage>

I would greatly appreciate any help on this matter. Thanks in advance

By Dave - 10/18/2022

SWIECHE - 10/18/2022
Hi,
I am trying to construct a surveypage in which participants receive multiple answer options per question and have to bet probability points on each answer option ("how likely the response is"). I want them to place probability points across three options with 100 points in total.
I was trying to construct it in a way that if the sum of the points across the three options differ from 100, they get an error message. However, this code is not working. I am attaching it below.

<textbox before>
/ caption = "before"
/ range = (0,100)
/ required = true
/ position = (10%, 15%)
/ mask = positiveinteger
</textbox>

<textbox during>
/ caption = "during"
/ range = (0,100)
/ required = true
/ position = (40%, 15%)
/ mask = positiveinteger
</textbox>

<textbox after>
/ caption = "after"
/ range = (0,100)
/ required = true
/ position = (70%, 15%)
/ mask = positiveinteger
</textbox>

<text error>
/ items = ("This does not add up to 100!")
/ position = (49%, 50%)
/ fontstyle = ("Arial", 5%, true, false, false, false, 5, 1)
/ vjustify = center
</text>

<trial error>
/ stimulusframes = [1= error]
/ timeout = 1000
</trial>

<surveypage pg01>
/ questions = [1=before; 2=during; 3=after]
/ caption = "When was it?"
/ showquestionnumbers = false
/ showpagenumbers = false
/ branch = [
  if ((textbox.before.response + textbox.after.response + textbox.during.response) != 100) {
   trial.error
  }
]
</surveypage>

I would greatly appreciate any help on this matter. Thanks in advance


<textbox before>
/ caption = "before"
/ range = (0,100)
/ required = true
/ position = (10%, 15%)
/ mask = positiveinteger
</textbox>

<textbox during>
/ caption = "during"
/ range = (0,100)
/ required = true
/ position = (40%, 15%)
/ mask = positiveinteger
</textbox>

<textbox after>
/ caption = "after"
/ range = (0,100)
/ required = true
/ position = (70%, 15%)
/ mask = positiveinteger
</textbox>

<text error>
/ items = ("This does not add up to 100!")
/ position = (49%, 50%)
/ fontstyle = ("Arial", 5%, true, false, false, false, 5, 1)
/ vjustify = center
</text>

<trial error>
/ stimulusframes = [1= error]
/ timeout = 1000
/ branch = [
    surveypage.pg01;
]
</trial>

<surveypage pg01>
/ questions = [1=before; 2=during; 3=after]
/ caption = "When was it?"
/ showquestionnumbers = false
/ showpagenumbers = false
/ branch = [
if ((textbox.before.response + textbox.after.response + textbox.during.response) != 100) {
 trial.error
}
]
</surveypage>

<block example>
/ trials = [1=pg01]
</block>


It's working just fine. Note that you need to at least define a block, a branch cannot be executed outside the context of a block.