Using component to know time taken to complete a task

Hi, I don’t know how to work with the clock component (docs are confusing).
I have a quiz in my app. I just want to know how to configure the clock component so that it will assign the time taken to answer the whole quiz to a variable and display it. So in short, like a stopwatch. Any idea how to do this?

store the start time in a variable
at the end of the quiz use the Duration block to calculate the duration in milliseconds between start time and end time
you can convert the duration in milliseconds into something else, just use one of the other duration blocks
http://ai2.appinventor.mit.edu/reference/components/sensors.html#Clock

Duration Duration(InstantInTime start, InstantInTime end)

Returns duration, which is milliseconds elapsed between instants

number DurationToSeconds(Duration duration)

Converts the duration to the number of seconds.

number DurationToMinutes(Duration duration)

Converts the duration to the number of minutes.

number DurationToHours(Duration duration)

Converts the duration to the number of hours.

number DurationToDays(Duration duration)

Converts the duration to the number of days.

number DurationToWeeks(Duration duration)

Converts the duration to the number of weeks.

Taifun

2 Likes

Thank you so much!!!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.