From e734796b93f39019ded22ee512ff93cc755152f9 Mon Sep 17 00:00:00 2001 From: M <12033826+maksudr@users.noreply.github.com> Date: Tue, 16 Jul 2019 15:46:58 +0100 Subject: [PATCH] Adding expiry time margin to setting and updating settings text. --- attendance.php | 3 ++- lang/en/attendance.php | 6 ++++-- settings.php | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/attendance.php b/attendance.php index 638ea4b..068b6f4 100644 --- a/attendance.php +++ b/attendance.php @@ -33,6 +33,7 @@ $id = required_param('sessid', PARAM_INT); $qrpass = optional_param('qrpass', '', PARAM_TEXT); $attforsession = $DB->get_record('attendance_sessions', array('id' => $id), '*', MUST_EXIST); +$attconfig = get_config('attendance'); $attendance = $DB->get_record('attendance', array('id' => $attforsession->attendanceid), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('attendance', $attendance->id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); @@ -54,7 +55,7 @@ if ($attforsession->rotateqrcode == 1) { // Check password $sql = 'SELECT * FROM {attendance_rotate_passwords}'. ' WHERE attendanceid = ? AND expirytime > ? ORDER BY expirytime ASC LIMIT 2'; - $qrpassdatabase = $DB->get_records_sql($sql, ['attendanceid' => $id, time() - 2]); + $qrpassdatabase = $DB->get_records_sql($sql, ['attendanceid' => $id, time() - $attconfig->rotateqrcodeexpirymargin]); $qrpassflag = false; diff --git a/lang/en/attendance.php b/lang/en/attendance.php index ab0652d..3c5cfd2 100644 --- a/lang/en/attendance.php +++ b/lang/en/attendance.php @@ -245,8 +245,10 @@ $string['includeall'] = 'Select all sessions'; $string['includenottaken'] = 'Include not taken sessions'; $string['includeqrcode'] = 'Include QR code'; $string['rotateqrcode'] = 'Rotate QR code'; -$string['rotateqrcodeinterval'] = 'Rotate QR code interval (seconds)'; -$string['rotateqrcodeinterval_desc'] = 'Time interval (seconds) to rotate QR codes by.'; +$string['rotateqrcodeinterval'] = 'Rotate QR code/password interval (seconds)'; +$string['rotateqrcodeinterval_desc'] = 'Time interval (seconds) to rotate QR code/password by.'; +$string['rotateqrcodeexpirymargin'] = 'Rotate QR code/password expiry margin (seconds)'; +$string['rotateqrcodeexpirymargin_desc'] = 'Time interval (seconds) to allow expired QR code/password by.'; $string['rotateqrcode_cleartemppass_task'] = 'Task to clear temporary passwords generated by rotate QR code functionality.'; $string['includeremarks'] = 'Include remarks'; $string['incorrectpassword'] = 'You have entered an incorrect password and your attendance has not been recorded, please enter the correct password.'; diff --git a/settings.php b/settings.php index e498d0c..88ce361 100644 --- a/settings.php +++ b/settings.php @@ -56,6 +56,10 @@ if ($ADMIN->fulltree) { get_string('rotateqrcodeinterval', 'attendance'), get_string('rotateqrcodeinterval_desc', 'attendance'), '15', PARAM_INT)); + $settings->add(new admin_setting_configtext('attendance/rotateqrcodeexpirymargin', + get_string('rotateqrcodeexpirymargin', 'attendance'), + get_string('rotateqrcodeexpirymargin_desc', 'attendance'), '2', PARAM_INT)); + $settings->add(new admin_setting_configcheckbox('attendance/studentscanmarksessiontime', get_string('studentscanmarksessiontime', 'attendance'), get_string('studentscanmarksessiontime_desc', 'attendance'), 1));