When Check button is pressed
Submitted by Alexk90 on Fri, 02/07/2020 - 20:08
Forums:
Hi everyone
I'm new to h5p and i would like to ask something because i m creating my own module( PHP ).
I would like to capture when the check button in an h5p quiz (question set or multiple choice ) is pressed.
How can i do this?
Is there maybe a specific function or an event that is triggered when the check button is pressed?
Thanks in advance
otacke
Sun, 02/09/2020 - 01:26
Permalink
Hi Alex!Of course, there's
Hi Alex!
Of course, there's the buttons very own click even that could be listened to. For the check button in particular, listening to answered/completed xAPI-statements could be feasible, too. You'd have to use JavaScript however as the magic is happening in the browser.
Best,
Oliver
YuryB
Tue, 06/14/2022 - 20:52
Permalink
Can we see an example of
Can we see an example of using that element's click event?
otacke
Tue, 06/14/2022 - 22:08
Permalink
Hi Yuri!What kind of example
Hi Yuri!
What kind of example are you looking for exactly? It may depend on what you're trying to achieve. The general steps would be as follows;
There are even more ways, but I guess we're leaving the terrain of examples and answers for the forum ...
Best,
Oliver
Gen2023
Wed, 10/18/2023 - 10:48
Permalink
A code example for Quiz (Question Set)
Hi, otacke!
Thank you very much for your answers and examples. The last example works perfectly well for the “Check“ button of the True/False Question. Can you develop a similar code example for tracking “Finish” button pressed after answering the last question in a Question Set (Quiz)? Or can you specify how to modify the last example to work with a Question Set?
Best regards
otacke
Wed, 10/18/2023 - 19:56
Permalink
Hi!I assume that the button
Hi!
I assume that the button is not attached to the DOM at all times (and that it is recreated every time that it is needed), so you probably would need to resort to a MutationObserver on some parent element that's available all the time, filter the mutations for the button in question and add your event listener (once or each time if it is recreated).
Best
Oliver