Welcome to the LimeSurvey Community Forum

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

Filter answers based on previous question/Answer Logic

More
10 years 10 months ago #102611 by andyb
Hey everyone,

New LimeSurvey user. Picking it up quite quickly but I am having some issues dealing with logic and routing. I'd like to throw a couple of questions at you.

[One]
The first question asks the respondent to pick any options that apply.

Eg
Which flavours do you enjoy?
Chocolate
Strawberry
Vanilla
Banana

If the user picks multiple options (ie, more than 1), I'd like the next question to provide a single choice only of the options previously selected

Eg
Which one do you enjoy MOST?
Chocolate
Vanilla


[Two]
Another question would present the respondent with a list of options and is single choice only.

Eg
Which is your favourite colour?
Black
White
Red
Blue
Green

The second question should then populate the same answers, but exclude the option selected.

Eg User selects black
Which is your least favourite colour?
White
Red
Blue
Green


[Three]
I get question logic. Is it possible to include an answer in a question based on a previous response?

Eg
How do you get to work?
Train
Bus
Car <--- only include this if respondent previously indicated owning a car.
Walk


Thanks for the help!
Andy
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 10 months ago #102614 by tpartner
Please refer to the manual:

Relevance (to show a question if more than one option in a previous question selected) - www.limesurvey.org/manual/Expression_Man...ation.2FBranching.29

Array filter - www.limesurvey.org/manual/Question_type_...r_.28array_filter.29

Array exclusion filter - www.limesurvey.org/manual/Question_type_...ay_filter_exclude.29

Regarding [Three], you will need to use JavaScript to show/hide that response.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
10 years 10 months ago #102617 by andyb
Tony

Thanks for the fast response.

I'm having some issues with the array filters, but I'll keep playing around for now.

As for the third, Javascript isn't something I'm comfortable with. One workaround for me will be just to set up two separate questions. The first has all the options, and second has all options except the one with is conditional. Then I can just use a logic statement to route them as necessary.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 10 months ago #102620 by tpartner
Sure, that would work.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
10 years 9 months ago - 10 years 9 months ago #103358 by andyb
Hi Again,

Thanks for your help on this. I'm still having trouble with one of the scenarios and despite weeks of testing and trying I simply cannot get this working properly. Have looked at the manual and I seem to be doing everything correctly.

In my survey, C1 is a radio list of options:

C1 - What is your favourite?

6 options are given.

C2 is then a radio list of the same options, which is supposed to give the same options but exclude the one chosen in C1.

C2 - And which is your least favourite?

5 remaining options given.

That I'm aware, I'm supposed to be setting up an exclusion filter on C2. This does nothing but excludes EVERYTHING, meaning there's nothing for the user to select.

I'm 99% sure I'm doing this correctly. Happy to provide screenshots if wanted. Any help appreciated :)
Last edit: 10 years 9 months ago by andyb. Reason: Clarification
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 9 months ago #103359 by tpartner
Are the answer codes for the two questions identical?

If so, can you attach a small sample survey with those questions?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
10 years 9 months ago #103362 by andyb
I've attached the survey here for you, thanks.


File Attachment:

File Name: limesurvey...2944.lss
File Size:0 KB
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 9 months ago #103374 by tpartner
That file is corrupted, all it contains is "XMLWriter class not compiled into PHP, please contact your system administrator".

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
10 years 9 months ago #103555 by MarcellavZ
Hello!

I have a similar question as the question ascribed above. I want to use the asnwers of multiple previous questions (list: radio) as the answer possibilities of a next question. So the participants need to choose one of their previous answers in one question. There are 5 different questions with 5 different codes and the question where all the answers need to be set has also a differen code. I tried the solution you ascribed on the forum but that didn't work. Than I tried the solutions ascribed in the manual at 'array filter' and 'array exclusion filter' but than nothing is excluded. I get all the answers of all the previous questions. What am I doing wrong? The questions I want to filter are in a different questiongroup than the question where the answers needs to be set, so is that what makes it going wrong?

I hope you can shed some light on the situation for me. Thanks!
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 9 months ago - 10 years 9 months ago #103556 by tpartner
Tricky because the filter question(s) need to be multiple-choice and, if there are several, the option must be checked in all of them to be shown in the filtered question.

If all of your filter questions (list-radios) are in the same group you can add a multiple-choice question to that group and then use JavaScript to hide the multiple-choice and check its options depending on the radio answers. This hidden question would become the filter question.

You should be able to find several examples in the forums of similar workarounds.

.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 10 years 9 months ago by tpartner.
The topic has been locked.
More
10 years 9 months ago #103568 by Haap
Although it is not a real solution, there is a workaround possible for this. It is based on using a hidden multiple text question. I ran into similar problems last week, and solved it this way.
The topic has been locked.
More
10 years 9 months ago #103587 by MarcellavZ
Thank you both Tony and Haap. I still don't know what you exactly mean because Java isn't my strong side but I will try to figur it out! I should come a long way with your directions.
Thanks!
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose