From 2bfe0e291d2aac461da543b724439fa28a0a8009 Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Thu, 26 Oct 2023 17:09:30 +0530 Subject: [PATCH 1/5] release 8.1.18 --- mlw_quizmaster2.php | 3 ++- php/classes/class-qmn-quiz-manager.php | 37 ++++++++++++++++++-------- readme.txt | 5 +++- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/mlw_quizmaster2.php b/mlw_quizmaster2.php index 7616b755f..4ec867dc3 100644 --- a/mlw_quizmaster2.php +++ b/mlw_quizmaster2.php @@ -2,7 +2,7 @@ /** * Plugin Name: Quiz And Survey Master * Description: Easily and quickly add quizzes and surveys to your website. - * Version: 8.1.17 + * Version: 8.1.18 * Author: ExpressTech * Author URI: https://quizandsurveymaster.com/ * Plugin URI: https://expresstech.io/ @@ -361,6 +361,7 @@ public function qsm_admin_scripts_style( $hook ) { wp_enqueue_script( 'jquery-ui-tabs' ); wp_enqueue_script( 'jquery-effects-blind' ); wp_enqueue_script( 'jquery-effects-explode' ); + wp_enqueue_media(); break; default: wp_enqueue_editor(); diff --git a/php/classes/class-qmn-quiz-manager.php b/php/classes/class-qmn-quiz-manager.php index 7d7ac7658..0d10c9d0e 100644 --- a/php/classes/class-qmn-quiz-manager.php +++ b/php/classes/class-qmn-quiz-manager.php @@ -509,13 +509,13 @@ public function display_shortcode( $atts ) { if (encryptedData === undefined) { var encryptedData = {}; } - - - - + + + + encryptionKey['.$quiz_id.'] = "'.hash('sha256',time().$quiz_id).'"; - + data['.$quiz_id.'] = '.wp_json_encode($encryption).'; jsonString['.$quiz_id.'] = JSON.stringify(data['.$quiz_id.']); encryptedData['.$quiz_id.'] = CryptoJS.AES.encrypt(jsonString['.$quiz_id.'], encryptionKey['.$quiz_id.']).toString();'; @@ -1567,7 +1567,7 @@ public function ajax_submit_results() { $post_status = get_post_status( $post_ids[0] ); } - if ( is_null( $options ) || 1 == $options->deleted || 'publish' !== $post_status ) { + if ( is_null( $options ) || 1 == $options->deleted ) { echo wp_json_encode( array( 'display' => __( 'This quiz is no longer available.', 'quiz-master-next' ), @@ -1579,6 +1579,18 @@ public function ajax_submit_results() { ); die(); } + if ( 'publish' !== $post_status ) { + echo wp_json_encode( + array( + 'display' => __( 'This quiz is in draft mode and is not recording your responses. Please publish the quiz to start recording your responses.', 'quiz-master-next' ), + 'redirect' => false, + 'result_status' => array( + 'save_response' => false, + ), + ) + ); + die(); + } $qsm_option = isset( $options->quiz_settings ) ? maybe_unserialize( $options->quiz_settings ) : array(); $qsm_option = array_map( 'maybe_unserialize', $qsm_option ); $dateStr = $qsm_option['quiz_options']['scheduled_time_end']; @@ -1859,6 +1871,9 @@ public function submit_results( $qmn_quiz_options, $qmn_array_for_variables ) { // Determines redirect/results page. $results_pages = $this->display_results_text( $qmn_quiz_options, $qmn_array_for_variables ); + if ( 1 === intval( $qmn_quiz_options->store_responses ) && ! $qmn_array_for_variables['response_saved'] ) { + $result_display .= '
' . __('Your responses are not being saved in the database due to a technical issue. Please contact the website administrator for assistance.', 'quiz-master-next') . '
'; + } $result_display .= $results_pages['display']; $result_display = apply_filters( 'qmn_after_results_text', $result_display, $qmn_quiz_options, $qmn_array_for_variables ); @@ -2137,11 +2152,11 @@ public static function check_answers( $options, $quiz_data ) { $results_array = apply_filters( 'qmn_results_array', $results_array, $question ); // If question was graded correctly. if ( ! isset( $results_array['null_review'] ) ) { - $points_earned += $results_array['points']; - $answer_points += $results_array['points']; + $points_earned += (float)$results_array['points']; + $answer_points += (float)$results_array['points']; // If the user's answer was correct. - if ( 'correct' == $results_array['correct'] ) { + if ( isset( $results_array['correct'] ) && ( 'correct' == $results_array['correct'] ) ) { $total_correct += 1; $correct_status = 'correct'; } @@ -2163,8 +2178,8 @@ public static function check_answers( $options, $quiz_data ) { if ( isset( $results_array['question_text'] ) ) { $question_text = $results_array['question_text']; } - $user_answer_array = is_array( $results_array['user_answer'] ) ? $results_array['user_answer'] : array(); - $correct_answer_array = is_array( $results_array['correct_answer'] ) ? $results_array['correct_answer'] : array(); + $user_answer_array = isset( $results_array['user_answer'] ) && is_array( $results_array['user_answer'] ) ? $results_array['user_answer'] : array(); + $correct_answer_array = isset( $results_array['correct_answer'] ) && is_array( $results_array['correct_answer'] ) ? $results_array['correct_answer'] : array(); // Save question data into new array in our array $question_data[] = apply_filters( diff --git a/readme.txt b/readme.txt index 94df709ca..b11f48eaa 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: quiz, survey, lead, test, score, exam, questionnaire, question,wordpress q Requires at least: 4.9 Tested up to: 6.3 Requires PHP: 5.4 -Stable tag: 8.1.17 +Stable tag: 8.1.18 License: GPLv2 License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -163,6 +163,9 @@ This is usually a theme conflict. You can [checkout out our common conflict solu 18. Database == Changelog == += 8.1.18 (October 26, 2023) = +* Enhancement: Updated the message when you submit a quiz in draft mode + = 8.1.17 (October 11, 2023) = * Feature: Added option to include custom text when the answer choice limit exceeds in multiple response type questions. * Feature: Added a new feature to accept shortcodes in the text set to display at the end of quizzes. From 8e6408c8c6797891abc816fa9b7fb5738157a085 Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Thu, 26 Oct 2023 17:13:43 +0530 Subject: [PATCH 2/5] release 8.1.18 --- mlw_quizmaster2.php | 3 +-- php/classes/class-qmn-quiz-manager.php | 35 ++++++++++++-------------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/mlw_quizmaster2.php b/mlw_quizmaster2.php index 4ec867dc3..f0b958e11 100644 --- a/mlw_quizmaster2.php +++ b/mlw_quizmaster2.php @@ -43,7 +43,7 @@ class MLWQuizMasterNext { * @var string * @since 4.0.0 */ - public $version = '8.1.17'; + public $version = '8.1.18'; /** * QSM Alert Manager Object @@ -361,7 +361,6 @@ public function qsm_admin_scripts_style( $hook ) { wp_enqueue_script( 'jquery-ui-tabs' ); wp_enqueue_script( 'jquery-effects-blind' ); wp_enqueue_script( 'jquery-effects-explode' ); - wp_enqueue_media(); break; default: wp_enqueue_editor(); diff --git a/php/classes/class-qmn-quiz-manager.php b/php/classes/class-qmn-quiz-manager.php index 0d10c9d0e..f5d170221 100644 --- a/php/classes/class-qmn-quiz-manager.php +++ b/php/classes/class-qmn-quiz-manager.php @@ -1567,7 +1567,7 @@ public function ajax_submit_results() { $post_status = get_post_status( $post_ids[0] ); } - if ( is_null( $options ) || 1 == $options->deleted ) { + if ( is_null( $options ) || 1 == $options->deleted || 'publish' !== $post_status ) { echo wp_json_encode( array( 'display' => __( 'This quiz is no longer available.', 'quiz-master-next' ), @@ -1579,10 +1579,16 @@ public function ajax_submit_results() { ); die(); } - if ( 'publish' !== $post_status ) { + $qsm_option = isset( $options->quiz_settings ) ? maybe_unserialize( $options->quiz_settings ) : array(); + $qsm_option = array_map( 'maybe_unserialize', $qsm_option ); + $dateStr = $qsm_option['quiz_options']['scheduled_time_end']; + $timezone = isset( $_POST['currentuserTimeZone'] ) ? sanitize_text_field( wp_unslash( $_POST['currentuserTimeZone'] ) ) : ''; + $dtUtcDate = strtotime( $dateStr . ' ' . $timezone ); + + if ( isset($qsm_option['quiz_options']['not_allow_after_expired_time']) && '1' === $qsm_option['quiz_options']['not_allow_after_expired_time'] && isset( $_POST['currentuserTime'] ) && sanitize_text_field( wp_unslash( $_POST['currentuserTime'] ) ) > $dtUtcDate && ! empty($dateStr) ) { echo wp_json_encode( array( - 'display' => __( 'This quiz is in draft mode and is not recording your responses. Please publish the quiz to start recording your responses.', 'quiz-master-next' ), + 'display' => htmlspecialchars_decode( 'Quiz Expired!' ), 'redirect' => false, 'result_status' => array( 'save_response' => false, @@ -1591,16 +1597,10 @@ public function ajax_submit_results() { ); die(); } - $qsm_option = isset( $options->quiz_settings ) ? maybe_unserialize( $options->quiz_settings ) : array(); - $qsm_option = array_map( 'maybe_unserialize', $qsm_option ); - $dateStr = $qsm_option['quiz_options']['scheduled_time_end']; - $timezone = isset( $_POST['currentuserTimeZone'] ) ? sanitize_text_field( wp_unslash( $_POST['currentuserTimeZone'] ) ) : ''; - $dtUtcDate = strtotime( $dateStr . ' ' . $timezone ); - - if ( isset($qsm_option['quiz_options']['not_allow_after_expired_time']) && '1' === $qsm_option['quiz_options']['not_allow_after_expired_time'] && isset( $_POST['currentuserTime'] ) && sanitize_text_field( wp_unslash( $_POST['currentuserTime'] ) ) > $dtUtcDate && ! empty($dateStr) ) { + if ( 'publish' !== $post_status ) { echo wp_json_encode( array( - 'display' => htmlspecialchars_decode( 'Quiz Expired!' ), + 'display' => __( 'This quiz is in draft mode and is not recording your responses. Please publish the quiz to start recording your responses.', 'quiz-master-next' ), 'redirect' => false, 'result_status' => array( 'save_response' => false, @@ -1871,9 +1871,6 @@ public function submit_results( $qmn_quiz_options, $qmn_array_for_variables ) { // Determines redirect/results page. $results_pages = $this->display_results_text( $qmn_quiz_options, $qmn_array_for_variables ); - if ( 1 === intval( $qmn_quiz_options->store_responses ) && ! $qmn_array_for_variables['response_saved'] ) { - $result_display .= '
' . __('Your responses are not being saved in the database due to a technical issue. Please contact the website administrator for assistance.', 'quiz-master-next') . '
'; - } $result_display .= $results_pages['display']; $result_display = apply_filters( 'qmn_after_results_text', $result_display, $qmn_quiz_options, $qmn_array_for_variables ); @@ -2152,11 +2149,11 @@ public static function check_answers( $options, $quiz_data ) { $results_array = apply_filters( 'qmn_results_array', $results_array, $question ); // If question was graded correctly. if ( ! isset( $results_array['null_review'] ) ) { - $points_earned += (float)$results_array['points']; - $answer_points += (float)$results_array['points']; + $points_earned += $results_array['points']; + $answer_points += $results_array['points']; // If the user's answer was correct. - if ( isset( $results_array['correct'] ) && ( 'correct' == $results_array['correct'] ) ) { + if ( 'correct' == $results_array['correct'] ) { $total_correct += 1; $correct_status = 'correct'; } @@ -2178,8 +2175,8 @@ public static function check_answers( $options, $quiz_data ) { if ( isset( $results_array['question_text'] ) ) { $question_text = $results_array['question_text']; } - $user_answer_array = isset( $results_array['user_answer'] ) && is_array( $results_array['user_answer'] ) ? $results_array['user_answer'] : array(); - $correct_answer_array = isset( $results_array['correct_answer'] ) && is_array( $results_array['correct_answer'] ) ? $results_array['correct_answer'] : array(); + $user_answer_array = is_array( $results_array['user_answer'] ) ? $results_array['user_answer'] : array(); + $correct_answer_array = is_array( $results_array['correct_answer'] ) ? $results_array['correct_answer'] : array(); // Save question data into new array in our array $question_data[] = apply_filters( From 9fdae00714d005f00ae5b28da29b8b405217a4e4 Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Thu, 26 Oct 2023 17:16:24 +0530 Subject: [PATCH 3/5] release 8.1.18 --- php/classes/class-qmn-quiz-manager.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/php/classes/class-qmn-quiz-manager.php b/php/classes/class-qmn-quiz-manager.php index f5d170221..a7c90fc73 100644 --- a/php/classes/class-qmn-quiz-manager.php +++ b/php/classes/class-qmn-quiz-manager.php @@ -1567,7 +1567,7 @@ public function ajax_submit_results() { $post_status = get_post_status( $post_ids[0] ); } - if ( is_null( $options ) || 1 == $options->deleted || 'publish' !== $post_status ) { + if ( is_null( $options ) || 1 == $options->deleted ) { echo wp_json_encode( array( 'display' => __( 'This quiz is no longer available.', 'quiz-master-next' ), @@ -1579,16 +1579,10 @@ public function ajax_submit_results() { ); die(); } - $qsm_option = isset( $options->quiz_settings ) ? maybe_unserialize( $options->quiz_settings ) : array(); - $qsm_option = array_map( 'maybe_unserialize', $qsm_option ); - $dateStr = $qsm_option['quiz_options']['scheduled_time_end']; - $timezone = isset( $_POST['currentuserTimeZone'] ) ? sanitize_text_field( wp_unslash( $_POST['currentuserTimeZone'] ) ) : ''; - $dtUtcDate = strtotime( $dateStr . ' ' . $timezone ); - - if ( isset($qsm_option['quiz_options']['not_allow_after_expired_time']) && '1' === $qsm_option['quiz_options']['not_allow_after_expired_time'] && isset( $_POST['currentuserTime'] ) && sanitize_text_field( wp_unslash( $_POST['currentuserTime'] ) ) > $dtUtcDate && ! empty($dateStr) ) { + if ( 'publish' !== $post_status ) { echo wp_json_encode( array( - 'display' => htmlspecialchars_decode( 'Quiz Expired!' ), + 'display' => __( 'This quiz is in draft mode and is not recording your responses. Please publish the quiz to start recording your responses.', 'quiz-master-next' ), 'redirect' => false, 'result_status' => array( 'save_response' => false, @@ -1597,10 +1591,17 @@ public function ajax_submit_results() { ); die(); } - if ( 'publish' !== $post_status ) { + + $qsm_option = isset( $options->quiz_settings ) ? maybe_unserialize( $options->quiz_settings ) : array(); + $qsm_option = array_map( 'maybe_unserialize', $qsm_option ); + $dateStr = $qsm_option['quiz_options']['scheduled_time_end']; + $timezone = isset( $_POST['currentuserTimeZone'] ) ? sanitize_text_field( wp_unslash( $_POST['currentuserTimeZone'] ) ) : ''; + $dtUtcDate = strtotime( $dateStr . ' ' . $timezone ); + + if ( isset($qsm_option['quiz_options']['not_allow_after_expired_time']) && '1' === $qsm_option['quiz_options']['not_allow_after_expired_time'] && isset( $_POST['currentuserTime'] ) && sanitize_text_field( wp_unslash( $_POST['currentuserTime'] ) ) > $dtUtcDate && ! empty($dateStr) ) { echo wp_json_encode( array( - 'display' => __( 'This quiz is in draft mode and is not recording your responses. Please publish the quiz to start recording your responses.', 'quiz-master-next' ), + 'display' => htmlspecialchars_decode( 'Quiz Expired!' ), 'redirect' => false, 'result_status' => array( 'save_response' => false, From 7bb157fbc064c56a704b7e7960e3f572abac4da9 Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Thu, 26 Oct 2023 17:38:40 +0530 Subject: [PATCH 4/5] change die() function to die(); --- php/classes/class-qmn-quiz-manager.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/php/classes/class-qmn-quiz-manager.php b/php/classes/class-qmn-quiz-manager.php index a7c90fc73..4e9fd9005 100644 --- a/php/classes/class-qmn-quiz-manager.php +++ b/php/classes/class-qmn-quiz-manager.php @@ -1577,7 +1577,7 @@ public function ajax_submit_results() { ), ) ); - die(); + wp_die(); } if ( 'publish' !== $post_status ) { echo wp_json_encode( @@ -1589,7 +1589,7 @@ public function ajax_submit_results() { ), ) ); - die(); + wp_die(); } $qsm_option = isset( $options->quiz_settings ) ? maybe_unserialize( $options->quiz_settings ) : array(); @@ -1608,7 +1608,7 @@ public function ajax_submit_results() { ), ) ); - die(); + wp_die(); } if ( 0 != $options->limit_total_entries ) { $mlw_qmn_entries_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(quiz_id) FROM {$wpdb->prefix}mlw_results WHERE deleted=0 AND quiz_id=%d", $options->quiz_id ) ); @@ -1622,7 +1622,7 @@ public function ajax_submit_results() { ), ) ); - die(); + wp_die(); } } if ( 0 != $options->total_user_tries ) { @@ -1649,7 +1649,7 @@ public function ajax_submit_results() { ), ) ); - die(); + wp_die(); } } $data = array( @@ -1659,7 +1659,7 @@ public function ajax_submit_results() { 'quiz_payment_id' => isset( $_POST['main_payment_id'] ) ? sanitize_text_field( wp_unslash( $_POST['main_payment_id'] ) ) : '', ); echo wp_json_encode( $this->submit_results( $options, $data ) ); - die(); + wp_die(); } /** From 63e7d1a37de6c0d1aba7a3360ec039f82ec71ec5 Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Tue, 31 Oct 2023 15:33:53 +0530 Subject: [PATCH 5/5] merge with master branch --- php/classes/class-qsm-install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/classes/class-qsm-install.php b/php/classes/class-qsm-install.php index 403baf3b7..e1d7de78f 100644 --- a/php/classes/class-qsm-install.php +++ b/php/classes/class-qsm-install.php @@ -1480,7 +1480,7 @@ public static function install() { form_type INT NOT NULL, page_name varchar(255) NOT NULL, page_url varchar(255) NOT NULL, - UNIQUE (unique_id), + UNIQUE KEY (unique_id), PRIMARY KEY (result_id) ) $charset_collate;";