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

419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
*/
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.