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.4 #45

Merged
merged 3 commits into from
Sep 30, 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
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
);
Loading