Welcome to the LimeSurvey Community Forum

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

Can I make a Conditional Answer Setup?

  • free521521521
  • free521521521's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
3 weeks 4 hours ago - 3 weeks 4 hours ago #270773 by free521521521
Can I make a Conditional Answer Setup? was created by free521521521
Please help us help you and fill where relevant:
Your LimeSurvey version: [LimeSurvey Community Edition Version 6.13.1+250428]
Own server or LimeSurvey hosting:self-host
Survey theme/template:fruit
==================
I need to set up a 3-question survey for Major Choice in university, Alll question is singal choice question.
Question 1, What is your major? Answer will be 1~9
Question 2, Will you change your major? Answer is Yes or No.
Question 3 Is the future major you will choice. But it will be partially setup base on the previously answer from Q1 and Q2.

For example, if Q1 = 7 and Q2 = No, then the Q3 will automatically set to 4.

Can I make it by LS? Thanks for help!!!
Last edit: 3 weeks 4 hours ago by free521521521.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 weeks 1 hour ago #270774 by Joffm
Replied by Joffm on topic Can I make a Conditional Answer Setup?
What's the exact workflow?
Q3 is set to 4, but then displayed that the respondent is able to change?
Or is Q3 hidden and set to 4 in the background?

Anyway: use ExpressionScript like
{Q3=if(Q1==7 and Q2=="N",4,Q3)}
with Q2 as Y/N question..

Joffm 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

More
2 weeks 6 days ago #270775 by freezhao
Replied by freezhao on topic Can I make a Conditional Answer Setup?
I think it will be:
Q3 is set to 4, but then displayed that the respondent is not able to change.

Because other respondent may complete Q3 by choosing the option they like.


for example the if respondent choose Q1 = 1 and Q2 = Yes, respondent need to choose the Q3 by themself.

Thanks for your help, the "ExpressionScript" you mean set the question as "ExpressionScript"? Then how to keep the single choice question for others?
Thanks agian!

Please Log in to join the conversation.

More
2 weeks 6 days ago #270782 by freezhao
Replied by freezhao on topic Can I make a Conditional Answer Setup?
And little more development,
if the condition is Q1= 1~5 How to express?

Please Log in to join the conversation.

More
2 weeks 6 days ago #270783 by freezhao
Replied by freezhao on topic Can I make a Conditional Answer Setup?
I have tested the
((Q1.NAOK == "06" or Q1.NAOK == "07") and (Q2.NAOK == "N"))

It can show or hide the Q3.

But the {Q3=if(Q1==7 and Q2=="N",4,Q3)} does not work
I used {Q3=if((Q1.NAOK == "06" or Q1.NAOK == "07") and (Q2.NAOK == "N")), 04, Q3}

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 weeks 6 days ago #270786 by Joffm
Replied by Joffm on topic Can I make a Conditional Answer Setup?
Of course "Q1==7" doesn't work if your code is "07".
But the thread opener talked about "7".
And nobody mentioned code "06" so far.

This is the disadvantage if you do not provide a loss export of a small sample.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • free521521521
  • free521521521's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
2 weeks 4 days ago - 2 weeks 4 days ago #270801 by free521521521
Replied by free521521521 on topic Can I make a Conditional Answer Setup?
I have set the 3 question, it have set the condition for Q3 by
Code:
if (Q1 == '07' && Q2 == 'Y', '03', '')
LS file is here
 

File Attachment:

File Name: limesurvey...2263.lss
File Size:43 KB


Now two questions need to be solved
  1. How to express the if the answer is 01~06 ?
  2. How to make default answer by ExpressionScript? I have checked the "edit the default answers", there is no place to input the ExpressionScript.

Thanks for help!
 
Last edit: 2 weeks 4 days ago by free521521521.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 weeks 4 days ago #270803 by Joffm
Replied by Joffm on topic Can I make a Conditional Answer Setup?
Hi,
if (Q1 == '07' && Q2 == 'Y', '03', '')

This is not a condition. 
A condition is a logical term that is either TRUE or FALSE.
BTW: In your first post you wrote

if Q1 = 7 and Q2 = No, then the Q3 will automatically set to 4.

What "Yes" or "No"?
I suppose "No".
First I changed these codes "01", "02", ... to the numerical codes 1,2,3,---
So it should be
Q1!=7 OR Q2!="N"  or analogue !(Q1==7 AND Q3=="N")
Q3 is displayed if Q1 is not equal 7 or Q2 is not equal "N".
Then the respondent enters his choice.
To avoid an initial display of Q3 that is suddenly hidden, you only run the condition after Q1 and Q2 are answered.
!is_empty(Q1) and !is_empty(Q2) and (Q1 !=7 OR Q2 != 'N')

Otherwise, if Q1 is equal 7 and Q2 is equal "N", Q3 is not displayed and the value is set in the background.
Here you use an equation that assigns the value (4) to Q3.
You may read the manual about assignments.
Create a question of type equation somewhere in your survey after these three questions.
{Q3=if(Q1==7 and Q2=="N",4,Q3)}

 

File Attachment:

File Name: limesurvey...63_J.lss
File Size:44 KB


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: free521521521

Please Log in to join the conversation.

  • free521521521
  • free521521521's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
2 weeks 3 days ago #270808 by free521521521
Replied by free521521521 on topic Can I make a Conditional Answer Setup?
After I check the detail for the structure. I think I fianlly understood the way LS control the answer.

The Q4( final question hide Equation) can control the result of Q3. And make the file data set to what it designed. Am I right?

Many thanks, really help me to understood how LS works.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose