diff --git a/attendance.php b/attendance.php index f08b89d..e038483 100644 --- a/attendance.php +++ b/attendance.php @@ -30,8 +30,6 @@ $pageparams = new att_sessions_page_params(); // Check that the required parameters are present. $id = required_param('sessid', PARAM_INT); -$attendance_session_id = required_param('sessid', PARAM_INT); - $attforsession = $DB->get_record('attendance_sessions', array('id' => $id), '*', MUST_EXIST); $attendance = $DB->get_record('attendance', array('id' => $attforsession->attendanceid), '*', MUST_EXIST); diff --git a/backup/moodle2/backup_attendance_activity_task.class.php b/backup/moodle2/backup_attendance_activity_task.class.php index df3b4a0..3e7703f 100644 --- a/backup/moodle2/backup_attendance_activity_task.class.php +++ b/backup/moodle2/backup_attendance_activity_task.class.php @@ -60,11 +60,11 @@ class backup_attendance_activity_task extends backup_activity_task { // Link to attendance view by moduleid. $search = "/(" . $base . "\/mod\/attendance\/view.php\?id\=)([0-9]+)/"; - $content= preg_replace($search, '$@ATTENDANCEVIEWBYID*$2@$', $content); + $content = preg_replace($search, '$@ATTENDANCEVIEWBYID*$2@$', $content); // Link to attendance view by moduleid and studentid. $search = "/(" . $base . "\/mod\/attendance\/view.php\?id\=)([0-9]+)\&studentid\=([0-9]+)/"; - $content= preg_replace($search, '$@ATTENDANCEVIEWBYIDSTUD*$2*$3@$', $content); + $content = preg_replace($search, '$@ATTENDANCEVIEWBYIDSTUD*$2*$3@$', $content); return $content; } diff --git a/backup/moodle2/restore_attendance_activity_task.class.php b/backup/moodle2/restore_attendance_activity_task.class.php index 989557b..28c1ec1 100644 --- a/backup/moodle2/restore_attendance_activity_task.class.php +++ b/backup/moodle2/restore_attendance_activity_task.class.php @@ -72,7 +72,7 @@ class restore_attendance_activity_task extends restore_activity_task { $rules[] = new restore_decode_rule('ATTENDANCEVIEWBYIDSTUD', '/mod/attendance/view.php?id=$1&studentid=$2', array('course_module', 'user')); - // Older style backups using previous plugin name + // Older style backups using previous plugin name. $rules[] = new restore_decode_rule('ATTFORBLOCKVIEWBYID', '/mod/attendance/view.php?id=$1', 'course_module'); $rules[] = new restore_decode_rule('ATTFORBLOCKVIEWBYIDSTUD', diff --git a/calendar.js b/calendar.js index 147c1ce..0c50310 100644 --- a/calendar.js +++ b/calendar.js @@ -68,7 +68,7 @@ YUI().use('yui2-container', 'yui2-calendar', function(Y) { calendar.cfg.setProperty("start_weekday", M.attendance.cal_start_weekday); calendar.cfg.setProperty("MONTHS_LONG", M.attendance.cal_months); calendar.cfg.setProperty("WEEKDAYS_SHORT", M.attendance.cal_week_days); - calendar.select(new Date(M.attendance.cal_cur_date*1000)); + calendar.select(new Date(M.attendance.cal_cur_date * 1000)); calendar.render(); calendar.selectEvent.subscribe(function() { diff --git a/classes/event/attendance_taken.php b/classes/event/attendance_taken.php index afbb322..d001a27 100644 --- a/classes/event/attendance_taken.php +++ b/classes/event/attendance_taken.php @@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die(); * @property-read array $other { * Extra information about event properties. * - * @string mode Mode of the report viewed. + * string mode Mode of the report viewed. * } * @package mod_attendance * @since Moodle 2.7 diff --git a/classes/event/attendance_taken_by_student.php b/classes/event/attendance_taken_by_student.php index f5344b3..8cb2b55 100644 --- a/classes/event/attendance_taken_by_student.php +++ b/classes/event/attendance_taken_by_student.php @@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die(); * @property-read array $other { * Extra information about event properties. * - * @string mode Mode of the report viewed. + * string mode Mode of the report viewed. * } * @package mod_attendance * @since Moodle 2.7 diff --git a/classes/event/report_viewed.php b/classes/event/report_viewed.php index e2981ba..cadfd3b 100644 --- a/classes/event/report_viewed.php +++ b/classes/event/report_viewed.php @@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die(); * @property-read array $other { * Extra information about event properties. * - * @string mode Mode of the report viewed. + * string mode Mode of the report viewed. * } * @package mod_attendance * @since Moodle 2.7 @@ -86,14 +86,4 @@ class report_viewed extends \core\event\base { return array($this->courseid, 'attendance', 'report', 'report.php?id=' . $this->objectid, $this->objectid, $this->contextinstanceid); } - - /** - * Custom validation. - * - * @throws \coding_exception - * @return void - */ - protected function validate_data() { - parent::validate_data(); - } } diff --git a/classes/event/session_added.php b/classes/event/session_added.php index 01b0e1a..db33ace 100644 --- a/classes/event/session_added.php +++ b/classes/event/session_added.php @@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die(); * @property-read array $other { * Extra information about event properties. * - * @string mode Mode of the report viewed. + * string mode Mode of the report viewed. * } * @package mod_attendance * @since Moodle 2.7 diff --git a/classes/event/session_deleted.php b/classes/event/session_deleted.php index 818170f..2cf29a5 100644 --- a/classes/event/session_deleted.php +++ b/classes/event/session_deleted.php @@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die(); * @property-read array $other { * Extra information about event properties. * - * @string mode Mode of the report viewed. + * string mode Mode of the report viewed. * } * @package mod_attendance * @since Moodle 2.7 diff --git a/classes/event/session_duration_updated.php b/classes/event/session_duration_updated.php index c4dede7..fbbaf56 100644 --- a/classes/event/session_duration_updated.php +++ b/classes/event/session_duration_updated.php @@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die(); * @property-read array $other { * Extra information about event properties. * - * @string mode Mode of the report viewed. + * string mode Mode of the report viewed. * } * @package mod_attendance * @since Moodle 2.7 diff --git a/classes/event/session_updated.php b/classes/event/session_updated.php index c9d5598..cab8e51 100644 --- a/classes/event/session_updated.php +++ b/classes/event/session_updated.php @@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die(); * @property-read array $other { * Extra information about event properties. * - * @string mode Mode of the report viewed. + * string mode Mode of the report viewed. * } * @package mod_attendance * @since Moodle 2.7 diff --git a/classes/event/status_added.php b/classes/event/status_added.php index 4cee03f..8a855c1 100644 --- a/classes/event/status_added.php +++ b/classes/event/status_added.php @@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die(); * @property-read array $other { * Extra information about event properties. * - * @string mode Mode of the report viewed. + * string mode Mode of the report viewed. * } * @package mod_attendance * @since Moodle 2.7 @@ -86,14 +86,4 @@ class status_added extends \core\event\base { return array($this->courseid, 'attendance', 'status added', $this->get_url(), $this->other['acronym'].': '.$this->other['description'].' ('.$this->other['grade'].')', $this->contextinstanceid); } - - /** - * Custom validation. - * - * @throws \coding_exception - * @return void - */ - protected function validate_data() { - parent::validate_data(); - } } diff --git a/classes/event/status_removed.php b/classes/event/status_removed.php index 96373da..a32ad7a 100644 --- a/classes/event/status_removed.php +++ b/classes/event/status_removed.php @@ -32,7 +32,7 @@ defined('MOODLE_INTERNAL') || die(); * @property-read array $other { * Extra information about event properties. * - * @string mode Mode of the report viewed. + * string mode Mode of the report viewed. * } * @package mod_attendance * @since Moodle 2.7 @@ -56,7 +56,8 @@ class status_removed extends \core\event\base { * @return string */ public function get_description() { - return 'User with id ' . $this->userid . ' deleted attendance status "' . $this->data['other']['acronym'] . ' - ' . $this->data['other']['description'] . '" with instanceid ' . + return 'User with id ' . $this->userid . ' deleted attendance status "' . $this->data['other']['acronym'] . + ' - ' . $this->data['other']['description'] . '" with instanceid ' . $this->objectid . ''; } @@ -87,14 +88,4 @@ class status_removed extends \core\event\base { return array($this->courseid, 'attendance', 'status removed', $this->get_url(), $this->other['acronym'] . ' - ' . $this->other['description'], $this->contextinstanceid); } - - /** - * Custom validation. - * - * @throws \coding_exception - * @return void - */ - protected function validate_data() { - parent::validate_data(); - } } diff --git a/classes/event/status_updated.php b/classes/event/status_updated.php index 22f4ab1..2a2caee 100644 --- a/classes/event/status_updated.php +++ b/classes/event/status_updated.php @@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die(); * @property-read array $other { * Extra information about event properties. * - * @string mode Mode of the report viewed. + * string mode Mode of the report viewed. * } * @package mod_attendance * @since Moodle 2.7 @@ -86,14 +86,4 @@ class status_updated extends \core\event\base { return array($this->courseid, 'attendance', 'status updated', $this->get_url(), $this->other['updated'], $this->contextinstanceid); } - - /** - * Custom validation. - * - * @throws \coding_exception - * @return void - */ - protected function validate_data() { - parent::validate_data(); - } } diff --git a/classes/notifyqueue.php b/classes/notifyqueue.php index 7f42a07..038b068 100644 --- a/classes/notifyqueue.php +++ b/classes/notifyqueue.php @@ -33,7 +33,7 @@ class mod_attendance_notifyqueue { global $SESSION, $OUTPUT; if (isset($SESSION->mod_attendance_notifyqueue)) { - foreach ($SESSION->mod_attendance_notifyqueue AS $message) { + foreach ($SESSION->mod_attendance_notifyqueue as $message) { echo $OUTPUT->notification($message->message, 'notify'.$message->type); } unset($SESSION->mod_attendance_notifyqueue); diff --git a/db/upgrade.php b/db/upgrade.php index ec1488f..5617bcd 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -42,7 +42,7 @@ function xmldb_attendance_upgrade($oldversion=0) { if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } - + upgrade_mod_savepoint($result, 2014112000, 'attendance'); } diff --git a/duration_form.php b/duration_form.php index 3051642..7bcdcbb 100644 --- a/duration_form.php +++ b/duration_form.php @@ -50,10 +50,10 @@ class mod_attendance_duration_form extends moodleform { $mform->addElement('header', 'general', get_string('changeduration', 'attendance')); $mform->addElement('static', 'count', get_string('countofselected', 'attendance'), count(explode('_', $ids))); - for ($i=0; $i<=23; $i++) { + for ($i = 0; $i <= 23; $i++) { $hours[$i] = sprintf("%02d", $i); } - for ($i=0; $i<60; $i+=5) { + for ($i = 0; $i < 60; $i+=5) { $minutes[$i] = sprintf("%02d", $i); } $durselect[] =& $mform->createElement('select', 'hours', '', $hours); @@ -67,10 +67,10 @@ class mod_attendance_duration_form extends moodleform { $mform->addElement('hidden', 'action', att_sessions_page_params::ACTION_CHANGE_DURATION); $mform->setType('action', PARAM_INT); - $mform->setDefaults(array('durtime' => array('hours'=>0, 'minutes'=>0))); + $mform->setDefaults(array('durtime' => array('hours' => 0, 'minutes' => 0))); - $submit_string = get_string('update', 'attendance'); - $this->add_action_buttons(true, $submit_string); + $submitstring = get_string('update', 'attendance'); + $this->add_action_buttons(true, $submitstring); } } diff --git a/export.php b/export.php index 6e46d3f..5258d4e 100644 --- a/export.php +++ b/export.php @@ -91,14 +91,14 @@ if ($formdata = $mform->get_data()) { if (isset($formdata->ident['uname'])) { $data->tabhead[] = get_string('username'); } - + $optional = array('idnumber', 'institution', 'department'); foreach ($optional as $opt) { if (isset($formdata->ident[$opt])) { $data->tabhead[] = get_string($opt); } } - + $data->tabhead[] = get_string('lastname'); $data->tabhead[] = get_string('firstname'); $groupmode = groups_get_activity_groupmode($cm, $course); @@ -133,14 +133,14 @@ if ($formdata = $mform->get_data()) { if (isset($formdata->ident['uname'])) { $data->table[$i][] = $user->username; } - - $optional_row = array('idnumber', 'institution', 'department'); - foreach ($optional_row as $opt) { + + $optionalrow = array('idnumber', 'institution', 'department'); + foreach ($optionalrow as $opt) { if (isset($formdata->ident[$opt])) { $data->table[$i][] = $user->$opt; } } - + $data->table[$i][] = $user->lastname; $data->table[$i][] = $user->firstname; if (!empty($groupmode)) { diff --git a/export_form.php b/export_form.php index b07b8ad..ba048e5 100644 --- a/export_form.php +++ b/export_form.php @@ -48,7 +48,7 @@ class mod_attendance_export_form extends moodleform { $mform->addElement('header', 'general', get_string('export', 'attendance')); - $groupmode=groups_get_activity_groupmode($cm, $course); + $groupmode = groups_get_activity_groupmode($cm, $course); $groups = groups_get_activity_allowed_groups($cm, $USER->id); if ($groupmode == VISIBLEGROUPS or has_capability('moodle/site:accessallgroups', $modcontext)) { $grouplist[0] = get_string('allparticipants'); @@ -60,7 +60,6 @@ class mod_attendance_export_form extends moodleform { } $mform->addElement('select', 'group', get_string('group'), $grouplist); - // Restrict the export to the selected users. $namefields = get_all_user_name_fields(true, 'u'); $allusers = get_enrolled_users($modcontext, 'mod/attendance:canbelisted', 0, 'u.id,'.$namefields); @@ -100,13 +99,13 @@ class mod_attendance_export_form extends moodleform { $ident = array(); $ident[] =& $mform->createElement('checkbox', 'id', '', get_string('studentid', 'attendance')); $ident[] =& $mform->createElement('checkbox', 'uname', '', get_string('username')); - + $optional = array('idnumber', 'institution', 'department'); foreach ($optional as $opt) { $ident[] =& $mform->createElement('checkbox', $opt, '', get_string($opt)); $mform->setType($opt, PARAM_NOTAGS); } - + $mform->addGroup($ident, 'ident', get_string('identifyby', 'attendance'), array('
'), true); $mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true)); $mform->setType('id', PARAM_INT); @@ -128,13 +127,13 @@ class mod_attendance_export_form extends moodleform { 'text' => get_string('downloadtext', 'attendance') )); - $submit_string = get_string('ok'); - $this->add_action_buttons(false, $submit_string); + $submitstring = get_string('ok'); + $this->add_action_buttons(false, $submitstring); $mform->addElement('hidden', 'id', $cm->id); } - function validation($data, $files) { + public function validation($data, $files) { $errors = parent::validation($data, $files); // Validate the 'users' field. diff --git a/lib.php b/lib.php index ab61452..3222181 100644 --- a/lib.php +++ b/lib.php @@ -54,7 +54,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', array('attendanceid' => 0), 'id'); foreach ($statuses as $st) { $rec = $st; $rec->attendanceid = $attid; @@ -97,17 +97,17 @@ function attendance_update_instance($attendance) { function attendance_delete_instance($id) { global $DB; - if (! $attendance = $DB->get_record('attendance', array('id'=> $id))) { + if (! $attendance = $DB->get_record('attendance', array('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', array('attendanceid' => $id), '', 'id'))) { $DB->delete_records_list('attendance_log', 'sessionid', $sessids); - $DB->delete_records('attendance_sessions', array('attendanceid'=> $id)); + $DB->delete_records('attendance_sessions', array('attendanceid' => $id)); } - $DB->delete_records('attendance_statuses', array('attendanceid'=> $id)); + $DB->delete_records('attendance_statuses', array('attendanceid' => $id)); - $DB->delete_records('attendance', array('id'=> $id)); + $DB->delete_records('attendance', array('id' => $id)); attendance_grade_item_delete($attendance); @@ -117,7 +117,7 @@ function attendance_delete_instance($id) { function attendance_delete_course($course, $feedback=true) { global $DB; - $attids = array_keys($DB->get_records('attendance', array('course'=> $course->id), '', 'id')); + $attids = array_keys($DB->get_records('attendance', array('course' => $course->id), '', 'id')); $sessids = array_keys($DB->get_records_list('attendance_sessions', 'attendanceid', $attids, '', 'id')); if ($sessids) { $DB->delete_records_list('attendance_log', 'sessionid', $sessids); @@ -126,7 +126,7 @@ function attendance_delete_course($course, $feedback=true) { $DB->delete_records_list('attendance_statuses', 'attendanceid', $attids); $DB->delete_records_list('attendance_sessions', 'attendanceid', $attids); } - $DB->delete_records('attendance', array('course'=> $course->id)); + $DB->delete_records('attendance', array('course' => $course->id)); return true; } @@ -154,7 +154,7 @@ function attendance_reset_course_form_definition(&$mform) { * Course reset form defaults. */ function attendance_reset_course_form_defaults($course) { - return array('reset_attendance_log'=>0, 'reset_attendance_statuses'=>0, 'reset_attendance_sessions'=>0); + return array('reset_attendance_log' => 0, 'reset_attendance_statuses' => 0, 'reset_attendance_sessions' => 0); } function attendance_reset_userdata($data) { @@ -162,7 +162,7 @@ function attendance_reset_userdata($data) { $status = array(); - $attids = array_keys($DB->get_records('attendance', array('course'=> $data->courseid), '', 'id')); + $attids = array_keys($DB->get_records('attendance', array('course' => $data->courseid), '', 'id')); if (!empty($data->reset_attendance_log)) { $sess = $DB->get_records_list('attendance_sessions', 'attendanceid', $attids, '', 'id'); @@ -283,16 +283,16 @@ function attendance_grade_item_update($attendance, $grades=null) { if (!isset($attendance->courseid)) { $attendance->courseid = $attendance->course; } - if (! $course = $DB->get_record('course', array('id'=> $attendance->course))) { + if (! $course = $DB->get_record('course', array('id' => $attendance->course))) { error("Course is misconfigured"); } if (!empty($attendance->cmidnumber)) { - $params = array('itemname'=>$attendance->name, 'idnumber'=>$attendance->cmidnumber); + $params = array('itemname' => $attendance->name, 'idnumber' => $attendance->cmidnumber); } else { // MDL-14303. $cm = get_coursemodule_from_instance('attendance', $attendance->id); - $params = array('itemname'=>$attendance->name/*, 'idnumber'=>$attendance->id*/); + $params = array('itemname' => $attendance->name/*, 'idnumber'=>$attendance->id*/); } if ($attendance->grade > 0) { @@ -307,7 +307,7 @@ function attendance_grade_item_update($attendance, $grades=null) { $params['gradetype'] = GRADE_TYPE_NONE; } - if ($grades === 'reset') { + if ($grades === 'reset') { $params['reset'] = true; $grades = null; } @@ -330,7 +330,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, array('deleted' => 1)); } function attendance_get_participants($attendanceid) { diff --git a/mod_form.php b/mod_form.php index 9d45e13..6cd15f7 100644 --- a/mod_form.php +++ b/mod_form.php @@ -46,7 +46,7 @@ class mod_attendance_mod_form extends moodleform_mod { $mform->addElement('header', 'general', get_string('general', 'form')); - $mform->addElement('text', 'name', get_string('name'), array('size'=>'64')); + $mform->addElement('text', 'name', get_string('name'), array('size' => '64')); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', null, 'required', null, 'client'); $mform->setDefault('name', get_string('modulename', 'attendance'));