You are here

interface QuizSessionInterface in Quiz 6.x

Stores quiz state in the anonymous user's session.

Hierarchy

Expanded class hierarchy of QuizSessionInterface

All classes that implement QuizSessionInterface

1 file declares its use of QuizSessionInterface
quiz.module in ./quiz.module
Contains quiz.module

File

src/Services/QuizSessionInterface.php, line 12

Namespace

Drupal\quiz\Services
View source
interface QuizSessionInterface {
  const RESULT_ID = 'result_id';
  const CURRENT_QUESTION = 'current_question';
  const TEMP_ID = 'temp';

  /**
   * Determine if the current user user has a result for this quiz or a
   * temporary quiz in the session.
   *
   * @param Quiz $quiz
   *   The quiz.
   */
  public function isTakingQuiz(Quiz $quiz = NULL);

  /**
   * Put a quiz result into the current user's session.
   *
   * @param QuizResult $quiz_result
   *   The quiz result.
   */
  public function startQuiz(QuizResult $quiz_result);

  /**
   * Remove quiz from session
   *
   * @param Quiz $quiz
   *   The quiz.
   */
  public function removeQuiz(Quiz $quiz);

  /**
   * Get the current user's result for a Quiz in the session
   *
   * @param Quiz $quiz
   *   The quiz.
   */
  public function getResult(Quiz $quiz = NULL);

  /**
   * Get the current user's temporary result ID (for feedback/review).
   *
   */
  public function getTemporaryResult();

  /**
   * Set a quiz result for the current user.
   *
   * @param QuizResult $quiz_result
   *   The quiz result.
   */
  public function setResult(QuizResult $quiz_result);

  /**
   * Set the user's temporary result ID (for feedback/review).
   *
   * @param QuizResult $quiz_result
   *   The quiz result.
   */
  public function setTemporaryResult(QuizResult $quiz_result);

  /**
   * Get the user's current question index for a quiz in the session.
   *
   * @param Quiz $quiz
   *   The quiz.
   *
   * @return int
   *   Question index starting at 1.
   */
  public function getCurrentQuestion(Quiz $quiz);

  /**
   * Set the user's current question.
   *
   * @param Quiz $quiz
   *   The quiz ID.
   *
   * @param int $current_question
   *   The current question, starting at 1.
   */
  public function setCurrentQuestion(Quiz $quiz, int $current_question);

}

Members

Namesort descending Modifiers Type Description Overrides
QuizSessionInterface::CURRENT_QUESTION constant
QuizSessionInterface::getCurrentQuestion public function Get the user's current question index for a quiz in the session. 1
QuizSessionInterface::getResult public function Get the current user's result for a Quiz in the session 1
QuizSessionInterface::getTemporaryResult public function Get the current user's temporary result ID (for feedback/review). 1
QuizSessionInterface::isTakingQuiz public function Determine if the current user user has a result for this quiz or a temporary quiz in the session. 1
QuizSessionInterface::removeQuiz public function Remove quiz from session 1
QuizSessionInterface::RESULT_ID constant
QuizSessionInterface::setCurrentQuestion public function Set the user's current question. 1
QuizSessionInterface::setResult public function Set a quiz result for the current user. 1
QuizSessionInterface::setTemporaryResult public function Set the user's temporary result ID (for feedback/review). 1
QuizSessionInterface::startQuiz public function Put a quiz result into the current user's session. 1
QuizSessionInterface::TEMP_ID constant