-
Notifications
You must be signed in to change notification settings - Fork 129
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
No result for simple Course Presentation #111
Comments
Hi @Adrian-S did you manage to get this work? I am also looking for a solution to this. |
Yes, but it's ugly. I had to add some JS that looks like this:
H5P exists on main window and inside the frame. But the main idea is to get the H5P and Instance that is running. If you have multiple types of H5P moduled it might be whise to try and check what they are. For example: Some info here: https://h5p.org/node/2466#setFinished Hope it helps, althow I still expect an official fix / response. |
Hi @Adrian-S and @fmarc-mdsol Using setFinished() 1If you really require to invoke setFinished() with those parameters, you should use
Calling setFinished() directly is not recommended. Using setFinished() 2If you just require setFinished to be called and can spare the time property - seems you set it to 0 anyway, you can just trigger the xAPI completed event which will result in setFinished to be called. This would achieve the same (except for time to be passed, but Course Presentation doesn't either) and not omit other things that are supposed to be triggered.
Adding scripts to H5P contentIf you want to add scripts to modyify H5P content, you should use the alter_scripts hook that H5P offers. Please see https://h5p.org/node/2692. Not only will it spare you the hassle of finding your way inside the iframe, but you also won't have to deal with finding the correct Course Presentation instance or dealing with all of them one by one. You can use the alter_scripts hook to filter for Course Presentation contents and then pass custom scripts only to those. This would leave you with something like this:
|
Thanks @otacke! We're using the H5P WordPress integration for LearnDash and ran into this exact same issue. For those interested, you can inject the code displayed above by doing the following: functions.phpAdd this code block to your /**
* This action allows us to enqueue our own JS files to be loaded whenever H5P content is being rendered.
*
* @param array &$scripts List of JavaScripts to be included.
* @param array $libraries The list of libraries that has the scripts.
* @param string $embed_type Possible values are: div, iframe, external, editor.
*/
add_action('h5p_alter_library_scripts', function (&$scripts, $libraries, $embed_type) {
$scripts[] = (object) [
'path' => get_stylesheet_directory_uri() . '/h5p-presentation-completion.js',
'version' => ''
];
}, 10, 3); JSCreate a file in your theme folder called H5P.externalDispatcher.on('initialized', function() {
// Is always Course Presentation if filtered in alter_scripts
var instance = H5P.instances[0];
var done = false;
// This will trigger setFinished (not supposed to be called directly)
var triggerFinish = function() {
instance.triggerXAPICompleted(1, 1);
};
// setFinished will fire anyway when there's a summary slide
if (instance.summarySlideObject.$summarySlide) {
return;
}
if (instance.slides.length === 1) {
// Just one slide
triggerFinish();
}
else {
// Multiple slides, wait for last
H5P.on(instance, 'changedSlide', function() {
if (!done && instance.getCurrentSlideIndex() === instance.slides.length - 1) {
done = true; // Only trigger once (feels more correct than retriggering)
triggerFinish();
}
});
}
}); That's it! The Course presentation H5P module should now send the 'completed' verb once you reach the end of the presentation. |
I'm using the WordPress plugin and I have created a 3 slide ‘Course Presentation’ with no quiz in them.
It seams that it will not send a finish statement when all slides are viewed.
I would expect a
h5p_setFinished
action to be sent, but I only geth5p_contents_user_data
. I have installed “H5PxAPIkatchu” plugin to check for xapi calls. There are no ‘completed’ verbs registered for this simple course with no quiz. No summary page also.test-22.zip - This is my course. It can't get more basic than this.
Not sure what to do in order to track completion of these courses.
The text was updated successfully, but these errors were encountered: