You are here

function Quiz::hasAttempts in Quiz 6.x

Same name and namespace in other branches
  1. 8.6 src/Entity/Quiz.php \Drupal\quiz\Entity\Quiz::hasAttempts()
  2. 8.5 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 612

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);
}