Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you detect if h5p package is successfully completed? #148

Open
arashb31 opened this issue Nov 24, 2023 · 3 comments
Open

How do you detect if h5p package is successfully completed? #148

arashb31 opened this issue Nov 24, 2023 · 3 comments

Comments

@arashb31
Copy link

How can you detect if programmatically if the H5P package is completed?

There seems to be a "ajax.setFinishedUrl" option for a URL but is there a way to detect the completion as a callback function instead?

@otacke
Copy link
Contributor

otacke commented Nov 25, 2023

You can listen for xAPI events that contain a result property or a verb property with completed or answered. See official documentation, for instance: https://h5p.org/node/3391

@arashb31
Copy link
Author

Hmm so I've tried it with a sample H5P package and the package doesn't report a result or verb property.

However, if I set the ajax.setFinishedUrl, it does POST the result to a URL at the right time with form post of something like:

contentId: 10c2ie7uy
score: 5
maxScore: 5
opened: 1701146845
finished: 1701146936

Is there any option for something like "setFinishedCallback" which is just a callback function that passes the completion object?

For example:

setFinishedCallback : function(results) { 
 //Let me process the completion however I want, not necessarily to do an Ajax post.
console.log(results); 
}

Is this something that could be added?

@otacke
Copy link
Contributor

otacke commented Nov 28, 2023

Not sure what the "H5P sample package" is, but I am pretty sure that all H5P content types that report some result via xAPI have both, a verb and a results property, which can be tracked (https://github.com/tunapanda/h5p-standalone#listening-to-xapi-events) and evaluated. The core of H5P does the same and calls the AJAX endpoint that you can define in H5P Standalone (see postUserStatistics and ajax.setFinishedURL. You will need to implement that endpoint, as H5P Standalone does not implement one itself. If you're only interested in the 'completed' state and not the whole xAPI information, that's an option.

Apart from that: I am neither affiliated with the H5P Standalone team nor H5P Group, so I cannot answer what could/will be added to either H5P Standalone or H5P core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants