You are here

public function QuizQuestionResponse::getReport in Quiz 8.4

Get data suitable for reporting a user's score on the question. This expects an object with the following attributes:

answer_id; // The answer ID answer; // The full text of the answer is_evaluated; // 0 if the question has not been evaluated, 1 if it has score; // The score the evaluator gave the user; this should be 0 if is_evaluated is 0. question_vid question_nid result_id

File

question_types/quiz_question/lib/Drupal/quiz_question/QuizQuestionResponse.php, line 169

Class

QuizQuestionResponse

Namespace

Drupal\quiz_question

Code

public function getReport() {

  // Basically, we encode internal information in a
  // legacy array format for Quiz.
  $report = array(
    'answer_id' => 0,
    // <-- Stupid vestige of multichoice.
    'answer' => $this->answer,
    'is_evaluated' => $this
      ->isEvaluated(),
    'is_correct' => $this
      ->isCorrect(),
    'score' => $this
      ->getScore(),
    'question_vid' => $this->question
      ->getRevisionId(),
    'question_nid' => $this->question
      ->id(),
    'result_id' => $this->rid,
  );
  return $report;
}