From 7fa4961b327464448035d00466a2140ae2519c1f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luca=20B=C3=B6sch?=
'), 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 '
'.get_string('tempuserslist', 'attendance').'
'; @@ -118,7 +118,7 @@ function attendance_print_tempusers($tempusers, mod_attendance_structure $att) { echo 'Merge Accounts
Moodle User | -Temporary User | -Action | -
---|---|---|
Attendance data | -Attendance data | -Temporary user will override Moodle user | -
No attendance data | -Attendance data | -Temporary user attendance will be transfered to Moodle user | -
Attendance data | -No attendance data | -Temporary user will be deleted | -
No attendance data | -No attendance data | -Temporary user will be deleted | -
Moodle User | +Temporary User | +Action | +
Attendance data | +Attendance data | +Temporary user will override Moodle user | +
No attendance data | +Attendance data | +Temporary user attendance will be transfered to Moodle user | +
Attendance data | +No attendance data | +Temporary user will be deleted | +
No attendance data | +No attendance data | +Temporary user will be deleted | +