-
Notifications
You must be signed in to change notification settings - Fork 134
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
Improve repeat count XForm output #435
Comments
Would a PR for this, with useful tests for these 3 ways of using repeat-count, be welcomed? |
Hi @MartijnR I'm trying to fix this issue. Which best route should I go first? Currently I'm trying to fix this by changing workbook_to_json method in xls2json.py. Is that the right one? |
Also, could you please attach desired xml file here? I found that desired xml above cannot pass odk validator. Thanks! |
Hi @gushil, Here is the XForm: I confirmed ODK Validate doesn't accept the 3rd case I'll have a look at pyxform code to see if I can tell where to make the changes. I'm not much of a pyxform expert though. |
@gushil, yes, I believe workbook_to_json is the place to be! Btw, make sure to the use the 'new' style of tests that use markdown (and not XForm files). Have fun! |
Thanks! We'll try to get the JavaRosa fix sooner than later. @gushil, our typical policy is to wait about a year to merge something that will lead to breaking behavior with one of either ODK Collect or Enketo. You may prefer to take on an issue that could be merged in a more timely way. |
I don't think this is what is supposed to happen per W3C XForms. @tiritea pointed out a while back that relevance is supposed to be only a display concern and not affect calculations. We may at some point need to explicitly describe what the intended behavior is in ODK XForms and verify that we are aligned across clients. |
Its worth noting that although relevance should not affect calculations per se, relevance is still inherited, and so any visible input questions within any enclosed repeats/sub groups should - as a consequence of being made irrelevant due to inheritance - be blanked upon submission. |
Thanks @lognaturel and @tiritea. I vaguely remember this discussion. Was it in Slack?
Good point. We could rewrite the third option to make it the same as the first option for now (if wanting to proceed). |
Thanks @gushil! We're just discussing another approach would actually solve the OpenClinica issue (and would be implemented on the Enketo side). It doesn't directly affect this pyxform issue, which will still be worthwhile, but makes it less of a priority perhaps. In any case, we'd either have to adjust the specs of this issue to prevent an issue in older ODK Collect clients or just wait (perhaps for a year) before merging it. So I'd still like to review your PR, but will get back to you after deliberating a possible Enketo change first. |
Another excellent issue @lognaturel brought up is that changing the location of the repeat count (second repeat_count case) changes the structure of the record. This could create issues when updating an existing form. |
Another thing that came out of the discussion with @tiritea and @lognaturel is that: The underlying issue 1 mentioned in the OP, is not actually an XForms issue, because XForms would "relevant prune" non-relevant nodes (including ones without a UI) upon submission, not in the middle of a session. I'll update the issue by:
|
There's an interesting plot twist that I discovered when looking at a possible JavaRosa change. It turns out that JavaRosa very explicitly only supports references and that this is baked in pretty deep. JavaRosa is the originator of |
Interesting twist indeed! If it's not easy to add support in Javarosa, I'm fine with correcting our spec. (Funnily enough, Enketo didn't support it either until a few months ago when I discovered the spec non-compliance - but it was a simple fix in our case). That would only leave case 1 (which bothers me most anyway because of the duplicate nodes), but as you mentioned in #441 while Aggregate is still used quite a bit, probably best to leave this for now. |
- Given a form with an item named "a_count" that holds the desired repeat count, and a repeat called "a", when pyxform injects an internal item suffixed with "_count" to hold the repeat count for "a", then pyxform emits a duplicate survey element error (2x "a_count"). - As described in XLSForm#435 (case 1), when the repeat count is just a reference to another item, then that item could be used directly, instead of injecting an item with a calculate item, thereby causing a name clash and thus the error. - for future reference, this code is a bit confusing but the dict structure of json["control"]["jr:count"] is a result of processing in dealias_and_group_headers (repeat_count -> control::jr:count -> dict). - adds new condition to existing logic, where if the expression parses to a single pyxform reference, then the item injection is skipped.
- Given a form with an item named "a_count" that holds the desired repeat count, and a repeat called "a", when pyxform injects an internal item suffixed with "_count" to hold the repeat count for "a", then pyxform emits a duplicate survey element error (2x "a_count"). - As described in XLSForm#435 (case 1), when the repeat count is just a reference to another item, then that item could be used directly, instead of injecting an item with a calculate item, thereby causing a name clash and thus the error. - for future reference, this code is a bit confusing but the dict structure of json["control"]["jr:count"] is a result of processing in dealias_and_group_headers (repeat_count -> control::jr:count -> dict). - adds new condition to existing logic, where if the expression parses to a single pyxform reference, then the item injection is skipped.
I think there
are 2is an issue with how pyxform transforms repeat_count values:1.
It places a new count node as sibling of the repeat. This means that any relevant condition on an ancestor of that repeat clears the repeat_count values and removes all repeats. This is not always desirable for implementations that want to keep irrelevant values stored in the model.See example below with the 3 different types of repeat_count values we support. I propose to change the output
of all 3the first and the third.Google Sheets
current output (relevant parts):
A cleaner, and less problematic, output would be:
The text was updated successfully, but these errors were encountered: