Skip to content

Commit

Permalink
Moodle 4.5 subsections WIP 13
Browse files Browse the repository at this point in the history
  • Loading branch information
james-cnz committed Oct 15, 2024
1 parent e3a9947 commit 5eafda6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion classes/output/courseformat/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ private function get_sections_to_display(\course_modinfo $modinfo): array {
if (!empty($thissectionextra->sectionbase->component)) {
continue;
}
$pageid = ($thissectionextra->levelsan != FORMAT_MULTITOPIC_SECTION_LEVEL_TOPIC) ?
$pageid = ($thissectionextra->levelsan < FORMAT_MULTITOPIC_SECTION_LEVEL_TOPIC) ?
$thissectionextra->id : $thissectionextra->parentid;
$onpage = ($pageid == $format->get_sectionid());
if ($onpage || $format->show_editor()) {
Expand Down
19 changes: 6 additions & 13 deletions classes/output/courseformat/content/section.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,14 @@ public function export_for_template(\renderer_base $output): \stdClass {
* @return bool if the cm has name data
*/
protected function add_header_data(\stdClass &$data, \renderer_base $output): bool {
if (!empty($this->hidetitle)) {
return false;
$result = parent::add_header_data($data, $output);
if (!$result || !empty($section->component)) {
return $result;
}

$section = $this->section;
$format = $this->format;

$header = new $this->headerclass($format, $section);
$headerdata = $header->export_for_template($output);

if ($section->id == $format->get_sectionid() && !empty($section->component)) {
$data->singleheader = $headerdata;
} else {
$data->header = $headerdata;
if (isset($data->singleheader) && !isset($data->header)) {
$data->header = $data->singleheader;
unset($data->singleheader);
}
return true;
}
Expand Down Expand Up @@ -160,7 +154,6 @@ protected function add_editor_data(\stdClass &$data, \renderer_base $output): bo
$controlmenu = new $this->controlmenuclass($this->format, $this->section);
$data->controlmenu = $controlmenu->export_for_template($output);
}

return true;
}

Expand Down
4 changes: 2 additions & 2 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ function format_multitopic_reorder_sections(array $sectionsextra, $origins, \std
$sections[$id]->level = ($sectionextra->levelsan >= FORMAT_MULTITOPIC_SECTION_LEVEL_TOPIC
&& $sectionextra->levelsan != $originlevel) ?
FORMAT_MULTITOPIC_SECTION_LEVEL_TOPIC // Don't change topic level.
: $sectionextra->levelsan + $levelchange;
: max($sectionextra->levelsan + $levelchange, 0);
}

// Append rest of array.
Expand All @@ -407,7 +407,7 @@ function format_multitopic_reorder_sections(array $sectionsextra, $origins, \std
$sections[$id] = new \stdClass;
$sections[$id]->id = $id;
$sections[$id]->visible = $sectionextra->visiblesan;
$sections[$id]->level = $sectionextra->levelsan;
$sections[$id]->level = max($sectionextra->levelsan, 0);
}
}

Expand Down

0 comments on commit 5eafda6

Please sign in to comment.