From 3d6255b749fb8dc291d47d4f9362277f6758f621 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Thu, 17 Feb 2022 00:18:41 +0800 Subject: [PATCH] MDL-73373 output: No Enrolments in tertiary nav in module context Enrolments should not be displayed on the tertiary navigation when it is being displayed in the module context. --- lib/classes/output/participants_action_bar.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/classes/output/participants_action_bar.php b/lib/classes/output/participants_action_bar.php index 44885bbfbb4..b1585dff737 100644 --- a/lib/classes/output/participants_action_bar.php +++ b/lib/classes/output/participants_action_bar.php @@ -89,18 +89,20 @@ class participants_action_bar implements \renderable { return []; } - // Pre-populate the formatted tertiary nav items with the "Enrolled users" node if user can view the participants page. - $coursecontext = context_course::instance($this->course->id); - $canviewparticipants = course_can_view_participants($coursecontext); $formattedcontent = []; $enrolmentsheading = get_string('enrolments', 'enrol'); - if ($canviewparticipants) { - $participantsurl = (new moodle_url('/user/index.php', ['id' => $this->course->id]))->out(); - $formattedcontent[] = [ + if ($this->page->context->contextlevel != CONTEXT_MODULE) { + // Pre-populate the formatted tertiary nav items with the "Enrolled users" node if user can view the participants page. + $coursecontext = context_course::instance($this->course->id); + $canviewparticipants = course_can_view_participants($coursecontext); + if ($canviewparticipants) { + $participantsurl = (new moodle_url('/user/index.php', ['id' => $this->course->id]))->out(); + $formattedcontent[] = [ $enrolmentsheading => [ - $participantsurl => get_string('enrolledusers', 'enrol'), + $participantsurl => get_string('enrolledusers', 'enrol'), ] - ]; + ]; + } } $nodes = $this->get_ordered_nodes();