From 7fa4961b327464448035d00466a2140ae2519c1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20B=C3=B6sch?= Date: Mon, 8 Jul 2024 08:38:59 +0200 Subject: [PATCH] Short array syntax. --- absentee.php | 36 +- attendance.php | 36 +- automark.php | 6 +- backup/moodle2/backup_attendance_stepslib.php | 30 +- ...restore_attendance_activity_task.class.php | 16 +- .../moodle2/restore_attendance_stepslib.php | 2 +- classes/analytics/indicator/activity_base.php | 2 +- classes/attendance_webservices_handler.php | 24 +- classes/calendar_helpers.php | 6 +- classes/customfield/session_handler.php | 4 +- classes/event/attendance_taken.php | 6 +- classes/event/attendance_taken_by_student.php | 6 +- .../course_module_instance_list_viewed.php | 6 +- classes/event/report_viewed.php | 4 +- classes/event/session_added.php | 4 +- classes/event/session_deleted.php | 4 +- classes/event/session_duration_updated.php | 4 +- classes/event/session_ip_shared.php | 6 +- classes/event/session_report_viewed.php | 8 +- classes/event/session_updated.php | 6 +- classes/event/sessions_imported.php | 6 +- classes/event/status_added.php | 4 +- classes/event/status_removed.php | 4 +- classes/event/status_updated.php | 4 +- classes/form/addsession.php | 42 +- classes/form/addwarning.php | 10 +- classes/form/duration.php | 4 +- classes/form/export.php | 26 +- classes/form/import/marksessions.php | 6 +- classes/form/import/marksessions_confirm.php | 6 +- classes/form/studentattendance.php | 10 +- classes/form/tempmerge.php | 2 +- classes/form/tempuseredit.php | 6 +- classes/form/updatesession.php | 30 +- classes/import/marksessions.php | 24 +- classes/import/sessions.php | 46 +- classes/local/automark.php | 12 +- classes/local/url_helpers.php | 8 +- classes/manage_page_params.php | 2 +- classes/notifyqueue.php | 2 +- classes/observer.php | 2 +- classes/output/filter_controls.php | 4 +- classes/output/mobile.php | 68 +-- classes/output/password_icon.php | 2 +- classes/output/preferences_data.php | 2 +- classes/output/renderer.php | 476 +++++++++--------- classes/output/report_data.php | 10 +- classes/output/set_selector.php | 2 +- classes/output/take_data.php | 6 +- classes/output/user_data.php | 36 +- classes/page_with_filter_controls.php | 4 +- classes/preferences_page_params.php | 2 +- classes/privacy/provider.php | 18 +- classes/report_page_params.php | 2 +- .../reportbuilder/datasource/attendance.php | 2 +- classes/structure.php | 174 +++---- classes/summary.php | 24 +- classes/take_page_params.php | 2 +- classes/task/auto_mark.php | 10 +- classes/task/clear_temporary_passwords.php | 2 +- classes/task/notify.php | 18 +- classes/view_page_params.php | 2 +- coursesummary.php | 20 +- db/access.php | 148 +++--- db/events.php | 8 +- db/install.php | 4 +- db/mobile.php | 10 +- db/services.php | 52 +- db/tasks.php | 16 +- db/upgrade.php | 34 +- db/upgradelib.php | 4 +- defaultstatus.php | 4 +- export.php | 16 +- externallib.php | 134 ++--- import.php | 6 +- import/marksessions.php | 14 +- index.php | 20 +- lib.php | 72 +-- locallib.php | 122 ++--- manage.php | 14 +- messageselect.php | 22 +- mod_form.php | 4 +- password.php | 4 +- password_ajax.php | 4 +- preferences.php | 8 +- renderhelpers.php | 2 +- report.php | 10 +- resetcalendar.php | 12 +- sessions.php | 26 +- settings.php | 18 +- take.php | 10 +- tempedit.php | 20 +- tempmerge.php | 28 +- tempusers.php | 12 +- tests/behat/behat_mod_attendance.php | 2 +- tests/external/external_test.php | 32 +- view.php | 26 +- warnings.php | 40 +- 98 files changed, 1158 insertions(+), 1158 deletions(-) diff --git a/absentee.php b/absentee.php index 8c632abde9f..205a8a45405 100644 --- a/absentee.php +++ b/absentee.php @@ -36,27 +36,27 @@ if (!empty($category)) { $context = context_coursecat::instance($category); $coursecat = core_course_category::get($category); - $courses = $coursecat->get_courses(array('recursive' => true, 'idonly' => true)); + $courses = $coursecat->get_courses(['recursive' => true, 'idonly' => true]); $PAGE->set_category_by_id($category); require_login(); } else if (!empty($attendancecm)) { $cm = get_coursemodule_from_id('attendance', $attendancecm, 0, false, MUST_EXIST); - $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); - $att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); - $courses = array($course->id); + $course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); + $att = $DB->get_record('attendance', ['id' => $cm->instance], '*', MUST_EXIST); + $courses = [$course->id]; $context = context_module::instance($cm->id); require_login($course, false, $cm); } else { admin_externalpage_setup('managemodules'); $context = context_system::instance(); - $courses = array(); // Show all courses. + $courses = []; // Show all courses. } // Check permissions. require_capability('mod/attendance:viewreports', $context); $exportfilename = 'attendance-absentee.csv'; -$PAGE->set_url('/mod/attendance/absentee.php', array('category' => $category, 'id' => $attendancecm)); +$PAGE->set_url('/mod/attendance/absentee.php', ['category' => $category, 'id' => $attendancecm]); $PAGE->set_heading($SITE->fullname); @@ -80,12 +80,12 @@ } } -$columns = array('coursename', 'aname', 'userid'); -$headers = array(get_string('course'), +$columns = ['coursename', 'aname', 'userid']; +$headers = [get_string('course'), get_string('pluginname', 'attendance'), - get_string('user')); + get_string('user'), ]; -$extrafields = array(); +$extrafields = []; if (!empty($CFG->showuseridentity) && has_capability('moodle/site:viewuseridentity', $context)) { $extrafields = explode(',', $CFG->showuseridentity); foreach ($extrafields as $field) { @@ -93,11 +93,11 @@ $headers[] = get_string($field); } } -$columns = array_merge($columns, array('numtakensessions', 'percent', 'timesent')); -$headers = array_merge($headers, array( +$columns = array_merge($columns, ['numtakensessions', 'percent', 'timesent']); +$headers = array_merge($headers, [ get_string('takensessions', 'attendance'), get_string('averageattendance', 'attendance'), - get_string('triggered', 'attendance'))); + get_string('triggered', 'attendance')]); $table->define_columns($columns); $table->define_headers($headers); @@ -105,7 +105,7 @@ $table->sortable(true); $table->set_attribute('cellspacing', '0'); $table->set_attribute('class', 'generaltable generalbox'); -$table->show_download_buttons_at(array(TABLE_P_BOTTOM)); +$table->show_download_buttons_at([TABLE_P_BOTTOM]); $table->setup(); // Work out direction of sort required. @@ -130,13 +130,13 @@ $records = attendance_get_users_to_notify($courses, $orderby); foreach ($records as $record) { - $row = array(); + $row = []; if (!$table->is_downloading($download, $exportfilename)) { - $url = new moodle_url('/mod/attendance/index.php', array('id' => $record->courseid)); + $url = new moodle_url('/mod/attendance/index.php', ['id' => $record->courseid]); $row[] = html_writer::link($url, $record->coursename); - $url = new moodle_url('/mod/attendance/view.php', array('studentid' => $record->userid, - 'id' => $record->cmid, 'view' => ATT_VIEW_ALL)); + $url = new moodle_url('/mod/attendance/view.php', ['studentid' => $record->userid, + 'id' => $record->cmid, 'view' => ATT_VIEW_ALL]); $row[] = html_writer::link($url, $record->aname); $row[] = html_writer::link($url, fullname($record)); diff --git a/attendance.php b/attendance.php index 4666678f620..c1b4c1cc255 100644 --- a/attendance.php +++ b/attendance.php @@ -32,11 +32,11 @@ $id = required_param('sessid', PARAM_INT); $qrpass = optional_param('qrpass', '', PARAM_TEXT); -$attforsession = $DB->get_record('attendance_sessions', array('id' => $id), '*', MUST_EXIST); +$attforsession = $DB->get_record('attendance_sessions', ['id' => $id], '*', MUST_EXIST); $attconfig = get_config('attendance'); -$attendance = $DB->get_record('attendance', array('id' => $attforsession->attendanceid), '*', MUST_EXIST); +$attendance = $DB->get_record('attendance', ['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); +$course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); // Require the user is logged in. require_login($course, true, $cm); @@ -58,7 +58,7 @@ if ($canmark && attendance_session_open_for_students($attforsession) && $attforsession->rotateqrcode == 1) { $cookiename = 'attendance_'.$attforsession->id; $secrethash = md5($USER->id.$attforsession->rotateqrcodesecret); - $url = new moodle_url('/mod/attendance/view.php', array('id' => $cm->id)); + $url = new moodle_url('/mod/attendance/view.php', ['id' => $cm->id]); // Check if cookie is set and verify. if (isset($_COOKIE[$cookiename])) { @@ -103,13 +103,13 @@ if (!$canmark) { - redirect(new moodle_url('/mod/attendance/view.php', array('id' => $cm->id)), get_string($reason, 'attendance')); + redirect(new moodle_url('/mod/attendance/view.php', ['id' => $cm->id]), get_string($reason, 'attendance')); exit; } // Check if subnet is set and if the user is in the allowed range. if (!empty($attforsession->subnet) && !address_in_subnet(getremoteaddr(), $attforsession->subnet)) { - $url = new moodle_url('/mod/attendance/view.php', array('id' => $cm->id)); + $url = new moodle_url('/mod/attendance/view.php', ['id' => $cm->id]); notice(get_string('subnetwrong', 'attendance'), $url); exit; // Notice calls this anyway. } @@ -124,7 +124,7 @@ // Check to see if autoassignstatus is in use and no password required or Qrpass given and passed. if ($attforsession->autoassignstatus && attendance_session_open_for_students($attforsession) && (empty($attforsession->studentpassword)) || $qrpassflag) { $statusid = attendance_session_get_highest_status($att, $attforsession); - $url = new moodle_url('/mod/attendance/view.php', array('id' => $cm->id)); + $url = new moodle_url('/mod/attendance/view.php', ['id' => $cm->id]); if (empty($statusid)) { throw new moodle_exception('attendance_no_status', 'mod_attendance', $url); } @@ -148,7 +148,7 @@ if (!empty($attforsession->studentpassword) && $attforsession->studentpassword !== $qrpass) { - $url = new moodle_url('/mod/attendance/attendance.php', array('sessid' => $id, 'sesskey' => sesskey())); + $url = new moodle_url('/mod/attendance/attendance.php', ['sessid' => $id, 'sesskey' => sesskey()]); redirect($url, get_string('incorrectpassword', 'mod_attendance'), null, \core\output\notification::NOTIFY_ERROR); } @@ -158,14 +158,14 @@ $fromform->status = attendance_session_get_highest_status($att, $attforsession); if (empty($fromform->status)) { - $url = new moodle_url('/mod/attendance/view.php', array('id' => $cm->id)); + $url = new moodle_url('/mod/attendance/view.php', ['id' => $cm->id]); throw new moodle_exception('attendance_no_status', 'mod_attendance', $url); } if (!empty($fromform->status)) { $success = $att->take_from_student($fromform); - $url = new moodle_url('/mod/attendance/view.php', array('id' => $cm->id)); + $url = new moodle_url('/mod/attendance/view.php', ['id' => $cm->id]); if ($success) { // Redirect back to the view page. redirect($url, get_string('studentmarked', 'attendance')); @@ -180,17 +180,17 @@ // Create the form. if ($attforsession->rotateqrcode == 1) { $mform = new mod_attendance\form\studentattendance(null, - array('course' => $course, 'cm' => $cm, 'modcontext' => $PAGE->context, 'session' => $attforsession, - 'attendance' => $att, 'password' => $attforsession->studentpassword)); + ['course' => $course, 'cm' => $cm, 'modcontext' => $PAGE->context, 'session' => $attforsession, + 'attendance' => $att, 'password' => $attforsession->studentpassword]); } else { $mform = new mod_attendance\form\studentattendance(null, - array('course' => $course, 'cm' => $cm, 'modcontext' => $PAGE->context, 'session' => $attforsession, - 'attendance' => $att, 'password' => $qrpass)); + ['course' => $course, 'cm' => $cm, 'modcontext' => $PAGE->context, 'session' => $attforsession, + 'attendance' => $att, 'password' => $qrpass]); } if ($mform->is_cancelled()) { // The user cancelled the form, so redirect them to the view page. - $url = new moodle_url('/mod/attendance/view.php', array('id' => $cm->id)); + $url = new moodle_url('/mod/attendance/view.php', ['id' => $cm->id]); redirect($url); } else if ($fromform = $mform->get_data()) { // Check if password required and if set correctly. @@ -200,13 +200,13 @@ // Check if password being passed is valid. && $attforsession->studentpassword !== $fromform->studentpassword) { - $url = new moodle_url('/mod/attendance/attendance.php', array('sessid' => $id, 'sesskey' => sesskey())); + $url = new moodle_url('/mod/attendance/attendance.php', ['sessid' => $id, 'sesskey' => sesskey()]); redirect($url, get_string('incorrectpassword', 'mod_attendance'), null, \core\output\notification::NOTIFY_ERROR); } if (attendance_session_open_for_students($attforsession) && $attforsession->autoassignstatus) { $fromform->status = attendance_session_get_highest_status($att, $attforsession); if (empty($fromform->status)) { - $url = new moodle_url('/mod/attendance/view.php', array('id' => $cm->id)); + $url = new moodle_url('/mod/attendance/view.php', ['id' => $cm->id]); throw new moodle_exception('attendance_no_status', 'mod_attendance', $url); } } @@ -218,7 +218,7 @@ } $success = $att->take_from_student($fromform); - $url = new moodle_url('/mod/attendance/view.php', array('id' => $cm->id)); + $url = new moodle_url('/mod/attendance/view.php', ['id' => $cm->id]); if ($success) { // Redirect back to the view page. redirect($url, get_string('studentmarked', 'attendance')); diff --git a/automark.php b/automark.php index c24e90e0787..6db4c809e49 100644 --- a/automark.php +++ b/automark.php @@ -30,9 +30,9 @@ $grouptype = required_param('grouptype', PARAM_INT); $cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); -$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); -$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); -$session = $DB->get_record('attendance_sessions', array('id' => $sessionid, 'attendanceid' => $att->id), +$course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); +$att = $DB->get_record('attendance', ['id' => $cm->instance], '*', MUST_EXIST); +$session = $DB->get_record('attendance_sessions', ['id' => $sessionid, 'attendanceid' => $att->id], '*', MUST_EXIST); require_login($course, true, $cm); diff --git a/backup/moodle2/backup_attendance_stepslib.php b/backup/moodle2/backup_attendance_stepslib.php index c3d18b98e1c..a5b553229c7 100644 --- a/backup/moodle2/backup_attendance_stepslib.php +++ b/backup/moodle2/backup_attendance_stepslib.php @@ -41,24 +41,24 @@ protected function define_structure() { $userinfo = $this->get_setting_value('userinfo'); // XML nodes declaration - non-user data. - $attendance = new backup_nested_element('attendance', array('id'), array( - 'name', 'intro', 'introformat', 'grade', 'showextrauserdetails', 'showsessiondetails', 'sessiondetailspos', 'subnet')); + $attendance = new backup_nested_element('attendance', ['id'], [ + 'name', 'intro', 'introformat', 'grade', 'showextrauserdetails', 'showsessiondetails', 'sessiondetailspos', 'subnet']); $statuses = new backup_nested_element('statuses'); - $status = new backup_nested_element('status', array('id'), array( - 'acronym', 'description', 'grade', 'studentavailability', 'availablebeforesession', 'setunmarked', 'visible', 'deleted', 'setnumber')); + $status = new backup_nested_element('status', ['id'], [ + 'acronym', 'description', 'grade', 'studentavailability', 'availablebeforesession', 'setunmarked', 'visible', 'deleted', 'setnumber']); $warnings = new backup_nested_element('warnings'); - $warning = new backup_nested_element('warning', array('id'), array('warningpercent', 'warnafter', - 'maxwarn', 'emailuser', 'emailsubject', 'emailcontent', 'emailcontentformat', 'thirdpartyemails')); + $warning = new backup_nested_element('warning', ['id'], ['warningpercent', 'warnafter', + 'maxwarn', 'emailuser', 'emailsubject', 'emailcontent', 'emailcontentformat', 'thirdpartyemails']); $sessions = new backup_nested_element('sessions'); - $session = new backup_nested_element('session', array('id'), array( + $session = new backup_nested_element('session', ['id'], [ 'groupid', 'sessdate', 'duration', 'lasttaken', 'lasttakenby', 'timemodified', 'description', 'descriptionformat', 'studentscanmark', 'allowupdatestatus', 'studentpassword', 'autoassignstatus', 'subnet', 'automark', 'automarkcompleted', 'statusset', 'absenteereport', 'preventsharedip', 'preventsharediptime', 'caleventid', 'calendarevent', 'includeqrcode', 'automarkcmid', - 'studentsearlyopentime')); + 'studentsearlyopentime']); $customfields = new backup_nested_element('customfields'); $customfield = new backup_nested_element('customfield', ['id'], [ @@ -66,8 +66,8 @@ protected function define_structure() { // XML nodes declaration - user data. $logs = new backup_nested_element('logs'); - $log = new backup_nested_element('log', array('id'), array( - 'sessionid', 'studentid', 'statusid', 'statusset', 'timetaken', 'takenby', 'remarks')); + $log = new backup_nested_element('log', ['id'], [ + 'sessionid', 'studentid', 'statusid', 'statusset', 'timetaken', 'takenby', 'remarks']); // Build the tree in the order needed for restore. $attendance->add_child($statuses); @@ -87,14 +87,14 @@ protected function define_structure() { // Data sources - non-user data. - $attendance->set_source_table('attendance', array('id' => backup::VAR_ACTIVITYID)); + $attendance->set_source_table('attendance', ['id' => backup::VAR_ACTIVITYID]); - $status->set_source_table('attendance_statuses', array('attendanceid' => backup::VAR_PARENTID)); + $status->set_source_table('attendance_statuses', ['attendanceid' => backup::VAR_PARENTID]); $warning->set_source_table('attendance_warning', - array('idnumber' => backup::VAR_PARENTID)); + ['idnumber' => backup::VAR_PARENTID]); - $session->set_source_table('attendance_sessions', array('attendanceid' => backup::VAR_PARENTID)); + $session->set_source_table('attendance_sessions', ['attendanceid' => backup::VAR_PARENTID]); $handler = mod_attendance\customfield\session_handler::create(); $fieldsforbackup = $handler->get_instance_data_for_backup_by_activity($this->task->get_activityid()); @@ -102,7 +102,7 @@ protected function define_structure() { // Data sources - user related data. if ($userinfo) { - $log->set_source_table('attendance_log', array('sessionid' => backup::VAR_PARENTID)); + $log->set_source_table('attendance_log', ['sessionid' => backup::VAR_PARENTID]); } // Id annotations. diff --git a/backup/moodle2/restore_attendance_activity_task.class.php b/backup/moodle2/restore_attendance_activity_task.class.php index 2acd4ac7d55..ead5bc9459c 100644 --- a/backup/moodle2/restore_attendance_activity_task.class.php +++ b/backup/moodle2/restore_attendance_activity_task.class.php @@ -52,11 +52,11 @@ protected function define_my_steps() { * processed by the link decoder */ public static function define_decode_contents() { - $contents = array(); + $contents = []; - $contents[] = new restore_decode_content('attendance', array('intro'), 'attendance'); + $contents[] = new restore_decode_content('attendance', ['intro'], 'attendance'); $contents[] = new restore_decode_content('attendance_sessions', - array('description'), 'attendance_session'); + ['description'], 'attendance_session'); return $contents; } @@ -66,18 +66,18 @@ public static function define_decode_contents() { * to the activity to be executed by the link decoder */ public static function define_decode_rules() { - $rules = array(); + $rules = []; $rules[] = new restore_decode_rule('ATTENDANCEVIEWBYID', '/mod/attendance/view.php?id=$1', 'course_module'); $rules[] = new restore_decode_rule('ATTENDANCEVIEWBYIDSTUD', - '/mod/attendance/view.php?id=$1&studentid=$2', array('course_module', 'user')); + '/mod/attendance/view.php?id=$1&studentid=$2', ['course_module', 'user']); // Older style backups using previous plugin name. $rules[] = new restore_decode_rule('ATTFORBLOCKVIEWBYID', '/mod/attendance/view.php?id=$1', 'course_module'); $rules[] = new restore_decode_rule('ATTFORBLOCKVIEWBYIDSTUD', - '/mod/attendance/view.php?id=$1&studentid=$2', array('course_module', 'user')); + '/mod/attendance/view.php?id=$1&studentid=$2', ['course_module', 'user']); return $rules; @@ -90,7 +90,7 @@ public static function define_decode_rules() { * of {@see restore_log_rule} objects */ public static function define_restore_log_rules() { - $rules = array(); + $rules = []; // TODO: log restore. return $rules; @@ -107,7 +107,7 @@ public static function define_restore_log_rules() { * activity level. All them are rules not linked to any module instance (cmid = 0) */ public static function define_restore_log_rules_for_course() { - $rules = array(); + $rules = []; return $rules; } diff --git a/backup/moodle2/restore_attendance_stepslib.php b/backup/moodle2/restore_attendance_stepslib.php index 6711a1edda3..1bb26250493 100644 --- a/backup/moodle2/restore_attendance_stepslib.php +++ b/backup/moodle2/restore_attendance_stepslib.php @@ -37,7 +37,7 @@ class restore_attendance_activity_structure_step extends restore_activity_struct */ protected function define_structure() { - $paths = array(); + $paths = []; $userinfo = $this->get_setting_value('userinfo'); // Are we including userinfo? diff --git a/classes/analytics/indicator/activity_base.php b/classes/analytics/indicator/activity_base.php index 53209c9cfa3..8cbcf38907f 100644 --- a/classes/analytics/indicator/activity_base.php +++ b/classes/analytics/indicator/activity_base.php @@ -41,6 +41,6 @@ abstract class activity_base extends \core_analytics\local\indicator\community_o * @return string[] */ protected function feedback_viewed_events() { - return array('\mod_attendance\event\session_report_viewed'); + return ['\mod_attendance\event\session_report_viewed']; } } diff --git a/classes/attendance_webservices_handler.php b/classes/attendance_webservices_handler.php index 934ca2823b1..20b0335966f 100644 --- a/classes/attendance_webservices_handler.php +++ b/classes/attendance_webservices_handler.php @@ -45,14 +45,14 @@ public static function get_courses_with_today_sessions($userid) { $usercourses = enrol_get_users_courses($userid); $attendanceinstance = get_all_instances_in_courses('attendance', $usercourses); - $coursessessions = array(); + $coursessessions = []; foreach ($attendanceinstance as $attendance) { $context = context_course::instance($attendance->course); if (has_capability('mod/attendance:takeattendances', $context, $userid)) { $course = $usercourses[$attendance->course]; if (!isset($course->attendance_instance)) { - $course->attendance_instance = array(); + $course->attendance_instance = []; } $att = new stdClass(); @@ -68,7 +68,7 @@ public static function get_courses_with_today_sessions($userid) { $todaysessions = $att->get_today_sessions(); if (!empty($todaysessions)) { - $course->attendance_instance[$att->id] = array(); + $course->attendance_instance[$att->id] = []; $course->attendance_instance[$att->id]['name'] = $att->name; $course->attendance_instance[$att->id]['today_sessions'] = $todaysessions; $coursessessions[$course->id] = $course; @@ -86,7 +86,7 @@ public static function get_courses_with_today_sessions($userid) { * @return array */ private static function prepare_data($coursessessions) { - $courses = array(); + $courses = []; foreach ($coursessessions as $c) { $courses[$c->id] = new stdClass(); @@ -107,15 +107,15 @@ private static function prepare_data($coursessessions) { public static function get_session($sessionid) { global $DB; - $session = $DB->get_record('attendance_sessions', array('id' => $sessionid)); - $session->courseid = $DB->get_field('attendance', 'course', array('id' => $session->attendanceid)); + $session = $DB->get_record('attendance_sessions', ['id' => $sessionid]); + $session->courseid = $DB->get_field('attendance', 'course', ['id' => $session->attendanceid]); $session->statuses = attendance_get_statuses($session->attendanceid, true, $session->statusset); $coursecontext = context_course::instance($session->courseid); $session->users = get_enrolled_users($coursecontext, 'mod/attendance:canbelisted', $session->groupid, 'u.id, u.firstname, u.lastname'); - $session->attendance_log = array(); + $session->attendance_log = []; - if ($attendancelog = $DB->get_records('attendance_log', array('sessionid' => $sessionid), + if ($attendancelog = $DB->get_records('attendance_log', ['sessionid' => $sessionid], '', 'studentid, statusid, remarks, id')) { $session->attendance_log = $attendancelog; } @@ -143,14 +143,14 @@ public static function update_user_status($sessionid, $studentid, $takenbyid, $s $record->statusid = $statusid; $record->studentid = $studentid; - if ($attendancelog = $DB->get_record('attendance_log', array('sessionid' => $sessionid, 'studentid' => $studentid))) { + if ($attendancelog = $DB->get_record('attendance_log', ['sessionid' => $sessionid, 'studentid' => $studentid])) { $record->id = $attendancelog->id; $DB->update_record('attendance_log', $record); } else { $DB->insert_record('attendance_log', $record); } - if ($attendancesession = $DB->get_record('attendance_sessions', array('id' => $sessionid))) { + if ($attendancesession = $DB->get_record('attendance_sessions', ['id' => $sessionid])) { $attendancesession->lasttaken = time(); $attendancesession->lasttakenby = $takenbyid; $attendancesession->timemodified = time(); @@ -168,9 +168,9 @@ public static function update_user_status($sessionid, $studentid, $takenbyid, $s public static function get_sessions($attendanceid) { global $DB; - $sessions = $DB->get_records('attendance_sessions', array('attendanceid' => $attendanceid), 'id ASC'); + $sessions = $DB->get_records('attendance_sessions', ['attendanceid' => $attendanceid], 'id ASC'); - $sessionsinfo = array(); + $sessionsinfo = []; foreach ($sessions as $session) { $sessionsinfo[$session->id] = self::get_session($session->id); diff --git a/classes/calendar_helpers.php b/classes/calendar_helpers.php index 9191e26a37e..07384c552de 100644 --- a/classes/calendar_helpers.php +++ b/classes/calendar_helpers.php @@ -43,7 +43,7 @@ function attendance_create_calendar_event(&$session) { return true; } - $attendance = $DB->get_record('attendance', array('id' => $session->attendanceid)); + $attendance = $DB->get_record('attendance', ['id' => $session->attendanceid]); $caleventdata = new stdClass(); $caleventdata->name = $attendance->name; @@ -65,7 +65,7 @@ function attendance_create_calendar_event(&$session) { $calevent = new stdClass(); if ($calevent = calendar_event::create($caleventdata, false)) { $session->caleventid = $calevent->id; - $DB->set_field('attendance_sessions', 'caleventid', $session->caleventid, array('id' => $session->id)); + $DB->set_field('attendance_sessions', 'caleventid', $session->caleventid, ['id' => $session->id]); return true; } else { return false; @@ -117,7 +117,7 @@ function attendance_update_calendar_event($session) { if ($session->calendarevent == 0) { if ($session->caleventid != 0) { // There is an existing event we should delete, calendarevent just got turned off. - $DB->delete_records_list('event', 'id', array($caleventid)); + $DB->delete_records_list('event', 'id', [$caleventid]); $session->caleventid = 0; $DB->update_record('attendance_sessions', $session); return true; diff --git a/classes/customfield/session_handler.php b/classes/customfield/session_handler.php index c45eee76b3f..26ce5b53f82 100644 --- a/classes/customfield/session_handler.php +++ b/classes/customfield/session_handler.php @@ -168,7 +168,7 @@ public function config_form_definition(\MoodleQuickForm $mform) { // Field data visibility. $visibilityoptions = [self::VISIBLETOALL => get_string('customfield_visibletoall', 'core_course'), self::VISIBLETOTEACHERS => get_string('customfield_visibletoteachers', 'core_course'), - self::NOTVISIBLE => get_string('customfield_notvisible', 'core_course')]; + self::NOTVISIBLE => get_string('customfield_notvisible', 'core_course'), ]; $mform->addElement('select', 'configdata[visibility]', get_string('customfield_visibility', 'core_course'), $visibilityoptions); $mform->addHelpButton('configdata[visibility]', 'customfield_visibility', 'core_course'); @@ -244,7 +244,7 @@ public function get_instance_data_for_backup_by_activity(int $activityid) : arra 'shortname' => $d->get_field()->get('shortname'), 'type' => $d->get_field()->get('type'), 'value' => $d->get_value(), - 'valueformat' => $d->get('valueformat')]; + 'valueformat' => $d->get('valueformat'), ]; } } } diff --git a/classes/event/attendance_taken.php b/classes/event/attendance_taken.php index b4f2b71e97f..ee51470ec14 100644 --- a/classes/event/attendance_taken.php +++ b/classes/event/attendance_taken.php @@ -73,9 +73,9 @@ public static function get_name() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/mod/attendance/take.php', array('id' => $this->contextinstanceid, + return new \moodle_url('/mod/attendance/take.php', ['id' => $this->contextinstanceid, 'sessionid' => $this->other['sessionid'], - 'grouptype' => $this->other['grouptype'])); + 'grouptype' => $this->other['grouptype']]); } /** @@ -84,7 +84,7 @@ public function get_url() { * @return array of parameters for object mapping. */ public static function get_objectid_mapping() { - return array('db' => 'attendance', 'restore' => 'attendance'); + return ['db' => 'attendance', 'restore' => 'attendance']; } /** diff --git a/classes/event/attendance_taken_by_student.php b/classes/event/attendance_taken_by_student.php index 9fe4b5581b0..4ca081f5caa 100644 --- a/classes/event/attendance_taken_by_student.php +++ b/classes/event/attendance_taken_by_student.php @@ -73,9 +73,9 @@ public static function get_name() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/take.php', array('id' => $this->contextinstanceid, + return new \moodle_url('/take.php', ['id' => $this->contextinstanceid, 'sessionid' => $this->other['sessionid'], - 'grouptype' => $this->other['grouptype'])); + 'grouptype' => $this->other['grouptype']]); } /** @@ -84,7 +84,7 @@ public function get_url() { * @return array of parameters for object mapping. */ public static function get_objectid_mapping() { - return array('db' => 'attendance', 'restore' => 'attendance'); + return ['db' => 'attendance', 'restore' => 'attendance']; } /** diff --git a/classes/event/course_module_instance_list_viewed.php b/classes/event/course_module_instance_list_viewed.php index a50ee2094b5..a6ea0789643 100644 --- a/classes/event/course_module_instance_list_viewed.php +++ b/classes/event/course_module_instance_list_viewed.php @@ -39,9 +39,9 @@ class course_module_instance_list_viewed extends \core\event\course_module_insta * @return course_module_instance_list_viewed */ public static function create_from_course(\stdClass $course) { - $params = array( - 'context' => \context_course::instance($course->id) - ); + $params = [ + 'context' => \context_course::instance($course->id), + ]; $event = self::create($params); $event->add_record_snapshot('course', $course); return $event; diff --git a/classes/event/report_viewed.php b/classes/event/report_viewed.php index 36611f25bb4..63752f13bdf 100644 --- a/classes/event/report_viewed.php +++ b/classes/event/report_viewed.php @@ -73,7 +73,7 @@ public static function get_name() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/mod/attendance/report.php', array('id' => $this->contextinstanceid)); + return new \moodle_url('/mod/attendance/report.php', ['id' => $this->contextinstanceid]); } /** @@ -82,7 +82,7 @@ public function get_url() { * @return array of parameters for object mapping. */ public static function get_objectid_mapping() { - return array('db' => 'attendance', 'restore' => 'attendance'); + return ['db' => 'attendance', 'restore' => 'attendance']; } } diff --git a/classes/event/session_added.php b/classes/event/session_added.php index c0178f3652b..07a3e0e3dda 100644 --- a/classes/event/session_added.php +++ b/classes/event/session_added.php @@ -73,7 +73,7 @@ public static function get_name() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/mod/attendance/manage.php', array('id' => $this->contextinstanceid)); + return new \moodle_url('/mod/attendance/manage.php', ['id' => $this->contextinstanceid]); } /** @@ -82,7 +82,7 @@ public function get_url() { * @return array of parameters for object mapping. */ public static function get_objectid_mapping() { - return array('db' => 'attendance', 'restore' => 'attendance'); + return ['db' => 'attendance', 'restore' => 'attendance']; } /** diff --git a/classes/event/session_deleted.php b/classes/event/session_deleted.php index 81df19d4d32..dede57a26ef 100644 --- a/classes/event/session_deleted.php +++ b/classes/event/session_deleted.php @@ -73,7 +73,7 @@ public static function get_name() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/mod/attendance/manage.php', array('id' => $this->contextinstanceid)); + return new \moodle_url('/mod/attendance/manage.php', ['id' => $this->contextinstanceid]); } /** @@ -82,7 +82,7 @@ public function get_url() { * @return array of parameters for object mapping. */ public static function get_objectid_mapping() { - return array('db' => 'attendance', 'restore' => 'attendance'); + return ['db' => 'attendance', 'restore' => 'attendance']; } /** diff --git a/classes/event/session_duration_updated.php b/classes/event/session_duration_updated.php index cf91b06cd08..59e5fd4c650 100644 --- a/classes/event/session_duration_updated.php +++ b/classes/event/session_duration_updated.php @@ -73,7 +73,7 @@ public static function get_name() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/mod/attendance/manage.php', array('id' => $this->contextinstanceid)); + return new \moodle_url('/mod/attendance/manage.php', ['id' => $this->contextinstanceid]); } /** @@ -82,7 +82,7 @@ public function get_url() { * @return array of parameters for object mapping. */ public static function get_objectid_mapping() { - return array('db' => 'attendance', 'restore' => 'attendance'); + return ['db' => 'attendance', 'restore' => 'attendance']; } /** diff --git a/classes/event/session_ip_shared.php b/classes/event/session_ip_shared.php index 56184a27bf9..6840d7f1adc 100644 --- a/classes/event/session_ip_shared.php +++ b/classes/event/session_ip_shared.php @@ -82,9 +82,9 @@ public function get_url() { * @return array of parameters for object mapping. */ public static function get_objectid_mapping() { - return array( + return [ 'db' => 'attendance', - 'restore' => 'attendance' - ); + 'restore' => 'attendance', + ]; } } diff --git a/classes/event/session_report_viewed.php b/classes/event/session_report_viewed.php index a41365bd23d..f1ed905e1bf 100644 --- a/classes/event/session_report_viewed.php +++ b/classes/event/session_report_viewed.php @@ -77,13 +77,13 @@ public function get_url() { $mode = empty($this->other['mode']) ? "" : $this->other['mode']; $groupby = empty($this->other['groupby']) ? "" : $this->other['groupby']; $sesscourses = empty($this->other['sesscourses']) ? "" : $this->other['sesscourses']; - return new \moodle_url('/mod/attendance/view.php', array('id' => $this->contextinstanceid, + return new \moodle_url('/mod/attendance/view.php', ['id' => $this->contextinstanceid, 'studentid' => $this->relateduserid, 'mode' => $mode, 'view' => $this->other['view'], 'groupby' => $groupby, 'sesscourses' => $sesscourses, - 'curdate' => $this->other['curdate'])); + 'curdate' => $this->other['curdate']]); } /** @@ -92,7 +92,7 @@ public function get_url() { * @return array of parameters for object mapping. */ public static function get_objectid_mapping() { - return array(); + return []; } /** @@ -101,7 +101,7 @@ public static function get_objectid_mapping() { * @return array of parameters for object mapping for objects referenced in 'other' property. */ public static function get_other_mapping() { - return array(); + return []; } /** diff --git a/classes/event/session_updated.php b/classes/event/session_updated.php index 33462f8c835..85c37d077d1 100644 --- a/classes/event/session_updated.php +++ b/classes/event/session_updated.php @@ -73,9 +73,9 @@ public static function get_name() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/mod/attendance/sessions.php', array('id' => $this->contextinstanceid, + return new \moodle_url('/mod/attendance/sessions.php', ['id' => $this->contextinstanceid, 'sessionid' => $this->other['sessionid'], - 'action' => $this->other['action'])); + 'action' => $this->other['action']]); } /** @@ -84,7 +84,7 @@ public function get_url() { * @return array of parameters for object mapping. */ public static function get_objectid_mapping() { - return array('db' => 'attendance', 'restore' => 'attendance'); + return ['db' => 'attendance', 'restore' => 'attendance']; } /** diff --git a/classes/event/sessions_imported.php b/classes/event/sessions_imported.php index ea2bf808257..305e8751056 100644 --- a/classes/event/sessions_imported.php +++ b/classes/event/sessions_imported.php @@ -82,9 +82,9 @@ public function get_url() { * @return array of parameters for object mapping. */ public static function get_objectid_mapping() { - return array( + return [ 'db' => 'attendance', - 'restore' => 'attendance' - ); + 'restore' => 'attendance', + ]; } } diff --git a/classes/event/status_added.php b/classes/event/status_added.php index e175314721e..be769edc408 100644 --- a/classes/event/status_added.php +++ b/classes/event/status_added.php @@ -73,7 +73,7 @@ public static function get_name() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/mod/attendance/preferences.php', array('id' => $this->contextinstanceid)); + return new \moodle_url('/mod/attendance/preferences.php', ['id' => $this->contextinstanceid]); } /** @@ -82,7 +82,7 @@ public function get_url() { * @return array of parameters for object mapping. */ public static function get_objectid_mapping() { - return array('db' => 'attendance', 'restore' => 'attendance'); + return ['db' => 'attendance', 'restore' => 'attendance']; } } diff --git a/classes/event/status_removed.php b/classes/event/status_removed.php index 5438e5ab115..f788438718d 100644 --- a/classes/event/status_removed.php +++ b/classes/event/status_removed.php @@ -75,7 +75,7 @@ public static function get_name() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/mod/attendance/preferences.php', array('id' => $this->contextinstanceid)); + return new \moodle_url('/mod/attendance/preferences.php', ['id' => $this->contextinstanceid]); } /** @@ -84,7 +84,7 @@ public function get_url() { * @return array of parameters for object mapping. */ public static function get_objectid_mapping() { - return array('db' => 'attendance', 'restore' => 'attendance'); + return ['db' => 'attendance', 'restore' => 'attendance']; } } diff --git a/classes/event/status_updated.php b/classes/event/status_updated.php index c3223bfe317..b8e471f2e05 100644 --- a/classes/event/status_updated.php +++ b/classes/event/status_updated.php @@ -73,7 +73,7 @@ public static function get_name() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/mod/attendance/preferences.php', array('id' => $this->contextinstanceid)); + return new \moodle_url('/mod/attendance/preferences.php', ['id' => $this->contextinstanceid]); } /** @@ -82,7 +82,7 @@ public function get_url() { * @return array of parameters for object mapping. */ public static function get_objectid_mapping() { - return array('db' => 'attendance', 'restore' => 'attendance'); + return ['db' => 'attendance', 'restore' => 'attendance']; } } diff --git a/classes/form/addsession.php b/classes/form/addsession.php index 75a19e776ce..116d31e742b 100644 --- a/classes/form/addsession.php +++ b/classes/form/addsession.php @@ -72,7 +72,7 @@ public function definition() { $mform->setType('sessiontype', PARAM_INT); break; case VISIBLEGROUPS: - $radio = array(); + $radio = []; $radio[] = &$mform->createElement('radio', 'sessiontype', '', get_string('commonsession', 'attendance'), mod_attendance_structure::SESSION_COMMON); $radio[] = &$mform->createElement('radio', 'sessiontype', '', get_string('groupsession', 'attendance'), @@ -90,7 +90,7 @@ public function definition() { $groups = groups_get_all_groups($course->id, 0, $cm->groupingid); } if ($groups) { - $selectgroups = array(); + $selectgroups = []; foreach ($groups as $group) { $selectgroups[$group->id] = $group->name; } @@ -99,7 +99,7 @@ public function definition() { $mform->disabledIf('groups', 'sessiontype', 'eq', mod_attendance_structure::SESSION_COMMON); } else { if ($groupmode == VISIBLEGROUPS) { - $mform->updateElementAttr($radio, array('disabled' => 'disabled')); + $mform->updateElementAttr($radio, ['disabled' => 'disabled']); } $mform->addElement('static', 'groups', get_string('groups', 'group'), get_string('nogroups', 'attendance')); @@ -114,7 +114,7 @@ public function definition() { // Select which status set to use. $maxstatusset = attendance_get_max_statusset($this->_customdata['att']->id); if ($maxstatusset > 0) { - $opts = array(); + $opts = []; for ($i = 0; $i <= $maxstatusset; $i++) { $opts[$i] = attendance_get_setname($this->_customdata['att']->id, $i); } @@ -124,8 +124,8 @@ public function definition() { $mform->setType('statusset', PARAM_INT); } - $mform->addElement('editor', 'sdescription', get_string('description', 'attendance'), array('rows' => 1, 'columns' => 80), - array('maxfiles' => EDITOR_UNLIMITED_FILES, 'noclean' => true, 'context' => $modcontext)); + $mform->addElement('editor', 'sdescription', get_string('description', 'attendance'), ['rows' => 1, 'columns' => 80], + ['maxfiles' => EDITOR_UNLIMITED_FILES, 'noclean' => true, 'context' => $modcontext]); $mform->setType('sdescription', PARAM_RAW); if (!empty($pluginconfig->enablecalendar)) { @@ -158,7 +158,7 @@ public function definition() { $mform->addElement('checkbox', 'addmultiply', '', get_string('repeatasfollows', 'attendance')); $mform->addHelpButton('addmultiply', 'createmultiplesessions', 'attendance'); - $sdays = array(); + $sdays = []; if ($CFG->calendar_startwday === '0') { // Week start from sunday. $sdays[] =& $mform->createElement('checkbox', 'Sun', '', get_string('sunday', 'calendar')); } @@ -171,15 +171,15 @@ public function definition() { if ($CFG->calendar_startwday !== '0') { // Week start from sunday. $sdays[] =& $mform->createElement('checkbox', 'Sun', '', get_string('sunday', 'calendar')); } - $mform->addGroup($sdays, 'sdays', get_string('repeaton', 'attendance'), array('     '), true); + $mform->addGroup($sdays, 'sdays', get_string('repeaton', 'attendance'), ['     '], true); $mform->disabledIf('sdays', 'addmultiply', 'notchecked'); - $period = array(1 => 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36); - $periodgroup = array(); + $period = [1 => 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, ]; + $periodgroup = []; $periodgroup[] =& $mform->createElement('select', 'period', '', $period, false, true); $periodgroup[] =& $mform->createElement('static', 'perioddesc', '', get_string('week', 'attendance')); - $mform->addGroup($periodgroup, 'periodgroup', get_string('repeatevery', 'attendance'), array(' '), false); + $mform->addGroup($periodgroup, 'periodgroup', get_string('repeatevery', 'attendance'), [' '], false); $mform->disabledIf('periodgroup', 'addmultiply', 'notchecked'); $mform->addElement('date_selector', 'sessionenddate', get_string('repeatuntil', 'attendance')); @@ -234,14 +234,14 @@ public function definition() { } if (!empty($studentscanmark)) { - $mgroup = array(); + $mgroup = []; $mgroup[] = & $mform->createElement('text', 'studentpassword', get_string('studentpassword', 'attendance')); $mform->disabledif('studentpassword', 'rotateqrcode', 'checked'); $mgroup[] = & $mform->createElement('checkbox', 'randompassword', '', get_string('randompassword', 'attendance')); $mform->disabledif('randompassword', 'rotateqrcode', 'checked'); - $mform->addGroup($mgroup, 'passwordgrp', get_string('passwordgrp', 'attendance'), array(' '), false); + $mform->addGroup($mgroup, 'passwordgrp', get_string('passwordgrp', 'attendance'), [' '], false); $mform->setType('studentpassword', PARAM_TEXT); $mform->addHelpButton('passwordgrp', 'passwordgrp', 'attendance'); @@ -283,7 +283,7 @@ public function definition() { $mform->setDefault('automark', $pluginconfig->automark_default); } } - $mgroup2 = array(); + $mgroup2 = []; $mgroup2[] = & $mform->createElement('text', 'subnet', get_string('requiresubnet', 'attendance')); if (empty(get_config('attendance', 'subnetactivitylevel'))) { $mform->setDefault('subnet', get_config('attendance', 'subnet')); @@ -295,18 +295,18 @@ public function definition() { $mform->setDefault('usedefaultsubnet', 1); $mform->setType('subnet', PARAM_TEXT); - $mform->addGroup($mgroup2, 'subnetgrp', get_string('requiresubnet', 'attendance'), array(' '), false); + $mform->addGroup($mgroup2, 'subnetgrp', get_string('requiresubnet', 'attendance'), [' '], false); $mform->setAdvanced('subnetgrp'); $mform->addHelpButton('subnetgrp', 'requiresubnet', 'attendance'); $mform->hideif('subnet', 'usedefaultsubnet', 'checked'); - $mgroup3 = array(); + $mgroup3 = []; $options = attendance_get_sharedipoptions(); $mgroup3[] = & $mform->createElement('select', 'preventsharedip', get_string('preventsharedip', 'attendance'), $options); $mgroup3[] = & $mform->createElement('text', 'preventsharediptime', get_string('preventsharediptime', 'attendance'), '', 'test'); - $mform->addGroup($mgroup3, 'preventsharedgroup', get_string('preventsharedip', 'attendance'), array(' '), false); + $mform->addGroup($mgroup3, 'preventsharedgroup', get_string('preventsharedip', 'attendance'), [' '], false); $mform->addHelpButton('preventsharedgroup', 'preventsharedip', 'attendance'); $mform->setAdvanced('preventsharedgroup'); $mform->setType('preventsharedip', PARAM_INT); @@ -353,7 +353,7 @@ public function validation($data, $files) { $addmulti = isset($data['addmultiply']) ? (int)$data['addmultiply'] : 0; if (($addmulti != 0) && (!array_key_exists('sdays', $data) || empty($data['sdays']))) { - $data['sdays'] = array(); + $data['sdays'] = []; $errors['sdays'] = get_string('required', 'attendance'); } if (isset($data['sdays'])) { @@ -380,7 +380,7 @@ public function validation($data, $files) { FROM {attendance_statuses} WHERE deleted = 0 AND (attendanceid = 0 or attendanceid = ?) AND setnumber = ? AND setunmarked = 1'; - $params = array($cm->instance, $data['statusset']); + $params = [$cm->instance, $data['statusset']]; if (!$DB->record_exists_sql($sql, $params)) { $errors['automark'] = get_string('noabsentstatusset', 'attendance'); } @@ -405,7 +405,7 @@ private function checkweekdays($sessiondate, $sessionenddate, $sdays) { $found = false; - $daysofweek = array(0 => "Sun", 1 => "Mon", 2 => "Tue", 3 => "Wed", 4 => "Thu", 5 => "Fri", 6 => "Sat"); + $daysofweek = [0 => "Sun", 1 => "Mon", 2 => "Tue", 3 => "Wed", 4 => "Thu", 5 => "Fri", 6 => "Sat"]; $start = new DateTime( date("Y-m-d", $sessiondate) ); $interval = new DateInterval('P1D'); $end = new DateTime( date("Y-m-d", $sessionenddate) ); diff --git a/classes/form/addwarning.php b/classes/form/addwarning.php index 52638161932..768dd5b08f3 100644 --- a/classes/form/addwarning.php +++ b/classes/form/addwarning.php @@ -45,7 +45,7 @@ public function definition() { // Load global defaults. $config = get_config('attendance'); - $options = array(); + $options = []; for ($i = 1; $i <= 100; $i++) { $options[$i] = "$i%"; } @@ -54,7 +54,7 @@ public function definition() { $mform->setType('warningpercent', PARAM_INT); $mform->setDefault('warningpercent', $config->warningpercent); - $options = array(); + $options = []; for ($i = 1; $i <= ATTENDANCE_MAXWARNAFTER; $i++) { $options[$i] = "$i"; } @@ -72,19 +72,19 @@ public function definition() { $mform->addHelpButton('emailuser', 'emailuser', 'mod_attendance'); $mform->setDefault('emailuser', $config->emailuser); - $mform->addElement('text', 'emailsubject', get_string('emailsubject', 'mod_attendance'), array('size' => '64')); + $mform->addElement('text', 'emailsubject', get_string('emailsubject', 'mod_attendance'), ['size' => '64']); $mform->setType('emailsubject', PARAM_TEXT); $mform->addRule('emailsubject', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $mform->addHelpButton('emailsubject', 'emailsubject', 'mod_attendance'); $mform->setDefault('emailsubject', $config->emailsubject); $mform->addElement('editor', 'emailcontent', get_string('emailcontent', 'mod_attendance'), null, null); - $mform->setDefault('emailcontent', array('text' => format_text($config->emailcontent))); + $mform->setDefault('emailcontent', ['text' => format_text($config->emailcontent)]); $mform->setType('emailcontent', PARAM_RAW); $mform->addHelpButton('emailcontent', 'emailcontent', 'mod_attendance'); $users = get_users_by_capability(context_course::instance($COURSE->id), 'mod/attendance:warningemails'); - $options = array(); + $options = []; foreach ($users as $user) { $options[$user->id] = fullname($user); } diff --git a/classes/form/duration.php b/classes/form/duration.php index 0eb8b0db7ec..d61d17a69e3 100644 --- a/classes/form/duration.php +++ b/classes/form/duration.php @@ -57,7 +57,7 @@ public function definition() { } $durselect[] =& $mform->createElement('select', 'hours', '', $hours); $durselect[] =& $mform->createElement('select', 'minutes', '', $minutes, false, true); - $mform->addGroup($durselect, 'durtime', get_string('newduration', 'attendance'), array(' '), true); + $mform->addGroup($durselect, 'durtime', get_string('newduration', 'attendance'), [' '], true); $mform->addElement('hidden', 'ids', $ids); $mform->setType('ids', PARAM_ALPHANUMEXT); @@ -66,7 +66,7 @@ public function definition() { $mform->addElement('hidden', 'action', \mod_attendance_sessions_page_params::ACTION_CHANGE_DURATION); $mform->setType('action', PARAM_INT); - $mform->setDefaults(array('durtime' => array('hours' => 0, 'minutes' => 0))); + $mform->setDefaults(['durtime' => ['hours' => 0, 'minutes' => 0]]); $submitstring = get_string('update', 'attendance'); $this->add_action_buttons(true, $submitstring); diff --git a/classes/form/export.php b/classes/form/export.php index 614bc6db08f..6dda9ae2312 100644 --- a/classes/form/export.php +++ b/classes/form/export.php @@ -62,12 +62,12 @@ public function definition() { $namefields = $userfieldsapi->get_sql('u', false, '', '', false)->selects; $allusers = get_enrolled_users($modcontext, 'mod/attendance:canbelisted', 0, 'u.id,'.$namefields); - $userlist = array(); + $userlist = []; foreach ($allusers as $user) { $userlist[$user->id] = fullname($user); } unset($allusers); - $tempusers = $DB->get_records('attendance_tempusers', array('courseid' => $course->id), 'studentid, fullname'); + $tempusers = $DB->get_records('attendance_tempusers', ['courseid' => $course->id], 'studentid, fullname'); foreach ($tempusers as $user) { $userlist[$user->studentid] = $user->fullname; } @@ -81,10 +81,10 @@ public function definition() { $params = array_merge($gparams, $uparams); $groupmembers = $DB->get_recordset_select('groups_members', "groupid {$gsql} AND userid {$usql}", $params, '', 'groupid, userid'); - $groupmappings = array(); + $groupmappings = []; foreach ($groupmembers as $groupmember) { if (!isset($groupmappings[$groupmember->groupid])) { - $groupmappings[$groupmember->groupid] = array(); + $groupmappings[$groupmember->groupid] = []; } $groupmappings[$groupmember->groupid][$groupmember->userid] = $userlist[$groupmember->userid]; } @@ -95,15 +95,15 @@ public function definition() { $mform->addElement('select', 'group', get_string('group'), $grouplist); $mform->addElement('selectyesno', 'selectedusers', get_string('onlyselectedusers', 'mod_attendance')); - $sel = $mform->addElement('select', 'users', get_string('users', 'mod_attendance'), $userlist, array('size' => 12)); + $sel = $mform->addElement('select', 'users', get_string('users', 'mod_attendance'), $userlist, ['size' => 12]); $sel->setMultiple(true); $mform->disabledIf('users', 'selectedusers', 'eq', 0); - $opts = array('groupmappings' => $groupmappings); - $PAGE->requires->yui_module('moodle-mod_attendance-groupfilter', 'M.mod_attendance.groupfilter.init', array($opts)); + $opts = ['groupmappings' => $groupmappings]; + $PAGE->requires->yui_module('moodle-mod_attendance-groupfilter', 'M.mod_attendance.groupfilter.init', [$opts]); - $ident = array(); - $checkedfields = array(); + $ident = []; + $checkedfields = []; $adminsetfields = get_config('attendance', 'customexportfields'); if (in_array('id', explode(',', $adminsetfields))) { @@ -124,14 +124,14 @@ public function definition() { if ((is_siteadmin($USER) || $field->visible == PROFILE_VISIBLE_ALL || $field->visible == PROFILE_VISIBLE_TEACHERS) && in_array($field->shortname, explode(',', $adminsetfields))) { $ident[] =& $mform->createElement('checkbox', $field->shortname, '', - format_string($field->name, true, array('context' => $modcontext))); + format_string($field->name, true, ['context' => $modcontext])); $mform->setType($field->shortname, PARAM_NOTAGS); $checkedfields['ident['. $field->shortname .']'] = true; } } if (count($ident) > 0) { - $mform->addGroup($ident, 'ident', get_string('identifyby', 'attendance'), array('
'), true); + $mform->addGroup($ident, 'ident', get_string('identifyby', 'attendance'), ['
'], true); $mform->setDefaults($checkedfields); } $mform->setType('id', PARAM_INT); @@ -147,9 +147,9 @@ public function definition() { $mform->addElement('date_selector', 'sessionenddate', get_string('endofperiod', 'attendance')); $mform->disabledIf('sessionenddate', 'includeallsessions', 'checked'); - $formatoptions = array('excel' => get_string('downloadexcel', 'attendance'), + $formatoptions = ['excel' => get_string('downloadexcel', 'attendance'), 'ooo' => get_string('downloadooo', 'attendance'), - 'text' => get_string('downloadtext', 'attendance')); + 'text' => get_string('downloadtext', 'attendance'), ]; $mform->addElement('select', 'format', get_string('format'), $formatoptions); $submitstring = get_string('ok'); diff --git a/classes/form/import/marksessions.php b/classes/form/import/marksessions.php index c8e56901065..b0799407029 100644 --- a/classes/form/import/marksessions.php +++ b/classes/form/import/marksessions.php @@ -52,10 +52,10 @@ public function definition() { $mform->addElement('header', 'uploadattendance', get_string('uploadattendance', 'attendance')); - $fileoptions = array('subdirs' => 0, + $fileoptions = ['subdirs' => 0, 'maxbytes' => $COURSE->maxbytes, 'accepted_types' => 'csv', - 'maxfiles' => 1); + 'maxfiles' => 1, ]; $mform->addElement('filepicker', 'attendancefile', get_string('uploadafile'), null, $fileoptions); $mform->addRule('attendancefile', get_string('uploadnofilefound'), 'required', null, 'client'); @@ -65,7 +65,7 @@ public function definition() { $mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $encodings); $mform->addHelpButton('encoding', 'encoding', 'grades'); - $radio = array(); + $radio = []; $radio[] = $mform->createElement('radio', 'separator', null, get_string('septab', 'grades'), 'tab'); $radio[] = $mform->createElement('radio', 'separator', null, get_string('sepcomma', 'grades'), 'comma'); $radio[] = $mform->createElement('radio', 'separator', null, get_string('sepcolon', 'grades'), 'colon'); diff --git a/classes/form/import/marksessions_confirm.php b/classes/form/import/marksessions_confirm.php index a27a791053c..7924e6f16a8 100644 --- a/classes/form/import/marksessions_confirm.php +++ b/classes/form/import/marksessions_confirm.php @@ -56,12 +56,12 @@ public function definition() { $mform->addElement('select', 'userfrom', get_string('userimportfield', 'attendance'), $foundheaders); $mform->addHelpButton('userfrom', 'userimportfield', 'attendance'); // This allows the user to choose which field in the user database the identifying column will map to. - $useroptions = array( + $useroptions = [ 'id' => get_string('userid', 'attendance'), 'username' => get_string('username'), 'idnumber' => get_string('idnumber'), - 'email' => get_string('email') - ); + 'email' => get_string('email'), + ]; $mform->addElement('select', 'userto', get_string('userimportto', 'attendance'), $useroptions); // Check if we can set an easy default value. diff --git a/classes/form/studentattendance.php b/classes/form/studentattendance.php index 5825c21d191..193c057ce29 100644 --- a/classes/form/studentattendance.php +++ b/classes/form/studentattendance.php @@ -87,18 +87,18 @@ public function definition() { } // Create radio buttons for setting the attendance status. - $radioarray = array(); + $radioarray = []; foreach ($statuses as $status) { $name = \html_writer::span($status->description, 'statusdesc'); - $radioarray[] =& $mform->createElement('radio', 'status', '', $name, $status->id, array()); + $radioarray[] =& $mform->createElement('radio', 'status', '', $name, $status->id, []); } if ($disabledduetotime) { $warning = \html_writer::span(get_string('somedisabledstatus', 'attendance'), 'somedisabledstatus'); $radioarray[] =& $mform->createElement('static', '', '', $warning); } // Add the radio buttons as a control with the user's name in front. - $radiogroup = $mform->addGroup($radioarray, 'statusarray', fullname($USER).':', array(''), false); - $radiogroup->setAttributes(array('class' => 'statusgroup')); + $radiogroup = $mform->addGroup($radioarray, 'statusarray', fullname($USER).':', [''], false); + $radiogroup->setAttributes(['class' => 'statusgroup']); $mform->addRule('statusarray', get_string('attendancenotset', 'attendance'), 'required', '', 'client', false, false); if (!empty($existingstatus) && !empty($statuses[$existingstatus->id])) { $mform->setDefault('status', $existingstatus->id); @@ -115,7 +115,7 @@ public function definition() { * @return array */ public function validation($data, $files) { - $errors = array(); + $errors = []; if (!($this->_customdata['session']->autoassignstatus)) { // Check if this status is allowed to be set. if (empty($data['status'])) { diff --git a/classes/form/tempmerge.php b/classes/form/tempmerge.php index a25e01ec395..ebfd8e20abb 100644 --- a/classes/form/tempmerge.php +++ b/classes/form/tempmerge.php @@ -45,7 +45,7 @@ public function definition() { $namefields = $userfieldsapi->get_sql('u', false, '', '', false)->selects; $students = get_enrolled_users($context, 'mod/attendance:canbelisted', 0, 'u.id,'.$namefields.',u.email', 'u.lastname, u.firstname', 0, 0, true); - $partarray = array(); + $partarray = []; foreach ($students as $student) { $partarray[$student->id] = fullname($student).' ('.$student->email.')'; } diff --git a/classes/form/tempuseredit.php b/classes/form/tempuseredit.php index b80fe0d8433..b96d5bbb09b 100644 --- a/classes/form/tempuseredit.php +++ b/classes/form/tempuseredit.php @@ -54,11 +54,11 @@ public function definition() { $mform->addRule('temail', 'Email', 'email', null, 'client'); $mform->setType('temail', PARAM_EMAIL); - $buttonarray = array( + $buttonarray = [ $mform->createElement('submit', 'submitbutton', get_string('edituser', 'attendance')), $mform->createElement('cancel'), - ); - $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); + ]; + $mform->addGroup($buttonarray, 'buttonar', '', [' '], false); $mform->closeHeaderBefore('submit'); } diff --git a/classes/form/updatesession.php b/classes/form/updatesession.php index 6f04594c314..61bfd8fceef 100644 --- a/classes/form/updatesession.php +++ b/classes/form/updatesession.php @@ -45,11 +45,11 @@ public function definition() { $modcontext = $this->_customdata['modcontext']; $sessionid = $this->_customdata['sessionid']; - if (!$sess = $DB->get_record('attendance_sessions', array('id' => $sessionid) )) { + if (!$sess = $DB->get_record('attendance_sessions', ['id' => $sessionid] )) { error('No such session in this course'); } - $attendancesubnet = $DB->get_field('attendance', 'subnet', array('id' => $sess->attendanceid)); - $defopts = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'noclean' => true, 'context' => $modcontext); + $attendancesubnet = $DB->get_field('attendance', 'subnet', ['id' => $sess->attendanceid]); + $defopts = ['maxfiles' => EDITOR_UNLIMITED_FILES, 'noclean' => true, 'context' => $modcontext]; $sess = file_prepare_standard_editor($sess, 'description', $defopts, $modcontext, 'mod_attendance', 'session', $sess->id); $starttime = $sess->sessdate - usergetmidnight($sess->sessdate); @@ -61,10 +61,10 @@ public function definition() { $endhour = floor($endtime / HOURSECS); $endminute = floor(($endtime - $endhour * HOURSECS) / MINSECS); - $data = array( + $data = [ 'sessiondate' => $sess->sessdate, - 'sestime' => array('starthour' => $starthour, 'startminute' => $startminute, - 'endhour' => $endhour, 'endminute' => $endminute), + 'sestime' => ['starthour' => $starthour, 'startminute' => $startminute, + 'endhour' => $endhour, 'endminute' => $endminute, ], 'sdescription' => $sess->description_editor, 'calendarevent' => $sess->calendarevent, 'studentscanmark' => $sess->studentscanmark, @@ -80,8 +80,8 @@ public function definition() { 'includeqrcode' => $sess->includeqrcode, 'rotateqrcode' => $sess->rotateqrcode, 'automarkcmid' => $sess->automarkcmid, - 'studentsearlyopentime' => $sess->studentsearlyopentime - ); + 'studentsearlyopentime' => $sess->studentsearlyopentime, + ]; if ($sess->subnet == $attendancesubnet) { $data['usedefaultsubnet'] = 1; } else { @@ -93,7 +93,7 @@ public function definition() { if ($sess->groupid == 0) { $strtype = get_string('commonsession', 'attendance'); } else { - $groupname = $DB->get_field('groups', 'name', array('id' => $sess->groupid)); + $groupname = $DB->get_field('groups', 'name', ['id' => $sess->groupid]); $strtype = get_string('group') . ': ' . $groupname; } $mform->addElement('static', 'sessiontypedescription', get_string('sessiontype', 'attendance'), $strtype); @@ -113,7 +113,7 @@ public function definition() { $mform->setType('statusset', PARAM_INT); $mform->addElement('editor', 'sdescription', get_string('description', 'attendance'), - array('rows' => 1, 'columns' => 80), $defopts); + ['rows' => 1, 'columns' => 80], $defopts); $mform->setType('sdescription', PARAM_RAW); if (!empty(get_config('attendance', 'enablecalendar'))) { @@ -187,14 +187,14 @@ public function definition() { $mform->hideif('autoassignstatus', 'studentscanmark', 'notchecked'); } - $mgroup = array(); + $mgroup = []; $mgroup[] = & $mform->createElement('text', 'subnet', get_string('requiresubnet', 'attendance')); $mform->setDefault('subnet', $this->_customdata['att']->subnet); $mgroup[] = & $mform->createElement('checkbox', 'usedefaultsubnet', get_string('usedefaultsubnet', 'attendance')); $mform->setDefault('usedefaultsubnet', 1); $mform->setType('subnet', PARAM_TEXT); - $mform->addGroup($mgroup, 'subnetgrp', get_string('requiresubnet', 'attendance'), array(' '), false); + $mform->addGroup($mgroup, 'subnetgrp', get_string('requiresubnet', 'attendance'), [' '], false); $mform->setAdvanced('subnetgrp'); $mform->addHelpButton('subnetgrp', 'requiresubnet', 'attendance'); $mform->hideif('subnet', 'usedefaultsubnet', 'checked'); @@ -202,14 +202,14 @@ public function definition() { $mform->addElement('hidden', 'automarkcompleted', '0'); $mform->settype('automarkcompleted', PARAM_INT); - $mgroup3 = array(); + $mgroup3 = []; $options = attendance_get_sharedipoptions(); $mgroup3[] = & $mform->createElement('select', 'preventsharedip', get_string('preventsharedip', 'attendance'), $options); $mgroup3[] = & $mform->createElement('text', 'preventsharediptime', get_string('preventsharediptime', 'attendance'), '', 'test'); $mform->addGroup($mgroup3, 'preventsharedgroup', - get_string('preventsharedip', 'attendance'), array(' '), false); + get_string('preventsharedip', 'attendance'), [' '], false); $mform->addHelpButton('preventsharedgroup', 'preventsharedip', 'attendance'); $mform->setAdvanced('preventsharedgroup'); $mform->setType('preventsharediptime', PARAM_INT); @@ -249,7 +249,7 @@ public function validation($data, $files) { FROM {attendance_statuses} WHERE deleted = 0 AND (attendanceid = 0 or attendanceid = ?) AND setnumber = ? AND setunmarked = 1'; - $params = array($cm->instance, $data['statusset']); + $params = [$cm->instance, $data['statusset']]; if (!$DB->record_exists_sql($sql, $params)) { $errors['automark'] = get_string('noabsentstatusset', 'attendance'); } diff --git a/classes/import/marksessions.php b/classes/import/marksessions.php index 8bc7b4da869..316a21770dc 100644 --- a/classes/import/marksessions.php +++ b/classes/import/marksessions.php @@ -43,10 +43,10 @@ class marksessions { protected $error = ''; /** @var array $sessions The sessions info */ - protected $sessions = array(); + protected $sessions = []; /** @var array $mappings The mappings info */ - protected $mappings = array(); + protected $mappings = []; /** @var int The id of the csv import */ protected $importid = 0; @@ -55,7 +55,7 @@ class marksessions { protected $importer = null; /** @var array $foundheaders */ - protected $foundheaders = array(); + protected $foundheaders = []; /** @var bool $useprogressbar Control whether importing should use progress bars or not. */ protected $useprogressbar = false; @@ -101,17 +101,17 @@ public function list_found_headers() { */ protected function read_mapping_data($data) { if ($data) { - return array( + return [ 'user' => $data->userfrom, 'scantime' => $data->scantime, - 'status' => $data->status - ); + 'status' => $data->status, + ]; } else { - return array( + return [ 'user' => 0, 'scantime' => 1, - 'status' => 2 - ); + 'status' => 2, + ]; } } @@ -180,10 +180,10 @@ public function __construct($text = null, $att, $encoding = null, $delimiter = n $this->useprogressbar = $useprogressbar; - $sesslog = array(); + $sesslog = []; $validusers = $this->att->get_users($this->att->pageparams->grouptype, 0); - $users = array(); + $users = []; // Re-key validusers based on the identifier used by import. if (!empty($mappingdata) && $mappingdata->userto !== 'id') { @@ -197,7 +197,7 @@ public function __construct($text = null, $att, $encoding = null, $delimiter = n } $statuses = $this->att->get_statuses(); - $statusmap = array(); + $statusmap = []; foreach ($statuses as $st) { $statusmap[$st->acronym] = $st->id; } diff --git a/classes/import/sessions.php b/classes/import/sessions.php index 1868bfb5cb0..2ecb6f1c03b 100644 --- a/classes/import/sessions.php +++ b/classes/import/sessions.php @@ -44,10 +44,10 @@ class sessions { protected $error = ''; /** @var array $sessions The sessions info */ - protected $sessions = array(); + protected $sessions = []; /** @var array $mappings The mappings info */ - protected $mappings = array(); + protected $mappings = []; /** @var int The id of the csv import */ protected $importid = 0; @@ -56,7 +56,7 @@ class sessions { protected $importer = null; /** @var array $foundheaders */ - protected $foundheaders = array(); + protected $foundheaders = []; /** @var bool $useprogressbar Control whether importing should use progress bars or not. */ protected $useprogressbar = false; @@ -252,7 +252,7 @@ public function __construct($text = null, $encoding = null, $delimiter = null, $ $this->useprogressbar = $useprogressbar; $domainid = 1; - $sessions = array(); + $sessions = []; while ($row = $this->importer->next()) { // This structure mimics what the UI form returns. @@ -485,20 +485,20 @@ public function import() { $okcount = 0; foreach ($this->sessions as $session) { - $groupids = array(); + $groupids = []; // Check course shortname matches. - if ($DB->record_exists('course', array( - 'shortname' => $session->course - ))) { + if ($DB->record_exists('course', [ + 'shortname' => $session->course, + ])) { // Get course. - $course = $DB->get_record('course', array( - 'shortname' => $session->course - ), '*', MUST_EXIST); + $course = $DB->get_record('course', [ + 'shortname' => $session->course, + ], '*', MUST_EXIST); // Check course has activities. - if ($DB->record_exists('attendance', array( - 'course' => $course->id - ))) { + if ($DB->record_exists('attendance', [ + 'course' => $course->id, + ])) { // Translate group names to group IDs. They are unique per course. if ($session->sessiontype === \mod_attendance_structure::SESSION_GROUP) { foreach ($session->groups as $groupname) { @@ -533,11 +533,11 @@ public function import() { foreach ($sessions as $index => $sess) { // Check for duplicate sessions. if ($this->session_exists($sess, $att->id)) { - mod_attendance_notifyqueue::notify_message(get_string('sessionduplicate', 'attendance', (array( + mod_attendance_notifyqueue::notify_message(get_string('sessionduplicate', 'attendance', ([ 'course' => $session->course, 'activity' => $cm->name, - 'date' => construct_session_full_date_time($sess->sessdate, $sess->duration) - )))); + 'date' => construct_session_full_date_time($sess->sessdate, $sess->duration), + ]))); unset($sessions[$index]); } else { $okcount ++; @@ -565,13 +565,13 @@ public function import() { } // Trigger a sessions imported event. - $event = \mod_attendance\event\sessions_imported::create(array( + $event = \mod_attendance\event\sessions_imported::create([ 'objectid' => 0, 'context' => \context_system::instance(), - 'other' => array( - 'count' => $okcount - ) - )); + 'other' => [ + 'count' => $okcount, + ], + ]); $event->trigger(); } @@ -589,7 +589,7 @@ private function session_exists(stdClass $session, $attid) { $check = ['attendanceid' => $attid, 'sessdate' => $session->sessdate, 'duration' => $session->duration, - 'groupid' => $session->groupid]; + 'groupid' => $session->groupid, ]; if ($DB->record_exists('attendance_sessions', $check)) { return true; } diff --git a/classes/local/automark.php b/classes/local/automark.php index dc9e61a5647..422ffffd71c 100644 --- a/classes/local/automark.php +++ b/classes/local/automark.php @@ -107,7 +107,7 @@ public static function session($session, $course, $cm, $attendance, $returnerror $duration = get_config('attendance', 'studentscanmarksessiontimeend') * 60; } $timeend = $timestart + $duration; - $logusers = $DB->get_recordset_sql($sql, array($course->id, $timestart, $timeend)); + $logusers = $DB->get_recordset_sql($sql, [$course->id, $timestart, $timeend]); // Check if user access is in allowed subnet. foreach ($logusers as $loguser) { if (!empty($session->subnet) && !address_in_subnet($loguser->ip, $session->subnet)) { @@ -170,7 +170,7 @@ public static function session($session, $course, $cm, $attendance, $returnerror // Get all unmarked students. $users = $att->get_users($session->groupid, 0); - $existinglog = $DB->get_recordset('attendance_log', array('sessionid' => $session->id)); + $existinglog = $DB->get_recordset('attendance_log', ['sessionid' => $session->id]); $updated = 0; foreach ($existinglog as $log) { @@ -247,13 +247,13 @@ public static function session($session, $course, $cm, $attendance, $returnerror $att->update_users_grade(array_keys($users)); } - $params = array( + $params = [ 'sessionid' => $att->pageparams->sessionid, - 'grouptype' => $att->pageparams->grouptype); - $event = \mod_attendance\event\attendance_taken::create(array( + 'grouptype' => $att->pageparams->grouptype, ]; + $event = \mod_attendance\event\attendance_taken::create([ 'objectid' => $att->id, 'context' => $att->context, - 'other' => $params)); + 'other' => $params]); $event->add_record_snapshot('course_modules', $att->cm); $event->add_record_snapshot('attendance_sessions', $session); $event->trigger(); diff --git a/classes/local/url_helpers.php b/classes/local/url_helpers.php index 1e6eed7368d..64785b4bbcf 100644 --- a/classes/local/url_helpers.php +++ b/classes/local/url_helpers.php @@ -41,7 +41,7 @@ class url_helpers { * @return mixed */ public static function url_take($att, $sessionid, $grouptype) { - $params = array('sessionid' => $sessionid); + $params = ['sessionid' => $sessionid]; if (isset($grouptype)) { $params['grouptype'] = $grouptype; } @@ -58,9 +58,9 @@ public static function url_take($att, $sessionid, $grouptype) { */ public static function url_sessions($att, $sessionid=null, $action=null) { if (isset($sessionid) && isset($action)) { - $params = array('sessionid' => $sessionid, 'action' => $action); + $params = ['sessionid' => $sessionid, 'action' => $action]; } else { - $params = array(); + $params = []; } return $att->url_sessions($params); @@ -72,7 +72,7 @@ public static function url_sessions($att, $sessionid=null, $action=null) { * @param array $params * @return mixed */ - public static function url_view($att, $params=array()) { + public static function url_view($att, $params=[]) { return $att->url_view($params); } } diff --git a/classes/manage_page_params.php b/classes/manage_page_params.php index d18c6737eb2..6b575c3feb0 100644 --- a/classes/manage_page_params.php +++ b/classes/manage_page_params.php @@ -41,6 +41,6 @@ public function __construct() { * @return array */ public function get_significant_params() { - return array(); + return []; } } diff --git a/classes/notifyqueue.php b/classes/notifyqueue.php index fb4e4ae0d7e..35dacdd01b8 100644 --- a/classes/notifyqueue.php +++ b/classes/notifyqueue.php @@ -81,7 +81,7 @@ private static function queue_message($message, $messagetype=\core\output\notifi global $SESSION; if (!isset($SESSION->mod_attendance_notifyqueue)) { - $SESSION->mod_attendance_notifyqueue = array(); + $SESSION->mod_attendance_notifyqueue = []; } $m = new stdclass(); $m->type = $messagetype; diff --git a/classes/observer.php b/classes/observer.php index c5307ba1a11..cd7ded9c57e 100644 --- a/classes/observer.php +++ b/classes/observer.php @@ -39,7 +39,7 @@ class mod_attendance_observer { public static function course_content_deleted(\core\event\course_content_deleted $event) { global $DB; - $attids = array_keys($DB->get_records('attendance', array('course' => $event->objectid), '', 'id')); + $attids = array_keys($DB->get_records('attendance', ['course' => $event->objectid], '', 'id')); $sessids = array_keys($DB->get_records_list('attendance_sessions', 'attendanceid', $attids, '', 'id')); if (attendance_existing_calendar_events_ids($sessids)) { attendance_delete_calendar_events($sessids); diff --git a/classes/output/filter_controls.php b/classes/output/filter_controls.php index 90998196731..6393fcf173f 100644 --- a/classes/output/filter_controls.php +++ b/classes/output/filter_controls.php @@ -114,7 +114,7 @@ public function __construct(mod_attendance_structure $att, $report = false) { * @param array $params * @return moodle_url */ - public function url($params=array()) { + public function url($params=[]) { $params = array_merge($this->urlparams, $params); return new moodle_url($this->urlpath, $params); @@ -133,7 +133,7 @@ public function url_path() { * @param array $params * @return array */ - public function url_params($params=array()) { + public function url_params($params=[]) { $params = array_merge($this->urlparams, $params); return $params; diff --git a/classes/output/mobile.php b/classes/output/mobile.php index 4f408422887..0a9a17500d4 100644 --- a/classes/output/mobile.php +++ b/classes/output/mobile.php @@ -67,11 +67,11 @@ public static function mobile_view_activity($args) { $context = \context_module::instance($cm->id); require_capability('mod/attendance:view', $context); - $attendance = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); - $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); + $attendance = $DB->get_record('attendance', ['id' => $cm->instance], '*', MUST_EXIST); + $course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); $config = get_config('attendance'); - $data = array(); // Data to pass to renderer. + $data = []; // Data to pass to renderer. $data['cmid'] = $cmid; $data['courseid'] = $courseid; $data['attendance'] = $attendance; @@ -90,7 +90,7 @@ public static function mobile_view_activity($args) { $pageparams->group = groups_get_activity_group($cm, true); $canseegroupsession = true; if (!empty($sessid) && (!empty($takenstatus) || $isteacher)) { - $session = $DB->get_record('attendance_sessions', array('id' => $sessid)); + $session = $DB->get_record('attendance_sessions', ['id' => $sessid]); $pageparams->grouptype = $session->groupid; $pageparams->sessionid = $sessid; @@ -130,11 +130,11 @@ public static function mobile_view_activity($args) { $timefrom = time() - $config->mobilesessionfrom; $timeto = time() + $config->mobilesessionto; - $data['sessions'] = array(); + $data['sessions'] = []; $sessions = $DB->get_records_select('attendance_sessions', 'attendanceid = ? AND sessdate > ? AND sessdate < ? ORDER BY sessdate', - array($attendance->id, $timefrom, $timeto)); + [$attendance->id, $timefrom, $timeto]); if (!empty($sessions)) { $userdata = new user_data($att, $USER->id, true); @@ -159,11 +159,11 @@ public static function mobile_view_activity($args) { } if ($isteacher || $canmark) { - $html = array('time' => strip_tags(construct_session_full_date_time($sess->sessdate, $sess->duration)), - 'groupname' => ''); + $html = ['time' => strip_tags(construct_session_full_date_time($sess->sessdate, $sess->duration)), + 'groupname' => '', ]; if (!empty($sess->groupid)) { // TODO In-efficient way to get group name - we should get all groups in one query. - $html['groupname'] = $DB->get_field('groups', 'name', array('id' => $sess->groupid)); + $html['groupname'] = $DB->get_field('groups', 'name', ['id' => $sess->groupid]); } // Check if Status already recorded. @@ -243,7 +243,7 @@ public static function mobile_view_activity($args) { } } - $summary = new \mod_attendance_summary($att->id, array($USER->id), $att->pageparams->startdate, + $summary = new \mod_attendance_summary($att->id, [$USER->id], $att->pageparams->startdate, $att->pageparams->enddate); $data['summary'] = $summary->get_all_sessions_summary_for($USER->id); @@ -255,7 +255,7 @@ public static function mobile_view_activity($args) { ], ], 'javascript' => '', - 'otherdata' => '' + 'otherdata' => '', ]; } @@ -284,24 +284,24 @@ public static function mobile_user_form($args) { $context = \context_module::instance($cm->id); require_capability('mod/attendance:view', $context); - $attendance = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); - $attforsession = $DB->get_record('attendance_sessions', array('id' => $sessid), '*', MUST_EXIST); - $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); + $attendance = $DB->get_record('attendance', ['id' => $cm->instance], '*', MUST_EXIST); + $attforsession = $DB->get_record('attendance_sessions', ['id' => $sessid], '*', MUST_EXIST); + $course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); $pageparams = new \mod_attendance_sessions_page_params(); $pageparams->sessionid = $sessid; $att = new \mod_attendance_structure($attendance, $cm, $course, $context, $pageparams); - $data = array(); // Data to pass to renderer. + $data = []; // Data to pass to renderer. $data['attendance'] = $attendance; $data['cmid'] = $cmid; $data['courseid'] = $courseid; $data['sessid'] = $sessid; - $data['messages'] = array(); + $data['messages'] = []; $data['showmessage'] = false; $data['showstatuses'] = true; $data['showpassword'] = false; - $data['statuses'] = array(); + $data['statuses'] = []; $data['disabledduetotime'] = false; list($canmark, $reason) = attendance_can_student_mark($attforsession, false); @@ -331,7 +331,7 @@ public static function mobile_user_form($args) { continue; $data['disabledduetotime'] = true; } - $data['statuses'][] = array('stid' => $status->id, 'description' => $status->description); + $data['statuses'][] = ['stid' => $status->id, 'description' => $status->description]; } if (empty($data['statuses'])) { $data['messages'][]['string'] = 'attendance_no_status'; @@ -340,7 +340,7 @@ public static function mobile_user_form($args) { $data['showpassword'] = true; if ($attforsession->autoassignstatus) { // If this is an auto status - don't show the statuses, but show the form. - $data['statuses'] = array(); + $data['statuses'] = []; } } } @@ -353,11 +353,11 @@ public static function mobile_user_form($args) { [ 'id' => 'main', 'html' => $OUTPUT->render_from_template("mod_attendance/mobile_user_form_$versionname", $data), - 'cache-view' => false + 'cache-view' => false, ], ], 'javascript' => '', - 'otherdata' => '' + 'otherdata' => '', ]; } @@ -386,27 +386,27 @@ public static function mobile_teacher_form($args) { $context = \context_module::instance($cm->id); require_capability('mod/attendance:takeattendances', $context); - $attendance = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); - $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); + $attendance = $DB->get_record('attendance', ['id' => $cm->instance], '*', MUST_EXIST); + $course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); $pageparams = new \mod_attendance_sessions_page_params(); $pageparams->sessionid = $sessid; $att = new \mod_attendance_structure($attendance, $cm, $course, $context, $pageparams); - $data = array(); // Data to pass to renderer. + $data = []; // Data to pass to renderer. $data['attendance'] = $attendance; $data['cmid'] = $cmid; $data['courseid'] = $courseid; $data['sessid'] = $sessid; - $data['messages'] = array(); + $data['messages'] = []; $data['showmessage'] = false; - $data['statuses'] = array(); + $data['statuses'] = []; $data['btnargs'] = ''; // Stores list of userid status args that should be added to form post. $statuses = $att->get_statuses(); - $otherdata = array(); + $otherdata = []; $existinglog = $DB->get_records('attendance_log', - array('sessionid' => $sessid), '', 'studentid,statusid'); + ['sessionid' => $sessid], '', 'studentid,statusid'); foreach ($existinglog as $log) { if (!empty($log->statusid)) { $otherdata['status'.$log->studentid] = $log->statusid; @@ -414,18 +414,18 @@ public static function mobile_teacher_form($args) { } foreach ($statuses as $status) { - $data['statuses'][] = array('stid' => $status->id, 'acronym' => $status->acronym, - 'description' => $status->description); + $data['statuses'][] = ['stid' => $status->id, 'acronym' => $status->acronym, + 'description' => $status->description, ]; } - $data['users'] = array(); + $data['users'] = []; $data['selectall'] = ''; $users = $att->get_users($att->get_session_info($sessid)->groupid, 0); foreach ($users as $user) { $userpicture = new \user_picture($user); $userpicture->size = 1; // Size f1. $profileimageurl = $userpicture->get_url($PAGE)->out(false); - $data['users'][] = array('userid' => $user->id, 'fullname' => $user->fullname, 'profileimageurl' => $profileimageurl); + $data['users'][] = ['userid' => $user->id, 'fullname' => $user->fullname, 'profileimageurl' => $profileimageurl]; // Generate args to use in submission button here. $data['btnargs'] .= ', status'. $user->id. ': CONTENT_OTHERDATA.status'. $user->id; // Really Hacky way to do a select-all. This really needs to be moved into a JS function within the app. @@ -440,11 +440,11 @@ public static function mobile_teacher_form($args) { [ 'id' => 'main', 'html' => $OUTPUT->render_from_template("mod_attendance/mobile_teacher_form_$versionname", $data), - 'cache-view' => false + 'cache-view' => false, ], ], 'javascript' => '', - 'otherdata' => $otherdata + 'otherdata' => $otherdata, ]; } diff --git a/classes/output/password_icon.php b/classes/output/password_icon.php index 0d4b3b4894e..b8f2de7e517 100644 --- a/classes/output/password_icon.php +++ b/classes/output/password_icon.php @@ -97,7 +97,7 @@ public function export_for_template(renderer_base $output) { $data->linktext = ''; $data->title = $title; $data->url = (new moodle_url('/mod/attendance/password.php', [ - 'session' => $this->sessionid]))->out(false); + 'session' => $this->sessionid, ]))->out(false); $data->ltr = !right_to_left(); return $data; diff --git a/classes/output/preferences_data.php b/classes/output/preferences_data.php index 211785059fd..2f47de284c3 100644 --- a/classes/output/preferences_data.php +++ b/classes/output/preferences_data.php @@ -63,7 +63,7 @@ public function __construct(mod_attendance_structure $att, $errors) { * @param bool $significantparams * @return moodle_url */ - public function url($params=array(), $significantparams=true) { + public function url($params=[], $significantparams=true) { if ($significantparams) { $params = array_merge($this->att->pageparams->get_significant_params(), $params); } diff --git a/classes/output/renderer.php b/classes/output/renderer.php index da1e12e0682..b1d04e0144d 100644 --- a/classes/output/renderer.php +++ b/classes/output/renderer.php @@ -102,7 +102,7 @@ protected function render_sess_group_selector(filter_controls $fcontrols) { $select->label = get_string('sessions', 'attendance'); $output = $this->output->render($select); - return html_writer::tag('div', $output, array('class' => 'groupselector m-0')); + return html_writer::tag('div', $output, ['class' => 'groupselector m-0']); } break; case mod_attendance_page_with_filter_controls::SELECTOR_GROUP: @@ -137,8 +137,8 @@ protected function render_paging_controls(filter_controls $fcontrols) { $numberofpages = ceil($totalusers / $fcontrols->pageparams->perpage); if ($fcontrols->pageparams->page > 1) { - $pagingcontrols .= html_writer::link($fcontrols->url(array('curdate' => $fcontrols->curdate, - 'page' => $fcontrols->pageparams->page - 1)), + $pagingcontrols .= html_writer::link($fcontrols->url(['curdate' => $fcontrols->curdate, + 'page' => $fcontrols->pageparams->page - 1, ]), $this->output->larrow()); } $a = new stdClass(); @@ -146,10 +146,10 @@ protected function render_paging_controls(filter_controls $fcontrols) { $a->numpages = $numberofpages; $text = get_string('pageof', 'attendance', $a); $pagingcontrols .= html_writer::tag('span', $text, - array('class' => 'attbtn')); + ['class' => 'attbtn']); if ($fcontrols->pageparams->page < $numberofpages) { - $pagingcontrols .= html_writer::link($fcontrols->url(array('curdate' => $fcontrols->curdate, - 'page' => $fcontrols->pageparams->page + 1)), + $pagingcontrols .= html_writer::link($fcontrols->url(['curdate' => $fcontrols->curdate, + 'page' => $fcontrols->pageparams->page + 1, ]), $this->output->rarrow()); } @@ -167,42 +167,42 @@ protected function render_curdate_controls(filter_controls $fcontrols) { $curdatecontrols = ''; if ($fcontrols->curdatetxt) { - $this->page->requires->strings_for_js(array('calclose'), 'attendance'); - $jsvals = array( + $this->page->requires->strings_for_js(['calclose'], 'attendance'); + $jsvals = [ 'cal_months' => explode(',', get_string('calmonths', 'attendance')), 'cal_week_days' => explode(',', get_string('calweekdays', 'attendance')), 'cal_start_weekday' => $CFG->calendar_startwday, - 'cal_cur_date' => $fcontrols->curdate); + 'cal_cur_date' => $fcontrols->curdate, ]; $curdatecontrols = html_writer::script(js_writer::set_variable('M.attendance', $jsvals)); $this->page->requires->js('/mod/attendance/calendar.js'); - $curdatecontrols .= html_writer::link($fcontrols->url(array('curdate' => $fcontrols->prevcur)), + $curdatecontrols .= html_writer::link($fcontrols->url(['curdate' => $fcontrols->prevcur]), $this->output->larrow()); - $params = array( + $params = [ 'title' => get_string('calshow', 'attendance'), 'id' => 'show', 'class' => 'btn btn-secondary', - 'type' => 'button'); + 'type' => 'button', ]; $buttonform = html_writer::tag('button', $fcontrols->curdatetxt, $params); - foreach ($fcontrols->url_params(array('curdate' => '')) as $name => $value) { - $params = array( + foreach ($fcontrols->url_params(['curdate' => '']) as $name => $value) { + $params = [ 'type' => 'hidden', 'id' => $name, 'name' => $name, - 'value' => $value); + 'value' => $value, ]; $buttonform .= html_writer::empty_tag('input', $params); } - $params = array( + $params = [ 'id' => 'currentdate', 'action' => $fcontrols->url_path(), - 'method' => 'post' - ); + 'method' => 'post', + ]; $buttonform = html_writer::tag('form', $buttonform, $params); $curdatecontrols .= $buttonform; - $curdatecontrols .= html_writer::link($fcontrols->url(array('curdate' => $fcontrols->nextcur)), + $curdatecontrols .= html_writer::link($fcontrols->url(['curdate' => $fcontrols->nextcur]), $this->output->rarrow()); } @@ -217,18 +217,18 @@ protected function render_curdate_controls(filter_controls $fcontrols) { */ protected function render_grouping_controls(filter_controls $fcontrols) { if ($fcontrols->pageparams->mode === mod_attendance_view_page_params::MODE_ALL_SESSIONS) { - $groupoptions = array( + $groupoptions = [ 'date' => get_string('sessionsbydate', 'attendance'), 'activity' => get_string('sessionsbyactivity', 'attendance'), - 'course' => get_string('sessionsbycourse', 'attendance') - ); + 'course' => get_string('sessionsbycourse', 'attendance'), + ]; $groupcontrols = get_string('groupsessionsby', 'attendance') . ":"; foreach ($groupoptions as $key => $opttext) { if ($key != $fcontrols->pageparams->groupby) { - $link = html_writer::link($fcontrols->url(array('groupby' => $key)), $opttext); - $groupcontrols .= html_writer::tag('span', $link, array('class' => 'attbtn')); + $link = html_writer::link($fcontrols->url(['groupby' => $key]), $opttext); + $groupcontrols .= html_writer::tag('span', $link, ['class' => 'attbtn']); } else { - $groupcontrols .= html_writer::tag('span', $opttext, array('class' => 'attcurbtn')); + $groupcontrols .= html_writer::tag('span', $opttext, ['class' => 'attcurbtn']); } } return html_writer::tag('div', $groupcontrols); @@ -244,17 +244,17 @@ protected function render_grouping_controls(filter_controls $fcontrols) { */ protected function render_course_controls(filter_controls $fcontrols) { if ($fcontrols->pageparams->mode === mod_attendance_view_page_params::MODE_ALL_SESSIONS) { - $courseoptions = array( + $courseoptions = [ 'all' => get_string('sessionsallcourses', 'attendance'), - 'current' => get_string('sessionscurrentcourses', 'attendance') - ); + 'current' => get_string('sessionscurrentcourses', 'attendance'), + ]; $coursecontrols = ""; foreach ($courseoptions as $key => $opttext) { if ($key != $fcontrols->pageparams->sesscourses) { - $link = html_writer::link($fcontrols->url(array('sesscourses' => $key)), $opttext); - $coursecontrols .= html_writer::tag('span', $link, array('class' => 'attbtn')); + $link = html_writer::link($fcontrols->url(['sesscourses' => $key]), $opttext); + $coursecontrols .= html_writer::tag('span', $link, ['class' => 'attbtn']); } else { - $coursecontrols .= html_writer::tag('span', $opttext, array('class' => 'attcurbtn')); + $coursecontrols .= html_writer::tag('span', $opttext, ['class' => 'attcurbtn']); } } return html_writer::tag('div', $coursecontrols); @@ -284,10 +284,10 @@ protected function render_view_controls(filter_controls $fcontrols) { $viewcontrols = ''; foreach ($views as $key => $sview) { if ($key != $fcontrols->pageparams->view) { - $link = html_writer::link($fcontrols->url(array('view' => $key)), $sview); - $viewcontrols .= html_writer::tag('span', $link, array('class' => 'attbtn')); + $link = html_writer::link($fcontrols->url(['view' => $key]), $sview); + $viewcontrols .= html_writer::tag('span', $link, ['class' => 'attbtn']); } else { - $viewcontrols .= html_writer::tag('span', $sview, array('class' => 'attcurbtn')); + $viewcontrols .= html_writer::tag('span', $sview, ['class' => 'attcurbtn']); } } @@ -302,7 +302,7 @@ protected function render_view_controls(filter_controls $fcontrols) { */ protected function render_manage_data(manage_data $sessdata) { $o = $this->render_sess_manage_table($sessdata) . $this->render_sess_manage_control($sessdata); - $o = html_writer::tag('form', $o, array('method' => 'post', 'action' => $sessdata->url_sessions()->out())); + $o = html_writer::tag('form', $o, ['method' => 'post', 'action' => $sessdata->url_sessions()->out()]); $o = $this->output->container($o, 'generalbox attwidth'); $o = $this->output->container($o, 'attsessions_manage_table'); @@ -320,11 +320,11 @@ protected function render_sess_manage_table(manage_data $sessdata) { $table = new html_table(); $table->head = [ - html_writer::checkbox('cb_selector', 0, false, '', array('id' => 'cb_selector')), + html_writer::checkbox('cb_selector', 0, false, '', ['id' => 'cb_selector']), get_string('date', 'attendance'), get_string('time', 'attendance'), get_string('sessiontypeshort', 'attendance'), - get_string('description', 'attendance') + get_string('description', 'attendance'), ]; $table->align = ['center', 'right', '', '', 'left']; $table->size = ['1px', '1px', '1px', '', '*']; @@ -352,7 +352,7 @@ protected function render_sess_manage_table(manage_data $sessdata) { $dta = $this->construct_date_time_actions($sessdata, $sess); $table->data[$sess->id][] = html_writer::checkbox('sessid[]', $sess->id, false, '', - array('class' => 'attendancesesscheckbox')); + ['class' => 'attendancesesscheckbox']); $table->data[$sess->id][] = $dta['date']; $table->data[$sess->id][] = $dta['time']; if ($sess->groupid) { @@ -424,8 +424,8 @@ private function construct_date_time_actions(manage_data $sessdata, $sess) { $url = $sessdata->url_take($sess->id, $sess->groupid); $title = get_string('changeattendance', 'attendance'); - $date = html_writer::link($url, $date, array('title' => $title)); - $time = html_writer::link($url, $time, array('title' => $title)); + $date = html_writer::link($url, $date, ['title' => $title]); + $time = html_writer::link($url, $time, ['title' => $title]); $actions .= $this->output->action_icon($url, new pix_icon('redo', $title, 'attendance')); } else { @@ -450,7 +450,7 @@ private function construct_date_time_actions(manage_data $sessdata, $sess) { $actions .= $this->output->action_icon($url, new pix_icon('t/delete', $title)); } - return array('date' => $date, 'time' => $time, 'actions' => $actions); + return ['date' => $date, 'time' => $time, 'actions' => $actions]; } /** @@ -463,30 +463,30 @@ protected function render_sess_manage_control(manage_data $sessdata) { $table = new html_table(); $table->attributes['class'] = ' '; $table->width = '100%'; - $table->align = array('left', 'right'); + $table->align = ['left', 'right']; $table->data[0][] = $this->output->help_icon('hiddensessions', 'attendance', get_string('hiddensessions', 'attendance').': '.$sessdata->hiddensessionscount); if (has_capability('mod/attendance:manageattendances', $sessdata->att->context)) { if ($sessdata->hiddensessionscount > 0) { - $attributes = array( + $attributes = [ 'type' => 'submit', 'name' => 'deletehiddensessions', 'class' => 'btn btn-secondary', - 'value' => get_string('deletehiddensessions', 'attendance')); + 'value' => get_string('deletehiddensessions', 'attendance'), ]; $table->data[1][] = html_writer::empty_tag('input', $attributes); } - $options = array(mod_attendance_sessions_page_params::ACTION_DELETE_SELECTED => get_string('delete'), - mod_attendance_sessions_page_params::ACTION_CHANGE_DURATION => get_string('changeduration', 'attendance')); + $options = [mod_attendance_sessions_page_params::ACTION_DELETE_SELECTED => get_string('delete'), + mod_attendance_sessions_page_params::ACTION_CHANGE_DURATION => get_string('changeduration', 'attendance'), ]; $controls = html_writer::select($options, 'action'); - $attributes = array( + $attributes = [ 'type' => 'submit', 'name' => 'ok', 'value' => get_string('ok'), - 'class' => 'btn btn-secondary'); + 'class' => 'btn btn-secondary', ]; $controls .= html_writer::empty_tag('input', $attributes); } else { $controls = get_string('youcantdo', 'attendance'); // You can't do anything. @@ -510,23 +510,23 @@ protected function render_take_data(take_data $takedata) { } else { $table .= $this->render_attendance_take_grid($takedata); } - $table .= html_writer::input_hidden_params($takedata->url(array('sesskey' => sesskey(), + $table .= html_writer::input_hidden_params($takedata->url(['sesskey' => sesskey(), 'page' => $takedata->pageparams->page, - 'perpage' => $takedata->pageparams->perpage))); + 'perpage' => $takedata->pageparams->perpage, ])); $table .= html_writer::end_div(); - $params = array( + $params = [ 'type' => 'submit', 'class' => 'btn btn-primary', - 'value' => get_string('saveandshownext', 'attendance')); + 'value' => get_string('saveandshownext', 'attendance'), ]; $table .= html_writer::tag('center', html_writer::empty_tag('input', $params)); - $table = html_writer::tag('form', $table, array('method' => 'post', 'action' => $takedata->url_path(), - 'id' => 'attendancetakeform')); + $table = html_writer::tag('form', $table, ['method' => 'post', 'action' => $takedata->url_path(), + 'id' => 'attendancetakeform']); foreach ($takedata->statuses as $status) { $sessionstats[$status->id] = 0; } // Calculate the sum of statuses for each user. - $sessionstats[] = array(); + $sessionstats[] = []; foreach ($takedata->sessionlog as $userlog) { foreach ($takedata->statuses as $status) { if ($userlog->statusid == $status->id && in_array($userlog->studentid, array_keys($takedata->users))) { @@ -551,9 +551,9 @@ protected function render_take_data(take_data $takedata) { */ protected function render_attendance_take_controls(take_data $takedata) { - $urlparams = array('id' => $takedata->cm->id, + $urlparams = ['id' => $takedata->cm->id, 'sessionid' => $takedata->pageparams->sessionid, - 'grouptype' => $takedata->pageparams->grouptype); + 'grouptype' => $takedata->pageparams->grouptype, ]; $url = new moodle_url('/mod/attendance/import/marksessions.php', $urlparams); $return = $this->output->single_button($url, get_string('uploadattendance', 'attendance')); if (!empty($takedata->sessioninfo->automark) && @@ -564,7 +564,7 @@ protected function render_attendance_take_controls(take_data $takedata) { ($takedata->sessioninfo->sessdate + $takedata->sessioninfo->duration) < time()))) { $urlparams = ['id' => $takedata->cm->id, 'sessionid' => $takedata->pageparams->sessionid, - 'grouptype' => $takedata->pageparams->grouptype]; + 'grouptype' => $takedata->pageparams->grouptype, ]; $url = new moodle_url('/mod/attendance/automark.php', $urlparams); $return .= $this->output->single_button($url, get_string('manualtriggerauto', 'attendance')); } @@ -638,7 +638,7 @@ private function construct_take_controls(take_data $takedata) { $numberofpages = ceil($totalusers / $usersperpage); if ($takedata->pageparams->page > 1) { - $controls .= html_writer::link($takedata->url(array('page' => $takedata->pageparams->page - 1)), + $controls .= html_writer::link($takedata->url(['page' => $takedata->pageparams->page - 1]), $this->output->larrow()); } $a = new stdClass(); @@ -646,10 +646,10 @@ private function construct_take_controls(take_data $takedata) { $a->numpages = $numberofpages; $text = get_string('pageof', 'attendance', $a); $controls .= html_writer::tag('span', $text, - array('class' => 'attbtn')); + ['class' => 'attbtn']); if ($takedata->pageparams->page < $numberofpages) { - $controls .= html_writer::link($takedata->url(array('page' => $takedata->pageparams->page + 1, - 'perpage' => $takedata->pageparams->perpage)), $this->output->rarrow()); + $controls .= html_writer::link($takedata->url(['page' => $takedata->pageparams->page + 1, + 'perpage' => $takedata->pageparams->perpage, ]), $this->output->rarrow()); } } @@ -661,29 +661,29 @@ private function construct_take_controls(take_data $takedata) { $controls .= html_writer::empty_tag('br'); - $options = array( + $options = [ mod_attendance_take_page_params::SORTED_LIST => get_string('sortedlist', 'attendance'), - mod_attendance_take_page_params::SORTED_GRID => get_string('sortedgrid', 'attendance')); + mod_attendance_take_page_params::SORTED_GRID => get_string('sortedgrid', 'attendance'), ]; $select = new single_select($takedata->url(), 'viewmode', $options, $takedata->pageparams->viewmode, null); $select->set_label(get_string('viewmode', 'attendance')); $select->class = 'singleselect inline'; $controls .= $this->output->render($select); if ($takedata->pageparams->viewmode == mod_attendance_take_page_params::SORTED_LIST) { - $options = array( + $options = [ 0 => get_string('donotusepaging', 'attendance'), - get_config('attendance', 'resultsperpage') => get_config('attendance', 'resultsperpage')); + get_config('attendance', 'resultsperpage') => get_config('attendance', 'resultsperpage'), ]; $select = new single_select($takedata->url(), 'perpage', $options, $takedata->pageparams->perpage, null); $select->class = 'singleselect inline'; $controls .= $this->output->render($select); } if ($takedata->pageparams->viewmode == mod_attendance_take_page_params::SORTED_GRID) { - $options = array (1 => '1 '.get_string('column', 'attendance'), '2 '.get_string('columns', 'attendance'), + $options = [1 => '1 '.get_string('column', 'attendance'), '2 '.get_string('columns', 'attendance'), '3 '.get_string('columns', 'attendance'), '4 '.get_string('columns', 'attendance'), '5 '.get_string('columns', 'attendance'), '6 '.get_string('columns', 'attendance'), '7 '.get_string('columns', 'attendance'), '8 '.get_string('columns', 'attendance'), - '9 '.get_string('columns', 'attendance'), '10 '.get_string('columns', 'attendance')); + '9 '.get_string('columns', 'attendance'), '10 '.get_string('columns', 'attendance'), ]; $select = new single_select($takedata->url(), 'gridcols', $options, $takedata->pageparams->gridcols, null); $select->class = 'singleselect inline'; $controls .= $this->output->render($select); @@ -693,13 +693,13 @@ private function construct_take_controls(take_data $takedata) { $controls .= html_writer::empty_tag('br'); $controls .= html_writer::empty_tag('br'); - $options = array(); + $options = []; foreach ($takedata->sessions4copy as $sess) { $start = attendance_strftimehm($sess->sessdate); $end = $sess->duration ? ' - '.attendance_strftimehm($sess->sessdate + $sess->duration) : ''; $options[$sess->id] = $start . $end; } - $select = new single_select($takedata->url(array(), array('copyfrom')), 'copyfrom', $options); + $select = new single_select($takedata->url([], ['copyfrom']), 'copyfrom', $options); $select->set_label(get_string('copyfrom', 'attendance')); $select->class = 'singleselect inline'; $controls .= $this->output->render($select); @@ -718,8 +718,8 @@ private function statusdropdown() { if (empty($pref)) { $pref = 'unselected'; } - $options = array('all' => get_string('statusall', 'attendance'), - 'unselected' => get_string('statusunselected', 'attendance')); + $options = ['all' => get_string('statusall', 'attendance'), + 'unselected' => get_string('statusunselected', 'attendance'), ]; $select = new \single_select(new \moodle_url('/'), 'setallstatus-select', $options, $pref, null, 'setallstatus-select'); @@ -737,14 +737,14 @@ private function statusdropdown() { protected function render_attendance_take_list(take_data $takedata) { global $CFG; $table = new html_table(); - $table->head = array( - $this->construct_fullname_head($takedata) - ); - $table->align = array('left'); - $table->size = array(''); + $table->head = [ + $this->construct_fullname_head($takedata), + ]; + $table->align = ['left']; + $table->size = ['']; $table->wrap[0] = 'nowrap'; // Check if extra useridentity fields need to be added. - $extrasearchfields = array(); + $extrasearchfields = []; if (!empty($CFG->showuseridentity) && has_capability('moodle/site:viewuseridentity', $takedata->att->context)) { $extrasearchfields = explode(',', $CFG->showuseridentity); } @@ -753,8 +753,8 @@ protected function render_attendance_take_list(take_data $takedata) { $table->align[] = 'left'; } foreach ($takedata->statuses as $st) { - $table->head[] = html_writer::link("#", $st->acronym, array('id' => 'checkstatus'.$st->id, - 'title' => get_string('setallstatusesto', 'attendance', $st->description))); + $table->head[] = html_writer::link("#", $st->acronym, ['id' => 'checkstatus'.$st->id, + 'title' => get_string('setallstatusesto', 'attendance', $st->description)]); $table->align[] = 'center'; $table->size[] = '20px'; // JS to select all radios of this status and prevent default behaviour of # link. @@ -790,13 +790,13 @@ protected function render_attendance_take_list(take_data $takedata) { $cell = new html_table_cell(html_writer::div($this->output->render($this->statusdropdown()), 'setallstatuses')); $row->cells[] = $cell; foreach ($takedata->statuses as $st) { - $attribs = array( + $attribs = [ 'id' => 'radiocheckstatus'.$st->id, 'type' => 'radio', 'title' => get_string('setallstatusesto', 'attendance', $st->description), 'name' => 'setallstatuses', 'class' => "st{$st->id}", - ); + ]; $row->cells[] = html_writer::empty_tag('input', $attribs); // Select all radio buttons of the same status. $this->page->requires->js_amd_inline(" @@ -820,7 +820,7 @@ protected function render_attendance_take_list(take_data $takedata) { foreach ($takedata->users as $user) { $i++; $row = new html_table_row(); - $fullname = html_writer::link($takedata->url_view(array('studentid' => $user->id)), fullname($user)); + $fullname = html_writer::link($takedata->url_view(['studentid' => $user->id]), fullname($user)); $fullname = $this->user_picture($user).$fullname; // Show different picture if it is a temporary user. $ucdata = $this->construct_take_user_controls($takedata, $user); @@ -866,11 +866,11 @@ protected function render_attendance_take_grid(take_data $takedata) { $table->attributes['class'] = 'generaltable takegrid'; $table->headspan = $takedata->pageparams->gridcols; - $head = array(); + $head = []; $head[] = html_writer::div($this->output->render($this->statusdropdown()), 'setallstatuses'); foreach ($takedata->statuses as $st) { - $head[] = html_writer::link("#", $st->acronym, array('id' => 'checkstatus'.$st->id, - 'title' => get_string('setallstatusesto', 'attendance', $st->description))); + $head[] = html_writer::link("#", $st->acronym, ['id' => 'checkstatus'.$st->id, + 'title' => get_string('setallstatusesto', 'attendance', $st->description)]); // JS to select all radios of this status and prevent default behaviour of # link. $this->page->requires->js_amd_inline(" require(['jquery', 'core_user/repository'], function($, UserRepository) { @@ -892,10 +892,10 @@ protected function render_attendance_take_grid(take_data $takedata) { $i = 0; $row = new html_table_row(); foreach ($takedata->users as $user) { - $celltext = $this->user_picture($user, array('size' => 100)); // Show different picture if it is a temporary user. + $celltext = $this->user_picture($user, ['size' => 100]); // Show different picture if it is a temporary user. $celltext .= html_writer::empty_tag('br'); - $fullname = html_writer::link($takedata->url_view(array('studentid' => $user->id)), fullname($user)); - $celltext .= html_writer::tag('span', $fullname, array('class' => 'fullname')); + $fullname = html_writer::link($takedata->url_view(['studentid' => $user->id]), fullname($user)); + $celltext .= html_writer::tag('span', $fullname, ['class' => 'fullname']); $celltext .= html_writer::empty_tag('br'); $ucdata = $this->construct_take_user_controls($takedata, $user); $celltext .= is_array($ucdata['text']) ? implode('', $ucdata['text']) : $ucdata['text']; @@ -942,8 +942,8 @@ private function construct_fullname_head($data) { $url->param('sort', ATT_SORT_LASTNAME); $lastname = html_writer::link($url, get_string('lastname')); } else { - $firstname = html_writer::link($data->url(array('sort' => ATT_SORT_FIRSTNAME)), get_string('firstname')); - $lastname = html_writer::link($data->url(array('sort' => ATT_SORT_LASTNAME)), get_string('lastname')); + $firstname = html_writer::link($data->url(['sort' => ATT_SORT_FIRSTNAME]), get_string('firstname')); + $lastname = html_writer::link($data->url(['sort' => ATT_SORT_LASTNAME]), get_string('lastname')); } if ($CFG->fullnamedisplay == 'lastname firstname') { @@ -963,7 +963,7 @@ private function construct_fullname_head($data) { * @return array */ private function construct_take_user_controls(take_data $takedata, $user) { - $celldata = array(); + $celldata = []; if ($user->enrolmentend && $user->enrolmentend < $takedata->sessioninfo->sessdate) { $celldata['text'] = get_string('enrolmentend', 'attendance', userdate($user->enrolmentend, '%d.%m.%Y')); $celldata['colspan'] = count($takedata->statuses) + 1; @@ -978,13 +978,13 @@ private function construct_take_user_controls(take_data $takedata, $user) { $celldata['class'] = 'userwithoutdata'; } - $celldata['text'] = array(); + $celldata['text'] = []; foreach ($takedata->statuses as $st) { - $params = array( + $params = [ 'type' => 'radio', 'name' => 'user'.$user->id, 'class' => 'st'.$st->id, - 'value' => $st->id); + 'value' => $st->id, ]; if (array_key_exists($user->id, $takedata->sessionlog) && $st->id == $takedata->sessionlog[$user->id]->statusid) { $params['checked'] = ''; } @@ -997,10 +997,10 @@ private function construct_take_user_controls(take_data $takedata, $user) { $celldata['text'][] = $input; } - $params = array( + $params = [ 'type' => 'text', 'name' => 'remarks'.$user->id, - 'maxlength' => 255); + 'maxlength' => 255, ]; if (array_key_exists($user->id, $takedata->sessionlog)) { $params['value'] = $takedata->sessionlog[$user->id]->remarks; } @@ -1024,7 +1024,7 @@ private function construct_take_user_controls(take_data $takedata, $user) { * @return array */ private function construct_take_session_controls(take_data $takedata, $user) { - $celldata = array(); + $celldata = []; $celldata['remarks'] = ''; if ($user->enrolmentend && $user->enrolmentend < $takedata->sessioninfo->sessdate) { $celldata['text'] = get_string('enrolmentend', 'attendance', userdate($user->enrolmentend, '%d.%m.%Y')); @@ -1040,13 +1040,13 @@ private function construct_take_session_controls(take_data $takedata, $user) { $celldata['class'] = 'userwithoutdata'; } - $celldata['text'] = array(); + $celldata['text'] = []; foreach ($takedata->statuses as $st) { - $params = array( + $params = [ 'type' => 'radio', 'name' => 'user'.$user->id.'sess'.$takedata->sessioninfo->id, 'class' => 'st'.$st->id, - 'value' => $st->id); + 'value' => $st->id, ]; if (array_key_exists($user->id, $takedata->sessionlog) && $st->id == $takedata->sessionlog[$user->id]->statusid) { $params['checked'] = ''; } @@ -1059,10 +1059,10 @@ private function construct_take_session_controls(take_data $takedata, $user) { $celldata['text'][] = $input; } - $params = array( + $params = [ 'type' => 'text', 'name' => 'remarks'.$user->id.'sess'.$takedata->sessioninfo->id, - 'maxlength' => 255); + 'maxlength' => 255, ]; if (array_key_exists($user->id, $takedata->sessionlog)) { $params['value'] = $takedata->sessionlog[$user->id]->remarks; } @@ -1103,9 +1103,9 @@ protected function render_user_data(user_data $userdata) { $table = new html_table(); $table->attributes['class'] = 'userinfobox'; - $table->colclasses = array('left side', ''); + $table->colclasses = ['left side', '']; // Show different picture if it is a temporary user. - $table->data[0][] = $this->user_picture($userdata->user, array('size' => 100)); + $table->data[0][] = $this->user_picture($userdata->user, ['size' => 100]); $table->data[0][] = $this->construct_user_data($userdata); $o .= html_writer::table($table); @@ -1121,23 +1121,23 @@ protected function render_user_data(user_data $userdata) { * @return string */ protected function render_user_report_tabs(user_data $userdata) { - $tabs = array(); + $tabs = []; $tabs[] = new tabobject(mod_attendance_view_page_params::MODE_THIS_COURSE, - $userdata->url()->out(true, array('mode' => mod_attendance_view_page_params::MODE_THIS_COURSE)), + $userdata->url()->out(true, ['mode' => mod_attendance_view_page_params::MODE_THIS_COURSE]), get_string('thiscourse', 'attendance')); // Skip the 'all courses' and 'all sessions' tabs for 'temporary' users. if ($userdata->user->type == 'standard') { $tabs[] = new tabobject(mod_attendance_view_page_params::MODE_ALL_COURSES, - $userdata->url()->out(true, array('mode' => mod_attendance_view_page_params::MODE_ALL_COURSES)), + $userdata->url()->out(true, ['mode' => mod_attendance_view_page_params::MODE_ALL_COURSES]), get_string('allcourses', 'attendance')); $tabs[] = new tabobject(mod_attendance_view_page_params::MODE_ALL_SESSIONS, - $userdata->url()->out(true, array('mode' => mod_attendance_view_page_params::MODE_ALL_SESSIONS)), + $userdata->url()->out(true, ['mode' => mod_attendance_view_page_params::MODE_ALL_SESSIONS]), get_string('allsessions', 'attendance')); } - return print_tabs(array($tabs), $userdata->pageparams->mode, null, null, true); + return print_tabs([$tabs], $userdata->pageparams->mode, null, null, true); } /** @@ -1167,7 +1167,7 @@ private function construct_user_data(user_data $userdata) { $o .= html_writer::start_div('allsessionssummary row'); $o .= html_writer::start_div('userinfo col-auto mr-xl-auto'); $o .= html_writer::start_div('float-left'); - $o .= $this->user_picture($userdata->user, array('size' => 100, 'class' => 'userpicture float-left')); + $o .= $this->user_picture($userdata->user, ['size' => 100, 'class' => 'userpicture float-left']); $o .= html_writer::end_div(); $o .= html_writer::start_div('float-right'); $o .= $allsessions->summary; @@ -1180,25 +1180,25 @@ private function construct_user_data(user_data $userdata) { $o .= $allsessions->detail; } else { $table = new html_table(); - $table->head = array(get_string('course'), + $table->head = [get_string('course'), get_string('pluginname', 'mod_attendance'), get_string('sessionscompleted', 'attendance'), get_string('pointssessionscompleted', 'attendance'), - get_string('percentagesessionscompleted', 'attendance')); - $table->align = array('left', 'left', 'center', 'center', 'center'); - $table->colclasses = array('colcourse', 'colatt', 'colsessionscompleted', - 'colpointssessionscompleted', 'colpercentagesessionscompleted'); + get_string('percentagesessionscompleted', 'attendance'), ]; + $table->align = ['left', 'left', 'center', 'center', 'center']; + $table->colclasses = ['colcourse', 'colatt', 'colsessionscompleted', + 'colpointssessionscompleted', 'colpercentagesessionscompleted', ]; $table2 = clone($table); // Duplicate table for ungraded sessions. $totalattendance = 0; $totalpercentage = 0; foreach ($userdata->coursesatts as $ca) { $row = new html_table_row(); - $courseurl = new moodle_url('/course/view.php', array('id' => $ca->courseid)); + $courseurl = new moodle_url('/course/view.php', ['id' => $ca->courseid]); $row->cells[] = html_writer::link($courseurl, $ca->coursefullname); - $attendanceurl = new moodle_url('/mod/attendance/view.php', array('id' => $ca->cmid, + $attendanceurl = new moodle_url('/mod/attendance/view.php', ['id' => $ca->cmid, 'studentid' => $userdata->user->id, - 'view' => ATT_VIEW_ALL)); + 'view' => ATT_VIEW_ALL]); $row->cells[] = html_writer::link($attendanceurl, $ca->attname); $usersummary = new stdClass(); if (isset($userdata->summary[$ca->attid])) { @@ -1236,7 +1236,7 @@ private function construct_user_data(user_data $userdata) { $col2 = new html_table_cell($average); $col2->style = 'text-align: center'; - $row->cells = array($col, $col2); + $row->cells = [$col, $col2]; $table->data[] = $row; if (!empty($table2->data) && !empty($table->data)) { @@ -1276,10 +1276,10 @@ private function construct_user_sessions_log(user_data $userdata) { $table = new html_table(); $table->attributes['class'] = 'generaltable attwidth boxaligncenter'; - $table->head = array(); - $table->align = array(); - $table->size = array(); - $table->colclasses = array(); + $table->head = []; + $table->align = []; + $table->size = []; + $table->colclasses = []; if (!$shortform) { $table->head[] = get_string('sessiontypeshort', 'attendance'); $table->align[] = ''; @@ -1289,9 +1289,9 @@ private function construct_user_sessions_log(user_data $userdata) { $table->head[] = get_string('date'); $table->head[] = get_string('description', 'attendance'); - $table->align = array_merge($table->align, array('', 'left')); - $table->colclasses = array_merge($table->colclasses, array('datecol', 'desccol')); - $table->size = array_merge($table->size, array('1px', '*')); + $table->align = array_merge($table->align, ['', 'left']); + $table->colclasses = array_merge($table->colclasses, ['datecol', 'desccol']); + $table->size = array_merge($table->size, ['1px', '*']); // Add custom fields. $customfields = []; @@ -1314,9 +1314,9 @@ private function construct_user_sessions_log(user_data $userdata) { $table->head[] = get_string('points', 'attendance'); $table->head[] = get_string('remarks', 'attendance'); - $table->align = array_merge($table->align, array('center', 'center', 'center')); - $table->colclasses = array_merge($table->colclasses, array('statuscol', 'pointscol', 'remarkscol')); - $table->size = array_merge($table->size, array('*', '1px', '*')); + $table->align = array_merge($table->align, ['center', 'center', 'center']); + $table->colclasses = array_merge($table->colclasses, ['statuscol', 'pointscol', 'remarkscol']); + $table->size = array_merge($table->size, ['*', '1px', '*']); if (has_capability('mod/attendance:takeattendances', $context)) { $table->head[] = get_string('action'); @@ -1357,7 +1357,7 @@ private function construct_user_sessions_log(user_data $userdata) { list($canmark, $reason) = attendance_can_student_mark($sess, false); if (attendance_check_allow_update($sess->id) && $canmark) { $url = new moodle_url('/mod/attendance/attendance.php', - array('sessid' => $sess->id, 'sesskey' => sesskey())); + ['sessid' => $sess->id, 'sesskey' => sesskey()]); $updatelink = "
".html_writer::link($url, get_string('updateattendance', 'attendance')); } $row->cells[] = $status->description.$updatelink; @@ -1380,7 +1380,7 @@ private function construct_user_sessions_log(user_data $userdata) { // Student can mark their own attendance. // URL to the page that lets the student modify their attendance. $url = new moodle_url('/mod/attendance/attendance.php', - array('sessid' => $sess->id, 'sesskey' => sesskey())); + ['sessid' => $sess->id, 'sesskey' => sesskey()]); if (attendance_session_open_for_students($sess)) { if ($sess->rotateqrcode == 1) { $url = new moodle_url('/mod/attendance/attendance.php'); @@ -1409,9 +1409,9 @@ private function construct_user_sessions_log(user_data $userdata) { } if (has_capability('mod/attendance:takeattendances', $context)) { - $params = array('id' => $userdata->filtercontrols->cm->id, + $params = ['id' => $userdata->filtercontrols->cm->id, 'sessionid' => $sess->id, - 'grouptype' => $sess->groupid); + 'grouptype' => $sess->groupid, ]; $url = new moodle_url('/mod/attendance/take.php', $params); $icon = $this->output->pix_icon('redo', get_string('changeattendance', 'attendance'), 'attendance'); $row->cells[] = html_writer::link($url, $icon); @@ -1444,10 +1444,10 @@ private function construct_user_allsessions_log(user_data $userdata) { $table = new html_table(); $table->attributes['class'] = 'generaltable attwidth boxaligncenter allsessions'; - $table->head = array(); - $table->align = array(); - $table->size = array(); - $table->colclasses = array(); + $table->head = []; + $table->align = []; + $table->size = []; + $table->colclasses = []; $colcount = 0; $summarywidth = 0; @@ -1553,26 +1553,26 @@ private function construct_user_allsessions_log(user_data $userdata) { $summarywidth++; } - $statusmaxpoints = array(); + $statusmaxpoints = []; foreach ($userdata->statuses as $attid => $attstatuses) { $statusmaxpoints[$attid] = attendance_get_statusset_maxpoints($attstatuses); } - $lastgroup = array(null, null); - $groups = array(); - $stats = array( - 'course' => array(), - 'activity' => array(), - 'date' => array(), - 'overall' => array( + $lastgroup = [null, null]; + $groups = []; + $stats = [ + 'course' => [], + 'activity' => [], + 'date' => [], + 'overall' => [ 'points' => 0, 'maxpointstodate' => 0, 'maxpoints' => 0, 'pcpointstodate' => null, 'pcpoints' => null, - 'statuses' => array() - ) - ); + 'statuses' => [], + ], + ]; $group = null; if ($userdata->sessionslog) { foreach ($userdata->sessionslog as $sess) { @@ -1582,18 +1582,18 @@ private function construct_user_allsessions_log(user_data $userdata) { if ($group !== null) { array_push($groups, $group); } - $group = array(); + $group = []; $lastgroup[0] = $weekformat; } if (!array_key_exists($weekformat, $stats['date'])) { - $stats['date'][$weekformat] = array( + $stats['date'][$weekformat] = [ 'points' => 0, 'maxpointstodate' => 0, 'maxpoints' => 0, 'pcpointstodate' => null, 'pcpoints' => null, - 'statuses' => array() - ); + 'statuses' => [], + ]; } $statussetmaxpoints = $statusmaxpoints[$sess->attendanceid]; // Ensure all possible acronyms for current sess's statusset are available as @@ -1605,11 +1605,11 @@ private function construct_user_allsessions_log(user_data $userdata) { if ($attstatus->setnumber === $sess->statusset) { if (!array_key_exists($attstatus->acronym, $stats['date'][$weekformat]['statuses'])) { $stats['date'][$weekformat]['statuses'][$attstatus->acronym] = - array('count' => 0, 'description' => $attstatus->description); + ['count' => 0, 'description' => $attstatus->description]; } if (!array_key_exists($attstatus->acronym, $stats['overall']['statuses'])) { $stats['overall']['statuses'][$attstatus->acronym] = - array('count' => 0, 'description' => $attstatus->description); + ['count' => 0, 'description' => $attstatus->description]; } } } @@ -1634,19 +1634,19 @@ private function construct_user_allsessions_log(user_data $userdata) { if ($group !== null) { array_push($groups, $group); } - $group = array(); + $group = []; $lastgroup[0] = $sess->courseid; $lastgroup[1] = $sess->cmid; } if (!array_key_exists($sess->courseid, $stats['course'])) { - $stats['course'][$sess->courseid] = array( + $stats['course'][$sess->courseid] = [ 'points' => 0, 'maxpointstodate' => 0, 'maxpoints' => 0, 'pcpointstodate' => null, 'pcpoints' => null, - 'statuses' => array() - ); + 'statuses' => [], + ]; } $statussetmaxpoints = $statusmaxpoints[$sess->attendanceid]; // Ensure all possible acronyms for current sess's statusset are available as @@ -1658,11 +1658,11 @@ private function construct_user_allsessions_log(user_data $userdata) { if ($attstatus->setnumber === $sess->statusset) { if (!array_key_exists($attstatus->acronym, $stats['course'][$sess->courseid]['statuses'])) { $stats['course'][$sess->courseid]['statuses'][$attstatus->acronym] = - array('count' => 0, 'description' => $attstatus->description); + ['count' => 0, 'description' => $attstatus->description]; } if (!array_key_exists($attstatus->acronym, $stats['overall']['statuses'])) { $stats['overall']['statuses'][$attstatus->acronym] = - array('count' => 0, 'description' => $attstatus->description); + ['count' => 0, 'description' => $attstatus->description]; } } } @@ -1680,14 +1680,14 @@ private function construct_user_allsessions_log(user_data $userdata) { $stats['overall']['maxpoints'] += $statussetmaxpoints[$sess->statusset]; if (!array_key_exists($sess->cmid, $stats['activity'])) { - $stats['activity'][$sess->cmid] = array( + $stats['activity'][$sess->cmid] = [ 'points' => 0, 'maxpointstodate' => 0, 'maxpoints' => 0, 'pcpointstodate' => null, 'pcpoints' => null, - 'statuses' => array() - ); + 'statuses' => [], + ]; } $statussetmaxpoints = $statusmaxpoints[$sess->attendanceid]; // Ensure all possible acronyms for current sess's statusset are available as @@ -1699,11 +1699,11 @@ private function construct_user_allsessions_log(user_data $userdata) { if ($attstatus->setnumber === $sess->statusset) { if (!array_key_exists($attstatus->acronym, $stats['activity'][$sess->cmid]['statuses'])) { $stats['activity'][$sess->cmid]['statuses'][$attstatus->acronym] = - array('count' => 0, 'description' => $attstatus->description); + ['count' => 0, 'description' => $attstatus->description]; } if (!array_key_exists($attstatus->acronym, $stats['overall']['statuses'])) { $stats['overall']['statuses'][$attstatus->acronym] = - array('count' => 0, 'description' => $attstatus->description); + ['count' => 0, 'description' => $attstatus->description]; } } } @@ -1754,7 +1754,7 @@ private function construct_user_allsessions_log(user_data $userdata) { $summarytable->data[] = $row; $allsessions->summary = html_writer::table($summarytable); - $lastgroup = array(null, null); + $lastgroup = [null, null]; foreach ($groups as $group) { $statussetmaxpoints = $statusmaxpoints[$sess->attendanceid]; @@ -1795,7 +1795,7 @@ private function construct_user_allsessions_log(user_data $userdata) { $table->data[] = $row; $row = new html_table_row(); $row->attributes['class'] = 'grouper'; - $summary = array(); + $summary = []; foreach ($stats['date'][$weekformat]['statuses'] as $acronym => $status) { array_push($summary, html_writer::tag('b', $acronym) . $status['count']); } @@ -1818,7 +1818,7 @@ private function construct_user_allsessions_log(user_data $userdata) { $cell->rowspan = 2; } $row->cells[] = $cell; - $courseurl = new moodle_url('/course/view.php', array('id' => $sess->courseid)); + $courseurl = new moodle_url('/course/view.php', ['id' => $sess->courseid]); $cell = new html_table_cell(get_string('course', 'attendance') . ": " . html_writer::link($courseurl, $sess->cname)); $cell->colspan = $colcount - $summarywidth; @@ -1841,7 +1841,7 @@ private function construct_user_allsessions_log(user_data $userdata) { $table->data[] = $row; $row = new html_table_row(); $row->attributes['class'] = 'grouper'; - $summary = array(); + $summary = []; foreach ($stats['course'][$sess->courseid]['statuses'] as $acronym => $status) { array_push($summary, html_writer::tag('b', $acronym) . $status['count']); } @@ -1859,9 +1859,9 @@ private function construct_user_allsessions_log(user_data $userdata) { $cell = new html_table_cell(); $cell->rowspan = count($group) + 2; $row->cells[] = $cell; - $attendanceurl = new moodle_url('/mod/attendance/view.php', array('id' => $sess->cmid, + $attendanceurl = new moodle_url('/mod/attendance/view.php', ['id' => $sess->cmid, 'studentid' => $userdata->user->id, - 'view' => ATT_VIEW_ALL)); + 'view' => ATT_VIEW_ALL]); $cell = new html_table_cell(get_string('pluginname', 'mod_attendance') . ": " . html_writer::link($attendanceurl, $sess->attname)); $cell->colspan = $colcount - $summarywidth; @@ -1884,7 +1884,7 @@ private function construct_user_allsessions_log(user_data $userdata) { $table->data[] = $row; $row = new html_table_row(); $row->attributes['class'] = 'grouper'; - $summary = array(); + $summary = []; foreach ($stats['activity'][$sess->cmid]['statuses'] as $acronym => $status) { array_push($summary, html_writer::tag('b', $acronym) . $status['count']); } @@ -1910,15 +1910,15 @@ private function construct_user_allsessions_log(user_data $userdata) { $row->cells[] = userdate($sess->sessdate, get_string('strftimedmw', 'attendance')) . " ". $this->construct_time($sess->sessdate, $sess->duration); - $courseurl = new moodle_url('/course/view.php', array('id' => $sess->courseid)); + $courseurl = new moodle_url('/course/view.php', ['id' => $sess->courseid]); $row->cells[] = html_writer::link($courseurl, $sess->cname); } // Need activity column unless we are using activity to group. if ($groupby !== 'activity') { - $attendanceurl = new moodle_url('/mod/attendance/view.php', array('id' => $sess->cmid, + $attendanceurl = new moodle_url('/mod/attendance/view.php', ['id' => $sess->cmid, 'studentid' => $userdata->user->id, - 'view' => ATT_VIEW_ALL)); + 'view' => ATT_VIEW_ALL]); $row->cells[] = html_writer::link($attendanceurl, $sess->attname); } @@ -1930,9 +1930,9 @@ private function construct_user_allsessions_log(user_data $userdata) { $sesscontext = context_module::instance($sess->cmid); if (has_capability('mod/attendance:takeattendances', $sesscontext)) { - $sessionurl = new moodle_url('/mod/attendance/take.php', array('id' => $sess->cmid, + $sessionurl = new moodle_url('/mod/attendance/take.php', ['id' => $sess->cmid, 'sessionid' => $sess->id, - 'grouptype' => $sess->groupid)); + 'grouptype' => $sess->groupid]); $description = html_writer::link($sessionurl, $sess->description); } else { $description = $sess->description; @@ -1974,7 +1974,7 @@ private function construct_user_allsessions_log(user_data $userdata) { return ($x->setnumber == $sess->statusset); }); $takedata->updatemode = true; - $takedata->sessionlog = array($userdata->user->id => $sess); + $takedata->sessionlog = [$userdata->user->id => $sess]; $takedata->pageparams = new stdClass(); $takedata->pageparams->viewmode = mod_attendance_take_page_params::SORTED_GRID; $ucdata = $this->construct_take_session_controls($takedata, $userdata->user); @@ -2028,7 +2028,7 @@ private function construct_user_allsessions_log(user_data $userdata) { // URL to the page that lets the student modify their attendance. $url = new moodle_url('/mod/attendance/attendance.php', - array('sessid' => $sess->id, 'sesskey' => sesskey())); + ['sessid' => $sess->id, 'sesskey' => sesskey()]); if (attendance_session_open_for_students($sess)) { $cell = new html_table_cell(html_writer::link($url, get_string('submitattendance', 'attendance'))); } else { @@ -2050,10 +2050,10 @@ private function construct_user_allsessions_log(user_data $userdata) { if (!empty($USER->attendanceediting)) { $row = new html_table_row(); - $params = array( + $params = [ 'type' => 'submit', 'class' => 'btn btn-primary', - 'value' => get_string('save', 'attendance')); + 'value' => get_string('save', 'attendance'), ]; $cell = new html_table_cell(html_writer::tag('center', html_writer::empty_tag('input', $params))); $cell->colspan = $colcount + (($groupby == 'activity') ? 2 : 1); $row->cells[] = $cell; @@ -2065,12 +2065,12 @@ private function construct_user_allsessions_log(user_data $userdata) { if (!empty($USER->attendanceediting)) { $formtext = html_writer::start_div('no-overflow'); $formtext .= $logtext; - $formtext .= html_writer::input_hidden_params($userdata->url(array('sesskey' => sesskey()))); + $formtext .= html_writer::input_hidden_params($userdata->url(['sesskey' => sesskey()])); $formtext .= html_writer::end_div(); // Could use userdata->urlpath if not private or userdata->url_path() if existed, but '' turns // out to DTRT. - $logtext = html_writer::tag('form', $formtext, array('method' => 'post', 'action' => '', - 'id' => 'attendancetakeform')); + $logtext = html_writer::tag('form', $formtext, ['method' => 'post', 'action' => '', + 'id' => 'attendancetakeform']); } $allsessions->detail = $logtext; return $allsessions; @@ -2107,7 +2107,7 @@ protected function render_report_data(report_data $reportdata) { $userrows = $this->get_user_rows($reportdata); if ($reportdata->pageparams->view == ATT_VIEW_SUMMARY) { - $sessionrows = array(); + $sessionrows = []; } else { $sessionrows = $this->get_session_rows($reportdata); } @@ -2131,8 +2131,8 @@ protected function render_report_data(report_data $reportdata) { // Extract rows from each part and collate them into one row each. $sessiondetailsleft = $reportdata->pageparams->sessiondetailspos == 'left'; foreach ($userrows as $index => $row) { - $summaryrow = isset($summaryrows[$index]->cells) ? $summaryrows[$index]->cells : array(); - $sessionrow = isset($sessionrows[$index]->cells) ? $sessionrows[$index]->cells : array(); + $summaryrow = isset($summaryrows[$index]->cells) ? $summaryrows[$index]->cells : []; + $sessionrow = isset($sessionrows[$index]->cells) ? $sessionrows[$index]->cells : []; if ($sessiondetailsleft) { $row->cells = array_merge($row->cells, $sessionrow, $acronymrows[$index]->cells, $summaryrow); } else { @@ -2143,19 +2143,19 @@ protected function render_report_data(report_data $reportdata) { if ($bulkmessagecapability) { // Require that the user can bulk message users. // Display check boxes that will allow the user to send a message to the students that have been checked. - $output = html_writer::empty_tag('input', array('name' => 'sesskey', 'type' => 'hidden', 'value' => sesskey())); - $output .= html_writer::empty_tag('input', array('name' => 'id', 'type' => 'hidden', 'value' => $COURSE->id)); - $output .= html_writer::empty_tag('input', array('name' => 'returnto', 'type' => 'hidden', 'value' => s(me()))); + $output = html_writer::empty_tag('input', ['name' => 'sesskey', 'type' => 'hidden', 'value' => sesskey()]); + $output .= html_writer::empty_tag('input', ['name' => 'id', 'type' => 'hidden', 'value' => $COURSE->id]); + $output .= html_writer::empty_tag('input', ['name' => 'returnto', 'type' => 'hidden', 'value' => s(me())]); $output .= html_writer::start_div('attendancereporttable'); $output .= html_writer::table($table).html_writer::tag('div', get_string('users').': '.count($reportdata->users)); $output .= html_writer::end_div(); $output .= html_writer::tag('div', - html_writer::empty_tag('input', array('type' => 'submit', + html_writer::empty_tag('input', ['type' => 'submit', 'value' => get_string('messageselectadd'), - 'class' => 'btn btn-secondary')), - array('class' => 'buttons')); + 'class' => 'btn btn-secondary', ]), + ['class' => 'buttons']); $url = new moodle_url('/mod/attendance/messageselect.php'); - return html_writer::tag('form', $output, array('action' => $url->out(), 'method' => 'post')); + return html_writer::tag('form', $output, ['action' => $url->out(), 'method' => 'post']); } else { return html_writer::table($table).html_writer::tag('div', get_string('users').': '.count($reportdata->users)); } @@ -2169,7 +2169,7 @@ protected function render_report_data(report_data $reportdata) { * @return array Array of html_table_row objects */ protected function get_user_rows(report_data $reportdata) { - $rows = array(); + $rows = []; $bulkmessagecapability = has_capability('moodle/course:bulkmessaging', $this->page->context); $extrafields = \core_user\fields::for_identity($reportdata->att->context, true)->get_required_fields(); @@ -2187,7 +2187,7 @@ protected function get_user_rows(report_data $reportdata) { $url = $reportdata->att->url_report($params); $text .= $this->output->action_icon($url, new pix_icon('t/switch_plus', get_string('showextrauserdetails', 'attendance')), null, null); - $extrafields = array(); + $extrafields = []; } } $usercolspan = count($extrafields); @@ -2204,7 +2204,7 @@ protected function get_user_rows(report_data $reportdata) { $row = new html_table_row(); $text = ''; if ($bulkmessagecapability) { - $text .= html_writer::checkbox('cb_selector', 0, false, '', array('id' => 'cb_selector')); + $text .= html_writer::checkbox('cb_selector', 0, false, '', ['id' => 'cb_selector']); } $text .= $this->construct_fullname_head($reportdata); $cell = $this->build_header_cell($text, false, false); @@ -2221,9 +2221,9 @@ protected function get_user_rows(report_data $reportdata) { $row = new html_table_row(); $text = ''; if ($bulkmessagecapability) { - $text .= html_writer::checkbox('user'.$user->id, 'on', false, '', array('class' => 'attendancesesscheckbox')); + $text .= html_writer::checkbox('user'.$user->id, 'on', false, '', ['class' => 'attendancesesscheckbox']); } - $text .= html_writer::link($reportdata->url_view(array('studentid' => $user->id)), fullname($user)); + $text .= html_writer::link($reportdata->url_view(['studentid' => $user->id]), fullname($user)); $cell = $this->build_data_cell($text, false, false, null, null, false); $cell->attributes['class'] = $cell->attributes['class'] . ' headcol'; $row->cells[] = $cell; @@ -2256,9 +2256,9 @@ protected function get_user_rows(report_data $reportdata) { * @return array Array of html_table_row objects */ protected function get_acronym_rows(report_data $reportdata, $startwithcontrast=false) { - $rows = array(); + $rows = []; - $summarycells = array(); + $summarycells = []; $row1 = new html_table_row(); $row2 = new html_table_row(); @@ -2317,10 +2317,10 @@ protected function get_acronym_rows(report_data $reportdata, $startwithcontrast= * @return array Array of html_table_row objects */ protected function get_summary_rows(report_data $reportdata, $startwithcontrast=false) { - $rows = array(); + $rows = []; $contrast = $startwithcontrast; - $summarycells = array(); + $summarycells = []; $row1 = new html_table_row(); $helpicon = $this->output->help_icon('oversessionstaken', 'attendance'); @@ -2404,7 +2404,7 @@ protected function get_summary_rows(report_data $reportdata, $startwithcontrast= */ protected function get_session_rows(report_data $reportdata, $startwithcontrast=false) { - $rows = array(); + $rows = []; $row = new html_table_row(); @@ -2451,32 +2451,32 @@ protected function get_session_rows(report_data $reportdata, $startwithcontrast= $sesstext = userdate($sess->sessdate, get_string('strftimedm', 'attendance')); $sesstext .= html_writer::empty_tag('br'); $sesstext .= attendance_strftimehm($sess->sessdate); - $capabilities = array( + $capabilities = [ 'mod/attendance:takeattendances', - 'mod/attendance:changeattendances' - ); + 'mod/attendance:changeattendances', + ]; if (is_null($sess->lasttaken) && has_any_capability($capabilities, $reportdata->att->context)) { $sesstext = html_writer::link($reportdata->url_take($sess->id, $sess->groupid), $sesstext, - array('class' => 'attendancereporttakelink')); + ['class' => 'attendancereporttakelink']); } - $sesstext .= html_writer::empty_tag('br', array('class' => 'attendancereportseparator')); + $sesstext .= html_writer::empty_tag('br', ['class' => 'attendancereportseparator']); if (!empty($sess->description) && !empty(get_config('attendance', 'showsessiondescriptiononreport'))) { $sesstext .= html_writer::tag('small', format_text($sess->description), - array('class' => 'attendancereportcommon')); + ['class' => 'attendancereportcommon']); } if ($sess->groupid) { if (empty($reportdata->groups[$sess->groupid])) { $sesstext .= html_writer::tag('small', get_string('deletedgroup', 'attendance'), - array('class' => 'attendancereportgroup')); + ['class' => 'attendancereportgroup']); } else { $sesstext .= html_writer::tag('small', $reportdata->groups[$sess->groupid]->name, - array('class' => 'attendancereportgroup')); + ['class' => 'attendancereportgroup']); } } else { $sesstext .= html_writer::tag('small', get_string('commonsession', 'attendance'), - array('class' => 'attendancereportcommon')); + ['class' => 'attendancereportcommon']); } $row->cells[] = $this->build_header_cell($sesstext, false, true, null, null, false); @@ -2507,7 +2507,7 @@ protected function get_session_rows(report_data $reportdata, $startwithcontrast= $row = new html_table_row(); if ($showsessiondetails && !empty($reportdata->sessions)) { foreach ($reportdata->sessions as $sess) { - $sessionstats = array(); + $sessionstats = []; foreach ($reportdata->statuses as $status) { if ($status->setnumber == $sess->statusset) { $status->count = 0; @@ -2550,7 +2550,7 @@ protected function get_session_rows(report_data $reportdata, $startwithcontrast= * @return html_table_cell a html table cell */ protected function build_header_cell($cell, $contrast=false, $center=true, $colspan=null, $rowspan=null, $nowrap=true) { - $classes = array('header', 'bottom'); + $classes = ['header', 'bottom']; if ($center) { $classes[] = 'center'; $classes[] = 'narrow'; @@ -2578,7 +2578,7 @@ protected function build_header_cell($cell, $contrast=false, $center=true, $cols * @return html_table_cell a html table cell */ protected function build_data_cell($cell, $contrast=false, $center=true, $colspan=null, $rowspan=null, $nowrap=true) { - $classes = array(); + $classes = []; if ($center) { $classes[] = 'center'; $classes[] = 'narrow'; @@ -2640,7 +2640,7 @@ protected function build_cell($cell, $classes, $colspan=null, $rowspan=null, $he protected function render_set_selector(set_selector $sel) { $current = $sel->get_current_statusset(); $selected = null; - $opts = array(); + $opts = []; for ($i = 0; $i <= $sel->maxstatusset; $i++) { $url = $sel->url($i); $display = $sel->get_status_name($i); @@ -2669,11 +2669,11 @@ protected function render_preferences_data($prefdata) { $table = new html_table(); $table->width = '100%'; - $table->head = array('#', + $table->head = ['#', get_string('acronym', 'attendance'), get_string('description'), - get_string('points', 'attendance')); - $table->align = array('center', 'center', 'center', 'center', 'center', 'center'); + get_string('points', 'attendance'), ]; + $table->align = ['center', 'center', 'center', 'center', 'center', 'center']; $table->head[] = get_string('availability', 'attendance'). $this->output->help_icon('availability', 'attendance'); @@ -2701,7 +2701,7 @@ protected function render_preferences_data($prefdata) { $emptydescription = $this->construct_notice(get_string('emptydescription', 'mod_attendance') , 'notifyproblem'); } } - $cells = array(); + $cells = []; $cells[] = $i; $cells[] = $this->construct_text_input('acronym['.$st->id.']', 2, 2, $st->acronym) . $emptyacronym; $cells[] = $this->construct_text_input('description['.$st->id.']', 30, 30, $st->description) . @@ -2738,14 +2738,14 @@ protected function render_preferences_data($prefdata) { $table->data[$i]->id = "statuslastrow"; $o = html_writer::table($table); - $o .= html_writer::input_hidden_params($prefdata->url(array(), false)); + $o .= html_writer::input_hidden_params($prefdata->url([], false)); // We should probably rewrite this to use mforms but for now add sesskey. - $o .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()))."\n"; + $o .= html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()])."\n"; $o .= $this->construct_preferences_button(get_string('update', 'attendance'), mod_attendance_preferences_page_params::ACTION_SAVE); - $o = html_writer::tag('form', $o, array('id' => 'preferencesform', 'method' => 'post', - 'action' => $prefdata->url(array(), false)->out_omit_querystring())); + $o = html_writer::tag('form', $o, ['id' => 'preferencesform', 'method' => 'post', + 'action' => $prefdata->url([], false)->out_omit_querystring()]); $o = $this->output->container($o, 'generalbox attwidth'); return $o; @@ -2782,13 +2782,13 @@ protected function render_attendance_pref($prefdata) { * @return string */ private function construct_text_input($name, $size, $maxlength, $value='', $classname='') { - $attributes = array( + $attributes = [ 'type' => 'text', 'name' => $name, 'size' => $size, 'maxlength' => $maxlength, 'value' => $value, - 'class' => "form-control {$classname}"); + 'class' => "form-control {$classname}", ]; return html_writer::empty_tag('input', $attributes); } @@ -2800,8 +2800,8 @@ private function construct_text_input($name, $size, $maxlength, $value='', $clas * @return string */ private function construct_preferences_actions_icons($st, $prefdata) { - $params = array('sesskey' => sesskey(), - 'statusid' => $st->id); + $params = ['sesskey' => sesskey(), + 'statusid' => $st->id, ]; if ($st->visible) { $params['action'] = mod_attendance_preferences_page_params::ACTION_HIDE; $showhideicon = $this->output->action_icon( @@ -2833,11 +2833,11 @@ private function construct_preferences_actions_icons($st, $prefdata) { * @return string */ private function construct_preferences_button($text, $action) { - $attributes = array( + $attributes = [ 'type' => 'submit', 'value' => $text, 'class' => 'btn btn-secondary', - 'onclick' => 'M.mod_attendance.set_preferences_action('.$action.')'); + 'onclick' => 'M.mod_attendance.set_preferences_action('.$action.')', ]; return html_writer::empty_tag('input', $attributes); } @@ -2849,7 +2849,7 @@ private function construct_preferences_button($text, $action) { * @return string */ private function construct_notice($text, $class = 'notifymessage') { - $attributes = array('class' => $class); + $attributes = ['class' => $class]; return html_writer::tag('p', $text, $attributes); } @@ -2870,10 +2870,10 @@ protected function construct_studentavailability($st) { } } - $options = array(0 => get_string('availabilityno', 'mod_attendance'), - 1 => get_string('availabilitylimitedtime', 'mod_attendance')); + $options = [0 => get_string('availabilityno', 'mod_attendance'), + 1 => get_string('availabilitylimitedtime', 'mod_attendance'), ]; $result = html_writer::select($options, 'availability['.$st->id.']', $default, - array('' => get_string('availabilityalways', 'mod_attendance'))); + ['' => get_string('availabilityalways', 'mod_attendance')]); $result .= $this->construct_text_input('studentavailability['.$st->id.']', 4, 5, $st->studentavailability, 'studentavailability'); return $result; @@ -2888,11 +2888,11 @@ protected function construct_studentavailability($st) { */ protected function user_picture($user, array $opts = null) { if ($user->type == 'temporary') { - $attrib = array( + $attrib = [ 'width' => '35', 'height' => '35', 'class' => 'userpicture defaultuserpic', - ); + ]; if (isset($opts['size'])) { $attrib['width'] = $attrib['height'] = $opts['size']; } diff --git a/classes/output/report_data.php b/classes/output/report_data.php index 20a9915486a..bd5b6221ed1 100644 --- a/classes/output/report_data.php +++ b/classes/output/report_data.php @@ -49,11 +49,11 @@ class report_data implements renderable { /** @var array includes disablrd/deleted statuses. */ public $allstatuses; /** @var array */ - public $usersgroups = array(); + public $usersgroups = []; /** @var array */ - public $sessionslog = array(); + public $sessionslog = []; /** @var array|mod_attendance_summary */ - public $summary = array(); + public $summary = []; /** @var mod_attendance_structure */ public $att; @@ -120,7 +120,7 @@ public function url_take($sessionid, $grouptype) { * @param array $params * @return mixed */ - public function url_view($params=array()) { + public function url_view($params=[]) { return url_helpers::url_view($this->att, $params); } @@ -129,7 +129,7 @@ public function url_view($params=array()) { * @param array $params * @return moodle_url */ - public function url($params=array()) { + public function url($params=[]) { $params = array_merge($params, $this->pageparams->get_significant_params()); return $this->att->url_report($params); diff --git a/classes/output/set_selector.php b/classes/output/set_selector.php index 3f013560f09..b2d364bf256 100644 --- a/classes/output/set_selector.php +++ b/classes/output/set_selector.php @@ -55,7 +55,7 @@ public function __construct(mod_attendance_structure $att, $maxstatusset) { * @return moodle_url */ public function url($statusset) { - $params = array(); + $params = []; $params['statusset'] = $statusset; return $this->att->url_preferences($params); diff --git a/classes/output/take_data.php b/classes/output/take_data.php index cfba03216b4..4ec051dd585 100644 --- a/classes/output/take_data.php +++ b/classes/output/take_data.php @@ -87,7 +87,7 @@ public function __construct(mod_attendance_structure $att) { } else if ($this->updatemode) { $this->sessionlog = $att->get_session_log($att->pageparams->sessionid); } else { - $this->sessionlog = array(); + $this->sessionlog = []; } if (!$this->updatemode) { @@ -108,7 +108,7 @@ public function __construct(mod_attendance_structure $att) { * @param array $excludeparams * @return moodle_url */ - public function url($params=array(), $excludeparams=array()) { + public function url($params=[], $excludeparams=[]) { $params = array_merge($this->urlparams, $params); foreach ($excludeparams as $paramkey) { @@ -123,7 +123,7 @@ public function url($params=array(), $excludeparams=array()) { * @param array $params * @return mixed */ - public function url_view($params=array()) { + public function url_view($params=[]) { return url_helpers::url_view($this->att, $params); } diff --git a/classes/output/user_data.php b/classes/output/user_data.php index e9d8a620885..634c81f2ae6 100644 --- a/classes/output/user_data.php +++ b/classes/output/user_data.php @@ -76,7 +76,7 @@ public function __construct(mod_attendance_structure $att, $userid, $mobile = f $this->statuses = $att->get_statuses(true, true); if (!$mobile) { - $this->summary = new mod_attendance_summary($att->id, array($userid), $att->pageparams->startdate, + $this->summary = new mod_attendance_summary($att->id, [$userid], $att->pageparams->startdate, $att->pageparams->enddate); $this->filtercontrols = new filter_controls($att); @@ -87,9 +87,9 @@ public function __construct(mod_attendance_structure $att, $userid, $mobile = f $this->groups = groups_get_all_groups($att->course->id); } else if ($this->pageparams->mode == mod_attendance_view_page_params::MODE_ALL_SESSIONS) { $this->coursesatts = attendance_get_user_courses_attendances($userid); - $this->statuses = array(); - $this->summaries = array(); - $this->groups = array(); + $this->statuses = []; + $this->summaries = []; + $this->groups = []; foreach ($this->coursesatts as $atid => $ca) { // Check to make sure the user can view this cm. @@ -101,7 +101,7 @@ public function __construct(mod_attendance_structure $att, $userid, $mobile = f $this->coursesatts[$atid]->cmid = $modinfo->instances['attendance'][$ca->attid]->get_course_module_record()->id; } $this->statuses[$ca->attid] = attendance_get_statuses($ca->attid); - $this->summaries[$ca->attid] = new mod_attendance_summary($ca->attid, array($userid)); + $this->summaries[$ca->attid] = new mod_attendance_summary($ca->attid, [$userid]); if (!array_key_exists($ca->courseid, $this->groups)) { $this->groups[$ca->courseid] = groups_get_all_groups($ca->courseid); @@ -109,7 +109,7 @@ public function __construct(mod_attendance_structure $att, $userid, $mobile = f } if (!$mobile) { - $this->summary = new mod_attendance_summary($att->id, array($userid), $att->pageparams->startdate, + $this->summary = new mod_attendance_summary($att->id, [$userid], $att->pageparams->startdate, $att->pageparams->enddate); $this->filtercontrols = new filter_controls($att); @@ -128,8 +128,8 @@ public function __construct(mod_attendance_structure $att, $userid, $mobile = f } else { $this->coursesatts = attendance_get_user_courses_attendances($userid); - $this->statuses = array(); - $this->summary = array(); + $this->statuses = []; + $this->summary = []; foreach ($this->coursesatts as $atid => $ca) { // Check to make sure the user can view this cm. $modinfo = get_fast_modinfo($ca->courseid); @@ -140,7 +140,7 @@ public function __construct(mod_attendance_structure $att, $userid, $mobile = f $this->coursesatts[$atid]->cmid = $modinfo->instances['attendance'][$ca->attid]->get_course_module_record()->id; } $this->statuses[$ca->attid] = attendance_get_statuses($ca->attid); - $this->summary[$ca->attid] = new mod_attendance_summary($ca->attid, array($userid)); + $this->summary[$ca->attid] = new mod_attendance_summary($ca->attid, [$userid]); } } $this->urlpath = $att->url_view()->out_omit_querystring(); @@ -155,7 +155,7 @@ public function __construct(mod_attendance_structure $att, $userid, $mobile = f * @param array $excludeparams * @return moodle_url */ - public function url($params=array(), $excludeparams=array()) { + public function url($params=[], $excludeparams=[]) { $params = array_merge($this->urlparams, $params); foreach ($excludeparams as $paramkey) { @@ -176,10 +176,10 @@ public function take_sessions_from_form_data($formdata) { // This whole function could do with a nice clean up. $now = time(); - $sesslog = array(); + $sesslog = []; $formdata = (array)$formdata; - $updatedsessions = array(); - $sessionatt = array(); + $updatedsessions = []; + $sessionatt = []; foreach ($formdata as $key => $value) { // Look at Remarks field because the user options may not be passed if empty. @@ -221,15 +221,15 @@ function($x) use($dbsession) { $formlog->takenby = $USER->id; if (!array_key_exists($stid, $sesslog)) { - $sesslog[$stid] = array(); + $sesslog[$stid] = []; } $sesslog[$stid][$sessid] = $formlog; } } - $updateatts = array(); + $updateatts = []; foreach ($sesslog as $stid => $userlog) { - $dbstudlog = $DB->get_records('attendance_log', array('studentid' => $stid), '', + $dbstudlog = $DB->get_records('attendance_log', ['studentid' => $stid], '', 'sessionid,statusid,remarks,id,statusset'); foreach ($userlog as $log) { if (array_key_exists($log->sessionid, $dbstudlog)) { @@ -245,7 +245,7 @@ function($x) use($dbsession) { $updatedsessions[$log->sessionid] = $log->sessionid; if (!array_key_exists($attid, $updateatts)) { - $updateatts[$attid] = array(); + $updateatts[$attid] = []; } array_push($updateatts[$attid], $log->studentid); } @@ -253,7 +253,7 @@ function($x) use($dbsession) { $DB->insert_record('attendance_log', $log, false); $updatedsessions[$log->sessionid] = $log->sessionid; if (!array_key_exists($attid, $updateatts)) { - $updateatts[$attid] = array(); + $updateatts[$attid] = []; } array_push($updateatts[$attid], $log->studentid); } diff --git a/classes/page_with_filter_controls.php b/classes/page_with_filter_controls.php index e998e572854..f686ba3460b 100644 --- a/classes/page_with_filter_controls.php +++ b/classes/page_with_filter_controls.php @@ -174,7 +174,7 @@ private function calc_sessgroupslist_sesstype() { global $SESSION; if (!property_exists($SESSION, 'attsessiontype')) { - $SESSION->attsessiontype = array($this->cm->course => self::SESSTYPE_ALL); + $SESSION->attsessiontype = [$this->cm->course => self::SESSTYPE_ALL]; } else if (!array_key_exists($this->cm->course, $SESSION->attsessiontype)) { $SESSION->attsessiontype[$this->cm->course] = self::SESSTYPE_ALL; } @@ -224,7 +224,7 @@ private function calc_sessgroupslist_sesstype() { private function calc_sessgroupslist() { global $USER, $PAGE; - $this->sessgroupslist = array(); + $this->sessgroupslist = []; $groupmode = groups_get_activity_groupmode($this->cm); if ($groupmode == NOGROUPS) { return; diff --git a/classes/preferences_page_params.php b/classes/preferences_page_params.php index 96554cba959..bda33bf2284 100644 --- a/classes/preferences_page_params.php +++ b/classes/preferences_page_params.php @@ -55,7 +55,7 @@ class mod_attendance_preferences_page_params { * @return array */ public function get_significant_params() { - $params = array(); + $params = []; if (isset($this->action)) { $params['action'] = $this->action; diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 0932f455425..67a0c2f61b6 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -58,7 +58,7 @@ public static function get_metadata(collection $collection) : collection { 'timetaken' => 'privacy:metadata:timetaken', 'takenby' => 'privacy:metadata:takenby', 'remarks' => 'privacy:metadata:remarks', - 'ipaddress' => 'privacy:metadata:ipaddress' + 'ipaddress' => 'privacy:metadata:ipaddress', ], 'privacy:metadata:attendancelog' ); @@ -71,7 +71,7 @@ public static function get_metadata(collection $collection) : collection { 'duration' => 'privacy:metadata:duration', 'lasttaken' => 'privacy:metadata:lasttaken', 'lasttakenby' => 'privacy:metadata:lasttakenby', - 'timemodified' => 'privacy:metadata:timemodified' + 'timemodified' => 'privacy:metadata:timemodified', ], 'privacy:metadata:attendancesessions' ); @@ -81,7 +81,7 @@ public static function get_metadata(collection $collection) : collection { [ 'notifyid' => 'privacy:metadata:notifyid', 'userid' => 'privacy:metadata:userid', - 'timesent' => 'privacy:metadata:timesent' + 'timesent' => 'privacy:metadata:timesent', ], 'privacy:metadata:attendancewarningdone' ); @@ -111,7 +111,7 @@ public static function get_contexts_for_userid(int $userid) : contextlist { 'modulename' => 'attendance', 'contextlevel' => CONTEXT_MODULE, 'userid' => $userid, - 'takenbyid' => $userid + 'takenbyid' => $userid, ] ); } @@ -177,7 +177,7 @@ public static function delete_data_for_all_users_in_context(context $context) { 'attendance_log', "sessionid IN (SELECT id FROM {attendance_sessions} WHERE attendanceid = :attendanceid", [ - 'attendanceid' => $cm->instance + 'attendanceid' => $cm->instance, ] ); @@ -248,7 +248,7 @@ public static function delete_data_for_users(approved_userlist $userlist) { $sql = 'SELECT DISTINCT w.* FROM {attendance_warning} w JOIN {attendance_warning_done} d ON d.notifyid = w.id AND d.userid = ?'; - $warnings = $DB->get_records_sql($sql, array($userid)); + $warnings = $DB->get_records_sql($sql, [$userid]); if (!empty($warnings)) { attendance_remove_user_from_thirdpartyemails($warnings, $userid); } @@ -283,7 +283,7 @@ public static function export_user_data(approved_contextlist $contextlist) { 'modulename' => 'attendance', 'contextlevel' => CONTEXT_MODULE, 'studentid' => $contextlist->get_user()->id, - 'takenby' => $contextlist->get_user()->id + 'takenby' => $contextlist->get_user()->id, ]; list($contextsql, $contextparams) = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED); @@ -489,7 +489,7 @@ private static function transform_db_row_to_session_data(stdClass $dbrow) : stdC 'sessiondescription' => $dbrow->description, 'timetaken' => transform::datetime($dbrow->timetaken), 'remarks' => $dbrow->remarks, - 'ipaddress' => $dbrow->ipaddress + 'ipaddress' => $dbrow->ipaddress, ]; } @@ -507,7 +507,7 @@ private static function transform_warning_data(stdClass $warning) : stdClass { 'timesent' => transform::datetime($warning->timesent), 'thirdpartyemails' => $warning->thirdpartyemails, 'subject' => $warning->emailsubject, - 'body' => $warning->emailcontent + 'body' => $warning->emailcontent, ]; } diff --git a/classes/report_page_params.php b/classes/report_page_params.php index b6c44b07cd2..efda5acb462 100644 --- a/classes/report_page_params.php +++ b/classes/report_page_params.php @@ -70,7 +70,7 @@ public function init($cm) { * @return array */ public function get_significant_params() { - $params = array(); + $params = []; if ($this->sort != ATT_SORT_DEFAULT) { $params['sort'] = $this->sort; diff --git a/classes/reportbuilder/datasource/attendance.php b/classes/reportbuilder/datasource/attendance.php index 6c9a8723b25..911761450a7 100644 --- a/classes/reportbuilder/datasource/attendance.php +++ b/classes/reportbuilder/datasource/attendance.php @@ -93,7 +93,7 @@ public function get_default_columns(): array { 'attendance:sessiondate', 'attendance:timetaken', 'attendance:status', - 'attendance:grade']; + 'attendance:grade', ]; } /** diff --git a/classes/structure.php b/classes/structure.php index c5d63721ab8..6e647898d0b 100644 --- a/classes/structure.php +++ b/classes/structure.php @@ -99,7 +99,7 @@ class mod_attendance_structure { private $allstatuses; /** @var array of sessionid. */ - private $sessioninfo = array(); + private $sessioninfo = []; /** @var float number [0..1], the threshold for student to be shown at low grade report */ private $lowgradethreshold; @@ -141,13 +141,13 @@ public function __construct(stdClass $dbrecord, stdClass $cm, stdClass $course, $this->pageparams = $pageparams; if (isset($pageparams->showextrauserdetails) && $pageparams->showextrauserdetails != $this->showextrauserdetails) { - $DB->set_field('attendance', 'showextrauserdetails', $pageparams->showextrauserdetails, array('id' => $this->id)); + $DB->set_field('attendance', 'showextrauserdetails', $pageparams->showextrauserdetails, ['id' => $this->id]); } if (isset($pageparams->showsessiondetails) && $pageparams->showsessiondetails != $this->showsessiondetails) { - $DB->set_field('attendance', 'showsessiondetails', $pageparams->showsessiondetails, array('id' => $this->id)); + $DB->set_field('attendance', 'showsessiondetails', $pageparams->showsessiondetails, ['id' => $this->id]); } if (isset($pageparams->sessiondetailspos) && $pageparams->sessiondetailspos != $this->sessiondetailspos) { - $DB->set_field('attendance', 'sessiondetailspos', $pageparams->sessiondetailspos, array('id' => $this->id)); + $DB->set_field('attendance', 'sessiondetailspos', $pageparams->sessiondetailspos, ['id' => $this->id]); } } @@ -179,9 +179,9 @@ public function get_current_sessions() : array { FROM {attendance_sessions} WHERE :time BETWEEN sessdate AND (sessdate + duration) AND attendanceid = :aid"; - $params = array( + $params = [ 'time' => $today, - 'aid' => $this->id); + 'aid' => $this->id, ]; return $DB->get_records_sql($sql, $params); } @@ -203,10 +203,10 @@ public function get_today_sessions() : array { FROM {attendance_sessions} WHERE sessdate >= :start AND sessdate < :end AND attendanceid = :aid"; - $params = array( + $params = [ 'start' => $start, 'end' => $end, - 'aid' => $this->id); + 'aid' => $this->id, ]; return $DB->get_records_sql($sql, $params); } @@ -228,11 +228,11 @@ public function get_today_sessions_for_copy($sess) : array { WHERE sessdate >= :start AND sessdate <= :end AND (groupid = 0 OR groupid = :groupid) AND lasttaken > 0 AND attendanceid = :aid"; - $params = array( + $params = [ 'start' => $start, 'end' => $sess->sessdate, 'groupid' => $sess->groupid, - 'aid' => $this->id); + 'aid' => $this->id, ]; return $DB->get_records_sql($sql, $params); } @@ -248,9 +248,9 @@ public function get_hidden_sessions_count() : int { global $DB; $where = "attendanceid = :aid AND sessdate < :csdate"; - $params = array( + $params = [ 'aid' => $this->id, - 'csdate' => $this->course->startdate); + 'csdate' => $this->course->startdate, ]; return $DB->count_records_select('attendance_sessions', $where, $params); } @@ -266,9 +266,9 @@ public function get_hidden_sessions() : array { global $DB; $where = "attendanceid = :aid AND sessdate < :csdate"; - $params = array( + $params = [ 'aid' => $this->id, - 'csdate' => $this->course->startdate); + 'csdate' => $this->course->startdate, ]; return $DB->get_records_select('attendance_sessions', $where, $params); } @@ -292,12 +292,12 @@ public function get_filtered_sessions() : array { if ($this->pageparams->get_current_sesstype() > mod_attendance_page_with_filter_controls::SESSTYPE_ALL) { $where .= " AND (groupid = :cgroup OR groupid = 0)"; } - $params = array( + $params = [ 'aid' => $this->id, 'csdate' => $this->course->startdate, 'sdate' => $this->pageparams->startdate, 'edate' => $this->pageparams->enddate, - 'cgroup' => $this->pageparams->get_current_sesstype()); + 'cgroup' => $this->pageparams->get_current_sesstype(), ]; $sessions = $DB->get_records_select('attendance_sessions', $where, $params, 'sessdate asc'); $statussetmaxpoints = attendance_get_statusset_maxpoints($this->get_statuses(true, true)); foreach ($sessions as $sess) { @@ -318,8 +318,8 @@ public function get_filtered_sessions() : array { * @param array $params * @return moodle_url of manage.php for attendance instance */ - public function url_manage($params=array()) : moodle_url { - $params = array_merge(array('id' => $this->cm->id), $params); + public function url_manage($params=[]) : moodle_url { + $params = array_merge(['id' => $this->cm->id], $params); return new moodle_url('/mod/attendance/manage.php', $params); } @@ -328,8 +328,8 @@ public function url_manage($params=array()) : moodle_url { * @param array $params optional * @return moodle_url of tempusers.php for attendance instance */ - public function url_managetemp($params=array()) : moodle_url { - $params = array_merge(array('id' => $this->cm->id), $params); + public function url_managetemp($params=[]) : moodle_url { + $params = array_merge(['id' => $this->cm->id], $params); return new moodle_url('/mod/attendance/tempusers.php', $params); } @@ -339,8 +339,8 @@ public function url_managetemp($params=array()) : moodle_url { * @param array $params optional * @return moodle_url of tempdelete.php for attendance instance */ - public function url_tempdelete($params=array()) : moodle_url { - $params = array_merge(array('id' => $this->cm->id, 'action' => 'delete'), $params); + public function url_tempdelete($params=[]) : moodle_url { + $params = array_merge(['id' => $this->cm->id, 'action' => 'delete'], $params); return new moodle_url('/mod/attendance/tempedit.php', $params); } @@ -350,8 +350,8 @@ public function url_tempdelete($params=array()) : moodle_url { * @param array $params optional * @return moodle_url of tempedit.php for attendance instance */ - public function url_tempedit($params=array()) : moodle_url { - $params = array_merge(array('id' => $this->cm->id), $params); + public function url_tempedit($params=[]) : moodle_url { + $params = array_merge(['id' => $this->cm->id], $params); return new moodle_url('/mod/attendance/tempedit.php', $params); } @@ -361,8 +361,8 @@ public function url_tempedit($params=array()) : moodle_url { * @param array $params optional * @return moodle_url of tempedit.php for attendance instance */ - public function url_tempmerge($params=array()) : moodle_url { - $params = array_merge(array('id' => $this->cm->id), $params); + public function url_tempmerge($params=[]) : moodle_url { + $params = array_merge(['id' => $this->cm->id], $params); return new moodle_url('/mod/attendance/tempmerge.php', $params); } @@ -371,8 +371,8 @@ public function url_tempmerge($params=array()) : moodle_url { * @param array $params * @return moodle_url of sessions.php for attendance instance */ - public function url_sessions($params=array()) : moodle_url { - $params = array_merge(array('id' => $this->cm->id), $params); + public function url_sessions($params=[]) : moodle_url { + $params = array_merge(['id' => $this->cm->id], $params); return new moodle_url('/mod/attendance/sessions.php', $params); } @@ -381,8 +381,8 @@ public function url_sessions($params=array()) : moodle_url { * @param array $params * @return moodle_url of report.php for attendance instance */ - public function url_report($params=array()) : moodle_url { - $params = array_merge(array('id' => $this->cm->id), $params); + public function url_report($params=[]) : moodle_url { + $params = array_merge(['id' => $this->cm->id], $params); return new moodle_url('/mod/attendance/report.php', $params); } @@ -391,8 +391,8 @@ public function url_report($params=array()) : moodle_url { * @param array $params * @return moodle_url of report.php for attendance instance */ - public function url_absentee($params=array()) : moodle_url { - $params = array_merge(array('id' => $this->cm->id), $params); + public function url_absentee($params=[]) : moodle_url { + $params = array_merge(['id' => $this->cm->id], $params); return new moodle_url('/mod/attendance/absentee.php', $params); } @@ -412,7 +412,7 @@ public function url_import() : moodle_url { * @return moodle_url of export.php for attendance instance */ public function url_export() : moodle_url { - $params = array('id' => $this->cm->id); + $params = ['id' => $this->cm->id]; return new moodle_url('/mod/attendance/export.php', $params); } @@ -421,12 +421,12 @@ public function url_export() : moodle_url { * @param array $params * @return moodle_url of attsettings.php for attendance instance */ - public function url_preferences($params=array()) : moodle_url { + public function url_preferences($params=[]) : moodle_url { // Add the statusset params. if (isset($this->pageparams->statusset) && !isset($params['statusset'])) { $params['statusset'] = $this->pageparams->statusset; } - $params = array_merge(array('id' => $this->cm->id), $params); + $params = array_merge(['id' => $this->cm->id], $params); return new moodle_url('/mod/attendance/preferences.php', $params); } @@ -435,12 +435,12 @@ public function url_preferences($params=array()) : moodle_url { * @param array $params * @return moodle_url of attsettings.php for attendance instance */ - public function url_warnings($params=array()) : moodle_url { + public function url_warnings($params=[]) : moodle_url { // Add the statusset params. if (isset($this->pageparams->statusset) && !isset($params['statusset'])) { $params['statusset'] = $this->pageparams->statusset; } - $params = array_merge(array('id' => $this->cm->id), $params); + $params = array_merge(['id' => $this->cm->id], $params); return new moodle_url('/mod/attendance/warnings.php', $params); } @@ -449,8 +449,8 @@ public function url_warnings($params=array()) : moodle_url { * @param array $params * @return moodle_url of attendances.php for attendance instance */ - public function url_take($params=array()) : moodle_url { - $params = array_merge(array('id' => $this->cm->id), $params); + public function url_take($params=[]) : moodle_url { + $params = array_merge(['id' => $this->cm->id], $params); return new moodle_url('/mod/attendance/take.php', $params); } @@ -459,8 +459,8 @@ public function url_take($params=array()) : moodle_url { * @param array $params * @return moodle_url */ - public function url_view($params=array()) : moodle_url { - $params = array_merge(array('id' => $this->cm->id), $params); + public function url_view($params=[]) : moodle_url { + $params = array_merge(['id' => $this->cm->id], $params); return new moodle_url('/mod/attendance/view.php', $params); } @@ -510,22 +510,22 @@ public function add_session($sess) : int { $sess->id = $DB->insert_record('attendance_sessions', $sess); $description = file_save_draft_area_files($sess->descriptionitemid, $this->context->id, 'mod_attendance', 'session', $sess->id, - array('subdirs' => false, 'maxfiles' => -1, 'maxbytes' => 0), + ['subdirs' => false, 'maxfiles' => -1, 'maxbytes' => 0], $sess->description); - $DB->set_field('attendance_sessions', 'description', $description, array('id' => $sess->id)); + $DB->set_field('attendance_sessions', 'description', $description, ['id' => $sess->id]); $sess->caleventid = 0; attendance_create_calendar_event($sess); - $infoarray = array(); + $infoarray = []; $infoarray[] = construct_session_full_date_time($sess->sessdate, $sess->duration); // Trigger a session added event. - $event = \mod_attendance\event\session_added::create(array( + $event = \mod_attendance\event\session_added::create([ 'objectid' => $this->id, 'context' => $this->context, - 'other' => array('info' => implode(',', $infoarray)) - )); + 'other' => ['info' => implode(',', $infoarray)], + ]); $event->add_record_snapshot('course_modules', $this->cm); $sess->description = $description; $sess->lasttaken = 0; @@ -581,7 +581,7 @@ public function add_session($sess) : int { public function update_session_from_form_data($formdata, $sessionid) { global $DB; - if (!$sess = $DB->get_record('attendance_sessions', array('id' => $sessionid) )) { + if (!$sess = $DB->get_record('attendance_sessions', ['id' => $sessionid] )) { throw new moodle_exception('No such session in this course'); } @@ -593,7 +593,7 @@ public function update_session_from_form_data($formdata, $sessionid) { $description = file_save_draft_area_files($formdata->sdescription['itemid'], $this->context->id, 'mod_attendance', 'session', $sessionid, - array('subdirs' => false, 'maxfiles' => -1, 'maxbytes' => 0), $formdata->sdescription['text']); + ['subdirs' => false, 'maxfiles' => -1, 'maxbytes' => 0], $formdata->sdescription['text']); $sess->description = $description; $sess->descriptionformat = $formdata->sdescription['format']; $sess->calendarevent = empty($formdata->calendarevent) ? 0 : $formdata->calendarevent; @@ -669,11 +669,11 @@ public function update_session_from_form_data($formdata, $sessionid) { } $info = construct_session_full_date_time($sess->sessdate, $sess->duration); - $event = \mod_attendance\event\session_updated::create(array( + $event = \mod_attendance\event\session_updated::create([ 'objectid' => $this->id, 'context' => $this->context, - 'other' => array('info' => $info, 'sessionid' => $sessionid, - 'action' => mod_attendance_sessions_page_params::ACTION_UPDATE))); + 'other' => ['info' => $info, 'sessionid' => $sessionid, + 'action' => mod_attendance_sessions_page_params::ACTION_UPDATE, ]]); $event->add_record_snapshot('course_modules', $this->cm); $event->add_record_snapshot('attendance_sessions', $sess); $event->trigger(); @@ -702,7 +702,7 @@ public function take_from_student($mformdata) : bool { $record->ipaddress = getremoteaddr(null); $existingattendance = $DB->get_field('attendance_log', 'id', - array('sessionid' => $mformdata->sessid, 'studentid' => $USER->id)); + ['sessionid' => $mformdata->sessid, 'studentid' => $USER->id]); if (!empty($existingattendance)) { if (!attendance_check_allow_update($mformdata->sessid)) { @@ -724,21 +724,21 @@ public function take_from_student($mformdata) : bool { $DB->update_record('attendance_sessions', $session); // Update the users grade. - $this->update_users_grade(array($USER->id)); + $this->update_users_grade([$USER->id]); /* create url for link in log screen * need to set grouptype to 0 to allow take attendance page to be called * from report/log page */ - $params = array( + $params = [ 'sessionid' => $this->pageparams->sessionid, - 'grouptype' => 0); + 'grouptype' => 0, ]; // Log the change. - $event = \mod_attendance\event\attendance_taken_by_student::create(array( + $event = \mod_attendance\event\attendance_taken_by_student::create([ 'objectid' => $this->id, 'context' => $this->context, - 'other' => $params)); + 'other' => $params]); $event->add_record_snapshot('course_modules', $this->cm); $event->add_record_snapshot('attendance_sessions', $session); $event->add_record_snapshot('attendance_log', $record); @@ -758,7 +758,7 @@ public function take_from_form_data($data) { $statuses = implode(',', array_keys( (array)$this->get_statuses() )); $now = time(); - $sesslog = array(); + $sesslog = []; $formdata = (array)$data; @@ -826,13 +826,13 @@ public function save_log($sesslog) { } // Create url for link in log screen. - $params = array( + $params = [ 'sessionid' => $this->pageparams->sessionid, - 'grouptype' => $this->pageparams->grouptype); - $event = \mod_attendance\event\attendance_taken::create(array( + 'grouptype' => $this->pageparams->grouptype, ]; + $event = \mod_attendance\event\attendance_taken::create([ 'objectid' => $this->id, 'context' => $this->context, - 'other' => $params)); + 'other' => $params]); $event->add_record_snapshot('course_modules', $this->cm); $event->add_record_snapshot('attendance_sessions', $session); $event->trigger(); @@ -849,7 +849,7 @@ public function get_users($groupid = 0, $page = 1) : array { global $DB, $CFG; require_once($CFG->dirroot . '/user/profile/lib.php'); // For profile_load_data function. - $fields = array('username' , 'idnumber' , 'institution' , 'department', 'city', 'country'); + $fields = ['username' , 'idnumber' , 'institution' , 'department', 'city', 'country']; $userf = \core_user\fields::for_identity($this->context, false)->with_userpic()->including(...$fields); $userfields = $userf->get_sql('u', false, '', 'id', false)->selects; @@ -916,7 +916,7 @@ public function get_users($groupid = 0, $page = 1) : array { AND e.status = :estatus AND e.courseid = :courseid GROUP BY ue.userid"; - $params += array('zerotime' => 0, 'estatus' => ENROL_INSTANCE_ENABLED, 'courseid' => $this->course->id); + $params += ['zerotime' => 0, 'estatus' => ENROL_INSTANCE_ENABLED, 'courseid' => $this->course->id]; $enrolments = $DB->get_records_sql($sql, $params); foreach ($users as $user) { @@ -929,7 +929,7 @@ public function get_users($groupid = 0, $page = 1) : array { } // Add the 'temporary' users to this list. - $tempusers = $DB->get_records('attendance_tempusers', array('courseid' => $this->course->id)); + $tempusers = $DB->get_records('attendance_tempusers', ['courseid' => $this->course->id]); foreach ($tempusers as $tempuser) { $users[$tempuser->studentid] = self::tempuser_to_user($tempuser); } @@ -951,7 +951,7 @@ public function get_users($groupid = 0, $page = 1) : array { protected static function tempuser_to_user($tempuser) { global $CFG; - $ret = (object)array( + $ret = (object)[ 'id' => $tempuser->studentid, 'firstname' => $tempuser->fullname, 'email' => $tempuser->email, @@ -961,7 +961,7 @@ protected static function tempuser_to_user($tempuser) { 'enrolmentend' => 0, 'picture' => 0, 'type' => 'temporary', - ); + ]; $allfields = \core_user\fields::get_name_fields(); if (!empty($CFG->showuseridentity)) { $allfields = array_merge($allfields, explode(',', $CFG->showuseridentity)); @@ -985,11 +985,11 @@ protected static function tempuser_to_user($tempuser) { public function get_user($userid) { global $DB; - $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST); + $user = $DB->get_record('user', ['id' => $userid], '*', MUST_EXIST); // Look for 'temporary' users and return their details from the attendance_tempusers table. if ($user->idnumber == 'tempghost') { - $tempuser = $DB->get_record('attendance_tempusers', array('studentid' => $userid), '*', MUST_EXIST); + $tempuser = $DB->get_record('attendance_tempusers', ['studentid' => $userid], '*', MUST_EXIST); return self::tempuser_to_user($tempuser); } @@ -1008,7 +1008,7 @@ public function get_user($userid) { AND e.status = :estatus AND e.courseid = :courseid GROUP BY ue.userid, ue.status"; - $params = array('zerotime' => 0, 'uid' => $userid, 'estatus' => ENROL_INSTANCE_ENABLED, 'courseid' => $this->course->id); + $params = ['zerotime' => 0, 'uid' => $userid, 'estatus' => ENROL_INSTANCE_ENABLED, 'courseid' => $this->course->id]; $enrolments = $DB->get_record_sql($sql, $params); if (!empty($enrolments)) { $user->enrolmentstatus = $enrolments->status; @@ -1092,7 +1092,7 @@ public function get_session_info($sessionid) { global $DB; if (!array_key_exists($sessionid, $this->sessioninfo)) { - $this->sessioninfo[$sessionid] = $DB->get_record('attendance_sessions', array('id' => $sessionid)); + $this->sessioninfo[$sessionid] = $DB->get_record('attendance_sessions', ['id' => $sessionid]); } if (empty($this->sessioninfo[$sessionid]->description)) { $this->sessioninfo[$sessionid]->description = get_string('nodescription', 'attendance'); @@ -1136,7 +1136,7 @@ public function get_sessions_info($sessionids) : array { public function get_session_log($sessionid) : array { global $DB; - return $DB->get_records('attendance_log', array('sessionid' => $sessionid), '', 'studentid,statusid,remarks,id,statusset'); + return $DB->get_records('attendance_log', ['sessionid' => $sessionid], '', 'studentid,statusid,remarks,id,statusset'); } /** @@ -1170,12 +1170,12 @@ public function get_user_filtered_sessions_log($userid) : array { WHERE $where AND (ats.groupid = 0 or gm.id is NOT NULL) ORDER BY ats.sessdate ASC"; - $params = array( + $params = [ 'uid' => $userid, 'aid' => $this->id, 'csdate' => $this->course->startdate, 'sdate' => $this->pageparams->startdate, - 'edate' => $this->pageparams->enddate); + 'edate' => $this->pageparams->enddate, ]; } else { $sql = "SELECT ats.id, ats.sessdate, ats.groupid, al.statusid, al.remarks, @@ -1186,12 +1186,12 @@ public function get_user_filtered_sessions_log($userid) : array { WHERE $where ORDER BY ats.sessdate ASC"; - $params = array( + $params = [ 'uid' => $userid, 'aid' => $this->id, 'csdate' => $this->course->startdate, 'sdate' => $this->pageparams->startdate, - 'edate' => $this->pageparams->enddate); + 'edate' => $this->pageparams->enddate, ]; } $sessions = $DB->get_records_sql($sql, $params); @@ -1242,13 +1242,13 @@ public function get_user_filtered_sessions_log_extended($userid) : array { ORDER BY ats.sessdate ASC"; } - $params = array( + $params = [ 'uid' => $userid, 'aid' => $this->id, 'csdate' => $this->course->startdate, 'sdate' => $this->pageparams->startdate, 'edate' => $this->pageparams->enddate, - 'value' => 'c'); + 'value' => 'c', ]; $sessions = $DB->get_records_sql($sql, $params); // All sessions for current groups. @@ -1301,10 +1301,10 @@ public function delete_sessions($sessionsids) { list($sql, $params) = $DB->get_in_or_equal($sessionsids); $DB->delete_records_select('attendance_log', "sessionid $sql", $params); $DB->delete_records_list('attendance_sessions', 'id', $sessionsids); - $event = \mod_attendance\event\session_deleted::create(array( + $event = \mod_attendance\event\session_deleted::create([ 'objectid' => $this->id, 'context' => $this->context, - 'other' => array('info' => implode(', ', $sessionsids)))); + 'other' => ['info' => implode(', ', $sessionsids)]]); $event->add_record_snapshot('course_modules', $this->cm); $event->trigger(); } @@ -1327,10 +1327,10 @@ public function update_sessions_duration($sessionsids, $duration) { if ($sess->caleventid) { attendance_update_calendar_event($sess); } - $event = \mod_attendance\event\session_duration_updated::create(array( + $event = \mod_attendance\event\session_duration_updated::create([ 'objectid' => $this->id, 'context' => $this->context, - 'other' => array('info' => implode(', ', $sessionsids)))); + 'other' => ['info' => implode(', ', $sessionsids)]]); $event->add_record_snapshot('course_modules', $this->cm); $event->add_record_snapshot('attendance_sessions', $sess); $event->trigger(); @@ -1352,12 +1352,12 @@ public static function check_existing_email($email, $tempuserid = 0) { if (empty($email)) { return null; // Fine to create temporary users without an email address. } - if ($tempuser = $DB->get_record('attendance_tempusers', array('email' => $email), 'id')) { + if ($tempuser = $DB->get_record('attendance_tempusers', ['email' => $email], 'id')) { if ($tempuser->id != $tempuserid) { return get_string('tempexists', 'attendance'); } } - if ($DB->record_exists('user', array('email' => $email))) { + if ($DB->record_exists('user', ['email' => $email])) { return get_string('userexists', 'attendance'); } @@ -1417,8 +1417,8 @@ public function get_lowgrade_threshold() { $this->lowgradethreshold = 1; if ($this->grade > 0) { - $gradeitem = grade_item::fetch(array('courseid' => $this->course->id, 'itemtype' => 'mod', - 'itemmodule' => 'attendance', 'iteminstance' => $this->id, 'itemnumber' => 0)); + $gradeitem = grade_item::fetch(['courseid' => $this->course->id, 'itemtype' => 'mod', + 'itemmodule' => 'attendance', 'iteminstance' => $this->id, 'itemnumber' => 0]); if ($gradeitem->gradepass > 0 && $gradeitem->grademax != $gradeitem->grademin) { $this->lowgradethreshold = ($gradeitem->gradepass - $gradeitem->grademin) / ($gradeitem->grademax - $gradeitem->grademin); diff --git a/classes/summary.php b/classes/summary.php index 2e83facdbe1..b1049ea0755 100644 --- a/classes/summary.php +++ b/classes/summary.php @@ -60,7 +60,7 @@ class mod_attendance_summary { * @param int $startdate Attendance sessions startdate * @param int $enddate Attendance sessions enddate */ - public function __construct($attendanceid, $userids=array(), $startdate = '', $enddate = '') { + public function __construct($attendanceid, $userids=[], $startdate = '', $enddate = '') { $this->attendanceid = $attendanceid; $this->compute_users_points($userids, $startdate, $enddate); @@ -102,7 +102,7 @@ public function get_groupmode() { * @return array */ public function get_user_taken_sessions_percentages() { - $percentages = array(); + $percentages = []; foreach ($this->userspoints as $userid => $userpoints) { $percentages[$userid] = attendance_calc_fraction($userpoints->points, $userpoints->maxpoints); @@ -134,7 +134,7 @@ public function get_taken_sessions_summary_for($userid) { if (isset($this->userstakensessionsbyacronym[$userid])) { $usersummary->userstakensessionsbyacronym = $this->userstakensessionsbyacronym[$userid]; } else { - $usersummary->userstakensessionsbyacronym = array(); + $usersummary->userstakensessionsbyacronym = []; } $usersummary->pointssessionscompleted = format_float($usersummary->takensessionspoints, 1, true, true) . ' / ' . @@ -204,17 +204,17 @@ public function get_all_sessions_summary_for($userid) { * @param int $enddate Attendance sessions enddate * @return (userid, numtakensessions, points, maxpoints) */ - private function compute_users_points($userids=array(), $startdate = '', $enddate = '') { + private function compute_users_points($userids=[], $startdate = '', $enddate = '') { global $DB; list($this->course, $cm) = get_course_and_cm_from_instance($this->attendanceid, 'attendance'); $this->groupmode = $cm->effectivegroupmode; - $params = array( + $params = [ 'attid' => $this->attendanceid, 'attid2' => $this->attendanceid, 'cstartdate' => $this->course->startdate, - ); + ]; $where = ''; if (!empty($userids)) { @@ -268,16 +268,16 @@ private function compute_users_points($userids=array(), $startdate = '', $enddat * @param int $enddate Attendance sessions enddate * @return null */ - private function compute_users_taken_sessions_by_acronym($userids=array(), $startdate = '', $enddate = '') { + private function compute_users_taken_sessions_by_acronym($userids=[], $startdate = '', $enddate = '') { global $DB; list($this->course, $cm) = get_course_and_cm_from_instance($this->attendanceid, 'attendance'); $this->groupmode = $cm->effectivegroupmode; - $params = array( + $params = [ 'attid' => $this->attendanceid, 'cstartdate' => $this->course->startdate, - ); + ]; $where = ''; if (!empty($userids)) { @@ -315,7 +315,7 @@ private function compute_users_taken_sessions_by_acronym($userids=array(), $star AND ats.lasttaken != 0 {$where} GROUP BY atl.studentid, sts.setnumber, sts.acronym"; - $this->userstakensessionsbyacronym = array(); + $this->userstakensessionsbyacronym = []; $records = $DB->get_recordset_sql($sql, $params); foreach ($records as $rec) { $this->userstakensessionsbyacronym[$rec->userid][$rec->setnumber][$rec->acronym] = $rec->numtakensessions; @@ -331,11 +331,11 @@ private function compute_users_taken_sessions_by_acronym($userids=array(), $star private function compute_maxpoints_by_group_session() { global $DB; - $params = array( + $params = [ 'attid' => $this->attendanceid, 'attid2' => $this->attendanceid, 'cstartdate' => $this->course->startdate, - ); + ]; $where = ''; if (!$this->with_groups()) { diff --git a/classes/take_page_params.php b/classes/take_page_params.php index b68c5281770..b9cffd50747 100644 --- a/classes/take_page_params.php +++ b/classes/take_page_params.php @@ -101,7 +101,7 @@ private function init_gridcols() { * @return array */ public function get_significant_params() { - $params = array(); + $params = []; $params['sessionid'] = $this->sessionid; $params['grouptype'] = $this->grouptype; diff --git a/classes/task/auto_mark.php b/classes/task/auto_mark.php index 66c26e0c43c..2bd77167fc7 100644 --- a/classes/task/auto_mark.php +++ b/classes/task/auto_mark.php @@ -52,9 +52,9 @@ public function get_name() { public function execute() { global $DB; // Create some cache vars - might be nice to restructure this and make a smaller number of sql calls. - $cachecm = array(); - $cacheatt = array(); - $cachecourse = array(); + $cachecm = []; + $cacheatt = []; + $cachecourse = []; $sql = "SELECT se.*, ss.id as setunmarked FROM {attendance_sessions} se LEFT JOIN {attendance_statuses} ss ON ss.attendanceid = se.attendanceid @@ -65,7 +65,7 @@ public function execute() { foreach ($sessions as $session) { if (empty($cacheatt[$session->attendanceid])) { - $cacheatt[$session->attendanceid] = $DB->get_record('attendance', array('id' => $session->attendanceid)); + $cacheatt[$session->attendanceid] = $DB->get_record('attendance', ['id' => $session->attendanceid]); } if (empty($cachecm[$session->attendanceid])) { $cachecm[$session->attendanceid] = get_coursemodule_from_instance('attendance', @@ -73,7 +73,7 @@ public function execute() { } $courseid = $cacheatt[$session->attendanceid]->course; if (empty($cachecourse[$courseid])) { - $cachecourse[$courseid] = $DB->get_record('course', array('id' => $courseid)); + $cachecourse[$courseid] = $DB->get_record('course', ['id' => $courseid]); } \mod_attendance\local\automark::session($session, $cachecourse[$courseid], $cachecm[$session->attendanceid], $cacheatt[$session->attendanceid]); diff --git a/classes/task/clear_temporary_passwords.php b/classes/task/clear_temporary_passwords.php index 86819410210..a20eaf3d63e 100644 --- a/classes/task/clear_temporary_passwords.php +++ b/classes/task/clear_temporary_passwords.php @@ -47,7 +47,7 @@ public function get_name() { public function execute() { global $DB; - $params = array('currenttime' => time()); + $params = ['currenttime' => time()]; $DB->delete_records_select('attendance_rotate_passwords', 'expirytime < :currenttime', $params); } } diff --git a/classes/task/notify.php b/classes/task/notify.php index f7aa4e55ae8..74feee2b4be 100644 --- a/classes/task/notify.php +++ b/classes/task/notify.php @@ -61,14 +61,14 @@ public function execute() { // Note: this returns all users for these sessions - even if the users attendance wasn't changed // since last time we ran, before sending a notification we check to see if the users have // updated attendance logs since last time they were notified. - $records = attendance_get_users_to_notify(array(), $orderby, true); - $sentnotifications = array(); - $thirdpartynotifications = array(); + $records = attendance_get_users_to_notify([], $orderby, true); + $sentnotifications = []; + $thirdpartynotifications = []; $numsentusers = 0; $numsentthird = 0; foreach ($records as $record) { if (empty($sentnotifications[$record->userid])) { - $sentnotifications[$record->userid] = array(); + $sentnotifications[$record->userid] = []; } if (!empty($record->emailuser)) { @@ -83,14 +83,14 @@ public function execute() { FROM {attendance_log} l JOIN {attendance_sessions} s ON s.id = l.sessionid WHERE s.attendanceid = ? AND studentid = ? AND timetaken > ?"; - if (!$DB->record_exists_sql($sql, array($record->aid, $record->userid, $record->timesent))) { + if (!$DB->record_exists_sql($sql, [$record->aid, $record->userid, $record->timesent])) { continue; // Skip this record and move to the next user. } } // Convert variables in emailcontent. $record = attendance_template_variables($record); - $user = $DB->get_record('user', array('id' => $record->userid)); + $user = $DB->get_record('user', ['id' => $record->userid]); $from = \core_user::get_noreply_user(); $oldforcelang = force_current_language($user->lang); @@ -104,7 +104,7 @@ public function execute() { } } // Only send one warning to this user from each attendance in this run. - flag any higher percent notifications as sent. - $thirdpartyusers = array(); + $thirdpartyusers = []; if (!empty($record->thirdpartyemails)) { $sendto = explode(',', $record->thirdpartyemails); $record->percent = round($record->percent * 100)."%"; @@ -120,7 +120,7 @@ public function execute() { // Check user is allowed to receive warningemails. if (has_capability('mod/attendance:warningemails', $context, $senduser)) { if (empty($thirdpartynotifications[$senduser])) { - $thirdpartynotifications[$senduser] = array(); + $thirdpartynotifications[$senduser] = []; } if (!isset($thirdpartynotifications[$senduser][$record->aid . '_' . $record->userid])) { $thirdpartynotifications[$senduser][$record->aid . '_' . $record->userid] @@ -142,7 +142,7 @@ public function execute() { } if (!empty($thirdpartynotifications)) { foreach ($thirdpartynotifications as $sendid => $notifications) { - $user = $DB->get_record('user', array('id' => $sendid)); + $user = $DB->get_record('user', ['id' => $sendid]); if (empty($user) || !empty($user->deleted)) { // Clean this user up and remove from the notification list. $warnings = $DB->get_records_list('attendance_warning', 'id', $thirdpartyusers[$sendid]); diff --git a/classes/view_page_params.php b/classes/view_page_params.php index f7340f425be..eb011ac71c0 100644 --- a/classes/view_page_params.php +++ b/classes/view_page_params.php @@ -63,7 +63,7 @@ public function __construct() { * @return array */ public function get_significant_params() { - $params = array(); + $params = []; if (isset($this->studentid)) { $params['studentid'] = $this->studentid; diff --git a/coursesummary.php b/coursesummary.php index 64d4e18e337..34da49fb7ad 100644 --- a/coursesummary.php +++ b/coursesummary.php @@ -43,18 +43,18 @@ if (empty($category)) { $context = context_system::instance(); - $courses = array(); // Show all courses. + $courses = []; // Show all courses. } else { $context = context_coursecat::instance($category); $coursecat = core_course_category::get($category); - $courses = $coursecat->get_courses(array('recursive' => true, 'idonly' => true)); + $courses = $coursecat->get_courses(['recursive' => true, 'idonly' => true]); } // Check permissions. require_capability('mod/attendance:viewsummaryreports', $context); $exportfilename = 'attendancecoursesummary.csv'; -$PAGE->set_url('/mod/attendance/coursesummary.php', array('category' => $category)); +$PAGE->set_url('/mod/attendance/coursesummary.php', ['category' => $category]); $PAGE->set_heading($SITE->fullname); @@ -73,7 +73,7 @@ $tabmenu = attendance_print_settings_tabs('coursesummary'); echo $tabmenu; } - $url = new moodle_url('/mod/attendance/coursesummary.php', array('category' => $category, 'fromcourse' => $fromcourse)); + $url = new moodle_url('/mod/attendance/coursesummary.php', ['category' => $category, 'fromcourse' => $fromcourse]); if ($admin) { $options = core_course_category::make_categories_list('mod/attendance:viewsummaryreports'); @@ -82,14 +82,14 @@ } -$table->define_columns(array('course', 'percentage')); -$table->define_headers(array(get_string('course'), - get_string('averageattendance', 'attendance'))); +$table->define_columns(['course', 'percentage']); +$table->define_headers([get_string('course'), + get_string('averageattendance', 'attendance')]); $table->sortable(true); $table->no_sorting('course'); $table->set_attribute('cellspacing', '0'); $table->set_attribute('class', 'generaltable generalbox'); -$table->show_download_buttons_at(array(TABLE_P_BOTTOM)); +$table->show_download_buttons_at([TABLE_P_BOTTOM]); $table->setup(); // Work out direction of sort required. @@ -115,12 +115,12 @@ $records = attendance_course_users_points($courses, $orderby); foreach ($records as $record) { if (!$table->is_downloading($download, $exportfilename)) { - $url = new moodle_url('/mod/attendance/index.php', array('id' => $record->courseid)); + $url = new moodle_url('/mod/attendance/index.php', ['id' => $record->courseid]); $name = html_writer::link($url, $record->coursename); } else { $name = $record->coursename; } - $table->add_data(array($name, round($record->percentage * 100)."%")); + $table->add_data([$name, round($record->percentage * 100)."%"]); } $table->finish_output(); diff --git a/db/access.php b/db/access.php index a5cac75b5a1..dfd8f59e61d 100644 --- a/db/access.php +++ b/db/access.php @@ -24,153 +24,153 @@ defined('MOODLE_INTERNAL') || die(); -$capabilities = array( - 'mod/attendance:view' => array( +$capabilities = [ + 'mod/attendance:view' => [ 'captype' => 'read', 'contextlevel' => CONTEXT_MODULE, - 'archetypes' => array( + 'archetypes' => [ 'student' => CAP_ALLOW, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) - ), + 'manager' => CAP_ALLOW, + ], + ], - 'mod/attendance:addinstance' => array( + 'mod/attendance:addinstance' => [ 'riskbitmask' => RISK_XSS, 'captype' => 'write', 'contextlevel' => CONTEXT_COURSE, - 'archetypes' => array( + 'archetypes' => [ 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ), - 'clonepermissionsfrom' => 'moodle/course:manageactivities' - ), + 'manager' => CAP_ALLOW, + ], + 'clonepermissionsfrom' => 'moodle/course:manageactivities', + ], - 'mod/attendance:viewreports' => array( + 'mod/attendance:viewreports' => [ 'riskbitmask' => RISK_PERSONAL, 'captype' => 'read', 'contextlevel' => CONTEXT_MODULE, - 'archetypes' => array( + 'archetypes' => [ 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) - ), + 'manager' => CAP_ALLOW, + ], + ], - 'mod/attendance:takeattendances' => array( + 'mod/attendance:takeattendances' => [ 'riskbitmask' => RISK_DATALOSS, 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, - 'archetypes' => array( + 'archetypes' => [ 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) - ), + 'manager' => CAP_ALLOW, + ], + ], - 'mod/attendance:changeattendances' => array( + 'mod/attendance:changeattendances' => [ 'riskbitmask' => RISK_DATALOSS, 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, - 'archetypes' => array( + 'archetypes' => [ 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) - ), + 'manager' => CAP_ALLOW, + ], + ], - 'mod/attendance:manageattendances' => array( + 'mod/attendance:manageattendances' => [ 'riskbitmask' => RISK_CONFIG, 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, - 'archetypes' => array( + 'archetypes' => [ 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) - ), + 'manager' => CAP_ALLOW, + ], + ], - 'mod/attendance:changepreferences' => array( + 'mod/attendance:changepreferences' => [ 'riskbitmask' => RISK_CONFIG, 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, - 'archetypes' => array( + 'archetypes' => [ 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) - ), + 'manager' => CAP_ALLOW, + ], + ], - 'mod/attendance:import' => array( + 'mod/attendance:import' => [ 'riskbitmask' => RISK_PERSONAL, 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, - 'archetypes' => array( + 'archetypes' => [ 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) - ), + 'manager' => CAP_ALLOW, + ], + ], - 'mod/attendance:export' => array( + 'mod/attendance:export' => [ 'riskbitmask' => RISK_PERSONAL, 'captype' => 'read', 'contextlevel' => CONTEXT_MODULE, - 'archetypes' => array( + 'archetypes' => [ 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) - ), + 'manager' => CAP_ALLOW, + ], + ], - 'mod/attendance:canbelisted' => array( + 'mod/attendance:canbelisted' => [ 'riskbitmask' => RISK_PERSONAL, 'captype' => 'read', 'contextlevel' => CONTEXT_MODULE, - 'archetypes' => array( - 'student' => CAP_ALLOW - ) - ), + 'archetypes' => [ + 'student' => CAP_ALLOW, + ], + ], // Allow teachers to manage temporary users. - 'mod/attendance:managetemporaryusers' => array( + 'mod/attendance:managetemporaryusers' => [ 'riskbitmask' => RISK_DATALOSS, 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, - 'archetypes' => array( + 'archetypes' => [ 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) - ), + 'manager' => CAP_ALLOW, + ], + ], // Allow access to site level reports. - 'mod/attendance:viewsummaryreports' => array( + 'mod/attendance:viewsummaryreports' => [ 'riskbitmask' => RISK_PERSONAL, 'captype' => 'read', 'contextlevel' => CONTEXT_COURSECAT, - 'archetypes' => array( - 'manager' => CAP_ALLOW - ) - ), + 'archetypes' => [ + 'manager' => CAP_ALLOW, + ], + ], // Users that can receive extra warning e-mails. - 'mod/attendance:warningemails' => array( + 'mod/attendance:warningemails' => [ 'riskbitmask' => RISK_DATALOSS, 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, - 'archetypes' => array( + 'archetypes' => [ 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) - ), - 'mod/attendance:manualautomark' => array( + 'manager' => CAP_ALLOW, + ], + ], + 'mod/attendance:manualautomark' => [ 'riskbitmask' => RISK_XSS, 'captype' => 'write', 'contextlevel' => CONTEXT_COURSE, - 'archetypes' => array( + 'archetypes' => [ 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ), - 'clonepermissionsfrom' => 'moodle/course:manageactivities' - ), -); + 'manager' => CAP_ALLOW, + ], + 'clonepermissionsfrom' => 'moodle/course:manageactivities', + ], +]; diff --git a/db/events.php b/db/events.php index 6b877b34893..eb096e3c254 100644 --- a/db/events.php +++ b/db/events.php @@ -26,11 +26,11 @@ defined('MOODLE_INTERNAL') || die(); // List of observers. -$observers = array( +$observers = [ - array( + [ 'eventname' => '\core\event\course_content_deleted', 'callback' => 'mod_attendance_observer::course_content_deleted', - ), + ], -); +]; diff --git a/db/install.php b/db/install.php index 6a9a1d65e6c..6b84727a31d 100644 --- a/db/install.php +++ b/db/install.php @@ -29,7 +29,7 @@ function xmldb_attendance_install() { global $DB; $result = true; - $arr = array('P' => 2, 'A' => 0, 'L' => 1, 'E' => 1); + $arr = ['P' => 2, 'A' => 0, 'L' => 1, 'E' => 1]; foreach ($arr as $k => $v) { $rec = new stdClass; $rec->attendanceid = 0; @@ -42,7 +42,7 @@ function xmldb_attendance_install() { $rec->grade = $v; $rec->visible = 1; $rec->deleted = 0; - if (!$DB->record_exists('attendance_statuses', array('attendanceid' => 0, 'acronym' => $rec->acronym))) { + if (!$DB->record_exists('attendance_statuses', ['attendanceid' => 0, 'acronym' => $rec->acronym])) { $result = $result && $DB->insert_record('attendance_statuses', $rec); } } diff --git a/db/mobile.php b/db/mobile.php index 14999744371..74136ef4ea7 100644 --- a/db/mobile.php +++ b/db/mobile.php @@ -36,9 +36,9 @@ 'method' => 'mobile_view_activity', 'styles' => [ 'url' => $CFG->wwwroot . '/mod/attendance/mobilestyles.css', - 'version' => 22 - ] - ] + 'version' => 22, + ], + ], ], 'lang' => [ // Language strings that are used in all the handlers. ['pluginname', 'attendance'], @@ -64,7 +64,7 @@ ['enterpassword', 'attendance'], ['incorrectpasswordshort', 'attendance'], ['attendancesuccess', 'attendance'], - ['setallstatuses', 'attendance'] + ['setallstatuses', 'attendance'], ], - ] + ], ]; diff --git a/db/services.php b/db/services.php index 4e0f0496b0b..cd5c1c4b99c 100644 --- a/db/services.php +++ b/db/services.php @@ -24,70 +24,70 @@ defined('MOODLE_INTERNAL') || die(); -$functions = array( - 'mod_attendance_add_attendance' => array( +$functions = [ + 'mod_attendance_add_attendance' => [ 'classname' => 'mod_attendance_external', 'methodname' => 'add_attendance', 'classpath' => 'mod/attendance/externallib.php', 'description' => 'Add attendance instance to course.', 'type' => 'write', - ), - 'mod_attendance_remove_attendance' => array( + ], + 'mod_attendance_remove_attendance' => [ 'classname' => 'mod_attendance_external', 'methodname' => 'remove_attendance', 'classpath' => 'mod/attendance/externallib.php', 'description' => 'Delete attendance instance.', 'type' => 'write', - ), - 'mod_attendance_add_session' => array( + ], + 'mod_attendance_add_session' => [ 'classname' => 'mod_attendance_external', 'methodname' => 'add_session', 'classpath' => 'mod/attendance/externallib.php', 'description' => 'Add a new session.', 'type' => 'write', - ), - 'mod_attendance_remove_session' => array( + ], + 'mod_attendance_remove_session' => [ 'classname' => 'mod_attendance_external', 'methodname' => 'remove_session', 'classpath' => 'mod/attendance/externallib.php', 'description' => 'Delete a session.', 'type' => 'write', - ), - 'mod_attendance_get_courses_with_today_sessions' => array( + ], + 'mod_attendance_get_courses_with_today_sessions' => [ 'classname' => 'mod_attendance_external', 'methodname' => 'get_courses_with_today_sessions', 'classpath' => 'mod/attendance/externallib.php', 'description' => 'Method that retrieves courses with today sessions of a teacher.', 'type' => 'read', - ), - 'mod_attendance_get_session' => array( + ], + 'mod_attendance_get_session' => [ 'classname' => 'mod_attendance_external', 'methodname' => 'get_session', 'classpath' => 'mod/attendance/externallib.php', 'description' => 'Method that retrieves the session data', 'type' => 'read', - ), - 'mod_attendance_update_user_status' => array( + ], + 'mod_attendance_update_user_status' => [ 'classname' => 'mod_attendance_external', 'methodname' => 'update_user_status', 'classpath' => 'mod/attendance/externallib.php', 'description' => 'Method that updates the user status in a session.', 'type' => 'write', - ), - 'mod_attendance_get_sessions' => array( + ], + 'mod_attendance_get_sessions' => [ 'classname' => 'mod_attendance_external', 'methodname' => 'get_sessions', 'classpath' => 'mod/attendance/externallib.php', 'description' => 'Method that retrieves the sessions in an attendance instance.', 'type' => 'read', - ) -); + ], +]; // We define the services to install as pre-build services. A pre-build service is not editable by administrator. -$services = array( - 'Attendance' => array( - 'functions' => array( +$services = [ + 'Attendance' => [ + 'functions' => [ 'mod_attendance_add_attendance', 'mod_attendance_remove_attendance', 'mod_attendance_add_session', @@ -95,10 +95,10 @@ 'mod_attendance_get_courses_with_today_sessions', 'mod_attendance_get_session', 'mod_attendance_update_user_status', - 'mod_attendance_get_sessions' - ), + 'mod_attendance_get_sessions', + ], 'restrictedusers' => 0, 'enabled' => 1, - 'shortname' => 'mod_attendance' - ) -); + 'shortname' => 'mod_attendance', + ], +]; diff --git a/db/tasks.php b/db/tasks.php index 23cfce8fd6a..0813b5a8c38 100644 --- a/db/tasks.php +++ b/db/tasks.php @@ -24,29 +24,29 @@ defined('MOODLE_INTERNAL') || die(); -$tasks = array( - array( +$tasks = [ + [ 'classname' => 'mod_attendance\task\auto_mark', 'blocking' => 0, 'minute' => '8', 'hour' => '*', 'day' => '*', 'dayofweek' => '*', - 'month' => '*'), - array( + 'month' => '*', ], + [ 'classname' => 'mod_attendance\task\notify', 'blocking' => 0, 'minute' => '30', 'hour' => '1', 'day' => '*', 'dayofweek' => '*', - 'month' => '*'), - array( + 'month' => '*', ], + [ 'classname' => 'mod_attendance\task\clear_temporary_passwords', 'blocking' => 0, 'minute' => '0', 'hour' => '1', 'day' => '*', 'dayofweek' => '*', - 'month' => '*') -); + 'month' => '*', ], +]; diff --git a/db/upgrade.php b/db/upgrade.php index 592bf076304..733c687b02f 100755 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -67,21 +67,21 @@ function xmldb_attendance_upgrade($oldversion=0) { * Only update the user's custom capabilities where modifierid is not zero. */ $sql = $DB->sql_like('capability', '?').' AND modifierid <> 0'; - $rs = $DB->get_recordset_select('role_capabilities', $sql, array('%mod/attforblock%')); + $rs = $DB->get_recordset_select('role_capabilities', $sql, ['%mod/attforblock%']); foreach ($rs as $cap) { $renamedcapability = str_replace('mod/attforblock', 'mod/attendance', $cap->capability); - $exists = $DB->record_exists('role_capabilities', array('roleid' => $cap->roleid, 'capability' => $renamedcapability)); + $exists = $DB->record_exists('role_capabilities', ['roleid' => $cap->roleid, 'capability' => $renamedcapability]); if (!$exists) { - $DB->update_record('role_capabilities', array('id' => $cap->id, 'capability' => $renamedcapability)); + $DB->update_record('role_capabilities', ['id' => $cap->id, 'capability' => $renamedcapability]); } } // Delete old role capabilities. $sql = $DB->sql_like('capability', '?'); - $DB->delete_records_select('role_capabilities', $sql, array('%mod/attforblock%')); + $DB->delete_records_select('role_capabilities', $sql, ['%mod/attforblock%']); // Delete old capabilities. - $DB->delete_records_select('capabilities', 'component = ?', array('mod_attforblock')); + $DB->delete_records_select('capabilities', 'component = ?', ['mod_attforblock']); upgrade_mod_savepoint(true, 2014112001, 'attendance'); } @@ -99,7 +99,7 @@ function xmldb_attendance_upgrade($oldversion=0) { $table->add_field('created', XMLDB_TYPE_INTEGER, '10', null, null, null, null); // Adding keys to table attendance_tempusers. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']); // Conditionally launch create table for attendance_tempusers. if (!$dbman->table_exists($table)) { @@ -107,13 +107,13 @@ function xmldb_attendance_upgrade($oldversion=0) { } // Conditionally launch add index courseid. - $index = new xmldb_index('courseid', XMLDB_INDEX_NOTUNIQUE, array('courseid')); + $index = new xmldb_index('courseid', XMLDB_INDEX_NOTUNIQUE, ['courseid']); if (!$dbman->index_exists($table, $index)) { $dbman->add_index($table, $index); } // Conditionally launch add index studentid. - $index = new xmldb_index('studentid', XMLDB_INDEX_UNIQUE, array('studentid')); + $index = new xmldb_index('studentid', XMLDB_INDEX_UNIQUE, ['studentid']); if (!$dbman->index_exists($table, $index)) { $dbman->add_index($table, $index); } @@ -274,7 +274,7 @@ function xmldb_attendance_upgrade($oldversion=0) { foreach ($attendances as $attendance) { if (!empty($attendance->subnet)) { // Get all sessions for this attendance. - $sessions = $DB->get_recordset('attendance_sessions', array('attendanceid' => $attendance->id)); + $sessions = $DB->get_recordset('attendance_sessions', ['attendanceid' => $attendance->id]); foreach ($sessions as $session) { $session->subnet = $attendance->subnet; $DB->update_record('attendance_sessions', $session); @@ -351,10 +351,10 @@ function xmldb_attendance_upgrade($oldversion=0) { $table->add_field('timesent', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); // Adding keys to table attendance_warning_done. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']); // Adding indexes to table attendance_warning_done. - $table->add_index('notifyid_userid', XMLDB_INDEX_UNIQUE, array('notifyid', 'userid')); + $table->add_index('notifyid_userid', XMLDB_INDEX_UNIQUE, ['notifyid', 'userid']); // Conditionally launch create table for attendance_warning_done. if (!$dbman->table_exists($table)) { @@ -383,8 +383,8 @@ function xmldb_attendance_upgrade($oldversion=0) { $table->add_field('thirdpartyemails', XMLDB_TYPE_TEXT, null, null, null, null, null); // Adding keys to table attendance_warning. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - $table->add_key('level_id', XMLDB_KEY_UNIQUE, array('idnumber', 'warningpercent', 'warnafter')); + $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']); + $table->add_key('level_id', XMLDB_KEY_UNIQUE, ['idnumber', 'warningpercent', 'warnafter']); // Conditionally launch create table for attendance_warning. $dbman->create_table($table); @@ -399,7 +399,7 @@ function xmldb_attendance_upgrade($oldversion=0) { $DB->execute("DROP INDEX ". $name); } } - $index = new xmldb_key('level_id', XMLDB_KEY_UNIQUE, array('idnumber', 'warningpercent', 'warnafter')); + $index = new xmldb_key('level_id', XMLDB_KEY_UNIQUE, ['idnumber', 'warningpercent', 'warnafter']); $dbman->add_key($table, $index); } // Attendance savepoint reached. @@ -423,12 +423,12 @@ function xmldb_attendance_upgrade($oldversion=0) { // Define field setunmarked to be added to attendance_statuses. $table = new xmldb_table('attendance_warning_done'); - $index = new xmldb_index('notifyid_userid', XMLDB_INDEX_UNIQUE, array('notifyid', 'userid')); + $index = new xmldb_index('notifyid_userid', XMLDB_INDEX_UNIQUE, ['notifyid', 'userid']); if ($dbman->index_exists($table, $index)) { $dbman->drop_index($table, $index); } - $index = new xmldb_index('notifyid', XMLDB_INDEX_NOTUNIQUE, array('notifyid', 'userid')); + $index = new xmldb_index('notifyid', XMLDB_INDEX_NOTUNIQUE, ['notifyid', 'userid']); $dbman->add_index($table, $index); // Attendance savepoint reached. @@ -630,7 +630,7 @@ function xmldb_attendance_upgrade($oldversion=0) { $table = new xmldb_table('attendance_sessions'); // Conditionally launch add index caleventid. - $index = new xmldb_index('caleventid', XMLDB_INDEX_NOTUNIQUE, array('caleventid')); + $index = new xmldb_index('caleventid', XMLDB_INDEX_NOTUNIQUE, ['caleventid']); if (!$dbman->index_exists($table, $index)) { $dbman->add_index($table, $index); } diff --git a/db/upgradelib.php b/db/upgradelib.php index dc531b857c0..f9fdaa38d19 100644 --- a/db/upgradelib.php +++ b/db/upgradelib.php @@ -30,7 +30,7 @@ function attendance_upgrade_create_calendar_events() { $attendances = $DB->get_records('attendance', null, null, 'id, name, course'); foreach ($attendances as $att) { - $sessionsdata = $DB->get_records('attendance_sessions', array('attendanceid' => $att->id), null, + $sessionsdata = $DB->get_records('attendance_sessions', ['attendanceid' => $att->id], null, 'id, groupid, sessdate, duration, description, descriptionformat'); foreach ($sessionsdata as $session) { $calevent = new stdClass(); @@ -47,7 +47,7 @@ function attendance_upgrade_create_calendar_events() { $calevent->format = $session->descriptionformat; $caleventid = $DB->insert_record('event', $calevent); - $DB->set_field('attendance_sessions', 'caleventid', $caleventid, array('id' => $session->id)); + $DB->set_field('attendance_sessions', 'caleventid', $caleventid, ['id' => $session->id]); } } } diff --git a/defaultstatus.php b/defaultstatus.php index 714d79227d4..299bccdea4a 100644 --- a/defaultstatus.php +++ b/defaultstatus.php @@ -31,7 +31,7 @@ $action = optional_param('action', null, PARAM_INT); $statusid = optional_param('statusid', null, PARAM_INT); admin_externalpage_setup('managemodules'); -$url = new moodle_url('/mod/attendance/defaultstatus.php', array('statusid' => $statusid, 'action' => $action)); +$url = new moodle_url('/mod/attendance/defaultstatus.php', ['statusid' => $statusid, 'action' => $action]); // Check sesskey if we are performing an action. if (!empty($action)) { @@ -45,7 +45,7 @@ echo $tabmenu; // TODO: Would be good to combine this code block with the one in preferences to avoid duplication. -$errors = array(); +$errors = []; switch ($action) { case mod_attendance_preferences_page_params::ACTION_ADD: $newacronym = optional_param('newacronym', null, PARAM_TEXT); diff --git a/export.php b/export.php index 1c00da10f56..66def2af10e 100644 --- a/export.php +++ b/export.php @@ -32,8 +32,8 @@ $id = required_param('id', PARAM_INT); $cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); -$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); -$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); +$att = $DB->get_record('attendance', ['id' => $cm->instance], '*', MUST_EXIST); require_login($course, true, $cm); @@ -49,7 +49,7 @@ $PAGE->set_cacheable(true); $PAGE->navbar->add(get_string('export', 'attendance')); -$formparams = array('course' => $course, 'cm' => $cm, 'modcontext' => $context); +$formparams = ['course' => $course, 'cm' => $cm, 'modcontext' => $context]; $mform = new mod_attendance\form\export($att->url_export(), $formparams); if ($formdata = $mform->get_data()) { @@ -87,7 +87,7 @@ $group = $formdata->group ? $reportdata->groups[$formdata->group] : 0; $data = new stdClass; - $data->tabhead = array(); + $data->tabhead = []; $data->course = $att->course->fullname; $data->group = $group ? $group->name : get_string('allparticipants'); @@ -107,7 +107,7 @@ } else if (in_array($opt, array_column($customfields, 'shortname'))) { foreach ($customfields as $customfield) { if ($opt == $customfield->shortname) { - $data->tabhead[] = format_string($customfield->name, true, array('context' => $context)); + $data->tabhead[] = format_string($customfield->name, true, ['context' => $context]); } } } else { @@ -151,7 +151,7 @@ $data->tabhead[] = get_string('percentage', 'attendance'); $i = 0; - $data->table = array(); + $data->table = []; foreach ($reportdata->users as $user) { profile_load_custom_fields($user); @@ -160,7 +160,7 @@ if (!empty($groupmode)) { $grouptext = ''; $groupsraw = groups_get_all_groups($course->id, $user->id, 0, 'g.name'); - $groups = array(); + $groups = []; foreach ($groupsraw as $group) { $groups[] = $group->name;; } @@ -171,7 +171,7 @@ foreach (array_keys($formdata->ident) as $opt) { if (in_array($opt, array_column($customfields, 'shortname'))) { if (isset($user->profile[$opt])) { - $data->table[$i][] = format_string($user->profile[$opt], true, array('context' => $context)); + $data->table[$i][] = format_string($user->profile[$opt], true, ['context' => $context]); } else { $data->table[$i][] = ''; } diff --git a/externallib.php b/externallib.php index 7da17a0a20f..a332c5f6607 100644 --- a/externallib.php +++ b/externallib.php @@ -41,13 +41,13 @@ class mod_attendance_external extends external_api { */ public static function add_attendance_parameters() { return new external_function_parameters( - array( + [ '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), - ) + ] ); } @@ -64,15 +64,15 @@ public static function add_attendance(int $courseid, $name, $intro, int $groupmo global $CFG, $DB; require_once($CFG->dirroot.'/course/modlib.php'); - $params = self::validate_parameters(self::add_attendance_parameters(), array( + $params = self::validate_parameters(self::add_attendance_parameters(), [ 'courseid' => $courseid, 'name' => $name, 'intro' => $intro, 'groupmode' => $groupmode, - )); + ]); // Get course. - $course = $DB->get_record('course', array('id' => $params['courseid']), '*', MUST_EXIST); + $course = $DB->get_record('course', ['id' => $params['courseid']], '*', MUST_EXIST); // Verify permissions. list($module, $context) = can_add_moduleinfo($course, 'attendance', 0); @@ -80,7 +80,7 @@ public static function add_attendance(int $courseid, $name, $intro, int $groupmo require_capability('mod/attendance:addinstance', $context); // Verify group mode. - if (!in_array($params['groupmode'], array(NOGROUPS, SEPARATEGROUPS, VISIBLEGROUPS))) { + if (!in_array($params['groupmode'], [NOGROUPS, SEPARATEGROUPS, VISIBLEGROUPS])) { throw new invalid_parameter_exception('Group mode is invalid.'); } @@ -103,7 +103,7 @@ public static function add_attendance(int $courseid, $name, $intro, int $groupmo // Add the module to the course. $moduleinfo = add_moduleinfo($moduleinfo, $course); - return array('attendanceid' => $moduleinfo->instance); + return ['attendanceid' => $moduleinfo->instance]; } /** @@ -112,9 +112,9 @@ public static function add_attendance(int $courseid, $name, $intro, int $groupmo * @return external_multiple_structure */ public static function add_attendance_returns() { - return new external_single_structure(array( + return new external_single_structure([ 'attendanceid' => new external_value(PARAM_INT, 'instance id of the created attendance'), - )); + ]); } /** @@ -124,9 +124,9 @@ public static function add_attendance_returns() { */ public static function remove_attendance_parameters() { return new external_function_parameters( - array( + [ 'attendanceid' => new external_value(PARAM_INT, 'attendance instance id'), - ) + ] ); } @@ -136,9 +136,9 @@ public static function remove_attendance_parameters() { * @param int $attendanceid */ public static function remove_attendance(int $attendanceid) { - $params = self::validate_parameters(self::remove_attendance_parameters(), array( + $params = self::validate_parameters(self::remove_attendance_parameters(), [ 'attendanceid' => $attendanceid, - )); + ]); $cm = get_coursemodule_from_instance('attendance', $params['attendanceid'], 0, false, MUST_EXIST); @@ -169,14 +169,14 @@ public static function remove_attendance_returns() { */ public static function add_session_parameters() { return new external_function_parameters( - array( + [ 'attendanceid' => new external_value(PARAM_INT, 'attendance instance id'), 'description' => new external_value(PARAM_RAW, 'description', VALUE_DEFAULT, ''), 'sessiontime' => new external_value(PARAM_INT, 'session start timestamp'), 'duration' => new external_value(PARAM_INT, 'session duration (seconds)', VALUE_DEFAULT, 0), 'groupid' => new external_value(PARAM_INT, 'group id', VALUE_DEFAULT, 0), 'addcalendarevent' => new external_value(PARAM_BOOL, 'add calendar event', VALUE_DEFAULT, true), - ) + ] ); } @@ -195,18 +195,18 @@ public static function add_session(int $attendanceid, $description, int $session bool $addcalendarevent) { global $USER, $DB; - $params = self::validate_parameters(self::add_session_parameters(), array( + $params = self::validate_parameters(self::add_session_parameters(), [ 'attendanceid' => $attendanceid, 'description' => $description, 'sessiontime' => $sessiontime, 'duration' => $duration, 'groupid' => $groupid, 'addcalendarevent' => $addcalendarevent, - )); + ]); $cm = get_coursemodule_from_instance('attendance', $params['attendanceid'], 0, false, MUST_EXIST); - $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); - $attendance = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); + $course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); + $attendance = $DB->get_record('attendance', ['id' => $cm->instance], '*', MUST_EXIST); // Check permissions. $context = context_module::instance($cm->id); @@ -260,7 +260,7 @@ public static function add_session(int $attendanceid, $description, int $session $sess->studentsearlyopentime = get_config('attendance', 'studentsearlyopentime'); $sessionid = $attendance->add_session($sess); - return array('sessionid' => $sessionid); + return ['sessionid' => $sessionid]; } /** @@ -269,9 +269,9 @@ public static function add_session(int $attendanceid, $description, int $session * @return external_multiple_structure */ public static function add_session_returns() { - return new external_single_structure(array( + return new external_single_structure([ 'sessionid' => new external_value(PARAM_INT, 'id of the created session'), - )); + ]); } /** @@ -281,9 +281,9 @@ public static function add_session_returns() { */ public static function remove_session_parameters() { return new external_function_parameters( - array( + [ 'sessionid' => new external_value(PARAM_INT, 'session id'), - ) + ] ); } @@ -297,12 +297,12 @@ public static function remove_session(int $sessionid) { global $DB; $params = self::validate_parameters(self::remove_session_parameters(), - array('sessionid' => $sessionid)); + ['sessionid' => $sessionid]); - $session = $DB->get_record('attendance_sessions', array('id' => $params['sessionid']), '*', MUST_EXIST); - $attendance = $DB->get_record('attendance', array('id' => $session->attendanceid), '*', MUST_EXIST); + $session = $DB->get_record('attendance_sessions', ['id' => $params['sessionid']], '*', MUST_EXIST); + $attendance = $DB->get_record('attendance', ['id' => $session->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); + $course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); // Check permissions. $context = context_module::instance($cm->id); @@ -313,7 +313,7 @@ public static function remove_session(int $sessionid) { $attendance = new mod_attendance_structure($attendance, $cm, $course, $context); // Delete session. - $attendance->delete_sessions(array($sessionid)); + $attendance->delete_sessions([$sessionid]); attendance_update_users_grade($attendance); return true; @@ -334,7 +334,7 @@ public static function remove_session_returns() { */ public static function get_courses_with_today_sessions_parameters() { return new external_function_parameters ( - array('userid' => new external_value(PARAM_INT, 'User id.', VALUE_DEFAULT, 0))); + ['userid' => new external_value(PARAM_INT, 'User id.', VALUE_DEFAULT, 0)]); } /** @@ -345,12 +345,12 @@ public static function get_courses_with_today_sessions_parameters() { public static function get_courses_with_today_sessions($userid) { global $DB; - $params = self::validate_parameters(self::get_courses_with_today_sessions_parameters(), array( + $params = self::validate_parameters(self::get_courses_with_today_sessions_parameters(), [ 'userid' => $userid, - )); + ]); // Check user id is valid. - $user = $DB->get_record('user', array('id' => $params['userid']), '*', MUST_EXIST); + $user = $DB->get_record('user', ['id' => $params['userid']], '*', MUST_EXIST); // Capability check is done in get_courses_with_today_sessions // as it switches contexts in loop for each course. @@ -363,7 +363,7 @@ public static function get_courses_with_today_sessions($userid) { * @return array */ private static function get_session_structure() { - $session = array('id' => new external_value(PARAM_INT, 'Session id.'), + $session = ['id' => new external_value(PARAM_INT, 'Session id.'), 'attendanceid' => new external_value(PARAM_INT, 'Attendance id.'), 'groupid' => new external_value(PARAM_INT, 'Group id.'), 'sessdate' => new external_value(PARAM_INT, 'Session date.'), @@ -380,7 +380,7 @@ private static function get_session_structure() { 'preventsharediptime' => new external_value(PARAM_INT, 'Time delay before IP address is allowed again.'), 'statusset' => new external_value(PARAM_INT, 'Session statusset.'), 'includeqrcode' => new external_value(PARAM_INT, 'Include QR code when displaying password'), - 'studentsearlyopentime' => new external_value(PARAM_INT, 'Duration to allow session to opened early')); + 'studentsearlyopentime' => new external_value(PARAM_INT, 'Duration to allow session to opened early'), ]; return $session; } @@ -392,14 +392,14 @@ private static function get_session_structure() { public static function get_courses_with_today_sessions_returns() { $todaysessions = self::get_session_structure(); - $attendanceinstances = array('name' => new external_value(PARAM_TEXT, 'Attendance name.'), + $attendanceinstances = ['name' => new external_value(PARAM_TEXT, 'Attendance name.'), 'today_sessions' => new external_multiple_structure( - new external_single_structure($todaysessions))); + new external_single_structure($todaysessions)), ]; - $courses = array('shortname' => new external_value(PARAM_TEXT, 'short name of a moodle course.'), + $courses = ['shortname' => new external_value(PARAM_TEXT, 'short name of a moodle course.'), 'fullname' => new external_value(PARAM_TEXT, 'full name of a moodle course.'), 'attendance_instances' => new external_multiple_structure( - new external_single_structure($attendanceinstances))); + new external_single_structure($attendanceinstances)), ]; return new external_multiple_structure(new external_single_structure(($courses))); } @@ -411,7 +411,7 @@ public static function get_courses_with_today_sessions_returns() { */ public static function get_session_parameters() { return new external_function_parameters ( - array('sessionid' => new external_value(PARAM_INT, 'session id'))); + ['sessionid' => new external_value(PARAM_INT, 'session id')]); } /** @@ -423,22 +423,22 @@ public static function get_session_parameters() { public static function get_session($sessionid) { global $DB; - $params = self::validate_parameters(self::get_session_parameters(), array( + $params = self::validate_parameters(self::get_session_parameters(), [ 'sessionid' => $sessionid, - )); + ]); - $session = $DB->get_record('attendance_sessions', array('id' => $params['sessionid']), '*', MUST_EXIST); - $attendance = $DB->get_record('attendance', array('id' => $session->attendanceid), '*', MUST_EXIST); + $session = $DB->get_record('attendance_sessions', ['id' => $params['sessionid']], '*', MUST_EXIST); + $attendance = $DB->get_record('attendance', ['id' => $session->attendanceid], '*', MUST_EXIST); $cm = get_coursemodule_from_instance('attendance', $attendance->id, 0, false, MUST_EXIST); // Check permissions. $context = context_module::instance($cm->id); self::validate_context($context); - $capabilities = array( + $capabilities = [ 'mod/attendance:manageattendances', 'mod/attendance:takeattendances', - 'mod/attendance:changeattendances' - ); + 'mod/attendance:changeattendances', + ]; if (!has_any_capability($capabilities, $context)) { throw new invalid_parameter_exception('Invalid session id or no permissions.'); } @@ -452,23 +452,23 @@ public static function get_session($sessionid) { * @return external_single_structure */ public static function get_session_returns() { - $statuses = array('id' => new external_value(PARAM_INT, 'Status id.'), + $statuses = ['id' => new external_value(PARAM_INT, 'Status id.'), 'attendanceid' => new external_value(PARAM_INT, 'Attendance id.'), 'acronym' => new external_value(PARAM_TEXT, 'Status acronym.'), 'description' => new external_value(PARAM_RAW, 'Status description.'), 'grade' => new external_value(PARAM_FLOAT, 'Status grade.'), 'visible' => new external_value(PARAM_INT, 'Status visibility.'), 'deleted' => new external_value(PARAM_INT, 'informs if this session was deleted.'), - 'setnumber' => new external_value(PARAM_INT, 'Set number.')); + 'setnumber' => new external_value(PARAM_INT, 'Set number.'), ]; - $users = array('id' => new external_value(PARAM_INT, 'User id.'), + $users = ['id' => new external_value(PARAM_INT, 'User id.'), 'firstname' => new external_value(PARAM_TEXT, 'User first name.'), - 'lastname' => new external_value(PARAM_TEXT, 'User last name.')); + 'lastname' => new external_value(PARAM_TEXT, 'User last name.'), ]; - $attendancelog = array('studentid' => new external_value(PARAM_INT, 'Student id.'), + $attendancelog = ['studentid' => new external_value(PARAM_INT, 'Student id.'), 'statusid' => new external_value(PARAM_TEXT, 'Status id (last time).'), 'remarks' => new external_value(PARAM_TEXT, 'Last remark.'), - 'id' => new external_value(PARAM_TEXT, 'log id.')); + 'id' => new external_value(PARAM_TEXT, 'log id.'), ]; $session = self::get_session_structure(); $session['courseid'] = new external_value(PARAM_INT, 'Course moodle id.'); @@ -486,11 +486,11 @@ public static function get_session_returns() { */ public static function update_user_status_parameters() { return new external_function_parameters( - array('sessionid' => new external_value(PARAM_INT, 'Session id'), + ['sessionid' => new external_value(PARAM_INT, 'Session id'), 'studentid' => new external_value(PARAM_INT, 'Student id'), 'takenbyid' => new external_value(PARAM_INT, 'Id of the user who took this session'), 'statusid' => new external_value(PARAM_INT, 'Status id'), - 'statusset' => new external_value(PARAM_TEXT, 'Status set of session'))); + 'statusset' => new external_value(PARAM_TEXT, 'Status set of session')]); } /** @@ -505,15 +505,15 @@ public static function update_user_status_parameters() { public static function update_user_status($sessionid, $studentid, $takenbyid, $statusid, $statusset) { global $DB; - $params = self::validate_parameters(self::update_user_status_parameters(), array( + $params = self::validate_parameters(self::update_user_status_parameters(), [ 'sessionid' => $sessionid, 'studentid' => $studentid, 'takenbyid' => $takenbyid, 'statusid' => $statusid, 'statusset' => $statusset, - )); + ]); - $session = $DB->get_record('attendance_sessions', array('id' => $params['sessionid']), '*', MUST_EXIST); + $session = $DB->get_record('attendance_sessions', ['id' => $params['sessionid']], '*', MUST_EXIST); $cm = get_coursemodule_from_instance('attendance', $session->attendanceid, 0, false, MUST_EXIST); // Check permissions. @@ -530,8 +530,8 @@ public static function update_user_status($sessionid, $studentid, $takenbyid, $s } // Check user id is valid. - $student = $DB->get_record('user', array('id' => $params['studentid']), '*', MUST_EXIST); - $takenby = $DB->get_record('user', array('id' => $params['takenbyid']), '*', MUST_EXIST); + $student = $DB->get_record('user', ['id' => $params['studentid']], '*', MUST_EXIST); + $takenby = $DB->get_record('user', ['id' => $params['takenbyid']], '*', MUST_EXIST); // TODO: Verify statusset and statusid. @@ -554,9 +554,9 @@ public static function update_user_status_returns() { */ public static function get_sessions_parameters() { return new external_function_parameters( - array( + [ 'attendanceid' => new external_value(PARAM_INT, 'Attendance id.', VALUE_REQUIRED), - ) + ] ); } @@ -575,20 +575,20 @@ public static function get_sessions_returns() { * @param int $attendanceid */ public static function get_sessions($attendanceid) { - $params = self::validate_parameters(self::get_sessions_parameters(), array( + $params = self::validate_parameters(self::get_sessions_parameters(), [ 'attendanceid' => $attendanceid, - )); + ]); // Check permissions. $cm = get_coursemodule_from_instance('attendance', $attendanceid, 0, false, MUST_EXIST); $context = context_module::instance($cm->id); self::validate_context($context); - $capabilities = array( + $capabilities = [ 'mod/attendance:manageattendances', 'mod/attendance:takeattendances', - 'mod/attendance:changeattendances' - ); + 'mod/attendance:changeattendances', + ]; if (!has_any_capability($capabilities, $context)) { throw new invalid_parameter_exception('Invalid session id or no permissions.'); } diff --git a/import.php b/import.php index 0e69e348c4a..f81f5031db3 100644 --- a/import.php +++ b/import.php @@ -33,8 +33,8 @@ $id = required_param('id', PARAM_INT); $cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); -$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); -$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); +$att = $DB->get_record('attendance', ['id' => $cm->instance], '*', MUST_EXIST); require_login($course, true, $cm); @@ -50,7 +50,7 @@ $PAGE->set_cacheable(true); $PAGE->navbar->add(get_string('import', 'attendance')); -$formparams = array('course' => $course, 'cm' => $cm, 'modcontext' => $context); +$formparams = ['course' => $course, 'cm' => $cm, 'modcontext' => $context]; $form = null; if (optional_param('confirm', 0, PARAM_BOOL)) { diff --git a/import/marksessions.php b/import/marksessions.php index d0963370d13..37a4951810c 100644 --- a/import/marksessions.php +++ b/import/marksessions.php @@ -38,11 +38,11 @@ $importid = optional_param('importid', null, PARAM_INT); $cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); -$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); -$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); +$att = $DB->get_record('attendance', ['id' => $cm->instance], '*', MUST_EXIST); // Check this is a valid session for this attendance. -$session = $DB->get_record('attendance_sessions', array('id' => $pageparams->sessionid, 'attendanceid' => $att->id), +$session = $DB->get_record('attendance_sessions', ['id' => $pageparams->sessionid, 'attendanceid' => $att->id], '*', MUST_EXIST); require_login($course, true, $cm); @@ -66,7 +66,7 @@ $formparams = ['id' => $cm->id, 'sessionid' => $pageparams->sessionid, - 'grouptype' => $pageparams->grouptype]; + 'grouptype' => $pageparams->grouptype, ]; $form = null; if (optional_param('needsconfirm', 0, PARAM_BOOL)) { $form = new \mod_attendance\form\import\marksessions($url->out(false), $formparams); @@ -80,9 +80,9 @@ if ($form->is_cancelled()) { redirect(new moodle_url('/mod/attendance/take.php', - array('id' => $cm->id, + ['id' => $cm->id, 'sessionid' => $pageparams->sessionid, - 'grouptype' => $pageparams->grouptype))); + 'grouptype' => $pageparams->grouptype, ])); return; } else if ($data = $form->get_data()) { if ($data->confirm) { @@ -96,7 +96,7 @@ echo $output->header(); $sessions = $importer->import(); mod_attendance_notifyqueue::show(); - $url = new moodle_url('/mod/attendance/manage.php', array('id' => $att->cmid)); + $url = new moodle_url('/mod/attendance/manage.php', ['id' => $att->cmid]); echo $output->continue_button($url); echo $output->footer(); die(); diff --git a/index.php b/index.php index 4a45ad769d6..a1f2d30609a 100644 --- a/index.php +++ b/index.php @@ -26,10 +26,10 @@ $id = required_param('id', PARAM_INT); -$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $id], '*', MUST_EXIST); require_login($course); -$PAGE->set_url('/mod/attendance/index.php', array('id' => $id)); +$PAGE->set_url('/mod/attendance/index.php', ['id' => $id]); $PAGE->set_pagelayout('incourse'); \mod_attendance\event\course_module_instance_list_viewed::create_from_course($course)->trigger(); @@ -47,7 +47,7 @@ require_capability('mod/attendance:view', $context); if (! $atts = get_all_instances_in_course("attendance", $course)) { - $url = new moodle_url('/course/view.php', array('id' => $course->id)); + $url = new moodle_url('/course/view.php', ['id' => $course->id]); notice(get_string('thereareno', 'moodle', $strplural), $url); die; } @@ -63,24 +63,24 @@ if ($usesections) { $strsectionname = get_string('sectionname', 'format_'.$course->format); - $table->head = array ($strsectionname, $strname); - $table->align = array ("center", "left"); + $table->head = [$strsectionname, $strname]; + $table->align = ["center", "left"]; } else { - $table->head = array ($strname); - $table->align = array ("left"); + $table->head = [$strname]; + $table->align = ["left"]; } foreach ($atts as $att) { // Get the responses of each attendance. - $viewurl = new moodle_url('/mod/attendance/view.php', array('id' => $att->coursemodule)); + $viewurl = new moodle_url('/mod/attendance/view.php', ['id' => $att->coursemodule]); $dimmedclass = $att->visible ? '' : 'class="dimmed"'; $link = ''.$att->name.''; if ($usesections) { - $tabledata = array (get_section_name($course, $att->section), $link); + $tabledata = [get_section_name($course, $att->section), $link]; } else { - $tabledata = array ($link); + $tabledata = [$link]; } $table->data[] = $tabledata; diff --git a/lib.php b/lib.php index a040cd89ed7..b33c22e7c58 100644 --- a/lib.php +++ b/lib.php @@ -64,7 +64,7 @@ function attendance_supports($feature) { function att_add_default_statuses($attid) { global $DB; - $statuses = $DB->get_recordset('attendance_statuses', array('attendanceid' => 0), 'id'); + $statuses = $DB->get_recordset('attendance_statuses', ['attendanceid' => 0], 'id'); foreach ($statuses as $st) { $rec = $st; $rec->attendanceid = $attid; @@ -83,7 +83,7 @@ function attendance_add_default_warnings($id) { require_once($CFG->dirroot.'/mod/attendance/locallib.php'); $warnings = $DB->get_recordset('attendance_warning', - array('idnumber' => 0), 'id'); + ['idnumber' => 0], 'id'); foreach ($warnings as $n) { $rec = $n; $rec->idnumber = $id; @@ -151,22 +151,22 @@ function attendance_delete_instance($id) { global $DB, $CFG; require_once($CFG->dirroot.'/mod/attendance/locallib.php'); - if (! $attendance = $DB->get_record('attendance', array('id' => $id))) { + if (! $attendance = $DB->get_record('attendance', ['id' => $id])) { return false; } - if ($sessids = array_keys($DB->get_records('attendance_sessions', array('attendanceid' => $id), '', 'id'))) { + if ($sessids = array_keys($DB->get_records('attendance_sessions', ['attendanceid' => $id], '', 'id'))) { if (attendance_existing_calendar_events_ids($sessids)) { attendance_delete_calendar_events($sessids); } $DB->delete_records_list('attendance_log', 'sessionid', $sessids); - $DB->delete_records('attendance_sessions', array('attendanceid' => $id)); + $DB->delete_records('attendance_sessions', ['attendanceid' => $id]); } - $DB->delete_records('attendance_statuses', array('attendanceid' => $id)); + $DB->delete_records('attendance_statuses', ['attendanceid' => $id]); - $DB->delete_records('attendance_warning', array('idnumber' => $id)); + $DB->delete_records('attendance_warning', ['idnumber' => $id]); - $DB->delete_records('attendance', array('id' => $id)); + $DB->delete_records('attendance', ['id' => $id]); attendance_grade_item_delete($attendance); @@ -199,7 +199,7 @@ function attendance_reset_course_form_definition(&$mform) { * @return array */ function attendance_reset_course_form_defaults($course) { - return array('reset_attendance_log' => 0, 'reset_attendance_statuses' => 0, 'reset_attendance_sessions' => 0); + return ['reset_attendance_log' => 0, 'reset_attendance_statuses' => 0, 'reset_attendance_sessions' => 0]; } /** @@ -211,9 +211,9 @@ function attendance_reset_course_form_defaults($course) { function attendance_reset_userdata($data) { global $DB; - $status = array(); + $status = []; - $attids = array_keys($DB->get_records('attendance', array('course' => $data->courseid), '', 'id')); + $attids = array_keys($DB->get_records('attendance', ['course' => $data->courseid], '', 'id')); if (!empty($data->reset_attendance_log)) { $sess = $DB->get_records_list('attendance_sessions', 'attendanceid', $attids, '', 'id'); @@ -227,11 +227,11 @@ function attendance_reset_userdata($data) { $DB->set_field_select('attendance_sessions', 'automarkcompleted', 0, "attendanceid $sql", $params); } - $status[] = array( + $status[] = [ 'component' => get_string('modulenameplural', 'attendance'), 'item' => get_string('attendancedata', 'attendance'), - 'error' => false - ); + 'error' => false, + ]; } } @@ -241,11 +241,11 @@ function attendance_reset_userdata($data) { att_add_default_statuses($attid); } - $status[] = array( + $status[] = [ 'component' => get_string('modulenameplural', 'attendance'), 'item' => get_string('sessions', 'attendance'), - 'error' => false - ); + 'error' => false, + ]; } if (!empty($data->reset_attendance_sessions)) { @@ -255,11 +255,11 @@ function attendance_reset_userdata($data) { } $DB->delete_records_list('attendance_sessions', 'attendanceid', $attids); - $status[] = array( + $status[] = [ 'component' => get_string('modulenameplural', 'attendance'), 'item' => get_string('statuses', 'attendance'), - 'error' => false - ); + 'error' => false, + ]; } return $status; @@ -349,15 +349,15 @@ function attendance_grade_item_update($attendance, $grades=null) { if (!isset($attendance->courseid)) { $attendance->courseid = $attendance->course; } - if (!$DB->get_record('course', array('id' => $attendance->course))) { + if (!$DB->get_record('course', ['id' => $attendance->course])) { error("Course is misconfigured"); } if (!empty($attendance->cmidnumber)) { - $params = array('itemname' => $attendance->name, 'idnumber' => $attendance->cmidnumber); + $params = ['itemname' => $attendance->name, 'idnumber' => $attendance->cmidnumber]; } else { // MDL-14303. - $params = array('itemname' => $attendance->name); + $params = ['itemname' => $attendance->name]; } if ($attendance->grade > 0) { @@ -395,7 +395,7 @@ function attendance_grade_item_delete($attendance) { } return grade_update('mod/attendance', $attendance->courseid, 'mod', 'attendance', - $attendance->id, 0, null, array('deleted' => 1)); + $attendance->id, 0, null, ['deleted' => 1]); } /** @@ -444,18 +444,18 @@ function attendance_pluginfile($course, $cm, $context, $filearea, $args, $forced require_login($course, false, $cm); - if (!$DB->record_exists('attendance', array('id' => $cm->instance))) { + if (!$DB->record_exists('attendance', ['id' => $cm->instance])) { return false; } // Session area is served by pluginfile.php. - $fileareas = array('session'); + $fileareas = ['session']; if (!in_array($filearea, $fileareas)) { return false; } $sessid = (int)array_shift($args); - if (!$DB->record_exists('attendance_sessions', array('id' => $sessid))) { + if (!$DB->record_exists('attendance_sessions', ['id' => $sessid])) { return false; } @@ -476,7 +476,7 @@ function attendance_pluginfile($course, $cm, $context, $filearea, $args, $forced function attendance_print_settings_tabs($selected = 'settings') { global $CFG; // Print tabs for different settings pages. - $tabs = array(); + $tabs = []; $tabs[] = new tabobject('settings', "{$CFG->wwwroot}/{$CFG->admin}/settings.php?section=modsettingattendance", get_string('settings', 'attendance'), get_string('settings'), false); @@ -506,7 +506,7 @@ function attendance_print_settings_tabs($selected = 'settings') { get_string('importsessions', 'attendance'), get_string('importsessions', 'attendance'), false); ob_start(); - print_tabs(array($tabs), $selected); + print_tabs([$tabs], $selected); $tabmenu = ob_get_contents(); ob_end_clean(); @@ -586,34 +586,34 @@ function attendance_extend_settings_navigation(settings_navigation $settingsnav, $nodes = []; if (has_capability('mod/attendance:viewreports', $context)) { $nodes[] = ['url' => new moodle_url('/mod/attendance/report.php', ['id' => $cm->id]), - 'title' => get_string('report', 'attendance')]; + 'title' => get_string('report', 'attendance'), ]; } if (has_capability('mod/attendance:import', $context)) { $nodes[] = ['url' => new moodle_url('/mod/attendance/import.php', ['id' => $cm->id]), - 'title' => get_string('import', 'attendance')]; + 'title' => get_string('import', 'attendance'), ]; } if (has_capability('mod/attendance:export', $context)) { $nodes[] = ['url' => new moodle_url('/mod/attendance/export.php', ['id' => $cm->id]), - 'title' => get_string('export', 'attendance')]; + 'title' => get_string('export', 'attendance'), ]; } if (has_capability('mod/attendance:viewreports', $context) && get_config('attendance', 'enablewarnings')) { $nodes[] = ['url' => new moodle_url('/mod/attendance/absentee.php', ['id' => $cm->id]), - 'title' => get_string('absenteereport', 'attendance')]; + 'title' => get_string('absenteereport', 'attendance'), ]; } if (has_capability('mod/attendance:changepreferences', $context)) { $nodes[] = ['url' => new moodle_url('/mod/attendance/preferences.php', ['id' => $cm->id]), - 'title' => get_string('statussetsettings', 'attendance')]; + 'title' => get_string('statussetsettings', 'attendance'), ]; if (get_config('attendance', 'enablewarnings')) { $nodes[] = ['url' => new moodle_url('/mod/attendance/warnings.php', ['id' => $cm->id]), - 'title' => get_string('warnings', 'attendance')]; + 'title' => get_string('warnings', 'attendance'), ]; } } if (has_capability('mod/attendance:managetemporaryusers', context_module::instance($cm->id))) { $nodes[] = ['url' => new moodle_url('/mod/attendance/tempusers.php', ['id' => $cm->id]), 'title' => get_string('tempusers', 'attendance'), - 'more' => true]; + 'more' => true, ]; } foreach ($nodes as $node) { diff --git a/locallib.php b/locallib.php index a668b066b45..328989e9159 100644 --- a/locallib.php +++ b/locallib.php @@ -64,7 +64,7 @@ function attendance_get_statuses($attid, $onlyvisible=true, $statusset = -1) { global $DB; // Set selector. - $params = array('aid' => $attid); + $params = ['aid' => $attid]; $setsql = ''; if ($statusset >= 0) { $params['statusset'] = $statusset; @@ -94,7 +94,7 @@ function attendance_get_setname($attid, $statusset, $includevalues = true) { $statusname = get_string('statusset', 'mod_attendance', $statusset + 1); if ($includevalues) { $statuses = attendance_get_statuses($attid, true, $statusset); - $statusesout = array(); + $statusesout = []; foreach ($statuses as $status) { $statusesout[] = $status->acronym; } @@ -125,24 +125,24 @@ function attendance_get_user_sessions_log_full($userid, $pageparams) { list($usql, $uparams) = $DB->get_in_or_equal(array_keys($usercourses), SQL_PARAMS_NAMED, 'cid0'); $coursesql = "(1 = 1)"; - $courseparams = array(); + $courseparams = []; $now = time(); if ($pageparams->sesscourses === 'current') { $coursesql = "(c.startdate = 0 OR c.startdate <= :now1) AND (c.enddate = 0 OR c.enddate >= :now2)"; - $courseparams = array( + $courseparams = [ 'now1' => $now, 'now2' => $now, - ); + ]; } $datesql = "(1 = 1)"; - $dateparams = array(); + $dateparams = []; if ($pageparams->startdate && $pageparams->enddate) { $datesql = "ats.sessdate >= :sdate AND ats.sessdate < :edate"; - $dateparams = array( + $dateparams = [ 'sdate' => $pageparams->startdate, 'edate' => $pageparams->enddate, - ); + ]; } if ($pageparams->groupby === 'date') { @@ -174,10 +174,10 @@ function attendance_get_user_sessions_log_full($userid, $pageparams) { AND $coursesql ORDER BY $ordersql"; - $params = array( + $params = [ 'uid' => $userid, 'uid1' => $userid, - ); + ]; $params = array_merge($params, $uparams); $params = array_merge($params, $dateparams); $params = array_merge($params, $courseparams); @@ -219,7 +219,7 @@ function attendance_get_user_courses_attendances($userid) { WHERE att.course $usql ORDER BY coursefullname ASC, attname ASC"; - $params = array_merge($uparams, array('uid' => $userid)); + $params = array_merge($uparams, ['uid' => $userid]); return $DB->get_records_sql($sql, $params); } @@ -246,7 +246,7 @@ function attendance_calc_fraction($part, $total) { */ function attendance_has_logs_for_status($statusid) { global $DB; - return $DB->record_exists('attendance_log', array('statusid' => $statusid)); + return $DB->record_exists('attendance_log', ['statusid' => $statusid]); } /** @@ -265,7 +265,7 @@ function attendance_form_sessiondate_selector (MoodleQuickForm $mform) { $minutes[$i] = sprintf("%02d", $i); } - $sesendtime = array(); + $sesendtime = []; if (!right_to_left()) { $sesendtime[] =& $mform->createElement('static', 'from', '', get_string('from', 'attendance')); $sesendtime[] =& $mform->createElement('select', 'starthour', get_string('hour', 'form'), $hours, false, true); @@ -281,7 +281,7 @@ function attendance_form_sessiondate_selector (MoodleQuickForm $mform) { $sesendtime[] =& $mform->createElement('select', 'endminute', get_string('minute', 'form'), $minutes, false, true); $sesendtime[] =& $mform->createElement('select', 'endhour', get_string('hour', 'form'), $hours, false, true); } - $mform->addGroup($sesendtime, 'sestime', get_string('time', 'attendance'), array(' '), true); + $mform->addGroup($sesendtime, 'sestime', get_string('time', 'attendance'), [' '], true); } /** @@ -294,7 +294,7 @@ function attendance_get_max_statusset($attendanceid) { global $DB; $max = $DB->get_field_sql('SELECT MAX(setnumber) FROM {attendance_statuses} WHERE attendanceid = ? AND deleted = 0', - array($attendanceid)); + [$attendanceid]); if ($max) { return $max; } @@ -308,7 +308,7 @@ function attendance_get_max_statusset($attendanceid) { * @return array */ function attendance_get_statusset_maxpoints($statuses) { - $statussetmaxpoints = array(); + $statussetmaxpoints = []; foreach ($statuses as $st) { if (!isset($statussetmaxpoints[$st->setnumber])) { $statussetmaxpoints[$st->setnumber] = $st->grade; @@ -323,7 +323,7 @@ function attendance_get_statusset_maxpoints($statuses) { * @param mod_attendance_structure|stdClass $attendance * @param array $userids */ -function attendance_update_users_grade($attendance, $userids=array()) { +function attendance_update_users_grade($attendance, $userids=[]) { global $DB; if (empty($attendance->grade)) { @@ -340,7 +340,7 @@ function attendance_update_users_grade($attendance, $userids=array()) { } if ($attendance->grade < 0) { - $dbparams = array('id' => -($attendance->grade)); + $dbparams = ['id' => -($attendance->grade)]; $scale = $DB->get_record('scale', $dbparams); $scalearray = explode(',', $scale->scale); $attendancegrade = count($scalearray); @@ -348,7 +348,7 @@ function attendance_update_users_grade($attendance, $userids=array()) { $attendancegrade = $attendance->grade; } - $grades = array(); + $grades = []; foreach ($userids as $userid) { $grades[$userid] = new stdClass(); $grades[$userid]->userid = $userid; @@ -388,7 +388,7 @@ function attendance_update_users_grades_by_id($attendanceid, $grade, $userids) { } if ($grade < 0) { - $dbparams = array('id' => -($grade)); + $dbparams = ['id' => -($grade)]; $scale = $DB->get_record('scale', $dbparams); $scalearray = explode(',', $scale->scale); $attendancegrade = count($scalearray); @@ -396,7 +396,7 @@ function attendance_update_users_grades_by_id($attendanceid, $grade, $userids) { $attendancegrade = $grade; } - $grades = array(); + $grades = []; foreach ($userids as $userid) { $grades[$userid] = new stdClass(); $grades[$userid]->userid = $userid; @@ -433,12 +433,12 @@ function attendance_add_status($status) { $id = $DB->insert_record('attendance_statuses', $status); $status->id = $id; - $event = \mod_attendance\event\status_added::create(array( + $event = \mod_attendance\event\status_added::create([ 'objectid' => $status->attendanceid, 'context' => $status->context, - 'other' => array('acronym' => $status->acronym, + 'other' => ['acronym' => $status->acronym, 'description' => $status->description, - 'grade' => $status->grade))); + 'grade' => $status->grade, ]]); if (!empty($status->cm)) { $event->add_record_snapshot('course_modules', $status->cm); } @@ -462,14 +462,14 @@ function attendance_remove_status($status, $context = null, $cm = null) { if (empty($context)) { $context = context_system::instance(); } - $DB->set_field('attendance_statuses', 'deleted', 1, array('id' => $status->id)); - $event = \mod_attendance\event\status_removed::create(array( + $DB->set_field('attendance_statuses', 'deleted', 1, ['id' => $status->id]); + $event = \mod_attendance\event\status_removed::create([ 'objectid' => $status->id, 'context' => $context, - 'other' => array( + 'other' => [ 'acronym' => $status->acronym, - 'description' => $status->description - ))); + 'description' => $status->description, + ]]); if (!empty($cm)) { $event->add_record_snapshot('course_modules', $cm); } @@ -505,10 +505,10 @@ function attendance_update_status($status, $acronym, $description, $grade, $visi $status->visible = $visible; $updated[] = $visible ? get_string('show') : get_string('hide'); } else if (empty($acronym) || empty($description)) { - return array('acronym' => $acronym, 'description' => $description); + return ['acronym' => $acronym, 'description' => $description]; } - $updated = array(); + $updated = []; if ($acronym) { $status->acronym = $acronym; @@ -544,11 +544,11 @@ function attendance_update_status($status, $acronym, $description, $grade, $visi } $DB->update_record('attendance_statuses', $status); - $event = \mod_attendance\event\status_updated::create(array( + $event = \mod_attendance\event\status_updated::create([ 'objectid' => $status->attendanceid, 'context' => $context, - 'other' => array('acronym' => $acronym, 'description' => $description, 'grade' => $grade, - 'updated' => implode(' ', $updated)))); + 'other' => ['acronym' => $acronym, 'description' => $description, 'grade' => $grade, + 'updated' => implode(' ', $updated), ]]); if (!empty($cm)) { $event->add_record_snapshot('course_modules', $cm); } @@ -611,9 +611,9 @@ function attendance_check_allow_update($sessionid) { */ function attendance_is_status_availablebeforesession($sessionid, $statusid = null) { global $DB; - $attendanceid = $DB->get_field('attendance_sessions', 'attendanceid', array('id' => $sessionid)); + $attendanceid = $DB->get_field('attendance_sessions', 'attendanceid', ['id' => $sessionid]); $params = ['deleted' => 0, 'visible' => 1, 'availablebeforesession' => 1, - 'attendanceid' => $attendanceid]; + 'attendanceid' => $attendanceid, ]; if (!empty($statusid)) { $params['id'] = $statusid; @@ -659,12 +659,12 @@ function attendance_can_student_mark($sess, $log = true) { if ($sess->preventsharedip == ATTENDANCE_SHAREDIP_MINUTES) { $time = time() - ($sess->preventsharediptime * 60); $sql = 'sessionid = ? AND studentid <> ? AND timetaken > ? AND ipaddress = ?'; - $params = array($sess->id, $USER->id, $time, getremoteaddr()); + $params = [$sess->id, $USER->id, $time, getremoteaddr()]; $record = $DB->get_record_select('attendance_log', $sql, $params); } else { // Assume ATTENDANCE_SHAREDIP_FORCED. $sql = 'sessionid = ? AND studentid <> ? AND ipaddress = ?'; - $params = array($sess->id, $USER->id, getremoteaddr()); + $params = [$sess->id, $USER->id, getremoteaddr()]; $record = $DB->get_record_select('attendance_log', $sql, $params); } @@ -673,22 +673,22 @@ function attendance_can_student_mark($sess, $log = true) { $reason = 'preventsharederror'; if ($log) { // Trigger an ip_shared event. - $attendanceid = $DB->get_field('attendance_sessions', 'attendanceid', array('id' => $record->sessionid)); + $attendanceid = $DB->get_field('attendance_sessions', 'attendanceid', ['id' => $record->sessionid]); $cm = get_coursemodule_from_instance('attendance', $attendanceid); - $event = \mod_attendance\event\session_ip_shared::create(array( + $event = \mod_attendance\event\session_ip_shared::create([ 'objectid' => 0, 'context' => \context_module::instance($cm->id), - 'other' => array( + 'other' => [ 'sessionid' => $record->sessionid, - 'otheruser' => $record->studentid - ) - )); + 'otheruser' => $record->studentid, + ], + ]); $event->trigger(); } } } - return array($canmark, $reason); + return [$canmark, $reason]; } /** @@ -806,7 +806,7 @@ function attendance_construct_sessions_data_for_add($formdata, mod_attendance_st $calendarevent = 1; } - $sessions = array(); + $sessions = []; if (isset($formdata->addmultiply)) { $startdate = $sessiondate; $enddate = $formdata->sessionenddate + DAYSECS; // Because enddate in 0:0am. @@ -825,7 +825,7 @@ function attendance_construct_sessions_data_for_add($formdata, mod_attendance_st $startweek = $startdate - ($wday - 1) * DAYSECS; } - $wdaydesc = array(0 => 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); + $wdaydesc = [0 => 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; while ($sdate < $enddate) { if ($sdate < strtotime('+1 week', $startweek)) { @@ -1035,11 +1035,11 @@ function attendance_fill_groupid($formdata, &$sessions, $sess) { * @param string $orderby - optional order by param * @return stdClass */ -function attendance_course_users_points($courseids = array(), $orderby = '') { +function attendance_course_users_points($courseids = [], $orderby = '') { global $DB; $where = ''; - $params = array(); + $params = []; $where .= ' AND ats.sessdate < :enddate '; $params['enddate'] = time(); @@ -1085,13 +1085,13 @@ function attendance_course_users_points($courseids = array(), $orderby = '') { * @param bool $allfornotify get notification list for scheduled task. * @return stdClass */ -function attendance_get_users_to_notify($courseids = array(), $orderby = '', $allfornotify = false) { +function attendance_get_users_to_notify($courseids = [], $orderby = '', $allfornotify = false) { global $DB, $CFG; $joingroup = 'LEFT JOIN {groups_members} gm ON (gm.userid = atl.studentid AND gm.groupid = ats.groupid)'; $where = ' AND (ats.groupid = 0 or gm.id is NOT NULL)'; $having = ''; - $params = array(); + $params = []; if (!empty($courseids)) { list($insql, $inparams) = $DB->get_in_or_equal($courseids, SQL_PARAMS_NAMED); @@ -1171,7 +1171,7 @@ function attendance_get_users_to_notify($courseids = array(), $orderby = '', $al * @return array - the content of the fields after templating. */ function attendance_template_variables($record) { - $templatevars = array( + $templatevars = [ '/%coursename%/' => $record->coursename, '/%courseid%/' => $record->courseid, '/%userfirstname%/' => $record->firstname, @@ -1184,7 +1184,7 @@ function attendance_template_variables($record) { '/%points%/' => $record->points, '/%maxpoints%/' => $record->maxpoints, '/%percent%/' => round($record->percent * 100), - ); + ]; $extrauserfields = \core_user\fields::get_name_fields(); foreach ($extrauserfields as $extra) { $templatevars['/%'.$extra.'%/'] = $record->$extra; @@ -1192,7 +1192,7 @@ function attendance_template_variables($record) { $patterns = array_keys($templatevars); // The placeholders which are to be replaced. $replacements = array_values($templatevars); // The values which are to be templated in for the placeholders. // Array to describe which fields in reengagement object should have a template replacement. - $replacementfields = array('emailsubject', 'emailcontent'); + $replacementfields = ['emailsubject', 'emailcontent']; // Replace %variable% with relevant value everywhere it occurs in reengagement->field. foreach ($replacementfields as $field) { @@ -1248,7 +1248,7 @@ function attendance_session_get_highest_status(mod_attendance_structure $att, $a function attendance_get_automarkoptions() { global $COURSE; - $options = array(); + $options = []; $options[ATTENDANCE_AUTOMARK_DISABLED] = get_string('noautomark', 'attendance'); if (strpos(get_config('tool_log', 'enabled_stores'), 'logstore_standard') !== false) { @@ -1291,7 +1291,7 @@ function attendance_get_coursemodulenames($id) { * @return array */ function attendance_get_sharedipoptions() { - $options = array(); + $options = []; $options[ATTENDANCE_SHAREDIP_DISABLED] = get_string('no'); $options[ATTENDANCE_SHAREDIP_FORCE] = get_string('yes'); $options[ATTENDANCE_SHAREDIP_MINUTES] = get_string('setperiod', 'attendance'); @@ -1404,11 +1404,11 @@ function attendance_renderqrcode($session) { function attendance_generate_passwords($session) { global $DB; $attconfig = get_config('attendance'); - $password = array(); + $password = []; for ($i = 0; $i < 30; $i++) { - array_push($password, array("attendanceid" => $session->id, - "password" => random_string(), "expirytime" => time() + ($attconfig->rotateqrcodeinterval * $i))); + array_push($password, ["attendanceid" => $session->id, + "password" => random_string(), "expirytime" => time() + ($attconfig->rotateqrcodeinterval * $i)]); } $DB->insert_records('attendance_rotate_passwords', $password); @@ -1424,13 +1424,13 @@ function attendance_renderqrcoderotate($session) { echo html_writer::tag('script', '', [ 'src' => 'js/qrcode/qrcode.min.js', - 'type' => 'text/javascript' + 'type' => 'text/javascript', ] ); echo html_writer::tag('script', '', [ 'src' => 'js/password/attendance_QRCodeRotate.js', - 'type' => 'text/javascript' + 'type' => 'text/javascript', ] ); echo html_writer::div('', '', ['id' => 'qrcode']); // Div to display qr code. diff --git a/manage.php b/manage.php index 4bb857584a0..d0b1a492350 100644 --- a/manage.php +++ b/manage.php @@ -34,19 +34,19 @@ $pageparams->perpage = get_config('attendance', 'resultsperpage'); $cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); -$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); -$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); +$att = $DB->get_record('attendance', ['id' => $cm->instance], '*', MUST_EXIST); require_login($course, true, $cm); $context = context_module::instance($cm->id); -$capabilities = array( +$capabilities = [ 'mod/attendance:manageattendances', 'mod/attendance:takeattendances', - 'mod/attendance:changeattendances' -); + 'mod/attendance:changeattendances', +]; if (!has_any_capability($capabilities, $context)) { - $url = new moodle_url('/mod/attendance/view.php', array('id' => $cm->id)); + $url = new moodle_url('/mod/attendance/view.php', ['id' => $cm->id]); redirect($url); } @@ -62,7 +62,7 @@ $nottaken = !$sess->lasttaken && has_capability('mod/attendance:takeattendances', $context); $canchange = $sess->lasttaken && has_capability('mod/attendance:changeattendances', $context); if ($nottaken || $canchange) { - redirect($att->url_take(array('sessionid' => $sess->id, 'grouptype' => $sess->groupid))); + redirect($att->url_take(['sessionid' => $sess->id, 'grouptype' => $sess->groupid])); } } else if ($size > 1) { $att->curdate = $today; diff --git a/messageselect.php b/messageselect.php index 86ab968c8f9..fccb6188b21 100644 --- a/messageselect.php +++ b/messageselect.php @@ -32,7 +32,7 @@ $returnto = optional_param('returnto', '', PARAM_LOCALURL); $format = optional_param('format', FORMAT_MOODLE, PARAM_INT); $deluser = optional_param('deluser', 0, PARAM_INT); -$url = new moodle_url('/user/messageselect.php', array('id' => $id)); +$url = new moodle_url('/user/messageselect.php', ['id' => $id]); if ($send !== '') { $url->param('send', $send); @@ -56,17 +56,17 @@ $messagebody = $messagebody['text']; } $PAGE->set_url($url); -$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $id], '*', MUST_EXIST); require_login($course); $coursecontext = context_course::instance($id); // Course context. $systemcontext = context_system::instance(); // SYSTEM context. require_capability('moodle/course:bulkmessaging', $coursecontext); if (empty($SESSION->emailto)) { - $SESSION->emailto = array(); + $SESSION->emailto = []; } if (!array_key_exists($id, $SESSION->emailto)) { - $SESSION->emailto[$id] = array(); + $SESSION->emailto[$id] = []; } if ($deluser) { if (array_key_exists($id, $SESSION->emailto) && array_key_exists($deluser, $SESSION->emailto[$id])) { @@ -74,7 +74,7 @@ } } if (empty($SESSION->emailselect[$id]) || $messagebody) { - $SESSION->emailselect[$id] = array('messagebody' => $messagebody); + $SESSION->emailselect[$id] = ['messagebody' => $messagebody]; } $messagebody = $SESSION->emailselect[$id]['messagebody']; $count = 0; @@ -86,7 +86,7 @@ foreach ($data as $k => $v) { if (preg_match('/^(user|teacher)(\d+)$/', $k, $m)) { if (!array_key_exists($m[2], $SESSION->emailto[$id])) { - if ($user = $DB->get_record_select('user', "id = ?", array($m[2]), 'id, '. + if ($user = $DB->get_record_select('user', "id = ?", [$m[2]], 'id, '. $namefields . ', idnumber, email, mailformat, lastaccess, lang, '. 'maildisplay, auth, suspended, deleted, emailstop, username')) { $SESSION->emailto[$id][$m[2]] = $user; @@ -106,7 +106,7 @@ $link = null; if (has_capability('moodle/course:viewparticipants', $coursecontext) || has_capability('moodle/site:viewparticipants', $systemcontext)) { - $link = new moodle_url("/user/index.php", array('id' => $course->id)); + $link = new moodle_url("/user/index.php", ['id' => $course->id]); } $PAGE->navbar->add(get_string('participants'), $link); $PAGE->navbar->add($strtitle); @@ -138,7 +138,7 @@ echo '

'; echo "\n"; } else if (!empty($send)) { - $fails = array(); + $fails = []; foreach ($SESSION->emailto[$id] as $user) { if (!message_post_message($USER, $user, $messagebody, $format)) { $user->fullname = fullname($user); @@ -176,9 +176,9 @@ } $PAGE->requires->yui_module('moodle-core-formchangechecker', 'M.core_formchangechecker.init', - array(array( - 'formid' => 'theform' - )) + [[ + 'formid' => 'theform', + ], ] ); $PAGE->requires->string_for_js('changesmadereallygoaway', 'moodle'); echo $OUTPUT->footer(); diff --git a/mod_form.php b/mod_form.php index 838b842c5fb..ae5881db45d 100644 --- a/mod_form.php +++ b/mod_form.php @@ -47,7 +47,7 @@ public function definition() { $mform->addElement('header', 'general', get_string('general', 'form')); - $mform->addElement('text', 'name', get_string('name'), array('size' => '64')); + $mform->addElement('text', 'name', get_string('name'), ['size' => '64']); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', null, 'required', null, 'client'); $mform->setDefault('name', get_string('modulename', 'attendance')); @@ -62,7 +62,7 @@ public function definition() { // IP address. if (get_config('attendance', 'subnetactivitylevel')) { $mform->addElement('header', 'security', get_string('extrarestrictions', 'attendance')); - $mform->addElement('text', 'subnet', get_string('defaultsubnet', 'attendance'), array('size' => '164')); + $mform->addElement('text', 'subnet', get_string('defaultsubnet', 'attendance'), ['size' => '164']); $mform->setType('subnet', PARAM_TEXT); $mform->addHelpButton('subnet', 'defaultsubnet', 'attendance'); $mform->setDefault('subnet', $attendanceconfig->subnet); diff --git a/password.php b/password.php index 26c92349e05..ef642d3c77a 100644 --- a/password.php +++ b/password.php @@ -30,13 +30,13 @@ require_once($CFG->libdir.'/tcpdf/tcpdf_barcodes_2d.php'); // Used for generating qrcode. $session = required_param('session', PARAM_INT); -$session = $DB->get_record('attendance_sessions', array('id' => $session), '*', MUST_EXIST); +$session = $DB->get_record('attendance_sessions', ['id' => $session], '*', MUST_EXIST); $cm = get_coursemodule_from_instance('attendance', $session->attendanceid); require_login($cm->course, $cm); $context = context_module::instance($cm->id); -$capabilities = array('mod/attendance:manageattendances', 'mod/attendance:takeattendances', 'mod/attendance:changeattendances'); +$capabilities = ['mod/attendance:manageattendances', 'mod/attendance:takeattendances', 'mod/attendance:changeattendances']; if (!has_any_capability($capabilities, $context)) { exit; } diff --git a/password_ajax.php b/password_ajax.php index 3f3f1651f35..aef16f2b567 100644 --- a/password_ajax.php +++ b/password_ajax.php @@ -28,13 +28,13 @@ require_once(dirname(__FILE__).'/../../config.php'); $session = required_param('session', PARAM_INT); -$session = $DB->get_record('attendance_sessions', array('id' => $session), '*', MUST_EXIST); +$session = $DB->get_record('attendance_sessions', ['id' => $session], '*', MUST_EXIST); $cm = get_coursemodule_from_instance('attendance', $session->attendanceid); require_login($cm->course, $cm); $context = context_module::instance($cm->id); -$capabilities = array('mod/attendance:manageattendances', 'mod/attendance:takeattendances', 'mod/attendance:changeattendances'); +$capabilities = ['mod/attendance:manageattendances', 'mod/attendance:takeattendances', 'mod/attendance:changeattendances']; if (!has_any_capability($capabilities, $context)) { exit; } diff --git a/preferences.php b/preferences.php index ef8775c1fb4..8da77efa71d 100644 --- a/preferences.php +++ b/preferences.php @@ -33,8 +33,8 @@ $pageparams->statusset = optional_param('statusset', 0, PARAM_INT); // Set of statuses to view. $cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); -$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); -$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); +$att = $DB->get_record('attendance', ['id' => $cm->instance], '*', MUST_EXIST); require_login($course, true, $cm); @@ -56,7 +56,7 @@ $PAGE->set_cacheable(true); $PAGE->navbar->add(get_string('settings', 'attendance')); $PAGE->requires->js_call_amd('mod_attendance/statusset', 'init'); -$errors = array(); +$errors = []; // Check sesskey if we are performing an action. if (!empty($att->pageparams->action)) { @@ -109,7 +109,7 @@ $message .= str_repeat(html_writer::empty_tag('br'), 2); $message .= $status->acronym.': '. ($status->description ? $status->description : get_string('nodescription', 'attendance')); - $params = array_merge($att->pageparams->get_significant_params(), array('confirm' => 1)); + $params = array_merge($att->pageparams->get_significant_params(), ['confirm' => 1]); echo $OUTPUT->header(); echo $OUTPUT->confirm($message, $att->url_preferences($params), $att->url_preferences()); echo $OUTPUT->footer(); diff --git a/renderhelpers.php b/renderhelpers.php index 5216d90a136..8eb632cb813 100644 --- a/renderhelpers.php +++ b/renderhelpers.php @@ -31,7 +31,7 @@ */ class user_sessions_cells_generator { /** @var array $cells - list of table cells. */ - protected $cells = array(); + protected $cells = []; /** @var stdClass $reportdata - data for report. */ protected $reportdata; diff --git a/report.php b/report.php index 083a08d2515..2535c40daa9 100644 --- a/report.php +++ b/report.php @@ -37,8 +37,8 @@ $pageparams->perpage = get_config('attendance', 'resultsperpage'); $cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); -$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); -$attrecord = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); +$attrecord = $DB->get_record('attendance', ['id' => $cm->instance], '*', MUST_EXIST); require_login($course, true, $cm); @@ -77,11 +77,11 @@ $reportdata = new mod_attendance\output\report_data($att); // Trigger a report viewed event. -$event = \mod_attendance\event\report_viewed::create(array( +$event = \mod_attendance\event\report_viewed::create([ 'objectid' => $att->id, 'context' => $PAGE->context, - 'other' => array() -)); + 'other' => [], +]); $event->add_record_snapshot('course_modules', $cm); $event->add_record_snapshot('attendance', $attrecord); $event->trigger(); diff --git a/resetcalendar.php b/resetcalendar.php index 5705f4ed2db..9748b41a835 100644 --- a/resetcalendar.php +++ b/resetcalendar.php @@ -49,7 +49,7 @@ if (get_config('attendance', 'enablecalendar')) { // Check to see if all sessions that need them have calendar events. if ($action == 'create' && confirm_sesskey()) { - $sessions = $DB->get_recordset('attendance_sessions', array('caleventid' => 0, 'calendarevent' => 1)); + $sessions = $DB->get_recordset('attendance_sessions', ['caleventid' => 0, 'calendarevent' => 1]); foreach ($sessions as $session) { attendance_create_calendar_event($session); if ($session->caleventid) { @@ -59,9 +59,9 @@ $sessions->close(); echo $OUTPUT->notification(get_string('eventscreated', 'mod_attendance'), 'notifysuccess'); } else { - if ($DB->record_exists('attendance_sessions', array('caleventid' => 0, 'calendarevent' => 1))) { - $createurl = new moodle_url('/mod/attendance/resetcalendar.php', array('action' => 'create')); - $returnurl = new moodle_url("/{$CFG->admin}/settings.php", array('section' => 'modsettingattendance')); + if ($DB->record_exists('attendance_sessions', ['caleventid' => 0, 'calendarevent' => 1])) { + $createurl = new moodle_url('/mod/attendance/resetcalendar.php', ['action' => 'create']); + $returnurl = new moodle_url("/{$CFG->admin}/settings.php", ['section' => 'modsettingattendance']); echo $OUTPUT->confirm(get_string('resetcaledarcreate', 'mod_attendance'), $createurl, $returnurl); } else { @@ -76,8 +76,8 @@ } else { // Check to see if there are any events that need to be deleted. if ($DB->record_exists_select('attendance_sessions', 'caleventid > 0')) { - $deleteurl = new moodle_url('/mod/attendance/resetcalendar.php', array('action' => 'delete')); - $returnurl = new moodle_url("/{$CFG->admin}/settings.php", array('section' => 'modsettingattendance')); + $deleteurl = new moodle_url('/mod/attendance/resetcalendar.php', ['action' => 'delete']); + $returnurl = new moodle_url("/{$CFG->admin}/settings.php", ['section' => 'modsettingattendance']); echo $OUTPUT->confirm(get_string('resetcaledardelete', 'mod_attendance'), $deleteurl, $returnurl); } else { diff --git a/sessions.php b/sessions.php index 5ac28a7e9f7..5db1e47659f 100644 --- a/sessions.php +++ b/sessions.php @@ -38,13 +38,13 @@ if (empty($pageparams->action)) { // The form on manage.php can submit with the "choose" option - this should be fixed in the long term, // but in the meantime show a useful error and redirect when it occurs. - $url = new moodle_url('/mod/attendance/view.php', array('id' => $id)); + $url = new moodle_url('/mod/attendance/view.php', ['id' => $id]); redirect($url, get_string('invalidaction', 'mod_attendance'), 2); } $cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); -$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); -$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); +$att = $DB->get_record('attendance', ['id' => $cm->instance], '*', MUST_EXIST); require_login($course, true, $cm); @@ -53,17 +53,17 @@ $att = new mod_attendance_structure($att, $cm, $course, $context, $pageparams); -$PAGE->set_url($att->url_sessions(array('action' => $pageparams->action))); +$PAGE->set_url($att->url_sessions(['action' => $pageparams->action])); $PAGE->set_title($course->shortname. ": ".$att->name); $PAGE->set_heading($course->fullname); $PAGE->force_settings_menu(true); $PAGE->set_cacheable(true); $PAGE->navbar->add($att->name); -$formparams = array('course' => $course, 'cm' => $cm, 'modcontext' => $context, 'att' => $att); +$formparams = ['course' => $course, 'cm' => $cm, 'modcontext' => $context, 'att' => $att]; switch ($att->pageparams->action) { case mod_attendance_sessions_page_params::ACTION_ADD: - $url = $att->url_sessions(array('action' => mod_attendance_sessions_page_params::ACTION_ADD)); + $url = $att->url_sessions(['action' => mod_attendance_sessions_page_params::ACTION_ADD]); $mform = new \mod_attendance\form\addsession($url, $formparams); if ($mform->is_cancelled()) { @@ -93,7 +93,7 @@ case mod_attendance_sessions_page_params::ACTION_UPDATE: $sessionid = required_param('sessionid', PARAM_INT); - $url = $att->url_sessions(array('action' => mod_attendance_sessions_page_params::ACTION_UPDATE, 'sessionid' => $sessionid)); + $url = $att->url_sessions(['action' => mod_attendance_sessions_page_params::ACTION_UPDATE, 'sessionid' => $sessionid]); $formparams['sessionid'] = $sessionid; $mform = new \mod_attendance\form\updatesession($url, $formparams); @@ -121,7 +121,7 @@ $confirm = optional_param('confirm', null, PARAM_INT); if (isset($confirm) && confirm_sesskey()) { - $att->delete_sessions(array($sessionid)); + $att->delete_sessions([$sessionid]); attendance_update_users_grade($att); redirect($att->url_manage(), get_string('sessiondeleted', 'attendance')); } @@ -134,7 +134,7 @@ $message .= html_writer::empty_tag('br'); $message .= $sessinfo->description; - $params = array('action' => $att->pageparams->action, 'sessionid' => $sessionid, 'confirm' => 1, 'sesskey' => sesskey()); + $params = ['action' => $att->pageparams->action, 'sessionid' => $sessionid, 'confirm' => 1, 'sesskey' => sesskey()]; echo $OUTPUT->header(); echo $OUTPUT->confirm($message, $att->url_sessions($params), $att->url_manage()); @@ -168,8 +168,8 @@ } $sessionsids = implode('_', $sessid); - $params = array('action' => $att->pageparams->action, 'sessionsids' => $sessionsids, - 'confirm' => 1, 'sesskey' => sesskey()); + $params = ['action' => $att->pageparams->action, 'sessionsids' => $sessionsids, + 'confirm' => 1, 'sesskey' => sesskey(), ]; echo $OUTPUT->header(); echo $OUTPUT->confirm($message, $att->url_sessions($params), $att->url_manage()); @@ -181,7 +181,7 @@ $slist = !empty($sessid) ? implode('_', $sessid) : ''; - $url = $att->url_sessions(array('action' => mod_attendance_sessions_page_params::ACTION_CHANGE_DURATION)); + $url = $att->url_sessions(['action' => mod_attendance_sessions_page_params::ACTION_CHANGE_DURATION]); $formparams['ids'] = $slist; $mform = new mod_attendance\form\duration($url, $formparams); @@ -214,7 +214,7 @@ $a->date = userdate($course->startdate); $message = get_string('confirmdeletehiddensessions', 'attendance', $a); - $params = array('action' => $att->pageparams->action, 'confirm' => 1, 'sesskey' => sesskey()); + $params = ['action' => $att->pageparams->action, 'confirm' => 1, 'sesskey' => sesskey()]; echo $OUTPUT->header(); echo $OUTPUT->confirm($message, $att->url_sessions($params), $att->url_manage()); echo $OUTPUT->footer(); diff --git a/settings.php b/settings.php index 43de1946eb8..f203e8be66b 100644 --- a/settings.php +++ b/settings.php @@ -36,7 +36,7 @@ $plugininfos = core_plugin_manager::instance()->get_plugins_of_type('local'); // Paging options. - $options = array( + $options = [ 0 => get_string('donotusepaging', 'attendance'), 25 => 25, 50 => 50, @@ -45,7 +45,7 @@ 250 => 250, 500 => 500, 1000 => 1000, - ); + ]; $settings->add(new admin_setting_configselect('attendance/resultsperpage', get_string('resultsperpage', 'attendance'), get_string('resultsperpage_desc', 'attendance'), 25, $options)); @@ -76,14 +76,14 @@ get_string('subnetactivitylevel', 'attendance'), get_string('subnetactivitylevel_desc', 'attendance'), 1)); - $options = array( + $options = [ ATT_VIEW_ALL => get_string('all', 'attendance'), ATT_VIEW_ALLPAST => get_string('allpast', 'attendance'), ATT_VIEW_NOTPRESENT => get_string('below', 'attendance', 'X'), ATT_VIEW_MONTHS => get_string('months', 'attendance'), ATT_VIEW_WEEKS => get_string('weeks', 'attendance'), - ATT_VIEW_DAYS => get_string('days', 'attendance') - ); + ATT_VIEW_DAYS => get_string('days', 'attendance'), + ]; $settings->add(new admin_setting_configselect('attendance/defaultview', get_string('defaultview', 'attendance'), @@ -113,7 +113,7 @@ get_string('automarkuseempty', 'attendance'), get_string('automarkuseempty_desc', 'attendance'), 1)); - $fields = array('id' => get_string('studentid', 'attendance')); + $fields = ['id' => get_string('studentid', 'attendance')]; $customfields = profile_get_custom_fields(); foreach ($customfields as $field) { $fields[$field->shortname] = format_string($field->name); @@ -122,7 +122,7 @@ $settings->add(new admin_setting_configmultiselect('attendance/customexportfields', new lang_string('customexportfields', 'attendance'), new lang_string('customexportfields_help', 'attendance'), - array('id'), $fields) + ['id'], $fields) ); $name = new lang_string('mobilesettings', 'mod_attendance'); @@ -192,14 +192,14 @@ $description = new lang_string('defaultwarningsettings_help', 'mod_attendance'); $settings->add(new admin_setting_heading('defaultwarningsettings', $name, $description)); - $options = array(); + $options = []; for ($i = 1; $i <= 100; $i++) { $options[$i] = "$i%"; } $settings->add(new admin_setting_configselect('attendance/warningpercent', get_string('warningpercent', 'attendance'), get_string('warningpercent_help', 'attendance'), 70, $options)); - $options = array(); + $options = []; for ($i = 1; $i <= 50; $i++) { $options[$i] = "$i"; } diff --git a/take.php b/take.php index fdd3df83c2e..fca3768a3ac 100644 --- a/take.php +++ b/take.php @@ -38,10 +38,10 @@ $pageparams->perpage = optional_param('perpage', get_config('attendance', 'resultsperpage'), PARAM_INT); $cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); -$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); -$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); +$att = $DB->get_record('attendance', ['id' => $cm->instance], '*', MUST_EXIST); // Check this is a valid session for this attendance. -$session = $DB->get_record('attendance_sessions', array('id' => $pageparams->sessionid, 'attendanceid' => $att->id), +$session = $DB->get_record('attendance_sessions', ['id' => $pageparams->sessionid, 'attendanceid' => $att->id], '*', MUST_EXIST); require_login($course, true, $cm); @@ -77,9 +77,9 @@ if (!empty($att->pageparams->page) && $att->pageparams->page && $totalusers && $usersperpage) { $numberofpages = ceil($totalusers / $usersperpage); if ($att->pageparams->page < $numberofpages) { - $params = array( + $params = [ 'sessionid' => $att->pageparams->sessionid, - 'grouptype' => $att->pageparams->grouptype); + 'grouptype' => $att->pageparams->grouptype, ]; $params['page'] = $att->pageparams->page + 1; redirect($att->url_take($params), get_string('moreattendance', 'attendance')); } diff --git a/tempedit.php b/tempedit.php index c2549f42eb6..bec72e916c2 100644 --- a/tempedit.php +++ b/tempedit.php @@ -31,13 +31,13 @@ $action = optional_param('action', null, PARAM_ALPHA); $cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); -$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); -$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); -$tempuser = $DB->get_record('attendance_tempusers', array('id' => $userid), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); +$att = $DB->get_record('attendance', ['id' => $cm->instance], '*', MUST_EXIST); +$tempuser = $DB->get_record('attendance_tempusers', ['id' => $userid], '*', MUST_EXIST); $att = new mod_attendance_structure($att, $cm, $course); -$params = array('userid' => $tempuser->id); +$params = ['userid' => $tempuser->id]; if ($action) { $params['action'] = $action; } @@ -60,19 +60,19 @@ require_sesskey(); // Remove the user from the grades table, the attendance log and the tempusers table. - $DB->delete_records('grade_grades', array('userid' => $tempuser->studentid)); - $DB->delete_records('attendance_log', array('studentid' => $tempuser->studentid)); - $DB->delete_records('attendance_tempusers', array('id' => $tempuser->id)); + $DB->delete_records('grade_grades', ['userid' => $tempuser->studentid]); + $DB->delete_records('attendance_log', ['studentid' => $tempuser->studentid]); + $DB->delete_records('attendance_tempusers', ['id' => $tempuser->id]); redirect($att->url_managetemp()); } else { - $info = (object)array( + $info = (object)[ 'fullname' => $tempuser->fullname, 'email' => $tempuser->email, - ); + ]; $msg = get_string('confirmdeleteuser', 'attendance', $info); - $continue = new moodle_url($PAGE->url, array('confirm' => 1, 'sesskey' => sesskey())); + $continue = new moodle_url($PAGE->url, ['confirm' => 1, 'sesskey' => sesskey()]); echo $output->header(); echo $output->confirm($msg, $continue, $att->url_managetemp()); diff --git a/tempmerge.php b/tempmerge.php index c041e8c1fbe..aa1e66b86df 100644 --- a/tempmerge.php +++ b/tempmerge.php @@ -30,12 +30,12 @@ $userid = required_param('userid', PARAM_INT); $cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); -$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); -$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); -$tempuser = $DB->get_record('attendance_tempusers', array('id' => $userid), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); +$att = $DB->get_record('attendance', ['id' => $cm->instance], '*', MUST_EXIST); +$tempuser = $DB->get_record('attendance_tempusers', ['id' => $userid], '*', MUST_EXIST); $att = new mod_attendance_structure($att, $cm, $course); -$params = array('userid' => $tempuser->id); +$params = ['userid' => $tempuser->id]; $PAGE->set_url($att->url_tempmerge($params)); require_login($course, true, $cm); @@ -45,14 +45,14 @@ $PAGE->set_cacheable(true); $PAGE->navbar->add(get_string('tempusermerge', 'attendance')); -$formdata = (object)array( +$formdata = (object)[ 'id' => $cm->id, 'userid' => $tempuser->id, -); +]; -$custom = array( +$custom = [ 'description' => format_string($tempuser->fullname).' ('.format_string($tempuser->email).')', -); +]; $mform = new mod_attendance\form\tempmerge(null, $custom); $mform->set_data($formdata); @@ -67,25 +67,25 @@ LEFT JOIN {attendance_log} lt ON lt.sessionid = s.id AND lt.studentid = :tempuserid WHERE s.attendanceid = :attendanceid AND lt.id IS NOT NULL ORDER BY s.id"; - $params = array( + $params = [ 'realuserid' => $data->participant, 'tempuserid' => $tempuser->studentid, 'attendanceid' => $att->id, - ); + ]; $logs = $DB->get_recordset_sql($sql, $params); foreach ($logs as $log) { if (!is_null($log->reallogid)) { // Remove the existing attendance for the real user for this session. - $DB->delete_records('attendance_log', array('id' => $log->reallogid)); + $DB->delete_records('attendance_log', ['id' => $log->reallogid]); } // Adjust the 'temp user' attendance record to point at the real user. - $DB->set_field('attendance_log', 'studentid', $data->participant, array('id' => $log->templogid)); + $DB->set_field('attendance_log', 'studentid', $data->participant, ['id' => $log->templogid]); } // Delete the temp user. - $DB->delete_records('attendance_tempusers', array('id' => $tempuser->id)); - $att->update_users_grade(array($data->participant)); // Update the gradebook after the merge. + $DB->delete_records('attendance_tempusers', ['id' => $tempuser->id]); + $att->update_users_grade([$data->participant]); // Update the gradebook after the merge. redirect($att->url_managetemp()); } diff --git a/tempusers.php b/tempusers.php index 5c8774464b4..65c66332fe1 100644 --- a/tempusers.php +++ b/tempusers.php @@ -29,8 +29,8 @@ $id = required_param('id', PARAM_INT); $cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); -$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); -$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); +$att = $DB->get_record('attendance', ['id' => $cm->instance], '*', MUST_EXIST); $att = new mod_attendance_structure($att, $cm, $course); $PAGE->set_url($att->url_managetemp()); @@ -47,9 +47,9 @@ $output = $PAGE->get_renderer('mod_attendance'); -$formdata = (object)array( +$formdata = (object)[ 'id' => $cm->id, -); +]; $mform = new mod_attendance\form\tempuser(); $mform->set_data($formdata); @@ -81,7 +81,7 @@ echo $output->header(); $mform->display(); -$tempusers = $DB->get_records('attendance_tempusers', array('courseid' => $course->id), 'fullname, email'); +$tempusers = $DB->get_records('attendance_tempusers', ['courseid' => $course->id], 'fullname, email'); echo '
'; echo '

'.get_string('tempuserslist', 'attendance').'

'; @@ -118,7 +118,7 @@ function attendance_print_tempusers($tempusers, mod_attendance_structure $att) { echo ''.format_string($tempuser->fullname).''; echo ''.format_string($tempuser->email).''; echo ''.userdate($tempuser->created, get_string('strftimedatetime')).''; - $params = array('userid' => $tempuser->id); + $params = ['userid' => $tempuser->id]; $editlink = html_writer::link($att->url_tempedit($params), get_string('edituser', 'attendance')); $deletelink = html_writer::link($att->url_tempdelete($params), get_string('deleteuser', 'attendance')); $mergelink = html_writer::link($att->url_tempmerge($params), get_string('mergeuser', 'attendance')); diff --git a/tests/behat/behat_mod_attendance.php b/tests/behat/behat_mod_attendance.php index 8058b2e4116..3e767a0bf5b 100644 --- a/tests/behat/behat_mod_attendance.php +++ b/tests/behat/behat_mod_attendance.php @@ -70,7 +70,7 @@ protected function resolve_page_instance_url(string $type, string $identifier): */ protected function get_attendance_by_name(string $name): stdClass { global $DB; - return $DB->get_record('attendance', array('name' => $name), '*', MUST_EXIST); + return $DB->get_record('attendance', ['name' => $name], '*', MUST_EXIST); } /** diff --git a/tests/external/external_test.php b/tests/external/external_test.php index 45a6ea79c27..4c42b4266f8 100644 --- a/tests/external/external_test.php +++ b/tests/external/external_test.php @@ -72,10 +72,10 @@ public function setUp(): void { global $CFG, $DB; require_once($CFG->dirroot . '/mod/attendance/externallib.php'); $this->category = $this->getDataGenerator()->create_category(); - $this->course = $this->getDataGenerator()->create_course(array('category' => $this->category->id)); - $att = $this->getDataGenerator()->create_module('attendance', array('course' => $this->course->id)); - $cm = $DB->get_record('course_modules', array('id' => $att->cmid), '*', MUST_EXIST); - $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); + $this->course = $this->getDataGenerator()->create_course(['category' => $this->category->id]); + $att = $this->getDataGenerator()->create_module('attendance', ['course' => $this->course->id]); + $cm = $DB->get_record('course_modules', ['id' => $att->cmid], '*', MUST_EXIST); + $course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); $this->attendance = new mod_attendance_structure($att, $cm, $course); $this->create_and_enrol_users(); @@ -102,7 +102,7 @@ public function setUp(): void { /** Creating 10 students and 1 teacher. */ protected function create_and_enrol_users() { - $this->students = array(); + $this->students = []; for ($i = 0; $i < 10; $i++) { $this->students[] = $this->getDataGenerator()->create_and_enrol($this->course, 'student'); } @@ -135,9 +135,9 @@ public function test_get_courses_with_today_sessions_multiple_instances() { $this->resetAfterTest(true); // Make another attendance. - $att = $this->getDataGenerator()->create_module('attendance', array('course' => $this->course->id)); - $cm = $DB->get_record('course_modules', array('id' => $att->cmid), '*', MUST_EXIST); - $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); + $att = $this->getDataGenerator()->create_module('attendance', ['course' => $this->course->id]); + $cm = $DB->get_record('course_modules', ['id' => $att->cmid], '*', MUST_EXIST); + $course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); $second = new mod_attendance_structure($att, $cm, $course); // Just add the same session. @@ -265,7 +265,7 @@ public function test_add_attendance() { // Become a teacher. $teacher = self::getDataGenerator()->create_user(); - $teacherrole = $DB->get_record('role', array('shortname' => 'editingteacher')); + $teacherrole = $DB->get_record('role', ['shortname' => 'editingteacher']); $this->getDataGenerator()->enrol_user($teacher->id, $course->id, $teacherrole->id); $this->setUser($teacher); @@ -312,7 +312,7 @@ public function test_remove_attendance() { // Become a teacher. $teacher = self::getDataGenerator()->create_user(); - $teacherrole = $DB->get_record('role', array('shortname' => 'editingteacher')); + $teacherrole = $DB->get_record('role', ['shortname' => 'editingteacher']); $this->getDataGenerator()->enrol_user($teacher->id, $this->course->id, $teacherrole->id); $this->setUser($teacher); @@ -335,11 +335,11 @@ public function test_add_session() { $this->resetAfterTest(true); $course = $this->getDataGenerator()->create_course(); - $group = $this->getDataGenerator()->create_group(array('courseid' => $course->id)); + $group = $this->getDataGenerator()->create_group(['courseid' => $course->id]); // Become a teacher. $teacher = self::getDataGenerator()->create_user(); - $teacherrole = $DB->get_record('role', array('shortname' => 'editingteacher')); + $teacherrole = $DB->get_record('role', ['shortname' => 'editingteacher']); $this->getDataGenerator()->enrol_user($teacher->id, $course->id, $teacherrole->id); $this->setUser($teacher); @@ -378,11 +378,11 @@ public function test_add_session_group_in_no_group_exception() { $this->resetAfterTest(true); $course = $this->getDataGenerator()->create_course(); - $group = $this->getDataGenerator()->create_group(array('courseid' => $course->id)); + $group = $this->getDataGenerator()->create_group(['courseid' => $course->id]); // Become a teacher. $teacher = self::getDataGenerator()->create_user(); - $teacherrole = $DB->get_record('role', array('shortname' => 'editingteacher')); + $teacherrole = $DB->get_record('role', ['shortname' => 'editingteacher']); $this->getDataGenerator()->enrol_user($teacher->id, $course->id, $teacherrole->id); $this->setUser($teacher); @@ -406,11 +406,11 @@ public function test_add_session_invalid_group_exception() { $this->resetAfterTest(true); $course = $this->getDataGenerator()->create_course(); - $group = $this->getDataGenerator()->create_group(array('courseid' => $course->id)); + $group = $this->getDataGenerator()->create_group(['courseid' => $course->id]); // Become a teacher. $teacher = self::getDataGenerator()->create_user(); - $teacherrole = $DB->get_record('role', array('shortname' => 'editingteacher')); + $teacherrole = $DB->get_record('role', ['shortname' => 'editingteacher']); $this->getDataGenerator()->enrol_user($teacher->id, $course->id, $teacherrole->id); $this->setUser($teacher); diff --git a/view.php b/view.php index 0bc59bb2129..869ccfd8569 100644 --- a/view.php +++ b/view.php @@ -38,8 +38,8 @@ $pageparams->sesscourses = optional_param('sesscourses', 'current', PARAM_ALPHA); $cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); -$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); -$attendance = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); +$attendance = $DB->get_record('attendance', ['id' => $cm->instance], '*', MUST_EXIST); require_login($course, true, $cm); $context = context_module::instance($cm->id); @@ -51,11 +51,11 @@ // Not specified studentid for displaying attendance? // Redirect to appropriate page if can. if (!$pageparams->studentid) { - $capabilities = array( + $capabilities = [ 'mod/attendance:manageattendances', 'mod/attendance:takeattendances', - 'mod/attendance:changeattendances' - ); + 'mod/attendance:changeattendances', + ]; if (has_any_capability($capabilities, $context)) { redirect($att->url_manage()); } else if (has_capability('mod/attendance:viewreports', $context)) { @@ -76,7 +76,7 @@ $PAGE->set_url($url); $buttons = ''; -$capabilities = array('mod/attendance:takeattendances', 'mod/attendance:changeattendances'); +$capabilities = ['mod/attendance:takeattendances', 'mod/attendance:changeattendances']; if (has_any_capability($capabilities, $context) && $pageparams->mode == mod_attendance_view_page_params::MODE_ALL_SESSIONS) { @@ -105,12 +105,12 @@ $userdata = new mod_attendance\output\user_data($att, $userid); // Create url for link in log screen. -$filterparams = array( +$filterparams = [ 'view' => $userdata->pageparams->view, 'curdate' => $userdata->pageparams->curdate, 'startdate' => $userdata->pageparams->startdate, - 'enddate' => $userdata->pageparams->enddate -); + 'enddate' => $userdata->pageparams->enddate, +]; $params = array_merge($userdata->pageparams->get_significant_params(), $filterparams); @@ -124,20 +124,20 @@ $userdata->take_sessions_from_form_data($formdata); // Trigger updated event. - $event = \mod_attendance\event\session_report_updated::create(array( + $event = \mod_attendance\event\session_report_updated::create([ 'relateduserid' => $relateduserid, 'context' => $context, - 'other' => $params)); + 'other' => $params]); $event->add_record_snapshot('course_modules', $cm); $event->trigger(); redirect($url, get_string('attendancesuccess', 'attendance')); } else { // Trigger viewed event. - $event = \mod_attendance\event\session_report_viewed::create(array( + $event = \mod_attendance\event\session_report_viewed::create([ 'relateduserid' => $relateduserid, 'context' => $context, - 'other' => $params)); + 'other' => $params]); $event->add_record_snapshot('course_modules', $cm); $event->trigger(); } diff --git a/warnings.php b/warnings.php index 2b1446774ed..60daab87f89 100644 --- a/warnings.php +++ b/warnings.php @@ -48,8 +48,8 @@ } else { // This is an attendance level config. $cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); - $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); - $att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); + $course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST); + $att = $DB->get_record('attendance', ['id' => $cm->instance], '*', MUST_EXIST); require_login($course, false, $cm); $context = context_module::instance($cm->id); @@ -66,7 +66,7 @@ echo $output->header(); } -$mform = new mod_attendance\form\addwarning($url, array('notid' => $notid, 'id' => $id)); +$mform = new mod_attendance\form\addwarning($url, ['notid' => $notid, 'id' => $id]); if ($data = $mform->get_data()) { if (empty($data->notid)) { @@ -89,9 +89,9 @@ if (!empty($data->thirdpartyemails)) { $notify->thirdpartyemails = implode(',', $data->thirdpartyemails); } - $existingrecord = $DB->record_exists('attendance_warning', array('idnumber' => $notify->idnumber, + $existingrecord = $DB->record_exists('attendance_warning', ['idnumber' => $notify->idnumber, 'warningpercent' => $notify->warningpercent, - 'warnafter' => $notify->warnafter)); + 'warnafter' => $notify->warnafter]); if (empty($existingrecord)) { $DB->insert_record('attendance_warning', $notify); echo $OUTPUT->notification(get_string('warningupdated', 'mod_attendance'), 'success'); @@ -100,7 +100,7 @@ } } else { - $notify = $DB->get_record('attendance_warning', array('id' => $data->notid)); + $notify = $DB->get_record('attendance_warning', ['id' => $data->notid]); if (!empty($id) && $data->idnumber != $att->id) { // Someone is trying to update a record for a different attendance. throw new moodle_exception('invalidcoursemodule'); @@ -119,8 +119,8 @@ if (!empty($data->thirdpartyemails)) { $notify->thirdpartyemails = implode(',', $data->thirdpartyemails); } - $existingrecord = $DB->get_record('attendance_warning', array('idnumber' => $notify->idnumber, - 'warningpercent' => $notify->warningpercent, 'warnafter' => $notify->warnafter)); + $existingrecord = $DB->get_record('attendance_warning', ['idnumber' => $notify->idnumber, + 'warningpercent' => $notify->warningpercent, 'warnafter' => $notify->warnafter]); if (empty($existingrecord) || $existingrecord->id == $notify->id) { $DB->update_record('attendance_warning', $notify); echo $OUTPUT->notification(get_string('warningupdated', 'mod_attendance'), 'success'); @@ -133,13 +133,13 @@ if ($action == 'delete' && !empty($notid)) { if (!optional_param('confirm', false, PARAM_BOOL)) { $cancelurl = $url; - $url->params(array('action' => 'delete', 'notid' => $notid, 'sesskey' => sesskey(), 'confirm' => true, 'id' => $id)); + $url->params(['action' => 'delete', 'notid' => $notid, 'sesskey' => sesskey(), 'confirm' => true, 'id' => $id]); echo $OUTPUT->confirm(get_string('deletewarningconfirm', 'mod_attendance'), $url, $cancelurl); echo $OUTPUT->footer(); exit; } else { require_sesskey(); - $params = array('id' => $notid); + $params = ['id' => $notid]; if (!empty($att)) { // Add id/level to array. $params['idnumber'] = $att->id; @@ -149,9 +149,9 @@ } } if ($action == 'update' && !empty($notid)) { - $existing = $DB->get_record('attendance_warning', array('id' => $notid)); + $existing = $DB->get_record('attendance_warning', ['id' => $notid]); $content = $existing->emailcontent; - $existing->emailcontent = array(); + $existing->emailcontent = []; $existing->emailcontent['text'] = $content; $existing->emailcontent['format'] = $existing->emailcontentformat; $existing->notid = $existing->id; @@ -170,28 +170,28 @@ } echo $OUTPUT->box($warningdesc, 'generalbox attendancedesc', 'notice'); $existingnotifications = $DB->get_records('attendance_warning', - array('idnumber' => $idnumber), + ['idnumber' => $idnumber], 'warningpercent'); if (!empty($existingnotifications)) { $table = new html_table(); - $table->head = array(get_string('warningthreshold', 'mod_attendance'), + $table->head = [get_string('warningthreshold', 'mod_attendance'), get_string('numsessions', 'mod_attendance'), get_string('emailsubject', 'mod_attendance'), - ''); + '', ]; foreach ($existingnotifications as $notification) { - $url->params(array('action' => 'delete', 'notid' => $notification->id, 'id' => $id)); + $url->params(['action' => 'delete', 'notid' => $notification->id, 'id' => $id]); $actionbuttons = $OUTPUT->action_icon($url, new pix_icon('t/delete', get_string('delete', 'attendance')), null, null); - $url->params(array('action' => 'update', 'notid' => $notification->id, 'id' => $id)); + $url->params(['action' => 'update', 'notid' => $notification->id, 'id' => $id]); $actionbuttons .= $OUTPUT->action_icon($url, new pix_icon('t/edit', get_string('update', 'attendance')), null, null); - $table->data[] = array($notification->warningpercent, $notification->warnafter, - $notification->emailsubject, $actionbuttons); + $table->data[] = [$notification->warningpercent, $notification->warnafter, + $notification->emailsubject, $actionbuttons, ]; } echo html_writer::table($table); } - $addurl = new moodle_url('/mod/attendance/warnings.php', array('action' => 'add', 'id' => $id)); + $addurl = new moodle_url('/mod/attendance/warnings.php', ['action' => 'add', 'id' => $id]); echo $OUTPUT->single_button($addurl, get_string('addwarning', 'mod_attendance')); }