Skip to content

Commit

Permalink
Coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
sharpchi committed Nov 17, 2023
1 parent 3c4671e commit 954918f
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 37 deletions.
2 changes: 1 addition & 1 deletion classes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 4 additions & 3 deletions classes/event/hours_edited.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]
);
}

}
2 changes: 1 addition & 1 deletion classes/event/report_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

}
2 changes: 1 addition & 1 deletion classes/forms/offjobhours.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions classes/tables/summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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];
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
],
];
22 changes: 12 additions & 10 deletions edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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()) {
Expand All @@ -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);
}

Expand Down
10 changes: 5 additions & 5 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', ''));
Expand All @@ -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();
Expand Down
7 changes: 3 additions & 4 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];

0 comments on commit 954918f

Please sign in to comment.