LLMS_Student_Quizzes::get_last_attempt( int $quiz_id )

Retrieve the last recorded attempt for a student for a given quiz/lesson


Description Description

"Last" is defined as the attempt with the highest attempt number


Top ↑

Parameters Parameters

$quiz_id

(int) (Required) WP Post ID of the quiz.


Top ↑

Return Return

(LLMS_Quiz_Attempt|false)


Top ↑

Source Source

File: includes/models/model.llms.student.quizzes.php

	public function get_last_attempt( $quiz_id ) {

		$attempts = $this->get_attempts_by_quiz(
			$quiz_id,
			array(
				'per_page' => 1,
				'sort'     => array(
					'attempt' => 'DESC',
				),
			)
		);

		if ( $attempts ) {
			return $attempts[0];
		}

		return false;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.9.0
3.16.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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