The ODK core team would like to add support for referencing form media (images, audio and video) in external secondary instances that can be used in the form in select options, defaults and as question answers. This is the first part of a set changes that should eventually add support for entity media.
Changes
The changes proposed are:
XForm
-
Additional specification around how non
jr://links should be handled by clients when used in as question/select media, defaults or as question answers (the latter including "dynamic defaults"). A value likemyFile.jpgshould be treated as a relative path for either form media (equivalent tojr://<type>/myFile.jpg) or instance media (<instance media dir>/myFile.jpg). Clients should first attempt to load form media and then fallback to instance media if no form media exists for the given value. -
Add a
referenceattribute to value nodes withintext(foritext). Iftrue, it indicates to a client that the element value is a column mapping, as opposed to a literal value to be used directly:<text id="c1-itemset:label"> <value reference="true">label_column</value> <value form="image" reference="true">image_column</value> <value form="audio" reference="true">audio_column</value> <value form="video" reference="true">video_column</value> </text>
XLSForm
Add a new sheet secondary_instances that allows configuring media/translation column mappings for secondary instances:
| name | label | image | image::English (en) | audio::French (fr) |
|---|---|---|---|---|
| c1 | label | image | image_en | audio_fr |
This will create the /itext/translation/text/ nodes required (as detailed above) which will be identified as <instance_name>-itemset:label from the itemset in question nodes for select_one_from_file:
<select1 ref="/test_name/q1">
<label ref="jr:itext('/test_name/q1:label)"l/>
<itemset nodeset="instance('c1')/root/item">
<value ref="name"/>
<label ref="jr:itext('c1-itemset:label’)" />
</itemset>
</select1>
Future expansion
- The
secondary_instancessheet could have a column that defines the actual csv file name for the instance allowing name to act as an identifier for the configuration rather than the file and the identifier. This would unlock having different column configurations for different questions. - The XForm generated by XLSForm for internal and external selects use
itextslightly differently. In the future, internal selects could adopt the approach being proposed here as well.