diff --git a/js/qsm-admin.js b/js/qsm-admin.js index d99d27498..8a46d48e8 100644 --- a/js/qsm-admin.js +++ b/js/qsm-admin.js @@ -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, }; @@ -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, }; @@ -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') { @@ -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, }; @@ -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(); @@ -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(); @@ -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, }; diff --git a/js/qsm-quiz.js b/js/qsm-quiz.js index a5bb4ef51..29e9a804a 100644 --- a/js/qsm-quiz.js +++ b/js/qsm-quiz.js @@ -34,7 +34,8 @@ var qsmTimerInterval = []; }, type: 'POST', success: function (response) { - jQuery('.qsm-quiz-container-' + quizID + '').prepend(''); + jQuery('.qsm-quiz-container-' + quizID + '').prepend(''); + jQuery('.qsm-quiz-container-' + quizID + '').prepend(''); } }); QSM.initPagination(quizID); @@ -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]); }, @@ -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') { @@ -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); @@ -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(); } } @@ -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. */ @@ -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); @@ -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; } } diff --git a/mlw_quizmaster2.php b/mlw_quizmaster2.php index ce760fb59..b0e77a710 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.13 + * Version: 8.1.14 * 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.13'; + public $version = '8.1.14'; /** * QSM Alert Manager Object diff --git a/php/admin/options-page-results-page-tab.php b/php/admin/options-page-results-page-tab.php index ade350706..57747f75d 100644 --- a/php/admin/options-page-results-page-tab.php +++ b/php/admin/options-page-results-page-tab.php @@ -219,6 +219,7 @@ function qsm_options_results_tab_template(){

+

diff --git a/php/admin/options-page-text-tab.php b/php/admin/options-page-text-tab.php index 37f04b945..438cc7bb2 100644 --- a/php/admin/options-page-text-tab.php +++ b/php/admin/options-page-text-tab.php @@ -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', + ), ) ); ?> @@ -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', + ), ) ); ?> diff --git a/php/admin/settings-page.php b/php/admin/settings-page.php index 0a42658a8..884b32cb0 100644 --- a/php/admin/settings-page.php +++ b/php/admin/settings-page.php @@ -462,7 +462,14 @@ public function results_details_template() {

The answers were as follows:

%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', + ), + ) + ); } /** diff --git a/php/classes/class-qmn-log-manager.php b/php/classes/class-qmn-log-manager.php index 0164bcfe9..fab384560 100644 --- a/php/classes/class-qmn-log-manager.php +++ b/php/classes/class-qmn-log-manager.php @@ -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 diff --git a/php/classes/class-qmn-plugin-helper.php b/php/classes/class-qmn-plugin-helper.php index a7e6ef11f..de13793f0 100644 --- a/php/classes/class-qmn-plugin-helper.php +++ b/php/classes/class-qmn-plugin-helper.php @@ -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; } diff --git a/php/classes/class-qmn-quiz-manager.php b/php/classes/class-qmn-quiz-manager.php index beb72813a..ea8af953a 100644 --- a/php/classes/class-qmn-quiz-manager.php +++ b/php/classes/class-qmn-quiz-manager.php @@ -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( @@ -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(), + ) ); } } diff --git a/php/classes/class-qsm-contact-manager.php b/php/classes/class-qsm-contact-manager.php index 7b5440a93..9d20c9cb8 100644 --- a/php/classes/class-qsm-contact-manager.php +++ b/php/classes/class-qsm-contact-manager.php @@ -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 ) { /** diff --git a/php/classes/class-qsm-fields.php b/php/classes/class-qsm-fields.php index 0e31153f8..3a147eb66 100644 --- a/php/classes/class-qsm-fields.php +++ b/php/classes/class-qsm-fields.php @@ -443,7 +443,12 @@ public static function generate_editor_field( $field, $value ) { - + 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', + ), +) ); ?> prefix . 'mlw_results'; $data = $mlwQuizMasterNext->version; if ( ! get_option( 'qmn_original_version' ) ) { add_option( 'qmn_original_version', $data ); @@ -2150,6 +2152,11 @@ public function update() { update_option( 'qmn-settings', $settings ); } + // Update 8.1.14 + if ( ! $wpdb->query("SHOW KEYS FROM {$results_table_name} WHERE Key_name = 'unique_id_unique'" ) ) { + $results = $wpdb->query("ALTER TABLE {$results_table_name} ADD UNIQUE (unique_id)"); + } + // Update 8.0.3 QSM_Migrate::fix_duplicate_questions(); QSM_Migrate::fix_deleted_quiz_posts(); diff --git a/php/classes/class-qsm-migrate.php b/php/classes/class-qsm-migrate.php index 73dc2ca05..02c67ae12 100644 --- a/php/classes/class-qsm-migrate.php +++ b/php/classes/class-qsm-migrate.php @@ -145,8 +145,8 @@ public static function fix_duplicate_questions() { /** * Setup new data */ - $settings['pages'] = maybe_serialize( $pages ); - $settings['qpages'] = maybe_serialize( $qpages ); + $settings['pages'] = ! empty( $pages ) && is_array( $pages) ? maybe_serialize( $pages ) : ""; + $settings['qpages'] = ! empty( $qpages ) && is_array( $qpages) ? maybe_serialize( $qpages ) : ""; /** * Update quiz settings */ diff --git a/php/classes/question-types/class-question-review-choice.php b/php/classes/question-types/class-question-review-choice.php index 52560f962..749e2130a 100644 --- a/php/classes/question-types/class-question-review-choice.php +++ b/php/classes/question-types/class-question-review-choice.php @@ -48,7 +48,7 @@ public function set_answer_status() { if ( ( $this->correct_answer_logic && count( $this->correct_answer ) === $user_correct_ans || ! $this->correct_answer_logic && $user_correct_ans === $total_correct_ans ) && $is_user_attempted ) { $this->answer_status = 'correct'; } - if ( in_array( $this->question_type, array( 0, 1 ), true ) && 0 < $user_correct_ans ) { + if ( in_array( intval( $this->question_type ), array( 0, 1 ), true ) && 0 < $user_correct_ans ) { $this->answer_status = 'correct'; } } diff --git a/php/question-types/qsm-question-title.php b/php/question-types/qsm-question-title.php index 95a05dc8a..4427e61eb 100644 --- a/php/question-types/qsm-question-title.php +++ b/php/question-types/qsm-question-title.php @@ -20,7 +20,7 @@ function qsm_question_title_func( $question, $question_type = '', $new_question_ if ( isset( $qmn_quiz_options->enable_deselect_option ) && 1 == $qmn_quiz_options->enable_deselect_option && ( 'multiple_choice' === $question_type || 'horizontal_multiple_choice' === $question_type ) ) { $deselect_answer = ''.__( 'Deselect Answer', 'quiz-master-next' ).''; } - + do_action('qsm_question_title_func_before',$question, $question_type, $new_question_title, $question_id ); if ( '' !== $new_question_title ) { $new_question_title = $mlwQuizMasterNext->pluginHelper->qsm_language_support( htmlspecialchars_decode( $new_question_title, ENT_QUOTES ), "Question-{$question_id}", "QSM Questions"); ?> @@ -52,4 +52,5 @@ function qsm_question_title_func( $question, $question_type = '', $new_question_

quiz_settings ); $options = maybe_unserialize( $setting['quiz_options'] ); $start_date = strtotime( $options['scheduled_time_start'] ); - $end_date = strtotime( $options['scheduled_time_end'] ); + $end_date = strtotime( $options['scheduled_time_end'] ); $now = strtotime( current_time( 'm/d/Y H:i' ) ); if ( $end_date && $end_date < $now ) { continue; @@ -243,7 +243,7 @@ function qsm_get_post_id_from_quiz_id( $quiz_id ) { add_filter( 'qmn_end_shortcode', 'qsm_display_popup_div', 10, 3 ); function qsm_display_popup_div( $return_display, $qmn_quiz_options ) { - if ( '0' === $qmn_quiz_options->enable_result_after_timer_end ) { + if ( '0' === $qmn_quiz_options->enable_result_after_timer_end && 0 < $qmn_quiz_options->timer_limit ) { $return_display .= '