From fd905bcacc4da0f2effa3453b9cda94293481a1d Mon Sep 17 00:00:00 2001 From: ferran Date: Mon, 24 Feb 2025 15:24:13 +0100 Subject: [PATCH] MDL-83892 course: fix section name in single activity format The course activities overview shows the section name under each activity. However, this information should not be present when the course format does not support sections. --- .../classes/output/local/overview/activityname.php | 8 ++++++-- .../templates/local/overview/activityname.mustache | 12 ++++++++++-- .../templates/local/overview/overviewtable.mustache | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) 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 @@
{{activityname}}
+ {{#sectiontitle}}
{{sectiontitle}}
+ {{/sectiontitle}}
{{#hidden}} - {{#str}}hiddenfromstudents{{/str}} + + {{#pix}}i/show, core{{/pix}} + {{#str}}hiddenfromstudents{{/str}} + {{/hidden}} {{#stealth}} - {{#str}}hiddenoncoursepage{{/str}} + + {{#pix}}t/stealth, core{{/pix}} + {{#str}}hiddenoncoursepage{{/str}} + {{/stealth}}
diff --git a/course/format/templates/local/overview/overviewtable.mustache b/course/format/templates/local/overview/overviewtable.mustache index 8b5866ad534..a0475eed65f 100644 --- a/course/format/templates/local/overview/overviewtable.mustache +++ b/course/format/templates/local/overview/overviewtable.mustache @@ -72,7 +72,7 @@ ] } }} -
+