Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: Filter answers based on previous question/Answer Logic

Filter answers based on previous question/Answer Logic 2 years 8 months ago #102611

  • andyb
  • andyb's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
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 administrator has disabled public write access.

Filter answers based on previous question/Answer Logic 2 years 8 months ago #102614

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6214
  • Thank you received: 1376
  • Karma: 539
Please refer to the manual:

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

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

Array exclusion filter - manual.limesurvey.org/Question_type_-_Li...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 administrator has disabled public write access.

Filter answers based on previous question/Answer Logic 2 years 8 months ago #102617

  • andyb
  • andyb's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
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 administrator has disabled public write access.

Filter answers based on previous question/Answer Logic 2 years 8 months ago #102620

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6214
  • Thank you received: 1376
  • Karma: 539
Sure, that would work.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Filter answers based on previous question/Answer Logic 2 years 7 months ago #103358

  • andyb
  • andyb's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
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: 2 years 7 months ago by andyb. Reason: Clarification
The administrator has disabled public write access.

Filter answers based on previous question/Answer Logic 2 years 7 months ago #103359

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6214
  • Thank you received: 1376
  • Karma: 539
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 administrator has disabled public write access.

Filter answers based on previous question/Answer Logic 2 years 7 months ago #103362

  • andyb
  • andyb's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
I've attached the survey here for you, thanks.


File Attachment:

File Name: limesurvey...2944.lss
File Size:0 KB
The administrator has disabled public write access.

Filter answers based on previous question/Answer Logic 2 years 7 months ago #103374

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6214
  • Thank you received: 1376
  • Karma: 539
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 administrator has disabled public write access.

Filter answers based on previous question/Answer Logic 2 years 7 months ago #103555

  • MarcellavZ
  • MarcellavZ's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 13
  • Karma: 0
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 administrator has disabled public write access.

Filter answers based on previous question/Answer Logic 2 years 7 months ago #103556

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6214
  • Thank you received: 1376
  • Karma: 539
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: 2 years 7 months ago by tpartner.
The administrator has disabled public write access.

Filter answers based on previous question/Answer Logic 2 years 7 months ago #103568

  • Haap
  • Haap's Avatar
  • Offline
  • Gold Donor
  • Posts: 13
  • Karma: 0
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 administrator has disabled public write access.

Filter answers based on previous question/Answer Logic 2 years 7 months ago #103587

  • MarcellavZ
  • MarcellavZ's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 13
  • Karma: 0
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 administrator has disabled public write access.

Filter answers based on previous question/Answer Logic 2 years 7 months ago #103709

  • MarcellavZ
  • MarcellavZ's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 13
  • Karma: 0
Hi!

If have succeeded, but not with the instructions you both described. Maybe it's interesting for you to know that there is also another possibility. I have put the javascript that you can use to filter multiple questions (example: {if(os.shown != '-oth-', os.shown, os_other.shown)}, where os is you questiongroup code) in the answer possibilities of the next question. So if you want to filter multiple list:radio questions for a next question than you can put all the individual javascript in the answer possibilities of the next question. In the attachement you can see an example. This way it doesn't matter in which questiongroup you are working :)



There is another question wherefor I can't find any answer. In my experiment I have 4 conditions and I would like to randomly assign my participants to one of these conditions. Is it possible to make 4 surveys that stands for the 4 conditions and than limesurvey randomly assign participant to one of these surveys with the same link? So that everyone get's one link and that limesurvey randomly assigns them to one of the 4 surveys?
The administrator has disabled public write access.

Filter answers based on previous question/Answer Logic 2 years 7 months ago #103729

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6214
  • Thank you received: 1376
  • Karma: 539
No, that is not possible within LimeSurvey. If you want to randomly assign respondents to 4 SEPARATE surveys, you will need to do that in a remote PHP script.

.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.270 seconds
Imprint                   Data Protection Statement                  Revocation information and revocation form