hide navigation pane and info panes for specific quiz

hide navigation pane and info panes for specific quiz

by Bop Giessen -
Number of replies: 7

Hi,

I have multiple quizzes in my course. How can I hide the navigation pane for one specific quiz? 

And same question for the grey info block on the left, how to hide for a specific quiz?

Thanks!

Average of ratings: -
In reply to Bop Giessen

Re: hide navigation pane and info panes for specific quiz

by Andrew Tully -

Sorry , no solution but I have exactly the same question. Most of my quizzes are great having both of those panels visible but there are a couple with large diagrams that are hard to read when so much real estate is occupied with those nav and question panels. 

In reply to Andrew Tully

Re: hide navigation pane and info panes for specific quiz

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

Hello Bop and Andrew,

If you place the following code in the HTML of the question text of any question on a quiz page, it will hide the navigation block and the info block from all questions on that page, and it will extend the main content block to the full width of the window.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$(document).ready(function() {
    $(".info").css("display","none");
    $(".content").css("margin-left","0");
    $("#region-main-box section:nth-child(2)").css("display","none");
    $("#region-main").css("width","100%");
});
</script>


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

Re: hide navigation pane and info panes for specific quiz

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

Hello Bop and Andrew,

I didn't want Tim to be too upset with me. smileSo I prepared a little script with which the navigation block remains displayed and the question information blocks are displayed on demand.

To meet your request, the main question region spans the entire width of the window, unless it is desired to show the question info blocks. It is then simply a question of pressing the Esc key. This is a toggle, so the question info blocks are hidden when the Esc key is pressed again. To free up space to the right of the window, I moved the navigation block to the top of the questions where it remains visible.

You can place the following code in the HTML of the question text of any question on a quiz page:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$(document).ready(function() {
    $("#region-main-box section:nth-child(2)").prependTo("#region-main-box");
    $("#mod_quiz_navblock").css("width","400px");
    $("#mod_quiz_navblock").css("float","right");
    $(".info").show();
    $("#region-main").css("width","100%"); 
    $("#region-main .content").css("margin-left","145px");
    var x = 1;
    $("body").keydown(function(event) {
        if (event.which == 27) {
            x = -x;
            if (x < 0) {
                $(".info").hide();
                $("#region-main .content").css("margin-left","0");
            } else {
                $(".info").show();
                $("#region-main .content").css("margin-left","145px");
            }
        };
    });
});
</script>

At the beginning of the test, the question info blocks are displayed for information to the student:

ForumQuiz_20210413_2251.png



Press the Esc key to hide the question info blocks, and answer the question(s):

ForumQuiz_20210413_2253.png



After clicking the [Check] button, the question info blocks are displayed for information to the student:

ForumQuiz_20210413_2255.png



Press the Esc key to hide the question info blocks and continue answering the question(s):

ForumQuiz_20210413_2259.png


There is a small bug regarding the display of the navigation block when the browser zoom value is high. I don't think it matters much and will fix it later.

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

Re: hide navigation pane and info panes for specific quiz

by Andrew Tully -
Hi Dominique,

This is amazing, it solves my problem and give lots of additional options!

THANK YOU!!
Andrew
In reply to Dominique Bauer

Re: hide navigation pane and info panes for specific quiz

by Bop Giessen -
Many thanks Dominique,
this works fine for me!
Bob
In reply to Dominique Bauer

Re: hide navigation pane and info panes for specific quiz

by Bop Giessen -
Hi Dominique,
this works when I create and test my quiz as a teacher but it doesn't when a student is doing the quiz. than the whole quiz blocks totally.
Any idea why and what to do about it?
Bob
In reply to Bop Giessen

Re: hide navigation pane and info panes for specific quiz

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

Hello Bop,

Any idea... It may depend on the Moodle version, the browser (Chrome, Edge, ...), the type of computer (desktop, tablet, phone), the Moodle site theme, the type of question, or something else.

... what to do about it?  Experiment on your computer with a student account. Determine if this is happening for a single student or for all students. Inspect the DOM and correct the script. Anyone with some knowledge of HTML may be able help.

Also, Moodle 4.0 will provide a much wider question area.