diff --git a/classes/api.php b/classes/api.php index 7c7b9df..8f2d5af 100644 --- a/classes/api.php +++ b/classes/api.php @@ -80,7 +80,7 @@ public static function save_hours($formdata) { $id = $DB->get_record('report_apprentice', [ 'studentid' => $dataobject->studentid, - 'activityid' => $dataobject->activityid + 'activityid' => $dataobject->activityid, ]); if (!$id) { $dataobject->timecreated = time(); diff --git a/classes/event/hours_edited.php b/classes/event/hours_edited.php index da55c04..9881410 100644 --- a/classes/event/hours_edited.php +++ b/classes/event/hours_edited.php @@ -69,9 +69,10 @@ public static function get_name() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/report/apprenticeoffjob/edit.php', array( + return new \moodle_url('/report/apprenticeoffjob/edit.php', [ 'studentid' => $this->relateduserid, - 'courseid' => $this->courseid)); + 'courseid' => $this->courseid, + ] + ); } - } diff --git a/classes/event/report_viewed.php b/classes/event/report_viewed.php index e5a2277..8eb6618 100644 --- a/classes/event/report_viewed.php +++ b/classes/event/report_viewed.php @@ -69,7 +69,7 @@ public static function get_name() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/report/apprenticeoffjob/index.php', array('id' => $this->courseid)); + return new \moodle_url('/report/apprenticeoffjob/index.php', ['id' => $this->courseid]); } } diff --git a/classes/forms/offjobhours.php b/classes/forms/offjobhours.php index 6187070..3f03741 100644 --- a/classes/forms/offjobhours.php +++ b/classes/forms/offjobhours.php @@ -63,7 +63,7 @@ public function definition() { $mform->addElement('hidden', 'courseid', $this->_customdata['courseid']); $mform->setType('courseid', PARAM_INT); $this->add_action_buttons(); - $formdata = array(); + $formdata = []; foreach ($targethours as $s => $d) { $formdata['activity_'. $d->activityid] = $d->hours; $this->set_data($formdata); diff --git a/classes/tables/summary.php b/classes/tables/summary.php index 06b3fe9..627afc7 100644 --- a/classes/tables/summary.php +++ b/classes/tables/summary.php @@ -88,7 +88,7 @@ public function __construct($courseid) { $this->students = get_role_users(5, $this->coursecontext); $this->targethours = report_api::get_targethours(array_keys($this->students)); - $headings = array(); + $headings = []; $headings[] = get_string('tableheaderstudent', 'report_apprenticeoffjob'); foreach ($this->activities as $a) { $headings[] = $a->activityname; @@ -114,7 +114,7 @@ private function assemble() { [$actualhours, $totalactualhours] = \local_apprenticeoffjob\api::get_actual_hours($student->id); $rag = ''; $row = new html_table_row(); - $cells = array(); + $cells = []; // Link to individual user log. $params = ['id' => $student->id, 'course' => $this->courseid]; @@ -161,7 +161,7 @@ private function assemble() { new moodle_url('/report/apprenticeoffjob/edit.php', $params), get_string('reportedithours', 'report_apprenticeoffjob'), [ - 'class' => 'btn btn-secondary' + 'class' => 'btn btn-secondary', ] ); $cells[] = new html_table_cell($editbutton); diff --git a/db/access.php b/db/access.php index ebaf69a..a3cef7d 100644 --- a/db/access.php +++ b/db/access.php @@ -24,15 +24,15 @@ defined('MOODLE_INTERNAL') || die(); -$capabilities = array( - 'report/apprenticeoffjob:view' => array( +$capabilities = [ + 'report/apprenticeoffjob:view' => [ 'riskbitmask' => RISK_PERSONAL, 'captype' => 'read', 'contextlevel' => CONTEXT_COURSE, - 'archetypes' => array( + 'archetypes' => [ 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) - ), -); + 'manager' => CAP_ALLOW, + ], + ], +]; diff --git a/edit.php b/edit.php index 132e345..7c29925 100644 --- a/edit.php +++ b/edit.php @@ -27,7 +27,7 @@ $studentid = required_param('studentid', PARAM_INT); $courseid = required_param('courseid', PARAM_INT); -$PAGE->set_url('/report/apprenticeoffjob/edit.php', array('studentid' => $studentid, 'courseid' => $courseid)); +$PAGE->set_url('/report/apprenticeoffjob/edit.php', ['studentid' => $studentid, 'courseid' => $courseid]); $PAGE->set_pagelayout('report'); require_login($courseid); @@ -41,16 +41,17 @@ -$fileoptions = array('maxbytes' => 41943040, 'maxfiles' => 1); +$fileoptions = ['maxbytes' => 41943040, 'maxfiles' => 1]; $data = new stdClass(); $data = file_prepare_standard_filemanager($data, 'apprenticeoffjob', $fileoptions, context_user::instance($studentid), 'report_apprenticeoffjob', 'apprenticeoffjob', 0); // 0 is the item id. -$hoursform = new \report_apprenticeoffjob\forms\offjobhours(null, array( - 'studentid' => $studentid, - 'courseid' => $courseid, - 'fileoptions' => $fileoptions)); +$hoursform = new \report_apprenticeoffjob\forms\offjobhours(null, [ + 'studentid' => $studentid, + 'courseid' => $courseid, + 'fileoptions' => $fileoptions, + ]); if ($hoursform->is_cancelled()) { redirect($CFG->wwwroot . '/report/apprenticeoffjob/index.php?id=' . $courseid); } else if ($formdata = $hoursform->get_data()) { @@ -60,15 +61,16 @@ // Trigger a log viewed event. $coursecontext = context_course::instance($COURSE->id); - $event = \report_apprenticeoffjob\event\hours_edited::create(array( + $event = \report_apprenticeoffjob\event\hours_edited::create([ 'context' => $coursecontext, 'userid' => $USER->id, - 'relateduserid' => $studentid - )); + 'relateduserid' => $studentid, + ] + ); $event->trigger(); redirect(new moodle_url('/report/apprenticeoffjob/index.php', [ - 'courseid' => $courseid + 'courseid' => $courseid, ]), get_string('hourssaved', 'report_apprenticeoffjob'), 15); } diff --git a/index.php b/index.php index b867591..e61aa66 100644 --- a/index.php +++ b/index.php @@ -28,9 +28,9 @@ $courseid = optional_param('courseid', '', PARAM_INT); $id = ($id ? $id : $courseid); -$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $id], '*', MUST_EXIST); -$PAGE->set_url('/report/apprenticeoffjob/index.php', array('id' => $id)); +$PAGE->set_url('/report/apprenticeoffjob/index.php', ['id' => $id]); $PAGE->set_pagelayout('report'); require_login($course); @@ -44,10 +44,10 @@ $PAGE->set_heading(get_string('pluginname', 'report_apprenticeoffjob')); // Trigger a log viewed event. -$event = \report_apprenticeoffjob\event\report_viewed::create(array( +$event = \report_apprenticeoffjob\event\report_viewed::create([ 'context' => $coursecontext, - 'userid' => $USER->id - )); + 'userid' => $USER->id, + ]); $event->trigger(); // Displaying the page. diff --git a/lib.php b/lib.php index 3f2160c..593409c 100644 --- a/lib.php +++ b/lib.php @@ -33,7 +33,7 @@ */ function report_apprenticeoffjob_extend_navigation_course($navigation, $course, $context) { if (has_capability('report/apprenticeoffjob:view', $context)) { - $url = new moodle_url('/report/apprenticeoffjob/index.php', array('id' => $course->id)); + $url = new moodle_url('/report/apprenticeoffjob/index.php', ['id' => $course->id]); $navigation->add( get_string('pluginname', 'report_apprenticeoffjob'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', '')); @@ -52,7 +52,7 @@ function report_apprenticeoffjob_extend_navigation_course($navigation, $course, * @param array $options Array of options. * @return void|false */ -function report_apprenticeoffjob_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) { +function report_apprenticeoffjob_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = []) { if ($context->contextlevel != CONTEXT_USER) { send_file_not_found(); diff --git a/version.php b/version.php index b3401e8..fe97b14 100644 --- a/version.php +++ b/version.php @@ -25,10 +25,9 @@ defined('MOODLE_INTERNAL') || die(); - $plugin->version = 2021041400; $plugin->requires = 2018120304; $plugin->component = 'report_apprenticeoffjob'; -$plugin->dependencies = array( - 'local_apprenticeoffjob' => 2021041400, // The Foo activity must be present (any version). -); +$plugin->dependencies = [ + 'local_apprenticeoffjob' => 2021041400, +];