mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
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:
parent
f4a2d69631
commit
390098fa64
@ -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');
|
||||
}
|
||||
|
@ -502,7 +502,22 @@ class core_calendar_renderer extends plugin_renderer_base {
|
||||
$attributes['class'] = $events[$eventindex]->class;
|
||||
}
|
||||
$dayhref->set_anchor('event_'.$events[$eventindex]->id);
|
||||
$link = html_writer::link($dayhref, format_string($events[$eventindex]->name, true));
|
||||
|
||||
$eventcontext = $events[$eventindex]->context;
|
||||
$eventformatopts = array('context' => $eventcontext);
|
||||
// Get event name.
|
||||
$eventname = format_string($events[$eventindex]->name, true, $eventformatopts);
|
||||
// Include course's shortname into the event name, if applicable.
|
||||
$courseid = $events[$eventindex]->courseid;
|
||||
if (!empty($courseid) && $courseid !== SITEID) {
|
||||
$course = get_course($courseid);
|
||||
$eventnameparams = (object)[
|
||||
'name' => $eventname,
|
||||
'course' => format_string($course->shortname, true, $eventformatopts)
|
||||
];
|
||||
$eventname = get_string('eventnameandcourse', 'calendar', $eventnameparams);
|
||||
}
|
||||
$link = html_writer::link($dayhref, $eventname);
|
||||
$cell->text .= html_writer::tag('li', $link, $attributes);
|
||||
}
|
||||
$cell->text .= html_writer::end_tag('ul');
|
||||
|
@ -93,6 +93,7 @@ $string['eventendtime'] = 'End time';
|
||||
$string['eventinstanttime'] = 'Time';
|
||||
$string['eventkind'] = 'Type of event';
|
||||
$string['eventname'] = 'Event title';
|
||||
$string['eventnameandcourse'] = '{$a->course}: {$a->name}';
|
||||
$string['eventnone'] = 'No events';
|
||||
$string['eventrepeat'] = 'Repeats';
|
||||
$string['eventsall'] = 'All events';
|
||||
|
Loading…
x
Reference in New Issue
Block a user