From 0d90600c239cf56d1066e14b86af7221faa91f7e Mon Sep 17 00:00:00 2001 From: Pol Torrent i Soler Date: Mon, 16 Dec 2024 16:07:14 +0100 Subject: [PATCH 1/4] fix: correct typo in corruptquestion_attempt key in es and ca messages --- lang/ca/qtype_wq.php | 2 +- lang/es/qtype_wq.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lang/ca/qtype_wq.php b/lang/ca/qtype_wq.php index 519c13f5..3c06fd49 100644 --- a/lang/ca/qtype_wq.php +++ b/lang/ca/qtype_wq.php @@ -97,4 +97,4 @@ $string['auxiliar_text'] = 'Escriviu un raonament opcional per a la vostra resposta:'; $string['corruptquestion_edit'] = 'AVÍS: Aquesta pregunta ha sigut corrompuda i se n\' perdut la informació matemàtica. Hem intentat refer tot el què hem pogut, però cal que reescriguis de nou l\'algorisme de CalcMe si la teva pregunta en tenia un, i que tornis a desar les opcions d\'entrada i validació personalitzades. Contacta amb el teu administrador per a més detalls.'; -$string['corruptquestion_attempt'] = 'La pregunta {a->questionname} ha sigut corrompuda i no s\'ha pogut carregar. Si us plau, contacta amb els teus professors perquè ho puguin arreglar.'; +$string['corruptquestion_attempt'] = 'La pregunta {$a->questionname} ha sigut corrompuda i no s\'ha pogut carregar. Si us plau, contacta amb els teus professors perquè ho puguin arreglar.'; diff --git a/lang/es/qtype_wq.php b/lang/es/qtype_wq.php index 76ed2dad..180e1c16 100644 --- a/lang/es/qtype_wq.php +++ b/lang/es/qtype_wq.php @@ -107,4 +107,4 @@ $string['filtercodes_compatibility_enabled_help'] = 'El filtro Filter Codes no es compatible con WirisQuizzes por defecto cuando la opción "Escape Tags" está activada. Esta opción de WirisQuizzes soluciona estos problemas. No se debe activar excepto en dicha situación.'; $string['corruptquestion_edit'] = 'AVISO: Esta pregunta ha sido corrompida y se ha perdido su información matemática. Hemos tratado de recuperar todo lo posible, pero debes reescribir el algoritmo de CalcMe si tu pregunta tenía uno y que vuelvas a guardar las opciones de entrada y validación personalizadas. Contacta con tu administrador para más detalles.'; -$string['corruptquestion_attempt'] = 'La pregunta {a->questionname} ha sido corrompida y no se ha podido cargar. Por favor, contacta con tus profesores para que la puedan arreglar.'; +$string['corruptquestion_attempt'] = 'La pregunta {$a->questionname} ha sido corrompida y no se ha podido cargar. Por favor, contacta con tus profesores para que la puedan arreglar.'; From 13836f02420c47f23db0a8114b536d28cc2b2ca9 Mon Sep 17 00:00:00 2001 From: Pol Torrent i Soler Date: Mon, 16 Dec 2024 16:33:39 +0100 Subject: [PATCH 2/4] chore: fix code style violations --- edit_wq_form.php | 10 +++++----- question.php | 4 ++-- questiontype.php | 2 +- step.php | 20 ++++++++++---------- styles.css | 8 +++++++- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/edit_wq_form.php b/edit_wq_form.php index 60ad939d..8074ae0f 100644 --- a/edit_wq_form.php +++ b/edit_wq_form.php @@ -55,10 +55,10 @@ protected function definition_inner($mform) { $mform->addElement('hidden', 'wirislang', current_language(), array('class' => 'wirislang')); $mform->setType('wirislang', PARAM_TEXT); - // TODO: Delete this if when all questions are wq! if (isset($this->question->wirisquestion)) { $program = $this->question->wirisquestion->serialize(); } else { + // If the wirisquestion is not already loaded in memory, load it from the DB directly. if (empty($this->question->id)) { // New question. $program = ''; @@ -66,12 +66,13 @@ protected function definition_inner($mform) { // Existing question. $wiris = $DB->get_record('qtype_wq', array('question' => $this->question->id)); if (empty($wiris)) { - // Corrupted question - $corruptwarning = $mform->createElement('html', '
' . get_string('corruptquestion_edit', 'qtype_wq') .'createElement('html', '
' . get_string('corruptquestion_edit', 'qtype_wq') . 'insertElementBefore($corruptwarning, 'generalheader'); $program = ''; } else { - // Happy path + // Question found in the DB. $program = $wiris->xml; } } @@ -90,7 +91,6 @@ protected function definition_inner($mform) { $defaultvalues = array(); $defaultvalues['wirisquestion'] = $program; $mform->setDefaults($defaultvalues); - } public function set_data($question) { $this->base->set_data($question); diff --git a/question.php b/question.php index da95af3b..3b760038 100644 --- a/question.php +++ b/question.php @@ -46,7 +46,7 @@ class qtype_wq_question extends question_graded_automatically { /** * @var bool - * Whether this question is corrupt and its wirisquestion was removed from the database. + * Whether this question is corrupt and its wirisquestion was removed from the database. */ public $corrupt = false; @@ -371,7 +371,7 @@ public function call_wiris_service($request) { $service = $builder->getQuizzesService(); $isdebugmodeenabled = get_config('qtype_wq', 'debug_mode_enabled') == '1'; - $islogmodeenabled = get_config('qtype_wq', 'log_server_errors') == '1'; + $islogmodeenabled = get_config('qtype_wq', 'log_server_errors') == '1'; if ($isdebugmodeenabled) { // @codingStandardsIgnoreLine diff --git a/questiontype.php b/questiontype.php index 98273526..181e35b9 100644 --- a/questiontype.php +++ b/questiontype.php @@ -101,9 +101,9 @@ protected function make_question_instance($questiondata) { protected function initialise_question_instance(question_definition $question, $questiondata) { global $CFG; - /** @var qtype_wq_question $question */ $this->base->initialise_question_instance($question->base, $questiondata); + /** @var qtype_wq_question $question */ $question->id = &$question->base->id; $question->idnumber = &$question->base->idnumber; $question->category = &$question->base->category; diff --git a/step.php b/step.php index ec35f895..2460deeb 100644 --- a/step.php +++ b/step.php @@ -247,14 +247,14 @@ public function is_attempt_limit_reached() { $isreached = $c >= self::MAX_ATTEMPS_SHORTANSWER_WIRIS; - $islogmodeenabled = get_config('qtype_wq', 'log_server_errors') == '1'; + $islogmodeenabled = get_config('qtype_wq', 'log_server_errors') == '1'; if ($islogmodeenabled) { - $errormessage = 'WIRISQUIZZES ATTEMPT LIMIT REACHED FOR STEP WITH ID ' . - ($this->step != null ? $this->step->get_id() : $this->stepid); + $errormessage = 'WIRISQUIZZES ATTEMPT LIMIT REACHED FOR STEP WITH ID ' . + ($this->step != null ? $this->step->get_id() : $this->stepid); // @codingStandardsIgnoreLine - error_log($errormessage); + error_log($errormessage); } - + return $isreached; } @@ -267,13 +267,13 @@ public function inc_attempts(moodle_exception $e) { $c = 0; } - $islogmodeenabled = get_config('qtype_wq', 'log_server_errors') == '1'; + $islogmodeenabled = get_config('qtype_wq', 'log_server_errors') == '1'; if ($islogmodeenabled) { - $errormessage = 'WIRISQUIZZES ATTEMPT ERROR --- INCREASING ATTEMPT COUNT TO ' . ($c + 1) . ' FOR STEP WITH ID ' . - ($this->step != null ? $this->step->get_id() : $this->stepid) . PHP_EOL . - 'EXCEPTION: ' . $e->getMessage(); + $errormessage = 'WIRISQUIZZES ATTEMPT ERROR --- INCREASING ATTEMPT COUNT TO ' . ($c + 1) . ' FOR STEP WITH ID ' . + ($this->step != null ? $this->step->get_id() : $this->stepid) . PHP_EOL . + 'EXCEPTION: ' . $e->getMessage(); // @codingStandardsIgnoreLine - error_log($errormessage); + error_log($errormessage); } $this->set_var('_gc', $c + 1, false); diff --git a/styles.css b/styles.css index d67a1e2c..445406e3 100644 --- a/styles.css +++ b/styles.css @@ -1,15 +1,19 @@ body.wrs_plugin.wrs_filter { font-family: Arial; } + span.wrs_plugin.wrs_filter { font-weight: bold; } + span.ok.wrs_plugin.wrs_filter { color: #090; } + span.error.wrs_plugin.wrs_filter { color: #d00; } + table.wrs_plugin.wrs_filter, th.wrs_plugin.wrs_filter, td.wrs_plugin.wrs_filter, @@ -18,9 +22,11 @@ tr.wrs_plugin.wrs_filter { border-collapse: collapse; padding: 5px; } + th.wrs_plugin.wrs_filter { background-color: #eee; } + img.wrs_plugin.wrs_filter { border: none; -} +} \ No newline at end of file From fa238394dea17d98819a0baf849c9a4566e894fe Mon Sep 17 00:00:00 2001 From: Pol Torrent i Soler Date: Mon, 16 Dec 2024 16:37:49 +0100 Subject: [PATCH 3/4] chore: more code style violations + typo --- edit_wq_form.php | 5 ++++- lang/en/qtype_wq.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/edit_wq_form.php b/edit_wq_form.php index 8074ae0f..0845e8cb 100644 --- a/edit_wq_form.php +++ b/edit_wq_form.php @@ -68,7 +68,10 @@ protected function definition_inner($mform) { if (empty($wiris)) { // Corrupted question. $corruptwarning = - $mform->createElement('html', '
' . get_string('corruptquestion_edit', 'qtype_wq') . 'createElement( + 'html', + '
' . get_string('corruptquestion_edit', 'qtype_wq') . '
' + ); $mform->insertElementBefore($corruptwarning, 'generalheader'); $program = ''; } else { diff --git a/lang/en/qtype_wq.php b/lang/en/qtype_wq.php index 3257f944..d8429fe7 100644 --- a/lang/en/qtype_wq.php +++ b/lang/en/qtype_wq.php @@ -17,7 +17,7 @@ $string['wq'] = 'Wiris Quizzes'; $string['pluginname'] = 'Wiris Quizzes'; $string['access_provider_enabled'] = 'Access control'; -$string['access_provider_enabled_help'] = 'If enabled ony authenticated users can access Wiris services.'; +$string['access_provider_enabled_help'] = 'If enabled, only authenticated users can access Wiris services.'; $string['pluginnamesummary'] = ''; $string['wq_help'] = 'Generic Wiris Quizzes Help'; $string['editingwq'] = 'Editing a generic Wiris Quizzes question'; From 1696c2595b3551480158fa1b029bdd50123563f3 Mon Sep 17 00:00:00 2001 From: Pol Torrent i Soler Date: Mon, 16 Dec 2024 16:46:45 +0100 Subject: [PATCH 4/4] ops: upgrade moodle-ci-plugin to v4 --- .github/workflows/ci.yml | 58 +++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52554670..2270443d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,10 +57,6 @@ jobs: database: "pgsql" steps: - - name: Get branch name - id: branch-name - uses: tj-actions/branch-names@v7.0.7 - - name: Check out repository code uses: actions/checkout@v4 with: @@ -72,65 +68,79 @@ jobs: php-version: ${{ matrix.php }} extensions: ${{ matrix.extensions }} ini-values: max_input_vars=5000 + # 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: Add filter & commons qtype + - name: Add Wiris filter run: | moodle-plugin-ci add-plugin wiris/moodle-filter_wiris - 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 }} - 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() }} - 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: ${{ !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() }} - run: moodle-plugin-ci phpunit + if: ${{ !cancelled() }} + run: moodle-plugin-ci phpunit --fail-on-warning - name: Behat features - if: ${{ always() }} + id: behat + 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 \ No newline at end of file