H5P Moodle Events?

Hi there,

I've been searching for a while, but couldn't find it anywhere... 

Is there a list somewhere of all the Moodle events that are being triggered by H5P?

Some more context: 

I talked to Fred, the developer of the level up plugin that we are using ( https://moodle.org/plugins/block_xp ) and I would like to make sure his plugin is compatible with h5p.

We’d like to reward users with experience points when they are using h5p content types.  For that to work we’d have to make sure that the event can be fetched by the level up plugin. In this snippet Fred explains how that can be done:

"In order for your plugin, or any plugin, to grant XP points it needs to trigger an event, so the developers have to add an event to the actions you're interested to track. There is a catch though, events have an educational type and a context. The educational type is either Other, Teaching or Participating. It is set by the developer and cannot be changed. The context is generally the context in which the user is (a course, a module, ...). For block_xp to catch an event (amongst other criterias), it must be of level participating, and in a context deeper or equal to the content of the course the block was added. Sorry if I lost you, it's just that there is a little more attention to give to that than just throwing a new event in Moodle. Once you have the new event, you may add a rule for it."

Thank you!




tomaj's picture

Hi Björn,

I think this is probably the best documentation there is on this at the moment. I don't know if it would be enough for Fred...

- Tom

tomaj's picture

When I want to check out the xapi-statements triggered, I often run this code snippet in my console.

var $ = H5P.jQuery;

var oldDefine = window.define;
window.define = undefined;

$.getScript('https://zackpierce.github.io/xAPI-Validator-JS/js/xapiValidator.js', function (data) {
 console.log('xapiValidator loaded', data);

 window.define = oldDefine;

 H5P.externalDispatcher.on('xAPI', function (event) {

  var instance = H5P.instances[0];

  var stmnt = event.data.statement;

  if (event.getScore() !== null && instance && instance.getXAPIData) {
    var xapiDataResult = instance.getXAPIData();
    if (JSON.stringify(xapiDataResult.statement) != JSON.stringify(stmnt)) {
      console.warn('NOT ALIKE!');
    else {
      console.log('They are alike :)');

  var result = xapiValidator.validateStatement(stmnt);

  // Let's check if MUST VIOLATIONS are reported
  var valid = true;
  if(result.errors) {
    for (var i = 0; i < result.errors.length; i++) {
      if (result.errors[i].level === "MUST_VIOLATION") {
        valid = false;
        console.error('Invalid xAPI statement: ' + result.errors[i].message + ' (trace: ' + result.errors[i].trace + ')');
  if (valid) {
    console.log('Valid xAPI statement: ', event.data.statement.verb.display['en-US']);
  else {

  var score = event.getScore();
  if (score !== null) {
    console.log('Score: ' + score);
papi Jo's picture

I didn't know one could run a code snippet in the navigator console! One learns something every day...

tomaj's picture

Awesome that you could pick up something new Joseph :)

This is how I use it in Chrome by the way.

- Tom


Great, thank you! I'll pass it on... 

One more thing not relating to this topic, but the forum in general: if I create a new forum post I do not get notifications when someone replies. This option (the "notify me" checkbox) does only show up for replies (like this one). I Just randomly saw that you had already responded. Can you turn on notfications for new forum posts as well?

tomaj's picture

Hey Björn,

I just testet the forum, and I am getting notifications on my forum post (from a non-admin account). Can you check your spamfolder for it?

- Tom

Hi Tom,

unfortunately there's nothing in my spam folder. I've had this problem with multiple forum topics I created. I'm on a Mac with Chrome. I can try to use a different browser for the next topic I create. Right now with a "new comment" I do have the option to "Notify me when new comments are posted", but I do not have this option when I'm creating a new forum topic (screenshot attached). I assume one should automatically follow comments on forum topics one has created and the missing option isn't the problem, but I thought I should share this... 

Any other tests I can run to help solve this? If I'm the only one reporting it it's probably not that high a priority...



tomaj's picture

Can you check your profile settings, to see if you have the "Receive content follow-up notification e-mails" checked?

- Tom

Good point! That was it... Thank you! I don't remember turning it off, though. And I assume it's turned on automatically. Strange! Either way: thanks a bunch!

tomaj's picture

Happy to help Björn! :)

I am new to using H5P hardware, I would like to know if anyone was able to use Level Up with H5P, I am working with gamification in moodle. I do not know if you have other gamification plugins that you can listen to the events (activities, quiz, interactive videos) of the H5P is compensate with a score. I am aware that it has gammatization of H5P but it presents me with few resources of manipulation of experience points with the activities that are carried out in the H5P. From what I realized, you can only create rules of experience points when an H5P course module is viewed, now assign the score according to the result / performance of the user with H5P activity, there is no way. What would be the guidelines for working with this?

icc's picture

It does sound like what you want is an event inside xapi_results.php that includes the score?

I just started to use Level Up and haven't figured out, how to realize this.
To me it sounds like an awesome option.

would it be the "raw_score" in the xapi_results.php?

I'm wondering, whether you could make the XP in Level Up grow according to the score you reached in a certain Activity.
By that I mean that the possible XP gainable is limited by reaching the maximum score and not just simply adding amount X according to reached score everytime you try. But thinking about it, I actually see useful Applications for both of these options.

I'll try to find out more about the Level Up Rules, but maybe somone has an idea for me ;)

otacke's picture

Hi bnse!

The raw_score variable corresponds to the value of the raw property in the xAPI score object that's caught. You can find the meaning of the score property values in the xAPI specification at https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#Score. So, probably yes, that's the score that was achieved, and you can also retrieve it from the database - that's probably more convenient that patching files. The H5P plugin for moodle stores a subset of the xAPI statement in the table named mdl_hvp_xapi_results and the moodle core integration uses the table named mdl_h5pactivity_attempts_results.


Hey Oliver,

thanks for your helpful reply. So I just need to find out how to use the maximum score stored in this tables with the level up plugin now.

I really wasn't expecting you to answer to that question, but it seems like you're deep into every topic I'm looking for answers to lately.
Thanks for your great Support for (german) h5p users.
I guess this won't be my last question about that.

Best regards,

otacke's picture

Hey Benedikt!

"That's what I do, I drink and I know things." :-) And that's what I earn my living with, so I better know a thing or two about H5P.