LLMS_Quiz::is_open( int $user_id = null )

Determine if a student can take the quiz.


Parameters Parameters

$user_id

(int) (Optional) WP User ID, none supplied uses current user. Default null.

Default value: null


Top ↑

Return Return

(boolean)


Top ↑

Source Source

File: includes/models/model.llms.quiz.php

	public function is_open( $user_id = null ) {

		$student = llms_get_student( $user_id );
		if ( ! $student ) {
			$quiz_open = false;
		} else {

			$remaining = $student->quizzes()->get_attempts_remaining_for_quiz( $this->get( 'id' ) );

			// string for "unlimited" or number of attempts.
			$quiz_open = ! is_numeric( $remaining ) || $remaining > 0;
		}

		/**
		 * Filters whether the quiz is open to a student or not.
		 *
		 * @param boolean            $quiz_open Whether the quiz is open.
		 * @param int|null           $user_id   WP User ID, can be `null`.
		 * @param int                $quiz_id   The Quiz id.
		 * @param LLMS_Quiz          $quiz      The LLMS_Quiz instance.
		 * @param LLMS_Student|false $student   LLMS_Student instance or false if user not found.
		 */
		return apply_filters( 'llms_quiz_is_open', $quiz_open, $user_id, $this->get( 'id' ), $this, $student );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.37.2 Added llms_quiz_is_open filter hook.
3.16.0 Unkwnown.
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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