diff --git a/question.php b/question.php index a48de64..f04439b 100644 --- a/question.php +++ b/question.php @@ -82,7 +82,9 @@ public function apply_attempt_state(question_attempt_step $step) { // 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'); + if ($subquestion->step->is_first_step()) { + $subquestion->step->set_var('_response_hash', '0'); + } } } } @@ -212,10 +214,7 @@ private function set_shortanswer_matching_answers(array $response) { $substep = $this->get_substep(null, $i); $subresp = $substep->filter_array($response); $subresphash = md5($subresp['answer']); - // 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('_response_hash', $subresphash, true); $subquestion->step->set_var('_matching_answer', $matchinganswerid, true); $numsubq++; } diff --git a/questiontype.php b/questiontype.php index 9842f83..8c42ca2 100644 --- a/questiontype.php +++ b/questiontype.php @@ -28,17 +28,8 @@ public function __construct() { public function save_question_options($question) { global $DB; - // Delete old subquestions. The Moodle implementation is somewhat more - // efficient because it reuses the questions, but we do that way so we - // can call base method. - - $oldidsseq = $DB->get_field('question_multianswer', 'sequence', array('question' => $question->id)); - if (!empty($oldidsseq)) { - $oldids = explode(',', $oldidsseq); - foreach ($oldids as $id) { - question_delete_question($id); - } - } + // We don't delete old subquestions because it cause + // a new ids on BD that throw error on regrade. parent::save_question_options($question); } diff --git a/version.php b/version.php index 8279bb0..e711d36 100644 --- a/version.php +++ b/version.php @@ -16,11 +16,11 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2017121200; -$plugin->release = '3.59.0.1031'; +$plugin->version = 2018020600; +$plugin->release = '3.61.0.1034'; $plugin->requires = 2011060313; $plugin->maturity = MATURITY_STABLE; $plugin->component = 'qtype_multianswerwiris'; $plugin->dependencies = array ( - 'qtype_wq' => 2017121200 + 'qtype_wq' => 2018020600 );