LLMS_Quiz_Attempt::get_next_question( int $last_question = null )

Retrieve the next unanswered question in the attempt


Parameters Parameters

$last_question

(int) (Optional) WP Post ID of the current LLMS_Question the "next" refers to. Default null.

Default value: null


Top ↑

Return Return

(int|false)


Top ↑

Source Source

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

	 * @return int|false
	 */
	public function get_next_question( $last_question = null ) {

		$next = false;

		foreach ( $this->get_questions() as $question ) {

			if ( $next || is_null( $question['answer'] ) ) {
				return $question['id'];

				// When rewinding and moving back through we don't want to skip questions.
			} elseif ( $last_question && absint( $last_question ) === absint( $question['id'] ) ) {
				$next = true;
			}
		}

		return false;


Top ↑

Changelog Changelog

Changelog
Version Description
4.2.0 Use strict type comparison.
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.