You are here

public static function QuizResultAnswerEntityTrait::viewsGetAnswers in Quiz 6.x

Same name and namespace in other branches
  1. 8.6 src/Entity/QuizResultAnswerEntityTrait.php \Drupal\quiz\Entity\QuizResultAnswerEntityTrait::viewsGetAnswers()
  2. 8.5 src/Entity/QuizResultAnswerEntityTrait.php \Drupal\quiz\Entity\QuizResultAnswerEntityTrait::viewsGetAnswers()
3 methods override QuizResultAnswerEntityTrait::viewsGetAnswers()
MatchingResponse::viewsGetAnswers in question_types/quiz_matching/src/Plugin/quiz/QuizQuestion/MatchingResponse.php
Get answers for a question in a result.
MultichoiceResponse::viewsGetAnswers in question_types/quiz_multichoice/src/Plugin/quiz/QuizQuestion/MultichoiceResponse.php
Get answers for a question in a result.
TrueFalseResponse::viewsGetAnswers in question_types/quiz_truefalse/src/Plugin/quiz/QuizQuestion/TrueFalseResponse.php
Get answers for a question in a result.

File

src/Entity/QuizResultAnswerEntityTrait.php, line 196

Class

QuizResultAnswerEntityTrait
Each question type must store its own response data and be able to calculate a score for that data.

Namespace

Drupal\quiz\Entity

Code

public static function viewsGetAnswers(array $result_answer_ids = []) : array {
  $items = [];
  $qras = QuizResultAnswer::loadMultiple($result_answer_ids);
  foreach ($qras as $qra) {
    $items[$qra
      ->getQuizResult()
      ->id()][] = [
      'answer' => $qra
        ->getResponse(),
    ];
  }
  return $items;
}