Using 'jr:choice-name' for multiple selections

635
2
04-29-2020 09:30 AM
KerryKang
Occasional Contributor II

Hello all, 

Is there any syntax using 'jr:choice-name' for all/ any selections in multiple choices? I hope to get labels in the attributes no matter how many answers are selected. I am aware that 'at' can be used to pull out the value in the specific order, but not sure how I can apply it to the entire answers. 

0 Kudos
2 Replies
BrettStokes
Esri Contributor

Hi Kerry,

Unfortunately this isn't possible using jr:choice-name(), which will only use the label to populate the attribute if one selection is made. Did you come up with a workaround or alternative to this workflow? If so, please share it on the forum.

Thanks,

Brett

BenjaminAu
New Contributor

Hi Brett/Kerry,

I am totally new to GIS domain. So happens I came across this website with the extensive methods to invoke within XLS for Survey123 Connect. Within the PDF there is a section describing the jr:choice() for multiple choice questions. Below is the example used to select exactly three colors:

Table 1: Survey

typenamelabelhintconstraintconstraint_message
select_
multiple
colors
color_prefsWhat colors do you like?Select threecount-selected(.)=3Select exactly three.

 

Table 2: Choices

list_namenamelabel
colorsredRed
colorsblueBlue
colorsyellowYellow
colorsgreenGreen
colorsorangeOrange
colorspurplePurple

 

Table 3: Survey with jr:choice()

typenamelabelhintcalculation
select_multiple colorscolor_prefsWhat colors do you like?Select three. 
calculatecolor_0  jr:choice-name(
selected-at(${
color_prefs},
0),
’${color_prefs}’)
calculatecolor_1  jr:choice-name(
selected-at(${
color_prefs},
1),
’${color_prefs}’)
calculatecolor_2  jr:choice-name(
selected-at(${
color_prefs},
2),
’${color_prefs}’)
notecolor_noteSelected colors:${color_0}
<br>
${color_1}
<br>
${color_2}
 

 

Snapshots from the PDF are attached here for your reference. Pardon for the resolution, it is snipped based on the PDF. For more information you can visit this link and download the PDF for its full information: https://docs.getodk.org/

I was able to use such concept on my form to produce the expected output.

Hopefully it helps!

0 Kudos