You are here

interface QuizQuestionInterface in Quiz 6.x

Same name in this branch
  1. 6.x src/QuizQuestionInterface.php \Drupal\quiz\QuizQuestionInterface
  2. 6.x src/Plugin/QuizQuestionInterface.php \Drupal\quiz\Plugin\QuizQuestionInterface

Provides an interface for quiz questions.

Hierarchy

Expanded class hierarchy of QuizQuestionInterface

All classes that implement QuizQuestionInterface

1 file declares its use of QuizQuestionInterface
QuizQuestion.php in src/Entity/QuizQuestion.php

File

src/QuizQuestionInterface.php, line 12

Namespace

Drupal\quiz
View source
interface QuizQuestionInterface {

  /**
   * Get the form through which the user will answer the question.
   *
   * Question types should populate the form with selected values from the
   * current result if possible.
   *
   * @param FormStateInterface $form_state
   *   Form state.
   * @param QuizResultAnswer $answer
   *   The quiz result answer.
   *
   * @return array
   *   Form array.
   */
  public function getAnsweringForm(FormStateInterface $form_state, QuizResultAnswer $answer) : array;

  /**
   * Get the maximum possible score for this question.
   *
   * @return int
   */
  public function getMaximumScore() : int;

  /**
   * Is this question graded?
   *
   * Questions like Quiz Directions, Quiz Page, and Scale are not.
   *
   * By default, questions are expected to be gradeable
   *
   * @return bool
   */
  public function isGraded() : bool;

  /**
   * Does this question type give feedback?
   *
   * Questions like Quiz Directions and Quiz Pages do not.
   *
   * By default, questions give feedback
   *
   * @return bool
   */
  public function hasFeedback() : bool;

  /**
   * Is this "question" an actual question?
   *
   * For example, a Quiz Page is not a question, neither is a "quiz directions".
   *
   * Returning FALSE here means that the question will not be numbered, and
   * possibly other things.
   *
   * @return bool
   */
  public function isQuestion() : bool;

  /**
   * Get the response to this question in a quiz result.
   *
   * @param \Drupal\quiz\Entity\QuizResult $quiz_result
   *
   * @return QuizResultAnswer|NULL
   */
  public function getResponse(QuizResult $quiz_result) : ?QuizResultAnswer;

}

Members

Namesort descending Modifiers Type Description Overrides
QuizQuestionInterface::getAnsweringForm public function Get the form through which the user will answer the question.
QuizQuestionInterface::getMaximumScore public function Get the maximum possible score for this question. 8
QuizQuestionInterface::getResponse public function Get the response to this question in a quiz result.
QuizQuestionInterface::hasFeedback public function Does this question type give feedback?
QuizQuestionInterface::isGraded public function Is this question graded?
QuizQuestionInterface::isQuestion public function Is this "question" an actual question?