Which event fires when summary slide show up

Forums: 

May you all live in peace!

I am a Moodle developer and am trying to customize summary slide in course presentation. I have already written JS code which can modify the summary slide content as per my needs. The only issue is that when summary slide loads, it shows default slide and I have to reload the page to get my custom design appear.

It appears that I need to run my JS code on a proper event to make it work. I have tried to go through documentation to get to know the relevant one but not successful.

Can someone mention how may I use my JS code so that it run when summary slide shows up?

Thanks in advance.

Warm regards,

Mahtab Hussain

Content types: 
otacke's picture

Hi!

You could listen for the xAPI event with the verb completed that is fired when the summary slide shows up. 

H5P.externalDispatcher.on('xAPI', function (event) {
  // event.data.statement holds the xAPI statement and can be parsed
});

Cheers, Oliver

May you live in peace Oliver!

Thanks heaps for the pointer. I did try the same but I found that this trigger fires as soon as summary slide is accessed but I need something which may trigger when summary slide has loaded all the content. This will let my script find different elements on summary slide and modify them as needed.

Can you please guide how to achieve this? OR a way to modify the content of summary slide before it appears on summary slide?

Warm regards,

Mahtab Hussain

otacke's picture

Hi!

As far as I can see, there's no event fired after the slide content has been updated and is attached to the DOM. The quirky way would be to add a setTimeout to your xAPI listener callback that performs the changes, or you access the Course Presentation object in H5P.instances and try to listen for some appropriate DOM event.

If you think having an extra H5P event being triggered would be beneficial for many people, feel free to contribute the required changes to the code of Course Presentation.

Best,
Oliver