Permalink
Browse files

Notices from T/F question is you submit without answering in adaptive…

… mode. Merged from OU Moodle.
  • Loading branch information...
tjhunt
tjhunt committed Jun 19, 2007
1 parent 7ee50b8 commit e1e7d03480c2a4af969a3c12a2e9d6adc0e45142
Showing with 11 additions and 6 deletions.
  1. +11 −6 question/type/truefalse/questiontype.php
@@ -161,8 +161,13 @@ function print_question_formulation_and_controls(&$question, &$state,
$falsefeedbackimg = '';
// Work out which radio button to select (if any)
- $truechecked = ($state->responses[''] == $trueanswer->id) ? ' checked="checked"' : '';
- $falsechecked = ($state->responses[''] == $falseanswer->id) ? ' checked="checked"' : '';
+ if (isset($state->responses[''])) {
+ $response = $state->responses[''];
+ } else {
+ $response = '';
+ }
+ $truechecked = ($response == $trueanswer->id) ? ' checked="checked"' : '';
+ $falsechecked = ($response == $falseanswer->id) ? ' checked="checked"' : '';
// Work out visual feedback for answer correctness.
if ($options->feedback) {
@@ -173,7 +178,7 @@ function print_question_formulation_and_controls(&$question, &$state,
}
}
if ($options->feedback || $options->correct_responses) {
- if (isset($answers[$state->responses['']])) {
+ if (isset($answers[$response])) {
$truefeedbackimg = question_get_feedback_image($trueanswer->fraction, !empty($truechecked) && $options->feedback);
$falsefeedbackimg = question_get_feedback_image($falseanswer->fraction, !empty($falsechecked) && $options->feedback);
}
@@ -193,16 +198,16 @@ function print_question_formulation_and_controls(&$question, &$state,
. s($falseanswer->answer) . '</label>';
$feedback = '';
- if ($options->feedback and isset($answers[$state->responses['']])) {
- $chosenanswer = $answers[$state->responses['']];
+ if ($options->feedback and isset($answers[$response])) {
+ $chosenanswer = $answers[$response];
$feedback = format_text($chosenanswer->feedback, true, $formatoptions, $cmoptions->course);
}
include("$CFG->dirroot/question/type/truefalse/display.html");
}
function grade_responses(&$question, &$state, $cmoptions) {
- if (isset($question->options->answers[$state->responses['']])) {
+ if (isset($state->responses['']) && isset($question->options->answers[$state->responses['']])) {
$state->raw_grade = $question->options->answers[$state->responses['']]->fraction * $question->maxgrade;
} else {
$state->raw_grade = 0;

0 comments on commit e1e7d03

Please sign in to comment.