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 8e6408c commit 9fdae00
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 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 || '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' ),
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 9fdae00

Please sign in to comment.