You are here

public function MatchingResponse::formatReport in Quiz 6.6

Same name and namespace in other branches
  1. 6.3 question_types/matching/matching.classes.inc \MatchingResponse::formatReport()
  2. 6.5 question_types/matching/matching.classes.inc \MatchingResponse::formatReport()

File

question_types/matching/matching.classes.inc, line 275
matching.classes

Class

MatchingResponse
Class that describes a "Directions question response". For the most part, no real scoring takes place for a direction node. However, there are a few behind-the-scenes tricks that are done here to make the quiz-taking process a little easier.

Code

public function formatReport($showpoints = TRUE, $showfeedback = TRUE) {
  $rows = $innerheader = array();

  // Build the question answers header (add blank space for IE).
  $innerheader[] = t('Match');
  if ($showpoints) {
    $innerheader[] = t('Correct Answer');
  }
  $innerheader[] = t('User Answer');
  if ($showfeedback) {
    $innerheader[] = ' ';
  }

  //if (empty($this->question->answers)) {

  //  return t('Missing question.');

  //}
  $MatchingQuestion = new MatchingQuestion($this->question);
  $correct_answers = $MatchingQuestion
    ->getCorrectAnswer();
  $user_answers = $this
    ->getUserAnswers();
  foreach ($correct_answers as $correct_answer) {
    $id = $user_answers[$correct_answer['match_id']];
    $theme = $correct_answer['answer'] == $correct_answers[$id]['answer'] ? 'quiz_score_correct' : 'quiz_score_incorrect';
    $rows[] = array(
      'match' => $correct_answer['question'],
      'correct_answer' => $showpoints ? $correct_answer['answer'] : '',
      'user_answer' => $showfeedback ? $correct_answers[$id]['answer'] : '',
      'image' => $showfeedback ? array(
        'data' => theme($theme),
        'class' => 'quiz_summary_qcell',
      ) : '',
    );
  }

  // Add the cell with the question and the answers.
  $q_output = '<div class="quiz_summary_question"><span class="quiz_question_bullet">Q:</span> ' . check_markup($this->question->body) . '</div>';
  $q_output .= theme('table', $innerheader, $rows) . '<br />';
  return $q_output;
}