mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-83214 core_course: Make is_delegated consistent
This commit is contained in:
parent
a97ddeb2a2
commit
e1e282a4b1
@ -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);
|
||||
|
@ -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)) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user