Skip to content

Commit

Permalink
Merge pull request #2321 from QuizandSurveyMaster/dev
Browse files Browse the repository at this point in the history
Release 8.1.14
  • Loading branch information
etvarun authored Aug 24, 2023
2 parents 83e87f0 + 567b1fa commit 9999217
Show file tree
Hide file tree
Showing 18 changed files with 124 additions and 95 deletions.
38 changes: 17 additions & 21 deletions js/qsm-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,8 @@ var QSMContact;
mediaButtons: true,
tinymce: {
forced_root_block: '',
toolbar1: 'formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,strikethrough,hr,forecolor,pastetext,removeformat,codeformat,charmap,undo,redo'
toolbar1: 'formatselect,bold,italic,underline,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,wp_more,fullscreen,wp_adv',
toolbar2: 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help'
},
quicktags: true,
};
Expand Down Expand Up @@ -2286,7 +2287,8 @@ var import_button;
mediaButtons: true,
tinymce: {
forced_root_block: '',
toolbar1: 'formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,strikethrough,hr,forecolor,pastetext,removeformat,codeformat,charmap,undo,redo'
toolbar1: 'formatselect,bold,italic,underline,bullist,numlist,blockquote,alignleft,aligncenter,alignright,alignjustify,link,wp_more,fullscreen,wp_adv',
toolbar2: 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help'
},
quicktags: true,
};
Expand Down Expand Up @@ -2469,10 +2471,8 @@ var import_button;
$.each(fut_arr, function (i) {
$(".questionElements input[name='" + index + "[]']:checkbox[value='" + fut_arr[i] + "']").attr("checked", "true").prop('checked', true);
});
} else {
if (value != null) {
$('#' + index).val(value);
}
} else if (value != null) {
$('#' + index).val(value);
}
}
if (index == 'matchAnswer') {
Expand Down Expand Up @@ -2522,7 +2522,8 @@ var import_button;
mediaButtons: true,
tinymce: {
forced_root_block: '',
toolbar1: 'formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,strikethrough,hr,forecolor,pastetext,removeformat,codeformat,charmap,undo,redo'
toolbar1: 'formatselect,bold,italic,underline,bullist,numlist,blockquote,alignleft,aligncenter,alignright,alignjustify,link,wp_more,fullscreen,wp_adv',
toolbar2: 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help'
},
quicktags: true,
};
Expand Down Expand Up @@ -2628,12 +2629,10 @@ var import_button;
current_element = current_page_section.find(".question").eq($("#current_question_position").val() - 1);
if ( 0 == new_element.length ) {
new_page_section.append(current_element.clone());
} else {
if ( 1 == $("#current_question_position").val() && $("#changed_question_page_no").val() == $("#current_question_page_no").val() ) {
} else if ( 1 == $("#current_question_position").val() && $("#changed_question_page_no").val() == $("#current_question_page_no").val() ) {
new_element.after(current_element.clone());
} else {
new_element.before(current_element.clone());
}
} else {
new_element.before(current_element.clone());
}
current_element.remove();
let question_id = $("#current_question_id").val();
Expand Down Expand Up @@ -2793,15 +2792,11 @@ var import_button;
MicroModal.show('modal-8');
return false;
}
} else {
if (blanks == null || options_length === 0) {
$('.modal-8-table').html(qsm_admin_messages.blank_required_validation);
MicroModal.show('modal-8');
return false;
}
} else if (blanks == null || options_length === 0) {
$('.modal-8-table').html(qsm_admin_messages.blank_required_validation);
MicroModal.show('modal-8');
return false;
}


}
$('#save-edit-question-spinner').addClass('is-active');
var model_html = $('#modal-1-content').html();
Expand Down Expand Up @@ -3397,7 +3392,8 @@ var import_button;
mediaButtons: true,
tinymce: {
forced_root_block: '',
toolbar1: 'formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,strikethrough,hr,forecolor,pastetext,removeformat,codeformat,charmap,undo,redo'
toolbar1: 'formatselect,bold,italic,underline,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,wp_more,fullscreen,wp_adv',
toolbar2: 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help'
},
quicktags: true,
};
Expand Down
82 changes: 37 additions & 45 deletions js/qsm-quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ var qsmTimerInterval = [];
},
type: 'POST',
success: function (response) {
jQuery('.qsm-quiz-container-' + quizID + '').prepend('<input type="hidden" name="qsm_nonce" id="qsm_nonce_'+quizID+'" value="'+response.data+'"/>');
jQuery('.qsm-quiz-container-' + quizID + '').prepend('<input type="hidden" name="qsm_unique_key" id="qsm_unique_key_'+quizID+'" value="'+response.data.unique_key+'"/>');
jQuery('.qsm-quiz-container-' + quizID + '').prepend('<input type="hidden" name="qsm_nonce" id="qsm_nonce_'+quizID+'" value="'+response.data.nonce+'"/>');
}
});
QSM.initPagination(quizID);
Expand Down Expand Up @@ -83,27 +84,23 @@ var qsmTimerInterval = [];
$('.qsm-quiz-container-' + quizID).find('.stoptimer-p').show();
}
// ...else, we must be using the questions per page option.
} else {
if (qmn_quiz_data[quizID].hasOwnProperty('pagination') && qmn_quiz_data[quizID].first_page) {
$(document).on('click', '.qsm-quiz-container-' + quizID + ' .mlw_next', function (event) {
event.preventDefault();
if ( qmn_quiz_data[quizID].hasOwnProperty('advanced_timer') && qmn_quiz_data[quizID].advanced_timer.hasOwnProperty('show_stop_timer') ) {
var start_timer = parseInt(qmn_quiz_data[quizID].advanced_timer.start_timer_page);
if ($('.qsm-quiz-container-' + quizID).find('.qmn_pagination > .slide_number_hidden').val() == start_timer) {
QSM.activateTimer(quizID);
$('.qsm-quiz-container-' + quizID).find('.stoptimer-p').show();
}
} else {
if (!qmn_quiz_data[quizID].timerStatus && (0 == $('.quiz_begin:visible').length || (1 == $('.quiz_begin:visible').length && qmnValidatePage('quizForm' + quizID)))) {
QSM.activateTimer(quizID);
$('.qsm-quiz-container-' + quizID).find('.stoptimer-p').show();
}
} else if (qmn_quiz_data[quizID].hasOwnProperty('pagination') && qmn_quiz_data[quizID].first_page) {
$(document).on('click', '.qsm-quiz-container-' + quizID + ' .mlw_next', function (event) {
event.preventDefault();
if ( qmn_quiz_data[quizID].hasOwnProperty('advanced_timer') && qmn_quiz_data[quizID].advanced_timer.hasOwnProperty('show_stop_timer') ) {
var start_timer = parseInt(qmn_quiz_data[quizID].advanced_timer.start_timer_page);
if ($('.qsm-quiz-container-' + quizID).find('.qmn_pagination > .slide_number_hidden').val() == start_timer) {
QSM.activateTimer(quizID);
$('.qsm-quiz-container-' + quizID).find('.stoptimer-p').show();
}
});
} else {
QSM.activateTimer(quizID);
$('.qsm-quiz-container-' + quizID).find('.stoptimer-p').show();
}
} else if (!qmn_quiz_data[quizID].timerStatus && (0 == $('.quiz_begin:visible').length || (1 == $('.quiz_begin:visible').length && qmnValidatePage('quizForm' + quizID)))) {
QSM.activateTimer(quizID);
$('.qsm-quiz-container-' + quizID).find('.stoptimer-p').show();
}
});
} else {
QSM.activateTimer(quizID);
$('.qsm-quiz-container-' + quizID).find('.stoptimer-p').show();
}
jQuery(document).trigger('qsm_init_timer_after', [quizID]);
},
Expand Down Expand Up @@ -180,7 +177,9 @@ var qsmTimerInterval = [];
// Updates timer element and title on browser tab.
var $timer = QSM.getTimer(quizID);
$timer.text(display);
document.title = display + ' ' + qsmTitleText;
if (0 < qmn_quiz_data[quizID].timer_limit) {
document.title = display + ' ' + qsmTitleText;
}

/*CUSTOM TIMER*/
if (qmn_quiz_data[quizID].hasOwnProperty('advanced_timer') && qmn_quiz_data[quizID].advanced_timer.hasOwnProperty('show_stop_timer') && qmn_quiz_data[quizID].advanced_timer.timer_design == 'big_timer') {
Expand All @@ -204,7 +203,7 @@ var qsmTimerInterval = [];
}

// If timer is run out, disable fields.
if (0 >= secondsRemaining) {
if (0 >= secondsRemaining && 0 < qmn_quiz_data[quizID].timer_limit) {
clearInterval(qmn_quiz_data[quizID].timerInterval);
$(".mlw_qmn_quiz input:radio").attr('disabled', true);
$(".mlw_qmn_quiz input:checkbox").attr('disabled', true);
Expand Down Expand Up @@ -481,11 +480,9 @@ var qsmTimerInterval = [];
QSM.activateTimer(quizID);
$('.qsm-quiz-container-' + quizID).find('.stoptimer-p').show();
}
} else {
if (!qmn_quiz_data[quizID].timerStatus) {
QSM.activateTimer(quizID);
$('.qsm-quiz-container-' + quizID).find('.stoptimer-p').show();
}
} else if (!qmn_quiz_data[quizID].timerStatus) {
QSM.activateTimer(quizID);
$('.qsm-quiz-container-' + quizID).find('.stoptimer-p').show();
}

}
Expand Down Expand Up @@ -584,14 +581,12 @@ var qsmTimerInterval = [];
var timerRemaning = localStorage.getItem('mlw_time_q' + quizID + '_page' + pid);
if (timerStoped != 'undefined' && timerStoped > 0) {
seconds = timerStoped;
} else {
if ('yes' == timerStarted) {
if (0 < timerRemaning) {
seconds = parseInt(timerRemaning);
}
} else {
seconds = parseFloat($curr_page_opt.pagetimer) * 60;
} else if ('yes' == timerStarted) {
if (0 < timerRemaning) {
seconds = parseInt(timerRemaning);
}
} else {
seconds = parseFloat($curr_page_opt.pagetimer) * 60;
}
qmn_quiz_data[quizID].qpages[pid].timerRemaning = seconds;
/* Makes the timer appear. */
Expand Down Expand Up @@ -1015,6 +1010,7 @@ function qmnFormSubmit(quiz_form_id) {
});
fd.append("action", 'qmn_process_quiz');
fd.append("nonce", jQuery('#qsm_nonce_' + quiz_id ).val() );
fd.append("qsm_unique_key", jQuery('#qsm_unique_key_' + quiz_id ).val() );
fd.append("currentuserTime", Math.round(new Date().getTime() / 1000));
fd.append("currentuserTimeZone", Intl.DateTimeFormat().resolvedOptions().timeZone);

Expand Down Expand Up @@ -1883,22 +1879,18 @@ function qsm_question_quick_result_js(question_id, answer, answer_type = '', sho
if (answer_array[answer[key]] !== undefined) {
if (1 == answer_array[answer[key]][2]) {
answer_count++;
} else {
if (answer[key] !== undefined) {
answer_count--;
}
} else if (answer[key] !== undefined) {
answer_count--;
}
}
if (1 == value[2]) {
total_correct_answer++;
}
}
} else {
if (parseInt(answer) === parseInt(key) && 1 === parseInt(value[2])) {
got_ans = true;
correct_answer = true;
break;
}
} else if (parseInt(answer) === parseInt(key) && 1 === parseInt(value[2])) {
got_ans = true;
correct_answer = true;
break;
}
}

Expand Down
4 changes: 2 additions & 2 deletions mlw_quizmaster2.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: Quiz And Survey Master
* Description: Easily and quickly add quizzes and surveys to your website.
* Version: 8.1.13
* Version: 8.1.14
* Author: ExpressTech
* Author URI: https://quizandsurveymaster.com/
* Plugin URI: https://expresstech.io/
Expand Down Expand Up @@ -43,7 +43,7 @@ class MLWQuizMasterNext {
* @var string
* @since 4.0.0
*/
public $version = '8.1.13';
public $version = '8.1.14';

/**
* QSM Alert Manager Object
Expand Down
1 change: 1 addition & 0 deletions php/admin/options-page-results-page-tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ function qsm_options_results_tab_template(){
<p><?php esc_html_e( 'Create the results page that should be shown when the conditions are met.', 'quiz-master-next' ); ?></p>
</div>
<textarea id="results-page-{{ data.id }}" class="results-page-template">{{{ data.page }}}</textarea>
<?php do_action( 'qsm_result_page_before_redirect_input', $quiz_id, $categories ); ?>
<p><?php esc_html_e( 'Or, redirect the user by entering the URL below:', 'quiz-master-next' ); ?></p>
<input type="text" class="results-page-redirect" value="<# if ( data.redirect ) { #>{{ data.redirect }}<# } #>">
<?php do_action( 'qsm_result_page_after', $quiz_id, $categories ); ?>
Expand Down
8 changes: 8 additions & 0 deletions php/admin/options-page-text-tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ function mlw_options_text_tab_content() {
wp_editor( htmlspecialchars_decode( $value_answer, ENT_QUOTES ), 'qsm_question_text_message', array(
'editor_height' => 250,
'textarea_rows' => 10,
'tinymce' => array(
'toolbar1' => 'formatselect,bold,italic,underline,bullist,numlist,blockquote,alignleft,aligncenter,alignright,alignjustify,link,wp_more,fullscreen,wp_adv',
'toolbar2' => 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help',
),
) );
?>
</div>
Expand Down Expand Up @@ -148,6 +152,10 @@ function mlw_options_text_tab_content() {
wp_editor( htmlspecialchars_decode( $value_answer, ENT_QUOTES ), 'qsm_question_text_message_variable', array(
'editor_height' => 250,
'textarea_rows' => 10,
'tinymce' => array(
'toolbar1' => 'formatselect,bold,italic,underline,bullist,numlist,blockquote,alignleft,aligncenter,alignright,alignjustify,link,wp_more,fullscreen,wp_adv',
'toolbar2' => 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help',
),
) );
?>
</div>
Expand Down
9 changes: 8 additions & 1 deletion php/admin/settings-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,14 @@ public function results_details_template() {
<p>The answers were as follows:</p>
%QUESTIONS_ANSWERS%';
}
wp_editor( $template, 'results_template', array( 'textarea_name' => 'qmn-settings[results_details_template]' ) );
wp_editor( $template, 'results_template', array(
'textarea_name' => 'qmn-settings[results_details_template]',
'tinymce' => array(
'toolbar1' => 'formatselect,bold,italic,underline,bullist,numlist,blockquote,alignleft,aligncenter,alignright,alignjustify,link,wp_more,fullscreen,wp_adv',
'toolbar2' => 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help',
),
)
);
}

/**
Expand Down
16 changes: 9 additions & 7 deletions php/classes/class-qmn-log-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ public function register_post_type() {
/* logs post type */
$settings = (array) get_option( 'qmn-settings' );
$log_args = array(
'labels' => array( 'name' => 'QSM Logs' ),
'public' => ! empty( $settings['enable_qsm_log'] ) && $settings['enable_qsm_log'],
'query_var' => false,
'rewrite' => false,
'capability_type' => 'post',
'supports' => array( 'title', 'editor' ),
'can_export' => false,
'labels' => array( 'name' => 'QSM Logs' ),
'public' => ! empty( $settings['enable_qsm_log'] ) && $settings['enable_qsm_log'],
'query_var' => false,
'publicly_queryable' => false,
'rewrite' => false,
'capability_type' => 'post',
'supports' => array( 'title', 'editor' ),
'can_export' => false,
'exclude_from_search' => true,
);

// Registers QSM logs post type with filtered $args
Expand Down
1 change: 1 addition & 0 deletions php/classes/class-qmn-plugin-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ public function register_question_type( $name, $display_function, $graded, $revi
'slug' => $slug,
'options' => $options,
);
$new_type = apply_filters( 'register_question_type_new_type',$new_type );
$this->question_types[ $slug ] = $new_type;
}

Expand Down
7 changes: 5 additions & 2 deletions php/classes/class-qmn-quiz-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ public function submit_results( $qmn_quiz_options, $qmn_array_for_variables ) {
$result_display = apply_filters( 'qmn_after_check_answers', $result_display, $qmn_quiz_options, $qmn_array_for_variables );
$qmn_array_for_variables['comments'] = $this->check_comment_section( $qmn_quiz_options, $qmn_array_for_variables );
$result_display = apply_filters( 'qmn_after_check_comments', $result_display, $qmn_quiz_options, $qmn_array_for_variables );
$unique_id = uniqid();
$unique_id = ! empty( $_REQUEST['qsm_unique_key'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['qsm_unique_key'] ) ) : uniqid();
$results_id = 0;
// Creates our results array.
$results_array = array(
Expand Down Expand Up @@ -2598,7 +2598,10 @@ public function qsm_process_background_email() {
*/
public function qsm_create_quiz_nonce() {
$quiz_id = ! empty( $_REQUEST['quiz_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['quiz_id'] ) ) : 0;
wp_send_json_success( wp_create_nonce( 'qsm_submit_quiz_' . $quiz_id ) );
wp_send_json_success( array(
'nonce' => wp_create_nonce( 'qsm_submit_quiz_' . $quiz_id ),
'unique_key' => uniqid(),
) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion php/classes/class-qsm-contact-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public static function load_fields( $type = 'display' ) {
global $mlwQuizMasterNext;
$default_fields = self::default_fields();
$fields = maybe_unserialize( $mlwQuizMasterNext->pluginHelper->get_quiz_setting( 'contact_form' ) );
if ( ! empty( $fields ) ) {
if ( ! empty( $fields ) && is_array( $fields ) ) {
$used_keys = array();
foreach ( $fields as $index => $field ) {
/**
Expand Down
7 changes: 6 additions & 1 deletion php/classes/class-qsm-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,12 @@ public static function generate_editor_field( $field, $value ) {
</label>
</th>
<td>
<?php wp_editor( htmlspecialchars_decode( $value, ENT_QUOTES ), $field["id"] ); ?>
<?php wp_editor( htmlspecialchars_decode( $value, ENT_QUOTES ), $field["id"], array(
'tinymce' => array(
'toolbar1' => 'formatselect,bold,italic,underline,bullist,numlist,blockquote,alignleft,aligncenter,alignright,alignjustify,link,wp_more,fullscreen,wp_adv',
'toolbar2' => 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help',
),
) ); ?>
</td>
</tr>
<?php
Expand Down
Loading

0 comments on commit 9999217

Please sign in to comment.