1

I've a repeat group that starts with a select1 prompt, other questions that follow in the group is based on the item selected from the select1 (relevants). Every item in the select1 is mandatory and should be asked only once. How can I validate that an item is not selected again. Is there a mechanism to somehow avoid selection of already selected item. I've defined the select1 as

<select1 appearance="minimal" ref="/data/ITEMLIST">
<label ref="jr:itext('/data/listlabel:label')"/>
  <item>
    <label>मसिनो चामल</label>
    <value>FRICE</value>
  </item>
  <item>
    <label>खस्रो चामल</label>
    <value>CRICE</value>
  </item>
       '
       '
       '
Learner
  • 41
  • 4

1 Answers1

0

You can either:

a) validate using a constraint, e.g.

constraint="not(selected(/path/to/previous/question, .))"

b) use an XPath predicate that excludes previously selected values from the option list presented to the user, see e.g. this form (upload it to http://opendatakit.org/xiframe/, to get the XForm).

c) Just a thought, haven't tested, might be wrong: Maybe count all the other answers with the current value and add a constraint to make sure this is not more than 1. E.g.

constraint="count(/path/to/repeated[question = current()/.]) <= 1"

Note that there is currently a predicate bug in JR/ODK, so best to test if this works in Enketo. They're working on fixing the bug in JR.

Martijn van de Rijdt
  • 1,020
  • 3
  • 10
  • 16
  • thanks martijnr, but I've got 80 items list, so I am not sure if I want to make 80 different select choices for it. That was the reason why I used the select in repeat group in the first place. Is it possible to dynamically obmit selected item in a next iteration in a repeat group with only one select? – Learner Jul 17 '15 at 05:17
  • I think this might not be possible, unfortunately. I can't think of an XPath predicate that would work for this without creating a circular reference. – Martijn van de Rijdt Jul 17 '15 at 15:02