The same question / calculation event behaving differently in Enketo & KoBoCollect android app

Dear @Kal_Lam,
I was surprised by the following behaviour (OCHA server).

  1. In Enketo, even on validation in Preview the calculations are not fired again. So I can change the data manually (Only for the once(…) cases I would expect this.)
  2. In KoBoCollect, the calculations will fire again on save. But NOT on moves through the form.
    Test01.xlsx (16.3 KB)

I thought calculations will fire on leaving the field, and at least on validation.
But after validation the manually edited values are shown.
image
Could you clear up my understanding, please? (Maybe separate this post as new topic?)
Kind regards

Hi @wroos,

Will have a look and get back to you!

Have a great day!

Hi,
I looked at your message and the issue here is more around the logic on when a calculation occurs. A calculation occurs on the form when you get to the question and not when you exit the question. So when you manually edit the question, this happens after your have already gotten to the question. In that case, the value you have entered in the edit would remain as the value on the question regardless of whether you used once() or not.

The use of once() is not meant to prevent manual edits from taking place, but rather recalculations from taking place. The only way to ensure that there is no chance of manually editing is to have the read_only for the question set to true.

I find it counter-intuitive to allow for an edit in a calculate question.

Stephane

1 Like

Dear @stephanealoo,
thanks. once() behaviour is known and like expected.
calculation with once(… ) is sometimes useful (as discussed in the community) to set a dynamic default, like pre-setting a date type entry field as once(today()),

  • Is it right that calculations are NOT re-fired on validation in Enketo (Preview)??

They are re-fired on save in KoBoCollect. You can test both with the given xls example.

  • I think calculations are also re-fired if they depend on another variable which is changed. Is this right??

Could you give more information on the 2 remaining questions, please?
Kind regards
Wolfgang