LLMS_Student_Quizzes::get_attempt_by_id( int $attempt_id )

Retrieve an attempt by attempt id

Parameters Parameters


(int) (Required) Attempt ID.

Top ↑

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.

Top ↑

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;


Top ↑

Changelog Changelog

Version Description
4.21.2 Return false for invalid IDs & check permissions before returning the attempt.
3.16.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.