Millisecond Forums

Survey Branching Issue

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

By Michael Y - 11/26/2020

Hey everyone,

I'm having some issues with some branching code. I found this forum post somewhat related to my issue: https://www.millisecond.com/forums/Topic20629.aspx
I'm attempting to make a series of questions for a number of different classrooms (126 to 131). The first question asks which classroom the participant belongs to. Based on their answer I want the program to take the participant to a questionnaire specific to that class. So there are 6 different branches.

For some reason, I'm unable to get my code to branch to the questions after the initial Class question. I'll put my code below:
---------------
<block RCPBLOCK>
/ trials = [1=classselect]
</block>

<surveypage Classselect>
/questions = [1=class2]
/fontstyle=("Arial", 2%, false, false, false, false, 5, 0)
/ branch = [if(radiobuttons.Class2.response=="126b")survey.homeroom126]
/ branch = [if(radiobuttons.Class2.response=="127b")survey.homeroom127]
/ branch = [if(radiobuttons.Class2.response=="128b")survey.homeroom128]
/ branch = [if(radiobuttons.Class2.response=="129b")survey.homeroom129]
/ branch = [if(radiobuttons.Class2.response=="130b")survey.homeroom130]
/ branch = [if(radiobuttons.Class2.response=="131b")survey.homeroom131]
/showpagenumbers = false
/showquestionnumbers = false
/ navigationbuttonsize=(10, 5)
/ navigationbuttonfontstyle=("Arial", 5%, true, false)
/finishlabel="Next"
</surveypage>

<radiobuttons Class2>
/ caption="Which class are you in?"
/ options=("126b","127b","128b","129b","130b","131b")
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 0)
/ responsefontstyle =("Arial", 3.5%, false, false, false, false, 5, 0)
/ position=(10,15)
/required=true
</radiobuttons>

<survey homeroom126>
/ pages=[1=HOME1; 2=HOME2; 3=HOME3; 4=HOME4; 5=HOME5; 6=HOME6; 7=HOME7; 8=HOME8; 9=HOME9; 10=HOME10; 11=HOME11; 12=HOME12; 13=HOME13; 14=HOME14; 15=HOME15; 16=HOME16; 17=HOME17]
/ backlabel="Back"
/ nextlabel="Next"
/ finishlabel="Next"
/ fontstyle=("Arial", 3%, false, false, false, false, 5, 0)
/ responsefontstyle=("Arial", 3%, false, false, false, false, 5, 0)
/ itemfontstyle=("Arial", 3%, false, false, false, false, 5, 0)
/ showpagenumbers=false
/ showquestionnumbers=false
/ backbuttonposition=(35, 90)
/ nextbuttonposition=(70, 90)
/ navigationbuttonsize=(10, 5)
/ navigationbuttonfontstyle=("Arial", 5%, true, false)
/ recorddata = true
</survey>

<surveypage home1>
/caption="Choose as many as you want."
/fontstyle=("Arial", 3%, false, false, false, false, 5, 0)
/questions=[1=hr1]
/showpagenumbers = false
/showquestionnumbers = false
/ navigationbuttonsize=(10, 5)
/ navigationbuttonfontstyle=("Arial", 5%, true, false)
/finishlabel="Next"
</surveypage>

<checkboxes hr1>
/caption="Who does well in school?"
/options=("I can't think of anybody", "My friend is not listed", "Don't want to answer", "Name Placeholder")
/optionvalues=("-77", "-88", "-99", "1")
/required=true
</checkboxes>

--------
(There are 17 questions in all, HOME1-17)
(There are also the surveys for 127-131 and beyond but it is the same besides some renamed checkboxes/names!)

Any help on why Class2 doesn't branch to the survey as coded would be very helpful. I'm unsure what I'm doing wrong here! Thank you ahead of time!
By Dave - 11/27/2020

Michael Y - 11/27/2020
Hey everyone,

I'm having some issues with some branching code. I found this forum post somewhat related to my issue: https://www.millisecond.com/forums/Topic20629.aspx
I'm attempting to make a series of questions for a number of different classrooms (126 to 131). The first question asks which classroom the participant belongs to. Based on their answer I want the program to take the participant to a questionnaire specific to that class. So there are 6 different branches.

For some reason, I'm unable to get my code to branch to the questions after the initial Class question. I'll put my code below:
---------------
<block RCPBLOCK>
/ trials = [1=classselect]
</block>

<surveypage Classselect>
/questions = [1=class2]
/fontstyle=("Arial", 2%, false, false, false, false, 5, 0)
/ branch = [if(radiobuttons.Class2.response=="126b")survey.homeroom126]
/ branch = [if(radiobuttons.Class2.response=="127b")survey.homeroom127]
/ branch = [if(radiobuttons.Class2.response=="128b")survey.homeroom128]
/ branch = [if(radiobuttons.Class2.response=="129b")survey.homeroom129]
/ branch = [if(radiobuttons.Class2.response=="130b")survey.homeroom130]
/ branch = [if(radiobuttons.Class2.response=="131b")survey.homeroom131]
/showpagenumbers = false
/showquestionnumbers = false
/ navigationbuttonsize=(10, 5)
/ navigationbuttonfontstyle=("Arial", 5%, true, false)
/finishlabel="Next"
</surveypage>

<radiobuttons Class2>
/ caption="Which class are you in?"
/ options=("126b","127b","128b","129b","130b","131b")
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 0)
/ responsefontstyle =("Arial", 3.5%, false, false, false, false, 5, 0)
/ position=(10,15)
/required=true
</radiobuttons>

<survey homeroom126>
/ pages=[1=HOME1; 2=HOME2; 3=HOME3; 4=HOME4; 5=HOME5; 6=HOME6; 7=HOME7; 8=HOME8; 9=HOME9; 10=HOME10; 11=HOME11; 12=HOME12; 13=HOME13; 14=HOME14; 15=HOME15; 16=HOME16; 17=HOME17]
/ backlabel="Back"
/ nextlabel="Next"
/ finishlabel="Next"
/ fontstyle=("Arial", 3%, false, false, false, false, 5, 0)
/ responsefontstyle=("Arial", 3%, false, false, false, false, 5, 0)
/ itemfontstyle=("Arial", 3%, false, false, false, false, 5, 0)
/ showpagenumbers=false
/ showquestionnumbers=false
/ backbuttonposition=(35, 90)
/ nextbuttonposition=(70, 90)
/ navigationbuttonsize=(10, 5)
/ navigationbuttonfontstyle=("Arial", 5%, true, false)
/ recorddata = true
</survey>

<surveypage home1>
/caption="Choose as many as you want."
/fontstyle=("Arial", 3%, false, false, false, false, 5, 0)
/questions=[1=hr1]
/showpagenumbers = false
/showquestionnumbers = false
/ navigationbuttonsize=(10, 5)
/ navigationbuttonfontstyle=("Arial", 5%, true, false)
/finishlabel="Next"
</surveypage>

<checkboxes hr1>
/caption="Who does well in school?"
/options=("I can't think of anybody", "My friend is not listed", "Don't want to answer", "Name Placeholder")
/optionvalues=("-77", "-88", "-99", "1")
/required=true
</checkboxes>

--------
(There are 17 questions in all, HOME1-17)
(There are also the surveys for 127-131 and beyond but it is the same besides some renamed checkboxes/names!)

Any help on why Class2 doesn't branch to the survey as coded would be very helpful. I'm unsure what I'm doing wrong here! Thank you ahead of time!

Your branches reside at the wrong level. A surveypage cannot branch to a survey. A surveypage can only branch to another surveypage. You need to move the branches up to the block-level. (A surveypage is a kind of trial, a survey is a kind of block.)

<expt>
/ blocks = [1=RCPBLOCK]
</expt>

<block RCPBLOCK>
/ trials = [1=classselect]
/ branch = [if(radiobuttons.Class2.response=="126b")survey.homeroom126]
/ branch = [if(radiobuttons.Class2.response=="127b")survey.homeroom127]
/ branch = [if(radiobuttons.Class2.response=="128b")survey.homeroom128]
/ branch = [if(radiobuttons.Class2.response=="129b")survey.homeroom129]
/ branch = [if(radiobuttons.Class2.response=="130b")survey.homeroom130]
/ branch = [if(radiobuttons.Class2.response=="131b")survey.homeroom131]
</block>

<surveypage Classselect>
/questions = [1=class2]
/fontstyle=("Arial", 2%, false, false, false, false, 5, 0)
/showpagenumbers = false
/showquestionnumbers = false
/ navigationbuttonsize=(10, 5)
/ navigationbuttonfontstyle=("Arial", 5%, true, false)
/finishlabel="Next"
</surveypage>

<radiobuttons Class2>
/ caption="Which class are you in?"
/ options=("126b","127b","128b","129b","130b","131b")
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 0)
/ responsefontstyle =("Arial", 3.5%, false, false, false, false, 5, 0)
/ position=(10,15)
/required=true
</radiobuttons>
By Michael Y - 11/27/2020

This did the trick perfectly! I knew it had to be a small mistake somewhere.
Thanks a ton!