diff --git a/add_form.php b/add_form.php index cf27bf3..0419e97 100644 --- a/add_form.php +++ b/add_form.php @@ -247,7 +247,7 @@ class mod_attendance_add_form extends moodleform { if (isset($pluginconfig->includeqrcode_default)) { $mform->setDefault('includeqrcode', $pluginconfig->includeqrcode_default); } - // TODO - Change in DB and provide value + // TODO - Change in DB and provide value. if (isset($pluginconfig->includeqrcode_default)) { $mform->setDefault('rotateqrcode', $pluginconfig->includeqrcode_default); } diff --git a/attendance.php b/attendance.php index 068b6f4..153e971 100644 --- a/attendance.php +++ b/attendance.php @@ -44,15 +44,15 @@ if ($attforsession->rotateqrcode == 1) { $secrethash = md5($USER->id.$attforsession->rotateqrcodesecret); $url = new moodle_url('/mod/attendance/view.php', array('id' => $cm->id)); - // Check if cookie is set and verify + // Check if cookie is set and verify. if (isset($_COOKIE[$cookiename])) { - // Check the token + // Check the token. if ($secrethash !== $_COOKIE[$cookiename]) { - // Flag error + // Flag error. print_error('qr_cookie_error', 'mod_attendance', $url); } } else { - // Check password + // 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() - $attconfig->rotateqrcodeexpirymargin]); @@ -66,10 +66,10 @@ if ($attforsession->rotateqrcode == 1) { } if ($qrpassflag) { - // Create and store the token + // Create and store the token. setcookie($cookiename, $secrethash, time() + (60 * 5), "/"); } else { - // Flag error + // Flag error. print_error('qr_pass_wrong', 'mod_attendance', $url); } } diff --git a/classes/event/session_report_viewed.php b/classes/event/session_report_viewed.php index 36e26a2..ba3cf0a 100644 --- a/classes/event/session_report_viewed.php +++ b/classes/event/session_report_viewed.php @@ -46,7 +46,7 @@ class session_report_viewed extends \core\event\base { protected function init() { $this->data['crud'] = 'r'; $this->data['edulevel'] = self::LEVEL_TEACHING; - // objecttable and objectid can't be meaningfully specified + // Objecttable and objectid can't be meaningfully specified. } /** @@ -121,7 +121,7 @@ class session_report_viewed extends \core\event\base { if (!isset($this->relateduserid)) { throw new \coding_exception('The event mod_attendance\\event\\session_report_viewed must specify relateduserid.'); } - // view params can be left out as defaults will be the same when log event is viewed as when + // View params can be left out as defaults will be the same when log event is viewed as when // it was stored. // filter params are important, but stored in session so default effectively unknown, // hence required here. diff --git a/externallib.php b/externallib.php index ac734fb..56a5303 100644 --- a/externallib.php +++ b/externallib.php @@ -45,7 +45,8 @@ class mod_attendance_external extends external_api { 'courseid' => new external_value(PARAM_INT, 'course id'), 'name' => new external_value(PARAM_TEXT, 'attendance name'), 'intro' => new external_value(PARAM_RAW, 'attendance description', VALUE_DEFAULT, ''), - 'groupmode' => new external_value(PARAM_INT, 'group mode (0 - no groups, 1 - separate groups, 2 - visible groups)', VALUE_DEFAULT, 0), + 'groupmode' => new external_value(PARAM_INT, + 'group mode (0 - no groups, 1 - separate groups, 2 - visible groups)', VALUE_DEFAULT, 0), ) ); } @@ -188,7 +189,8 @@ class mod_attendance_external extends external_api { * @param bool $addcalendarevent * @return array */ - public static function add_session(int $attendanceid, $description, int $sessiontime, int $duration, int $groupid, bool $addcalendarevent) { + public static function add_session(int $attendanceid, $description, int $sessiontime, int $duration, int $groupid, + bool $addcalendarevent) { global $USER, $DB; $params = self::validate_parameters(self::add_session_parameters(), array( @@ -218,7 +220,7 @@ class mod_attendance_external extends external_api { throw new invalid_parameter_exception('Group id is not specified (or 0) in separate groups mode.'); } if ($groupmode === SEPARATEGROUPS || ($groupmode === VISIBLEGROUPS && $groupid > 0)) { - // Determine valid groups + // Determine valid groups. $userid = has_capability('moodle/site:accessallgroups', $context) ? 0 : $USER->id; $validgroupids = array_map(function($group) { return $group->id; diff --git a/locallib.php b/locallib.php index 01bd79e..c8251be 100644 --- a/locallib.php +++ b/locallib.php @@ -1104,7 +1104,8 @@ function attendance_renderqrcode($session) { global $CFG; if (strlen($session->studentpassword) > 0) { - $qrcodeurl = $CFG->wwwroot . '/mod/attendance/attendance.php?qrpass=' . $session->studentpassword . '&sessid=' . $session->id; + $qrcodeurl = $CFG->wwwroot . '/mod/attendance/attendance.php?qrpass=' . + $session->studentpassword . '&sessid=' . $session->id; } else { $qrcodeurl = $CFG->wwwroot . '/mod/attendance/attendance.php?sessid=' . $session->id; } @@ -1127,7 +1128,8 @@ function attendance_generate_passwords($session) { $password = array(); for ($i = 0; $i < 30; $i++) { - array_push($password, array("attendanceid" => $session->id, "password" => mt_rand(1000, 10000), "expirytime" => time() + ($attconfig->rotateqrcodeinterval * $i))); + array_push($password, array("attendanceid" => $session->id, + "password" => mt_rand(1000, 10000), "expirytime" => time() + ($attconfig->rotateqrcodeinterval * $i))); } $DB->insert_records('attendance_rotate_passwords', $password); @@ -1139,7 +1141,7 @@ function attendance_generate_passwords($session) { * @param stdClass $session */ function attendance_renderqrcoderotate($session) { - // load requered js + // Load required js. echo html_writer::tag('script', '', [ 'src' => 'js/qrcode/qrcode.min.js', @@ -1152,12 +1154,12 @@ function attendance_renderqrcoderotate($session) { 'type' => 'text/javascript' ] ); - echo html_writer::tag('div', '', ['id' => 'rotate-time']); // div to display timer + echo html_writer::tag('div', '', ['id' => 'rotate-time']); // Div to display timer. echo html_writer::tag('h3', get_string('passwordgrp', 'attendance')); - echo html_writer::tag('div', '', ['id' => 'text-password']); // div to display password + echo html_writer::tag('div', '', ['id' => 'text-password']); // Div to display password. echo html_writer::tag('h3', get_string('qrcode', 'attendance')); - echo html_writer::tag('div', '', ['id' => 'qrcode']); // div to display qr code - // js to start the password manager + echo html_writer::tag('div', '', ['id' => 'qrcode']); // Div to display qr code. + // Js to start the password manager. echo '