From 8a0d02d373c3654f0d5dc308bab0708ed636bf3f Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Thu, 27 Jun 2024 17:41:28 +0100 Subject: [PATCH] MDL-82326 calendar: correct course name formatting and shortening. --- calendar/renderer.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/calendar/renderer.php b/calendar/renderer.php index 2c356347dc6..7766e1b30de 100644 --- a/calendar/renderer.php +++ b/calendar/renderer.php @@ -234,10 +234,12 @@ class core_calendar_renderer extends plugin_renderer_base { if (isset($contextrecords[$course->id])) { context_helper::preload_from_record($contextrecords[$course->id]); } - $coursecontext = context_course::instance($course->id); + // Limit the displayed course name to prevent the dropdown from getting too wide. - $coursename = shorten_text($course->fullname, 50, true); - $courseoptions[$course->id] = format_string($coursename, true, ['context' => $coursecontext]); + $coursename = format_string($course->fullname, true, [ + 'context' => \core\context\course::instance($course->id), + ]); + $courseoptions[$course->id] = shorten_text($coursename, 50, true); } if ($courseid) {