Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V4.11.6 #90

Merged
merged 6 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions edit_wq_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
class qtype_wq_edit_form extends question_edit_form {
protected $base;


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

Expand Down Expand Up @@ -60,15 +59,21 @@ protected function definition_inner($mform) {
if (isset($this->question->wirisquestion)) {
$program = $this->question->wirisquestion->serialize();
} else {
if (!empty($this->question->id)) {
$wiris = $DB->get_record('qtype_wq', array('question' => $this->question->id));
}
if (!empty($wiris)) {
// Existing question.
$program = $wiris->xml;
} else {
if (empty($this->question->id)) {
// New question.
$program = '<question/>';
} else {
// Existing question.
$wiris = $DB->get_record('qtype_wq', array('question' => $this->question->id));
if (empty($wiris)) {
// Corrupted question
$corruptwarning = $mform->createElement('html', '<div class="wiriscorruptquestionedit">' . get_string('corruptquestion_edit', 'qtype_wq') .'</div');
$mform->insertElementBefore($corruptwarning, 'generalheader');
$program = '<question/>';
} else {
// Happy path
$program = $wiris->xml;
}
}
}

Expand All @@ -85,6 +90,7 @@ protected function definition_inner($mform) {
$defaultvalues = array();
$defaultvalues['wirisquestion'] = $program;
$mform->setDefaults($defaultvalues);

}
public function set_data($question) {
$this->base->set_data($question);
Expand Down
5 changes: 4 additions & 1 deletion lang/ca/qtype_wq.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
$string['cachedir'] = 'CACHE_DIR:';
$string['serviceurl'] = 'SERVICE_URL:';
$string['wqsummary'] = 'This adds a generic Wiris Quizzes question. Only for test purpose. It will be hide from here.';
$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}\'';
$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}';
$string['wirisquizzeserror'] = 'Sorry! There was an error in Wiris Quizzes.';
$string['failedtoloadwirisquizzesfromxml'] = 'Failed to load Wiris Quizzes XML definition for question id';
$string['connectionsettings'] = 'Connection settings';
Expand All @@ -95,3 +95,6 @@
$string['privacy:metadata:qtype_wq:xml'] = 'Wiris Quizzes Question XML';

$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.';
5 changes: 4 additions & 1 deletion lang/en/qtype_wq.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
$string['cachedir'] = 'CACHE_DIR:';
$string['serviceurl'] = 'SERVICE_URL:';
$string['wqsummary'] = 'This adds a generic Wiris Quizzes question. Only for test purpose. It will be hide from here.';
$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}\'';
$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}.';
$string['wirisquizzeserror'] = 'Sorry! There was an error in Wiris Quizzes.';
$string['failedtoloadwirisquizzesfromxml'] = 'Failed to load Wiris Quizzes XML definition for question id';
$string['connectionsettings'] = 'Connection settings';
Expand Down Expand Up @@ -108,3 +108,6 @@

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

$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.';
$string['corruptquestion_attempt'] = 'The question {$a->questionname} was corrupted and could not be loaded. Please contact with your teacher so they can fix it.';
5 changes: 4 additions & 1 deletion lang/es/qtype_wq.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
$string['cachedir'] = 'CACHE_DIR:';
$string['serviceurl'] = 'SERVICE_URL:';
$string['wqsummary'] = 'This adds a generic Wiris Quizzes question. Only for test purpose. It will be hide from here.';
$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}\'';
$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}.';
$string['wirisquizzeserror'] = 'Sorry! There was an error in Wiris Quizzes.';
$string['failedtoloadwirisquizzesfromxml'] = 'Failed to load Wiris Quizzes XML definition for question id';
$string['connectionsettings'] = 'Connection settings';
Expand Down Expand Up @@ -105,3 +105,6 @@
$string['compatibility_settings_text'] = '';
$string['filtercodes_compatibility_enabled'] = 'Compatibilidad con el filtro Filter Codes';
$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.';
13 changes: 13 additions & 0 deletions question.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ class qtype_wq_question extends question_graded_automatically {
*/
public $auxiliartextfieldlines = 10;

/**
* @var bool
* Whether this question is corrupt and its wirisquestion was removed from the database.
*/
public $corrupt = false;

public function __construct(question_definition $base = null) {
$this->base = $base;
}
Expand All @@ -59,6 +65,13 @@ public function __construct(question_definition $base = null) {
* **/
public function start_attempt(question_attempt_step $step, $variant) {
global $USER;

if ($this->corrupt) {
$a = new stdClass();
$a->questionname = $this->name;
throw new moodle_exception('corruptquestion_attempt', 'qtype_wq', '', $a);
}

$this->base->start_attempt($step, $variant);

// Get variables from Wiris Quizzes service.
Expand Down
9 changes: 7 additions & 2 deletions questiontype.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ 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);

$question->id = &$question->base->id;
Expand Down Expand Up @@ -135,10 +136,14 @@ protected function initialise_question_instance(question_definition $question, $
// Load question xml into Wiris Quizzes API question object.
if (empty($question->parent)) {
$builder = com_wiris_quizzes_api_Quizzes::getInstance();
$question->wirisquestion = $builder->readQuestion($questiondata->options->wirisquestion);
if (isset($questiondata->options->wirisquestion)) {
$question->wirisquestion = $builder->readQuestion($questiondata->options->wirisquestion);
} else {
$question->wirisquestion = $builder->newQuestion();
$question->corrupt = true;
}
}
}

// This method has to be overriden in each real question.
public function menu_name() {
// Include JavaScript Hack to modify question chooser.
Expand Down
11 changes: 2 additions & 9 deletions step.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,7 @@

/*
* Class used to store information in the question attempt step data
*/

/**
* Description of step
*
* @author dani
*/

/**
* This class is useful for:
* - No intentar avaluar una pregunta si ha fallat en 3 intents seguits
* en les mateixes condicions. Útil en exàmens.
Expand All @@ -38,7 +30,8 @@
class qtype_wirisstep {
const MAX_ATTEMPS_SHORTANSWER_WIRIS = 5;

private ?question_attempt_step $step;
/** @var ?question_attempt_step */
private $step;
private $stepid;
private $extraprefix;

Expand Down
6 changes: 3 additions & 3 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

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

$plugin->version = 2024032205;
$plugin->version = 2024032206;
$plugin->requires = 2015111600; // Moodle 3.0.
$plugin->release = '4.11.5';
$plugin->release = '4.11.6';
$plugin->maturity = MATURITY_STABLE;
$plugin->component = 'qtype_wq';
$plugin->dependencies = array(
'filter_wiris' => 2024100700
'filter_wiris' => 2024110400
);
Loading