tunapanda / h5p-standalone

Display H5P content without the need for an H5P server
MIT License
272 stars 117 forks source link

How to get user score by each interaction #130

Closed adebareshowemimo closed 1 year ago

adebareshowemimo commented 1 year ago

How can I get each user score on each event interaction not to wait till when all activities are completed.

0xMurage commented 1 year ago

@adebareshowemimo you should listen for the xAPI events.

Here is an example of that

https://github.com/tunapanda/h5p-standalone#listening-to-xapi-events


const el = document.getElementById("h5p-container");
const options = {
  h5pJsonPath: "/h5p-folder",
  frameJs: "/assets/frame.bundle.js",
  frameCss: "/assets/styles/h5p.css",
};

new H5PStandalone.H5P(el, options).then(function () {
  H5P.externalDispatcher.on("xAPI", (event) => {
    //do something useful with the event
    console.log("xAPI event: ", event);
  });
});