List Question driving a Loop

Using the same List Question as described in List Questions, we want to gather income information for the people in a household. We will use a nested fast path loop as described in the following example:

Figure 1. Fast Path List Question driving a Loop Code Example
...
<loop loop-type="for-each" entity="Person"
  criteria="hasIncome==true" fast-path="true">
  <loop loop-type="while" loop-expression="hasMoreIncome"
    entity="Income">
    <question-page id="IncomePage" entity="Income"
      show-person-tabs="true">
      <title id="IncomePage.Title">
        <![CDATA[Income Details]]>
      </title>
      <cluster>
        <title id="IncomeDetails.Title">
          <![CDATA[Income Details]]>
        </title>
        <question id="type">
          <label id="Type.Label">
            <![CDATA[Type:]]>
          </label>
        </question>
        <question id="amount">
          <label id="Amount.Label">
            <![CDATA[Amount:]]>
          </label>
        </question>
        <question id="hasMoreIncome"
          control-question="true"
          control-question-type="IEG_BOOLEAN">
          <label id="ContinueQuestion.Label">
            <![CDATA[Does %1s have any more income?]]>
            <argument id="Person.firstName" />
          </label>
        </question>
      </cluster>
    </question-page>
  </loop>
</loop>

The first time the list question is encountered, the pages following the loop will gather income for the people that have been selected. Then when re-visiting the page containing the list question, the following can occur:

  • If the checkboxes are not modified, clicking Next will jump over the income loop and display the page after the loop.
  • If some of the checkboxes are unselected, clicking Next will delete the incomes corresponding to the people that were unselected, jump over the income loop and display the page after the loop.
  • If new checkboxes are checked, clicking Next will jump over the existing income pages, show new income pages for the newly selected people and then display the page after the loop.
  • If new checkboxes are checked and others are unselected, clicking Next will delete the incomes corresponding to the people that were unselected,jump over the existing income pages, show new income pages for the newly selected people and then display the page after the loop.