List Questions

In an earlier example, we saw a requirement to gather income information for the people in a household. In order to only gather income information for the people who actually have income, a question was added to the 'Household Members Details' page to indicate if the person has income or not.

IEG provides an alternative to asking the same boolean question for a number of entities. A list question can be used to gather all the answers at the same time.

Continuing the previous example where information has been collected about the people in the household, the attribute hasIncome has been added to the Person entity to indicate if income information should be collected for the person, as follows:

Figure 1. Has Income Person Schema
<xs:element name="Person">
  <xs:complexType>
    ...
    <xs:attribute name="hasIncome" type="IEG_BOOLEAN"/>

Like questions, list questions must be added to a cluster. Where list questions differ is that you must specify the type of the entities that will be displayed in the list. The ID of the list question corresponds to the name of the boolean attribute that should be set if the user selects an item in the list. As with questions, a list question should have a label to indicate the purpose of the question. List questions should also have an item label element. The item label specifies which attribute from the entities should be used to identify the entities in the list. In the following example, the first name of the household members is displayed to identify them.

Figure 2. List question
<question-page id="AnyoneHaveIncome">
...
  <cluster>
    <list-question id="hasIncome" entity="Person">
      <label id="HasIncome.Label">
             <![CDATA[Which people have income?]]>
      </label>
      <item-label>
        <label-element attribute-id="firstName"/>
      </item-label>
    </list-question>
  </cluster>
</question-page>

So rather than adding a question in the loop where the household member details are gathered, once the household member details have been captured a list containing the household members can be displayed. The user can then select the members that have income.

List questions are particularly useful when used in conjunction with a for-each loop, referencing the question that was set in the list-question in the criteria expression of the loop. List questions can also be used with entity types other than Person.