/** * Loads all of the course sections into the navigation * * @param global_navigation $navigation * @param navigation_node $node The course node within the navigation */ public function extend_course_navigation($navigation, navigation_node $node) { global $PAGE; // if section is specified in course/view.php, make sure it is expanded in navigation if ($navigation->includesectionnum === false) { $selectedsection = optional_param('section', null, PARAM_INT); if ($selectedsection !== null && (!defined('AJAX_SCRIPT') || AJAX_SCRIPT == '0') && $PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) { $navigation->includesectionnum = $selectedsection; } } // check if there are callbacks to extend course navigation parent::extend_course_navigation($navigation, $node); // We want to remove the general section if it is empty. $modinfo = get_fast_modinfo($this->get_course()); $sections = $modinfo->get_sections(); if (!isset($sections[0])) { // The general section is empty to find the navigation node for it we need to get its ID. $section = $modinfo->get_section_info(0); $generalsection = $node->get($section->id, navigation_node::TYPE_SECTION); if ($generalsection) { // We found the node - now remove it. $generalsection->remove(); } } }
/** * Loads all of the course sections into the navigation * * @param global_navigation $navigation * @param navigation_node $node The course node within the navigation */ public function extend_course_navigation($navigation, navigation_node $node) { global $PAGE; // If section is specified in course/view.php, make sure it is expanded in navigation. if ($navigation->includesectionnum === false) { $selectedsection = optional_param('section', null, PARAM_INT); if ($selectedsection !== null && (!defined('AJAX_SCRIPT') || AJAX_SCRIPT == '0') && $PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) { $navigation->includesectionnum = $selectedsection; } } parent::extend_course_navigation($navigation, $node); $modinfo = get_fast_modinfo($this->get_course()); $context = context_course::instance($modinfo->courseid); $sectioninfos = $this->get_sections(); foreach ($sectioninfos as $sectionnum => $section) { if ($sectionnum == 0) { if (empty($modinfo->sections[0]) && ($sectionnode = $node->get($section->id, navigation_node::TYPE_SECTION))) { // The general section is empty, remove the node from navigation. $sectionnode->remove(); } } else { if ($this->get_section_display_mode($section) > FORMAT_PERIODS_COLLAPSED && ($sectionnode = $node->get($section->id, navigation_node::TYPE_SECTION))) { // Remove or hide navigation nodes for sections that are hidden/not available. if (!has_capability('moodle/course:viewhiddenactivities', $context) && $navigation->includesectionnum != $sectionnum) { $sectionnode->remove(); } else { $sectionnode->hidden = true; } } } } }
/** * Loads all of the course sections into the navigation * * @param global_navigation $navigation * @param navigation_node $node The course node within the navigation */ public function extend_course_navigation($navigation, navigation_node $node) { global $PAGE; // if section is specified in course/view.php, make sure it is expanded in navigation if ($navigation->includesectionnum === false) { $selectedsection = optional_param('section', null, PARAM_INT); if ($selectedsection !== null && (!defined('AJAX_SCRIPT') || AJAX_SCRIPT == '0') && $PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) { $navigation->includesectionnum = $selectedsection; } } parent::extend_course_navigation($navigation, $node); }
/** * Loads all of the course sections into the navigation * * First this function calls callback_FORMATNAME_display_content() if it exists to check * if the navigation should be extended at all * * Then it calls function callback_FORMATNAME_load_content() if it exists to actually extend * navigation * * By default the parent method is called * * @param global_navigation $navigation * @param navigation_node $node The course node within the navigation */ public function extend_course_navigation($navigation, navigation_node $node) { global $PAGE; // if course format displays section on separate pages and we are on course/view.php page // and the section parameter is specified, make sure this section is expanded in // navigation if ($navigation->includesectionnum === false) { $selectedsection = optional_param('section', null, PARAM_INT); if ($selectedsection !== null && (!defined('AJAX_SCRIPT') || AJAX_SCRIPT == '0') && $PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) { $navigation->includesectionnum = $selectedsection; } } // check if there are callbacks to extend course navigation $displayfunc = 'callback_' . $this->format . '_display_content'; if (function_exists($displayfunc) && !$displayfunc()) { return; } $featurefunction = 'callback_' . $this->format . '_load_content'; if (function_exists($featurefunction) && ($course = $this->get_course())) { $featurefunction($navigation, $course, $node); } else { parent::extend_course_navigation($navigation, $node); } }