diff --git a/.github/workflows/moodle-plugin-ci.yml b/.github/workflows/moodle-plugin-ci.yml index 89a57083..4938e27e 100644 --- a/.github/workflows/moodle-plugin-ci.yml +++ b/.github/workflows/moodle-plugin-ci.yml @@ -36,14 +36,15 @@ jobs: # - each moodle version at least once # - each database at least once include: - - {php: '7.4', moodle-branch: MOODLE_401_STABLE, database: mariadb} - - {php: '8.0', moodle-branch: MOODLE_402_STABLE, database: pgsql} - - {php: '8.2', moodle-branch: MOODLE_403_STABLE, database: mariadb} - - {php: '8.1', moodle-branch: main, database: pgsql} + - {php: '8.0', moodle-branch: MOODLE_401_STABLE, database: mariadb} + - {php: '8.1', moodle-branch: MOODLE_402_STABLE, database: pgsql} + - {php: '8.1', moodle-branch: MOODLE_403_STABLE, database: mariadb} + - {php: '8.2', moodle-branch: MOODLE_404_STABLE, database: pgsql} + - {php: '8.2', moodle-branch: main, database: mariadb} steps: - name: Check out repository code - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: path: plugin @@ -51,13 +52,13 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: mbstring, pgsql, mysqli + extensions: ${{ matrix.extensions }} ini-values: max_input_vars=5000 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 @@ -71,47 +72,56 @@ jobs: MOODLE_BRANCH: ${{ matrix.moodle-branch }} - name: PHP Lint - if: ${{ always() }} + if: ${{ !cancelled() }} run: moodle-plugin-ci phplint - - name: PHP Copy/Paste Detector - if: ${{ always() }} - continue-on-error: true # This step will show errors but will not fail - run: moodle-plugin-ci phpcpd - - name: PHP Mess Detector - if: ${{ always() }} + if: ${{ !cancelled() }} run: moodle-plugin-ci phpmd - name: Moodle Code Checker - if: ${{ always() }} - run: moodle-plugin-ci codechecker --max-warnings 0 + continue-on-error: true # This step will show errors but will not fail + if: ${{ !cancelled() }} + run: moodle-plugin-ci phpcs --max-warnings 0 - name: Moodle PHPDoc Checker continue-on-error: true # This step will show errors but will not fail - 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 - if: ${{ always() }} + if: ${{ !cancelled() }} run: moodle-plugin-ci grunt --max-lint-warnings 0 - name: PHPUnit tests - if: ${{ always() }} + if: ${{ !cancelled() }} run: moodle-plugin-ci phpunit - name: Behat features - if: ${{ always() }} + if: ${{ !cancelled() }} run: moodle-plugin-ci behat --profile chrome + + - name: Upload Behat Faildump + if: ${{ failure() && steps.behat.outcome == 'failure' }} + uses: actions/upload-artifact@v4 + with: + name: Behat Faildump (${{ join(matrix.*, ', ') }}) + path: ${{ github.workspace }}/moodledata/behat_dump + retention-days: 7 + if-no-files-found: ignore + + - name: Mark cancelled jobs as failed. + if: ${{ cancelled() }} + run: exit 1 diff --git a/classes/statistics_calculator.php b/classes/statistics_calculator.php index 82ed872a..c7c27939 100644 --- a/classes/statistics_calculator.php +++ b/classes/statistics_calculator.php @@ -132,7 +132,6 @@ private static function get_attempt_stat_joins($cmid, $groupid, $excluderoles = JOIN {question_references} qr ON qr.itemid = sqq.id AND qr.component = 'mod_studentquiz' AND qr.questionarea = 'studentquiz_question' - AND qr.usingcontextid = :contextid1 JOIN {question_bank_entries} qbe ON qr.questionbankentryid = qbe.id JOIN {question_versions} qv ON qv.questionbankentryid = qr.questionbankentryid AND qv.version = ( SELECT MAX(version) @@ -164,7 +163,6 @@ private static function get_attempt_stat_joins($cmid, $groupid, $excluderoles = JOIN {question_references} qr ON qr.itemid = sqq.id AND qr.component = 'mod_studentquiz' AND qr.questionarea = 'studentquiz_question' - AND qr.usingcontextid = :contextid2 JOIN {question_bank_entries} qbe ON qr.questionbankentryid = qbe.id JOIN {question_versions} qv ON qv.questionbankentryid = qr.questionbankentryid AND qv.version = ( SELECT MAX(version) @@ -199,7 +197,6 @@ private static function get_attempt_stat_joins($cmid, $groupid, $excluderoles = JOIN {question_references} qr ON qr.itemid = sqq.id AND qr.component = 'mod_studentquiz' AND qr.questionarea = 'studentquiz_question' - AND qr.usingcontextid = :contextid3 JOIN {question_bank_entries} qbe ON qr.questionbankentryid = qbe.id JOIN {question_versions} qv ON qv.questionbankentryid = qr.questionbankentryid AND qv.version = ( SELECT MAX(version) @@ -234,7 +231,6 @@ private static function get_attempt_stat_joins($cmid, $groupid, $excluderoles = JOIN {question_references} qr ON qr.itemid = sqq.id AND qr.component = 'mod_studentquiz' AND qr.questionarea = 'studentquiz_question' - AND qr.usingcontextid = :contextid4 JOIN {question_bank_entries} qbe ON qr.questionbankentryid = qbe.id JOIN {question_versions} qv ON qv.questionbankentryid = qr.questionbankentryid AND qv.version = ( SELECT MAX(version) @@ -263,7 +259,6 @@ private static function get_attempt_stat_joins($cmid, $groupid, $excluderoles = JOIN {question_references} qr ON qr.itemid = sqq.id AND qr.component = 'mod_studentquiz' AND qr.questionarea = 'studentquiz_question' - AND qr.usingcontextid = :contextid5 JOIN {question_bank_entries} qbe ON qr.questionbankentryid = qbe.id JOIN {question_versions} qv ON qv.questionbankentryid = qr.questionbankentryid AND qv.version = ( SELECT MAX(version) @@ -308,7 +303,6 @@ private static function get_attempt_stat_joins($cmid, $groupid, $excluderoles = * @return array */ private static function get_attempt_stat_joins_params($cmid, $quantifiers = null, $userid = null): array { - $contextid = \context_module::instance($cmid)->id; $params = [ 'cmid1' => $cmid, 'cmid2' => $cmid, @@ -317,11 +311,6 @@ private static function get_attempt_stat_joins_params($cmid, $quantifiers = null 'cmid5' => $cmid, 'cmid6' => $cmid, 'cmid7' => $cmid, - 'contextid1' => $contextid, - 'contextid2' => $contextid, - 'contextid3' => $contextid, - 'contextid4' => $contextid, - 'contextid5' => $contextid, 'status1' => question_version_status::QUESTION_STATUS_HIDDEN, 'status2' => question_version_status::QUESTION_STATUS_HIDDEN, 'status3' => question_version_status::QUESTION_STATUS_HIDDEN, @@ -444,7 +433,6 @@ public static function get_question_stats($cmid, $groupid) { JOIN {question_references} qr ON qr.itemid = sqq.id AND qr.component = 'mod_studentquiz' AND qr.questionarea = 'studentquiz_question' - AND qr.usingcontextid = :contextid1 JOIN {question_bank_entries} qbe ON qr.questionbankentryid = qbe.id JOIN {question_versions} qv ON qv.questionbankentryid = qr.questionbankentryid AND qv.version = ( SELECT MAX(version) @@ -461,7 +449,6 @@ public static function get_question_stats($cmid, $groupid) { JOIN {question_bank_entries} qbe ON qr.questionbankentryid = qbe.id AND qr.component = 'mod_studentquiz' AND qr.questionarea = 'studentquiz_question' - AND qr.usingcontextid = :contextid2 JOIN {question_versions} qv ON qv.questionbankentryid = qr.questionbankentryid AND qv.version = ( SELECT MAX(version) FROM {question_versions} @@ -477,12 +464,9 @@ public static function get_question_stats($cmid, $groupid) { 'q.parent = 0', 'sq.coursemodule = :cmid1' ]; - $contextid = \context_module::instance($cmid)->id; $params = [ 'cmid1' => $cmid, 'cmid2' => $cmid, - 'contextid1' => $contextid, - 'contextid2' => $contextid, 'status1' => question_version_status::QUESTION_STATUS_HIDDEN, 'status2' => question_version_status::QUESTION_STATUS_HIDDEN, ];