You are here

public function LongAnswerResponse::formatReport in Quiz 6.3

Same name and namespace in other branches
  1. 6.6 question_types/long_answer/long_answer.classes.inc \LongAnswerResponse::formatReport()
  2. 6.5 question_types/long_answer/long_answer.classes.inc \LongAnswerResponse::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/long_answer/long_answer.classes.inc, line 219
Long answer classes.

Class

LongAnswerResponse

Code

public function formatReport($showpoints = TRUE, $showfeedback = TRUE) {
  $slug = '<div class="quiz_summary_question"><span class="quiz_question_bullet">' . t('Q:') . '</span> ' . check_markup($this->question->body, $this->question->filter) . '</div>';
  $result = '<div class="quiz_answer_feedback">';
  if ($this->question && !empty($this->question->answers)) {
    $answer = (object) current($this->question->answers);
    if ($answer->is_evaluated == 1) {

      // Show score:
      if ($showpoints) {
        $args = array(
          '@yours' => $answer->score,
          '@total' => $this->question->maximum_score,
        );
        $result .= t('Score: @yours of @total possible points', $args);
      }

      // Show feedback, if any.
      if ($showfeedback && !empty($answer->feedback)) {
        $result .= '</div><div class="quiz_answer_feedback">' . check_markup($answer->feedback, $this->question->format);
      }
    }
    else {
      $result .= t('This answer has not yet been scored.') . '<br/>' . t('Until the answer is scored, the total score will not be correct.');
    }
    if (user_access('score long answer')) {
      $path = sprintf('admin/quiz/score-long-answer/%s/%s', $this->question->vid, $this->rid);
      $result .= '<p>' . l(t('Score this answer'), $path) . '</p>';
    }
  }
  else {
    $result .= t('This question was not answered.');
  }
  $result .= '</div>';
  return $slug . $result;
}