Content type: Memory Game, how to retrieve exact TIME SPENT from WP database
Submitted by Michaelabf on Thu, 10/13/2022 - 22:03
I'm using the Memory Game on my Wordpress site, I'd like to create a way of displaying a "today's quickest user" plus time, below the cards display.
I'm not a coder, but can probably work out the required PHP code ($wpdb etc).
Looking in the WP database, in the h5p_results table, the values there do not match the exact "time spent" as shown when playing the game. By "time spent", I mean the exact time between the first card being turned and the game completed ("Good work!" is displayed).
In the DB, there are values (in seconds) for Opened and Finished, but these do not match the real exact "time spent".
Could you advise please?
Fri, 10/14/2022 - 19:59
Content type: Memory Game, how to retrieve exact TIME SPENT from
here it would make more sense to contact the developers of H5P directly or to push this in feature request or to ask.
Sat, 10/15/2022 - 14:10
Hi Michaelabf!The duration
The duration property of the xAPI 'completed' statement that is used for the results table in fact only reflects the time spent since the 'attempted' statement was emitted (that normally happens when the interaction is opened).
You will not be able to determine the time from the results database table only. There are a couple of solutions, but they all involve frontend work to some extent. The best one for you may be tracking all the xAPI statements and use the `duration` string of the `results` property. The duration string is in ISO8601 format.
Unfortunately, while the xAPI statements carries the correct time, H5P core doesn't report that time when storing the result, and the WordPress plugin uses a fallback for that case and computed the duration as difference between the finished time and the opened time.
@BV I think this is something that should be considered for being changed in H5P core. The completed listener of the x-api class does report scores to the H5P integration, but it doesn't report the time. I think if an xAPI statement carries duration information in the `results` property of an 'answered' or 'completed' statement, that value should take precedence over any (fallback) time that H5P core might set or that an H5P integration infers. The duration time would just need to be converted from ISO8601 to seconds and passed to `H5P.setFinished` which actually can take the time value (as seconds) as the 4th function argument.
I think if there was no reason this was not done in the first place (nothing in the comments), this should be changed.
Tue, 10/18/2022 - 14:10
Thanks Villon & Oliver,
Thanks Villon & Oliver,
Oliver, thankyou for that info, I will certainly need a developer to implement those changes so I will try to find someone willing to assist.