Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

LLMS_Quiz_Attempt::get_new_questions()

Retrieve an array of blank questions for insertion into a new attempt during initialization


Return Return

(array)


Top ↑

Source Source

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

	 */
	private function get_new_questions() {

		$quiz = llms_get_post( $this->get( 'quiz_id' ) );

		$questions = array();

		if ( $quiz ) {

			/**
			 * Filter randomize value for quiz questions.
			 *
			 * @since 7.4.0
			 *
			 * @param bool              $randomize The randomize boolean value.
			 * @param LLMS_Quiz         $quiz      LLMS_Quiz instance.
			 * @param LLMS_Quiz_Attempt $attempt   LLMS_Quiz_Attempt instance.
			 */
			$randomize = apply_filters( 'llms_quiz_attempt_questions_randomize', llms_parse_bool( $quiz->get( 'random_questions' ) ), $quiz, $this );

			/**
			 * Filter questions for the quiz.
			 *
			 * Sets the questions to be used for the quiz.
			 *
			 * @since 7.4.0
			 *
			 * @param array             $questions Array of LLMS_Question objects.
			 * @param LLMS_Quiz         $quiz      LLMS_Quiz instance.
			 * @param LLMS_Quiz_Attempt $attempt   LLMS_Quiz_Attempt instance.
			 */
			$quiz_questions = apply_filters( 'llms_quiz_attempt_questions', $quiz->get_questions(), $quiz, $this );

			foreach ( $quiz_questions as $index => $question ) {

				$questions[] = array(
					'id'      => $question->get( 'id' ),
					'earned'  => 0,
					'points'  => $question->supports( 'points' ) ? $question->get( 'points' ) : 0,
					'answer'  => null,
					'correct' => null,
				);

			}

			/**
			 * Filter attempt's questions array for the quiz.
			 *
			 * @since 7.4.1
			 *
			 * @param array             $questions Array of question (each question is an array itself).
			 * @param LLMS_Quiz         $quiz      LLMS_Quiz instance.
			 * @param LLMS_Quiz_Attempt $attempt   LLMS_Quiz_Attempt instance.
			 */
			$questions = apply_filters( 'llms_quiz_attempt_questions_array', $questions, $quiz, $this );

			if ( $randomize ) {
				$questions = self::randomize_attempt_questions( $questions );
			}
		}

		return $questions;


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.