From 9fdae00714d005f00ae5b28da29b8b405217a4e4 Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Thu, 26 Oct 2023 17:16:24 +0530 Subject: [PATCH] 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,