Skip to content

Commit

Permalink
Fix 'Orphaned Section still appear in Index Drawer' - #146.
Browse files Browse the repository at this point in the history
  • Loading branch information
gjb2048 committed Feb 10, 2024
1 parent 415c5a8 commit d19b340
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

Version 401.1.2 - TBR
----------------------------
1. Fix 'Orphaned Section still appear in Index Drawer' - #146.

Version 401.1.1 - 14/08/2023
----------------------------
Expand Down
22 changes: 22 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,28 @@ public function get_topcoll_section_name($course, $section, $additional) {
return $o;
}

/**
* Returns if an specific section is visible to the current user.
*
* Formats can overrride this method to implement any special section logic.
*
* @param section_info $section the section modinfo
* @return bool;
*/
public function is_section_visible(section_info $section): bool {
if ($section->section > $this->get_last_section_number()) {
// Stealth section.
global $PAGE;
$context = context_course::instance($this->course->id);
if ($PAGE->user_is_editing() && has_capability('moodle/course:update', $context)) {
$modinfo = get_fast_modinfo($this->course);
// If the stealth section has modules then is visible.
return (!empty($modinfo->sections[$section->section]));
}
}
return parent::is_section_visible($section);
}

public function get_section_dates($section, $course = null, $tcsettings = null) {
if (empty($tcsettings) && empty($course)) {
return $this->format_topcoll_get_section_dates($section, $this->get_course());
Expand Down

0 comments on commit d19b340

Please sign in to comment.