OpenClinica / enketo-oc

OpenClinica's fork of the Enketo web forms monorepo
Apache License 2.0
0 stars 1 forks source link

Calculate item with relevant logic in repeating group not calculating when it becomes relevant #96

Open pbowen-oc opened 2 years ago

pbowen-oc commented 2 years ago

Found in 2.5.6.oc-16

Steps:

  1. Open the attached form as a new record - Relevant Calc Repeat Group.xform.txt
  2. Select the radio button for each repeat

Expected: The note for each repeat shows the calculation value: 'abc' for the first repeat and 'def' for the second and third repeats.

Actual: The note displays the calculation value as expected for the first repeat, but it is blank for the second and third repeats. The calculation is not submitted for those repeats.

Screenshot 2021-09-30 000353

Note: Reopening the form with the second or third radio buttons already selected causes the calculations to display as expected in the form editing session.

Screenshot 2021-09-30 000640

pbowen-oc commented 2 years ago

@MartijnR - We had another example of this reported.

In this form - Relevant Calc Repeat Group2.xform.txt - the calculations on the second repeating group don't trigger for rows greater than one (as in the original form above). In this case, there is a separate repeating group on the form. When a new repeat is added to this other group, than all pending calculations in the other group immediately process.

Screenshot 2021-10-06 001807 Screenshot 2021-10-06 001839

MartijnR commented 2 years ago

first form: http://localhost:8005/single/fs/i/2wnm6qY3?ecid=1

issue is present in master of enketo-express-oc as well

Looks like this might have multiple causes.

One cause is the _updateCalc overwrite in this fork. When disabling that overwrite the 3 calculations are performed when the first Show Note is set to Yes, regardless of whether the others are relevant.

When calc update is called with:

Screen Shot 2021-10-08 at 4 43 41 PM

No nodes are found to update. The bug probably has to do with the the relative relevant path in "../shownote = 'Yes'".

MartijnR commented 2 years ago

The issue can be reproduced only if a) the calculation is separate (and not a readonly text input), and the calculate doesn't refer directly to the node that changes the relevancy (e.g just "1+1" will do)

There is something tricky about the form. Cannot reproduce with this: