From 9c02796d51b96dd04c6c9651539c039e082465c0 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Wed, 5 Dec 2018 13:59:09 +1300 Subject: [PATCH] Fix stupid way of checking if user already has a recorded attendance. --- classes/structure.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/classes/structure.php b/classes/structure.php index 74b99b2..ebb515d 100644 --- a/classes/structure.php +++ b/classes/structure.php @@ -622,8 +622,10 @@ class mod_attendance_structure { $record->takenby = $USER->id; $record->ipaddress = getremoteaddr(null); - $dbsesslog = $this->get_session_log($mformdata->sessid); - if (array_key_exists($record->studentid, $dbsesslog)) { + $existingattendance = $DB->record_exists('attendance_log', + array('sessionid' => $mformdata->sessid, 'studentid' => $USER->id)); + + if ($existingattendance) { // Already recorded do not save. return false; }