Restrict what combinations can be selected in a multiple select using ODK

Hello

I have an .xls form that has a series of about 20 questions that all use the same list name for a choice list. The user is able to select from 4 options for each of these 20 questions.
The options are numbered 1,2,3,4.

What I want to do is put a restriction that a user can select multiple answers but cannot select the combinations 1&2, 2&3, 1&3 ie. the only combinations allowed are 1&4 or 2&4, however the user can still select individually options 1,2 and 3.

I am designing the form in excel and using ODKCollect v1.10.2 to run it

I have tried to use the constraint field to solve my problem with 'and' and 'or' operators, which leave me with a lengthy field that has to be repeated for all 20 questions with the new variable name eg:
(selected(${variable},1) and selected(${variable},4)) or (selected(${variable},2) and selected(${variable},4)) or selected(${variable},1) or selected(${variable},2) or selected(${variable},2)

Looking forward to some colorful solutions.

Thanks

Hi @Leangelindiku17,

Please try instead in the constraint field: 'not(selected(${variable},1) and selected(${variable},2)) and not(selected(${variable},2) and selected(${variable},3)) and not(selected(${variable},1) and selected(${variable},3))

2 Likes

Hi @Souirji_Adgelghani

Thanks so much. The condition now works properly although I still have to
type if out over 20 times for each question.

Any ideas?

hi @Leangelindiku17,

I'm afraid I don't see how these conditions can be grouped; sorry! Making the Excel form is tedious, lots of copying and pasting, but once it's done, it's done!
If I were you, I would copy the first question (with all the lengthy conditions) and paste it as many times as there are similar questions then edit the questions' content rather than the conditions. It should be much faster.

1 Like

Hi @Souirji_Adgelghani

True, design once and use forever.

It works fine now. I just added a condition I missed.

Thanks again!