kobotoolbox / enketo-express

We've moved! Please use the new repository 🠊 https://github.com/enketo/enketo-express
Apache License 2.0
102 stars 90 forks source link

OC only: retrieve custom values [WIP] #936

Closed MartijnR closed 6 years ago

MartijnR commented 6 years ago

earlier issue: https://github.com/kobotoolbox/enketo-express/issues/553

Requirements:

  1. Obtain a custom value based on other values in the form during the data entry session.
  2. Update calculations/contraints/relevants/required evaluations based on the random value change.

Implementation discussed so far:

  1. Use external data mechanism to obtain document with random value, e.g. an instance with a fixed random id attribute.
  2. Use a question to store the random value. A change in that value would automatically trigger the resulting form engine updates. This can be a readonly question with a calculation that obtains the value from the instance e.g. instance('random')/data/thevalue
  3. Use a button in that question (a custom OC widget with a random appearance e.g.) to re-fresh the external data document (asynchronously!), and then update the calculation in that question.
  4. Use a custom bind attribute on the question to pass field names that should be used in the randomization, e.g. oc:params="field1, field2, field3".
  5. OC would use the field names in the previous point to craft a URL to be published in the manifest
  6. The URL (API endpoint) would use the auto-saved values in the randomization.

Potential issues:

  1. asynchronous fieldsubmissions, and asynchronous data refresh may cause issues. Eg. a fieldsubmission for field1 could still be pending at the time the user requests the random value. Similarly, a request for a random value could still be pending when the Complete button is clicked.
  2. random values could be recalculated (at any time), so good to use once() for this, and serve empty external data documents if there isn't enough information to create a random value (e.g. an empty form is loaded).
  3. some potential XLSForm syntax issues, e.g. if a form is created with two similar random questions but with different parameters (though could be caught in enketo-validate). It would be much better if the parameters could be added to the <instance> to avoid this.
  4. A parameter field cannot live inside a repeat, I think
screen shot 2018-02-07 at 2 52 04 pm
MartijnR commented 6 years ago

@kkrumlian

MartijnR commented 6 years ago

Possible show dark overlay to block any user interaction while data pulling is ongoing.

MartijnR commented 6 years ago
enketo-issue-mover commented 6 years ago

This issue was moved to OpenClinica/enketo-oc#199