Time stamps

Hi,

I am trying to collect multiple time stamps in my ODK form. I used a note
with calculation code "if( boolean-from-string(${variable name}),
format-date-time(now(), '%H:%M:%S'), format-date-time(now(), '%H:%M:%S'))",
and this displays the time stamps on the tablet. However, the time stamps
aren't saved and finalised, and end up being all the same time in my
exported data (csv or excel).

Does anyone know how I can fix this?

Thanks.

Best Regards,
Amy

When you finalize the form, it is traversed from the start to the finish,
and all values are recalculated. This causes the now() values to be
re-calculated, causing all of your values to be updated to one time.

The once() function can be used to wrap a formula so that it is evaluated
only once.

However, it is tricky to use.

If you had a calculated field that had once(now()) as the very last
question in your survey, it would be evaluated at the very start of your
survey because the formula does not depend upon any other fields in your
survey. I.e., formulas are evaluated whenever all of their references have
values or have values change.

You can play around with relevant conditions to restrict when a formula
will be evaluated.

In general, this type of logging-of-timestamps is not well supported by
XForms and ODK Collect.

For user interface studies, we support UI action logging (with timestamps
of each user interaction) if the following file exists:
"/sdcard/odk/log/enabled"

In that case, the activity logging is written to
"/sdcard/odk/log/activityLog.db"

This is a SQLite database. We have not used this in a while, so some of the
newer widgets may not log all of their interactions.

There is no mechanism to retrieve this file from the devices. It was used
for small-scale user studies.

ยทยทยท On Wed, Jul 13, 2016 at 6:38 AM, Amy Pannapat Chanyarungrojn < amychanya@gmail.com> wrote:

Hi,

I am trying to collect multiple time stamps in my ODK form. I used a note
with calculation code "if( boolean-from-string(${variable name}),
format-date-time(now(), '%H:%M:%S'), format-date-time(now(), '%H:%M:%S'))",
and this displays the time stamps on the tablet. However, the time stamps
aren't saved and finalised, and end up being all the same time in my
exported data (csv or excel).

Does anyone know how I can fix this?

Thanks.

Best Regards,
Amy

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com

Resurrecting the time stamp issue, as I'm trying to collect the time at multiple spots in a form (using XML forms).

I've tried creating a type "acknowledge" then using ${acknowledge} = 'OK' as a relevant condition for the following two strings calculating the hour and minute:
once(format-date-time(now(), '%H'))
once(format-date-time(now(), '%M'))

But this returns the hour and minute when the form was first opened; it doesn't calculate after the acknowledge trigger. Based on @Jorge_Durand_Zurdo post, what I'm trying to do seems possible, but I've run out of ideas on how to implement this.

Thanks in advance for any help! -- Greg

See the sample form at Timestamping responses.

It might also be good to read https://docs.opendatakit.org/form-logic/#when-expressions-are-evaluated to understand how once() works.

Unfortunately, this is working as designed: relevant='...' conditions only determine whether or not to display a question, they have no effect on whether a calculation is performed or not. Hence all your once() calculations are fired soon as you start the form, so they all effectively capture the start time.

What you need to do instead is add an explicit condition in the 'finished' timestamp calculation as to whether to perform the once() or not, eg checking an acknowledgement response. Try this:

timestamps.xls (5.5 KB)

where the finished timestamp is only captured when the user hits the acknowledgement (last question of form). Of course, there's still nothing to prevent the user going back and changing earlier responses after hitting 'OK', but that's about the best you can do.

Thank you @yanokwa and @Xiphware! I eliminated the relevant condition and instead used these calculations:
if(${acknowledge}!='',once(format-date-time(now(), '%H')),'')
if(${acknowledge}!='',once(format-date-time(now(), '%M')),'')

That works. I appreciate the help.

YW. :slight_smile: Please remember to close out question threads as 'solved' once you have a working solution.

Happy to mark solved, but don't see how to do so.

hit the boxed check mark under the relevant response. check