You are here

function Quiz::getNumberOfRequiredQuestions in Quiz 6.x

Same name and namespace in other branches
  1. 8.6 src/Entity/Quiz.php \Drupal\quiz\Entity\Quiz::getNumberOfRequiredQuestions()
  2. 8.5 src/Entity/Quiz.php \Drupal\quiz\Entity\Quiz::getNumberOfRequiredQuestions()

Get the number of required questions for a quiz.

Return value

int Number of required questions.

1 call to Quiz::getNumberOfRequiredQuestions()
Quiz::getNumberOfQuestions in src/Entity/Quiz.php
Finds out the number of configured questions for the quiz, taking into account random questions pulled from a pool

File

src/Entity/Quiz.php, line 681

Class

Quiz
Defines the Quiz entity class.

Namespace

Drupal\quiz\Entity

Code

function getNumberOfRequiredQuestions() {
  $query = Drupal::entityQuery('quiz_question_relationship');
  $query
    ->condition('quiz_vid', $this
    ->getRevisionId());
  $query
    ->condition('question_status', QuizQuestion::QUESTION_ALWAYS);
  $result = $query
    ->execute();
  return count($result);
}