Constraint moving forward in a questionnaire based on selections in a Repeat

Hi All,
I am working on a Household survey questionnaire in which we need to
identify who was the key respondent in teh survey. Only 1 Key Respondent
must be identified.

  • At start of survey, the number of Household members is asked for. This
    gets saved as "CountOfRepeatSelection/hh_members"
  • Then there is a repeat section "CountOfRepeatSelection/demo" where
    in the number of repeats is limited by "*CountOfRepeatSelection/hh_member
    *" using jr:count property
  • Within repeat section, there is a question on "whether the person is
    key respondent or no", IF yes, then "*
    /CountOfRepeatSelection/demo/keyrespcounter2*" receives a value of 1
  • After the repeat section has completed, I have a Note question *
    "/CountOfRepeatSelection/no_key_resps*" which displays the total number
    of key respondents using "sum( /*

Now I want to restrict moving on to the next question if the number of key
respondents is not equal to 1.
I have tried to add a constraint to /*CountOfRepeatSelection/demo/keyrespcounter2
** *but it does not seem to be working in teh sense that the next question
comes up regardless of the number of key respondents identified. The XML is
attached for reference.
Any help would be much appreciated.


CountOfRepeatSelection.xml (3.92 KB)

I have updated the form and moved the selection of Key respondent to
Outside the Repeat group. I have used the technique suggested in
choiceOfRepeat.xml. Many Thanks to Mitch Sundt for showing the path in his
prior post

I have now two Repeats in the Form:

  1. First is the Household member repeating list. (
    constrained by the number of household members informed earlier): demo
  2. Second is the Illness episode list (un-constrained): hsb

*Now I am able to: *

  1. Select a key respondent among the members entered using a Select1
    type field
  2. Select a name of ill family member in the *hsb *Illness-episode list
    using a Select1 type field. This is of particular utility to me in field
    level surveys.

This form creates three data tables:

  1. illnessbehaviour_core
  2. illnessbehaviour_demo
  3. illnessbehaviour_hsb

For analysis purposes, I will need to link the data tables. To link demowith
core data, i need to use two relationships simultaneously:

  • illnessbehaviour_demo._ORDINAL_NUMBER with
  • illnessbehaviour_demo._TOP_LEVEL_AUR with illnessbehaviour_core._URI

To link demo with *hsb *data, i again need to specify two
relationships simultaneously:

  • illnessbehaviour_demo._ORDINAL_NUMBER with
  • illnessbehaviour_demo.TOP_LEVEL_AURI with illnessbehaviour_hsb.

This is quite extensible and I feel, this may be used with success in vast
majority of household surveys.
The only downsides i see for now are:

  1. Due the jr:count implementations standards, if wrong number of
    household members are entered and data entry initiated, then one is forced
    has to enter all those members even upon correcting the HH member count
  2. The Selection list for household members shows 1-25 members always
    even if the actual number of household members may be less. It is a
    small inconvenience More importantly, it mandates a routine data
    management check to identify and correct these errors
  3. This will work only for top level repeats,. This is something I can
    live with. Having repeats section within a repeat section has given me
    enough troubles in past while using paper forms !!!

The Form I am using is enclosed. Also enclosed is the SQL script that I use
for matching records across data tables.

PS: I using a local install of ODKAggregate to manage and pull data from
device, and MySQL to store data.

illnessbehaviour.xml (10.1 KB)

checking_key_rep_SQL.sql (702 Bytes)