Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cu 86cxan40f total question variable count issue #2737

Merged
merged 4 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions js/qsm-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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 },
Expand Down
8 changes: 4 additions & 4 deletions js/qsm-quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
11 changes: 9 additions & 2 deletions php/template-variables.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading