Skip to content

Commit ad9236c

Browse files
author
Go MergeUpstream
committed
Merge commit '162768251949808ace6c66a4b930abf906b0a4da' into catalyst-main
2 parents 96fb223 + 1627682 commit ad9236c

File tree

214 files changed

+85460
-2564
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+85460
-2564
lines changed

.github/workflows/ci.yml

Lines changed: 69 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,61 @@ on: [push, pull_request]
44

55
jobs:
66
test:
7-
runs-on: ubuntu-18.04
7+
runs-on: ubuntu-latest
88

99
services:
1010
postgres:
11-
image: postgres:12
11+
image: postgres:13
1212
env:
13-
POSTGRES_USER: 'postgres'
14-
POSTGRES_HOST_AUTH_METHOD: 'trust'
13+
POSTGRES_USER: "postgres"
14+
POSTGRES_HOST_AUTH_METHOD: "trust"
1515
ports:
1616
- 5432:5432
1717
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
1818

1919
strategy:
2020
fail-fast: false
2121
matrix:
22-
php: ['7.3', '7.4', '8.0']
22+
php: ["7.4", "8.0", 8.1', "8.2", "8.3"]
2323
moodle-branch:
2424
[
25-
'MOODLE_39_STABLE',
26-
'MOODLE_310_STABLE',
27-
'MOODLE_311_STABLE',
28-
'MOODLE_400_STABLE',
29-
'MOODLE_401_STABLE'
25+
"MOODLE_401_STABLE",
26+
"MOODLE_402_STABLE",
27+
"MOODLE_403_STABLE",
28+
"MOODLE_404_STABLE",
29+
"main",
3030
]
3131
database: [pgsql]
3232
exclude:
3333
# Exclude Moodle+PHP incompatible versions
34-
# See: https://docs.moodle.org/dev/Moodle_and_PHP
35-
- moodle-branch: 'MOODLE_401_STABLE'
36-
php: '7.3'
37-
- moodle-branch: 'MOODLE_39_STABLE'
38-
php: '8.0'
39-
- moodle-branch: 'MOODLE_310_STABLE'
40-
php: '8.0'
34+
# See: https://moodledev.io/general/development/policies/php
35+
- moodle-branch: "MOODLE_401_STABLE"
36+
php: "8.2"
37+
- moodle-branch: "MOODLE_401_STABLE"
38+
php: "8.3"
39+
- moodle-branch: "MOODLE_402_STABLE"
40+
php: "7.4"
41+
- moodle-branch: "MOODLE_402_STABLE"
42+
php: "8.3"
43+
- moodle-branch: "MOODLE_403_STABLE"
44+
php: "7.4"
45+
- moodle-branch: "MOODLE_403_STABLE"
46+
php: "8.3"
47+
- moodle-branch: "MOODLE_404_STABLE"
48+
php: "7.4"
49+
- moodle-branch: "MOODLE_404_STABLE"
50+
php: "8.0"
51+
- moodle-branch: "main"
52+
include:
53+
# Only test master against latest PHP until we know which
54+
# versions are supported in the next release
55+
- moodle-branch: "main"
56+
php: "8.3"
57+
database: "pgsql"
4158

4259
steps:
4360
- name: Check out repository code
44-
uses: actions/checkout@v2
61+
uses: actions/checkout@v4
4562
with:
4663
path: plugin
4764

@@ -51,65 +68,79 @@ jobs:
5168
php-version: ${{ matrix.php }}
5269
extensions: ${{ matrix.extensions }}
5370
ini-values: max_input_vars=5000
71+
# If you are not using code coverage, keep "none". Otherwise, use "pcov" (Moodle 3.10 and up) or "xdebug".
72+
# If you try to use code coverage with "none", it will fallback to phpdbg (which has known problems).
5473
coverage: none
5574

5675
- name: Initialise moodle-plugin-ci
5776
run: |
58-
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
77+
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4
5978
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
6079
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
6180
sudo locale-gen en_AU.UTF-8
6281
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
6382
64-
- name: Add filter & commons qtype
83+
- name: Add Wiris filter
6584
run: |
6685
moodle-plugin-ci add-plugin wiris/moodle-filter_wiris
6786
6887
- name: Install moodle-plugin-ci
69-
run: |
70-
moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
88+
run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
7189
env:
7290
DB: ${{ matrix.database }}
7391
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
7492

7593
- name: PHP Lint
76-
if: ${{ always() }}
94+
if: ${{ !cancelled() }}
7795
run: moodle-plugin-ci phplint
7896

79-
- name: PHP Copy/Paste Detector
80-
continue-on-error: true # This step will show errors but will not fail
81-
if: ${{ always() }}
82-
run: moodle-plugin-ci phpcpd
83-
8497
- name: PHP Mess Detector
8598
continue-on-error: true # This step will show errors but will not fail
86-
if: ${{ always() }}
99+
if: ${{ !cancelled() }}
87100
run: moodle-plugin-ci phpmd
88101

89102
- name: Moodle Code Checker
90-
if: ${{ always() }}
91-
run: moodle-plugin-ci codechecker --max-warnings 0
103+
if: ${{ !cancelled() }}
104+
run: moodle-plugin-ci phpcs --max-warnings 0
105+
106+
- name: Moodle PHPDoc Checker
107+
if: ${{ !cancelled() }}
108+
run: moodle-plugin-ci phpdoc --max-warnings 0
92109

93110
- name: Validating
94-
if: ${{ always() }}
111+
if: ${{ !cancelled() }}
95112
run: moodle-plugin-ci validate
96113

97114
- name: Check upgrade savepoints
98-
if: ${{ always() }}
115+
if: ${{ !cancelled() }}
99116
run: moodle-plugin-ci savepoints
100117

101118
- name: Mustache Lint
102-
if: ${{ always() }}
119+
if: ${{ !cancelled() }}
103120
run: moodle-plugin-ci mustache
104121

105122
- name: Grunt
106-
if: ${{ always() }}
123+
if: ${{ !cancelled() }}
107124
run: moodle-plugin-ci grunt --max-lint-warnings 0
108125

109126
- name: PHPUnit tests
110-
if: ${{ always() }}
111-
run: moodle-plugin-ci phpunit
127+
if: ${{ !cancelled() }}
128+
run: moodle-plugin-ci phpunit --fail-on-warning
112129

113130
- name: Behat features
114-
if: ${{ always() }}
131+
id: behat
132+
if: ${{ !cancelled() }}
115133
run: moodle-plugin-ci behat --profile chrome
134+
135+
- name: Upload Behat Faildump
136+
if: ${{ failure() && steps.behat.outcome == 'failure' }}
137+
uses: actions/upload-artifact@v4
138+
with:
139+
name: Behat Faildump (${{ join(matrix.*, ', ') }})
140+
path: ${{ github.workspace }}/moodledata/behat_dump
141+
retention-days: 7
142+
if-no-files-found: ignore
143+
144+
- name: Mark cancelled jobs as failed.
145+
if: ${{ cancelled() }}
146+
run: exit 1

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
gpl.txt
22
bu-git.xml
3-
**.DS_Store
3+
**.DS_Store
4+
5+
quizzes/configuration.ini

classes/MoodleConfiguration.class.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ public function get($key) {
4848
return $quizzeshandurl;
4949
}
5050
}
51+
if ($key == 'quizzes.calc.url') {
52+
$quizzescalcurl = get_config('qtype_wq', 'quizzescalcurl');
53+
if (isset($quizzescalcurl) && !empty($quizzescalcurl)) {
54+
return $quizzescalcurl;
55+
}
56+
}
57+
if ($key == 'quizzes.graph.url') {
58+
$quizzesgraphurl = get_config('qtype_wq', 'quizzesgraphurl');
59+
if (isset($quizzesgraphurl) && !empty($quizzesgraphurl)) {
60+
return $quizzesgraphurl;
61+
}
62+
}
5163
if ($key == 'quizzes.wirislauncher.url') {
5264
$quizzeswirislauncherurl = get_config('qtype_wq', 'quizzeswirislauncherurl');
5365
if (isset($quizzeswirislauncherurl) && !empty($quizzeswirislauncherurl)) {
@@ -72,7 +84,12 @@ public function get($key) {
7284
if ($key == 'quizzes.httpproxy.pass' && $moodleproxyenabled && $proxypassenabled) {
7385
return $CFG->proxypassword;
7486
}
75-
87+
if ($key == 'quizzes.maxconnections') {
88+
$maxconnectionsdisabled = get_config('qtype_wq', 'maxconnections_disabled');
89+
if ($maxconnectionsdisabled) {
90+
return '-1';
91+
}
92+
}
7693
if ($key == 'quizzes.cache.dir') {
7794
return $CFG->dataroot . '/filter/wiris/cache';
7895
}

classes/moodlelockprovider.class.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,15 @@ class moodlelockprovider {
4545
* **/
4646
// @codingStandardsIgnoreStart
4747
public function getLock($id) {
48-
// @codingStandardsIgnoreStop
48+
// @codingStandardsIgnoreStop
4949
$timeout = 10;
5050

5151
$resource = $id;
5252

5353
$lockfactory = new \core\lock\db_record_lock_factory('qtype_wq_persistenvariables');
5454
$lock = $lockfactory->get_lock($resource, $timeout);
5555
if ($lock === false) {
56-
$lock->release();
57-
throw new moodle_exception('couldnotaquirelock', 'qtype_wq', '','Could not acquire lock');
56+
throw new moodle_exception('couldnotaquirelock', 'qtype_wq', '', 'Could not acquire lock');
5857
}
5958

6059
return new moodlelock($lock);

db/upgrade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function xmldb_qtype_wq_upgrade($oldversion) {
7777

7878
if ($oldversion < 2017011300) {
7979

80-
// Define table qtype_wq_variables to be created.
80+
// Define table qtype_wq_variables to be created.
8181
$table = new xmldb_table('qtype_wq_variables');
8282

8383
// Adding fields to table qtype_wq_variables.
@@ -102,12 +102,12 @@ function xmldb_qtype_wq_upgrade($oldversion) {
102102

103103
function get_entities_table($table, $flags) {
104104
if ((version_compare(PHP_VERSION, '5.3.4') >= 0)) {
105-
return get_html_translation_taquestionble($table, $flags, 'UTF-8');
105+
return get_html_translation_table($table, $flags, 'UTF-8');
106106
} else {
107107
$isotable = get_html_translation_table($table, $flags);
108108
$utftable = array();
109109
foreach ($isotable as $key => $value) {
110-
$utftable[utf8_encode($key)] = utf8_encode($value);
110+
$utftable[mb_convert_encoding($key, 'UTF-8', 'ISO-8859-1')] = mb_convert_encoding($value, 'UTF-8', 'ISO-8859-1');
111111
}
112112
return $utftable;
113113
}

edit_wq_form.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
class qtype_wq_edit_form extends question_edit_form {
2121
protected $base;
2222

23-
2423
public function __construct($base, $submiturl, $question, $category, $contexts, $formeditable) {
2524
// TODO: remove all but $base function parameters.
2625

@@ -56,19 +55,29 @@ protected function definition_inner($mform) {
5655
$mform->addElement('hidden', 'wirislang', current_language(), array('class' => 'wirislang'));
5756
$mform->setType('wirislang', PARAM_TEXT);
5857

59-
// TODO: Delete this if when all questions are wq!
6058
if (isset($this->question->wirisquestion)) {
6159
$program = $this->question->wirisquestion->serialize();
6260
} else {
63-
if (!empty($this->question->id)) {
64-
$wiris = $DB->get_record('qtype_wq', array('question' => $this->question->id));
65-
}
66-
if (!empty($wiris)) {
67-
// Existing question.
68-
$program = $wiris->xml;
69-
} else {
61+
// If the wirisquestion is not already loaded in memory, load it from the DB directly.
62+
if (empty($this->question->id)) {
7063
// New question.
7164
$program = '<question/>';
65+
} else {
66+
// Existing question.
67+
$wiris = $DB->get_record('qtype_wq', array('question' => $this->question->id));
68+
if (empty($wiris)) {
69+
// Corrupted question.
70+
$corruptwarning =
71+
$mform->createElement(
72+
'html',
73+
'<div class="wiriscorruptquestionedit">' . get_string('corruptquestion_edit', 'qtype_wq') . '</div>'
74+
);
75+
$mform->insertElementBefore($corruptwarning, 'generalheader');
76+
$program = '<question/>';
77+
} else {
78+
// Question found in the DB.
79+
$program = $wiris->xml;
80+
}
7281
}
7382
}
7483

info.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,6 @@ function wrs_createtablerow($testname, $reporttext, $solutionlink, $condition) {
370370

371371
$output .= html_writer::start_tag('tr', array('class' => 'wrs_filter wrs_plugin'));
372372

373-
require_once($CFG->dirroot . '/lib/editor/tinymce/lib.php');
374-
$tinyeditor = new tinymce_texteditor();
375-
376373
$rb = com_wiris_quizzes_api_Quizzes::getInstance();
377374

378375
$questionxml = '<question><wirisCasSession>&lt;session lang=&quot;en&quot; version=&quot;2.0&quot;' .

lang/ca/qtype_wq.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
$string['cachedir'] = 'CACHE_DIR:';
7575
$string['serviceurl'] = 'SERVICE_URL:';
7676
$string['wqsummary'] = 'This adds a generic Wiris Quizzes question. Only for test purpose. It will be hide from here.';
77-
$string['wirisquestionincorrect'] = 'Sorry! The system can not generate one of the questions of the quiz. <br />Maybe there is a temporary connection problem right now. <br />Maybe the question algorithm has a bug, and fails sometimes. <br />Maybe it will fail always. <br />Don\'t panic... <br />You can retry the quiz, without penalty, just clicking Continue. <br />You can also tell the Teachers that there is an issue with the question titled: \'{$a->questionname}\'';
77+
$string['wirisquestionincorrect'] = 'El sistema no ha pogut generar una de les preguntes del qüestionari. Potser és un problema de connexió temporal, o que hi ha un problema en la configuració de la pregunta. Pots tornar a intentar aquest qüestionari sense cap penalització clicant Continuar. Si aquest error persisteix, pots dir als teus professors que hi ha un problema amb la pregunta {$a->questionname}';
7878
$string['wirisquizzeserror'] = 'Sorry! There was an error in Wiris Quizzes.';
7979
$string['failedtoloadwirisquizzesfromxml'] = 'Failed to load Wiris Quizzes XML definition for question id';
8080
$string['connectionsettings'] = 'Connection settings';
@@ -95,3 +95,6 @@
9595
$string['privacy:metadata:qtype_wq:xml'] = 'Wiris Quizzes Question XML';
9696

9797
$string['auxiliar_text'] = 'Escriviu un raonament opcional per a la vostra resposta:';
98+
99+
$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.';
100+
$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.';

lang/en/qtype_wq.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
$string['wq'] = 'Wiris Quizzes';
1818
$string['pluginname'] = 'Wiris Quizzes';
1919
$string['access_provider_enabled'] = 'Access control';
20-
$string['access_provider_enabled_help'] = 'If enabled ony authenticated users can access Wiris services.';
20+
$string['access_provider_enabled_help'] = 'If enabled, only authenticated users can access Wiris services.';
2121
$string['pluginnamesummary'] = '';
2222
$string['wq_help'] = 'Generic Wiris Quizzes Help';
2323
$string['editingwq'] = 'Editing a generic Wiris Quizzes question';
@@ -74,7 +74,7 @@
7474
$string['cachedir'] = 'CACHE_DIR:';
7575
$string['serviceurl'] = 'SERVICE_URL:';
7676
$string['wqsummary'] = 'This adds a generic Wiris Quizzes question. Only for test purpose. It will be hide from here.';
77-
$string['wirisquestionincorrect'] = 'Sorry! The system can not generate one of the questions of the quiz. <br />Maybe there is a temporary connection problem right now. <br />Maybe the question algorithm has a bug, and fails sometimes. <br />Maybe it will fail always. <br />Don\'t panic... <br />You can retry the quiz, without penalty, just clicking Continue. <br />You can also tell the Teachers that there is an issue with the question titled: \'{$a->questionname}\'';
77+
$string['wirisquestionincorrect'] = 'Sorry! The system can not generate one of the questions of the quiz. Maybe there is a temporary connection problem right now, or there is a problem with how the question is set up. You can retry the quiz, without penalty, just clicking Continue. If this error persists, you can tell your teachers that there is an issue with the question {$a->questionname}.';
7878
$string['wirisquizzeserror'] = 'Sorry! There was an error in Wiris Quizzes.';
7979
$string['failedtoloadwirisquizzesfromxml'] = 'Failed to load Wiris Quizzes XML definition for question id';
8080
$string['connectionsettings'] = 'Connection settings';
@@ -97,11 +97,29 @@
9797

9898
$string['compatibility_settings'] = 'Compatibility settings';
9999
$string['compatibility_settings_text'] = '';
100-
$string['filtercodes_compatibility_enabled'] = 'Compatibility with Filter Codes filter';
100+
$string['filtercodes_compatibility_enabled'] = 'FilterCodes compatibility';
101101
$string['filtercodes_compatibility_enabled_help'] = 'The Filter Codes filter is not compatible with certain WirisQuizzes features if the option "Escape tags" is selected. Enabling this option solves the compatibility problem. Do not enable it in any other situation.';
102102

103103
$string['privacy:metadata:qtype_wq'] = 'Information about user\'s correct answer for a given WirisQuizzes question type';
104104
$string['privacy:metadata:qtype_wq:question'] = 'Wiris Quizzes question type id';
105105
$string['privacy:metadata:qtype_wq:xml'] = 'Wiris Quizzes Question XML';
106106

107107
$string['auxiliar_text'] = 'Write an optional reasoning for your answer:';
108+
109+
$string['log_server_errors'] = 'Log server errors';
110+
$string['log_server_errors_help'] = 'Extensively log errors coming from the WirisQuizzes service and other errors occurred when processing WirisQuizzes questions to your server logs. This might cause an increase in the size of your log files but might help the Wiris team troubleshoot issues.';
111+
112+
$string['corruptquestion_edit'] = 'WARNING: This question was corrupted and its mathematical data was lost from the database. We have tried to restore everything we could, but you need to rebuild the CalcMe algorithm if your question had one, and any custom input options and validation options. Contact with your administrator for further information.';
113+
$string['corruptquestion_attempt'] = 'The question {$a->questionname} was corrupted and could not be loaded. Please contact with your teacher so they can fix it.';
114+
115+
$string['quizzescalcurl'] = 'CalcMe URL';
116+
$string['quizzescalcurl_help'] = 'URL where to load the CalcMe web app.';
117+
118+
$string['quizzesgraphurl'] = 'Graph tool URL';
119+
$string['quizzesgraphurl_help'] = 'URL where to load the tool used for graph rendering and graphical answer questions.';
120+
121+
$string['maxconnections_disabled'] = 'Disable max connections protection';
122+
$string['maxconnections_disabled_help'] = 'Disables the protection mechanism that limits the number of concurrent connections to the WirisQuizzes server. Only enable this setting if your usage of WirisQuizzes reaches the concurrency limit and be mindful that your infrastructure will need to handle the increased number of concurrent connections to our server.';
123+
124+
$string['mathjax_compatibity'] = 'MathJax compatibility';
125+
$string['mathjax_compatibity_help'] = '(Experimental) Enables compatibility with MathJax. This option is only needed if you want to use MathJax instead of MathType to render LaTeX formulas in WirisQuizzes questions. Formulas created with MathType or WirisQuizzes will still be rendered by MathType. For the best performance, we recommend using MathType to render all formulas.';

0 commit comments

Comments
 (0)