LLMS_Student_Quizzes::get_best_attempt( int $quiz_id = null, null $deprecated = null )
Get the quiz attempt with the highest grade for a given quiz and lesson combination
Parameters Parameters
- $quiz_id
-
(int) (Optional) WP Post ID of a Quiz.
Default value: null
- $deprecated
-
(null) (Optional) Deprecated.
Default value: null
Return Return
(false|LLMS_Quiz_Attempt)
Source Source
File: includes/models/model.llms.student.quizzes.php
public function get_best_attempt( $quiz_id = null, $deprecated = null ) {
$attempts = $this->get_attempts_by_quiz(
$quiz_id,
array(
'per_page' => 1,
'sort' => array(
'grade' => 'DESC',
'update_date' => 'DESC',
'id' => 'DESC',
),
'status' => array( 'pass', 'fail' ),
)
);
if ( $attempts ) {
return $attempts[0];
}
return false;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 3.9.0 | |
| 3.16.0 | Introduced. |