From 7b77db8e2d1846a438117830dad12b1ecaba6854 Mon Sep 17 00:00:00 2001 From: zubairraeen Date: Fri, 15 Sep 2023 17:56:50 +0530 Subject: [PATCH] added random page support with manual pagination --- php/classes/class-qmn-quiz-manager.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/php/classes/class-qmn-quiz-manager.php b/php/classes/class-qmn-quiz-manager.php index 0a5aa6c11..538b95da0 100644 --- a/php/classes/class-qmn-quiz-manager.php +++ b/php/classes/class-qmn-quiz-manager.php @@ -914,7 +914,7 @@ public function display_quiz( $options, $quiz_data, $question_amount, $shortcode // If deprecated pagination setting is not used, use new system... $pages = $mlwQuizMasterNext->pluginHelper->get_quiz_setting( 'pages', array() ); - if ( 0 == $options->randomness_order && 0 == $options->question_from_total && 0 == $options->pagination && is_countable($pages) && 0 !== count( $pages ) ) { + if ( 0 == $options->question_from_total && 0 == $options->pagination && is_countable($pages) && 0 !== count( $pages ) ) { $this->display_pages( $options, $quiz_data ); } else { // ... else, use older system. @@ -971,6 +971,23 @@ public function display_pages( $options, $quiz_data ) { $contact_fields = QSM_Contact_Manager::load_fields(); $animation_effect = isset( $options->quiz_animation ) && '' !== $options->quiz_animation ? ' animated ' . $options->quiz_animation : ''; $enable_pagination_quiz = isset( $options->enable_pagination_quiz ) && 1 == $options->enable_pagination_quiz ? true : false; + if ( ( 1 == $options->randomness_order || 2 == $options->randomness_order ) && is_array( $pages ) ) { + shuffle( $pages ); + $question_list_array = array(); + foreach( $pages as &$question_ids ){ + shuffle( $question_ids ); + $question_list_array = array_merge($question_list_array, $question_ids); + } + $question_list_str = implode( ',', $question_list_array ); + ?> + + disable_first_page ) && ( ! empty( $options->message_before ) || ( 0 == $options->contact_info_location && $contact_fields ) ) ) { $qmn_json_data['first_page'] = true; $message_before = $mlwQuizMasterNext->pluginHelper->qsm_language_support( htmlspecialchars_decode( $options->message_before, ENT_QUOTES ), "quiz_message_before-{$options->quiz_id}" );