Millisecond Forums

Designing a Yes/No Questionnaire Where Answering Yes Immediately Leads to 3 Additional Questions

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

By cindy1358 - 10/25/2016

Hi everyone! I am new to Inquisit and I am trying to design a questionnaire where all 21 of my questions have yes/no radiobuttons as the answers and for each question, answering yes leads to 3 additional follow-up questions that must be answered using radiobuttons (whereas answering no means that those 3 questions are not needed). So is there a way to make those 3 questions appear on the same page only when someone answers "yes" and not when he/she answers "no"? I am looking into the branch attribute but the branching only seems to only apply to a trial/block as an event and not a radiobutton. Thanks in advance! 
By Dave - 10/25/2016

Yes. From the <surveypage> containing the 1st yes/no question, you /branch to a <surveypage> containing the 3 follow-up questions if the answer is yes. In a nutshell:

<block myblock>
/ trials = [1-2 = noreplace(q1, q2)]
</block>

//q1
<surveypage q1>
/ questions = [1=q1_rb]
/ branch = [if (radiobuttons.q1_rb.response=="Yes") surveypage.q1_followup]
</surveypage>

<radiobuttons q1_rb>
/ caption = "Q1"
/ options = ("Yes", "No")
</radiobuttons>

//follow-up qs for q1
<surveypage q1_followup>
/ caption = "Put your Q1 follow-up questions here"
</surveypage>

//q2
<surveypage q2>
/ questions = [1=q2_rb]
/ branch = [if (radiobuttons.q2_rb.response=="Yes") surveypage.q2_followup]
</surveypage>

<radiobuttons q2_rb>
/ caption = "Q2"
/ options = ("Yes", "No")
</radiobuttons>

//follow-up qs for q2
<surveypage q2_followup>
/ caption = "Put your Q2 follow-up questions here"
</surveypage>


Hope this helps.
By cindy1358 - 10/25/2016

Hi Dave! First of all, thank you so much for your speedy response! Secondly, I was wondering if there's a way for the followup questions to appear on the same surveypage? Or would they have to be on a separate surveypage because the spacing for the second question would be problematic and because branching only applies at the surveypage level? 
By Dave - 10/25/2016

> I was wondering if there's a way for the followup questions to appear on the same surveypage.

No. The follow-up questions for Q(n) cannot reside on the same <surveypage> as Q(n).

> Or would they have to be on a separate surveypage [...] because branching only applies at the surveypage level?

Yes, you are precisely correct here. Branching works at the surveypage level, not at the level of individual questions.

Hope this clarifies.
By cindy1358 - 10/25/2016

Thanks again, Dave! I am now having trouble combining multiple questions into a survey. When I try to validate my script, it says "Validation failed. The script contains errors.". However, the script runs fine when I only have 1 question and its followup questions on a second surveypage. Would you be able to take a look at my script to see what's wrong? I've copied and pasted my script for 2 questions. Thank you so much!

<surveypage PDI1>
/caption ="<%values.title%>"
/subcaption = "<%values.instructions%>"
/subcaptionfontstyle = ("Arial", 2%, false, false, false, false, 5, 0)
/showquestionnumbers = true
/showpagenumbers = false
/questions = [1 = q1]
/branch = [if (radiobuttons.q1.response == "Yes") surveypage.PDI1_fu
else surveypage.PDI2]
/ ontrialend = [if (radiobuttons.q1.response == "No") {values.q1D = 0; values.q1P = 0; values.q1C = 0;}]
</surveypage>

<surveypage PDI1_fu>
/caption ="<%values.title%>"
/subcaption = "<%values.instructions%>"
/subcaptionfontstyle = ("Arial", 2%, false, false, false, false, 5, 0)
/showquestionnumbers = true
/showpagenumbers = false
/questions = [1 = q1d, q1p, q1c]
/ ontrialend = [values.q1D = radiobuttons.q1d.response; values.q1P = radiobuttons.q1p.response;
values.q1C = radiobuttons.q1c.response]
</surveypage>

<surveypage PDI2>
/caption ="<%values.title%>"
/subcaption = "<%values.instructions%>"
/subcaptionfontstyle = ("Arial", 2%, false, false, false, false, 5, 0)
/showquestionnumbers = true
/showpagenumbers = false
/questions = [1 = q2]
/branch = [if (radiobuttons.q2.response == "Yes") surveypage.PDI2_fu]
/ ontrialend = [if (radiobuttons.q2.response == "No") {values.q2D = 0; values.q2P = 0; values.q2C = 0;}]
</surveypage>

<surveypage PDI2_fu>
/caption ="<%values.title%>"
/subcaption = "<%values.instructions%>"
/subcaptionfontstyle = ("Arial", 2%, false, false, false, false, 5, 0)
/showquestionnumbers = true
/showpagenumbers = false
/questions = [1 = q2d, q2p, q2c]
/ ontrialend = [values.q2D = radiobuttons.q2d.response; values.q2P = radiobuttons.q2p.response;
values.q2C = radiobuttons.q2c.response]
</surveypage>


*******************************************************************************************************************
*******************************************************************************************************************
SURVEY
*******************************************************************************************************************
*******************************************************************************************************************
<survey PDI>
/pages = [1 = PDI1, PDI2]
/fontstyle = ("Arial", 2.5%, false, false, false, false, 5, 1)
/itemfontstyle = ("Arial", 2%, true, false, false, false, 5, 0)
/itemspacing = 1.5%
/responsefontstyle = ("Arial", 2%, false, false, false, false, 5, 0)
/finishlabel = "Finish"
/nextlabel = "Next"
/backlabel = "Back"
</survey>
*******************************************************************************************************************
*******************************************************************************************************************
SUMMARY TRIAL/BLOCK
*******************************************************************************************************************
*******************************************************************************************************************
<trial summarytrial>
/ ontrialbegin = [if (radiobuttons.q1.response == "")
{values.number_misseditems_PDI += 1;
values.misseditems_PDI = concat(values.misseditems_PDI, "1,")}]
/ ontrialbegin = [if (radiobuttons.q2.response == "")
{values.number_misseditems_PDI += 1;
values.misseditems_PDI = concat(values.misseditems_PDI, "2,")}]

/ontrialend = [values.completed = 1]
/ timeout = (0)
/ recorddata = true
</trial>

<block summary>
/ trials = [1 = summarytrial]
</block>

*******************************************************************************************************************
*****************************************************************************************************************
EXPERIMENT
*******************************************************************************************************************
*******************************************************************************************************************
<expt>
/ blocks = [1 = PDI; 2 = summary]
</expt>[/left]

By Dave - 10/25/2016

<survey PDI>
/pages = [1 = PDI1, PDI2]
...
</survey>

needs to read

<survey PDI>
/pages = [1 = PDI1; 2=PDI2]
...
</survey>

or

<survey PDI>
/pages = [1-2 = noreplace(PDI1,PDI2)]
...
</survey>

if you want pages run in random order.

Additionally,

<surveypage PDI1>
...
/branch = [if (radiobuttons.q1.response == "Yes") surveypage.PDI1_fu
else surveypage.PDI2]
...
</surveypage>

does not make sense. You don't need to /branch to <surveypage PDI2> if you already have it in the <survey>'s /pages attribute. This should thus only read

<surveypage PDI1>
...
/branch = [if (radiobuttons.q1.response == "Yes") surveypage.PDI1_fu]
...
</surveypage>

just like in the original example I posted.
By cindy1358 - 10/25/2016

Thanks, Dave! Turns out I made several bracket errors as well and the survey now runs smoothly. However, I'm running into another problem. I noticed that if I press the back keys several times while doing the survey, it seems to end earlier, as the "Finish" button appears before all the questions are shown. Is there a way to fix this without eliminating the "Back" option? Also, I was wondering if there's a way to show an example of how the questions should be answered using pre-selected radiobuttons that cannot be altered? The only feasible way I can think of right now is putting those examples as actual survey questions, going through the survey while taking screenshots, and then adding those images to the instruction page as examples. 
By Dave - 10/26/2016

> Is there a way to fix this without eliminating the "Back" option?

Either (1) set / showbackbutton = false in the <survey> element, or (2) run your pages via a <block> instead of a a <survey>.

> Also, I was wondering if there's a way to show an example of how the questions should be answered using pre-selected radiobuttons that
> cannot be altered? The only feasible way I can think of right now is putting those examples as actual survey questions, going through the
> survey while taking screenshots, and then adding those images to the instruction page as examples.

This would be the way to go.