# Fill in a multiple choice question based on previous answers

2 years 9 months ago #111473
wilmslow3 created the topic: Fill in a multiple choice question based on previous answers
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

Please Log in to join the conversation.

2 years 9 months ago - 2 years 9 months ago #111487 by tpartner
tpartner replied the 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:
`{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:
`{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:
`if(q3 == 'A1', 'Y', '')`
This would be followed by another equation question to control "results":
`results_SQ003 = equation1`

Here's a working example for LS2.05.

#### File Attachment:

File Name: limesurvey...8-07.lss
File Size:24 KB

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
##### Attachments:
Last Edit: 2 years 9 months ago by tpartner.
The following user(s) said Thank You: Ben_V

Please Log in to join the conversation.

2 years 9 months ago #111501 by Ben_V
Ben_V replied the 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)?

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)

Please Log in to join the conversation.

2 years 9 months ago #111503 by tpartner
tpartner replied the 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.

.

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

Please Log in to join the conversation.

2 years 9 months ago #111528
david2013 replied the 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', '').

Please Log in to join the conversation.

2 years 9 months ago #111530 by tpartner
tpartner replied the 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

Please Log in to join the conversation.

2 years 9 months ago #111542
wilmslow3 replied the 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}
The following user(s) said Thank You: Ben_V

Please Log in to join the conversation.

2 years 9 months ago #111544 by tpartner
tpartner replied the 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

Please Log in to join the conversation.

2 years 9 months ago #111554 by holch
holch replied the 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.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds
The following user(s) said Thank You: wilmslow3

Please Log in to join the conversation.

2 years 9 months ago #111555
wilmslow3 replied the 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.

Please Log in to join the conversation.

2 years 9 months ago - 2 years 9 months ago #111556 by holch
holch replied the 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...).

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds
Last Edit: 2 years 9 months ago by holch.

Please Log in to join the conversation.