Browse files

MDL-28684 QE2 upgrade: recognize empty answer in multichoice questions

  • Loading branch information...
1 parent 24654d9 commit ec5f40b1a9f858980a17bfcb96fad6a184b6b135 @bostelm bostelm committed Aug 16, 2011
View
2 question/engine/upgrade/behaviourconverters.php
@@ -191,7 +191,7 @@ protected function process0($step, $state) {
$this->logger->log_assumption("Ignoring bogus state in attempt at question {$state->question}");
$this->sequencenumber = 0;
$this->qa->steps = array();
- } else if ($state->answer == '') {
+ } else if ($this->qtypeupdater->is_blank_answer($state)) {
$this->logger->log_assumption("Ignoring second start state with blank answer in attempt at question {$state->question}");
return;
} else {
View
4 question/engine/upgrade/upgradelib.php
@@ -568,6 +568,10 @@ public function compare_answers($answer1, $answer2) {
return $answer1 == $answer2;
}
+ public function is_blank_answer($state) {
+ return $state->answer == '';
+ }
+
public abstract function right_answer();
public abstract function response_summary($state);
public abstract function was_answered($state);
View
7 question/type/multichoice/db/upgradelib.php
@@ -39,6 +39,13 @@
class qtype_multichoice_qe2_attempt_updater extends question_qtype_attempt_updater {
protected $order;
+ public function is_blank_answer($state) {
+ // blank multichoice answers are not empty strings, they rather end in a colon
+ $a = $state->answer;
+ $empty = (substr($a, strlen($a) - 1) == ':');
+ return $empty;
+ }
+
public function right_answer() {
if ($this->question->options->single) {
foreach ($this->question->options->answers as $ans) {

0 comments on commit ec5f40b

Please sign in to comment.