getodk / web-forms

ODK Web Forms enables form filling and submission editing of ODK forms in a web browser. It's coming soon! ✨
https://getodk.org
Apache License 2.0
9 stars 7 forks source link

Field/questions order #134

Open sadiqkhoja opened 3 months ago

sadiqkhoja commented 3 months ago

Currently, the order of the children in the tree generated by xforms-engine is based on the order of the nodes in <model>. It should be based on the controls in the <body>.

This is a low priority issue, as it is extremely rare to see a mismatch between the order of <model> and <body> because pyxform orders them the same.

If we choose not to fix this, it would be nice to document this.

eyelidlessness commented 3 months ago

To capture something I mentioned in Slack on this topic, the underlying cause for this ordering is that we parse the body in a first pass, and then effectively use it as a ref/nodeset lookup to associate body-defined aspects of a node with their model-defined counterparts, and then treat this conglomeration as effectively the definition data model to initialize instance state.

There are other consequences for this besides ordering, including edge cases where certain body structures are not associated properly at all (here's an example from a refactor branch I created a few months back to make this parsing process more clear).

I agree that this is all probably lower priority, but it may be helpful for documentation (or future work if we reconsider its priority) to recognize that there are at least a couple distinct issues, with the same root cause.