You are here

function theme_multichoice_feedback in Quiz 5.2

Same name and namespace in other branches
  1. 6.6 question_types/multichoice/multichoice.module \theme_multichoice_feedback()
  2. 6.2 multichoice.module \theme_multichoice_feedback()
  3. 6.3 question_types/multichoice/multichoice.module \theme_multichoice_feedback()
  4. 6.5 question_types/multichoice/multichoice.module \theme_multichoice_feedback()

Displays feedback for multichoice

Parameters

$quiz: The quiz node.

$report: The report variables.

Return value

$output HTML output to be written to the screen.

File

./multichoice.module, line 872
Multiple choice question type for the Quiz module.

Code

function theme_multichoice_feedback($quiz, $report) {
  $output = '<span class="quiz-summary-text">' . $report->body . '</span><br />';
  foreach ($report->answers as $answer) {
    if ($answer['user_answer']) {
      $answers[] = $answer['answer'];
      $feedbacks[] = $answer['feedback'];
    }
    if ($answer['is_correct']) {
      $corrects[] = $answer['answer'];
    }
  }
  $output .= '<span class="quiz-summary-header">Your Answer(s):</span> <span class="quiz-summary-text">' . implode(', ', $answers) . '</span>';
  if ($answer['feedback']) {
    $output .= '<br /><span class="quiz-summary-text">' . implode(',', $feedbacks) . '</span>';
  }
  $output .= '<br />';
  if ($report->correct) {
    $output .= "You're right!";
  }
  else {
    $output .= "Sorry!<br />";
    $output .= "Correct Answer(s): " . implode(',', $corrects);
  }
  return $output;
}