Skip to content

Commit

Permalink
release 8.1.18
Browse files Browse the repository at this point in the history
  • Loading branch information
zubairraeen committed Oct 26, 2023
1 parent 2bfe0e2 commit 8e6408c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
3 changes: 1 addition & 2 deletions mlw_quizmaster2.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
35 changes: 16 additions & 19 deletions php/classes/class-qmn-quiz-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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 .= '<div class="qsm-result-page-warning">' . __('Your responses are not being saved in the database due to a technical issue. Please contact the website administrator for assistance.', 'quiz-master-next') . '</div>';
}
$result_display .= $results_pages['display'];
$result_display = apply_filters( 'qmn_after_results_text', $result_display, $qmn_quiz_options, $qmn_array_for_variables );

Expand Down Expand Up @@ -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';
}
Expand All @@ -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(
Expand Down

0 comments on commit 8e6408c

Please sign in to comment.