public function QuizSession::getResult in Quiz 6.x
Get the current user's result for a Quiz in the session
Parameters
Quiz $quiz: The quiz.
Overrides QuizSessionInterface::getResult
1 call to QuizSession::getResult()
- QuizSession::isTakingQuiz in src/
Services/ QuizSession.php - Determine if the current user user has a result for this quiz or a temporary quiz in the session.
File
- src/
Services/ QuizSession.php, line 60
Class
- QuizSession
- Default implementation of the quiz session.
Namespace
Drupal\quiz\ServicesCode
public function getResult(Quiz $quiz = NULL) {
$current_quizzes = $this
->getCurrentQuizzes();
if ($quiz && isset($current_quizzes[$quiz
->id()]) && !empty($current_quizzes[$quiz
->id()][self::RESULT_ID])) {
$result_id = $current_quizzes[$quiz
->id()][self::RESULT_ID];
return QuizResult::load($result_id);
}
return NULL;
}