Validation constraints for multi-select

Hello,

I’m interested in validation logic within the responses for a multiple
choice/multiple select question. I found the "Common Logic and Calculation"
page helpful for this, but I still have a question.

We have a question that has multiple choices that can be selected (A
through F), along with “Don’t know” and “No response”. We want to restrict
the question such that after one of the valid choices (from A through F) is
selected, the user is unable to select “Don’t know” OR “No response”.

We can use the validation constraint so that you can’t select 'Don’t know’
and another valid answer: “not(selected(., ‘Don’t know’) and
count-selected(.) > 1)”

and we can also use it so that you can’t select “No response”: “not(selected(.,
‘No response’) and count-selected(.) > 1)”

But is it possible to do it such that BOTH “Don’t know” AND "No response"
are restricted if any other valid answer is selected?

I’ve tried to make this clear but if it’s confusing, I can clarify. I tried
to use operators in between two separate expressions, but it didn’t work.

Thanks!
Sarah

Hi Sarah,

You can just combine both the statements you have with an and. This will
say that the question is valid only if both the pieces of logic you have
are true.
not(selected(., ‘No response’) and count-selected(.) > 1) and not(selected(.,
‘Don’t know’) and count-selected(.) > 1)

However, I think you should be using your item values, not the display text
when checking in the logic. I.e. your select item is probably called
something like “no_response” not “No response”. Same goes for “Don’t
Know”. So your selected function should be something like selected(.,
“no_response”).

Thanks,
Sheel

··· On Wed, Mar 5, 2014 at 1:41 PM, Sarah S. wrote:

Hello,

I’m interested in validation logic within the responses for a multiple
choice/multiple select question. I found the "Common Logic and Calculation"
page helpful for this, but I still have a question.

We have a question that has multiple choices that can be selected (A
through F), along with “Don’t know” and “No response”. We want to restrict
the question such that after one of the valid choices (from A through F) is
selected, the user is unable to select “Don’t know” OR “No response”.

We can use the validation constraint so that you can’t select ‘Don’t
know’ and another valid answer: “not(selected(., ‘Don’t know’) and
count-selected(.) > 1)”

and we can also use it so that you can’t select “No response”: “not(selected(.,
‘No response’) and count-selected(.) > 1)”

But is it possible to do it such that BOTH “Don’t know” AND "No response"
are restricted if any other valid answer is selected?

I’ve tried to make this clear but if it’s confusing, I can clarify. I
tried to use operators in between two separate expressions, but it didn’t
work.

Thanks!
Sarah


You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Sheel Shah
Project Manager | Dimagi
m: +1.781.428.5419 | skype: sheel_shah