Generate multiple choice alternatives, based on the answers in a repeat

Very interesting question!

This is possible but as far as I know you will need to write the dynamic select one in raw XML. What I would do is create my form in XLSForm leaving that question aside, convert the form to XML and then modify the select one.

The general idea is to use an itemset that refers to your repeat in the select1. To build my example, I started with the XLSForm here. Then I replaced the definition of the select1 with:

<select1 ref="/select-one-from-repeats/people_select_one">
  <label>Select the relevant people:</label>
    <itemset nodeset="/select-one-from-repeats/people">
      <value ref="person_name"/>
      <label ref="person_name"/>
  </itemset>
</select1>

The full, functioning form: select-one-from-repeats.xml (1.8 KB)

Notice that both the value and the label use the name entered by the user. Depending on what analysis you intend to do on the resulting data, you could also consider using a calculate that gets the position in the repeat and use that as the value.

7 Likes