Skip to content

Commit fa90254

Browse files
Merge pull request #90 from wiris/v4.11.6
V4.11.6
2 parents 87c0052 + eeba6a0 commit fa90254

File tree

8 files changed

+51
-25
lines changed

8 files changed

+51
-25
lines changed

edit_wq_form.php

Lines changed: 14 additions & 8 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

@@ -60,15 +59,21 @@ protected function definition_inner($mform) {
6059
if (isset($this->question->wirisquestion)) {
6160
$program = $this->question->wirisquestion->serialize();
6261
} 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 {
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 = $mform->createElement('html', '<div class="wiriscorruptquestionedit">' . get_string('corruptquestion_edit', 'qtype_wq') .'</div');
71+
$mform->insertElementBefore($corruptwarning, 'generalheader');
72+
$program = '<question/>';
73+
} else {
74+
// Happy path
75+
$program = $wiris->xml;
76+
}
7277
}
7378
}
7479

@@ -85,6 +90,7 @@ protected function definition_inner($mform) {
8590
$defaultvalues = array();
8691
$defaultvalues['wirisquestion'] = $program;
8792
$mform->setDefaults($defaultvalues);
93+
8894
}
8995
public function set_data($question) {
9096
$this->base->set_data($question);

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: 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'] = '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';
@@ -108,3 +108,6 @@
108108

109109
$string['log_server_errors'] = 'Log server errors';
110110
$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.';

lang/es/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 podido generar una de las preguntas del cuestionario. Quizá es un problema temporal de conexión, pero también puede ser que haya un problema con la configuración de la pregunta. Puedes reintentar el cuestionario sin penalización apretando Continuar. Si este error persiste, contacta con tus profesores para notificarles que hay un problema con 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';
@@ -105,3 +105,6 @@
105105
$string['compatibility_settings_text'] = '';
106106
$string['filtercodes_compatibility_enabled'] = 'Compatibilidad con el filtro Filter Codes';
107107
$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.';
108+
109+
$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.';
110+
$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.';

question.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ class qtype_wq_question extends question_graded_automatically {
4444
*/
4545
public $auxiliartextfieldlines = 10;
4646

47+
/**
48+
* @var bool
49+
* Whether this question is corrupt and its wirisquestion was removed from the database.
50+
*/
51+
public $corrupt = false;
52+
4753
public function __construct(question_definition $base = null) {
4854
$this->base = $base;
4955
}
@@ -59,6 +65,13 @@ public function __construct(question_definition $base = null) {
5965
* **/
6066
public function start_attempt(question_attempt_step $step, $variant) {
6167
global $USER;
68+
69+
if ($this->corrupt) {
70+
$a = new stdClass();
71+
$a->questionname = $this->name;
72+
throw new moodle_exception('corruptquestion_attempt', 'qtype_wq', '', $a);
73+
}
74+
6275
$this->base->start_attempt($step, $variant);
6376

6477
// Get variables from Wiris Quizzes service.

questiontype.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ protected function make_question_instance($questiondata) {
101101
protected function initialise_question_instance(question_definition $question, $questiondata) {
102102
global $CFG;
103103

104+
/** @var qtype_wq_question $question */
104105
$this->base->initialise_question_instance($question->base, $questiondata);
105106

106107
$question->id = &$question->base->id;
@@ -135,10 +136,14 @@ protected function initialise_question_instance(question_definition $question, $
135136
// Load question xml into Wiris Quizzes API question object.
136137
if (empty($question->parent)) {
137138
$builder = com_wiris_quizzes_api_Quizzes::getInstance();
138-
$question->wirisquestion = $builder->readQuestion($questiondata->options->wirisquestion);
139+
if (isset($questiondata->options->wirisquestion)) {
140+
$question->wirisquestion = $builder->readQuestion($questiondata->options->wirisquestion);
141+
} else {
142+
$question->wirisquestion = $builder->newQuestion();
143+
$question->corrupt = true;
144+
}
139145
}
140146
}
141-
142147
// This method has to be overriden in each real question.
143148
public function menu_name() {
144149
// Include JavaScript Hack to modify question chooser.

step.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,7 @@
1717

1818
/*
1919
* Class used to store information in the question attempt step data
20-
*/
21-
22-
/**
23-
* Description of step
2420
*
25-
* @author dani
26-
*/
27-
28-
/**
2921
* This class is useful for:
3022
* - No intentar avaluar una pregunta si ha fallat en 3 intents seguits
3123
* en les mateixes condicions. Útil en exàmens.
@@ -38,7 +30,8 @@
3830
class qtype_wirisstep {
3931
const MAX_ATTEMPS_SHORTANSWER_WIRIS = 5;
4032

41-
private ?question_attempt_step $step;
33+
/** @var ?question_attempt_step */
34+
private $step;
4235
private $stepid;
4336
private $extraprefix;
4437

version.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
defined('MOODLE_INTERNAL') || die();
1818

19-
$plugin->version = 2024032205;
19+
$plugin->version = 2024032206;
2020
$plugin->requires = 2015111600; // Moodle 3.0.
21-
$plugin->release = '4.11.5';
21+
$plugin->release = '4.11.6';
2222
$plugin->maturity = MATURITY_STABLE;
2323
$plugin->component = 'qtype_wq';
2424
$plugin->dependencies = array(
25-
'filter_wiris' => 2024100700
25+
'filter_wiris' => 2024110400
2626
);

0 commit comments

Comments
 (0)