If an attribute is defined in a DS schema as a codetable, when the corresponding question is displayed the default behavior is to display the question as a drop-down. Only one answer can be selected in the drop-down list.
For example, if these is a requirement to capture a household member's home state, a new a new domain definition can be added to represent the AddressState codetable and an attribute to store the home state can be added to the Person entity as follows:
... <xsd:simpleType name="IEG_STATE_ADDRESS"> <xsd:annotation> <xsd:appinfo> <D:options> <D:option name="code-table-name">AddressState</D:option> </D:options> </xsd:appinfo> </xsd:annotation> <xsd:restriction base="IEG_CODETABLE_CODE" /> </xsd:simpleType> ... <xsd:element name="Person"> ... <xsd:attribute name="homeState" type="IEG_STATE_ADDRESS" />
A question to capture the hone state information can then be added to the script as follows:
<question-page id="AboutYouPage" entity="Person"> ... <cluster> <question id="homeState"> <label id="State.Label"> <![CDATA[Please select your home state:]]> </label> </question> </cluster>
When the script is executed the question is displayed to the user as a dropdown.
IEG also supports defining codetable questions in such a way that the user can make multiple selections.
When a codetable question is single-select the answer to the question can be stored in a single attribute of an entity. Because there are multiple possible answers in a multi-select codetable question, a sequence must be added to store all the answers and a new entity type must be defined to represent the answers in the sequence.
<xsd:element name="Person"> <xsd:complexType> <xsd:sequence minOccurs="0"> <xsd:element ref="State" minOccurs="0" maxOccurs="unbounded" /> </xsd:sequence> ... </xsd:complexType> </xsd:element> <xsd:element name="State"> <xsd:complexType> <xsd:attribute name="stateCode" type="IEG_STATE_ADDRESS" /> </xsd:complexType> </xsd:element>
Making a codetable question multi-select is done by setting the multi-select attribute of the question to true. When adding a multi-select codetable question, the cluster that the question is being added to must be mapped to the new entity type representing the answers to the question. In our example the cluster must be mapped to the State entity. The page that contains the multi-select question must be mapped to the entity that contains the sequence. In this example the page should be mapped to the Person entity. Finally, in order for a number of options in a multi-select codetable question to be visible a layout should be added to the question. The layout should specify the number of visible rows for the question. If the number of options available for the question exceeds the number of rows specified in the layout a scroll bar will be added to the question.
<question-page id="AboutYouPage" entity="Person"> ... <cluster entity="State"> <question id="stateCode" multi-select="true"> <label id="State.Label"> <![CDATA[Please select the states you lived in:]]> </label> <layout> <num-rows>4</num-rows> </layout> </question> </cluster>
When the script is executed the question is displayed to the user as a list of codetable descriptions with one checkbox for each item.