I have an XLSForm that uses once(random()) with a following calculation, "int(${randNum}*${hhSize})+1" to select a random individual within a household. However, in reviewing the first data today, it's clear that the random number selected in once(random()) is the same for all instances submitted by the same tablet. So each enumerator has submitted four instances so far, and each random number in the data repeats four times. We are using ODK 1.14.0. I've also raised this on GitHub - there's an example form there.
In the immediate term, is there any alternative means of generating a random number I can use? We have already started data collection now so any thoughts would be gratefully received. Not sure what to do as this seems to be the recommended way to generate random numbers?
Small update - I did find a workaround for the time being by adapting this previous suggestion. The random number takes the seconds field of the start time like so:
int(format-date-time(${start}, "%S")) div 60
Which I believe will generate a close-enough-to-random number between 0 & 1.
@Grzesiek2010 the once function means essentially “only evaluate the arguments if the node’s value is null”. This is important when using functions like random or now because otherwise they will be constantly re-evaluated up through form saving.
The behavior of random on its own currently matches what once(random()) should do but that is a bug and should not be relied on.
In 1.14.1 this problem stays!!! It's horrible!!! It's ruins everything! HELP!!!
Can someone quickly rollback once() to some previous state 1.13.?
Please!
Thank you very much for the detailed issue report, @Bramleyl. This was a tricky issue to identify and your report was very helpful. The problem has now been fixed thanks to @dcbriccetti and is released in ODK 1.14.2.
New forms will immediately work as expected. For forms that were first opened in versions 1.14.0 or 1.14.1, you will need to clear the form cache for the fix to come into effect. Tap on the three dots at the top right of the landing page and then go to admin settings. From "Reset application...", select ONLY "Form load cache (.cache folder)" and tap reset. Resetting the form cache is always a safe operation, it just means the form may take a little bit longer to open next time it is loaded.
Forms that were first opened in versions less than 1.14.0 should have continued working as expected.