From af780603e0934b67c47210441e0b5472763ed300 Mon Sep 17 00:00:00 2001 From: etchirag Date: Mon, 27 Feb 2023 19:18:12 +0530 Subject: [PATCH 01/21] added new class for show inline option yes questions. --- js/qsm-quiz.js | 3 +++ php/classes/class-qmn-quiz-manager.php | 11 +++++++++++ templates/qmn_primary.css | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/js/qsm-quiz.js b/js/qsm-quiz.js index af44f9784..2d7bf4a09 100644 --- a/js/qsm-quiz.js +++ b/js/qsm-quiz.js @@ -1491,12 +1491,15 @@ jQuery(function () { }, success: function (response) { var data = jQuery.parseJSON(response); + console.log(data) $this.find('.quick-question-res-p').remove(); $this.find('.qsm-inline-correct-info').remove(); + $this.find('.qmn_radio_answers').children().removeClass('data-correct-answer'); if (data.success == 'correct') { $this.append('
' + qmn_quiz_data[quizID].quick_result_correct_answer_text + '
') $this.append('
' + data.message + '
'); } else if (data.success == 'incorrect') { + $this.find('.qmn_radio_answers').children().eq(parseInt(data.correct_index)).addClass('data-correct-answer'); $this.append('
' + qmn_quiz_data[quizID].quick_result_wrong_answer_text + '
') $this.append('
' + data.message + '
'); } diff --git a/php/classes/class-qmn-quiz-manager.php b/php/classes/class-qmn-quiz-manager.php index 29e1a8eaa..63175db4b 100644 --- a/php/classes/class-qmn-quiz-manager.php +++ b/php/classes/class-qmn-quiz-manager.php @@ -229,6 +229,7 @@ public function qsm_get_question_quick_result() { $show_correct_info = isset( $_POST['show_correct_info'] ) ? sanitize_text_field( wp_unslash( $_POST['show_correct_info'] ) ) : 0; $got_ans = false; $correct_answer = false; + $count = 0; if ( $answer_array && false === $got_ans ) { foreach ( $answer_array as $key => $value ) { if ( 'input' === $answer_type ) { @@ -245,12 +246,22 @@ public function qsm_get_question_quick_result() { } } } + + foreach ( $answer_array as $key => $value ) { + if( false == $correct_answer ) { + if( 1 == $value[2] ) { + $correct_index = $count; + } + $count++; + } + } } if ( 2 == $show_correct_info ) { $got_ans = true; } echo wp_json_encode( array( + 'correct_index' => $correct_index, 'success' => $correct_answer ? 'correct' : 'incorrect', 'message' => $show_correct_info && $got_ans ? '' . __( 'Correct Info: ', 'quiz-master-next' ) . '' . do_shortcode( $correct_info_text ) : '', ) diff --git a/templates/qmn_primary.css b/templates/qmn_primary.css index 94f2d6507..51fc18f01 100644 --- a/templates/qmn_primary.css +++ b/templates/qmn_primary.css @@ -516,4 +516,8 @@ label.inline .mlw_qmn_question, color: red; font-size: 18px; line-height: 24px; +} + +.data-correct-answer { + color: green; } \ No newline at end of file From 83b87a7fb22ba7b3a65064566b7f5a8e11c75047 Mon Sep 17 00:00:00 2001 From: etchirag Date: Tue, 28 Feb 2023 11:40:00 +0530 Subject: [PATCH 02/21] minor changes remove console and fix phpcbf coding standard --- js/qsm-quiz.js | 1 - php/classes/class-qmn-quiz-manager.php | 8 ++++---- php/template-variables.php | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/js/qsm-quiz.js b/js/qsm-quiz.js index 2d7bf4a09..c496a55e0 100644 --- a/js/qsm-quiz.js +++ b/js/qsm-quiz.js @@ -1491,7 +1491,6 @@ jQuery(function () { }, success: function (response) { var data = jQuery.parseJSON(response); - console.log(data) $this.find('.quick-question-res-p').remove(); $this.find('.qsm-inline-correct-info').remove(); $this.find('.qmn_radio_answers').children().removeClass('data-correct-answer'); diff --git a/php/classes/class-qmn-quiz-manager.php b/php/classes/class-qmn-quiz-manager.php index 63175db4b..fb8510dba 100644 --- a/php/classes/class-qmn-quiz-manager.php +++ b/php/classes/class-qmn-quiz-manager.php @@ -248,8 +248,8 @@ public function qsm_get_question_quick_result() { } foreach ( $answer_array as $key => $value ) { - if( false == $correct_answer ) { - if( 1 == $value[2] ) { + if ( false == $correct_answer ) { + if ( 1 == $value[2] ) { $correct_index = $count; } $count++; @@ -262,8 +262,8 @@ public function qsm_get_question_quick_result() { echo wp_json_encode( array( 'correct_index' => $correct_index, - 'success' => $correct_answer ? 'correct' : 'incorrect', - 'message' => $show_correct_info && $got_ans ? '' . __( 'Correct Info: ', 'quiz-master-next' ) . '' . do_shortcode( $correct_info_text ) : '', + 'success' => $correct_answer ? 'correct' : 'incorrect', + 'message' => $show_correct_info && $got_ans ? '' . __( 'Correct Info: ', 'quiz-master-next' ) . '' . do_shortcode( $correct_info_text ) : '', ) ); wp_die(); diff --git a/php/template-variables.php b/php/template-variables.php index 09aa321f0..de1c811b3 100644 --- a/php/template-variables.php +++ b/php/template-variables.php @@ -1079,7 +1079,7 @@ function qsm_questions_answers_shortcode_to_text( $mlw_quiz_array, $qmn_question $question_with_answer_text .= '' . $user_given_answer . ''; foreach ( $total_answers as $single_answer ) { $hide_correct_answer = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_options', 'hide_correct_answer' ); - if ( isset( $single_answer[2] ) && 1 == $single_answer[2] && 1 != $hide_correct_answer ) { + if ( isset( $single_answer[2] ) && 1 == $single_answer[2] && 1 != $hide_correct_answer ) { $question_with_answer_text .= '' . $mlwQuizMasterNext->pluginHelper->qsm_language_support( $single_answer[0], 'answer-' . $single_answer[0], 'QSM Answers' ) . ''; break; } From afb8bdb494cbda6b1418dc0992cd7bc04201ff44 Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Thu, 2 Mar 2023 18:32:00 +0530 Subject: [PATCH 03/21] fixed issue with correct in correct class --- js/qsm-quiz.js | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/js/qsm-quiz.js b/js/qsm-quiz.js index af44f9784..427c54106 100644 --- a/js/qsm-quiz.js +++ b/js/qsm-quiz.js @@ -1021,21 +1021,28 @@ function qmnInit() { let key = parseInt(quiz.quiz_id); if (qmn_quiz_data[key].ajax_show_correct === '1') { jQuery('#quizForm' + qmn_quiz_data[key].quiz_id + ' .qmn_quiz_radio').change(function () { - var chosen_answer = jQuery(this).val(); - var question_id = jQuery(this).attr('name').replace(/question/i, ''); - var chosen_id = jQuery(this).attr('id'); - jQuery.each(qmn_quiz_data[key].question_list, function (i, value) { - if (question_id == value.question_id) { - jQuery.each(value.answers, function (j, answer) { - if (answer[0] === chosen_answer) { - if (answer[2] !== 1) { - jQuery('#' + chosen_id).parent().addClass("qmn_incorrect_answer"); - } - } - if (answer[2] === 1) { - jQuery(':radio[name=question' + question_id + '][value="' + answer[0] + '"]').parent().addClass("qmn_correct_answer"); - } - }); + $this = jQuery(this); + var value = $this.val(); + var question_id = $this.attr('name').replace(/question/i, ''); + jQuery.ajax({ + type: 'POST', + url: qmn_ajax_object.ajaxurl, + data: { + action: "qsm_get_question_quick_result", + question_id: question_id, + answer: value, + }, + success: function (response) { + var data = jQuery.parseJSON(response); + if (data.success == 'correct') { + $this.parent().addClass("qmn_correct_answer"); + + } else if (data.success == 'incorrect') { + $this.parent().addClass("qmn_incorrect_answer"); + } + }, + error: function (errorThrown) { + alert(errorThrown); } }); }); From 4ae5bd40cd77da90c500a4624de8773cb1bc3275 Mon Sep 17 00:00:00 2001 From: etchirag Date: Thu, 2 Mar 2023 19:00:42 +0530 Subject: [PATCH 04/21] mobile viwe css changes --- css/qsm-admin-question.css | 19 +++++++++++++ css/qsm-admin.css | 55 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/css/qsm-admin-question.css b/css/qsm-admin-question.css index 1a079b0c1..57b7a0f71 100644 --- a/css/qsm-admin-question.css +++ b/css/qsm-admin-question.css @@ -691,3 +691,22 @@ a#qsm-category-add-toggle { margin: 5px; } } + +@media screen and (max-width: 767px) { + #modal-2 .qsm-popup__container { + max-width: initial; + min-width: initial; + } + .qsm-question-bank-filters { + flex-direction: column; + } + .qsm-question-bank-search { + display: flex; + flex-direction: column; + } + .qsm-popup select, .qsm-popup textarea, .qsm-popup input[type=text], .qsm-popup input[type=search], .qsm-popup input[type=number] { + min-width: initial !important; + max-width: initial !important; + width: 330px; + } +} diff --git a/css/qsm-admin.css b/css/qsm-admin.css index e9532d3e9..b4b29d217 100644 --- a/css/qsm-admin.css +++ b/css/qsm-admin.css @@ -3021,4 +3021,59 @@ input#duplicate_questions { font-size: 12px; min-height: 35px; } + .contact-form-builder-wrap { + flex-direction: column; + } + .contact-tab-sidebar { + max-width: initial; + width: 100%; + } + .contact-form-field { + flex-direction: column; + align-items: initial; + font-size: 12px; + padding-bottom: 0; + } + .contact-form-field > div { + margin: 2px 0; + } + .contact-tab-content { + width: 100%; + max-width: initial; + margin-right: 0; + } + .contact-form-field .contact-form-switch { + position: relative; + bottom: 35px; + left: 70%; + } + .contact-form-field .contact-form-actions, + .contact-form-field .contact-form-switch { + margin-top: 5px; + } + .wp-core-ui .contact-form-field select { + max-width: initial; + } + .qsm_tab_content .qsm-page-subheading { + font-size: 17px; + padding-top: 10px; + } + .contact-tab-content .hide-control { + font-size: 14px; + position: relative; + top: -7px; + } +} + +@media screen and (max-width: 600px) { + .quiz_text_tab_content { + flex-direction: column; + } + .quiz_text_tab_content .left-bar, .quiz_text_tab_content .right-bar { + width: 100%; + } + .nav-tab-wrapper .button-primary { + position: relative; + top: 10px; + } } \ No newline at end of file From f2fd70dbee7120b98e71846be01a31a13985ec81 Mon Sep 17 00:00:00 2001 From: etchirag Date: Fri, 3 Mar 2023 15:40:57 +0530 Subject: [PATCH 05/21] mobile-version-button-overlap-issue --- css/common.css | 2 +- templates/qmn_primary.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/css/common.css b/css/common.css index 79357c6fa..1f00acbe1 100644 --- a/css/common.css +++ b/css/common.css @@ -281,7 +281,7 @@ footer.qsm-popup__footer button.qsm-popup-secondary-button:hover { position: absolute; padding: 0px; margin: 0px; - top: 10px !important; + top: 15px !important; right: 10px; font-size: 13px; font-weight: bold; diff --git a/templates/qmn_primary.css b/templates/qmn_primary.css index 51fc18f01..b42010de2 100644 --- a/templates/qmn_primary.css +++ b/templates/qmn_primary.css @@ -1,7 +1,7 @@ .qsm-progress-bar { position: relative; flex-grow: 2; - padding: 0 10px; + padding: 0px 10px 8px 10px } .ui-tooltip { From 37cf31145b5f33d0ff74e2c5671e9baa4ecfce80 Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Sun, 5 Mar 2023 22:44:34 +0530 Subject: [PATCH 06/21] fixed issue with encoding --- php/template-variables.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/template-variables.php b/php/template-variables.php index de1c811b3..edb28d139 100644 --- a/php/template-variables.php +++ b/php/template-variables.php @@ -403,7 +403,7 @@ function mlw_qmn_variable_quiz_links( $content, $mlw_quiz_array ) { } function mlw_qmn_variable_user_name( $content, $mlw_quiz_array ) { - $content = str_replace( '%USER_NAME%', ( isset( $mlw_quiz_array['user_name'] ) ? $mlw_quiz_array['user_name'] : '' ), $content ); + $content = str_replace( '%USER_NAME%', ( isset( $mlw_quiz_array['user_name'] ) ? html_entity_decode( $mlw_quiz_array['user_name'] ) : '' ), $content ); return $content; } From 90c95c66f47c74bfeeae9e1d964d4da81f32711c Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Mon, 6 Mar 2023 11:10:59 +0530 Subject: [PATCH 07/21] fixed issue with reply to email --- php/classes/class-qsm-emails.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/classes/class-qsm-emails.php b/php/classes/class-qsm-emails.php index 8b16cff71..27b18d258 100644 --- a/php/classes/class-qsm-emails.php +++ b/php/classes/class-qsm-emails.php @@ -221,7 +221,7 @@ public static function send_results_email( $response_data, $to, $subject, $conte } if ( is_email( $user_email ) && true === $reply_to ) { $name = sanitize_text_field( $response_data['user_name'] ); - $headers[] = 'Reply-To: ' . $name . ' <' . $user_email . '>'; + $headers[] = 'Reply-To: ' . html_entity_decode( $name ). ' <' . $user_email . '>'; } /** * Filter to modify email headers. From 3e667f03f0c803a14805258b30f38cedb9b4bf5d Mon Sep 17 00:00:00 2001 From: etchirag Date: Mon, 6 Mar 2023 16:30:22 +0530 Subject: [PATCH 08/21] Fix next and previous buttn mobile device --- css/common.css | 2 +- templates/qmn_primary.css | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/css/common.css b/css/common.css index 1f00acbe1..d10f2c476 100644 --- a/css/common.css +++ b/css/common.css @@ -281,7 +281,7 @@ footer.qsm-popup__footer button.qsm-popup-secondary-button:hover { position: absolute; padding: 0px; margin: 0px; - top: 15px !important; + top: 20px !important; right: 10px; font-size: 13px; font-weight: bold; diff --git a/templates/qmn_primary.css b/templates/qmn_primary.css index b42010de2..5b7b6648f 100644 --- a/templates/qmn_primary.css +++ b/templates/qmn_primary.css @@ -1,7 +1,7 @@ .qsm-progress-bar { position: relative; flex-grow: 2; - padding: 0px 10px 8px 10px + padding: 0px 10px 30px 10px } .ui-tooltip { @@ -355,17 +355,31 @@ label.inline .mlw_qmn_question, .qmn_pagination { position: relative; display: flex; - align-items: stretch; - flex-direction: column; + align-items: start; + flex-direction: row-reverse; padding: 15px 0 15px 0; + flex-wrap: wrap; + justify-content: space-between; +} + +.qmn_pagination .mlw_next, .qmn_pagination .qsm-submit-btn { + margin: 0 0 0 auto; } +.qmn_pagination :nth-child(0) { order: 0; } +.qmn_pagination :nth-child(1) { order: 1; } +.qmn_pagination :nth-child(2) { order: 2; } + @media screen and (min-width: 500px) { .qmn_pagination { justify-content: space-between; align-items: center; flex-direction: row; + flex-wrap: initial; } + .qmn_pagination :nth-child(0) { order: initial; } + .qmn_pagination :nth-child(1) { order: initial; } + .qmn_pagination :nth-child(2) { order: initial; } } .mlw_qmn_timer { From 66b234896294e5e4a944e831c21eb34f3baeddf2 Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Tue, 7 Mar 2023 01:02:12 +0530 Subject: [PATCH 09/21] fixed issue with submit quiz logic if answer is wrong --- js/qsm-quiz.js | 84 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/js/qsm-quiz.js b/js/qsm-quiz.js index 720f2665b..f0ca6531f 100644 --- a/js/qsm-quiz.js +++ b/js/qsm-quiz.js @@ -1352,7 +1352,21 @@ function qmnInitPagination(quiz_id) { jQuery(document).on("click", ".qsm-quiz-container-" + quiz_id + " .mlw_next", function (event) { event.preventDefault(); var quiz_id = +jQuery(this).closest('.qmn_quiz_container').find('.qmn_quiz_id').val(); + var $quizForm = QSM.getQuizForm(quiz_id); jQuery(document).trigger('qsm_auto_next_button_click_before', [quiz_id]); + jQuery('.qmn_radio_answers:visible input:checked , .qmn_check_answers:visible input:checked , .qsm_select:visible').each(function () { + if (qmn_quiz_data[quiz_id].end_quiz_if_wrong == 1 && jQuery(this).is(':visible') && jQuery(this).is('input, select')) { + if (jQuery(this).parents('.qmn_radio_answers, .qsm_check_answer')) { + var question_id = jQuery(this).attr('name').split('question')[1], + value = jQuery(this).val(), + $this = jQuery(this).parents('.quiz_section'); + if (value !== "") { + qsm_submit_quiz_if_answer_wrong(question_id, value, $this, $quizForm); + } + } + } + }) + if (qmnValidatePage('quizForm' + quiz_id)) { qmnNextSlide(qmn_quiz_data[quiz_id].pagination.amount, 1, '#quizForm' + quiz_id); } @@ -1500,7 +1514,7 @@ jQuery(function () { var data = jQuery.parseJSON(response); $this.find('.quick-question-res-p').remove(); $this.find('.qsm-inline-correct-info').remove(); - $this.find('.qmn_radio_answers').children().removeClass('data-correct-answer'); + $this.find('.qmn_radio_answers').children().removeClass('data-correct-answer'); if (data.success == 'correct') { $this.append('
' + qmn_quiz_data[quizID].quick_result_correct_answer_text + '
') $this.append('
' + data.message + '
'); @@ -1532,41 +1546,11 @@ jQuery(function () { jQuery(document).on('change ', '.qmn_radio_answers input , .qmn_check_answers input , .qsm_select', function (e) { var quizID = jQuery(this).parents('.qsm-quiz-container').find('.qmn_quiz_id').val(); var $quizForm = QSM.getQuizForm(quizID); - if (qmn_quiz_data[quizID].end_quiz_if_wrong == 1) { + if (qmn_quiz_data[quizID].end_quiz_if_wrong == 1 && !jQuery('.mlw_custom_next').length ) { var question_id = jQuery(this).attr('name').split('question')[1], value = jQuery(this).val(), $this = jQuery(this).parents('.quiz_section'); - jQuery.ajax({ - type: 'POST', - url: qmn_ajax_object.ajaxurl, - data: { - action: "qsm_get_question_quick_result", - question_id: question_id, - answer: value, - show_correct_info: qmn_quiz_data[quizID].enable_quick_correct_answer_info - }, - success: function (response) { - var data = jQuery.parseJSON(response); - $this.find('.quick-question-res-p').remove(); - $this.find('.qsm-inline-correct-info').remove(); - jQuery(document).trigger('qsm_after_answer_input', [data.success, $this, $quizForm]); - if (data.success == 'correct') { - } else if (data.success == 'incorrect') { - $this.append('
' + qmn_quiz_data[quizID].quick_result_wrong_answer_text + '
') - $this.append('
' + data.message + '
'); - setTimeout(function () { - $quizForm.closest('.qmn_quiz_container').find('[class*="Required"]').removeClass(); - $quizForm.closest('.qmn_quiz_container').find('.qsm-submit-btn').trigger('click'); - }, 1000); - } - if (1 != qmn_quiz_data[quizID].disable_mathjax) { - MathJax.typesetPromise(); - } - }, - error: function (errorThrown) { - alert(errorThrown); - } - }); + qsm_submit_quiz_if_answer_wrong(question_id, value, $this, $quizForm); } }); @@ -1724,4 +1708,38 @@ function checkMaxLength(obj){ if (value.length > parseInt(maxlength)) { obj.value = value.slice(0, parseInt(maxlength)); } +} + +function qsm_submit_quiz_if_answer_wrong(question_id, value, $this, $quizForm) { + jQuery.ajax({ + type: 'POST', + url: qmn_ajax_object.ajaxurl, + data: { + action: "qsm_get_question_quick_result", + question_id: question_id, + answer: value, + show_correct_info: qmn_quiz_data[quizID].enable_quick_correct_answer_info + }, + success: function (response) { + var data = jQuery.parseJSON(response); + $this.find('.quick-question-res-p').remove(); + $this.find('.qsm-inline-correct-info').remove(); + jQuery(document).trigger('qsm_after_answer_input', [data.success, $this, $quizForm]); + if (data.success == 'correct') { + } else if (data.success == 'incorrect') { + $this.append('
' + qmn_quiz_data[quizID].quick_result_wrong_answer_text + '
') + $this.append('
' + data.message + '
'); + setTimeout(function () { + $quizForm.closest('.qmn_quiz_container').find('[class*="Required"]').removeClass(); + $quizForm.closest('.qmn_quiz_container').find('.qsm-submit-btn').trigger('click'); + }, 1000); + } + if (1 != qmn_quiz_data[quizID].disable_mathjax) { + MathJax.typesetPromise(); + } + }, + error: function (errorThrown) { + alert(errorThrown); + } + }); } \ No newline at end of file From 9ca204695b1091475efd5d1884d561c3a107006d Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Tue, 7 Mar 2023 10:39:18 +0530 Subject: [PATCH 10/21] fixed submit if ans wrong issue with manual pagination --- js/qsm-quiz.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/js/qsm-quiz.js b/js/qsm-quiz.js index f0ca6531f..59d618259 100644 --- a/js/qsm-quiz.js +++ b/js/qsm-quiz.js @@ -328,6 +328,19 @@ var qsmTimerInterval = []; jQuery(document).on('click', '.qsm-quiz-container-' + quizID + ' .qsm-pagination .qsm-next', function (event) { jQuery(document).trigger('qsm_next_button_click_before', [quizID]); event.preventDefault(); + var $quizForm = QSM.getQuizForm(quizID); + jQuery('.qmn_radio_answers:visible input:checked , .qmn_check_answers:visible input:checked , .qsm_select:visible').each(function () { + if (qmn_quiz_data[quizID].end_quiz_if_wrong == 1 && jQuery(this).is(':visible') && jQuery(this).is('input, select')) { + if (jQuery(this).parents('.qmn_radio_answers, .qsm_check_answer')) { + var question_id = jQuery(this).attr('name').split('question')[1], + value = jQuery(this).val(), + $this = jQuery(this).parents('.quiz_section'); + if (value !== "") { + qsm_submit_quiz_if_answer_wrong(question_id, value, $this, $quizForm); + } + } + } + }) QSM.nextPage(quizID); var $container = jQuery('.qsm-quiz-container-' + quizID); if (qmn_quiz_data[quizID].disable_scroll_next_previous_click != 1) { @@ -1546,7 +1559,7 @@ jQuery(function () { jQuery(document).on('change ', '.qmn_radio_answers input , .qmn_check_answers input , .qsm_select', function (e) { var quizID = jQuery(this).parents('.qsm-quiz-container').find('.qmn_quiz_id').val(); var $quizForm = QSM.getQuizForm(quizID); - if (qmn_quiz_data[quizID].end_quiz_if_wrong == 1 && !jQuery('.mlw_custom_next').length ) { + if (qmn_quiz_data[quizID].end_quiz_if_wrong == 1 && !jQuery('.mlw_next').length ) { var question_id = jQuery(this).attr('name').split('question')[1], value = jQuery(this).val(), $this = jQuery(this).parents('.quiz_section'); From 62f2366ad6392324a2fe31f7e2d77b28cb4c0885 Mon Sep 17 00:00:00 2001 From: etchirag Date: Tue, 7 Mar 2023 11:28:30 +0530 Subject: [PATCH 11/21] Fix button overlap with new ui --- js/qsm-quiz.js | 4 ++++ php/classes/class-qmn-quiz-manager.php | 3 ++- templates/qmn_primary.css | 19 ++++++++++++------- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/js/qsm-quiz.js b/js/qsm-quiz.js index 720f2665b..1de5c09a9 100644 --- a/js/qsm-quiz.js +++ b/js/qsm-quiz.js @@ -1155,6 +1155,7 @@ function qmnNextSlide(pagination, go_to_top, quiz_form_id) { if (jQuery(quiz_form_id + " .qsm-auto-page-row.empty_quiz_end").length) { submit_button = jQuery(quiz_form_id + " .qsm-auto-page-row.empty_quiz_end").html(); jQuery(quiz_form_id + " .qsm-auto-page-row.empty_quiz_end").show(); + jQuery(".qsm-quiz-container-" + quiz_id + " .qsm-submit-btn").show(); $container.find(".mlw_next").hide(); $container.find('.g-recaptcha').show(); } @@ -1214,6 +1215,7 @@ function qmnPrevSlide(pagination, go_to_top, quiz_form_id) { var slide_original_val = parseInt(slide_number) - 1; if (slide_original_val == 0) { $container.find(".mlw_next").show(); + $container.find(".qsm-submit-btn").hide(); jQuery(quiz_form_id + " .qsm-auto-page-row.quiz_begin").show(); $container.find('.slide_number_hidden').val(slide_original_val); $container.find('.current_page_hidden').val(parseInt(page_number) - 1); @@ -1223,6 +1225,7 @@ function qmnPrevSlide(pagination, go_to_top, quiz_form_id) { $container.find('.slide_number_hidden').val(slide_original_val); $container.find('.current_page_hidden').val(parseInt(page_number) - 1); $container.find(".mlw_next").show(); + $container.find(".qsm-submit-btn").hide(); } check_if_show_start_quiz_button($container, total_pages, page_number); if (go_to_top == 1 && qmn_quiz_data[quiz_id].disable_scroll_next_previous_click != 1) { @@ -1314,6 +1317,7 @@ function qmnInitPagination(quiz_id) { .append('
') .append('') .append('' + qmn_quiz_data[quiz_id].pagination.start_quiz_survey_text + '') + .append('') .append('' + qmn_quiz_data[quiz_id].pagination.next_text + ''); if ('1' == qmn_quiz_data[quiz_id].progress_bar) { diff --git a/php/classes/class-qmn-quiz-manager.php b/php/classes/class-qmn-quiz-manager.php index fb8510dba..ef3c887b1 100644 --- a/php/classes/class-qmn-quiz-manager.php +++ b/php/classes/class-qmn-quiz-manager.php @@ -1401,7 +1401,6 @@ public function display_end_section( $qmn_quiz_options, $qmn_array_for_variables } else { ?>
- quiz_id}" ) ); ?>" />
start_quiz_survey_text) && "" != $qmn_quiz_options->start_quiz_survey_text ) { $quiz_btn_display_text = $qmn_quiz_options->start_quiz_survey_text; // For old quizes set default here @@ -2683,6 +2683,7 @@ function qmn_pagination_check( $display, $qmn_quiz_options, $qmn_array_for_varia 'previous_text' => $mlwQuizMasterNext->pluginHelper->qsm_language_support( $qmn_quiz_options->previous_button_text, "quiz_previous_button_text-{$qmn_quiz_options->quiz_id}" ), 'next_text' => $mlwQuizMasterNext->pluginHelper->qsm_language_support( $qmn_quiz_options->next_button_text, "quiz_next_button_text-{$qmn_quiz_options->quiz_id}" ), 'start_quiz_survey_text' => $mlwQuizMasterNext->pluginHelper->qsm_language_support( $quiz_btn_display_text, "quiz_next_button_text-{$qmn_quiz_options->quiz_id}" ), + 'submit_quiz_text' => $mlwQuizMasterNext->pluginHelper->qsm_language_support( $quiz_btn_submit_text, "quiz_submit_button_text-{$qmn_quiz_options->quiz_id}" ), ); } return $display; diff --git a/templates/qmn_primary.css b/templates/qmn_primary.css index 5b7b6648f..cfee462b5 100644 --- a/templates/qmn_primary.css +++ b/templates/qmn_primary.css @@ -352,26 +352,28 @@ label.inline .mlw_qmn_question, background: #666; } -.qmn_pagination { +.qmn_pagination, .qsm_auto_pagination_enabled .qmn_pagination { position: relative; display: flex; align-items: start; flex-direction: row-reverse; padding: 15px 0 15px 0; flex-wrap: wrap; - justify-content: space-between; -} - -.qmn_pagination .mlw_next, .qmn_pagination .qsm-submit-btn { - margin: 0 0 0 auto; + justify-content: center; + width: 100% !important; + margin: 3px; } .qmn_pagination :nth-child(0) { order: 0; } .qmn_pagination :nth-child(1) { order: 1; } .qmn_pagination :nth-child(2) { order: 2; } +.qsm_auto_pagination_enabled .qmn_pagination :nth-child(5) { order: 0; } +.qsm_auto_pagination_enabled .qmn_pagination :nth-child(6) { order: 1; } +.qsm_auto_pagination_enabled .qmn_pagination :nth-child(7) { order: 2; } + @media screen and (min-width: 500px) { - .qmn_pagination { + .qmn_pagination, .qsm_auto_pagination_enabled .qmn_pagination { justify-content: space-between; align-items: center; flex-direction: row; @@ -380,6 +382,9 @@ label.inline .mlw_qmn_question, .qmn_pagination :nth-child(0) { order: initial; } .qmn_pagination :nth-child(1) { order: initial; } .qmn_pagination :nth-child(2) { order: initial; } + .qsm_auto_pagination_enabled .qmn_pagination :nth-child(5) { order: initial; } + .qsm_auto_pagination_enabled .qmn_pagination :nth-child(6) { order: initial; } + .qsm_auto_pagination_enabled .qmn_pagination :nth-child(7) { order: initial; } } .mlw_qmn_timer { From 83efc41f509fff72787931e8b76a4e82ab15232f Mon Sep 17 00:00:00 2001 From: etchirag Date: Tue, 7 Mar 2023 16:22:15 +0530 Subject: [PATCH 12/21] Minor changes for space between buttons --- templates/qmn_primary.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/templates/qmn_primary.css b/templates/qmn_primary.css index cfee462b5..44b70940d 100644 --- a/templates/qmn_primary.css +++ b/templates/qmn_primary.css @@ -364,6 +364,10 @@ label.inline .mlw_qmn_question, margin: 3px; } +.qmn_pagination .mlw_previous { + margin-right: 5px; +} + .qmn_pagination :nth-child(0) { order: 0; } .qmn_pagination :nth-child(1) { order: 1; } .qmn_pagination :nth-child(2) { order: 2; } From 3f392e14c76936276bff727d779541c6d4228645 Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Wed, 8 Mar 2023 16:15:37 +0530 Subject: [PATCH 13/21] hook added for admin result page --- php/admin/admin-results-details-page.php | 1 + php/classes/class-qmn-quiz-manager.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/php/admin/admin-results-details-page.php b/php/admin/admin-results-details-page.php index a49821a8c..4deb1258d 100644 --- a/php/admin/admin-results-details-page.php +++ b/php/admin/admin-results-details-page.php @@ -169,6 +169,7 @@ function qsm_generate_results_details_tab() { $template .= $span_start. __( 'Phone:', 'quiz-master-next' ) .$span_end. $results_data->phone .$spanend; $template .= $span_start. __( 'Email:', 'quiz-master-next' ) .$span_end. $results_data->email .$spanend; } + $template .= apply_filters('qsm_admin_results_details_contact', "test", $results_array); $template .= ''; $template .= ''; $template .= ''; diff --git a/php/classes/class-qmn-quiz-manager.php b/php/classes/class-qmn-quiz-manager.php index ef3c887b1..837b097f8 100644 --- a/php/classes/class-qmn-quiz-manager.php +++ b/php/classes/class-qmn-quiz-manager.php @@ -2683,7 +2683,7 @@ function qmn_pagination_check( $display, $qmn_quiz_options, $qmn_array_for_varia 'previous_text' => $mlwQuizMasterNext->pluginHelper->qsm_language_support( $qmn_quiz_options->previous_button_text, "quiz_previous_button_text-{$qmn_quiz_options->quiz_id}" ), 'next_text' => $mlwQuizMasterNext->pluginHelper->qsm_language_support( $qmn_quiz_options->next_button_text, "quiz_next_button_text-{$qmn_quiz_options->quiz_id}" ), 'start_quiz_survey_text' => $mlwQuizMasterNext->pluginHelper->qsm_language_support( $quiz_btn_display_text, "quiz_next_button_text-{$qmn_quiz_options->quiz_id}" ), - 'submit_quiz_text' => $mlwQuizMasterNext->pluginHelper->qsm_language_support( $quiz_btn_submit_text, "quiz_submit_button_text-{$qmn_quiz_options->quiz_id}" ), + 'submit_quiz_text' => $mlwQuizMasterNext->pluginHelper->qsm_language_support( $quiz_btn_submit_text, "quiz_submit_button_text-{$qmn_quiz_options->quiz_id}" ), ); } return $display; From ec944e712c604a4d34fb53afe10145617d0198b0 Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Wed, 8 Mar 2023 16:19:16 +0530 Subject: [PATCH 14/21] hook added for admin result page --- php/admin/admin-results-details-page.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/admin/admin-results-details-page.php b/php/admin/admin-results-details-page.php index 4deb1258d..4890a8fd9 100644 --- a/php/admin/admin-results-details-page.php +++ b/php/admin/admin-results-details-page.php @@ -169,7 +169,7 @@ function qsm_generate_results_details_tab() { $template .= $span_start. __( 'Phone:', 'quiz-master-next' ) .$span_end. $results_data->phone .$spanend; $template .= $span_start. __( 'Email:', 'quiz-master-next' ) .$span_end. $results_data->email .$spanend; } - $template .= apply_filters('qsm_admin_results_details_contact', "test", $results_array); + $template .= apply_filters('qsm_admin_results_details_contact', "", $results_array); $template .= ''; $template .= ''; $template .= ''; From 36742478fa2e3331701ad06239498b22b5d53490 Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Wed, 8 Mar 2023 17:03:55 +0530 Subject: [PATCH 15/21] option added to show featured images in result page --- php/admin/functions.php | 4 ++++ php/admin/settings-page.php | 18 ++++++++++++++++++ php/classes/class-qsm-install.php | 22 +++++++++++++++++++++- php/template-variables.php | 16 +++++++++------- 4 files changed, 52 insertions(+), 8 deletions(-) diff --git a/php/admin/functions.php b/php/admin/functions.php index 04c0c8e31..6e5c16187 100644 --- a/php/admin/functions.php +++ b/php/admin/functions.php @@ -709,6 +709,10 @@ class="qsm-opt-desc"> __( 'Show current page number', 'quiz-master-next' ), 'value' => $globalQuizsetting['enable_pagination_quiz'], ), + 'show_question_featured_image_in_result' => array( + 'option_name' => __( 'Show question featured image in results page', 'quiz-master-next' ), + 'value' => $globalQuizsetting['show_question_featured_image_in_result'], + ), 'progress_bar' => array( 'option_name' => __( 'Show progress bar', 'quiz-master-next' ), 'value' => $globalQuizsetting['enable_pagination_quiz'], diff --git a/php/admin/settings-page.php b/php/admin/settings-page.php index b2b3f5cec..22b9a365b 100644 --- a/php/admin/settings-page.php +++ b/php/admin/settings-page.php @@ -191,6 +191,7 @@ public function quiz_default_global_option_init() { add_settings_field( 'show-correct-answer-inline', __( 'Show correct answer inline', 'quiz-master-next' ), array( $this, 'qsm_global_show_correct_answer_inline' ), 'qsm_default_global_option_display', 'qmn-global-section' ); add_settings_field( 'retake-quiz', __( 'Retake Quiz', 'quiz-master-next' ), array( $this, 'qsm_global_retake_quiz' ), 'qsm_default_global_option_quiz_submission', 'qmn-global-section' ); add_settings_field( 'show-current-page-number', __( 'Show current page number', 'quiz-master-next' ), array( $this, 'qsm_global_show_current_page_number' ), 'qsm_default_global_option_display', 'qmn-global-section' ); + add_settings_field( 'show-current-page-number', __( 'Show question featured image in results page', 'quiz-master-next' ), array( $this, 'qsm_global_show_question_featured_image_in_result' ), 'qsm_default_global_option_display', 'qmn-global-section' ); add_settings_field( 'deselect-answer', __( 'Deselect Answer', 'quiz-master-next' ), array( $this, 'qsm_global_deselect_answer' ), 'qsm_default_global_option_general', 'qmn-global-section' ); add_settings_field( 'disable-description-on-quiz-result-page', __( 'Disable description on quiz result page?', 'quiz-master-next' ), array( $this, 'qsm_global_disable_description_on_quiz_result_page' ), 'qsm_default_global_option_general', 'qmn-global-section' ); add_settings_field( 'disable_mathjax', __( 'Disable MathJax?', 'quiz-master-next' ), array( $this, 'qsm_global_disable_mathjax' ), 'qsm_default_global_option_general', 'qmn-global-section' ); @@ -1102,6 +1103,23 @@ public function qsm_global_show_current_page_number() { '; } + /** + * Generates Quiz Global Field For Show question feature image in result + * + * @since 4.1.0 + * @return void + */ + public function qsm_global_show_question_featured_image_in_result() { + global $globalQuizsetting; + $qsm_show_question_featured_image_in_result = ( isset( $globalQuizsetting['show_question_featured_image_in_result'] ) && '' !== $globalQuizsetting['show_question_featured_image_in_result'] ? $globalQuizsetting['show_question_featured_image_in_result'] : '0' ); + echo '
+ +
+ +
+
'; + } + /** * Generates Quiz Global Field For Deselect Answer * diff --git a/php/classes/class-qsm-install.php b/php/classes/class-qsm-install.php index 437e7e294..bd8c913df 100644 --- a/php/classes/class-qsm-install.php +++ b/php/classes/class-qsm-install.php @@ -664,7 +664,7 @@ public function register_default_settings() { 'option_tab' => 'display', ); $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - + // Settings for quick result $field_array = array( 'id' => 'hide_correct_answer', @@ -772,6 +772,26 @@ public function register_default_settings() { ); $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); + // Setting for pagination of quiz + $field_array = array( + 'id' => 'show_question_featured_image_in_result', + 'label' => __( 'Show question featured image in results page', 'quiz-master-next' ), + 'type' => 'radio', + 'options' => array( + array( + 'label' => __( 'Yes', 'quiz-master-next' ), + 'value' => 1, + ), + array( + 'label' => __( 'No', 'quiz-master-next' ), + 'value' => 0, + ), + ), + 'default' => 0, + 'option_tab' => 'display', + ); + $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); + // Setting for pagination of quiz $field_array = array( 'id' => 'enable_deselect_option', diff --git a/php/template-variables.php b/php/template-variables.php index edb28d139..64508fc4f 100644 --- a/php/template-variables.php +++ b/php/template-variables.php @@ -1011,7 +1011,7 @@ function qsm_questions_answers_shortcode_to_text( $mlw_quiz_array, $qmn_question } else { $mlw_question_answer_display = str_replace( '%QUESTION%', '' . $question_description . '', $mlw_question_answer_display ); } - $mlw_question_answer_display = qsm_varibale_question_title_func( $mlw_question_answer_display, $answer['question_type'] ); + $mlw_question_answer_display = qsm_varibale_question_title_func( $mlw_question_answer_display, $answer['question_type'], "", $answer['id'] ); $extra_border_bottom_class = ''; $remove_border = true; if ( 6 == $answer['question_type'] ) { @@ -1549,23 +1549,25 @@ function qsm_varibale_question_title_func( $question, $question_type = '', $new_ $qmn_quiz_options = $mlwQuizMasterNext->quiz_settings->get_quiz_options(); + if ( $question_id ) { + $featureImageID = $mlwQuizMasterNext->pluginHelper->get_question_setting( $question_id, 'featureImageID' ); + if ( $featureImageID && isset( $qmn_quiz_options->show_question_featured_image_in_result ) && 1 === intval( $qmn_quiz_options->show_question_featured_image_in_result ) ) { + $question_display .= ''; + } + } + $question_numbering = ''; if ( isset( $qmn_quiz_options->question_numbering ) && 1 == $qmn_quiz_options->question_numbering && 6 != $question_type ) { $qmn_total_questions += 1; $question_numbering = '' . esc_html( $qmn_total_questions ) . '. '; } - if ( $question_id ) { - $featureImageID = $mlwQuizMasterNext->pluginHelper->get_question_setting( $question_id, 'featureImageID' ); - if ( $featureImageID ) { - $question_display .= ''; - } - } if ( '' !== $new_question_title ) { $new_question_title = $mlwQuizMasterNext->pluginHelper->qsm_language_support( htmlspecialchars_decode( $new_question_title, ENT_QUOTES ), "Question-{$question_id}", 'QSM Questions' ); $question_display .= "
" . $new_question_title . '
'; $polar_extra_class .= ' qsm_remove_bold'; } $question_display .= "
" . $question_numbering . do_shortcode( htmlspecialchars_decode( $question_title, ENT_QUOTES ) ) . '
'; + return $question_display; } From 60b2c3c10813c01a85a1d65bbdc79e87ebc06af9 Mon Sep 17 00:00:00 2001 From: etchirag Date: Thu, 9 Mar 2023 12:53:28 +0530 Subject: [PATCH 16/21] minor changes in css for button --- templates/qmn_primary.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/templates/qmn_primary.css b/templates/qmn_primary.css index 44b70940d..eb83fdf3f 100644 --- a/templates/qmn_primary.css +++ b/templates/qmn_primary.css @@ -366,8 +366,15 @@ label.inline .mlw_qmn_question, .qmn_pagination .mlw_previous { margin-right: 5px; + margin-top: 5px; } +.qmn_pagination .mlw_next, .qmn_pagination .qsm-submit-btn { + margin-top: 5px; +} + + + .qmn_pagination :nth-child(0) { order: 0; } .qmn_pagination :nth-child(1) { order: 1; } .qmn_pagination :nth-child(2) { order: 2; } From f0c0e6426ca9efd15e5dc20b20825dc04cb2d614 Mon Sep 17 00:00:00 2001 From: etchirag Date: Thu, 9 Mar 2023 13:18:15 +0530 Subject: [PATCH 17/21] removed extra space --- templates/qmn_primary.css | 2 -- 1 file changed, 2 deletions(-) diff --git a/templates/qmn_primary.css b/templates/qmn_primary.css index eb83fdf3f..d42a4a3ba 100644 --- a/templates/qmn_primary.css +++ b/templates/qmn_primary.css @@ -373,8 +373,6 @@ label.inline .mlw_qmn_question, margin-top: 5px; } - - .qmn_pagination :nth-child(0) { order: 0; } .qmn_pagination :nth-child(1) { order: 1; } .qmn_pagination :nth-child(2) { order: 2; } From 6971f00effbbc7f66148259af38496f336841b82 Mon Sep 17 00:00:00 2001 From: Vibina Date: Thu, 9 Mar 2023 15:30:26 +0530 Subject: [PATCH 18/21] core files code changed --- js/qsm-quiz.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/qsm-quiz.js b/js/qsm-quiz.js index ef39c0e1c..3984f357a 100644 --- a/js/qsm-quiz.js +++ b/js/qsm-quiz.js @@ -1442,8 +1442,8 @@ jQuery(function () { jQuery(document).on('click', ".qsm-submit-btn", function (event) { event.preventDefault(); - var form = jQuery(this).closest('form')[0]; - var form_id = form.id; + var quiz_id = +jQuery(this).closest('.qmn_quiz_container').find('.qmn_quiz_id').val(); + var form_id = "quizForm"+quiz_id; var recaptcha = jQuery('#' + form_id).find("#qsm_grecaptcha_v3"); if (!recaptcha.length) { qmnFormSubmit(form_id); From 9bf613c21f5d7981123178247e5f7e2440cd29d9 Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Thu, 9 Mar 2023 19:21:23 +0530 Subject: [PATCH 19/21] update changelog 8.1.1 --- mlw_quizmaster2.php | 4 ++-- readme.txt | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/mlw_quizmaster2.php b/mlw_quizmaster2.php index ff4fb2cfd..0ff7e171c 100644 --- a/mlw_quizmaster2.php +++ b/mlw_quizmaster2.php @@ -2,7 +2,7 @@ /** * Plugin Name: Quiz And Survey Master * Description: Easily and quickly add quizzes and surveys to your website. - * Version: 8.1.0 + * Version: 8.1.1 * Author: ExpressTech * Author URI: https://quizandsurveymaster.com/ * Plugin URI: https://expresstech.io/ @@ -43,7 +43,7 @@ class MLWQuizMasterNext { * @var string * @since 4.0.0 */ - public $version = '8.1.0'; + public $version = '8.1.1'; /** * QSM Alert Manager Object diff --git a/readme.txt b/readme.txt index b6677b6ba..a84e37c3e 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: quiz, survey, lead, test, score, exam, questionnaire, question,wordpress q Requires at least: 4.9 Tested up to: 6.1 Requires PHP: 5.4 -Stable tag: 8.1.0 +Stable tag: 8.1.1 License: GPLv2 License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -163,6 +163,16 @@ This is usually a theme conflict. You can [checkout out our common conflict solu 18. Database == Changelog == += 8.1.1 (March 09, 2023) = +* Feature: Added an option to highlight the correct answer if the user selected the wrong answer +* Feature: Added an option to show/hide the question's featured image on the result page +* Bug: Fixed an issue with adding a class for the correct/incorrect answers option +* Bug: Fixed an encoding issue in the email header +* Bug: Fixed an issue with immediately ending the quiz if the user selects the wrong answer in pagination +* Enhancement: Improved the user interface for the question bank popup and options tabs +* Enhancement: Improved the user interface for the quiz next and submit buttons + + = 8.1.0 (Feb 27, 2023) = * Feature: Added a new feature that allows users to show or hide correct answers on the result page * Bug: Fixed a bug that caused issues with the required field for the polar question type From b56eca23899151856539cadc2657c310938351c1 Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Thu, 9 Mar 2023 19:37:06 +0530 Subject: [PATCH 20/21] fixed sonar issue --- js/qsm-quiz.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/qsm-quiz.js b/js/qsm-quiz.js index 3984f357a..f6504e617 100644 --- a/js/qsm-quiz.js +++ b/js/qsm-quiz.js @@ -328,11 +328,11 @@ var qsmTimerInterval = []; jQuery(document).on('click', '.qsm-quiz-container-' + quizID + ' .qsm-pagination .qsm-next', function (event) { jQuery(document).trigger('qsm_next_button_click_before', [quizID]); event.preventDefault(); - var $quizForm = QSM.getQuizForm(quizID); + let $quizForm = QSM.getQuizForm(quizID); jQuery('.qmn_radio_answers:visible input:checked , .qmn_check_answers:visible input:checked , .qsm_select:visible').each(function () { if (qmn_quiz_data[quizID].end_quiz_if_wrong == 1 && jQuery(this).is(':visible') && jQuery(this).is('input, select')) { if (jQuery(this).parents('.qmn_radio_answers, .qsm_check_answer')) { - var question_id = jQuery(this).attr('name').split('question')[1], + let question_id = jQuery(this).attr('name').split('question')[1], value = jQuery(this).val(), $this = jQuery(this).parents('.quiz_section'); if (value !== "") { From 3e66350f82e1fc6e4700d1a542fe010e09a98ac2 Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Thu, 9 Mar 2023 19:37:48 +0530 Subject: [PATCH 21/21] fixed sonar issue --- js/qsm-quiz.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/js/qsm-quiz.js b/js/qsm-quiz.js index f6504e617..5ec8416a1 100644 --- a/js/qsm-quiz.js +++ b/js/qsm-quiz.js @@ -1034,9 +1034,9 @@ function qmnInit() { let key = parseInt(quiz.quiz_id); if (qmn_quiz_data[key].ajax_show_correct === '1') { jQuery('#quizForm' + qmn_quiz_data[key].quiz_id + ' .qmn_quiz_radio').change(function () { - $this = jQuery(this); - var value = $this.val(); - var question_id = $this.attr('name').replace(/question/i, ''); + let $this = jQuery(this); + let value = $this.val(); + let question_id = $this.attr('name').replace(/question/i, ''); jQuery.ajax({ type: 'POST', url: qmn_ajax_object.ajaxurl, @@ -1046,7 +1046,7 @@ function qmnInit() { answer: value, }, success: function (response) { - var data = jQuery.parseJSON(response); + let data = jQuery.parseJSON(response); if (data.success == 'correct') { $this.parent().addClass("qmn_correct_answer"); @@ -1368,13 +1368,13 @@ function qmnInitPagination(quiz_id) { jQuery(document).on("click", ".qsm-quiz-container-" + quiz_id + " .mlw_next", function (event) { event.preventDefault(); - var quiz_id = +jQuery(this).closest('.qmn_quiz_container').find('.qmn_quiz_id').val(); - var $quizForm = QSM.getQuizForm(quiz_id); + let quiz_id = +jQuery(this).closest('.qmn_quiz_container').find('.qmn_quiz_id').val(); + let $quizForm = QSM.getQuizForm(quiz_id); jQuery(document).trigger('qsm_auto_next_button_click_before', [quiz_id]); jQuery('.qmn_radio_answers:visible input:checked , .qmn_check_answers:visible input:checked , .qsm_select:visible').each(function () { if (qmn_quiz_data[quiz_id].end_quiz_if_wrong == 1 && jQuery(this).is(':visible') && jQuery(this).is('input, select')) { if (jQuery(this).parents('.qmn_radio_answers, .qsm_check_answer')) { - var question_id = jQuery(this).attr('name').split('question')[1], + let question_id = jQuery(this).attr('name').split('question')[1], value = jQuery(this).val(), $this = jQuery(this).parents('.quiz_section'); if (value !== "") { @@ -1442,17 +1442,17 @@ jQuery(function () { jQuery(document).on('click', ".qsm-submit-btn", function (event) { event.preventDefault(); - var quiz_id = +jQuery(this).closest('.qmn_quiz_container').find('.qmn_quiz_id').val(); - var form_id = "quizForm"+quiz_id; - var recaptcha = jQuery('#' + form_id).find("#qsm_grecaptcha_v3"); + let quiz_id = +jQuery(this).closest('.qmn_quiz_container').find('.qmn_quiz_id').val(); + let form_id = "quizForm"+quiz_id; + let recaptcha = jQuery('#' + form_id).find("#qsm_grecaptcha_v3"); if (!recaptcha.length) { qmnFormSubmit(form_id); return false; } // Proceed reCaptcha v3 - var site_key = jQuery('#' + form_id).find("#qsm_grecaptcha_v3_sitekey").val(); - var submit_action = jQuery('#' + form_id).find("#qsm_grecaptcha_v3_nonce").val(); + let site_key = jQuery('#' + form_id).find("#qsm_grecaptcha_v3_sitekey").val(); + let submit_action = jQuery('#' + form_id).find("#qsm_grecaptcha_v3_nonce").val(); grecaptcha.ready(function () { grecaptcha.execute(site_key, { action: submit_action }).then(function (token) { jQuery('#' + form_id).find("#qsm_grecaptcha_v3_response").val(token);