From 9bc4d9e8dd8a24040925e72ab3a63d49de2814c8 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Mon, 8 Apr 2019 20:20:05 +1200 Subject: [PATCH] Prevent Calendarevent value being set when disabled at site level. --- classes/structure.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/classes/structure.php b/classes/structure.php index ebb515d..9090216 100644 --- a/classes/structure.php +++ b/classes/structure.php @@ -454,13 +454,18 @@ class mod_attendance_structure { public function add_sessions($sessions) { global $DB; + $config = get_config('attendance'); + foreach ($sessions as $sess) { $sess->attendanceid = $this->id; $sess->automarkcompleted = 0; if (!isset($sess->automark)) { $sess->automark = 0; } - + if (empty($config->enablecalendar)) { + // If calendard disabled at site level, don't use it. + $sess->calendarevent = 0; + } $sess->id = $DB->insert_record('attendance_sessions', $sess); $description = file_save_draft_area_files($sess->descriptionitemid, $this->context->id, 'mod_attendance', 'session', $sess->id,