You are here

function QuizQuestionController::numberToQuestionResultAnswer in Quiz 6.x

Same name and namespace in other branches
  1. 8.6 src/Controller/QuizQuestionController.php \Drupal\quiz\Controller\QuizQuestionController::numberToQuestionResultAnswer()
  2. 8.5 src/Controller/QuizQuestionController.php \Drupal\quiz\Controller\QuizQuestionController::numberToQuestionResultAnswer()

Translate the numeric question index to a question result answer.

Parameters

Quiz $quiz:

int $question_number:

Return value

QuizResultAnswer The question result answer, or NULL if the current result does not exist or does not contain this question.

1 call to QuizQuestionController::numberToQuestionResultAnswer()
QuizQuestionController::checkEntityAccess in src/Controller/QuizQuestionController.php
Translate the numeric question index to a question result answer, and run the default entity access check on it.

File

src/Controller/QuizQuestionController.php, line 255

Class

QuizQuestionController

Namespace

Drupal\quiz\Controller

Code

function numberToQuestionResultAnswer(Quiz $quiz, $question_number) {
  if ($quiz_result = QuizUtil::resultOrTemp($quiz)) {
    return $quiz_result
      ->getLayout()[$question_number];
  }
  return NULL;
}