Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Pre-fill answer on a routed question

  • Matadeleo
  • Matadeleo's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
2 years 5 months ago - 2 years 5 months ago #221340 by Matadeleo
Pre-fill answer on a routed question was created by Matadeleo
Hi guys,

I have a question (Q1) where the respondent must select from a multiple choice question. If they select more than 1 choice, we want to ask them what their main choice is in the following question (Q2). If they only answer with 1 choice at Q1, then we want to auto-fill Q2 and hide it from the user. This is so the user doesn't see Q2 with the array filter showing only a single option.

Unfortunately, it seems to work if Q2 is hidden all the time, however, if I duplicate Q2 as Q3 and add routing (Answer Count @ Q1 > 1) then the answer does not get pre-filled anymore.

 

File Attachment:

File Name: example.lss
File Size:23 KB


LS: Version 3.17.16+190906

Goal: Get Q3 to record data in the responses when only 1 option selected at Q1.
Last edit: 2 years 5 months ago by Matadeleo.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 5 months ago #221342 by DenisChenu
Replied by DenisChenu on topic Pre-fill answer on a routed question
You need 2 question : one hidden and one hidden by relevance.

relevance for answer to be null.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • Matadeleo
  • Matadeleo's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
2 years 5 months ago #221345 by Matadeleo
Replied by Matadeleo on topic Pre-fill answer on a routed question
Apologies Denis - I'm not 100% sure what you mean.

Are you suggesting that I should have 2 "copies" of the question? Ideally I would like the data to be contained within a single question as I need to use the answer given later in the survey.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 5 months ago #221346 by DenisChenu
Replied by DenisChenu on topic Pre-fill answer on a routed question
Yes :

Q2shown : relevance count(that.Q1.NAOK) > 1
Q2: equation with {if(count(that.Q1.NAOK) > 1),Q2shown.NAOK,list(Q1.NAOK))}

The relebvance force Q2 ro be null, then you can not use it if you hide it.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • Matadeleo
  • Matadeleo's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
2 years 5 months ago #221356 by Matadeleo
Replied by Matadeleo on topic Pre-fill answer on a routed question
Thanks Denis - was not aware it would force Q2 to be null.

I can see the logic in the equation you provided, however I think it would not be usable as the value returned by `list(that.Q1.NAOK)` would be "Y". We would have no context for what subquestion this relates to. I'm not sure if there is a way to return the subquestion code rather than the value of the checkbox for multiple choice questions.

I have managed to get it working using the logic of having a Q2shown and a Q2hidden however, with an equation to set the value:

`Q2Hidden=if((count(that.Q1.NAOK) == 1) && Q1_1 == "Y", 1, if((count(that.Q1.NAOK) == 1) && Q1_2 == "Y", 2, if((count(that.Q1.NAOK) == 1) && Q1_3 == "Y", 3, Q2Shown)))`
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 5 months ago #221358 by DenisChenu
Replied by DenisChenu on topic Pre-fill answer on a routed question
Arg you right about list(that.Q1) …

About your system, i prefer to use join/concat since if count(that.Q1.NAOK) == 1 it can be ony one choice …

{join(
if((count(that.Q1.NAOK) == 1) && Q1_1 == "Y", 1),
if((count(that.Q1.NAOK) == 1) && Q1_2 == "Y", 2),

if((count(that.Q1.NAOK) > 1), Q2.NAOK)
)}

Else : warning with 1,2 … 10,11 etc …
I always prefer to have 01,02,03 … 10,11

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: Matadeleo
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose