diff --git a/mod/assign/lib.php b/mod/assign/lib.php index 57ac40853fd..c789465e031 100644 --- a/mod/assign/lib.php +++ b/mod/assign/lib.php @@ -1772,3 +1772,20 @@ function mod_assign_core_calendar_provide_event_action(\core_calendar\event $eve $actionable ); } + +/** + * Callback function that determines whether an action event should be showing its item count + * based on the event type and the item count. + * + * @param \core_calendar\event $event The calendar event. + * @param int $itemcount The item count associated with the action event. + * @return bool + */ +function mod_assign_core_calendar_event_action_shows_item_count(\core_calendar\event $event, $itemcount = 0) { + // List of event types where the action event's item count should be shown. + $eventtypesshowingitemcount = [ + ASSIGN_EVENT_TYPE_GRADINGDUE + ]; + // For mod_assign, item count should be shown if the event type is 'gradingdue' and there is one or more item count. + return in_array($event->eventtype, $eventtypesshowingitemcount) && $itemcount > 0; +} diff --git a/mod/forum/lib.php b/mod/forum/lib.php index e26deede178..be1a17d179f 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -8116,3 +8116,16 @@ function mod_forum_get_fontawesome_icon_map() { 'mod_forum:t/unsubscribed' => 'fa-envelope-open-o', ]; } + +/** + * Callback function that determines whether an action event should be showing its item count + * based on the event type and the item count. + * + * @param \core_calendar\event $event The calendar event. + * @param int $itemcount The item count associated with the action event. + * @return bool + */ +function mod_forum_core_calendar_event_action_shows_item_count(\core_calendar\event $event, $itemcount = 0) { + // Always show item count for forums if item count is greater than 0. + return $itemcount > 0; +} \ No newline at end of file