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


Top ↑

Return Return

(false|LLMS_Quiz_Attempt)


Top ↑

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;

	}


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.