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 );