Populating multiple choice questions with dynamic values - Trouble with choice filter

Hi all,

Interesting one for you here.

I'm trying to design a survey with an initial repeat group where the respondent lists the name, age, and gender of all their family members.

I want these names to populate several multiple choice questions later on in the survey.

To do this, I use 20 "dummy" names that get populated by the choices entered in the first repeat. This works fine, however it means that at each multiple choice there are several "blank" choices which is unacceptable.

My next step was to use a choice filter to narrow the list down to a number of choices that correspond to the number of repeats (or family members). For some reason, when I implement the choice filter, the labels of the choices suddenly disappear.

It's driving me insane trying to understand why this happens. Funny thing is, I swear I have done this process in the past successfully!

Any help would be much appreciated!

Replication.xlsx (132.5 KB)

It works fine in ODK collect. But mentioned problem happen in enketo web form. Could you please contact with enketo?

1 Like

Will do. Thank you for that. Should I take down this post or keep it up and update with solution in case it's useful for others?

Thanks for reporting! I quickly checked and I think this is not a bug. There is no official support for using ${name} references like this in options.

Technical details here: https://github.com/enketo/enketo-core/issues/615

1 Like

That's a very clever approach, @Steve_Dxn! Note that the underlying value saved for each of the choices will be literally the text ${pname2}, etc. That is, they will not get expanded. The fact that the correct names are displayed in the select works kind of accidentally in Collect, I'd say. I put the details in the issue @martijnr linked to above.

The approach I would take is described at Generate multiple choice alternatives, based on the answers in a repeat. Unfortunately, it currently requires modifying the form XML. There is a proposal to support it in XLSForm and hopefully that will happen soon: https://github.com/XLSForm/pyxform/issues/38

1 Like