Skip to content

Commit

Permalink
MDL-74160 core_coureformat: fix legacy renderer methods
Browse files Browse the repository at this point in the history
To ensure legacy course formats works on Moodle 4.0 some method are
reintroduced (but marked as deprecated) like start_section_list and
end_section_list. Furthermore, the course_section_cm_availability
returns a string again as expected.
  • Loading branch information
ferranrecio committed Mar 22, 2022
1 parent 9344149 commit ce7edab
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
28 changes: 28 additions & 0 deletions course/format/classes/output/section_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,34 @@ protected function section_footer() {
return $o;
}

/**
* Generate the starting container html for a list of sections.
*
* @deprecated since 4.0 MDL-72656 - use core_course output components instead.
*
* @return string HTML to output.
*/
protected function start_section_list() {
debugging('start_section_list() is deprecated. Please use ' .
'core_courseformat\\output\\local\\content\\section to render individual sections or .' .
'core_courseformat\\output\\local\\content to render the full course', DEBUG_DEVELOPER);
return html_writer::start_tag('ul', ['class' => 'sections']);
}

/**
* Generate the closing container html for a list of sections.
*
* @deprecated since 4.0 MDL-72656 - use core_course output components instead.y
*
* @return string HTML to output.
*/
protected function end_section_list() {
debugging('end_section_list() is deprecated. Please use ' .
'core_courseformat\\output\\local\\content\\section to render individual sections or .' .
'core_courseformat\\output\\local\\content to render the full course', DEBUG_DEVELOPER);
return html_writer::end_tag('ul');
}

/**
* Old method to print section edit controls. Do not use it!
*
Expand Down
4 changes: 1 addition & 3 deletions course/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -823,10 +823,8 @@ public function course_section_cm_availability(cm_info $mod, $displayoptions = a
$mod->get_section_info(),
$mod,
);

$renderer = $format->get_renderer($this->page);
$data = $availability->export_for_template($renderer);
return $data->info ?? '';
return $renderer->render($availability);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion course/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ renderer and course format renderer:
- course_section_cm_name_title (replaced by core_courseformat\output\local\cm\title)
- course_section_cm_text (integrated in core_courseformat\output\local\content\cm)
- course_section_cm_availability (replaced by core_courseformat\output\local\content\cm\availability))
* The following abstract methods are deleted:
- start_section_list (integrated in core_courseformat\output\local\content)
- end_section_list (integrated in core_courseformat\output\local\content)
* The following abstract methods are deleted:
- page_title (moved to core_courseformat\output\local\content)
* Course formats should have a renderer (until now it was only highly recommended but not mandatory). For backwards
compatibility (to not break third-party plugins without it), legacy_format_renderer has been created and will be used when
Expand Down

0 comments on commit ce7edab

Please sign in to comment.