Skip to content

Commit e3c36e4

Browse files
committedMay 31, 2024
MDL-81648 navigation: Add delegated section logic to section nodes
1 parent 932b094 commit e3c36e4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed
 

‎lib/navigationlib.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -2295,10 +2295,20 @@ public function load_generic_course_sections(stdClass $course, navigation_node $
22952295
continue;
22962296
}
22972297

2298+
$parentnode = $coursenode;
2299+
2300+
// Set the parent node to the parent section if this is a delegated section.
2301+
if ($section->is_delegated()) {
2302+
$parentsection = $section->get_component_instance()->get_parent_section();
2303+
if ($parentsection) {
2304+
$parentnode = $coursenode->find($parentsection->id, self::TYPE_SECTION) ?: $coursenode;
2305+
}
2306+
}
2307+
22982308
$sectionname = get_section_name($course, $section);
22992309
$url = course_get_url($course, $section->section, array('navigation' => true));
23002310

2301-
$sectionnode = $coursenode->add($sectionname, $url, navigation_node::TYPE_SECTION,
2311+
$sectionnode = $parentnode->add($sectionname, $url, navigation_node::TYPE_SECTION,
23022312
null, $section->id, new pix_icon('i/section', ''));
23032313
$sectionnode->nodetype = navigation_node::NODETYPE_BRANCH;
23042314
$sectionnode->hidden = (!$section->visible || !$section->available);

‎theme/boost/classes/boostnavbar.php

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ protected function prepare_nodes_for_boost(): void {
6868
}
6969
}
7070
if ($this->page->context->contextlevel == CONTEXT_COURSE) {
71+
$removesections = course_get_format($this->page->course)->can_sections_be_removed_from_navigation();
7172
// Remove any duplicate navbar nodes.
7273
$this->remove_duplicate_items();
7374
// Remove 'My courses' and 'Courses' if we are in the course context.

0 commit comments

Comments
 (0)
Please sign in to comment.