Skip to content

Commit

Permalink
MDL-9208 - Only hightlight the correct answer if that option is set.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjhunt committed Apr 4, 2007
1 parent 8fe9be5 commit 8ef0022
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion question/type/match/questiontype.php
Expand Up @@ -290,7 +290,7 @@ function print_question_formulation_and_controls(&$question, &$state, $cmoptions
$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);
}
Expand Down
2 changes: 1 addition & 1 deletion question/type/multianswer/questiontype.php
Expand Up @@ -275,7 +275,7 @@ function print_question_formulation_and_controls(&$question, &$state, $cmoptions
}

/// 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 {
Expand Down
18 changes: 10 additions & 8 deletions question/type/multichoice/questiontype.php
Expand Up @@ -310,20 +310,22 @@ function print_question_formulation_and_controls(&$question, &$state, $cmoptions
$a->control = "<input $readonly id=\"$a->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);
}
Expand Down
18 changes: 11 additions & 7 deletions question/type/truefalse/questiontype.php
Expand Up @@ -165,14 +165,18 @@ function print_question_formulation_and_controls(&$question, &$state,
$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.'" ';
Expand Down

0 comments on commit 8ef0022

Please sign in to comment.