Remove preview questions button and link in Feedback Activity Moodle 4.0

Remove preview questions button and link in Feedback Activity Moodle 4.0

by Bronwen Campbell -
Number of replies: 12

Hi, I have recently upgraded to Moodle 4.0.1 and the "Preview questions" button in Feedback is much more obvious than in the previous versions, causing confusion for students and also allowing them to see all questions when a conditional set of questions is included, which they would not normally see. 

Can I hide the preview questions button and the link to print.php?

I managed to hide it in our previous version (3.9) by commenting out the following code in feedback\view.php, but it has not worked in the new version


$previewimg = $OUTPUT->pix_icon('t/preview', get_string('preview'));

$previewlnk = new moodle_url('/mod/feedback/print.php', array('id' => $id));

if ($courseid) {

    $previewlnk->param('courseid', $courseid);

}

$preview = html_writer::link($previewlnk, $previewimg);


I can see that this is showing as an unresolved issue in https://tracker.moodle.org/browse/MDL-63015 and https://tracker.moodle.org/browse/MDL-70586

Does anyone have a workaround?

Regards,

Bronwen

Average of ratings: -
In reply to Bronwen Campbell

Re: Remove preview questions button and link in Feedback Activity Moodle 4.0

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

That is very strange and I am not sure why it is even an option.  I am glad that you pointed it out - it should be possible to hide the button with css but you would have to make it specific for each feedback.  For example, the code below hid it one of mine.

a#action_link63109d81e953c3 {
display: none;
}
In reply to Emma Richardson

Re: Remove preview questions button and link in Feedback Activity Moodle 4.0

by Anthony M -
Hi @Emma,

For some reason the code that you mention is not working for me

and I am updating the Number/ID in bold (a#action_link63109d81e953c3) to reflect my specific number

Is anyone else facing the same problem?

Thanks!
In reply to Bronwen Campbell

Re: Remove preview questions button and link in Feedback Activity Moodle 4.0

by Cam Howard -
I'm finding that targeting the "Preview Questions" button with a CSS rule by using the ID doesn't work in Moodle 4.x because the ID changes every time the page is loaded or refreshed.

I wrote and am using the following CSS on two self-hosted Moodle 4.1.1 sites and one Moodle 4.0.5 MoodleCloud site, all using the Boost Theme:

/* hide Feedback activity Preview Questions button */
div.feedback_description div.navitem:first-of-type a.btn {
display: none;
}
/* show Feedback activity Preview Questions button in Edit Mode */
body.editing div.feedback_description div.navitem:first-of-type a.btn {
display: inline-block;
}

Both rules are needed.

The first rule will hide the "Preview Questions" button for students, guests, facilitators, course creators, and parents.

However, it also hides the "Edit Questions" button for managers and teachers (because the "Edit Questions" button is the first button in that div) making it impossible for them to edit the Feedback activity questions. The second rule displays the "Edit Questions" button when "Edit Mode" is turned on and hides it when "Edit Mode" is turned off. Although this means an extra step for managers and teachers, they can at least still edit the Feedback questions.

A downside to this method is that it hides the "Preview Questions" button for facilitators so they can no longer see what questions are being asked in the Feedback activity. I haven't found a way around this.

This method will only work as long as the "Preview Questions" button is in the first div with a class of "navitem" inside the div with a class of "feedback_description." If the HTML changes, the CSS will need to be updated.

I'm using this as a workaround until https://tracker.moodle.org/browse/MDL-70586 is resolved. It would be much better to be able to handle the display of the "Preview Questions" button via role permissions.
In reply to Cam Howard

Re: Remove preview questions button and link in Feedback Activity Moodle 4.0

by Cam Howard -
Minor correction/clarification to CSS comment for second rule:

/* hide Feedback activity Preview Questions button */
div.feedback_description div.navitem:first-of-type a.btn {
display: none;
}
/* show Feedback activity Edit Questions button in Edit Mode */
body.editing div.feedback_description div.navitem:first-of-type a.btn {
display: inline-block;
}
Average of ratings: Useful (2)
In reply to Cam Howard

Re: Remove preview questions button and link in Feedback Activity Moodle 4.0

by Przemek Kaszubski -
Picture of Particularly helpful Moodlers Picture of Testers
Inspired by your solution, as well as by https://moodle.org/mod/forum/discuss.php?d=356299#p1437215 , I have developed a variant for Moodle 3.11 whereby the Preview icon shows for the Teacher in the editing mode (while also those Teachers who "know" will find the invisible link in the usual place, as well).
I described my CSS in this comment on the Tracker (the problem is solved now for Moodle 4 and up. but not for earlier versions):
https://tracker.moodle.org/browse/MDL-70586?focusedCommentId=997750&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-997750 .
Cheers.
In reply to Przemek Kaszubski

Re: Remove preview questions button and link in Feedback Activity Moodle 4.0

by Cam Howard -
Hi Przemek,

Great idea! Your CSS code looks like it should work well in Moodle 3.11.

Cam
In reply to Cam Howard

Re: Remove preview questions button and link in Feedback Activity Moodle 4.0

by Julien Garrigue -
Hi! In which file shall I paste this CSS code?
I've tried in mod/feedback/styles.css but it doesn't work. I put it in the first line of the file.
Thanks
In reply to Julien Garrigue

Re: Remove preview questions button and link in Feedback Activity Moodle 4.0

by Cam Howard -

Hi Julien,

On my sites, which all use the Boost theme, it goes in the "Raw SCSS" field for the theme.

  1. In Moodle, go to Site administration > Appearance.

  2. In the "Themes" section, click "Boost" (or your theme name).

  3. On the Boost (or your theme) page, click the tab for "Advanced settings."

  4. Paste the CSS in the "Raw SCSS" field.

  5. Scroll down and Save changes.

  6. Clear the theme caches: Appearance > Themes: Theme selector > Clear theme caches.

  7. Test to be sure you are getting the results you want for all roles.

I hope this helps!

Cam

Average of ratings: Useful (2)
In reply to Cam Howard

Re: Remove preview questions button and link in Feedback Activity Moodle 4.0

by Julien Garrigue -
Thank you, it works! I use the classic theme
In reply to Cam Howard

Re: Remove preview questions button and link in Feedback Activity Moodle 4.0

by Bronwen Campbell -
Thank you so much to Cam, Emma, Antonio and Julien - Cam for providing the CSS and everyone else for the comments and questions that helped clarify things and to remind me to vote on the issue. I implemented this today in a Moodle 4.1.1 and a Moodle 4.0.4 site and both worked perfectly.
In reply to Bronwen Campbell

Re: Remove preview questions button and link in Feedback Activity Moodle 4.0

by Cam Howard -
Hi Julien and Bronwen,

Great, thanks! I'm glad the CSS and where to put it are helpful and working well on your sites. Thanks for reporting back!

Cam