You are here

function Quiz::hasAttempts in Quiz 8.5

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

Check if this Quiz revision has attempts.

Return value

bool If the version of this Quiz has attempts.

File

src/Entity/Quiz.php, line 608

Class

Quiz
Defines the Quiz entity class.

Namespace

Drupal\quiz\Entity

Code

function hasAttempts() {
  $result = \Drupal::entityQuery('quiz_result')
    ->condition('qid', $this
    ->id())
    ->condition('vid', $this
    ->getRevisionId())
    ->range(0, 1)
    ->execute();
  return !empty($result);
}