public function ShortAnswerResponse::formatReport in Quiz 6.3
Same name and namespace in other branches
- 6.6 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::formatReport()
- 6.5 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::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/
short_answer/ short_answer.classes.inc, line 352 - The main classes for the short answer question type.
Class
- ShortAnswerResponse
- The short answer question response class.
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) . '</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">' . $answer->feedback;
}
}
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 short answer')) {
$path = sprintf('admin/quiz/score-short-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;
}