You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Sometimes you may have a set of questions and want to require the user to answer a subset of them. However, you want each user to be able to choose their own subset. 

For example, imagine you have two questions

Question IDQuestion Text
/data/colorWhat is your favorite color?
/data/foodWhat is your favorite food?

In this scenario you want the user to answer exactly one of these, though the user can answer either one.

 

Option 1: Add a Preceding Question

The simplest solution would be to add a question beforehand which asks:

Question IDQuestion Text
/data/select-question

Which question do you want to answer?

  • What is your favorite color?
  • What is your favorite food?

This question would be required, and then you could use the display conditions to show exactly one question, which would also be required.

 

Option 2: Allow Users to See All Questions - Using a label as a validation condition

Sometimes you want the users to be able to see all of the possible questions before choosing which one to answer. Here is a way to do that:

1. Put all of the Questions in a Question List Group (works on Android)

This will put all of the questions on the same page.

2. Create a Label after the Questions, but still in the Question List Group

This label will be displayed when someone does not answer exactly one question.

3. Set the Label's Display Condition

You will want the display condition to show the label when you don't answer exactly one of them. For example:

(/data/color != '' and /data/food != '') or (/data/color = '' and /data/food = '')

4. Set the Label's Validation Condition

We want to treat the label like a validation condition so put a validation condition that can never be met. For example:

1=2

Set the label's message (Label) to be: "You must answer exactly one of the above questions."

Now when the user doesn't answer exactly one question they will see an error message which prevents them from going forward until they correct it.

 

  • No labels