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!

Björn

 

 

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];
  console.log(event);

  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!');
      console.warn(xapiDataResult.statement);
      console.warn(stmnt);
    }
    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 {
    console.log(result);
  }


  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

Attachments: 

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...

Thanks 

Björn

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?