Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support selecting from external dataset in forms #9875

Open
jkuester opened this issue Apr 2, 2025 · 2 comments
Open

Support selecting from external dataset in forms #9875

jkuester opened this issue Apr 2, 2025 · 2 comments
Assignees
Labels
Enketo Affects Enketo forms Type: Feature Add something new

Comments

@jkuester
Copy link
Contributor

jkuester commented Apr 2, 2025

Is your feature request related to a problem? Please describe.
Sometimes in a form you want to allow the user to select from very large set of choices. Currently, the only way to do this is by adding all the choices to the choices tab (aka the "internal" dataset).

This approach does not scale well for a number of reasons:

  • It can be hard to maintain the list of data, particularly keeping the data in sync across multiple different forms that use the same dataset.
  • The xlsx files can become large and unwieldy to edit
  • The form xml file produced by cht-conf is very large and cht-conf's form validation logic will not perform well.

Describe the solution you'd like
Enketo supports a select_*_from_file question type that allows for specifying that the data to select from is coming from an external dataset. We should add support to the CHT for this question type. External data files could be uploaded to the server as attachments on the form doc and then injected into the form model when initializing the Enketo form.

Describe alternatives you've considered
I did spend some time exploring the possibility of using the extension-libs to do something here. Unfortunately, the intricacies/functionality of select_* questions are so closely integrated with the Enekto form lifecycle (which requires that the form-model data be completely initialized when creating the form that I could not find any feasible approach from that angle.

Additional context

The select_*_from_file question type basically causes the select widget to look for an external instance in the form model. We are already adding an external instance to forms containing contact-summary data. I think it should be fairly straightforward to extend this code to include more xml instances in the options.external list that gets passed to the EnketoForm constructor.

The MVP here would seem to be including an xml file that exists as an attachment to the form doc. For completeness, this would also probably include changes in cht-conf and the api server to upload/save the attachment to the doc.

@jkuester jkuester added Enketo Affects Enketo forms Type: Feature Add something new labels Apr 2, 2025
@Akshanshkaushal
Copy link

@jkuester I would love to work upon this issue. Could you please assign this to me ?

@andrablaj
Copy link
Member

Thanks @Akshanshkaushal! Additionally, please review the development workflow and the style guide for extra guidance about contributing to the CHT Core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enketo Affects Enketo forms Type: Feature Add something new
Projects
None yet
Development

No branches or pull requests

3 participants