Output label for selected option

This problem comes up for me all the time so if anyone can solve it I’ll be
very, very grateful.

Often in surveys we’ll have a structure like this:

  • Checkbox with 20 animal types, to select all types the household owns
    / farms
  • Repeat group with repeat count of count-selected(animal_types)
  • Calculate selected-at(animal_types,position(animal_type_repeat)) to
    get the value of the next selected animal type for each repeat loop
  • 5 questions about each animal type in repeat group with the value
    output in the label (e.g. how many head of <animal_type>, what is the cost
    in feed per week for <animal_type> etc)

This works fine if a) the app only has one language and b) the values for
the checkbox options are human readable.

However, if we have multiple languages or the checkbox option values are
coded for import to Stata or R (e.g. 1 = horses, 2 = beef cattle, 3 =
ducks) then we need to include a whole key in each question for each
language so the mobile worker knows which animal type they are asking about.

So my question is, is it possible to output the label of the checkbox
option in the current language if we have the question id and the selected
position? Like the selected-at function, but with label instead of value?

I believe it can be done with lookup tables and instances, but as this is a
very common structure (it might be used more than 10 times in a long
survey) that would mean creating a lot of lookup tables and would reduce
the ease of editing of the application.

Pretty please say it’s possible! You will make my year.

Thanks in advance.

Amber.

Amber,

This is possible but only with some fairly complicated custom XML that we
can’t offer full support for. If you feel comfortable working with the
XForm XML and debugging any issues that arise yourself, please email me
directly (wpride@dimagi.com) and I can walk you through the needed changes.

Cheers,
Will

··· On Sat, Sep 24, 2016 at 9:01 AM, wrote:

This problem comes up for me all the time so if anyone can solve it I’ll
be very, very grateful.

Often in surveys we’ll have a structure like this:

  • Checkbox with 20 animal types, to select all types the household
    owns / farms
  • Repeat group with repeat count of count-selected(animal_types)
  • Calculate selected-at(animal_types,position(animal_type_repeat)) to
    get the value of the next selected animal type for each repeat loop
  • 5 questions about each animal type in repeat group with the value
    output in the label (e.g. how many head of <animal_type>, what is the cost
    in feed per week for <animal_type> etc)

This works fine if a) the app only has one language and b) the values for
the checkbox options are human readable.

However, if we have multiple languages or the checkbox option values are
coded for import to Stata or R (e.g. 1 = horses, 2 = beef cattle, 3 =
ducks) then we need to include a whole key in each question for each
language so the mobile worker knows which animal type they are asking about.

So my question is, is it possible to output the label of the checkbox
option in the current language if we have the question id and the selected
position? Like the selected-at function, but with label instead of value?

I believe it can be done with lookup tables and instances, but as this is
a very common structure (it might be used more than 10 times in a long
survey) that would mean creating a lot of lookup tables and would reduce
the ease of editing of the application.

Pretty please say it’s possible! You will make my year.

Thanks in advance.

Amber.


You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.