You are here

public function QuizSession::setCurrentQuestion in Quiz 6.x

Set the user's current question.

Parameters

Quiz $quiz: The quiz ID.

int $current_question: The current question, starting at 1.

Overrides QuizSessionInterface::setCurrentQuestion

File

src/Services/QuizSession.php, line 115

Class

QuizSession
Default implementation of the quiz session.

Namespace

Drupal\quiz\Services

Code

public function setCurrentQuestion(Quiz $quiz, int $current_question) {
  $current_quizzes = $this
    ->getCurrentQuizzes();
  if (isset($current_quizzes[$quiz
    ->id()])) {
    $current_quizzes[$quiz
      ->id()][self::CURRENT_QUESTION] = $current_question;
    $this
      ->setCurrentQuizzes($current_quizzes);
  }
}