- Posts: 15
- Thank you received: 1
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Fill in a multiple choice question based on previous answers
- wilmslow3
- Topic Author
- Offline
- New Member
Less
More
9 years 8 months ago #111473
by wilmslow3
Fill in a multiple choice question based on previous answers was created by wilmslow3
Hi,
Just wondering if this is possible, Can you automatically answer a multiple choice question based on previous answers (i.e. radio button questions, multiple choice questions and array questions)
Reason being...I want to have a "summary multiple choice question" that based on previous answers ticks a multiple choice question.
I have a couple of multiple choice questions and a couple of radio buttons questions that when the options are selected a later question records the answers in a "big multiple choice question". (This can be hidden or shown)
Is this possible? Ive looked at the EM and can't seem to get it to work - does anyone have any sample surveys they could share with the correct syntax or point me in the right direction.
Thanks
Just wondering if this is possible, Can you automatically answer a multiple choice question based on previous answers (i.e. radio button questions, multiple choice questions and array questions)
Reason being...I want to have a "summary multiple choice question" that based on previous answers ticks a multiple choice question.
I have a couple of multiple choice questions and a couple of radio buttons questions that when the options are selected a later question records the answers in a "big multiple choice question". (This can be hidden or shown)
Is this possible? Ive looked at the EM and can't seem to get it to work - does anyone have any sample surveys they could share with the correct syntax or point me in the right direction.
Thanks
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
9 years 8 months ago - 9 years 8 months ago #111487
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Fill in a multiple choice question based on previous answers
Yes, you can use equation questions to select the options in the "results" question. These equation questions must be placed after the "results" question.
In the case of multiple options questions the equation is a simple - you can directly tie the "results" option to the "q1" option:
In the case of radio questions you will need to define which answer will result in a checked box in the "results" question. The easiest way to do that is to simply give that radio answer a code of "Y". Then you can tie them directly in the equation:
If you can not use an answer code of "Y", you will need to put in a intermediary equation question to define "Y". So, for example, if I had a radio question (lets call it "q3") where I wanted answer code "A1" to check the box in "results", my intermediary equation (lets call it "equation1") would be:
This would be followed by another equation question to control "results":
Here's a working example for LS2.05.
In the case of multiple options questions the equation is a simple - you can directly tie the "results" option to the "q1" option:
Code:
{results_SQ001 = q1_SQ001}
In the case of radio questions you will need to define which answer will result in a checked box in the "results" question. The easiest way to do that is to simply give that radio answer a code of "Y". Then you can tie them directly in the equation:
Code:
{results_SQ002 = q2}
If you can not use an answer code of "Y", you will need to put in a intermediary equation question to define "Y". So, for example, if I had a radio question (lets call it "q3") where I wanted answer code "A1" to check the box in "results", my intermediary equation (lets call it "equation1") would be:
Code:
if(q3 == 'A1', 'Y', '')
Code:
results_SQ003 = equation1
Here's a working example for LS2.05.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
Last edit: 9 years 8 months ago by tpartner.
The following user(s) said Thank You: Ben_V
The topic has been locked.
- Ben_V
- Offline
- Platinum Member
Less
More
- Posts: 1128
- Thank you received: 329
9 years 8 months ago #111501
by Ben_V
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Replied by Ben_V on topic Fill in a multiple choice question based on previous answers
Hello Tony,
Very kind explanations & sample...as you used to provide!
Is this method already explained somewhere in the manual (and where)?
Very kind explanations & sample...as you used to provide!
Is this method already explained somewhere in the manual (and where)?
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
9 years 8 months ago #111503
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Fill in a multiple choice question based on previous answers
Hi Ben,
The only thing I could find is here - manual.limesurvey.org/Expression_Manager#Operators
Feel free to expand on that if you wish.
.
The only thing I could find is here - manual.limesurvey.org/Expression_Manager#Operators
Feel free to expand on that if you wish.
.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: Ben_V
The topic has been locked.
- david2013
- Offline
- Senior Member
Less
More
- Posts: 42
- Thank you received: 6
9 years 8 months ago #111528
by david2013
Replied by david2013 on topic Fill in a multiple choice question based on previous answers
Can we use one equation question instead of two? for example, results_SQ003 = if(q3 == 'A1', 'Y', '').
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
9 years 8 months ago #111530
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Fill in a multiple choice question based on previous answers
I'm not sure why but that didn't work for me in testing.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: wilmslow3
The topic has been locked.
- wilmslow3
- Topic Author
- Offline
- New Member
Less
More
- Posts: 15
- Thank you received: 1
9 years 8 months ago #111542
by wilmslow3
Replied by wilmslow3 on topic Fill in a multiple choice question based on previous answers
Thanks TPartner
Your solution is perfect for my needs, really good explanation and I'm sure I'll be using a few variations for the future. With this I have implemented a filter in an array question based on two questions into my questionnaire using this method.
See www.limesurvey.org/en/forum/can-i-do-thi...swers-of-2-questions
and
www.limesurvey.org/en/forum/can-i-do-thi...ter-on-two-questions
I have two questions 10a and 10b
at Q9 people select what bands they have heard of
at 10a people select their favourite band (array filter of Q9)
at 10b people select other top 4 bands (with array filter of Q9 and array exclusion of 10a)
At 10c Peple can rate the bands they have slected in q10a and 10b in an array question. (array filter from results)
So inbetween 10b and 10c
I load a equation (Sum1, Sum2 etc) for each of the options using:
{if(Q10a_A1=='Y','Y',Q10b_A1)}
then
{Results_A1 = Sum1}
Your solution is perfect for my needs, really good explanation and I'm sure I'll be using a few variations for the future. With this I have implemented a filter in an array question based on two questions into my questionnaire using this method.
See www.limesurvey.org/en/forum/can-i-do-thi...swers-of-2-questions
and
www.limesurvey.org/en/forum/can-i-do-thi...ter-on-two-questions
I have two questions 10a and 10b
at Q9 people select what bands they have heard of
at 10a people select their favourite band (array filter of Q9)
at 10b people select other top 4 bands (with array filter of Q9 and array exclusion of 10a)
At 10c Peple can rate the bands they have slected in q10a and 10b in an array question. (array filter from results)
So inbetween 10b and 10c
I load a equation (Sum1, Sum2 etc) for each of the options using:
{if(Q10a_A1=='Y','Y',Q10b_A1)}
then
{Results_A1 = Sum1}
The following user(s) said Thank You: Ben_V
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
9 years 8 months ago #111544
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Fill in a multiple choice question based on previous answers
That's a great explanation of a real-world application.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: wilmslow3
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11639
- Thank you received: 2737
9 years 8 months ago #111554
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Fill in a multiple choice question based on previous answers
Nice, but with a little tweaking the problem wouldn't have been a problem...
Ask in 10a for the top 5 bands from Q9 and then from those top 5 bands ask for the single most favorite band. Then you could do the filter of 10c based on 10a and you don't need to have it from 2 different question.
In your case I also don't see a need for the specific order you had (sometimes this could have had an impact and the technical solution would have been really necessary).
But in your case I would have just switched the order of the questions and the problem would be solved by the array filter out of the box.
Ask in 10a for the top 5 bands from Q9 and then from those top 5 bands ask for the single most favorite band. Then you could do the filter of 10c based on 10a and you don't need to have it from 2 different question.
In your case I also don't see a need for the specific order you had (sometimes this could have had an impact and the technical solution would have been really necessary).
But in your case I would have just switched the order of the questions and the problem would be solved by the array filter out of the box.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The following user(s) said Thank You: wilmslow3
The topic has been locked.
- wilmslow3
- Topic Author
- Offline
- New Member
Less
More
- Posts: 15
- Thank you received: 1
9 years 8 months ago #111555
by wilmslow3
Thanks, yes that would have worked, unfortunatly soemtimes you dont get the luxury of changing questions in a survey 'i.e. clients!!!' Also my actual survey filtering is a lot more complex to what I actually posted, I thought I'd try and simplify it to post the solution.
Replied by wilmslow3 on topic Fill in a multiple choice question based on previous answers
holch wrote: Nice, but with a little tweaking the problem wouldn't have been a problem...
Ask in 10a for the top 5 bands from Q9 and then from those top 5 bands ask for the single most favorite band. Then you could do the filter of 10c based on 10a and you don't need to have it from 2 different question.
In your case I also don't see a need for the specific order you had (sometimes this could have had an impact and the technical solution would have been really necessary).
But in your case I would have just switched the order of the questions and the problem would be solved by the array filter out of the box.
Thanks, yes that would have worked, unfortunatly soemtimes you dont get the luxury of changing questions in a survey 'i.e. clients!!!' Also my actual survey filtering is a lot more complex to what I actually posted, I thought I'd try and simplify it to post the solution.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11639
- Thank you received: 2737
9 years 8 months ago - 9 years 8 months ago #111556
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Fill in a multiple choice question based on previous answers
Yeah, I know. The factor "client" can be a problem sometimes. Usually I manage to explain it to them and they get it, but some are quite stubborn.
OK, if it is more complex, this changes the game of course. I just saw the posted solution and thought, that it could have been solved a lot simpler, without any additional Javascript.
But as I said, there are always problems that are more complex and there this solution might be relevant. Thus it would be great if you could post it in the work around section, maybe? Because things in the forum get lost, in the work around section they are well archived (don't want to know how many of Tony's brilliant work arounds have been lost over time in the forum...).
OK, if it is more complex, this changes the game of course. I just saw the posted solution and thought, that it could have been solved a lot simpler, without any additional Javascript.
But as I said, there are always problems that are more complex and there this solution might be relevant. Thus it would be great if you could post it in the work around section, maybe? Because things in the forum get lost, in the work around section they are well archived (don't want to know how many of Tony's brilliant work arounds have been lost over time in the forum...).
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Last edit: 9 years 8 months ago by holch.
The topic has been locked.