MDL-1322 calendar: Add course short name in calendar event

* Add the course's short name for a course event in order to let the
user know immediately which course an event belongs to. Particularly
helpful for activity events.
This commit is contained in:
Jun Pataleta 2017-06-23 14:11:49 +08:00
parent f4a2d69631
commit 390098fa64
3 changed files with 26 additions and 1 deletions

View file

@ -1457,6 +1457,15 @@ function calendar_get_mini($courses, $groups, $users, $calmonth = false, $calyea
$name = format_string($event->name, true);
}
}
// Include course's shortname into the event name, if applicable.
if (!empty($event->courseid) && $event->courseid !== SITEID) {
$course = get_course($event->courseid);
$eventnameparams = (object)[
'name' => $name,
'course' => format_string($course->shortname, true, array('context' => $event->context))
];
$name = get_string('eventnameandcourse', 'calendar', $eventnameparams);
}
$popupcontent .= \html_writer::link($dayhref, $name);
$popupcontent .= \html_writer::end_tag('div');
}