From 1b16ecd1ca92b5215fd1dd2494eea114824b5c13 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Wed, 4 Apr 2007 18:01:36 +0000 Subject: [PATCH] MDL-9208 - Only hightlight the correct answer if that option is set. --- question/type/match/questiontype.php | 2 +- question/type/multianswer/questiontype.php | 2 +- question/type/multichoice/questiontype.php | 18 ++++++++++-------- question/type/truefalse/questiontype.php | 18 +++++++++++------- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/question/type/match/questiontype.php b/question/type/match/questiontype.php index 43b71c1bcb..8c5e97e607 100644 --- a/question/type/match/questiontype.php +++ b/question/type/match/questiontype.php @@ -294,7 +294,7 @@ class question_match_qtype extends default_questiontype { $correctresponse = 0; } - if ($options->correct_responses && $response) { + if ($options->feedback && $response) { $a->class = question_get_feedback_class($correctresponse); $a->feedbackimg = question_get_feedback_image($correctresponse); } diff --git a/question/type/multianswer/questiontype.php b/question/type/multianswer/questiontype.php index 57539b8f32..78f78ca2b2 100644 --- a/question/type/multianswer/questiontype.php +++ b/question/type/multianswer/questiontype.php @@ -279,7 +279,7 @@ class embedded_cloze_qtype extends default_questiontype { } /// Determine style - if (!empty($response)) { + if ($options->feedback && !empty($response)) { $style = 'class = "'.question_get_feedback_class($chosenanswer->fraction).'"'; $feedbackimg = question_get_feedback_image($chosenanswer->fraction); } else { diff --git a/question/type/multichoice/questiontype.php b/question/type/multichoice/questiontype.php index c6506ebb24..18f15d5765 100644 --- a/question/type/multichoice/questiontype.php +++ b/question/type/multichoice/questiontype.php @@ -314,20 +314,22 @@ class question_multichoice_qtype extends default_questiontype { $a->control = "id\" $name $checked $type value=\"$aid\"" . " alt=\"" . s($answer->answer) . '" />'; - if ($options->readonly) { - // Means we need to display answer correctness. - if ($answer->fraction > 0) { - $a->class = question_get_feedback_class(1); - } - $a->feedbackimg = question_get_feedback_image($answer->fraction > 0 ? 1 : 0, $chosen); + if ($options->correct_responses && $answer->fraction > 0) { + $a->class = question_get_feedback_class(1); + } + if (($options->feedback && $chosen) || $options->correct_responses) { + $a->feedbackimg = question_get_feedback_image($answer->fraction > 0 ? 1 : 0, $chosen && $options->feedback); } // Print the answer text $a->text = format_text("$qnumchar. $answer->answer", FORMAT_MOODLE, $formatoptions, $cmoptions->course); // Print feedback if feedback is on - $a->feedback = (($options->feedback || $options->correct_responses) && $checked) ? - $feedback = format_text($answer->feedback, true, $formatoptions, $cmoptions->course) : ''; + if (($options->feedback || $options->correct_responses) && $checked) { + $a->feedback = format_text($answer->feedback, true, $formatoptions, $cmoptions->course); + } else { + $a->feedback = ''; + } $anss[] = clone($a); } diff --git a/question/type/truefalse/questiontype.php b/question/type/truefalse/questiontype.php index 8f34460248..fba906575f 100644 --- a/question/type/truefalse/questiontype.php +++ b/question/type/truefalse/questiontype.php @@ -169,14 +169,18 @@ class question_truefalse_qtype extends default_questiontype { $falsechecked = ($state->responses[''] == $falseanswer->id) ? ' checked="checked"' : ''; // Work out visual feedback for answer correctness. - if ($truechecked) { - $trueclass = question_get_feedback_class($trueanswer->fraction); - } else if ($falsechecked) { - $falseclass = question_get_feedback_class($falseanswer->fraction); + if ($options->feedback) { + if ($truechecked) { + $trueclass = question_get_feedback_class($trueanswer->fraction); + } else if ($falsechecked) { + $falseclass = question_get_feedback_class($falseanswer->fraction); + } } - if (isset($answers[$state->responses['']])) { - $truefeedbackimg = question_get_feedback_image($trueanswer->fraction, !empty($truechecked)); - $falsefeedbackimg = question_get_feedback_image($falseanswer->fraction, !empty($falsechecked)); + if ($options->feedback || $options->correct_responses) { + if (isset($answers[$state->responses['']])) { + $truefeedbackimg = question_get_feedback_image($trueanswer->fraction, !empty($truechecked) && $options->feedback); + $falsefeedbackimg = question_get_feedback_image($falseanswer->fraction, !empty($falsechecked) && $options->feedback); + } } $inputname = ' name="'.$question->name_prefix.'" '; -- 2.39.5