Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add triggers for saveContentState/setUserData #106

Open
otacke opened this issue Oct 18, 2021 · 0 comments
Open

Add triggers for saveContentState/setUserData #106

otacke opened this issue Oct 18, 2021 · 0 comments

Comments

@otacke
Copy link
Contributor

otacke commented Oct 18, 2021

If admins have set the saveContentState option, H5P is supposed to store the current content's state for the user

  1. every saveFreq seconds,
  2. 3 seconds after an xAPI event with the verb completed or progressed
  3. when the browser triggers an unload, beforeunload, pagehide event.

The latter is pretty unreliable. There's no guarantee that either of those three events will fire and it may depend on the browser policy. It might help to use visibilitychange (https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilitychange_event) in addition to pagehide. (https://github.com/h5p/h5p-php-library/blob/master/js/h5p.js#L2868 and https://github.com/h5p/h5p-php-library/blob/master/js/h5p.js#L2872)

Still, unload, beforeunload are unreliable. There's no guarantee that these will be triggered and users might complete an exercise and close the tab without the state being stored. Most content types do not use the xAPI verb completed, but answered when they are checked, so it might be a good idea to add answered as well (https://github.com/h5p/h5p-php-library/blob/master/js/h5p.js#L246). There's still that 3 seconds delay set in H5P core, so if people close the tab within 2999 milliseconds after completing an exercise the state would not be saved - but still better than it is now.

Those new triggers would only cause an AJAX request to the server if the state actually changed, because H5P checks, so these two additions should not have a performance impact server-side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant