Remove Activity Navigation while in a questionnaire

Remove Activity Navigation while in a questionnaire

by Tim Beachy -
Number of replies: 8

I've used CSS in the past extensively to remove the .activity-navigation bar from the bottom of certain activities, especially ones that have their own navigation built-in (i.e. Lesson, Quiz).  Usually this is no problem, but with Questionnaire, it is problematic.

It appears that Questionnaire uses two pages primarily (from a student standpoint) -  "view" and "complete".  The body IDs are "page-mod-questionnaire-view" and "page-mod-questionnaire-complete", respectively.

The problem is that both of these pages are used in multiple states of questionnaire completion, some of which need to have the activity-navigation bar apparent, and others where we would like it not to.

In essence, I cannot find a CSS-inherent way to target these different states.  I tried to look at the massive wealth of code that is the Questionnaire module, to see if I could add body classes appropriately, but I've come up short.

Does anyone know how I can best accomplish this?  The bottom line, is that when a student is in a multi-page questionnaire, they essentially have two sets of nav buttons - Questionnaire provides Next and Previous pages, but just below that are the Activity Navigation, which would essentially take the student out of the Questionnaire by clicking on them.  Not only is it confusing for the student, it doesn't make much sense to have them there while within a Questionnaire. 

Can't figure out why this problem has never been raised before?...

Thanks for any help.

Average of ratings: -
In reply to Tim Beachy

Re: Remove Activity Navigation while in a questionnaire

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

@Tim,

I suppose you want to hide the activity-navigation bar by adding CSS rules to the Advanced settings of your current Moodle theme? I use it extensively to remove that bar from the Quiz and Lesson activities.

You write "The problem is that both of these pages are used in multiple states of questionnaire completion, some of which need to have the activity-navigation bar apparent, and others where we would like it not to."

You don't say exactly which student questionnaire pages you want to have that bar removed from. The following rules work ok for me:

#page-mod-questionnaire-complete .activity-navigation,
#page-mod-questionnaire-view .activity-navigation,
#page-mod-questionnaire-myreport .activity-navigation,
#page-mod-questionnaire-report .activity-navigation {
    display: none;
}

Average of ratings: Useful (1)
In reply to Joseph Rézeau

Re: Remove Activity Navigation while in a questionnaire

by Tim Beachy -
Thank you Joseph.
Like you, I am able to hide the .activity-navigation class that way, but it hides them on every page of the questionnaire, and there are no selectors that I can target to control it.

To illustrate:
  • Before answering the questions - we would like the activity navigation to not show up, so that the Answer the Questions button is the only thing showing:Shows the Answer the questions button with the activity navigation buttons below it, crossed out in red line.
  • During the process of filling out the questionnaire, we would also like the activity navigation to not display: Shows questionnaire pagination button, with activity navigation buttons below it, crossed out in red line.
  • After the questionnaire is submitted, we would like the activity navigation to display, otherwise, the user has no ready way to advance to the next activity: Shows the "Thank You for completing this questionnaire" page, with the activity navigation buttons showing as normal.  (We have hidden the "Continue" button as well, as you can see, because the users hated being taken back into their finished questionnaire when they assumed that "continue" meant "continue to the next topic".
  • When a student returns to the questionnaire (technically the same view page as top image), we would like the activity navigation buttons to show:  Shows the front page for a questionnaire with a link to "Your response", with the activity navigation buttons showing below.  This is why your solution doesn't work for us, and why I mentioned the view and complete pages have different "states".  If I have those different states write CSS selectors to the page, then it would be trivial to target them appropriately.  As it is now, the CSS display:none; works all-or-nothing.
In reply to Tim Beachy

Re: Remove Activity Navigation while in a questionnaire

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

"(We have hidden the "Continue" button as well, as you can see, because the users hated being taken back into their finished questionnaire when they assumed that "continue" meant "continue to the next topic"."

Well, if you had not hidden that "continue" button, what you want to achieve would be possible with the following rules:

#page-mod-questionnaire-complete .activity-navigation,
#page-mod-questionnaire-view .activity-navigation,
#page-mod-questionnaire-report .activity-navigation {
    display: none;
}

Clicking the continue button takes the students to their "my report" page (where the course navigation bar appears). All this looks quite logical to me.

Average of ratings: Useful (1)
In reply to Joseph Rézeau

Re: Remove Activity Navigation while in a questionnaire

by Tim Beachy -
I wonder if you could please point me to where in Questionnaire module code I could potentially find the logic for the different "states" of the view and complete pages, and possibly insert some CSS classes there? I've tried my best, and I've just not figured it out yet.
Thank you.
In reply to Tim Beachy

Re: Remove Activity Navigation while in a questionnaire

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Tim,
I don't follow you. I thought we were talking about using CSS rules in your Moodle theme's advanced settings in order to hide the course activities bar. Now you are talking about something quite different. I'm afraid I cannot help you here. And tampering with the Questionnaire scripts is not a good idea, as your changes might be over-written with updates...
In reply to Joseph Rézeau

Re: Remove Activity Navigation while in a questionnaire

by Tim Beachy -
I'm sorry you're not understanding my request -- it is the same request I started out with:
<blockquote>In essence, I cannot find a CSS-inherent way to target these different statesI tried to look at the massive wealth of code that is the Questionnaire module, to see if I could add body classes appropriately, but I've come up short.</blockquote>

I do just want to use CSS, but the code does not provide the level of granularity in CSS selector use that I can do that.  So my next option was to inject the CSS selectors via the code.  

It seems like you're not really reading the information I've posted...?

In reply to Tim Beachy

Re: Remove Activity Navigation while in a questionnaire

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

@Tim,

I have re-read your message dated Tuesday, 16 November 2021, 5:43 PM. The problem is that the questionnaire page BEFORE a questionnaire is answered has the same ID as the page AFTER it's been answered, when the student reviews their answers, i.e. page-mod-questionnaire-view

I expect that, in order to find out the ID of those pages, you are using your browser console, as I do (see screenshots above). There's no need to dive into the code of the Questionnaire scripts (unless you want to modify them, which does not seem to be what you want to do).

The only solution I can see at the moment is to use the CSS rules I gave in my post dated Tuesday, 16 November 2021, 6:13 PM and to leave the Continue button visible. When the students come back to a questionnaire already answered and set to one response only, it's logical to suppose that they want to review their answers, so the "Your response" link is available and, once they are (re)viewing  their answers, then the course Navigation bar is visible again.

Average of ratings: Useful (1)
In reply to Joseph Rézeau

Re: Remove Activity Navigation while in a questionnaire

by Tim Beachy -
Thank you for taking the time to re-read and re-iterate the situation Joseph.
Tim