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 = "
" . get_string('overview_text_ptutor_tab', 'report_myfeedback') . "
"; 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 ""; $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 "