Verification class

Hello,

I'm actually running H5P on a Moodle server. I want to implement a timer on 3 differents activites that I'm using.

I have done this in view.php page by adding a function that run every seconds. It's launched when the page is loaded so it works well. -> OK.

Now I want to stop the timer when the user hasfinished the activity.

The problem is that I can't find the function which is executed when we press the verification button (PHP or JS?). Then I'll store the timer value in the database. I'm thinking about adding a parameter in the function if this function is made like I'm thinking of it.

Can you help me for to solve this problem?

Thanks in advance.

icc's picture

Hi, 

Try adding this to a script tag on your page. You should see a "Finished!" text in your browser console when the task is completed:

H5P.externalDispatcher.on('xAPI', function (event) { 
  if (event.data.statement.result) { 
    console.log('Finished!'); 
  } 
});

… or you can use alert('Finished!')