diff --git a/course/format/classes/output/local/overview/activityname.php b/course/format/classes/output/local/overview/activityname.php index 6dce126d630..2f2754b9796 100644 --- a/course/format/classes/output/local/overview/activityname.php +++ b/course/format/classes/output/local/overview/activityname.php @@ -53,13 +53,17 @@ class activityname implements renderable, named_templatable { $section = $this->cm->get_section_info(); $course = $this->cm->get_course(); $format = course_format::instance($course); - return (object) [ + + $result = (object) [ 'activityname' => \core_external\util::format_string($cm->name, $cm->context, true), 'activityurl' => $cm->url, - 'sectiontitle' => $format->get_section_name($section), 'hidden' => empty($cm->visible), 'stealth' => $cm->is_stealth(), ]; + if ($format->uses_sections()) { + $result->sectiontitle = $format->get_section_name($section); + } + return $result; } /** diff --git a/course/format/templates/local/overview/activityname.mustache b/course/format/templates/local/overview/activityname.mustache index 7e4b30052f0..85ad16ffd0e 100644 --- a/course/format/templates/local/overview/activityname.mustache +++ b/course/format/templates/local/overview/activityname.mustache @@ -32,15 +32,23 @@
+ {{#sectiontitle}}