From 8940a60ccf987e63fd3ad4b285a014602c01e7ac Mon Sep 17 00:00:00 2001 From: Manuel Cagigas Date: Tue, 12 Dec 2017 08:19:39 +0100 Subject: [PATCH] 3.59.0 stable version --- question.php | 13 ++++++++++++- renderer.php | 4 ++-- version.php | 6 +++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/question.php b/question.php index 048b39d..a48de64 100644 --- a/question.php +++ b/question.php @@ -77,6 +77,14 @@ public function apply_attempt_state(question_attempt_step $step) { parent::apply_attempt_state($step); $this->set_wirisquestioninstance(); $this->load_step($step); + foreach ($this->subquestions as $subquestion) { + if ($subquestion->get_type_name() == 'shortanswerwiris') { + // This is a regrade because is the only case where this function is + // called with the first step instead of start_attempt. So invalidate + // cached matching answers. + $subquestion->step->set_var('_response_hash', '0'); + } + } } private function set_shortanswer_matching_answers(array $response) { @@ -204,7 +212,10 @@ private function set_shortanswer_matching_answers(array $response) { $substep = $this->get_substep(null, $i); $subresp = $substep->filter_array($response); $subresphash = md5($subresp['answer']); - $subquestion->step->set_var('_response_hash', $subresphash, true); + // This is a regrade because is the only case where this function is + // called with the first step instead of start_attempt. So invalidate + // cached matching answers. + $subquestion->step->set_var('_response_hash', '0'); $subquestion->step->set_var('_matching_answer', $matchinganswerid, true); $numsubq++; } diff --git a/renderer.php b/renderer.php index f577c1f..af84628 100644 --- a/renderer.php +++ b/renderer.php @@ -137,7 +137,7 @@ public function subquestion(question_attempt $qa, question_display_options $opti } } else { foreach ($subq->answers as $ans) { - $size = max($size, core_text::strlen(trim($ans->answer))); + $size = max($size, core_text::strlen(trim($qa->get_question()->expand_variables_text($ans->answer)))); } } } else { @@ -151,7 +151,7 @@ public function subquestion(question_attempt $qa, question_display_options $opti } } else { foreach ($subq->answers as $ans) { - $size = max($size, textlib::strlen(trim($ans->answer))); + $size = max($size, textlib::strlen(trim($qa->get_question()->expand_variables_text($ans->answer)))); } } } diff --git a/version.php b/version.php index 74cd632..8279bb0 100644 --- a/version.php +++ b/version.php @@ -16,11 +16,11 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2017112300; -$plugin->release = '3.58.0.1029'; +$plugin->version = 2017121200; +$plugin->release = '3.59.0.1031'; $plugin->requires = 2011060313; $plugin->maturity = MATURITY_STABLE; $plugin->component = 'qtype_multianswerwiris'; $plugin->dependencies = array ( - 'qtype_wq' => 2017112300 + 'qtype_wq' => 2017121200 );