diff --git a/admin/tool/lp/lib.php b/admin/tool/lp/lib.php index 62b6892b6fc..7f1ba9cfc0e 100644 --- a/admin/tool/lp/lib.php +++ b/admin/tool/lp/lib.php @@ -24,40 +24,6 @@ defined('MOODLE_INTERNAL') || die(); -/** - * This function extends the course navigation - * - * @param navigation_node $navigation The navigation node to extend - * @param stdClass $course The course to object for the tool - * @param context $coursecontext The context of the course - */ -function tool_lp_extend_navigation_course($navigation, $course, $coursecontext) { - if (!get_config('core_competency', 'enabled')) { - return; - } - - // Check access to the course and competencies page. - $capabilities = array('moodle/competency:coursecompetencyview', 'moodle/competency:coursecompetencymanage'); - $context = context_course::instance($course->id); - if (!has_any_capability($capabilities, $context) || !can_access_course($course)) { - return; - } - - // Just a link to course competency. - $title = get_string('competencies', 'core_competency'); - $path = new moodle_url("/admin/tool/lp/coursecompetencies.php", array('courseid' => $course->id)); - $settingsnode = navigation_node::create($title, - $path, - navigation_node::TYPE_SETTING, - null, - null, - new pix_icon('i/competencies', '')); - if (isset($settingsnode)) { - $navigation->add_node($settingsnode); - } -} - - /** * This function extends the user navigation. * diff --git a/course/lib.php b/course/lib.php index 8d89b8dd804..d8a922b522c 100644 --- a/course/lib.php +++ b/course/lib.php @@ -3469,7 +3469,7 @@ function course_get_tagged_course_modules($tag, $exclusivemode = false, $fromcon * This function also handles the frontpage course. * * @param stdClass $context context object (it can be a course context or the system context for frontpage settings) - * @param stdClass $course the course where the settings are being rendered (only used when $context is set to frontpage) + * @param stdClass $course the course where the settings are being rendered * @return stdClass the navigation options in a course and their availability status * @since Moodle 3.2 */ @@ -3512,6 +3512,7 @@ function course_get_user_navigation_options($context, $course = null) { has_capability('moodle/badges:viewbadges', $context); // Add view grade report is permitted. $grades = false; + if (has_capability('moodle/grade:viewall', $context)) { $grades = true; } else if (!empty($course->showgrades)) { @@ -3568,25 +3569,6 @@ function course_get_user_administration_options($course, $context) { $options->publish = has_capability('moodle/course:publish', $context); $options->reset = has_capability('moodle/course:reset', $context); $options->roles = has_capability('moodle/role:switchroles', $context); - - // Add view grade report is permitted. - $grades = false; - if (has_capability('moodle/grade:viewall', $context)) { - $grades = true; - } else if (!empty($course->showgrades)) { - $reports = core_component::get_plugin_list('gradereport'); - if (is_array($reports) && count($reports) > 0) { // Get all installed reports. - arsort($reports); // User is last, we want to test it first. - foreach ($reports as $plugin => $plugindir) { - if (has_capability('gradereport/'.$plugin.':view', $context)) { - // Stop when the first visible plugin is found. - $grades = true; - break; - } - } - } - } - $options->grades = $grades; } else { // Set default options to false. $listofoptions = array('tags', 'gradebook', 'outcomes', 'badges', 'import', 'publish', 'reset', 'roles', 'grades'); diff --git a/lib/navigationlib.php b/lib/navigationlib.php index 7bf575d8fa4..622ddfa57bc 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -2387,7 +2387,7 @@ class global_navigation extends navigation_node { $usercoursenode = $userscoursesnode->add($usercourseshortname, new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $usercourse->id)), self::TYPE_CONTAINER); - $gradeavailable = has_capability('moodle/grade:viewall', $usercoursecontext); + $gradeavailable = has_capability('moodle/grade:view', $usercoursecontext); if (!$gradeavailable && !empty($usercourse->showgrades) && is_array($reports) && !empty($reports)) { foreach ($reports as $plugin => $plugindir) { if (has_capability('gradereport/'.$plugin.':view', $usercoursecontext)) { @@ -2647,7 +2647,7 @@ class global_navigation extends navigation_node { return true; } - $navoptions = course_get_user_navigation_options($this->page->context); + $navoptions = course_get_user_navigation_options($this->page->context, $course); //Participants if ($navoptions->participants) { @@ -4158,11 +4158,6 @@ class settings_navigation extends navigation_node { } } - if ($adminoptions->grades) { - $url = new moodle_url('/grade/report/index.php', array('id'=>$course->id)); - $gradenode = $coursenode->add(get_string('grades'), $url, self::TYPE_SETTING, null, 'grades', new pix_icon('i/grades', '')); - } - // Check if we can view the gradebook's setup page. if ($adminoptions->gradebook) { $url = new moodle_url('/grade/edit/tree/index.php', array('id' => $course->id)); diff --git a/theme/boost/classes/output/core_renderer.php b/theme/boost/classes/output/core_renderer.php index 05a89b97eb9..a14ad7d4c90 100644 --- a/theme/boost/classes/output/core_renderer.php +++ b/theme/boost/classes/output/core_renderer.php @@ -554,23 +554,29 @@ class core_renderer extends \core_renderer { $settingsnode = $this->page->settingsnav->find('frontpage', navigation_node::TYPE_SETTING); if ($settingsnode) { // Build an action menu based on the visible nodes from this navigation tree. - $this->build_action_menu_from_navigation($menu, $settingsnode, false, true); + $skipped = $this->build_action_menu_from_navigation($menu, $settingsnode, false, true); - $text = get_string('frontpagesettings'); - $url = new moodle_url('/course/admin.php', array('courseid' => $this->page->course->id)); - $link = new action_link($url, $text, null, null, new pix_icon('t/edit', $text)); - $menu->add_secondary_action($link); + // We only add a list to the full settings menu if we didn't include every node in the short menu. + if ($skipped) { + $text = get_string('frontpagesettings'); + $url = new moodle_url('/course/admin.php', array('courseid' => $this->page->course->id)); + $link = new action_link($url, $text, null, null, new pix_icon('t/edit', $text)); + $menu->add_secondary_action($link); + } } } else if ($node->type == navigation_node::TYPE_COURSE) { $settingsnode = $this->page->settingsnav->find('courseadmin', navigation_node::TYPE_COURSE); if ($settingsnode) { // Build an action menu based on the visible nodes from this navigation tree. - $this->build_action_menu_from_navigation($menu, $settingsnode, false, true); + $skipped = $this->build_action_menu_from_navigation($menu, $settingsnode, false, true); - $text = get_string('courseadministration'); - $url = new moodle_url('/course/admin.php', array('courseid' => $this->page->course->id)); - $link = new action_link($url, $text, null, null, new pix_icon('t/edit', $text)); - $menu->add_secondary_action($link); + // We only add a list to the full settings menu if we didn't include every node in the short menu. + if ($skipped) { + $text = get_string('courseadministration'); + $url = new moodle_url('/course/admin.php', array('courseid' => $this->page->course->id)); + $link = new action_link($url, $text, null, null, new pix_icon('t/edit', $text)); + $menu->add_secondary_action($link); + } } } } else if ($context->contextlevel == CONTEXT_USER) { @@ -629,15 +635,18 @@ class core_renderer extends \core_renderer { * @param navigation_node $node * @param boolean $indent * @param boolean $onlytopleafnodes + * @return boolean nodesskipped - True if nodes were skipped in building the menu */ private function build_action_menu_from_navigation(action_menu $menu, navigation_node $node, $indent = false, $onlytopleafnodes = false) { + $skipped = false; // Build an action menu based on the visible nodes from this navigation tree. foreach ($node->children as $menuitem) { if ($menuitem->display) { if ($onlytopleafnodes && $menuitem->children->count()) { + $skipped = true; continue; } if ($menuitem->action) { @@ -652,14 +661,16 @@ class core_renderer extends \core_renderer { } } else { if ($onlytopleafnodes) { + $skipped = true; continue; } $link = $menuitem->text; } $menu->add_secondary_action($link); - $this->build_action_menu_from_navigation($menu, $menuitem, true); + $skipped = $skipped || $this->build_action_menu_from_navigation($menu, $menuitem, true); } } + return $skipped; } }