Anyway to create a stopwatch to track how much time lapses before a question is answered?

20 views
Skip to first unread message

Staci Leigh

unread,
Feb 3, 2017, 8:01:50 AM2/3/17
to commcare-users
Hi all,

Is there anyway to create a stopwatch function in CommCare? I'm hoping to track how long it takes for someone to read a small passage. Rather than using an actual stopwatch and recording the time manually in CommCare, I wanted to know if there was any start/stop function or workaround I could use.

Cheers,

Staci

Michel Akkaoui - de Sousa

unread,
Feb 3, 2017, 8:19:07 AM2/3/17
to commcare-users
Here is an option : 

  • Create a multiple choice question named quest_start
    • Label : 'Are you ready ?'
    • with a single choice that is labeled as 'start'
    • with display condition set as 'quick'
  • Create a hidden value named 'start' with calculate condition set as : if(/quest_start = 'start', now(), '')
  • Create a question list with two things in it : 
    • Your text as a label
    • A multiple choice question with parameters : 
      • id : quest_stop
      • Only one choice named 'stop'
  • Create a hidden value named 'stop' with calculate condition set as : if(/quest_stop = 'stop', now(), '')
  • Create a hidden value or a label with calculate condition set as : stop - start. It will give you the time 
When the reader starts the form, he will encounter the quest-start question. When he press start, the phone goes automatically to the next page witch shows the text to be read and the stop button. When stop is pressed, the phone make the calculation to determine the difference between time when start and time when stop.
Depending on the phone capabilities and the length of the text to be read, this stop watch as a few milisecondes of precision. The result of the substraction is a number of seconds I guess...


Michel

William Pride

unread,
Feb 3, 2017, 12:44:33 PM2/3/17
to commcare-users
Hi Staci,

Unfortunately I'm not sure that Michel's solution will work (though worth trying) - the reason being that calculations can fire more than once, for example they would likely be re-triggered when the form is completed. This would result in both hidden values just containing the end time of the form.

The easiest solution might be to have this passage be in its own form so that you can use the form's built in start and end times as your proxies. You could use end of form navigation to make the transition more seamless.

Cheers,
Will

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

Michel Akkaoui - de Sousa

unread,
Feb 3, 2017, 1:56:30 PM2/3/17
to commcar...@googlegroups.com
Thanks will for the precision. I didn't know the app re-triggered the hidden values when the form is completed... I understand we won't be able to store the value in a case property, but will the proposition works just to output the time spent reading in the same form though ? 

Michel 


--
You received this message because you are subscribed to a topic in the Google Groups "commcare-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/commcare-users/0rks8RWvg8M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to commcare-users+unsubscribe@googlegroups.com.

William Pride

unread,
Feb 3, 2017, 2:04:13 PM2/3/17
to commcare-users
Hi Michel,

Your calculation would be correct when first calculated; however, when the calculations fire again they also re-trigger all the calculations that are dependent on them. So, the differential would also be recalculated.

Cheers,
Will

Simon Berry

unread,
Feb 3, 2017, 2:33:24 PM2/3/17
to commcar...@googlegroups.com
Am I right that all hidden values are re-calculated after every question?

Simon


Michel 


To unsubscribe from this group and stop receiving emails from it, send an email to commcare-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "commcare-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/commcare-users/0rks8RWvg8M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to commcare-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to commcare-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to commcare-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Please excuse any syntax errors. This email was sent from my phone.
07932 107109.

William Pride

unread,
Feb 5, 2017, 5:12:13 AM2/5/17
to commcare-users
Hi Simon,

The set of calculations to update is determined by a fairly complex algorithm that figures out the minimum set of calculations that need to be updated as an optimization. In theory, however, this should result in the same behavior as if all calculations were re-calculated (IE any value that could have changed, would have changed).

Cheers,
Will



Michel 


To unsubscribe from this group and stop receiving emails from it, send an email to commcare-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "commcare-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/commcare-users/0rks8RWvg8M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to commcare-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to commcare-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to commcare-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Please excuse any syntax errors. This email was sent from my phone.
07932 107109.

--
You received this message because you are subscribed to the Google Groups "commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to commcare-users+unsubscribe@googlegroups.com.

Clayton Sims

unread,
Feb 5, 2017, 11:12:50 PM2/5/17
to commcare-users
As one more confusing wrench in the works - Technically the now() calculation is a bit unique in that it sometimes evaluates only once, which may make it possible to exhibit the behavior that has been mentioned here, but that behavior is hard to predict and quite finicky.

We have a plan for how to execute this behavior cleanly in the future, but it isn't implemented in a usable way currently.

Currently I can think of one way, though to create a timestamp of when a question was answered (or answered in a specific way) which would be to make a repeat whose count is set to 

if(/data/question_to_answer = '', 0, 1)

and set a now() based calculation as the Default Value of a member of that repeat.

that should result in one element whose calculation only triggers once, conditionally based on a question in the form.

-Clayton
Reply all
Reply to author
Forward
0 new messages