MDL-81648 navigation: Add delegated section logic to section nodes

This commit is contained in:
Mikel Martín 2024-05-17 10:09:39 +02:00
parent 932b094134
commit e3c36e48cc
2 changed files with 12 additions and 1 deletions

View File

@ -2295,10 +2295,20 @@ class global_navigation extends navigation_node {
continue;
}
$parentnode = $coursenode;
// Set the parent node to the parent section if this is a delegated section.
if ($section->is_delegated()) {
$parentsection = $section->get_component_instance()->get_parent_section();
if ($parentsection) {
$parentnode = $coursenode->find($parentsection->id, self::TYPE_SECTION) ?: $coursenode;
}
}
$sectionname = get_section_name($course, $section);
$url = course_get_url($course, $section->section, array('navigation' => true));
$sectionnode = $coursenode->add($sectionname, $url, navigation_node::TYPE_SECTION,
$sectionnode = $parentnode->add($sectionname, $url, navigation_node::TYPE_SECTION,
null, $section->id, new pix_icon('i/section', ''));
$sectionnode->nodetype = navigation_node::NODETYPE_BRANCH;
$sectionnode->hidden = (!$section->visible || !$section->available);

View File

@ -68,6 +68,7 @@ class boostnavbar implements \renderable {
}
}
if ($this->page->context->contextlevel == CONTEXT_COURSE) {
$removesections = course_get_format($this->page->course)->can_sections_be_removed_from_navigation();
// Remove any duplicate navbar nodes.
$this->remove_duplicate_items();
// Remove 'My courses' and 'Courses' if we are in the course context.