Dear Community,
I have a question about making an Ajax call in an H5P module. If I was in Moodle, I would just include core/ajax to my AMD module and be on my way. Does Moodle provide an equivalent for H5P module?
You see, I just want to add the number of students who answered this answer when the student clicks on the check button in a Question Set module (https://h5p.org/question-set).
From:
This is the question?
- Answer #1
- Answer #2
To
This is the question?
- Answer #1
57% of students answered this
- Answer #2
43% of students answered this
Coding the external function to calculate the % is quite easy but I am having a hard time making H5P call the Moodle external function. Mainly, there is the sesskey that is not available in an H5P module so I can’t use jQuery to do a quick ajax call, the sesskey is usually handled by core/ajax.
I also tried to override a renderer to inject my own AMD module but the Moodle version of H5P does not use renderer to output an H5P activity (as far as I can see).
H5P provides ways to do that but it is not using the Moodle H5P integration but rather the mod_hvp plugin https://h5p.org/moodle-customization which we are not using.
Am I missing something? I am probably not the first one who wants to add an ajax call from an H5P activity... I am guessing.
Thank you for your time and help in advance.