Welcome to the LimeSurvey Community Forum

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

How do I make question as mandatory based on certain answer of previous question

  • murthyma
  • murthyma's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 8 months ago - 3 years 8 months ago #202417 by murthyma
Hello Team,

I have a survey with 3 questions.


Question 1: It has a slider to choose a value from 0 to 100.

Question 2: It has a dropdown with 3 values (Good, Ok, Bad).

Question 3: This question has to be displayed always, but it should be mandatory if a value in Question 1 is greater than 20, and if the value in Question 2 is Bad.


Could anyone suggest a solution, please?


I know using conditions we can display/show questions based on conditions of previous questions. But here i want to display the question always and set it mandatory based on value of previous questions. So, need to know where do we set this logic and what is the expression or step to set it based on my above questions.




Regards,
Murthy
Last edit: 3 years 8 months ago by murthyma.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago #202418 by tpartner
Depending on the question type, you can use a question validation equation.

For example, if Q3 is a list-radio, something like this:

Code:
(Q1 > 20 AND Q2 == "answerCodeBad" AND !is_empty(Q3)) 
OR 
((Q1 <= 20 OR Q2 != "answerCodeBad") AND (!is_empty(Q3) OR is_empty(Q3)))

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago #202420 by holch
Or you could create 2 different questions, one mandatory, one none mandatory and show/hide them based on the previous questions via relevance equation.

But keep in mind that you would need to join the responses later. So I think Tpartner's solution is the more "elegant" one.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose