LLMS_Quiz_Legacy::previous_question( $question_id )

Previous question button click Finds the previous question and redirects the user to the post


Description Description


Return Return

(void)


Top ↑

Source Source

File: includes/class.llms.quiz.legacy.php

	public static function previous_question( $question_id ) {

		$quiz = LLMS()->session->get( 'llms_quiz' );

		foreach ( (array) $quiz->questions as $key => $value ) {
			if ( $value['id'] == $question_id ) {
				$previous_question_key = ( $key - 1 );
				if ( $previous_question_key >= 0 ) {
					$prev_question_link = get_permalink( $quiz->questions[ $previous_question_key ]['id'] );
					$redirect           = get_permalink( $prev_question_link );

					return $quiz->questions[ $previous_question_key ]['id'];

				}
			}
		}
	}


Top ↑

User Contributed Notes User Contributed Notes

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





Permalink: