The only reason the exclusion of require_once was not exploding before
is because the call to provider_event_action() was being triggered first
which required the file. We can't rely on this happening all the time.
The doc update describes when the usage of is_event_visible() is appropriate.
Part of MDL-55611 epic.
/**
* Is the event visible?
*
+ * This is used to determine global visibility of an event in all places throughout Moodle. For example,
+ * the ASSIGN_EVENT_TYPE_GRADINGDUE event will not be shown to students on their calendar, and
+ * ASSIGN_EVENT_TYPE_DUE events will not be shown to teachers.
+ *
* @param \core_calendar\event $event
* @return bool Returns true if the event is visible to the current user, false otherwise.
*/
function mod_assign_core_calendar_is_event_visible(\core_calendar\event $event) {
- global $USER;
+ global $CFG, $USER;
+
+ require_once($CFG->dirroot . '/mod/assign/locallib.php');
$cm = get_fast_modinfo($event->courseid)->instances['assign'][$event->instance];
$context = context_module::instance($cm->id);