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.
This commit is contained in:
ferran
2025-02-25 09:41:44 +01:00
parent a26db489d0
commit fd905bcacc
3 changed files with 17 additions and 5 deletions
@@ -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;
}
/**
@@ -32,15 +32,23 @@
<div class="fw-bold">
<a href="{{activityurl}}" class="activityname">{{activityname}}</a>
</div>
{{#sectiontitle}}
<div>
{{sectiontitle}}
</div>
{{/sectiontitle}}
<div class="ml-2">
{{#hidden}}
<span class="badge badge-success">{{#str}}hiddenfromstudents{{/str}}</span>
<span class="badge rounded-pill text-bg-secondary fw-normal">
{{#pix}}i/show, core{{/pix}}
{{#str}}hiddenfromstudents{{/str}}
</span>
{{/hidden}}
{{#stealth}}
<span class="badge badge-warning">{{#str}}hiddenoncoursepage{{/str}}</span>
<span class="badge rounded-pill text-bg-secondary fw-normal">
{{#pix}}t/stealth, core{{/pix}}
{{#str}}hiddenoncoursepage{{/str}}
</span>
{{/stealth}}
</div>
</div>
@@ -72,7 +72,7 @@
]
}
}}
<div class="course-overview border border-secondary border-1 rounded">
<div class="course-overview border border-secondary border-1 rounded pt-2">
<table
class="course-overview-table boxaligncenter {{!
}} table table-responsive w-100 d-block d-md-table"