public function MatchingQuestion::getCorrectAnswer in Quiz 8.5
Same name and namespace in other branches
- 8.6 question_types/quiz_matching/src/Plugin/quiz/QuizQuestion/MatchingQuestion.php \Drupal\quiz_matching\Plugin\quiz\QuizQuestion\MatchingQuestion::getCorrectAnswer()
- 6.x question_types/quiz_matching/src/Plugin/quiz/QuizQuestion/MatchingQuestion.php \Drupal\quiz_matching\Plugin\quiz\QuizQuestion\MatchingQuestion::getCorrectAnswer()
Get the correct answers for this question.
Return value
array Array of correct answers
File
- question_types/
quiz_matching/ src/ Plugin/ quiz/ QuizQuestion/ MatchingQuestion.php, line 121 - Matching classes.
Class
- MatchingQuestion
- @QuizQuestion ( id = "matching", label = Plugin annotation @Translation("Matching question"), handlers = { "response" = "\Drupal\quiz_matching\Plugin\quiz\QuizQuestion\MatchingResponse" } )
Namespace
Drupal\quiz_matching\Plugin\quiz\QuizQuestionCode
public function getCorrectAnswer() {
$correct_answers = [];
foreach ($this
->get('quiz_matching')
->referencedEntities() as $entity) {
$correct_answers[$entity
->getRevisionId()] = $entity;
}
return $correct_answers;
}