-
Notifications
You must be signed in to change notification settings - Fork 5
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
Calculations for repeating group items not working like before #22
Comments
Looks pretty serious.
|
@pbowen-oc, @kkrumlian, for expediency sake, could somebody at your side do the 2 things I mentioned above? Since it doesn't deal with submissions, it doesn't require using a backend. |
Martijn to do This appears to be caused by a customization in this fork. In enketo-express-oc: http://localhost:8005/preview/?xform=http://localhost:3000/form/repeatgroup_simple/form.xml Removing the 'init' calculation (that doesn't actually do anything) indeed avoids the issue. Very strange. Cause appears to be in the calculate module customization. Something to do with first clearing the calculation values (due to non-relevancy) as desired by OC. It looks like the new enketo-core no longer re-calculates them when the repeat becomes relevant. Why this doesn't happen when the init no-op question is removed is still a mystery and may mean my diagnosis is wrong. |
Hi @MartijnR ~ I tried to debug the issue, and here are my findings : in HTML it looks like this the problem is when the code(line 454 in calculate.js) that get the ancestorGroup from that input(bp_rg_num_init), The result value on line 489 in calculate.js is false for input(bp_rg_num_init) then it's ancestor( This caused an issue when the other input the false above will be value of
Do you think we can exclude the I'm not quite familiar with the logic code so I'm sorry if my deduction is wrong, can you elaborate more about the calculation you mentioned above? |
@theywa, quite an investigation! I still have to read through it a bit more, but I wanted to quickly comment on the This may not necessarily be helpful, as I may have misunderstood one of your comments. Will try to read through your comments more thoroughly later. |
I don't know. I don't think so. I am looking at the code too. I don't see where |
I observed this issue in the Blood Pressure repeating group on my test form on the first pass through as a new form. However, when I reopened the form as an existing record, the calculations in the repeating group ran as expected. So, this looks like the same issue as #16. |
My findings:
One potential fix in enketo-core, calculate.js, _isRelevant fn is changing line 486 to:
I think this could be done in enketo/enketo as well but we need to first identify a real bug in Enketo/Enketo, I think (no tests failing in enketo-core when doing this).
For now, in this fork, let's just overwrite the preInitRelevance cache feature by adding the following line to calculate.js in this fork (the update function): // We're disabling this map because it is causing this bug
// https://github.com/OpenClinica/enketo-oc/issues/22
// which we don't quite understand, but need to fix urgently.
this.preInitRelevance = new WeakMap(); We'll likely incur a performance hit by disabling this cache until the PR to enketo/enketo can be created and merged. So @theywa, while looking into your analysis it appears you found the cause, and I think I stumbled upon a temporary "fix" and figured it was easiest to create a PR for it myself. I'll ask you to review the PR! |
…re non-relevant upon load, kobotoolbox#730
@MartijnR ~ Thank you for the explanation. Ah yes, that is much easier to reset the map than figure out how to handle the |
@theywa - If the workaround solution addresses the calculation issue and does not cause other issues, then it works for me. |
removed temporary workaround for https://github.com/OpenClinica/enketo-express-oc/issues/730
Describe the bug
Calculations that should display information for each repeat group are not executing as expect/at all. The first repeat of the repeat group should show the position1 for item "" but this field is blank.
To Reproduce
Expected behavior
Item "This is a Repeating Group entry:" should have a value of 1.
Screenshots
Browser and OS:
-Windows
-Browser - chrome
Notes:
When I cut the xform down to 2 items, Item 1: "Was blood pressure measured?" and item 2: "This is a Repeating Group entry:" (item 2 is part of the repeat group) the calculation works as expected and I see the value 1 for "This is a Repeating Group entry:".
I was able to simplify the form down to item "Was blood pressure measured?" and then 2 items in the repeat group. 1 that is a none calculate type item "This is Repeating Group entry :". And the second must be an item with the type calculate. This form did not work and calculations were not show.
If you put two integer items or two non-calculate items, there will be no issue. Once you add a calculate item within the repeat group all other item calculations are broken.
The text was updated successfully, but these errors were encountered: