diff --git a/js/qsm-admin.js b/js/qsm-admin.js index f5ca5e80..a6a64a5c 100644 --- a/js/qsm-admin.js +++ b/js/qsm-admin.js @@ -3051,7 +3051,6 @@ var QSM_Quiz_Broadcast_Channel; } CurrentElement.parents('.question').next('.questionElements').slideDown('slow'); $('#modal-1-content').html(questionElements); - //MicroModal.show( 'modal-1' ); $('.questions').sortable('disable'); $('.page').sortable('disable'); @@ -4144,7 +4143,6 @@ var QSM_Quiz_Broadcast_Channel; .fail(QSMAdmin.displayjQueryError); }, loadResults: function () { - //QSMAdmin.displayAlert( 'Loading results pages...', 'info' ); $.ajax({ url: wpApiSettings.root + 'quiz-survey-master/v1/quizzes/' + qsmResultsObject.quizID + '/results', headers: { 'X-WP-Nonce': qsmResultsObject.nonce }, diff --git a/js/qsm-quiz.js b/js/qsm-quiz.js index c00b575d..0cd71090 100644 --- a/js/qsm-quiz.js +++ b/js/qsm-quiz.js @@ -1875,10 +1875,10 @@ jQuery(document).ready(function () { let captchaElement = jQuery('#mlw_code_captcha'); if (captchaElement.length !== 0) { mlw_code = ''; - var mlw_chars = '0123456789ABCDEFGHIJKL!@#$%^&*()MNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'; - var mlw_code_length = 5; - for (var i = 0; i < mlw_code_length; i++) { - var rnum = Math.floor(Math.random() * mlw_chars.length); + let mlw_chars = '0123456789ABCDEFGHIJKL!@#$%^&*()MNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'; + let mlw_code_length = 5; + for (let i = 0; i < mlw_code_length; i++) { + let rnum = Math.floor(Math.random() * mlw_chars.length); mlw_code += mlw_chars.substring(rnum, rnum + 1); } var captchaCanvas = document.getElementById('mlw_captcha'); diff --git a/php/template-variables.php b/php/template-variables.php index d799fc1e..b8dbcbc4 100644 --- a/php/template-variables.php +++ b/php/template-variables.php @@ -394,13 +394,20 @@ function mlw_qmn_variable_amount_incorrect( $content, $mlw_quiz_array ) { function mlw_qmn_variable_total_questions( $content, $mlw_quiz_array ) { global $wp_current_filter; - if ( ! empty( $wp_current_filter[1] ) && 'mlw_qmn_template_variable_quiz_page' == $wp_current_filter[1] ) { + if ( is_array( $wp_current_filter ) && ! empty( $wp_current_filter ) && in_array( 'mlw_qmn_template_variable_quiz_page', $wp_current_filter, true ) ) { global $wpdb; $table_name = $wpdb->prefix . 'mlw_quizzes'; $quiz_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table_name WHERE quiz_id=%d", $mlw_quiz_array['quiz_id'] ) ); $quiz_settings = maybe_unserialize($quiz_data->quiz_settings); $quiz_questions = ! empty( $quiz_settings['pages'] ) ? maybe_unserialize( $quiz_settings['pages'] ) : array(); - $total_questions = isset( $quiz_questions[0] ) ? count( $quiz_questions[0] ) : 0; + $total_questions = 0; + if ( ! empty( $quiz_questions ) && isset( $quiz_questions[0] ) ) { + foreach ( $quiz_questions as $sub_questions ) { + if ( is_array( $sub_questions ) ) { + $total_questions += count( $sub_questions ); + } + } + } $content = str_replace( '%TOTAL_QUESTIONS%', $total_questions, $content ); return $content; }