Limit answer attempts and hide solution until max allowed attempts have been reached
Submitted by nschildre on Sat, 05/15/2021 - 00:41
Forums:
I have added the following jQuery code to limit attempts to 3 times and to hide the solution until all three attempts have been executed:
(check_count is a variable in the main document that is counting the attempts and is initially set to 0)
H5P.jQuery('.h5p-question-try-again').add('.h5p-question-check-answer').bind("click", function(event) { if(parent.check_count < 2){ parent.check_count++; H5P.jQuery('.h5p-question .h5p-joubelui-button.h5p-question-show-solution').hide(); }else{ H5P.jQuery('.h5p-question-check-answer').hide(); H5P.jQuery('.h5p-question-try-again').hide(); H5P.jQuery('.h5p-question .h5p-joubelui-button.h5p-question-show-solution').show(); } });
It works for Quiz (Question sets), but not for interactive videos. The dialogs are not loaded initially with the H5P video, but with the dialog when a question is loaded into the video. So how can I interact with those question buttons? Can I even interact with those through jQuery?
Summary:
Limit attempts and hide solutions until attempts have been executed
Content types:
nschildre
Tue, 05/18/2021 - 17:45
Permalink
Needed to use the domChanged event
Found the answer to my own question:
https://h5p.org/events
https://h5p.org/comment/20508#comment-20508