Remove preview questions button and link in Feedback Activity Moodle 4.0

Remove preview questions button and link in Feedback Activity Moodle 4.0

per Bronwen Campbell -
Nombre de respostes: 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

Mitjana de qualificacions: -
En resposta a Bronwen Campbell

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

per Emma Richardson -
Imatge de Documentation writers Imatge de Particularly helpful Moodlers Imatge de 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;
}
En resposta a Emma Richardson

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

per 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!
En resposta a Bronwen Campbell

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

per 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.
En resposta a Cam Howard

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

per 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;
}
En resposta a Cam Howard

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

per Przemek Kaszubski -
Imatge de Particularly helpful Moodlers Imatge de 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.
En resposta a Przemek Kaszubski

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

per Cam Howard -
Hi Przemek,

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

Cam
En resposta a Cam Howard

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

per 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
En resposta a Julien Garrigue

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

per 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

En resposta a Cam Howard

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

per 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.
En resposta a Bronwen Campbell

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

per 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