Moodle quiz navigation method

Moodle quiz navigation method

by Mario Gharib -
Number of replies: 2

Dear Moodlers,

During an online quiz on Moodle composed of multiple pages where the navigation is sequential, I would like to know if it is possible to ask students, once they click on next page, if they are sure they want to go to next page;

The reason is to avoid clicking by mistake "next page".

Thanks.

Average of ratings: -
In reply to Mario Gharib

Re: Moodle quiz navigation method

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Add the following script to the questions' text:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("input.mod_quiz-next-nav").on("mouseenter", function(){
        if (sessionStorage.nextPage!=1) {  
            var r = confirm("Are you sure you want to go to the next page?\nIf yes, click again on [Next page]");
            if (r == true) {
                sessionStorage.nextPage = 1;
            } else {
                sessionStorage.nextPage = 0;
            };
        } else {
             sessionStorage.nextPage = 0;
        };
    });
});
</script>

You will find an example with its XML on MoodleFormulas .

Average of ratings: Useful (1)
In reply to Dominique Bauer

Re: Moodle quiz navigation method

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

The following script is simpler and works better:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("input.mod_quiz-next-nav").on("focus", function(){
        var r = confirm("Are you sure you want to go to the next page?\n• Click [OK] to go to the next page\n• Click [Cancel] to stay on this page");
        if (r == true) {
            $("input.mod_quiz-next-nav").blur()
            $("input.mod_quiz-next-nav").click()
        } else {
            $("input.mod_quiz-next-nav").blur()
        };
    });
});
</script>

You will find a second example with its XML on MoodleFormulas .

Average of ratings: Useful (1)