public function QuizResult::findOldResult in Quiz 6.x
Same name and namespace in other branches
- 8.6 src/Entity/QuizResult.php \Drupal\quiz\Entity\QuizResult::findOldResult()
- 8.5 src/Entity/QuizResult.php \Drupal\quiz\Entity\QuizResult::findOldResult()
Find a result that is not the same as the passed result.
Note: the Quiz result does not have an actually exist - in that case, it will return the first completed result found.
// @todo what? // Oh, this is to find a result for build-on-last.
1 call to QuizResult::findOldResult()
- QuizResult::save in src/
Entity/ QuizResult.php - Save the Quiz result and do any post-processing to the result.
File
- src/
Entity/ QuizResult.php, line 547
Class
- QuizResult
- Defines the Quiz entity class.
Namespace
Drupal\quiz\EntityCode
public function findOldResult() {
$efq = \Drupal::entityQuery('quiz_result');
$result = $efq
->condition('uid', $this
->get('uid')
->getString())
->condition('qid', $this
->get('qid')
->getString())
->condition('vid', $this
->get('vid')
->getString())
->condition('result_id', (int) $this
->id(), '!=')
->condition('time_start', 0, '>')
->sort('time_start', 'DESC')
->range(0, 1)
->execute();
if (!empty($result)) {
return QuizResult::load(key($result));
}
return NULL;
}