getodk/javarosa

Describe and document which expressions are evaluated when

Opened this issue · 6 comments

During #515, we detected a special scenario where a group's relevance might make some field calculations not be evaluated. See Safe2014DagImplTest.verify_relation_between_calculate_expressions_and_relevancy_conditions() for context.

We should discuss this and:

  • Decide if we should evaluate all expressions regardless of relevance or not, considering the performance implications.
  • In any case, describe and document how all this works. Specify which expressions get evaluated when and under which circumstances.

@lognaturel affirms that "I believe Gareth had found something in the XForms spec that suggested that expressions should be evaluated regardless of relevance. This has performance implications, certainly.". @tiritea, could you provide more info regarding this?

found it, in https://www.w3.org/TR/2012/WD-xforms20-20120807/: [emphasis added]

6.1.4 The relevant Property

Description: indicates whether the model item is currently relevant. Instance data nodes with this property evaluating to false are unavailable in the user interface ...

note emphasis that is about visibility in UI...

And later:

Elements other than form controls may also use a Single Item Binding that selects a non-relevant node, but such elements are not made unavailable or non-operable due to the Single Item Binding because it is not a UI binding expression...

Which I interpret to mean calculations - as a non-UI element - are specifically not disabled (ie are "not made non-operable") as a consequence of their immediate (or inherited) relevance evaluating to false. More specifically, calculations in non-relevant groups are still to be evaluated.

Thanks, @tiritea. I think you're right and we should always compute calculates. It's clear to me now that the relevance of a field is a UI concern. What do you think, @lognaturel?

If we all agree on this, we should raise an issue and review this accordingly, starting from describing different regression scenarios and creating tests for them.

FYI adding this as it appears 'relevant' to discussion (no pun intended... ;-) :

#284

Btw, the practical benefit of always performing calculations irrespective of relevance is that it permits processing lists using repeat groups, but ‘hiding’ the repeat group from the UI so the user doesn’t have to nav thru it; eg my geofence or geotrace-2-KML forms.

Thanks for taking the time to add info, @tiritea!