Browse Source

Fix some coding guideline issues.

MOODLE_29_STABLE
Dan Marsden 9 years ago
parent
commit
396d24d047
  1. 2
      attendance.php
  2. 4
      backup/moodle2/backup_attendance_activity_task.class.php
  3. 2
      backup/moodle2/restore_attendance_activity_task.class.php
  4. 2
      calendar.js
  5. 2
      classes/event/attendance_taken.php
  6. 2
      classes/event/attendance_taken_by_student.php
  7. 12
      classes/event/report_viewed.php
  8. 2
      classes/event/session_added.php
  9. 2
      classes/event/session_deleted.php
  10. 2
      classes/event/session_duration_updated.php
  11. 2
      classes/event/session_updated.php
  12. 12
      classes/event/status_added.php
  13. 15
      classes/event/status_removed.php
  14. 12
      classes/event/status_updated.php
  15. 2
      classes/notifyqueue.php
  16. 10
      duration_form.php
  17. 4
      export.php
  18. 9
      export_form.php
  19. 28
      lib.php
  20. 2
      mod_form.php

2
attendance.php

@ -30,8 +30,6 @@ $pageparams = new att_sessions_page_params();
// Check that the required parameters are present. // Check that the required parameters are present.
$id = required_param('sessid', PARAM_INT); $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); $attforsession = $DB->get_record('attendance_sessions', array('id' => $id), '*', MUST_EXIST);
$attendance = $DB->get_record('attendance', array('id' => $attforsession->attendanceid), '*', MUST_EXIST); $attendance = $DB->get_record('attendance', array('id' => $attforsession->attendanceid), '*', MUST_EXIST);

4
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. // Link to attendance view by moduleid.
$search = "/(" . $base . "\/mod\/attendance\/view.php\?id\=)([0-9]+)/"; $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. // Link to attendance view by moduleid and studentid.
$search = "/(" . $base . "\/mod\/attendance\/view.php\?id\=)([0-9]+)\&studentid\=([0-9]+)/"; $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; return $content;
} }

2
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', $rules[] = new restore_decode_rule('ATTENDANCEVIEWBYIDSTUD',
'/mod/attendance/view.php?id=$1&studentid=$2', array('course_module', 'user')); '/mod/attendance/view.php?id=$1&studentid=$2', array('course_module', 'user'));
// Older style backups using previous plugin name // Older style backups using previous plugin name.
$rules[] = new restore_decode_rule('ATTFORBLOCKVIEWBYID', $rules[] = new restore_decode_rule('ATTFORBLOCKVIEWBYID',
'/mod/attendance/view.php?id=$1', 'course_module'); '/mod/attendance/view.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('ATTFORBLOCKVIEWBYIDSTUD', $rules[] = new restore_decode_rule('ATTFORBLOCKVIEWBYIDSTUD',

2
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("start_weekday", M.attendance.cal_start_weekday);
calendar.cfg.setProperty("MONTHS_LONG", M.attendance.cal_months); calendar.cfg.setProperty("MONTHS_LONG", M.attendance.cal_months);
calendar.cfg.setProperty("WEEKDAYS_SHORT", M.attendance.cal_week_days); 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.render();
calendar.selectEvent.subscribe(function() { calendar.selectEvent.subscribe(function() {

2
classes/event/attendance_taken.php

@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other { * @property-read array $other {
* Extra information about event properties. * Extra information about event properties.
* *
* @string mode Mode of the report viewed. * string mode Mode of the report viewed.
* } * }
* @package mod_attendance * @package mod_attendance
* @since Moodle 2.7 * @since Moodle 2.7

2
classes/event/attendance_taken_by_student.php

@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other { * @property-read array $other {
* Extra information about event properties. * Extra information about event properties.
* *
* @string mode Mode of the report viewed. * string mode Mode of the report viewed.
* } * }
* @package mod_attendance * @package mod_attendance
* @since Moodle 2.7 * @since Moodle 2.7

12
classes/event/report_viewed.php

@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other { * @property-read array $other {
* Extra information about event properties. * Extra information about event properties.
* *
* @string mode Mode of the report viewed. * string mode Mode of the report viewed.
* } * }
* @package mod_attendance * @package mod_attendance
* @since Moodle 2.7 * @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, return array($this->courseid, 'attendance', 'report', 'report.php?id=' . $this->objectid,
$this->objectid, $this->contextinstanceid); $this->objectid, $this->contextinstanceid);
} }
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
}
} }

2
classes/event/session_added.php

@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other { * @property-read array $other {
* Extra information about event properties. * Extra information about event properties.
* *
* @string mode Mode of the report viewed. * string mode Mode of the report viewed.
* } * }
* @package mod_attendance * @package mod_attendance
* @since Moodle 2.7 * @since Moodle 2.7

2
classes/event/session_deleted.php

@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other { * @property-read array $other {
* Extra information about event properties. * Extra information about event properties.
* *
* @string mode Mode of the report viewed. * string mode Mode of the report viewed.
* } * }
* @package mod_attendance * @package mod_attendance
* @since Moodle 2.7 * @since Moodle 2.7

2
classes/event/session_duration_updated.php

@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other { * @property-read array $other {
* Extra information about event properties. * Extra information about event properties.
* *
* @string mode Mode of the report viewed. * string mode Mode of the report viewed.
* } * }
* @package mod_attendance * @package mod_attendance
* @since Moodle 2.7 * @since Moodle 2.7

2
classes/event/session_updated.php

@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other { * @property-read array $other {
* Extra information about event properties. * Extra information about event properties.
* *
* @string mode Mode of the report viewed. * string mode Mode of the report viewed.
* } * }
* @package mod_attendance * @package mod_attendance
* @since Moodle 2.7 * @since Moodle 2.7

12
classes/event/status_added.php

@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other { * @property-read array $other {
* Extra information about event properties. * Extra information about event properties.
* *
* @string mode Mode of the report viewed. * string mode Mode of the report viewed.
* } * }
* @package mod_attendance * @package mod_attendance
* @since Moodle 2.7 * @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(), return array($this->courseid, 'attendance', 'status added', $this->get_url(),
$this->other['acronym'].': '.$this->other['description'].' ('.$this->other['grade'].')', $this->contextinstanceid); $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();
}
} }

15
classes/event/status_removed.php

@ -32,7 +32,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other { * @property-read array $other {
* Extra information about event properties. * Extra information about event properties.
* *
* @string mode Mode of the report viewed. * string mode Mode of the report viewed.
* } * }
* @package mod_attendance * @package mod_attendance
* @since Moodle 2.7 * @since Moodle 2.7
@ -56,7 +56,8 @@ class status_removed extends \core\event\base {
* @return string * @return string
*/ */
public function get_description() { 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 . ''; $this->objectid . '';
} }
@ -87,14 +88,4 @@ class status_removed extends \core\event\base {
return array($this->courseid, 'attendance', 'status removed', $this->get_url(), return array($this->courseid, 'attendance', 'status removed', $this->get_url(),
$this->other['acronym'] . ' - ' . $this->other['description'], $this->contextinstanceid); $this->other['acronym'] . ' - ' . $this->other['description'], $this->contextinstanceid);
} }
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
}
} }

12
classes/event/status_updated.php

@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other { * @property-read array $other {
* Extra information about event properties. * Extra information about event properties.
* *
* @string mode Mode of the report viewed. * string mode Mode of the report viewed.
* } * }
* @package mod_attendance * @package mod_attendance
* @since Moodle 2.7 * @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(), return array($this->courseid, 'attendance', 'status updated', $this->get_url(),
$this->other['updated'], $this->contextinstanceid); $this->other['updated'], $this->contextinstanceid);
} }
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
}
} }

2
classes/notifyqueue.php

@ -33,7 +33,7 @@ class mod_attendance_notifyqueue {
global $SESSION, $OUTPUT; global $SESSION, $OUTPUT;
if (isset($SESSION->mod_attendance_notifyqueue)) { 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); echo $OUTPUT->notification($message->message, 'notify'.$message->type);
} }
unset($SESSION->mod_attendance_notifyqueue); unset($SESSION->mod_attendance_notifyqueue);

10
duration_form.php

@ -50,10 +50,10 @@ class mod_attendance_duration_form extends moodleform {
$mform->addElement('header', 'general', get_string('changeduration', 'attendance')); $mform->addElement('header', 'general', get_string('changeduration', 'attendance'));
$mform->addElement('static', 'count', get_string('countofselected', 'attendance'), count(explode('_', $ids))); $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); $hours[$i] = sprintf("%02d", $i);
} }
for ($i=0; $i<60; $i+=5) { for ($i = 0; $i < 60; $i+=5) {
$minutes[$i] = sprintf("%02d", $i); $minutes[$i] = sprintf("%02d", $i);
} }
$durselect[] =& $mform->createElement('select', 'hours', '', $hours); $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->addElement('hidden', 'action', att_sessions_page_params::ACTION_CHANGE_DURATION);
$mform->setType('action', PARAM_INT); $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'); $submitstring = get_string('update', 'attendance');
$this->add_action_buttons(true, $submit_string); $this->add_action_buttons(true, $submitstring);
} }
} }

4
export.php

@ -134,8 +134,8 @@ if ($formdata = $mform->get_data()) {
$data->table[$i][] = $user->username; $data->table[$i][] = $user->username;
} }
$optional_row = array('idnumber', 'institution', 'department'); $optionalrow = array('idnumber', 'institution', 'department');
foreach ($optional_row as $opt) { foreach ($optionalrow as $opt) {
if (isset($formdata->ident[$opt])) { if (isset($formdata->ident[$opt])) {
$data->table[$i][] = $user->$opt; $data->table[$i][] = $user->$opt;
} }

9
export_form.php

@ -48,7 +48,7 @@ class mod_attendance_export_form extends moodleform {
$mform->addElement('header', 'general', get_string('export', 'attendance')); $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); $groups = groups_get_activity_allowed_groups($cm, $USER->id);
if ($groupmode == VISIBLEGROUPS or has_capability('moodle/site:accessallgroups', $modcontext)) { if ($groupmode == VISIBLEGROUPS or has_capability('moodle/site:accessallgroups', $modcontext)) {
$grouplist[0] = get_string('allparticipants'); $grouplist[0] = get_string('allparticipants');
@ -60,7 +60,6 @@ class mod_attendance_export_form extends moodleform {
} }
$mform->addElement('select', 'group', get_string('group'), $grouplist); $mform->addElement('select', 'group', get_string('group'), $grouplist);
// Restrict the export to the selected users. // Restrict the export to the selected users.
$namefields = get_all_user_name_fields(true, 'u'); $namefields = get_all_user_name_fields(true, 'u');
$allusers = get_enrolled_users($modcontext, 'mod/attendance:canbelisted', 0, 'u.id,'.$namefields); $allusers = get_enrolled_users($modcontext, 'mod/attendance:canbelisted', 0, 'u.id,'.$namefields);
@ -128,13 +127,13 @@ class mod_attendance_export_form extends moodleform {
'text' => get_string('downloadtext', 'attendance') 'text' => get_string('downloadtext', 'attendance')
)); ));
$submit_string = get_string('ok'); $submitstring = get_string('ok');
$this->add_action_buttons(false, $submit_string); $this->add_action_buttons(false, $submitstring);
$mform->addElement('hidden', 'id', $cm->id); $mform->addElement('hidden', 'id', $cm->id);
} }
function validation($data, $files) { public function validation($data, $files) {
$errors = parent::validation($data, $files); $errors = parent::validation($data, $files);
// Validate the 'users' field. // Validate the 'users' field.

28
lib.php

@ -54,7 +54,7 @@ function attendance_supports($feature) {
function att_add_default_statuses($attid) { function att_add_default_statuses($attid) {
global $DB; 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) { foreach ($statuses as $st) {
$rec = $st; $rec = $st;
$rec->attendanceid = $attid; $rec->attendanceid = $attid;
@ -97,17 +97,17 @@ function attendance_update_instance($attendance) {
function attendance_delete_instance($id) { function attendance_delete_instance($id) {
global $DB; global $DB;
if (! $attendance = $DB->get_record('attendance', array('id'=> $id))) { if (! $attendance = $DB->get_record('attendance', array('id' => $id))) {
return false; 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_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); attendance_grade_item_delete($attendance);
@ -117,7 +117,7 @@ function attendance_delete_instance($id) {
function attendance_delete_course($course, $feedback=true) { function attendance_delete_course($course, $feedback=true) {
global $DB; 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')); $sessids = array_keys($DB->get_records_list('attendance_sessions', 'attendanceid', $attids, '', 'id'));
if ($sessids) { if ($sessids) {
$DB->delete_records_list('attendance_log', 'sessionid', $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_statuses', 'attendanceid', $attids);
$DB->delete_records_list('attendance_sessions', '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; return true;
} }
@ -154,7 +154,7 @@ function attendance_reset_course_form_definition(&$mform) {
* Course reset form defaults. * Course reset form defaults.
*/ */
function attendance_reset_course_form_defaults($course) { 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) { function attendance_reset_userdata($data) {
@ -162,7 +162,7 @@ function attendance_reset_userdata($data) {
$status = array(); $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)) { if (!empty($data->reset_attendance_log)) {
$sess = $DB->get_records_list('attendance_sessions', 'attendanceid', $attids, '', 'id'); $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)) { if (!isset($attendance->courseid)) {
$attendance->courseid = $attendance->course; $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"); error("Course is misconfigured");
} }
if (!empty($attendance->cmidnumber)) { if (!empty($attendance->cmidnumber)) {
$params = array('itemname'=>$attendance->name, 'idnumber'=>$attendance->cmidnumber); $params = array('itemname' => $attendance->name, 'idnumber' => $attendance->cmidnumber);
} else { } else {
// MDL-14303. // MDL-14303.
$cm = get_coursemodule_from_instance('attendance', $attendance->id); $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) { if ($attendance->grade > 0) {
@ -330,7 +330,7 @@ function attendance_grade_item_delete($attendance) {
} }
return grade_update('mod/attendance', $attendance->courseid, 'mod', '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) { function attendance_get_participants($attendanceid) {

2
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('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->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', null, 'required', null, 'client');
$mform->setDefault('name', get_string('modulename', 'attendance')); $mform->setDefault('name', get_string('modulename', 'attendance'));

Loading…
Cancel
Save