Index of help pages

A condition for an answer option in LimeSurvey

LimeSurvey has conditions for question group, question and subquestion. You can for example ask first about gender and then about beard shaving only from men. For instructions see How to make a conditional question in LimeSurvey.

However, an answer option does not have condition. You can directly make a checkbox question that shows water and juice to all, beer and wine to those who earlier answered being over 18 years old. You can not directly make a radio button showing selections in a similar way. This can be done with a trick with two invisible question.

Let's go this step-by-step.

Array filter

First step contains no tricks at all.

Make a survey with two question groups. To the first one make a question of type Multiple choise. Give it a code tmp1 and to subquestions put codes and questions wa-wa, ju-ju, be-be and wi-wi. (Only codes have real meaning, texts are for making this easier to follow.)

To the second question group put a question of type List (radio) and to answer options code-text -pairs wa-Water, ju-Juice, be-Beer and wi-Wine. You can use for example drink as the question code.

In the settings for this second question put tmp1 to the field Logic > Array filter.

Now test. If you select for example "wa" and "be" in the first question, then only water and beer are visible in the second question.

Trick: setting value in a pseudoquestion

Now, after first question group we have internal variables tmp1_wa, tmp1_ju and so on. Each variable is either empty value or string value "Y".

As the first question of second question group add a question with type Equation; the question code can be for example tmp2, it does not matter. To the question text put {tmp1_wa="Y"}.

Now test. Regardless of what you put in to the first question, "Water" is always shown in the second question.

Final step

To the first question group add a question of type Short free text and put age to the code for it.

For the tmp2-question put

{tmp1_wa="Y"}
{tmp1_ju="Y"}
{tmp1_be=if(age>=18,"Y","")}
{tmp1_wi=if(age>=18,"Y","")}

That's it. Now if the age is at least 18, then internal variables tmp1_be and tmp1_wi will be set, and the last question uses variables tmp_* to determine which answer options to show.

Hide internal questions

Last, go to the questions tmp1 and tmp2, and to the settings put Display > Always hide this question to On.

An example for download

You can download the example survey. Use Create survey > Import with the .lss file you downloaded.