Check out the LimeSurvey source code on GitHub!

Conditionals: change and to or

4 years 1 month ago #91193 by sD960
Hello, my name is Fee. I'm quite new to LimeSurvey, and not very sophisticated programming-wise. I am using responses to an Array to determine whether the next question will be visible. A fake example: The Array question is "What do you think of your neighbors", and the array has 2 items on the Y-axis (him, her) and 4 on the X-axis (nice, smart, mean, stupid). I want the next question ("Will you invite them for dinner") to show up only if the survey-taker clicks on him-nice, OR him-smart, OR her-nice, Or her-smart. However, in setting the conditions, LimeSurvey seems to only allow me to set him-nice OR him-smart, AND her-nice OR her-smart. That is, there has to be both a him- AND a her-response (to either nice or smart), instead of what I want, which is any ONE of the 4 him-her-nice-smart responses. I guess I could work around this by having two separate but identical "Will you invite them for dinner" questions--that is, one conditional on the him-responses and one on the her-responses, but that seems really inelegant. Help?!

Please Log in to join the conversation.

4 years 1 month ago #91211 by tpartner
If using the conditions designer, you can use scenarios -

If using Expression Manager and relevance, you can use the OR operator -

Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

4 years 1 month ago #91235 by sD960
Thanks, using scenario did the trick. This is great, especially as my inelegant fix wouldn't have worked anyway, as it would have made the follow-up question "Will you invite them for dinner" appear twice if the survey-taker had selected either him-nice or him-smart AND either her-nice and her-smart.

For the benefit of other users at or below my advanced-beginner level with an analogous OR-vs-AND issue, and since it can be daunting wading through all the information to learn how to solve one's particular problem, I'll explain what I did:

When setting the conditions, I clicked on the Scenario button which showed a default label of 1, and chose him-nice and him-smart, which set up the conditions him-nice OR him-smart, and added those conditions. I then clicked on the Scenario button again which automatically showed a label of 2, chose her-nice and her-smart, which set up the conditions her-nice OR her-smart, and added those conditions. LimeSurvey automatically sets an OR between scenarios 1 and 2, so I end up with ([him-nice OR him-smart] OR [her-nice OR her-smart]). This may seem like a complicated way to get to (him-nice OR him-smart OR her-nice OR her-smart)--logically I don't need the sub-parentheses--but it works!

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form