LLMS_Student_Quizzes::get_attempt_by_id( int $attempt_id )
Retrieve an attempt by attempt id
Parameters Parameters
- $attempt_id
-
(int) (Required) Attempt ID.
Return Return
(LLMS_Quiz_Attempt|boolean) Returns the quiz attempt or false
if the attempt doesn't exist or doesn't belong to the initialized student.
Source Source
File: includes/models/model.llms.student.quizzes.php
public function get_attempt_by_id( $attempt_id ) { $attempt = new LLMS_Quiz_Attempt( $attempt_id ); // Invalid ID. if ( ! $attempt->exists() || ! current_user_can( 'view_grades', absint( $attempt->get( 'student_id' ) ), absint( $attempt->get( 'quiz_id' ) ) ) ) { return false; } return $attempt; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
4.21.2 | Return false for invalid IDs & check permissions before returning the attempt. |
3.16.0 | Introduced. |