diff --git a/.github/workflows/moodle-ci.yml b/.github/workflows/moodle-ci.yml index e71081e..ff12472 100644 --- a/.github/workflows/moodle-ci.yml +++ b/.github/workflows/moodle-ci.yml @@ -15,6 +15,7 @@ jobs: ports: - 5432:5432 options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3 + mariadb: image: mariadb:10 env: @@ -22,7 +23,6 @@ jobs: MYSQL_ALLOW_EMPTY_PASSWORD: "true" MYSQL_CHARACTER_SET_SERVER: "utf8mb4" MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci" - ports: - 3306:3306 options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3 @@ -31,22 +31,25 @@ jobs: fail-fast: false matrix: include: - - php: '7.4' - moodle-branch: 'MOODLE_311_STABLE' + - php: '8.2' + moodle-branch: 'master' + database: 'mariadb' + - php: '8.2' + moodle-branch: 'master' database: 'pgsql' - - php: '8.0' - moodle-branch: 'MOODLE_311_STABLE' + - php: '8.1' + moodle-branch: 'MOODLE_403_STABLE' database: 'mariadb' - php: '8.0' moodle-branch: 'MOODLE_402_STABLE' database: 'pgsql' - - php: '8.1' - moodle-branch: 'master' + - php: '8.0' + moodle-branch: 'MOODLE_401_STABLE' database: 'mariadb' steps: - name: Check out repository code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: plugin @@ -56,67 +59,72 @@ jobs: php-version: ${{ matrix.php }} extensions: ${{ matrix.extensions }} ini-values: max_input_vars=5000 - # none to use phpdbg fallback. Specify pcov (Moodle 3.10 and up) or xdebug to use them instead. + # If you are not using code coverage, keep "none". Otherwise, use "pcov" (Moodle 3.10 and up) or "xdebug". + # If you try to use code coverage with "none", it will fallback to phpdbg (which has known problems). coverage: none - name: Initialise moodle-plugin-ci run: | - composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3 + composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4 echo $(cd ci/bin; pwd) >> $GITHUB_PATH echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH sudo locale-gen en_AU.UTF-8 echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV + - name: Install moodle-plugin-ci - run: | - moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1 + run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1 env: DB: ${{ matrix.database }} MOODLE_BRANCH: ${{ matrix.moodle-branch }} + # Uncomment this to run Behat tests using the Moodle App. + # MOODLE_APP: 'true' - name: PHP Lint - if: ${{ always() }} + if: ${{ !cancelled() }} run: moodle-plugin-ci phplint - name: PHP Copy/Paste Detector continue-on-error: true # This step will show errors but will not fail - if: ${{ always() }} + if: ${{ !cancelled() }} run: moodle-plugin-ci phpcpd - name: PHP Mess Detector continue-on-error: true # This step will show errors but will not fail - if: ${{ always() }} + if: ${{ !cancelled() }} run: moodle-plugin-ci phpmd - name: Moodle Code Checker - if: ${{ always() }} - run: moodle-plugin-ci codechecker --max-warnings 0 + if: ${{ !cancelled() }} + run: moodle-plugin-ci phpcs --max-warnings 0 - name: Moodle PHPDoc Checker - if: ${{ always() }} - run: moodle-plugin-ci phpdoc + if: ${{ !cancelled() }} + run: moodle-plugin-ci phpdoc --max-warnings 0 - name: Validating - if: ${{ always() }} + if: ${{ !cancelled() }} run: moodle-plugin-ci validate - name: Check upgrade savepoints - if: ${{ always() }} + if: ${{ !cancelled() }} run: moodle-plugin-ci savepoints - name: Mustache Lint - if: ${{ always() }} + if: ${{ !cancelled() }} run: moodle-plugin-ci mustache - name: Grunt - # Only test grunt against branches other than MOODLE_311_STABLE - # as it will mark files grunted with latest version of npm and grunt as stale. - if: ${{ matrix.moodle-branch != 'MOODLE_311_STABLE' }} + if: ${{ !cancelled() }} run: moodle-plugin-ci grunt --max-lint-warnings 0 - name: PHPUnit tests - if: ${{ always() }} + if: ${{ !cancelled() }} run: moodle-plugin-ci phpunit --fail-on-warning - name: Behat features - if: ${{ always() }} + if: ${{ !cancelled() }} run: moodle-plugin-ci behat --profile chrome + + - name: Mark cancelled jobs as failed. + if: ${{ cancelled() }} + run: exit 1 diff --git a/classes/event/myfeedbackreport_addfeedback.php b/classes/event/myfeedbackreport_addfeedback.php index e075f7e..03f4be7 100644 --- a/classes/event/myfeedbackreport_addfeedback.php +++ b/classes/event/myfeedbackreport_addfeedback.php @@ -67,7 +67,7 @@ public function get_description() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/report/myfeedback/index.php', array('user' => $this->relateduserid)); + return new \moodle_url('/report/myfeedback/index.php', ['user' => $this->relateduserid]); } /** diff --git a/classes/event/myfeedbackreport_addnotes.php b/classes/event/myfeedbackreport_addnotes.php index 4efce41..beab257 100644 --- a/classes/event/myfeedbackreport_addnotes.php +++ b/classes/event/myfeedbackreport_addnotes.php @@ -67,7 +67,7 @@ public function get_description() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/report/myfeedback/index.php', array('user' => $this->relateduserid)); + return new \moodle_url('/report/myfeedback/index.php', ['user' => $this->relateduserid]); } /** diff --git a/classes/event/myfeedbackreport_download.php b/classes/event/myfeedbackreport_download.php index 30bc88c..c40db11 100644 --- a/classes/event/myfeedbackreport_download.php +++ b/classes/event/myfeedbackreport_download.php @@ -67,7 +67,7 @@ public function get_description() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/report/myfeedback/index.php', array('user' => $this->relateduserid)); + return new \moodle_url('/report/myfeedback/index.php', ['user' => $this->relateduserid]); } /** diff --git a/classes/event/myfeedbackreport_downloaddeptadmin.php b/classes/event/myfeedbackreport_downloaddeptadmin.php index 2485352..15aac0f 100644 --- a/classes/event/myfeedbackreport_downloaddeptadmin.php +++ b/classes/event/myfeedbackreport_downloaddeptadmin.php @@ -67,7 +67,7 @@ public function get_description() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/report/myfeedback/index.php', array('user' => $this->relateduserid)); + return new \moodle_url('/report/myfeedback/index.php', ['user' => $this->relateduserid]); } /** diff --git a/classes/event/myfeedbackreport_downloadmtutor.php b/classes/event/myfeedbackreport_downloadmtutor.php index 30026ac..f17668e 100644 --- a/classes/event/myfeedbackreport_downloadmtutor.php +++ b/classes/event/myfeedbackreport_downloadmtutor.php @@ -67,7 +67,7 @@ public function get_description() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/report/myfeedback/index.php', array('user' => $this->relateduserid)); + return new \moodle_url('/report/myfeedback/index.php', ['user' => $this->relateduserid]); } /** diff --git a/classes/event/myfeedbackreport_downloadptutor.php b/classes/event/myfeedbackreport_downloadptutor.php index dc0e4ae..e0070b2 100644 --- a/classes/event/myfeedbackreport_downloadptutor.php +++ b/classes/event/myfeedbackreport_downloadptutor.php @@ -67,7 +67,7 @@ public function get_description() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/report/myfeedback/index.php', array('user' => $this->relateduserid)); + return new \moodle_url('/report/myfeedback/index.php', ['user' => $this->relateduserid]); } /** diff --git a/classes/event/myfeedbackreport_updatefeedback.php b/classes/event/myfeedbackreport_updatefeedback.php index 24653df..29542f6 100644 --- a/classes/event/myfeedbackreport_updatefeedback.php +++ b/classes/event/myfeedbackreport_updatefeedback.php @@ -67,7 +67,7 @@ public function get_description() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/report/myfeedback/index.php', array('user' => $this->relateduserid)); + return new \moodle_url('/report/myfeedback/index.php', ['user' => $this->relateduserid]); } /** diff --git a/classes/event/myfeedbackreport_updatenotes.php b/classes/event/myfeedbackreport_updatenotes.php index 8b789d5..aff5828 100644 --- a/classes/event/myfeedbackreport_updatenotes.php +++ b/classes/event/myfeedbackreport_updatenotes.php @@ -67,7 +67,7 @@ public function get_description() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/report/myfeedback/index.php', array('user' => $this->relateduserid)); + return new \moodle_url('/report/myfeedback/index.php', ['user' => $this->relateduserid]); } /** diff --git a/classes/event/myfeedbackreport_viewed.php b/classes/event/myfeedbackreport_viewed.php index cb1a8a0..0c94d7e 100644 --- a/classes/event/myfeedbackreport_viewed.php +++ b/classes/event/myfeedbackreport_viewed.php @@ -67,7 +67,7 @@ public function get_description() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/report/myfeedback/index.php', array('user' => $this->relateduserid)); + return new \moodle_url('/report/myfeedback/index.php', ['user' => $this->relateduserid]); } /** diff --git a/classes/event/myfeedbackreport_viewed_deptdash.php b/classes/event/myfeedbackreport_viewed_deptdash.php index 7eaa220..394327c 100644 --- a/classes/event/myfeedbackreport_viewed_deptdash.php +++ b/classes/event/myfeedbackreport_viewed_deptdash.php @@ -67,7 +67,7 @@ public function get_description() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/report/myfeedback/index.php', array('user' => $this->relateduserid)); + return new \moodle_url('/report/myfeedback/index.php', ['user' => $this->relateduserid]); } /** diff --git a/classes/event/myfeedbackreport_viewed_mtutordash.php b/classes/event/myfeedbackreport_viewed_mtutordash.php index a950111..33b124e 100644 --- a/classes/event/myfeedbackreport_viewed_mtutordash.php +++ b/classes/event/myfeedbackreport_viewed_mtutordash.php @@ -67,7 +67,7 @@ public function get_description() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/report/myfeedback/index.php', array('user' => $this->relateduserid)); + return new \moodle_url('/report/myfeedback/index.php', ['user' => $this->relateduserid]); } /** diff --git a/classes/event/myfeedbackreport_viewed_mystudents.php b/classes/event/myfeedbackreport_viewed_mystudents.php index 1835c2a..033ea92 100644 --- a/classes/event/myfeedbackreport_viewed_mystudents.php +++ b/classes/event/myfeedbackreport_viewed_mystudents.php @@ -67,7 +67,7 @@ public function get_description() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/report/myfeedback/index.php', array('user' => $this->relateduserid)); + return new \moodle_url('/report/myfeedback/index.php', ['user' => $this->relateduserid]); } /** diff --git a/classes/event/myfeedbackreport_viewed_ptutordash.php b/classes/event/myfeedbackreport_viewed_ptutordash.php index efd6c77..5a8e262 100644 --- a/classes/event/myfeedbackreport_viewed_ptutordash.php +++ b/classes/event/myfeedbackreport_viewed_ptutordash.php @@ -67,7 +67,7 @@ public function get_description() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/report/myfeedback/index.php', array('user' => $this->relateduserid)); + return new \moodle_url('/report/myfeedback/index.php', ['user' => $this->relateduserid]); } /** diff --git a/classes/event/myfeedbackreport_viewed_usagedash.php b/classes/event/myfeedbackreport_viewed_usagedash.php index 84a03dc..b4846a1 100644 --- a/classes/event/myfeedbackreport_viewed_usagedash.php +++ b/classes/event/myfeedbackreport_viewed_usagedash.php @@ -71,7 +71,7 @@ public function get_description() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/report/myfeedback/index.php', array('user' => $this->relateduserid)); + return new \moodle_url('/report/myfeedback/index.php', ['user' => $this->relateduserid]); } /** diff --git a/classes/local/report.php b/classes/local/report.php index eca4bd4..fc74c96 100644 --- a/classes/local/report.php +++ b/classes/local/report.php @@ -164,8 +164,8 @@ public function mod_is_available($modname) { // Is the module installed? if (array_key_exists($modname, $installedplugins)) { // Is the module visible? - if ($currentdb->get_field('modules', 'visible', array('name' => $modname - ))) { + if ($currentdb->get_field('modules', 'visible', ['name' => $modname, + ])) { return true; } else { return false; @@ -188,10 +188,10 @@ public function mod_is_available($modname) { public function has_pdf_feedback_file($iteminstance, $userid, $gradeid) { global $currentdb; // Is there any online pdf annotation feedback or any feedback file? - if ($currentdb->get_record('assignfeedback_editpdf_annot', array('gradeid' => $gradeid), 'id', IGNORE_MULTIPLE)) { + if ($currentdb->get_record('assignfeedback_editpdf_annot', ['gradeid' => $gradeid], 'id', IGNORE_MULTIPLE)) { return true; } - if ($currentdb->get_record('assignfeedback_editpdf_cmnt', array('gradeid' => $gradeid), 'id', IGNORE_MULTIPLE)) { + if ($currentdb->get_record('assignfeedback_editpdf_cmnt', ['gradeid' => $gradeid], 'id', IGNORE_MULTIPLE)) { return true; } @@ -199,7 +199,7 @@ public function has_pdf_feedback_file($iteminstance, $userid, $gradeid) { FROM {assign_grades} ag JOIN {assignfeedback_file} af on ag.id=af.grade AND ag.id=? AND ag.userid=? AND af.assignment=?"; - $params = array($gradeid, $userid, $iteminstance); + $params = [$gradeid, $userid, $iteminstance]; $feedbackfile = $currentdb->get_record_sql($sql, $params); if ($feedbackfile) { if ($feedbackfile->numfiles != 0) { @@ -223,7 +223,7 @@ public function has_workshop_feedback_file($userid, $subid) { FROM {workshop_assessments} wa JOIN {workshop_submissions} ws ON wa.submissionid=ws.id AND ws.authorid=? AND ws.id=? and ws.example = 0"; - $params = array($userid, $subid); + $params = [$userid, $subid]; $feedbackfile = $currentdb->get_record_sql($sql, $params); if ($feedbackfile) { if ($feedbackfile->feedbackauthorattachment != 0) { @@ -254,7 +254,7 @@ public function has_workshop_feedback($userid, $subid, $assignid, $cid, $itemnum JOIN {workshop_assessments} wa ON wa.submissionid=ws.id AND ws.authorid=? AND ws.workshopid=? AND ws.example=0 AND wa.submissionid=? LEFT JOIN {workshop_grades} wg ON wg.assessmentid=wa.id AND wa.submissionid=?"; - $arr = array($cid, $userid, $assignid, $subid, $subid); + $arr = [$cid, $userid, $assignid, $subid, $subid]; // TODO: fix this! If won't work here, use: if ($rs->valid()) {}. if ($assess = $currentdb->get_recordset_sql($peer, $arr)) { if ($itemnumber == 1) { @@ -276,7 +276,7 @@ public function has_workshop_feedback($userid, $subid, $assignid, $cid, $itemnum JOIN {workshop_submissions} ws ON ws.workshopid=w.id AND w.course=? AND w.useexamples=0 JOIN {workshop_assessments} wa ON wa.submissionid=ws.id AND ws.authorid=? AND ws.workshopid=? AND ws.example=0 AND wa.submissionid=?"; - $par = array($cid, $userid, $assignid, $subid); + $par = [$cid, $userid, $assignid, $subid]; $self = $pfeed = false; if ($asse = $currentdb->get_records_sql($auth, $par)) { foreach ($asse as $cub) { @@ -318,7 +318,7 @@ public function has_workshop_feedback($userid, $subid, $assignid, $cid, $itemnum JOIN {workshop_submissions} ws ON wa.submissionid=ws.id AND ws.workshopid=? AND ws.example=0 AND ws.authorid = ? ORDER BY wa.reviewerid"; - $paramsc = array($subid, $assignid, $userid); + $paramsc = [$subid, $assignid, $userid]; $c = 0; if ($commentscheck = $currentdb->get_records_sql($sqlc, $paramsc)) { foreach ($commentscheck as $com) { @@ -345,7 +345,7 @@ public function has_workshop_feedback($userid, $subid, $assignid, $cid, $itemnum JOIN {workshop_submissions} ws ON wa.submissionid=ws.id AND ws.workshopid=? AND ws.example=0 AND ws.authorid = ? ORDER BY wa.reviewerid"; - $paramsa = array($subid, $assignid, $userid); + $paramsa = [$subid, $assignid, $userid]; $a = 0; if ($accumulativecheck = $currentdb->get_records_sql($sqla, $paramsa)) { foreach ($accumulativecheck as $acc) { @@ -374,7 +374,7 @@ public function has_workshop_feedback($userid, $subid, $assignid, $cid, $itemnum JOIN {workshop_submissions} ws ON wa.submissionid=ws.id AND ws.workshopid=? AND ws.example=0 AND ws.authorid = ? ORDER BY wa.reviewerid"; - $params = array($assignid, $subid, $assignid, $userid); + $params = [$assignid, $subid, $assignid, $userid]; $r = 0; if ($rubriccheck = $currentdb->get_records_sql($sql, $params)) { foreach ($rubriccheck as $rub) { @@ -404,7 +404,7 @@ public function has_workshop_feedback($userid, $subid, $assignid, $cid, $itemnum JOIN {workshop_submissions} ws ON wa.submissionid=ws.id AND ws.workshopid=? AND ws.example=0 AND ws.authorid = ? ORDER BY wa.reviewerid"; - $paramsn = array($subid, $assignid, $userid); + $paramsn = [$subid, $assignid, $userid]; $n = 0; if ($numerrorcheck = $currentdb->get_records_sql($sqln, $paramsn)) { foreach ($numerrorcheck as $num) { @@ -439,7 +439,7 @@ public function check_assign_extension($userid, $assignment) { $sql = "SELECT max(extensionduedate) as extensionduedate FROM {assign_user_flags} WHERE userid=? AND assignment=?"; - $params = array($userid, $assignment); + $params = [$userid, $assignment]; $extension = $currentdb->get_record_sql($sql, $params); if ($extension) { return $extension->extensionduedate; @@ -459,7 +459,7 @@ public function check_quiz_extension($assignid, $userid) { $sql = "SELECT max(timeclose) as timeclose FROM {quiz_overrides} WHERE quiz=? AND userid=?"; - $params = array($assignid, $userid); + $params = [$assignid, $userid]; $override = $currentdb->get_record_sql($sql, $params); if ($override) { return $override->timeclose; @@ -481,7 +481,7 @@ public function check_quiz_group_extension($assignid, $userid) { FROM {quiz_overrides} qo JOIN {groups_members} gm ON qo.groupid=gm.groupid AND qo.quiz=? AND gm.userid=?"; - $params = array($assignid, $userid); + $params = [$assignid, $userid]; $override = $currentdb->get_record_sql($sql, $params); if ($override) { return $override->timeclose; @@ -505,7 +505,7 @@ public function get_quiz_submissiondate($assignid, $userid, $grade, $availablegr $sql = "SELECT id, timefinish, sumgrades FROM {quiz_attempts} WHERE quiz=? AND userid=?"; - $params = array($assignid, $userid); + $params = [$assignid, $userid]; $attempts = $currentdb->get_records_sql($sql, $params); if ($attempts) { foreach ($attempts as $attempt) { @@ -538,7 +538,7 @@ public function get_quiz_attempts_link($quizid, $userid, $quizurlid, $archivedom $sqlcount = "SELECT count(attempt) as attempts, max(id) as id FROM {quiz_attempts} qa WHERE quiz=? and userid=?"; - $params = array($quizid, $userid); + $params = [$quizid, $userid]; $attemptcount = $currentdb->get_records_sql($sqlcount, $params); $out = []; $url = ''; @@ -552,7 +552,7 @@ public function get_quiz_attempts_link($quizid, $userid, $quizurlid, $archivedom if ($archive) { // If an archive year then change the domain. $url = $archivedomainyear . "/mod/quiz/review.php?attempt=" . $attempt->id; - $attr = array("target" => "_blank"); + $attr = ["target" => "_blank"]; $newicon = $newwindowicon; } @@ -591,7 +591,7 @@ public function get_group_assign_submission_date($userid, $assignid): string { FROM {assign_submission} su JOIN {groups_members} gm ON su.groupid = gm.groupid AND gm.userid = ? AND su.assignment=?"; - $params = array($userid, $assignid); + $params = [$userid, $assignid]; $files = $currentdb->get_record_sql($sql, $params); if (isset($files->subdate)) { return $files->subdate; @@ -611,7 +611,7 @@ public function get_workshop_comments($userid): string { $sql = "SELECT wg.peercomment FROM {workshop_grades} wg LEFT JOIN {workshop_submissions} su ON wg.assessmentid = su.id and su.authorid=?"; - $params = array($userid); + $params = [$userid]; $comments = $currentdb->get_recordset_sql($sql, $params, $limitfrom = 0, $limitnum = 0); $out = []; foreach ($comments as $comment) { @@ -649,16 +649,16 @@ public function check_viewed_gradereport($contextid, $assignmentid, $userid, $co AND gi.courseid=? AND gi.itemname=? JOIN {course_modules} cm ON gi.iteminstance=cm.instance AND cm.course=? AND cm.id=?"; - $paramstwo = array($userid, $courseid, $itemname, $courseid, $assignmentid); + $paramstwo = [$userid, $courseid, $itemname, $courseid, $assignmentid]; $gradeadded = $currentdb->get_record_sql($sqltwo, $paramstwo); if ($gradeadded) { - $params = array($contextid, $assignmentid, $userid, $courseid, $gradeadded->timemodified); + $params = [$contextid, $assignmentid, $userid, $courseid, $gradeadded->timemodified]; $viewreport = $currentdb->get_record_sql($sql, $params); if ($viewreport && $viewreport->timecreated > $gradeadded->timemodified) { return date('d-m-Y H:i', $viewreport->timecreated); } - $paramsone = array('gradereport_user', 'viewed', $userid, $courseid, $gradeadded->timemodified); + $paramsone = ['gradereport_user', 'viewed', $userid, $courseid, $gradeadded->timemodified]; $userreport = $currentdb->get_record_sql($sqlone, $paramsone); if ($userreport && $userreport->timecreated > $gradeadded->timemodified) { return date('d-m-Y H:i', $userreport->timecreated); @@ -685,8 +685,8 @@ public function check_viewed_manualitem($userid, $courseid, $gradeitemid) { FROM {grade_grades} g JOIN {grade_items} gi ON g.itemid=gi.id AND g.userid=? AND gi.courseid=? AND gi.id=?"; - $paramsone = array('gradereport_user', 'viewed', $userid, $courseid); - $paramstwo = array($userid, $courseid, $gradeitemid); + $paramsone = ['gradereport_user', 'viewed', $userid, $courseid]; + $paramstwo = [$userid, $courseid, $gradeitemid]; $userreport = $currentdb->get_record_sql($sqlone, $paramsone); $gradeadded = $currentdb->get_record_sql($sqltwo, $paramstwo); if ($userreport) { @@ -714,7 +714,7 @@ public function overallfeedback($quizid, $grade) { FROM {quiz_feedback} WHERE quizid=? and mingrade<=? and maxgrade>=? limit 1"; - $params = array($quizid, $grade, $grade); + $params = [$quizid, $grade, $grade]; $feedback = $currentdb->get_record_sql($sql, $params); return $feedback->feedbacktext; } @@ -745,7 +745,7 @@ public function rubrictext($userid, $courseid, $iteminstance, $itemmodule) { JOIN {grade_grades} gg ON gi.id=gg.itemid AND gi.itemmodule=? AND gi.courseid=? AND gg.userid=? AND gi.iteminstance=? AND status=?"; - $params = array($userid, $itemmodule, $courseid, $userid, $iteminstance, 1); + $params = [$userid, $itemmodule, $courseid, $userid, $iteminstance, 1]; $rubrics = $currentdb->get_recordset_sql($sql, $params); $out = ''; if ($rubrics) { @@ -783,7 +783,7 @@ public function marking_guide_text($userid, $courseid, $iteminstance, $itemmodul JOIN {grade_grades} gg ON gi.id=gg.itemid AND gi.itemmodule=? AND gi.courseid=? AND gg.userid=? AND gi.iteminstance=?"; - $params = array($userid, $itemmodule, $courseid, $userid, $iteminstance); + $params = [$userid, $itemmodule, $courseid, $userid, $iteminstance]; $guides = $currentdb->get_recordset_sql($sql, $params); $out = ''; if ($guides) { @@ -813,7 +813,7 @@ public function get_grade_scale($itemid, $userid, $courseid, $grade) { JOIN {grade_items} gi ON gg.itemid=gi.id AND gi.id=? AND gg.userid=? AND gi.courseid=? AND gi.gradetype = 2 JOIN {scale} s ON gi.scaleid=s.id limit 1"; - $params = array($itemid, $userid, $courseid); + $params = [$itemid, $userid, $courseid]; $scales = $currentdb->get_record_sql($sql, $params); $num = 0; if ($scales) { @@ -840,7 +840,7 @@ public function get_min_grade_scale($itemid, $userid, $courseid) { JOIN {grade_items} gi ON gg.itemid=gi.id AND gi.id=? AND gg.userid=? AND gi.courseid=? AND gi.gradetype = 2 JOIN {scale} s ON gi.scaleid=s.id limit 1"; - $params = array($itemid, $userid, $courseid); + $params = [$itemid, $userid, $courseid]; $scales = $currentdb->get_record_sql($sql, $params); if ($scales) { $scale = explode(',', $scales->scale); @@ -866,7 +866,7 @@ public function get_available_grade_scale($itemid, $userid, $courseid) { JOIN {grade_items} gi ON gg.itemid=gi.id AND gi.id=? AND gg.userid=? AND gi.courseid=? AND gi.gradetype = 2 JOIN {scale} s ON gi.scaleid=s.id limit 1"; - $params = array($itemid, $userid, $courseid); + $params = [$itemid, $userid, $courseid]; $scales = $currentdb->get_record_sql($sql, $params); if ($scales) { $scale = explode(',', $scales->scale); @@ -892,7 +892,7 @@ public function get_all_grade_scale($itemid, $userid, $courseid) { JOIN {grade_items} gi ON gg.itemid=gi.id AND gi.id=? AND gg.userid=? AND gi.courseid=? AND gi.gradetype = 2 JOIN {scale} s ON gi.scaleid=s.id"; - $params = array($itemid, $userid, $courseid); + $params = [$itemid, $userid, $courseid]; $scales = $currentdb->get_records_sql($sql, $params); $out = ''; if ($scales) { @@ -919,7 +919,7 @@ public function get_grade_letter($courseid, $grade) { JOIN {context} con ON l.contextid = con.id AND con.contextlevel=50 AND con.instanceid=? AND l.lowerboundary <=? ORDER BY l.lowerboundary DESC limit 1"; - $params = array($courseid, $grade); + $params = [$courseid, $grade]; $letters = $currentdb->get_record_sql($sql, $params); if ($letters) { $letter = $letters->letter; @@ -948,7 +948,7 @@ public function get_min_grade_letter($courseid): string { FROM {grade_letters} l JOIN {context} con ON l.contextid = con.id AND con.contextlevel=50 AND con.instanceid=? ORDER BY l.lowerboundary ASC limit 1"; - $params = array($courseid); + $params = [$courseid]; $letters = $currentdb->get_record_sql($sql, $params); if ($letters) { $letter = $letters->letter; @@ -972,7 +972,7 @@ public function get_available_grade_letter($courseid) { FROM {grade_letters} l JOIN {context} con ON l.contextid = con.id AND con.contextlevel=50 AND con.instanceid=? ORDER BY l.lowerboundary DESC limit 1"; - $params = array($courseid); + $params = [$courseid]; $letters = $currentdb->get_record_sql($sql, $params); if ($letters) { $letter = $letters->letter; @@ -996,7 +996,7 @@ public function get_all_grade_letters($courseid) { FROM {grade_letters} l JOIN {context} con ON l.contextid = con.id AND con.contextlevel=50 AND con.instanceid=?"; - $params = array($courseid); + $params = [$courseid]; $letters = $currentdb->get_records_sql($sql, $params); $out = ''; if ($letters) { @@ -1046,7 +1046,7 @@ public function get_fraction($grade, $cid, $decimals) { public function user_timezone() { global $USER, $currentdb; $sql = "SELECT timezone FROM {user} WHERE id = ?"; - $params = array($USER->id); + $params = [$USER->id]; $timezone = $currentdb->get_record_sql($sql, $params); return $timezone ? $timezone->timezone : 99; } @@ -1091,7 +1091,7 @@ public function bst_gmt($date) { public function get_personal_tutor_id() { global $currentdb; $sql = "SELECT roleid FROM {role_context_levels} WHERE contextlevel = ? limit 1"; - $params = array(30); + $params = [30]; $tutor = $currentdb->get_record_sql($sql, $params); return $tutor ? $tutor->roleid : 0; } @@ -1169,7 +1169,7 @@ public function search_all_categories($search, $reporttype, $hideor = false): st $sql = "SELECT id, name, parent FROM {course_categories} WHERE visible = 1 AND " . $sqllike; - $result = $currentdb->get_records_sql($sql, array('%' . $searchu . '%')); + $result = $currentdb->get_records_sql($sql, ['%' . $searchu . '%']); if ($result) { foreach ($result as $a) { if ($a->id) { @@ -1273,10 +1273,10 @@ public function search_all_courses($search, $reporttype) { FROM {course} WHERE " . $sqllikefullname . " OR " . $sqllikeshortname; - $result = $currentdb->get_records_sql($sql, array( + $result = $currentdb->get_records_sql($sql, [ '%' . $searchu . '%', - '%' . $searchu . '%' - )); + '%' . $searchu . '%', + ]); if ($result) { foreach ($result as $a) { if ($a->id) { @@ -1362,7 +1362,7 @@ public function search_all_users($search, $reporttype = "student") { if (strpos($searchu, '@')) { // If it is an email address search for the full input. $userresult = $currentdb->get_records_sql("SELECT id,firstname,lastname,email,department FROM {user} - WHERE deleted = 0 AND email = ?", array($searchu)); + WHERE deleted = 0 AND email = ?", [$searchu]); } else { // If not an email address then search on first word or last word. $namef = explode(" ", $searchu); // Make string into array if multiple words. @@ -1467,7 +1467,7 @@ public function get_all_accessible_users($ptutor, $modt, $proga, $search = null) if (strpos($searchu, '@')) { // If it is an email address search for the full input. $userresult = $currentdb->get_records_sql("SELECT id,firstname,lastname,email FROM {user} - WHERE deleted = 0 AND email = ?", array($searchu)); + WHERE deleted = 0 AND email = ?", [$searchu]); } else { // If not an email address then search on first word or last word. $namef = explode(" ", $searchu); // Make string into array if multiple words. @@ -1563,7 +1563,7 @@ public function get_all_accessible_users($ptutor, $modt, $proga, $search = null) WHERE ra.userid = ? AND ra.contextid = c.id AND c.instanceid = u.id - AND c.contextlevel = " . CONTEXT_USER, array($USER->id))) { + AND c.contextlevel = " . CONTEXT_USER, [$USER->id])) { foreach ($usercontexts as $u) { if ($u->id && ($u->firstname || $u->lastname)) { $myusers[$u->id][0] = "wwwroot . "/report/myfeedback/index.php?userid=" . $u->id @@ -1617,7 +1617,7 @@ public function get_tutees_for_prog_ptutors($uid) { WHERE ra.userid = ? AND ra.contextid = c.id AND c.instanceid = u.id - AND c.contextlevel = " . CONTEXT_USER, array($uid))) { + AND c.contextlevel = " . CONTEXT_USER, [$uid])) { foreach ($usercontexts as $u) { $myusers[$u->id]['prog'] = ''; $myusers[$u->id]['year'] = ''; @@ -1668,7 +1668,7 @@ public function get_tutees_for_prog_tutor_groups($uid, $cid, $tutgroup) { JOIN {groups_members} gm ON g.id=gm.groupid AND g.courseid = ? JOIN {user} u ON u.id=gm.userid AND userid != ? AND groupid IN ( SELECT groupid FROM {groups_members}, {groups} - WHERE userid = ? AND courseid = ?)", array($cid, $uid, $uid, $cid))) { + WHERE userid = ? AND courseid = ?)", [$cid, $uid, $uid, $cid])) { foreach ($tutorgroups as $tgroup) { $myusers[$tgroup->id]['due'] = 0; $myusers[$tgroup->id]['non'] = 0; @@ -1741,7 +1741,7 @@ public function get_my_personal_tutor($ptutorroleid, $contextid) { $sql = "SELECT userid FROM {role_assignments} WHERE roleid = ? AND contextid = ? ORDER BY timemodified DESC limit 1"; - $params = array($ptutorroleid, $contextid); + $params = [$ptutorroleid, $contextid]; $tutor = $currentdb->get_record_sql($sql, $params); return $tutor ? $tutor->userid : 0; } @@ -1756,7 +1756,7 @@ public function get_course_id_from_shortname($shortname) { global $currentdb; $sql = "SELECT max(id) as id, fullname FROM {course} WHERE shortname = ?"; - $params = array($shortname); + $params = [$shortname]; $cid = $currentdb->get_record_sql($sql, $params); return $cid ?: 0; } @@ -1770,7 +1770,7 @@ public function get_course_id_from_shortname($shortname) { public function get_all_assessments($cid) { global $currentdb; $now = time(); - $items = array('turnitintool', 'turnitintooltwo', 'workshop', 'quiz', 'assign'); + $items = ['turnitintool', 'turnitintooltwo', 'workshop', 'quiz', 'assign']; foreach ($items as $key => $item) { if (!$this->mod_is_available($item)) { unset($items[$key]); @@ -1781,7 +1781,7 @@ public function get_all_assessments($cid) { FROM {grade_items} gi WHERE (hidden != 1 AND hidden < ?) AND courseid = ? AND (itemmodule IN ($items) OR (itemtype = 'manual'))"; - $params = array($now, $cid); + $params = [$now, $cid]; $assess = $currentdb->get_records_sql($sql, $params); return $assess; @@ -1975,7 +1975,7 @@ public function get_assessment_link_from_type($type, $cid, $gid = null) { JOIN {grade_items} gi ON gi.iteminstance=cm.instance JOIN {modules} m ON cm.module = m.id AND gi.itemmodule = m.name AND cm.course = ? AND gi.id = ? AND gi.itemmodule = ?"; - $params = array($cid, $gid, $type); + $params = [$cid, $gid, $type]; $link = $currentdb->get_record_sql($sql, $params); switch ($type) { case 'quiz': @@ -2153,7 +2153,7 @@ public function get_user_analytics($users, $cid, $display = null, $style = null, foreach ($users as $usid => $usr) { $scol1 = $scol2 = $scol3 = ''; if (!isset($usr['name']) || !$usr['name']) { - $getname = $currentdb->get_record('user', array('id' => $usid), $list = 'firstname,lastname,email'); + $getname = $currentdb->get_record('user', ['id' => $usid], $list = 'firstname,lastname,email'); if ($getname) { $uname = "wwwroot . "/report/myfeedback/index.php?userid=" . $usid . $sesskeyqs @@ -2258,7 +2258,7 @@ public function get_subcategories($parentcatid) { return $currentdb->get_records_sql("SELECT id, visible FROM {course_categories} - WHERE parent = ? ORDER BY visible desc, sortorder", array($parentcatid)); + WHERE parent = ? ORDER BY visible desc, sortorder", [$parentcatid]); } @@ -2330,7 +2330,7 @@ public function get_unique_category_users($catid, $capability = 'report/myfeedba if ($catid > 0) { // If this category isn't the root, get its contextid. $contextid = $this->get_categorycontextid($catid); - $params = array("%/".$contextid, "%/".$contextid."/%"); + $params = ["%/".$contextid, "%/".$contextid."/%"]; $sql .= ' AND (con.path LIKE ? OR con.path LIKE ? )'; } $sql .= ' AND (roleid = ?'; @@ -2380,7 +2380,7 @@ public function get_unique_course_users($catid, $capability = 'report/myfeedback return null; } // Get courses in a category and iterate though each enrolled user on that course. - $courseparams = array("%/".$catid, "%/".$catid."/%"); + $courseparams = ["%/".$catid, "%/".$catid."/%"]; $coursesql = "SELECT DISTINCT c.id FROM {course} c, {course_categories} cat @@ -2463,7 +2463,7 @@ public function get_course_name($id, $fullname = true): string { $coursename = $currentdb->get_record_sql("SELECT c.fullname, c.shortname FROM {course} c - WHERE c.id = ?", array($id)); + WHERE c.id = ?", [$id]); if ($fullname == true) { return $coursename->fullname; } else { @@ -2482,7 +2482,7 @@ public function get_category_name($id): ?string { $catname = $currentdb->get_record_sql("SELECT cat.name FROM {course_categories} cat - WHERE cat.id = ?", array($id)); + WHERE cat.id = ?", [$id]); if (!empty($catname->name)) { return $catname->name; } @@ -2503,7 +2503,7 @@ public function get_parent_category_link($categoryid, $reporttype): string { $category = $currentdb->get_record_sql("SELECT cat.parent FROM {course_categories} cat - WHERE cat.id = ?", array($categoryid)); + WHERE cat.id = ?", [$categoryid]); if (!empty($category->parent) && $category->parent > 0) { return " wwwroot ."/report/myfeedback/index.php?currenttab=usage&reporttype=" . $reporttype . $sesskeyqs @@ -2527,7 +2527,7 @@ public function get_course_category_link($courseid, $reporttype): string { $course = $currentdb->get_record_sql("SELECT c.category FROM {course} c - WHERE c.id = ?", array($courseid)); + WHERE c.id = ?", [$courseid]); if (!empty($course->category) && $course->category > 0) { return " wwwroot ."/report/myfeedback/index.php?currenttab=usage&reporttype=" . $reporttype . $sesskeyqs @@ -2549,7 +2549,7 @@ public function is_active_user($id): bool { $user = $currentdb->get_record_sql("SELECT deleted, suspended FROM {user} - WHERE id = ?", array($id)); + WHERE id = ?", [$id]); if ($user->suspended == 0 && $user->deleted == 0) { return true; } @@ -2570,7 +2570,7 @@ public function get_categorycontextid($id): int { $contextid = $currentdb->get_record_sql("SELECT id FROM {context} - WHERE contextlevel = 40 AND instanceid = ?", array($id)); + WHERE contextlevel = 40 AND instanceid = ?", [$id]); return $contextid->id; } @@ -2590,7 +2590,7 @@ public function get_personal_tutees($personaltutorid) { AND u.suspended = 0 AND ra.contextid = c.id AND c.instanceid = u.id - AND c.contextlevel = " . CONTEXT_USER, array($personaltutorid)); + AND c.contextlevel = " . CONTEXT_USER, [$personaltutorid]); } @@ -2792,8 +2792,8 @@ public function get_staff_statistics_table($uids, $showptutees=false, $overview= $usagetable = ""; // Print the table headings. - $headers = array(get_string('tutortblheader_name', 'report_myfeedback')); - $headerhelptext = array(get_string('usagetblheader_name_info', 'report_myfeedback')); + $headers = [get_string('tutortblheader_name', 'report_myfeedback')]; + $headerhelptext = [get_string('usagetblheader_name_info', 'report_myfeedback')]; if ($overview == true) { $headers[] = ucfirst(get_string('staff', 'report_myfeedback')); @@ -3121,8 +3121,8 @@ public function get_student_statistics_table($uids, $reporttype, $overview=false $usagetable = "
"; // Print the table headings. - $headers = array(get_string('tutortblheader_name', 'report_myfeedback')); - $headerhelptext = array(get_string('usagetblheader_name_info', 'report_myfeedback')); + $headers = [get_string('tutortblheader_name', 'report_myfeedback')]; + $headerhelptext = [get_string('usagetblheader_name_info', 'report_myfeedback')]; if ($overview == true) { $headers[] = ucfirst(get_string('dashboard_students', 'report_myfeedback')); @@ -3638,7 +3638,7 @@ public function get_activity_min_and_max_grade($itemid, $grade): string { global $currentdb; $sql = "SELECT min(finalgrade) as min, max(finalgrade) as max FROM {grade_grades} WHERE itemid = ?"; - $params = array($itemid); + $params = [$itemid]; $activity = $currentdb->get_record_sql($sql, $params); $loc = 100; if ($activity) { @@ -3717,7 +3717,7 @@ public function get_notes($userid, $gradeitemid, $instn): string { $sql = "SELECT DISTINCT notes FROM {report_myfeedback} WHERE userid=? AND gradeitemid=? AND iteminstance=?"; - $params = array($userid, $gradeitemid, $instn); + $params = [$userid, $gradeitemid, $instn]; $usernotes = $currentdb->get_record_sql($sql, $params); $displaynotes = ''; if ($usernotes) { @@ -3740,7 +3740,7 @@ public function get_turnitin_feedback($userid, $gradeitemid, $inst): string { $sql = "SELECT DISTINCT modifierid, feedback FROM {report_myfeedback} WHERE userid=? AND gradeitemid=? AND iteminstance=?"; - $params = array($userid, $gradeitemid, $inst); + $params = [$userid, $gradeitemid, $inst]; $turnitinfeedback = $currentdb->get_record_sql($sql, $params); if ($turnitinfeedback) { return $turnitinfeedback; @@ -3756,7 +3756,7 @@ public function get_turnitin_feedback($userid, $gradeitemid, $inst): string { */ public function get_archived_dbs(): array { $dbs = get_config('report_myfeedback'); - $acyears = array('current'); + $acyears = ['current']; $archivedyears = 0; if (isset($dbs->archivedyears)) { if ($dbs->archivedyears) { @@ -3781,7 +3781,7 @@ public function get_archived_dbs(): array { */ public function get_archived_years(): array { $dbs = get_config('report_myfeedback'); - $acyears = array('current'); + $acyears = ['current']; $archivedyears = 0; if (isset($dbs->archivedyears)) { if ($dbs->archivedyears) { @@ -3846,7 +3846,7 @@ public function get_dashboard_tutees($personaltutorid = 0): array { AND c.contextlevel = " . CONTEXT_USER; if ($usercontexts = $currentdb->get_records_sql($sql, [$personaltutorid])) { foreach ($usercontexts as $u) { - $user = $currentdb->get_record('user', array('id' => $u->id, 'deleted' => 0)); + $user = $currentdb->get_record('user', ['id' => $u->id, 'deleted' => 0]); $year = null; profile_load_data($user); @@ -3855,7 +3855,7 @@ public function get_dashboard_tutees($personaltutorid = 0): array { $year = $user->profile_field_courseyear; } $myusers[$u->id][0] = "
" . - $OUTPUT->user_picture($user, array('size' => 40)) . "
user_picture($user, ['size' => 40]) . "
wwwroot . "/report/myfeedback/index.php?userid=" . $u->id . $sesskeyqs . "\">" . $u->firstname . " " . $u->lastname . "
" . @@ -3890,7 +3890,7 @@ public function get_eachcourse_dashboard_grades($userid, $courseid, $modtutor = $archive = true; } $now = time(); - $items = array('turnitintool', 'turnitintooltwo', 'workshop', 'quiz', 'assign'); + $items = ['turnitintool', 'turnitintooltwo', 'workshop', 'quiz', 'assign']; foreach ($items as $key => $item) { if (!$this->mod_is_available($item)) { unset($items[$key]); @@ -3939,7 +3939,7 @@ public function get_eachcourse_dashboard_grades($userid, $courseid, $modtutor = } $gr->close(); } - $result = array(0, 0); + $result = [0, 0]; $result[0] = count($grades); $modresult = []; foreach ($grades as $b) { @@ -3995,7 +3995,7 @@ public function get_eachcourse_dashboard_submissions($userid, $courseid, $modtut JOIN {grade_grades} gg ON gi.id=gg.itemid AND gg.userid = ? AND gi.courseid = ? AND (gg.hidden != 1 AND gg.hidden < ?) WHERE c.visible=1 AND c.showgrades = 1 "; - $params = array($now, $userid, $courseid, $now); + $params = [$now, $userid, $courseid, $now]; if ($this->mod_is_available('assign')) { $sql .= "UNION SELECT DISTINCT c.id AS cid, gi.id as tid, a.id, a.duedate as due, su.timemodified as sub, gi.itemmodule as type, su.status AS status, a.nosubmissions AS nosubmissions, cm.id AS cmid, @@ -4113,7 +4113,7 @@ public function get_eachcourse_dashboard_submissions($userid, $courseid, $modtut } } $r->close(); - $result = array(0, 0, 0, 0); + $result = [0, 0, 0, 0]; $modresult = []; foreach ($all as $b) { $modresult[$b->tid]['due'] = 0; @@ -4582,7 +4582,7 @@ public function get_dashboard_zscore($userid, $tutor = null, $coid = null, $asid */ public function get_prog_admin_dept_prog($deptprog, $frommod = null): array { $prog = []; - $tomod = array('dept' => '', 'prog' => ''); + $tomod = ['dept' => '', 'prog' => '']; foreach ($deptprog as $dp) { $catid = ($dp->category ? $dp->category : 0); if ($catid) { @@ -4656,7 +4656,7 @@ public function is_grade_overridden($itemid, $userid) { $sql = "SELECT DISTINCT id, finalgrade, overridden FROM {grade_grades} WHERE itemid=? AND userid=?"; - $params = array($itemid, $userid); + $params = [$itemid, $userid]; $overridden = $currentdb->get_record_sql($sql, $params); if ($overridden && $overridden->overridden > 0) { return $overridden->finalgrade; @@ -4675,7 +4675,7 @@ public function get_course_grade_displaytype($cid): string { $sql = "SELECT DISTINCT id, value FROM {grade_settings} WHERE courseid=? AND name='displaytype'"; - $param = array($cid); + $param = [$cid]; $displaytype = $currentdb->get_record_sql($sql, $param); return $displaytype ? $displaytype->value : ''; } diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index bca48c4..c6e04c7 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -24,7 +24,7 @@ namespace report_myfeedback\privacy; -use \core_privacy\local\metadata\collection; +use core_privacy\local\metadata\collection; use core_privacy\local\request\approved_contextlist; use core_privacy\local\request\approved_userlist; use core_privacy\local\request\contextlist; @@ -81,7 +81,7 @@ public static function get_contexts_for_userid(int $userid): contextlist { $contextlist = new \core_privacy\local\request\contextlist(); - $user = $DB->get_record('user', array('id' => $userid), 'id'); + $user = $DB->get_record('user', ['id' => $userid], 'id'); if ($usercontext = \context_user::instance($user->id, IGNORE_MISSING)) { $contextlist->add_user_context($userid); } @@ -164,7 +164,7 @@ public static function export_user_data(approved_contextlist $contextlist) { 'feedback' => $record->feedback, 'coursefullname' => format_string($record->fullname, true, ['context' => $context]), 'timemodified' => \core_privacy\local\request\transform::datetime($record->timemodified), - 'gradeitemname' => $record->gradeitemname + 'gradeitemname' => $record->gradeitemname, ]; } diff --git a/db/access.php b/db/access.php index c626f2c..39f989a 100644 --- a/db/access.php +++ b/db/access.php @@ -25,54 +25,54 @@ defined('MOODLE_INTERNAL') || die(); -$capabilities = array( - 'report/myfeedback:view' => array( +$capabilities = [ + 'report/myfeedback:view' => [ 'riskbitmask' => RISK_PERSONAL, 'captype' => 'read', 'contextlevel' => CONTEXT_SYSTEM, - 'legacy' => array( - 'manager' => CAP_ALLOW - ) - ), - 'report/myfeedback:progadmin' => array( + 'legacy' => [ + 'manager' => CAP_ALLOW, + ], + ], + 'report/myfeedback:progadmin' => [ 'riskbitmask' => RISK_PERSONAL, 'captype' => 'read', 'contextlevel' => CONTEXT_COURSE, - 'legacy' => array( - 'manager' => CAP_ALLOW - ) - ), - 'report/myfeedback:personaltutor' => array( + 'legacy' => [ + 'manager' => CAP_ALLOW, + ], + ], + 'report/myfeedback:personaltutor' => [ 'riskbitmask' => RISK_PERSONAL, 'captype' => 'read', 'contextlevel' => CONTEXT_USER, - 'legacy' => array( - 'manager' => CAP_ALLOW - ) - ), - 'report/myfeedback:modtutor' => array( + 'legacy' => [ + 'manager' => CAP_ALLOW, + ], + ], + 'report/myfeedback:modtutor' => [ 'riskbitmask' => RISK_PERSONAL, 'captype' => 'read', 'contextlevel' => CONTEXT_COURSE, - 'legacy' => array( + 'legacy' => [ 'manager' => CAP_ALLOW, - 'teacher' => CAP_ALLOW - ) - ), - 'report/myfeedback:student' => array( + 'teacher' => CAP_ALLOW, + ], + ], + 'report/myfeedback:student' => [ 'riskbitmask' => RISK_PERSONAL, 'captype' => 'read', 'contextlevel' => CONTEXT_COURSE, - 'legacy' => array( - 'student' => CAP_ALLOW - ) - ), - 'report/myfeedback:usage' => array( + 'legacy' => [ + 'student' => CAP_ALLOW, + ], + ], + 'report/myfeedback:usage' => [ 'riskbitmask' => RISK_PERSONAL, 'captype' => 'read', 'contextlevel' => CONTEXT_SYSTEM, - 'legacy' => array( - 'manager' => CAP_PREVENT - ) - ) -); + 'legacy' => [ + 'manager' => CAP_PREVENT, + ], + ], +]; diff --git a/db/upgrade.php b/db/upgrade.php index 4b0f36d..792a8cd 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -49,7 +49,7 @@ function xmldb_report_myfeedback_upgrade($oldversion) { $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, null, null, null); // Adding keys to table report_myfeedback. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']); // Conditionally launch create table for report_myfeedback. if (!$dbman->table_exists($table)) { @@ -67,7 +67,7 @@ function xmldb_report_myfeedback_upgrade($oldversion) { // Optimise the log table. if ($oldversion < 2018031100) { $table = new xmldb_table('logstore_standard_log'); - $index = new xmldb_index('logsstanlog_usecou_ix', XMLDB_INDEX_NOTUNIQUE, array('userid', 'courseid')); + $index = new xmldb_index('logsstanlog_usecou_ix', XMLDB_INDEX_NOTUNIQUE, ['userid', 'courseid']); if (!$dbman->index_exists($table, $index)) { $dbman->add_index($table, $index); } diff --git a/export.php b/export.php index 82e887f..14ac7be 100644 --- a/export.php +++ b/export.php @@ -46,12 +46,12 @@ $tutor = $_SESSION['tutor']; // Arrays to clean up the heading tags passed to the usage reports. -$strfind = array(" ", ":", "\r", "\n"); -$strreplace = array("_", "", "", ""); +$strfind = [" ", ":", "\r", "\n"]; +$strreplace = ["_", "", "", ""]; $headingtext = get_string('reportfor', 'report_myfeedback').$username."\r\n"; $event = \report_myfeedback\event\myfeedbackreport_download::create( - array('context' => context_user::instance($userid), 'relateduserid' => $userid) + ['context' => context_user::instance($userid), 'relateduserid' => $userid] ); $filename = get_string('filename', 'report_myfeedback') . date('YmdHis') . ".csv"; $excelheader = get_string('exportheader', 'report_myfeedback') . " \r\n"; @@ -59,7 +59,7 @@ // Personal tutor dashboard. $headingtext = get_string('p_tutor_report', 'report_myfeedback') . " \r\n"; $event = \report_myfeedback\event\myfeedbackreport_downloadptutor::create( - array('context' => context_user::instance($USER->id), 'relateduserid' => $userid) + ['context' => context_user::instance($USER->id), 'relateduserid' => $userid] ); $filename = get_string('p_tutor_filename', 'report_myfeedback') . date('YmdHis') . ".csv"; $excelheader = get_string('p_tutor_exportheader', 'report_myfeedback') . " \r\n"; @@ -67,7 +67,7 @@ // Module tutor dashboard. $headingtext = get_string('mod_tutor_report', 'report_myfeedback') . " \r\n"; $event = \report_myfeedback\event\myfeedbackreport_downloadmtutor::create( - array('context' => context_user::instance($USER->id), 'relateduserid' => $userid) + ['context' => context_user::instance($USER->id), 'relateduserid' => $userid] ); $filename = get_string('mod_tutor_filename', 'report_myfeedback') . date('YmdHis') . ".csv"; $excelheader = get_string('mod_tutor_exportheader', 'report_myfeedback') . " \r\n"; @@ -75,7 +75,7 @@ // Departmental admin dashboard. $headingtext = get_string('dept_admin_report', 'report_myfeedback') . " \r\n"; $event = \report_myfeedback\event\myfeedbackreport_downloaddeptadmin::create( - array('context' => context_user::instance($USER->id), 'relateduserid' => $userid) + ['context' => context_user::instance($USER->id), 'relateduserid' => $userid] ); $filename = get_string('dept_admin_filename', 'report_myfeedback') . date('YmdHis') . ".csv"; $excelheader = get_string('dept_admin_exportheader', 'report_myfeedback') . " \r\n"; diff --git a/index.php b/index.php index 5f143a5..a220a71 100644 --- a/index.php +++ b/index.php @@ -57,7 +57,7 @@ $userid = optional_param('userid', 0, PARAM_INT); // User id. $yearview = optional_param('myselect', 0, PARAM_ALPHANUMEXT); // Academic year for archive. -$modview = optional_param_array('modselect', array(), PARAM_NOTAGS); // The selected course for Mod tutor Dashboard. +$modview = optional_param_array('modselect', [], PARAM_NOTAGS); // The selected course for Mod tutor Dashboard. $deptview = optional_param('deptselect', $dots, PARAM_NOTAGS); // For top level category on Dept admin dashboard. $progview = optional_param('progselect', $dots, PARAM_NOTAGS); // For second level category on Dept admin dashboard. @@ -105,7 +105,7 @@ // Get a progress bar when report is getting info. echo $OUTPUT->render_from_template('report_myfeedback/progress', [ - 'progressimg' => new moodle_url('/report/myfeedback/pix/progress.gif') + 'progressimg' => new moodle_url('/report/myfeedback/pix/progress.gif'), ]); if (empty($userid)) { @@ -123,7 +123,7 @@ $ucontext = context_user::instance($USER->id, MUST_EXIST); // If user don't have the report capability they can't access it. -$user = $currentdb->get_record('user', array('id' => $userid, 'deleted' => 0)); +$user = $currentdb->get_record('user', ['id' => $userid, 'deleted' => 0]); $userlinked = "" . $user->firstname . " " . $user->lastname . ""; $_SESSION['user_name'] = $user->firstname . ' ' . $user->lastname; @@ -263,16 +263,16 @@ // Tabs setup. $currenttab = optional_param('currenttab', 'overview', PARAM_TEXT); $thispageurl = 'index.php'; -$tabs = array(); +$tabs = []; // If departmental admin and not viewing a tutee's report. if ($prog && !$viewtutee) { $tabs[] = new tabobject('progadmin', - new moodle_url($thispageurl, array( + new moodle_url($thispageurl, [ 'userid' => $userid, 'currenttab' => 'progadmin', - 'sesskey' => sesskey() - )), + 'sesskey' => sesskey(), + ]), get_string('progadmin_dashboard', 'report_myfeedback') ); } @@ -280,21 +280,21 @@ // If tutor and not viewing a tutee's report. if ($moduletutor && !$viewtutee) { $tabs[] = new tabobject('mymodules', - new moodle_url($thispageurl, array( + new moodle_url($thispageurl, [ 'userid' => $userid, 'currenttab' => 'mymodules', - 'sesskey' => sesskey() - )), + 'sesskey' => sesskey(), + ]), get_string('tabs_mtutor', 'report_myfeedback')); } // If personal tutor and not viewing a tutee's report. if ($personaltutor && !$viewtutee) { $tabs[] = new tabobject('tutor', - new moodle_url($thispageurl, array( + new moodle_url($thispageurl, [ 'userid' => $userid, 'currenttab' => 'tutor', - 'sesskey' => sesskey() - )), + 'sesskey' => sesskey(), + ]), get_string('tabs_tutor', 'report_myfeedback') ); } @@ -315,11 +315,11 @@ if ($showstudentstab) { if ($prog || $moduletutor || $personaltutor) { $tabs[] = new tabobject('mytutees', - new moodle_url($thispageurl, array( + new moodle_url($thispageurl, [ 'userid' => $userid, 'currenttab' => 'mytutees', - 'sesskey' => sesskey() - )), + 'sesskey' => sesskey(), + ]), get_string('tabs_mytutees', 'report_myfeedback') ); } @@ -327,28 +327,28 @@ if ($viewtutee || $isstudent || is_siteadmin() || (!$prog && !$moduletutor && !$personaltutor && !$usage)) { $tabs[] = new tabobject('overview', - new moodle_url($thispageurl, array( + new moodle_url($thispageurl, [ 'userid' => $userid, 'currenttab' => 'overview', - 'sesskey' => sesskey() - )), + 'sesskey' => sesskey(), + ]), get_string('tabs_overview', 'report_myfeedback') ); $tabs[] = new tabobject('feedback', - new moodle_url($thispageurl, array( + new moodle_url($thispageurl, [ 'userid' => $userid, 'currenttab' => 'feedback', - 'sesskey' => sesskey() - )), + 'sesskey' => sesskey(), + ]), get_string('tabs_feedback', 'report_myfeedback') ); if ($mytutorid && !$personaltutor) { $tabs[] = new tabobject('ptutor', - new moodle_url($thispageurl, array( + new moodle_url($thispageurl, [ 'userid' => $userid, 'currenttab' => 'ptutor', - 'sesskey' => sesskey() - )), + 'sesskey' => sesskey(), + ]), get_string('tabs_ptutor', 'report_myfeedback')); } $currenttab = optional_param('currenttab', 'overview', PARAM_TEXT); @@ -357,11 +357,11 @@ // If usage and not viewing a tutee's report. if ($usage && !$viewtutee) { $tabs[] = new tabobject('usage', - new moodle_url($thispageurl, array( + new moodle_url($thispageurl, [ 'userid' => $userid, 'currenttab' => 'usage', - 'sesskey' => sesskey() - )), + 'sesskey' => sesskey(), + ]), get_string('usage_dashboard', 'report_myfeedback') ); } @@ -410,14 +410,14 @@ if ($_SESSION['viewed'] != $userid) { // Trigger a viewed event. $event = \report_myfeedback\event\myfeedbackreport_viewed::create( - array('context' => context_system::instance(0), 'relateduserid' => $userid) + ['context' => context_system::instance(0), 'relateduserid' => $userid] ); $event->trigger(); $_SESSION['viewed'] = $userid; } } else { $event = \report_myfeedback\event\myfeedbackreport_viewed::create( - array('context' => context_system::instance(0), 'relateduserid' => $userid) + ['context' => context_system::instance(0), 'relateduserid' => $userid] ); $event->trigger(); $_SESSION['viewed'] = $userid; diff --git a/lib.php b/lib.php index 9bfc3a3..9dee444 100644 --- a/lib.php +++ b/lib.php @@ -38,7 +38,7 @@ function report_myfeedback_extend_navigation(global_navigation $navigation) { // TODO: Segun Babalola. Where does $course come from? // TODO: Check that pix_icon is not deprecated. - $url = new moodle_url('/report/myfeedback/index.php', array('course' => $course->id)); + $url = new moodle_url('/report/myfeedback/index.php', ['course' => $course->id]); $navigation->add(get_string('pluginname', 'report_myfeedback'), $url, null, null, null, new pix_icon('i/report', '')); } @@ -55,7 +55,7 @@ function report_myfeedback_extend_navigation(global_navigation $navigation) { function report_myfeedback_extend_navigation_user($navigation, $user, $course) { // Backward compatibility to v2.8 and earlier versions. $context = context_user::instance($user->id, MUST_EXIST); - $url = new moodle_url('/report/myfeedback/index.php', array('userid' => $user->id)); + $url = new moodle_url('/report/myfeedback/index.php', ['userid' => $user->id]); $navigation->add(get_string('pluginname', 'report_myfeedback'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', '')); } @@ -70,10 +70,10 @@ function report_myfeedback_extend_navigation_user($navigation, $user, $course) { * @param stdClass $coursecontext The context of the course */ function report_myfeedback_extend_navigation_user_settings($navigation, $user, $context, $course, $coursecontext) { - $url = new moodle_url('/report/myfeedback/index.php', array( + $url = new moodle_url('/report/myfeedback/index.php', [ 'userid' => $user->id, - 'sesskey' => sesskey() - )); + 'sesskey' => sesskey(), + ]); $navigation->add(get_string('pluginname', 'report_myfeedback'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', '')); } @@ -88,8 +88,8 @@ function report_myfeedback_extend_navigation_user_settings($navigation, $user, $ function report_myfeedback_extend_navigation_course($navigation, $course, $context) { global $USER; $url = has_capability('report/myfeedback:modtutor', $context) - ? new moodle_url('/report/myfeedback/index.php', array('userid' => $USER->id, 'currenttab' => 'mymodules')) : - new moodle_url('/report/myfeedback/index.php', array('userid' => $USER->id)); + ? new moodle_url('/report/myfeedback/index.php', ['userid' => $USER->id, 'currenttab' => 'mymodules']) : + new moodle_url('/report/myfeedback/index.php', ['userid' => $USER->id]); $navigation->add(get_string('pluginname', 'report_myfeedback'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', '')); } @@ -107,10 +107,10 @@ function report_myfeedback_extend_navigation_course($navigation, $course, $conte */ function report_myfeedback_myprofile_navigation(core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course) { // For compatibility with v2.9 and later. - $url = new moodle_url('/report/myfeedback/index.php', array( + $url = new moodle_url('/report/myfeedback/index.php', [ 'userid' => $user->id, - 'sesskey' => sesskey() - )); + 'sesskey' => sesskey(), + ]); if (!empty($course)) { $url->param('course', $course->id); } diff --git a/mytutees.php b/mytutees.php index 49d6392..8e9bb74 100644 --- a/mytutees.php +++ b/mytutees.php @@ -39,6 +39,6 @@ $tutees = $report->get_all_accessible_users($personaltutor, $moduletutor, $prog, $searchuser); echo $tutees; $event = \report_myfeedback\event\myfeedbackreport_viewed_mystudents::create( - array('context' => context_user::instance($USER->id), 'relateduserid' => $userid) + ['context' => context_user::instance($USER->id), 'relateduserid' => $userid] ); $event->trigger(); diff --git a/nonmoodlefeedback.php b/nonmoodlefeedback.php index 7a83a2c..1295f8d 100644 --- a/nonmoodlefeedback.php +++ b/nonmoodlefeedback.php @@ -47,19 +47,19 @@ $sql2 = "INSERT INTO {report_myfeedback} (userid, gradeitemid, modifierid, iteminstance, feedback, timemodified) VALUES (?, ?, ?, ?, ?, ?)"; - $params = array($userid, $gradeid, $instance); - $params1 = array($USER->id, $feednotes, $now, $userid, $gradeid, $instance); - $params2 = array($userid, $gradeid, $USER->id, $instance, $feednotes, $now); + $params = [$userid, $gradeid, $instance]; + $params1 = [$USER->id, $feednotes, $now, $userid, $gradeid, $instance]; + $params2 = [$userid, $gradeid, $USER->id, $instance, $feednotes, $now]; $userfeedback = $DB->get_record_sql($sql, $params); $event = \report_myfeedback\event\myfeedbackreport_addfeedback::create( - array('context' => context_user::instance($userid), 'relateduserid' => $userid) + ['context' => context_user::instance($userid), 'relateduserid' => $userid] ); if ($userfeedback) { $currentdb->execute($sql1, $params1); echo get_string('updatesuccessful', 'report_myfeedback'); $event = \report_myfeedback\event\myfeedbackreport_updatefeedback::create( - array('context' => context_user::instance($userid), 'relateduserid' => $userid) + ['context' => context_user::instance($userid), 'relateduserid' => $userid] ); } else { $currentdb->execute($sql2, $params2); @@ -71,7 +71,7 @@ redirect(new \moodle_url('/report/myfeedback/index.php', [ 'userid' => $userid, - 'currenttab' => 'feedback' + 'currenttab' => 'feedback', ] )); } diff --git a/programmeadmin/index.php b/programmeadmin/index.php index e270a92..48b6e4f 100644 --- a/programmeadmin/index.php +++ b/programmeadmin/index.php @@ -51,7 +51,7 @@
'; $report->setup_external_db(); -$adminmods = array(); +$adminmods = []; $getmods = get_user_capability_course( 'report/myfeedback:progadmin', @@ -71,7 +71,7 @@ $padmin = $report->get_prog_admin_dept_prog($adminmods); $x = 0; -$exceltable = array(); +$exceltable = []; $curdept = 0; $deptview = (isset($_COOKIE['curdept']) ? $_COOKIE['curdept'] : $deptview); if ($padmin) { @@ -153,17 +153,17 @@ echo "
"; echo "
"; $pgmods = $padmin; - $ptutoruids = array(); - $ptutormod = array(); + $ptutoruids = []; + $ptutormod = []; $dup = 0; - $pgtot = array(); - $astot = array(); - $pmtot = array(); - $pgusers = array(); - $pguserspermod = array(); - $pgtutcontext = array(); - $pgeach = array(); - $pgeach1 = array(); + $pgtot = []; + $astot = []; + $pmtot = []; + $pgusers = []; + $pguserspermod = []; + $pgtutcontext = []; + $pgeach = []; + $pgeach1 = []; if (count($pgmods[$curdept]['prog'][$curprog]['mod']) <= $report->get_course_limit() || $curmod) { // CATALYST CUSTOM. foreach ($pgmods[$curdept]['prog'][$curprog]['mod'] as $key1 => $pmod) {// All modules in the category. // CATALYST CUSTOM START - IF a course is selected, process just that selected course. @@ -173,7 +173,7 @@ // CATALYST CUSTOM END. $progmodcontext = context_course::instance($key1); $pgtutcontext[$key1] = $progmodcontext->id; - $puids = array(); + $puids = []; $modenrolledusers = get_enrolled_users( $progmodcontext, @@ -282,7 +282,7 @@ $modtut = null; if ($curmod) { // Get users with scores per module instead of the entire category. - $pgusers = (isset($pguserspermod[$curmod]) ? $pguserspermod[$curmod] : array()); + $pgusers = (isset($pguserspermod[$curmod]) ? $pguserspermod[$curmod] : []); // Get user ids per module. $ptutoruids = (isset($ptutormod[$curmod]) ? $ptutormod[$curmod] : $ptutoruids); $modtut = (isset($ptutormod[$curmod]) ? $pgtutcontext[$curmod] : 0); @@ -355,7 +355,7 @@ // Users for the export table on department level. foreach ($pgusers as $k4 => $eachu) { - $getname = $currentdb->get_record('user', array('id' => $k4), $list = 'firstname,lastname'); + $getname = $currentdb->get_record('user', ['id' => $k4], $list = 'firstname,lastname'); $fname = ($getname ? $getname->firstname : ''); $lname = ($getname ? $getname->lastname : ''); $exceltable[$x]['Name'] = $fname; @@ -369,7 +369,7 @@ } $stu = $report->get_user_analytics($pgusers, $cid = 't', $display = 'stuRec', $style = 'display:none'); - $progadminptutors = array(); + $progadminptutors = []; $progtable .= "
"; $progtable .= ""; @@ -385,7 +385,7 @@ } $progtable .= '
" . $stu->uname . "" . $stu->u_vas . "
'; $ptutorid = ($modtut ? 3 : $ptutorid); // Var $modtut is course context. - $tutgroup = ($modtut ? $pgusers : array()); // Array of users in course. + $tutgroup = ($modtut ? $pgusers : []); // Array of users in course. $activemod = ($modtut ? $curmod : 0); // Current module. echo $progtable; @@ -401,6 +401,6 @@ } $event = \report_myfeedback\event\myfeedbackreport_viewed_deptdash::create( - array('context' => context_user::instance($USER->id), 'relateduserid' => $userid) + ['context' => context_user::instance($USER->id), 'relateduserid' => $userid] ); $event->trigger(); diff --git a/reflectivenotes.php b/reflectivenotes.php index 6527d58..96f669a 100644 --- a/reflectivenotes.php +++ b/reflectivenotes.php @@ -48,19 +48,19 @@ $sql2 = "INSERT INTO {report_myfeedback} (userid, gradeitemid, modifierid, iteminstance, notes, timemodified) VALUES (?, ?, ?, ?, ?, ?)"; - $params = array($userid, $gradeid, $instance); - $params1 = array($USER->id, $reflectivenotes, $now, $userid, $gradeid, $instance); - $params2 = array($userid, $gradeid, $USER->id, $instance, $reflectivenotes, $now); + $params = [$userid, $gradeid, $instance]; + $params1 = [$USER->id, $reflectivenotes, $now, $userid, $gradeid, $instance]; + $params2 = [$userid, $gradeid, $USER->id, $instance, $reflectivenotes, $now]; $usernotes = $DB->get_record_sql($sql, $params); $event = \report_myfeedback\event\myfeedbackreport_addnotes::create( - array('context' => context_user::instance($userid), 'relateduserid' => $userid) + ['context' => context_user::instance($userid), 'relateduserid' => $userid] ); if ($usernotes) { $currentdb->execute($sql1, $params1); echo get_string('updatesuccessful', 'report_myfeedback'); $event = \report_myfeedback\event\myfeedbackreport_updatenotes::create( - array('context' => context_user::instance($userid), 'relateduserid' => $userid) + ['context' => context_user::instance($userid), 'relateduserid' => $userid] ); } else { $currentdb->execute($sql2, $params2); @@ -72,7 +72,7 @@ redirect(new \moodle_url('/report/myfeedback/index.php', [ 'userid' => $userid, - 'currenttab' => 'feedback' + 'currenttab' => 'feedback', ] )); } diff --git a/settings.php b/settings.php index 2f58380..9bf85a3 100644 --- a/settings.php +++ b/settings.php @@ -37,7 +37,7 @@ $settings->add(new admin_setting_configpasswordunmask('report_myfeedback/dbpass', get_string('dbpass', 'report_myfeedback'), get_string('dbpassinfo', 'report_myfeedback'), '', PARAM_RAW, 30)); - $options = array(); + $options = []; $max = 5; for ($i = 0; $i <= $max; $i++) { $options[$i] = $i; diff --git a/student/academicyear.php b/student/academicyear.php index 96a9c36..bf417fc 100644 --- a/student/academicyear.php +++ b/student/academicyear.php @@ -100,5 +100,5 @@ $varprog, $varsadmin, $livedomain, - $vararchiveinst + $vararchiveinst, ]); diff --git a/student/overview.php b/student/overview.php index 98e5024..8b8cd44 100644 --- a/student/overview.php +++ b/student/overview.php @@ -48,7 +48,7 @@ if ($userid != $USER->id) { echo '
'; - echo $OUTPUT->user_picture($user, array('size' => 125)); + echo $OUTPUT->user_picture($user, ['size' => 125]); echo '
'; echo '
'; @@ -70,7 +70,7 @@ // List of courses enrolled on. $courselist = ''; $limitcourse = 1; - $allcourses = array(); + $allcourses = []; $allcourse = get_user_capability_course( 'report/myfeedback:student', $userid, diff --git a/student/personaltutor.php b/student/personaltutor.php index 8fc4c8b..1c6c4a5 100644 --- a/student/personaltutor.php +++ b/student/personaltutor.php @@ -27,12 +27,12 @@ $programme = ''; if ($mytutorid) { - $mytutorobj = $currentdb->get_record('user', array('id' => $mytutorid)); + $mytutorobj = $currentdb->get_record('user', ['id' => $mytutorid]); profile_load_data($mytutorobj); echo "

" . get_string('overview_text_ptutor_tab', 'report_myfeedback') . "

"; echo '
'; echo '
'; - echo $OUTPUT->user_picture($mytutorobj, array('size' => 100)); + echo $OUTPUT->user_picture($mytutorobj, ['size' => 100]); echo '
'; echo '
'; diff --git a/tests/behat/behat_myfeedback.php b/tests/behat/behat_myfeedback.php index f8e3f24..f0715e4 100644 --- a/tests/behat/behat_myfeedback.php +++ b/tests/behat/behat_myfeedback.php @@ -145,7 +145,7 @@ public function user_is_granted_departmental_admin_rights($username, TableNode $ $roleassigndata[] = ['role', 'contextlevel', 'user', 'reference']; $roleassigndata[] = ['departmental_admin', 'System', $username, '']; $this->execute("behat_data_generators::the_following_entities_exist", ['role assigns', - new TableNode($roleassigndata) + new TableNode($roleassigndata), ]); // Grant the departmental admin role permissions to the appropriate capability required by my feedback plugin. @@ -161,12 +161,12 @@ public function user_is_granted_departmental_admin_rights($username, TableNode $ 'Allow', 'departmental_admin', 'Course', - $coursedata[$i][0] + $coursedata[$i][0], ]; } $this->execute("behat_data_generators::the_following_entities_exist", ['permission overrides', - new TableNode($coursepermissions) + new TableNode($coursepermissions), ]); } @@ -186,7 +186,7 @@ public function the_following_personal_tutors_are_assigned_the_following_tutees( $coursepermissions[] = ['report/myfeedback:personaltutor', 'Allow', 'personal_tutor', 'System', '']; $this->execute("behat_data_generators::the_following_entities_exist", ['permission overrides', - new TableNode($coursepermissions) + new TableNode($coursepermissions), ]); // Grant listed user accounts the personal tutor role. diff --git a/tutor/mymodules.php b/tutor/mymodules.php index b12a36c..975c6bf 100644 --- a/tutor/mymodules.php +++ b/tutor/mymodules.php @@ -47,7 +47,7 @@
'; -echo $OUTPUT->user_picture($USER, array('size' => 100)); +echo $OUTPUT->user_picture($USER, ['size' => 100]); echo '
'; echo '
@@ -62,7 +62,7 @@ $courselist = ''; $num = 0; -$mytutormods = array(); +$mytutormods = []; // Get all courses the logged-in user has modtutor capability in. // Used this function as it gets courses added at category level as well - // so courses they may have the capability in under other users. @@ -134,14 +134,14 @@ $gradeicon = '-'; -$exceltable = array(); +$exceltable = []; $x = 0; $zscore = new stdClass(); -$zscore->users = array(); -$zscore->assess = array(); +$zscore->users = []; +$zscore->assess = []; $report->setup_external_db(); -$mytutormods = array(); +$mytutormods = []; $archivemods = get_user_capability_course( 'report/myfeedback:modtutor', $USER->id, @@ -193,7 +193,7 @@ $myid = $t->category; $sname = $t->shortname; $modname = $t->fullname; - if ($getcat = $report->get_prog_admin_dept_prog(array($t), true)) { + if ($getcat = $report->get_prog_admin_dept_prog([$t], true)) { $dept = $getcat['dept']; $prog = $getcat['prog']; } @@ -203,7 +203,7 @@ $csename .= ($dept ? get_string('faculty', 'report_myfeedback') . $dept . '
' : ''); $csename .= ($prog ? get_string('programme', 'report_myfeedback') . $prog . '
' : ''); - $uids = array(); + $uids = []; $allenrolledusers = get_enrolled_users( $modcontext, $cap = 'report/myfeedback:student', @@ -299,6 +299,6 @@ $_SESSION['user_name'] = 'nil'; $event = \report_myfeedback\event\myfeedbackreport_viewed_mtutordash::create( - array('context' => context_user::instance($USER->id), 'relateduserid' => $userid) + ['context' => context_user::instance($USER->id), 'relateduserid' => $userid] ); $event->trigger(); diff --git a/tutor/personaltutoring.php b/tutor/personaltutoring.php index bbbc701..6df7db1 100644 --- a/tutor/personaltutoring.php +++ b/tutor/personaltutoring.php @@ -45,7 +45,7 @@ echo '
'; if ($userid != $USER->id && !$viewtutee) { - echo $OUTPUT->user_picture($USER, array('size' => 80)); + echo $OUTPUT->user_picture($USER, ['size' => 80]); } echo '
'; @@ -111,10 +111,10 @@ $latesub = 0; $graded = 0; $lowgrades = 0; -$exceltable = array(); +$exceltable = []; $x = 0; $modnames = ''; -$useremail = array(); +$useremail = []; if ($tutees = $report->get_dashboard_tutees()) { // Get all personal tutees for the user. echo "

" . get_string('academicyear', 'report_myfeedback') . ":

"; @@ -192,7 +192,7 @@ // Log the event that the user viewed the dashboard. $event = \report_myfeedback\event\myfeedbackreport_viewed_ptutordash::create( - array('context' => context_user::instance($USER->id), 'relateduserid' => $userid) + ['context' => context_user::instance($USER->id), 'relateduserid' => $userid] ); $event->trigger(); $config = get_config('report_myfeedback'); diff --git a/usage/index.php b/usage/index.php index d626a8d..1e95fc5 100644 --- a/usage/index.php +++ b/usage/index.php @@ -61,7 +61,7 @@ "coursestaff" => get_string('coursestaff', 'report_myfeedback'), "student" => get_string('student', 'report_myfeedback'), "staffmember" => get_string('staffmember', 'report_myfeedback'), - "personaltutorstudents" => get_string('personaltutees', 'report_myfeedback') + "personaltutorstudents" => get_string('personaltutees', 'report_myfeedback'), ]; // Display report type menu. echo "
" @@ -83,7 +83,7 @@ echo ""; echo "
"; $reporttitle = ""; - $uids = array(); + $uids = []; // Table for students / staff. switch ($reporttype) { @@ -250,7 +250,7 @@ foreach ($courses as $course) { // Get the course students. - $uids = array(); + $uids = []; // Note: active users refers to students who haven't had their enrolments suspended. $coursecontext = context_course::instance($course->id); $modenrolledusers = get_enrolled_users( @@ -310,7 +310,7 @@ foreach ($courses as $course) { // Get the course staff. - $uids = array(); + $uids = []; // Note: active users refers to students who haven't had their enrolments suspended. $coursecontext = context_course::instance($course->id); $modenrolledusers = get_enrolled_users( @@ -357,7 +357,7 @@ // Get the course users. // Note: active users refers to students who haven't had their enrolments suspended. $coursecontext = context_course::instance($courseid); - $uids = array(); + $uids = []; $modenrolledusers = get_enrolled_users( $coursecontext, $cap = 'report/myfeedback:student', @@ -395,7 +395,7 @@ echo "

" . $reporttitle . $report->get_course_category_link($courseid, "categorystaff") . "

"; echo '
' . get_string('usage_coursestaff_info', 'report_myfeedback') . '
'; - $uids = array(); + $uids = []; // Get the course users. // Note: active users refers to students who haven't had their enrolments suspended. // Not sure it's quite accurate though. @@ -455,7 +455,7 @@ // Check the user is not suspended or deleted. if ($report->is_active_user($reportuserid)) { - echo $report->get_staff_statistics_table(array($reportuserid), true); + echo $report->get_staff_statistics_table([$reportuserid], true); } else { echo "This user is suspended or deleted"; } @@ -473,7 +473,7 @@ // Check the user is not suspended or deleted. if ($report->is_active_user($reportuserid)) { - echo $report->get_student_statistics_table(array($reportuserid), $reporttype); + echo $report->get_student_statistics_table([$reportuserid], $reporttype); } else { echo "This user is suspended or deleted"; } @@ -488,7 +488,7 @@ $event = \report_myfeedback\event\myfeedbackreport_viewed_usagedash::create( [ 'context' => context_user::instance($USER->id), - 'relateduserid' => $USER->id + 'relateduserid' => $USER->id, ] ); $event->trigger();