Activity Completion Tracking in Wordpress for Tutor LMS


Moodle supports Activity completion ( and I'd like to enable similar support for Tutor LMS ( in WordPress:

  • In the LMS, lessons are just regular WordPress posts (blog posts) of a specific post_type.
  • Once can just use the shortcode [h5p id=...] to include the H5P content.

But the successful completion of H5P activities is not tracked.

Prior extensive thoughts on this have been shared here:
Best practices for connecting H5P responses with LMS's user data? Link:

Like Moodle, Tutor LMS has completion tracking for the learner in his sidebar and for the teacher.

I'd need a action or filter hook which gets called upon a user completing a lesson with success:

  • Success / Failure (or Completion otherwise) is already defined for H5P content, and it should be passed to the filter/action handler.
  • To set the completion status in the LMS, the completion filter/action handler also needs to get the wordpress post ID in which the [h5p id=...] shortcode is used.
    Getting the post ID in the [h5p id=...] shortcode is easy, it is returned by get_the_ID().

So the additional infor needs is the combination of:

  1. success or failure
  2. the post id of the post (which serves as the lesson and lession id)

The hard part is get both (success and post id) into an AJAX POST request back to a wordpress AJAX handler which then sets the completion status.

So far, I looked at two avenues:

First idea - The H5P wordpress plugin sends very limited completion data (only scores and time) to WordPress using setFinished.

If my assumption for Problem 2 is correct, that might be hard problem - while it would be great to have the success info in the normal H5P plugin, I could find no knowledge about it there. Any hints how to add it?

Second Idea - Oliver Tacke/SNORDIAN's H5PxAPIkatchu plugin

  • H5PxAPIkatchu sends the success information, back to wordpress using xAPI
  • But H5PxAPIkatchu does not create it's own h5p shortcode, so I don't know how to pass on the post id from the h5p shortcode to H5PxAPIkatchu

An idea how to implement this might be to use the description provided by Thomas Mars in this posting:

Adding custom xAPI attributes to statements

That would mean to use the h5p example mods plugin as basis to hook into h5pmods_alter_scripts, which like Thomas wrote allows "to insert your own scripts inside the H5P iFrame. Using this hook you can make your own script that extends or replace an existing script.
For instance if you want to change the context of an xAPI event to always include a "group" property, you could override the H5P.XAPIEvent.prototype.setContext() function with your own function that is a variation of the already existing setContext(), then add this script through the h5pmods_alter_scripts that you've added through your own mod." -

I guess this might make it possible to override H5P.XAPIEvent.prototype.setContext()  to include the post id (and also the lesson name and course id and course name as custom xAPI attributes, which would make the xAPI themself also vastly more useful for Tutor LMS users.

Thanks a lot for any guidance!

Content types: 
otacke's picture


H5PxAPIkatchu does exactly what you describe to have learned from Thomas. It merely runs a JavaScript inside the contents iframe that waits for xAPI events and sends appropriate data incl. the xAPI statement to the server using a custom endpoint. Then, on the server, data can be processed as needed.

If you require some post id or other pieces of information, you would simply need to pass them to the client when injecting the JavaScript into the iframe (like H5PxAPIkatchu gets configuration data) and return it to the server alongside the xAPI statement. There's no need to override anything or "misuse" the xAPI statement to transfer further data.