You are here

public function MatchingResponse::formatReport in Quiz 6.3

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

Return an HTML marked-up report for displaying the results of this question.

Return value

An HTML string.

Overrides QuizQuestionResponse::formatReport

File

question_types/matching/matching.classes.inc, line 270
quiz_directions.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();

  //$correct_answers = $this->question
  $user_answers = $this
    ->getUserAnswers();

  //print_r($correct_answers);

  //print_r($user_answers);

  //exit;
  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' => check_markup($correct_answer['question'], $this->question->format),
      'correct_answer' => $showpoints ? check_plain($correct_answer['answer']) : '',
      'user_answer' => $showfeedback ? check_plain($correct_answers[$id]['answer']) : '',
      'image' => $showfeedback ? array(
        'data' => theme($theme),
        'class' => 'quiz_summary_qcell',
      ) : '',
    );
  }

  //$answer = $this->question->answers[0];

  //$correct_answer = $answer['is_correct'] ? $answer['answer'] : !$answer['answer'];

  //$user_answer = $answer['answer'];

  //if ($showpoints) {

  //  $rows[0][] = ($correct_answer ? t('True') : t('False'));
  // }

  //$rows[0][] = ($user_answer ? t('True') : t('False'));

  //if($showfeedback && !empty($this->question->feedback)) {

  //  $rows[0][] = $this->question->feedback;

  //}

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