Configure Quiz Navigation Block

Configure Quiz Navigation Block

by Ram Sharma -
Number of replies: 10

I'm using the Moodle 3.6 version. I have created a "Listening" quiz with 4 pages - in each page, an audio will be played followed by a few questions. 

Now my question is this: when a student completes the test and comes to the review page, the audio files in all the 4 pages start playing, making it extremely hard to listen to it. I discovered that the issue is because of the default option on the Quiz Navigation Block - "show all questions on one page". Is there any way I can change this default option to "show one page at a time" for all quizzes so that the onus of changing this option is not on the student every time they take a quiz?

Average of ratings: -
In reply to Ram Sharma

Re: Configure Quiz Navigation Block

by Ram Sharma -

This is turning out to be an annoying problem.

In addition to this, in quizzes where there are several questions available in one page, the timer (in the quiz navigation block) cannot be seen when the student scrolls down.

Is there a way to fix the quiz navigation block and make the "Show one page at a time" the default option? Is there no way to customize the Quiz Navigation block?

In reply to Ram Sharma

Re: Configure Quiz Navigation Block

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
Show one question per page is a quiz setting, and I think that this is the default, but I think that you can control this with the General Quiz configuration setting called "Automatically start a new page." 
In reply to Rick Jerz

Re: Configure Quiz Navigation Block

by Ram Sharma -

No, I mean the setting in Quiz Navigation block in the quiz review page after taking the quiz. 

Quiz Navigation

This setting is, by default, "Show all pages at once". I want to be able to set "Show one page at a time" as default. 

In reply to Ram Sharma

Re: Configure Quiz Navigation Block

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
Okay, now I better understand.

As far as I know, no, you cannot make "Show one page at a time" the default in this quiz navigation area.

Maybe you can focus on how to make audio files not "autoplay?" I don't use audio files, so I am not the best at guiding you.

Maybe someone else will be able to help.
Average of ratings: Useful (1)
In reply to Ram Sharma

Re: Configure Quiz Navigation Block

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

Hello Ram,

The following solution is a quick workaround. It works well on a desktop computer, but does not claim to work on all systems, for example with the Moodle app on iOS or Android. To do this, we would need to make sure the solution is truly responsive on all systems, a task that I would leave to others.

If you are satisfied with a solution for desktops, just place the following code in Site administration / Appearance / Additional HTML / Within HEAD. Obviously, you have to replace https://moodleformulas.org in the code with the URL of your Moodle site. You can adjust the background color and the top and right positions as desired. Note that the code only fixes the timer position and that the navigation block is not otherwise affected.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>
<script>
$(document).ready(function(){
    if (window.location.href.indexOf("https://moodleformulas.org/mod/quiz/attempt.php") > -1) {
        $("div#quiz-timer").css("background-color","yellow");
        $("div#quiz-timer").css("position","fixed");
        $("div#quiz-timer").css("top","-4px");
        $("div#quiz-timer").css("right","250px");
        $("div#quiz-timer").css("z-index","10000");
    };
})
</script>

It should look like this:

Formulas_20200908_1241.png

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

Re: Configure Quiz Navigation Block

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

Hello Ram,

I discovered that the issue is because of the default option on the Quiz Navigation Block - "show all questions on one page". Is there any way I can change this default option to "show one page at a time" for all quizzes so that the onus of changing this option is not on the student every time they take a quiz?
This is turning out to be an annoying problem.

The following solution is a quick workaround. It does not pretend to replace an option that could eventually be integrated into Moodle's core code. It doesn't pretend to be super elegant either, but it does work just fine. If you are satisfied with this kind of workaround, just place the following code in Site administration / Appearance / Additional HTML / Within HEAD. Obviously, you have to replace the two occurrences of https://moodleformulas.org in the code with the URL of your Moodle site. If you use this code, I would be curious if it fixes your problem. Note that the code opens the Review page to "Show one page at a time", but after that the behaviour of "Show one page at a time"/ "Show all questions on one page" remains as usual.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>
<script>

$(document).ready(function(){

    // JavaScript code to set "Show one page at a time" as default

    // In the Summary page, remove the session storage item "switch" i.e. switch to one page at a time 
    if (window.location.href.indexOf("https://moodleformulas.org/mod/quiz/summary.php") !== -1) {
        sessionStorage.removeItem("switch");
    };

    // In the Review page, switch to the first question page (&showall=0) unless this has already been done
    if (window.location.href.indexOf("https://moodleformulas.org/mod/quiz/review.php") !== -1) {
        if (sessionStorage.getItem("switch") !== "done") {
            if (window.location.href.indexOf("showall=") == -1 && window.location.href.indexOf("page=") == -1) {
                window.location.replace(window.location.href + "&showall=0");
                sessionStorage.setItem("switch", "done");
            };
        };
    };

})
</script>
In reply to Dominique Bauer

Re: Configure Quiz Navigation Block

by Ram Sharma -
I applied this method. It should do for now, thanks a lot!

Note that the code opens the Review page to "Show one page at a time", but after that the behaviour of "Show one page at a time"/ "Show all questions on one page" remains as usual.

I understood what you meant by this. As soon as the page opens, all audios start playing at the same time, but only for a second. Then the "Show one page at a time" feature kicks in.

Thanks a lot for this workaround. It's a huge relief to have found a solution to this!

In reply to Ram Sharma

Re: Configure Quiz Navigation Block

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

Thanks for your feedback.

all audios start playing at the same time, but only for a second
It's not perfect. If you have access to Moodle's code files, a more straightforward and efficient solution may be possible. Either someone else provides it to you, or I'll look at it a bit later.

In reply to Dominique Bauer

Re: Configure Quiz Navigation Block

by Ram Sharma -
This works beautifully, thanks a ton!
In reply to Dominique Bauer

Re: Configure Quiz Navigation Block

by Manibhushan Dharmadhikari -
Hello Dominique,

Thanks a ton. The script you mentioned above worked perfectly. I was looking for this kind of solution from the past 4 months. Thank you once again for sharing this useful and working script.

Regards