Skip to content

Commit

Permalink
Merge pull request #2372 from QuizandSurveyMaster/CU-85zu2pthg-Vulner…
Browse files Browse the repository at this point in the history
…ability-Report-draft-quiz-submitting

fixed Vulnerability Report
  • Loading branch information
zubairraeen authored Oct 4, 2023
2 parents 8757864 + 258c515 commit 4bdb4ea
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions php/classes/class-qmn-quiz-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function qsm_upload_image_fd_question() {
} else {
$filetypes_allowed[] = $filetypes[0];
}
}else {
}else {
$filetypes_allowed[] = $file;
}
}
Expand Down Expand Up @@ -1318,7 +1318,7 @@ public function display_questions( $qmn_quiz_options, $qmn_quiz_questions, $qmn_
<?php
$current_page_number++;
echo apply_filters( 'qsm_auto_page_begin_pagination', '', ( $current_page_number - 1 ), $qmn_quiz_options, $qmn_quiz_questions );
}
}
echo apply_filters( 'qsm_auto_page_begin_row', '', ( $current_page_number - 1 ), $qmn_quiz_options, $qmn_quiz_questions );
}
$category_class = '';
Expand Down Expand Up @@ -1519,13 +1519,24 @@ public function ajax_submit_results() {
global $qmn_allowed_visit, $mlwQuizMasterNext, $wpdb;

$qmn_allowed_visit = true;
$quiz = isset( $_POST['qmn_quiz_id'] ) ? intval( $_POST['qmn_quiz_id'] ) : '';
$mlwQuizMasterNext->pluginHelper->prepare_quiz( $quiz );
$mlwQuizMasterNext->pluginHelper->prepare_quiz( $quiz_id );
$options = $mlwQuizMasterNext->quiz_settings->get_quiz_options();
if ( is_null( $options ) || 1 == $options->deleted ) {
$post_ids = get_posts(array(
'post_type' => 'qsm_quiz', // Replace with the post type you're working with
'meta_key' => 'quiz_id',
'meta_value' => intval( $quiz_id ),
'fields' => 'ids',
'numberposts' => 1,
));
$post_status = false;
if ( ! empty( $post_ids[0] ) ) {
$post_status = get_post_status( $post_ids[0] );
}

if ( is_null( $options ) || 1 == $options->deleted || 'publish' !== $post_status ) {
echo wp_json_encode(
array(
'display' => htmlspecialchars_decode( 'This quiz is no longer available.' ),
'display' => __( 'This quiz is no longer available.', 'quiz-master-next' ),
'redirect' => false,
'result_status' => array(
'save_response' => false,
Expand Down Expand Up @@ -2150,13 +2161,13 @@ public static function check_answers( $options, $quiz_data ) {
}
}
}
foreach ( $question_data as $questiontype ) {
foreach ( $question_data as $questiontype ) {
if ( 11 == $questiontype['question_type'] ) {
$total_questions = $total_questions - 1;
}
}


// Calculate Total Percent Score And Average Points Only If Total Questions Doesn't Equal Zero To Avoid Division By Zero Error
if ( 0 !== $total_questions ) {
$total_score = round( ( ( $total_correct / ( $total_questions - count( $hidden_questions ) ) ) * 100 ), 2 );
Expand Down

0 comments on commit 4bdb4ea

Please sign in to comment.