Skip to content

Commit

Permalink
Merge pull request #45 from wiris/v4.11.4
Browse files Browse the repository at this point in the history
v4.11.4
  • Loading branch information
ptorrent-at-wiris authored Sep 30, 2024
2 parents b59a58d + 40d0b65 commit 4d3d157
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 6 deletions.
16 changes: 15 additions & 1 deletion edit_multianswerwiris_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@


class qtype_multianswerwiris_edit_form extends qtype_wq_edit_form {

protected function definition_inner($mform) {
global $CFG;
parent::definition_inner($mform);
Expand All @@ -47,3 +46,18 @@ public function qtype() {
return 'multianswerwiris';
}
}

class qtype_multianswer_edit_form_helper extends qtype_multianswer_edit_form {
protected function definition_inner($mform) {
// Remove wiris particle from subquestion qtypes so the multianswer form does not think
// we are changing the qtypes when we are not actually doing it.
foreach ($this->savedquestiondisplay->options->questions as $subq) {
$qtype = $subq->qtype;
if (substr($qtype, -5) == 'wiris') {
$subq->qtype = substr($qtype, 0, strlen($qtype) - 5);
}
}

parent::definition_inner($mform);
}
}
21 changes: 21 additions & 0 deletions question.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,4 +392,25 @@ public function summarise_response(array $response) {
// data.
return get_string('contentnotviewable', 'qtype_multianswerwiris');
}


public function update_attempt_state_data_for_new_version(
question_attempt_step $oldstep,
question_definition $oldquestion
) {
// Save global state data to prevent it from being overwritten.
$qi = $oldstep->get_qt_var('_qi');
$gc = $oldstep->get_qt_var('_gc');

$result = parent::update_attempt_state_data_for_new_version($oldstep, $oldquestion);

if (isset($qi)) {
$result['_qi'] = $qi;
}
if (isset($gc)) {
$result['_gc'] = $gc;
}

return $result;
}
}
10 changes: 8 additions & 2 deletions questiontype.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,13 @@ public function save_question($authorizedquestion, $form) {
$question->id = $authorizedquestion->id;
}

$question->category = $authorizedquestion->category;
global $CFG;
if ($CFG->version >= 2022041900 /* Moodle 4.0.0 */) {
$question->category = $form->category;
} else {
$question->category = $authorizedquestion->category;
}

$form->defaultmark = $question->defaultmark;
$form->questiontext = $question->questiontext;
$form->questiontextformat = 0;
Expand All @@ -160,7 +166,7 @@ public function save_question($authorizedquestion, $form) {
public function create_editing_form($submiturl, $question, $category, $contexts, $formeditable) {
global $CFG;
require_once($CFG->dirroot . '/question/type/multianswerwiris/edit_multianswerwiris_form.php');
$wform = $this->base->create_editing_form($submiturl, $question, $category, $contexts, $formeditable);
$wform = new qtype_multianswer_edit_form_helper($submiturl, $question, $category, $contexts, $formeditable);
return new qtype_multianswerwiris_edit_form($wform, $submiturl, $question, $category, $contexts, $formeditable);
}

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 = 2024032203;
$plugin->version = 2024032204;
$plugin->requires = 2015111600; // Moodle 3.0.
$plugin->release = '4.11.3';
$plugin->release = '4.11.4';
$plugin->maturity = MATURITY_STABLE;
$plugin->component = 'qtype_multianswerwiris';
$plugin->dependencies = array(
'qtype_wq' => 2024032203
'qtype_wq' => 2024032204
);

0 comments on commit 4d3d157

Please sign in to comment.