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(