LLMS_Student_Quizzes::get_attempts_remaining_for_quiz( int $quiz_id )

Get the # of attempts remaining by a student for a given quiz


Description Description


Parameters Parameters

$quiz_id

(int) (Required) WP Post ID of the Quiz


Top ↑

Return Return

(mixed)


Top ↑

Source Source

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

	public function get_attempts_remaining_for_quiz( $quiz_id ) {

		$quiz = llms_get_post( $quiz_id );

		$ret = _x( 'Unlimited', 'quiz attempts remaining', 'lifterlms' );

		if ( $quiz->has_attempt_limit() ) {

			$allowed = $quiz->get( 'allowed_attempts' );
			$used = $this->count_attempts_by_quiz( $quiz->get( 'id' ) );

			// ensure undefined, null, '', etc.. show as an int
			if ( ! $allowed ) {
				$allowed = 0;
			}

			$remaining = ( $allowed - $used );

			// don't show negative attempts
			$ret = max( 0, $remaining );

		}

		return apply_filters( 'llms_student_quiz_attempts_remaining_for_quiz', $ret, $quiz, $this );

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.16.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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





Permalink: