You are here

public function TrueFalseResponse::getReportFormResponse in Quiz 6.4

Same name and namespace in other branches
  1. 7 question_types/truefalse/truefalse.classes.inc \TrueFalseResponse::getReportFormResponse()
  2. 7.4 question_types/truefalse/truefalse.classes.inc \TrueFalseResponse::getReportFormResponse()

Implementation of getReportFormResponse

Overrides QuizQuestionResponse::getReportFormResponse

See also

QuizQuestionResponse#getReportFormResponse($showpoints, $showfeedback, $allow_scoring)

File

question_types/truefalse/truefalse.classes.inc, line 291
Defines the classes necessary for a True/False quiz.

Class

TrueFalseResponse
Extension of QuizQuestionResponse

Code

public function getReportFormResponse($showpoints = TRUE, $showfeedback = TRUE, $allow_scoring = FALSE) {
  if (empty($this->question->answers)) {
    return array(
      '#type' => 'markup',
      '#value' => t('Missing question.'),
    );
  }
  $metadata = array();
  $data = array();

  // Build the question answers header (add blank space for IE).
  if ($showpoints) {
    $metadata[] = t('Correct Answer');
  }
  $metadata[] = t('User answer');
  if ($showfeedback) {
    $metadata[] = ' ';
  }
  $answer = $this->question->answers[0];
  $correct_answer = $answer['is_correct'] ? $answer['answer'] : !$answer['answer'];
  $user_answer = $answer['answer'];
  if ($showpoints) {
    $data[0]['correct_answer'] = $correct_answer ? t('True') : t('False');
  }
  $data[0]['user_answer'] = $user_answer === NULL ? '' : ($user_answer ? t('True') : t('False'));
  if ($showfeedback && !empty($this->question->feedback)) {
    $data[0]['feedback'] = check_markup($this->question->feedback, $this->question->format, FALSE);
  }

  // Return themed output
  return array(
    '#type' => 'markup',
    '#value' => theme('truefalse_response', $metadata, $data),
  );
}