diff --git a/course/format/topics/lib.php b/course/format/topics/lib.php index aa043783809..f7e91bb8633 100644 --- a/course/format/topics/lib.php +++ b/course/format/topics/lib.php @@ -143,6 +143,19 @@ class format_topics extends format_base { // 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(); + } + } } /** diff --git a/course/format/weeks/lib.php b/course/format/weeks/lib.php index f554d9c0433..73d97c26dfb 100644 --- a/course/format/weeks/lib.php +++ b/course/format/weeks/lib.php @@ -148,6 +148,19 @@ class format_weeks extends format_base { } } 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(); + } + } } /**