MDL-83214 core_course: Make is_delegated consistent

This commit is contained in:
Amaia Anabitarte 2024-12-16 11:07:15 +01:00
parent a97ddeb2a2
commit e1e282a4b1
7 changed files with 9 additions and 9 deletions

View File

@ -105,7 +105,7 @@ $editoroptions = array(
$courseformat = course_get_format($course);
if ($sectioninfo->is_delegated()) {
if ($sectioninfo->name) {
$defaultsectionname = $sectioninfo->name;
} else {
$defaultsectionname = $courseformat->get_default_section_name($section);

View File

@ -409,8 +409,8 @@ class sectionactions extends baseactions {
$cmids = [];
// In case the section is delegated by a module, we change also the visibility for the source module.
if ($sectioninfo->is_delegated()) {
$delegateinstance = $sectioninfo->get_component_instance();
$delegateinstance = $sectioninfo->get_component_instance();
if ($delegateinstance) {
// We only return sections delegated by course modules. Sections delegated to other
// types of components must implement their own methods to get the section.
if ($delegateinstance && ($delegateinstance instanceof \core_courseformat\sectiondelegatemodule)) {

View File

@ -119,7 +119,7 @@ class header implements named_templatable, renderable {
}
// Delegated sections in main course page need to have h4 tag, h3 otherwise.
$data->headinglevel = ($section->is_delegated() && is_null($format->get_sectionid())) ? 4 : 3;
$data->headinglevel = ($section->get_component_instance() && is_null($format->get_sectionid())) ? 4 : 3;
return $data;
}

View File

@ -45,7 +45,7 @@ class section extends section_base {
$data = parent::export_for_template($output);
if (!$this->format->get_sectionnum() && !$this->section->is_delegated()) {
if (!$this->format->get_sectionnum() && !$this->section->get_component_instance()) {
$addsectionclass = $format->get_output_classname('content\\addsection');
$addsection = new $addsectionclass($format);
$data->numsections = $addsection->export_for_template($output);

View File

@ -3701,7 +3701,7 @@ class section_info implements IteratorAggregate {
* Get the delegate component instance.
*/
public function get_component_instance(): ?sectiondelegate {
if (empty($this->_component)) {
if (!$this->is_delegated()) {
return null;
}
if ($this->_delegateinstance !== null) {

View File

@ -71,7 +71,7 @@ class coursestructure implements \renderable, \templatable {
$sectioninfo = $this->modinfo->get_section_info($sectionnum);
// Don't show subsections here. We are showing them in the corresponding module.
if ($sectioninfo->is_delegated()) {
if ($sectioninfo->get_component_instance()) {
continue;
}
@ -128,7 +128,7 @@ class coursestructure implements \renderable, \templatable {
$sectioninfo = $this->modinfo->get_section_info($sectionnum);
// Don't show subsections here. We are showing them in the corresponding module.
if ($sectioninfo->is_delegated()) {
if ($sectioninfo->get_component_instance()) {
continue;
}

View File

@ -226,7 +226,7 @@ class report_log_renderable implements renderable {
$sectioninfo = $modinfo->get_section_info($cm->sectionnum);
// Don't show subsections here. We are showing them in the corresponding module.
if ($sectioninfo->is_delegated()) {
if ($sectioninfo->get_component_instance()) {
continue;
}