Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

… mode. Merged from OU Moodle.
  • Loading branch information...
commit e1e7d03480c2a4af969a3c12a2e9d6adc0e45142 1 parent 7ee50b8
tjhunt authored
Showing with 11 additions and 6 deletions.
  1. +11 −6 question/type/truefalse/questiontype.php
View
17 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,8 +198,8 @@ 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);
}
@@ -202,7 +207,7 @@ function print_question_formulation_and_controls(&$question, &$state,
}
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;
Please sign in to comment.
Something went wrong with that request. Please try again.