From 613aff5053df60b189fa4fa2e9c6f7c16e15e24d Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Wed, 4 Aug 2010 17:54:55 +0000 Subject: [PATCH] qtype_truefalse MDL-22658 questions get marked as answered even when an answer has not been selected. --- question/type/truefalse/questiontype.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/question/type/truefalse/questiontype.php b/question/type/truefalse/questiontype.php index 87ae461e071..9c2b895e0c0 100644 --- a/question/type/truefalse/questiontype.php +++ b/question/type/truefalse/questiontype.php @@ -110,6 +110,17 @@ class question_truefalse_qtype extends default_questiontype { return true; } + function compare_responses($question, $state, $teststate) { + if (isset($state->responses['']) && isset($teststate->responses[''])) { + return $state->responses[''] === $teststate->responses['']; + } else if (isset($teststate->responses['']) && $teststate->responses[''] === '' && + !isset($state->responses[''])) { + // Nothing selected in the past, and nothing selected now. + return true; + } + return false; + } + function get_correct_responses(&$question, &$state) { // The correct answer is the one which gives full marks foreach ($question->options->answers as $answer) {