function Quiz::hasAttempts in Quiz 6.x
Same name and namespace in other branches
- 8.6 src/Entity/Quiz.php \Drupal\quiz\Entity\Quiz::hasAttempts()
- 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\EntityCode
function hasAttempts() {
$result = \Drupal::entityQuery('quiz_result')
->condition('qid', $this
->id())
->condition('vid', $this
->getRevisionId())
->range(0, 1)
->execute();
return !empty($result);
}