From 5096acdc9d709bad31d4ba8678e3feaf16fdc833 Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Tue, 5 Nov 2024 19:45:27 +0530 Subject: [PATCH 1/2] update changelog --- blocks/block.php | 10 +++++----- js/qsm-quiz.js | 12 +++++++----- mlw_quizmaster2.php | 7 ++++--- php/admin/about-page.php | 2 +- php/admin/addons-page.php | 2 +- php/admin/admin-dashboard.php | 2 +- php/admin/stats-page.php | 2 +- php/admin/tools-page.php | 2 +- php/classes/class-qmn-plugin-helper.php | 2 +- php/classes/class-qsm-quiz-api.php | 17 +++++++++++------ php/classes/class-qsm-results-pages.php | 2 +- php/classes/class-qsm-settings.php | 6 +----- php/rest-api.php | 10 +++++----- php/template-variables.php | 4 ++-- readme.txt | 7 ++++++- 15 files changed, 48 insertions(+), 39 deletions(-) diff --git a/blocks/block.php b/blocks/block.php index 6c6fc3e94..d16042ebf 100644 --- a/blocks/block.php +++ b/blocks/block.php @@ -306,7 +306,7 @@ public function register_editor_rest_routes() { 'methods' => WP_REST_Server::CREATABLE, 'callback' => array( $this, 'hierarchical_category_list' ), 'permission_callback' => function () { - return current_user_can( 'edit_posts' ); + return current_user_can( 'edit_qsm_quizzes' ); }, ) ); @@ -319,7 +319,7 @@ public function register_editor_rest_routes() { 'methods' => WP_REST_Server::CREATABLE, 'callback' => array( $this, 'advance_question_type_upgrade_popup' ), 'permission_callback' => function () { - return current_user_can( 'edit_posts' ); + return current_user_can( 'edit_qsm_quizzes' ); }, ) ); @@ -332,7 +332,7 @@ public function register_editor_rest_routes() { 'methods' => WP_REST_Server::CREATABLE, 'callback' => array( $this, 'qsm_quiz_structure_data' ), 'permission_callback' => function () { - return current_user_can( 'edit_posts' ); + return current_user_can( 'edit_qsm_quizzes' ); }, ) ); @@ -345,7 +345,7 @@ public function register_editor_rest_routes() { 'methods' => WP_REST_Server::CREATABLE, 'callback' => array( $this, 'create_new_quiz_from_editor' ), 'permission_callback' => function () { - return current_user_can( 'edit_posts' ); + return current_user_can( 'edit_qsm_quizzes' ); }, ) ); @@ -358,7 +358,7 @@ public function register_editor_rest_routes() { 'methods' => WP_REST_Server::CREATABLE, 'callback' => array( $this, 'save_quiz' ), 'permission_callback' => function () { - return current_user_can( 'edit_posts' ); + return current_user_can( 'edit_qsm_quizzes' ); }, ) ); diff --git a/js/qsm-quiz.js b/js/qsm-quiz.js index bbd87c641..735aa5090 100644 --- a/js/qsm-quiz.js +++ b/js/qsm-quiz.js @@ -52,8 +52,6 @@ var qsmTimerInterval = []; if (quiz.hasOwnProperty('timer_limit') && 0 != quiz.timer_limit) { QSM.initTimer(quizID); quizType = 'timer'; - } else { - qsmTimerInterval[quizID] = setInterval(function () { qmnTimeTakenTimer(quizID) }, 1000); } if (jQuery('.qsm-quiz-container-' + quizID + ' .qsm-submit-btn').is(':visible') && !jQuery('.qsm-quiz-container-' + quizID).hasClass('qsm_auto_pagination_enabled') ) { jQuery('.qsm-quiz-container-' + quizID + ' .qsm-quiz-comment-section').fadeIn(); @@ -173,6 +171,10 @@ var qsmTimerInterval = []; jQuery(document).trigger('qmn_timer_consumed_seconds', [quizID, qmn_quiz_data, qsm_timer_consumed_obj]); if (localStorage.getItem('mlw_time_quiz' + quizID) != null ) { secondsRemaining = (parseFloat(qmn_quiz_data[quizID].timer_limit) * 60) - secondsConsumed + 1; + if(qsm_timer_consumed_obj.qmn_count_upward_status){ + secondsConsumed = qmn_quiz_data[quizID].timerConsumed - 1; + secondsRemaining = (parseFloat(qmn_quiz_data[quizID].timer_limit) * 60) - secondsConsumed; + } if(secondsRemaining < 0) { secondsRemaining = 0; } @@ -2018,13 +2020,13 @@ jQuery(document).keydown(function(event) { return; } } - if ([39, 37, 13, 9].includes(event.keyCode) && jQuery('textarea:focus').length === 0) { + if ([39, 37, 13, 9].includes(event.keyCode) && jQuery('textarea:focus, input[type="text"]:focus, input[type="email"]:focus, input[type="number"]:focus').length === 0) { event.preventDefault(); } - if (event.keyCode === 39) { + if (event.keyCode === 39 && jQuery('textarea:focus, input[type="text"]:focus, input[type="email"]:focus, input[type="number"]:focus').length === 0 ) { jQuery('.qsm-quiz-container.qsm-recently-active').find('.mlw_next:visible').click(); } - if (event.keyCode === 37) { + if (event.keyCode === 37 && jQuery('textarea:focus, input[type="text"]:focus, input[type="email"]:focus, input[type="number"]:focus').length === 0 ) { jQuery('.qsm-quiz-container.qsm-recently-active').find('.mlw_previous:visible').click(); } if (event.keyCode === 13 && jQuery('textarea:focus').length === 0) { diff --git a/mlw_quizmaster2.php b/mlw_quizmaster2.php index 2a6e8e6bc..57364677d 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: 9.2.1 + * Version: 9.2.2 * 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 = '9.2.1'; + public $version = '9.2.2'; /** * QSM Alert Manager Object @@ -840,6 +840,7 @@ public function setup_admin_menu() { 'manage_qsm_quiz_categories', 'manage_qsm_quiz_answer_label', 'view_qsm_quiz_result', + 'manage_options', ); add_menu_page( 'Quiz And Survey Master', __( 'QSM', 'quiz-master-next' ), $capabilities[1], 'qsm_dashboard', 'qsm_generate_dashboard_page', 'dashicons-feedback', $menu_position ); @@ -862,7 +863,7 @@ public function setup_admin_menu() { add_submenu_page( 'qsm_dashboard', __( 'Failed DB Queries', 'quiz-master-next' ), __( 'Failed Database Queries', 'quiz-master-next' ), $capabilities[2], 'qsm-database-failed-queries', array( $this, 'qsm_database_failed_queries' ) ); } add_submenu_page( 'options.php', __( 'Result Details', 'quiz-master-next' ), __( 'Result Details', 'quiz-master-next' ), $capabilities[5], 'qsm_quiz_result_details', 'qsm_generate_result_details' ); - add_submenu_page( 'qsm_dashboard', __( 'Settings', 'quiz-master-next' ), __( 'Settings', 'quiz-master-next' ), $capabilities[2], 'qmn_global_settings', array( 'QMNGlobalSettingsPage', 'display_page' ) ); + add_submenu_page( 'qsm_dashboard', __( 'Settings', 'quiz-master-next' ), __( 'Settings', 'quiz-master-next' ), $capabilities[6], 'qmn_global_settings', array( 'QMNGlobalSettingsPage', 'display_page' ) ); add_submenu_page( 'qsm_dashboard', __( 'Tools', 'quiz-master-next' ), __( 'Tools', 'quiz-master-next' ), $capabilities[2], 'qsm_quiz_tools', 'qsm_generate_quiz_tools' ); add_submenu_page( 'qsm_dashboard', __( 'Stats', 'quiz-master-next' ), __( 'Stats', 'quiz-master-next' ), $capabilities[2], 'qmn_stats', 'qmn_generate_stats_page' ); add_submenu_page( 'qsm_dashboard', __( 'About', 'quiz-master-next' ), __( 'About', 'quiz-master-next' ), $capabilities[2], 'qsm_quiz_about', 'qsm_generate_about_page' ); diff --git a/php/admin/about-page.php b/php/admin/about-page.php index b54d9cc21..60fd79854 100644 --- a/php/admin/about-page.php +++ b/php/admin/about-page.php @@ -18,7 +18,7 @@ function qsm_generate_about_page() { global $mlwQuizMasterNext; $version = $mlwQuizMasterNext->version; - if ( ! current_user_can( 'moderate_comments' ) ) { + if ( ! current_user_can( 'delete_others_qsm_quizzes' ) ) { return; } $tab_array = [ diff --git a/php/admin/addons-page.php b/php/admin/addons-page.php index 6c055261d..00c81c5b5 100644 --- a/php/admin/addons-page.php +++ b/php/admin/addons-page.php @@ -10,7 +10,7 @@ * @since 4.4.0 */ function qmn_addons_page() { - if ( ! current_user_can( 'moderate_comments' ) ) { + if ( ! current_user_can( 'delete_others_qsm_quizzes' ) ) { return; } diff --git a/php/admin/admin-dashboard.php b/php/admin/admin-dashboard.php index b4f2eb7c8..21895a48b 100644 --- a/php/admin/admin-dashboard.php +++ b/php/admin/admin-dashboard.php @@ -102,7 +102,7 @@ function qsm_dashboard_screen_options( $status, $args ) { */ function qsm_generate_dashboard_page() { // Only let admins and editors see this page. - if ( ! current_user_can( 'edit_posts' ) ) { + if ( ! current_user_can( 'edit_qsm_quizzes' ) ) { return; } global $mlwQuizMasterNext; diff --git a/php/admin/stats-page.php b/php/admin/stats-page.php index 243d74fe6..211dcd2d8 100644 --- a/php/admin/stats-page.php +++ b/php/admin/stats-page.php @@ -16,7 +16,7 @@ * @return void */ function qmn_generate_stats_page() { - if ( ! current_user_can('moderate_comments') ) { + if ( ! current_user_can('delete_others_qsm_quizzes') ) { return; } global $mlwQuizMasterNext; diff --git a/php/admin/tools-page.php b/php/admin/tools-page.php index 472ede5ed..70951f6b4 100644 --- a/php/admin/tools-page.php +++ b/php/admin/tools-page.php @@ -15,7 +15,7 @@ * @since 6.2.0 */ function qsm_generate_quiz_tools() { - if ( ! current_user_can( 'moderate_comments' ) ) { + if ( ! current_user_can( 'delete_others_qsm_quizzes' ) ) { return; } add_meta_box( 'qsm_restore_box', 'Restore Quiz', 'qsm_restore_function', 'quiz_wpss' ); diff --git a/php/classes/class-qmn-plugin-helper.php b/php/classes/class-qmn-plugin-helper.php index d6c6ffaee..7b5a59276 100644 --- a/php/classes/class-qmn-plugin-helper.php +++ b/php/classes/class-qmn-plugin-helper.php @@ -704,7 +704,7 @@ public static function qsm_language_support( $translation_text = '', $translatio } elseif ( ! empty( $translation_text ) ) { $translation_text = wp_kses_post( $translation_text ); } - + return $translation_text; } diff --git a/php/classes/class-qsm-quiz-api.php b/php/classes/class-qsm-quiz-api.php index de88ac738..40c5dfc44 100644 --- a/php/classes/class-qsm-quiz-api.php +++ b/php/classes/class-qsm-quiz-api.php @@ -131,6 +131,7 @@ public function qsm_get_quiz_result_info( WP_REST_Request $request ) { $email = $request->get_param('email'); $from_date = $request->get_param('from_date'); $order = $request->get_param('order'); + $user_id = $request->get_param('user_id'); $s = $request->get_param('s'); $query = "SELECT * FROM {$wpdb->prefix}mlw_results WHERE 1=1"; @@ -154,6 +155,10 @@ public function qsm_get_quiz_result_info( WP_REST_Request $request ) { $query .= $wpdb->prepare(" AND email = %s", $email); } + if ( ! empty($user_id) ) { + $query .= $wpdb->prepare(" AND user = %d", $user_id); + } + if ( ! empty($from_date) ) { $query .= $wpdb->prepare( " AND time_taken_real >= %s", $from_date ); } @@ -416,9 +421,9 @@ public function qsm_api_quiz_submit( $request ) { $api_key = $request->get_header('authorization'); $qsm_api_settings = (array) get_option( 'qmn-settings' ); if ( ($api_key && "" != $api_key) && (isset($qsm_api_settings['api_key']) && ("" != $qsm_api_settings['api_key'] && $api_key == $qsm_api_settings['api_key'])) && isset($qsm_api_settings['allow_submit_quiz']) && "1" == $qsm_api_settings['allow_submit_quiz'] ) { - + $quiz_id = ! empty( $_POST['qmn_quiz_id'] ) ? sanitize_text_field( wp_unslash( $_POST['qmn_quiz_id'] ) ) : 0 ; - + global $qmn_allowed_visit, $mlwQuizMasterNext, $wpdb, $qmnQuizManager; $qmn_allowed_visit = true; $qmnQuizManager = new QMNQuizManager(); @@ -433,11 +438,11 @@ public function qsm_api_quiz_submit( $request ) { 'fields' => 'ids', 'numberposts' => 1, )); - + if ( ! empty( $post_ids[0] ) ) { $post_status = get_post_status( $post_ids[0] ); } - + if ( is_null( $options ) || 1 == $options->deleted ) { echo wp_json_encode( array( @@ -462,11 +467,11 @@ public function qsm_api_quiz_submit( $request ) { ); wp_die(); } - + $qsm_option = isset( $options->quiz_settings ) ? maybe_unserialize( $options->quiz_settings ) : array(); $qsm_option = array_map( 'maybe_unserialize', $qsm_option ); $post_status = false; - + if ( 0 != $options->limit_total_entries ) { $mlw_qmn_entries_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(quiz_id) FROM {$wpdb->prefix}mlw_results WHERE deleted=0 AND quiz_id=%d", $options->quiz_id ) ); if ( $mlw_qmn_entries_count >= $options->limit_total_entries ) { diff --git a/php/classes/class-qsm-results-pages.php b/php/classes/class-qsm-results-pages.php index 2f7d6e465..fc981ed1d 100644 --- a/php/classes/class-qsm-results-pages.php +++ b/php/classes/class-qsm-results-pages.php @@ -179,7 +179,7 @@ public static function generate_pages( $response_data ) { // Decodes special characters, runs through our template // variables, and then outputs the text. $page = wp_kses_post( htmlspecialchars_decode( $content, ENT_QUOTES) ); - + $response_data['result_page_index'] = $page_index; //last chance to filter $page $page = apply_filters( 'qsm_template_variable_results_page', $page, $response_data ); diff --git a/php/classes/class-qsm-settings.php b/php/classes/class-qsm-settings.php index 5046ca6e8..916afe615 100644 --- a/php/classes/class-qsm-settings.php +++ b/php/classes/class-qsm-settings.php @@ -472,11 +472,7 @@ public function get_quiz_options() { $text = $this->get_setting('quiz_text'); if ( is_array($text) ) { - foreach ( $text as $key => $value ) { - if ( ! empty($value) ) { - $quiz_options[ $key ] = $value; - } - } + $quiz_options = array_merge( $quiz_options, $text ); } // Return as old object model diff --git a/php/rest-api.php b/php/rest-api.php index bbb612a19..07c626cfb 100644 --- a/php/rest-api.php +++ b/php/rest-api.php @@ -30,7 +30,7 @@ function qsm_register_rest_routes() { 'methods' => WP_REST_Server::CREATABLE, 'callback' => 'qsm_rest_create_question', 'permission_callback' => function () { - return current_user_can( 'edit_posts' ); + return current_user_can( 'edit_qsm_quizzes' ); }, ) ); @@ -41,7 +41,7 @@ function qsm_register_rest_routes() { 'methods' => WP_REST_Server::EDITABLE, 'callback' => 'qsm_rest_save_question', 'permission_callback' => function () { - return current_user_can( 'edit_posts' ); + return current_user_can( 'edit_qsm_quizzes' ); }, ) ); @@ -70,7 +70,7 @@ function qsm_register_rest_routes() { 'methods' => WP_REST_Server::EDITABLE, 'callback' => 'qsm_rest_save_results', 'permission_callback' => function () { - return current_user_can( 'edit_posts' ); + return current_user_can( 'edit_qsm_quizzes' ); }, ) ); @@ -90,7 +90,7 @@ function qsm_register_rest_routes() { 'methods' => WP_REST_Server::EDITABLE, 'callback' => 'qsm_rest_save_emails', 'permission_callback' => function () { - return current_user_can( 'edit_posts' ); + return current_user_can( 'edit_qsm_quizzes' ); }, ) ); @@ -123,7 +123,7 @@ function qsm_register_rest_routes() { 'methods' => WP_REST_Server::READABLE, 'callback' => 'qsm_rest_get_bank_questions', 'permission_callback' => function () { - return current_user_can( 'edit_posts' ); + return current_user_can( 'edit_qsm_quizzes' ); }, ) ); diff --git a/php/template-variables.php b/php/template-variables.php index 5a561122e..4b848ed51 100644 --- a/php/template-variables.php +++ b/php/template-variables.php @@ -1201,7 +1201,7 @@ function qsm_questions_answers_shortcode_to_text( $mlw_quiz_array, $qmn_question } else { $options[] = mb_strtoupper( htmlspecialchars_decode( $mlwQuizMasterNext->pluginHelper->qsm_language_support( $single_answer[0], 'answer-' . $answer['id'] . '-' . $key, 'QSM Answers' ), ENT_QUOTES ) ); } - $question_correct_fill_answer_text .= '(' . $key + 1 . ') ' . strval( $mlwQuizMasterNext->pluginHelper->qsm_language_support( $single_answer[0], 'answer-' . $answer['id'] . '-' . $key, 'QSM Answers' ) ) . ''; + $question_correct_fill_answer_text .= '(' . ($key + 1) . ') ' . strval( $mlwQuizMasterNext->pluginHelper->qsm_language_support( $single_answer[0], 'answer-' . $answer['id'] . '-' . $key, 'QSM Answers' ) ) . ''; } $is_any_incorrect = false; if ( sizeof( $new_array_user_answer ) < sizeof( $total_answers ) ) { @@ -1597,7 +1597,7 @@ function qmn_polar_display_on_resultspage( $id, $question, $answers, $answer ) { * @since 7.3.3 */ function qmn_sanitize_input_data( $data, $strip = false ) { - if ( $strip ) { + if ( $strip && is_string( $data ) ) { $data = stripslashes( $data ); } return maybe_unserialize( $data ); diff --git a/readme.txt b/readme.txt index e07e315a4..46df082bf 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: quiz, survey, test, exam, online assessment Requires at least: 4.9 Tested up to: 6.6 Requires PHP: 5.4 -Stable tag: 9.2.1 +Stable tag: 9.2.2 License: GPLv2 License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -222,6 +222,11 @@ As a WordPress quiz maker, QSM is designed to be compatible with most other plug 18. Database == Changelog == += 9.2.2 ( November 05, 2024 ) = +* Bug: Fixed issue with text displaying before quiz options +* Bug: Resolved issue with left/right arrow keys in the quiz input box +* Enhancement: Updated API to retrieve results by user ID + = 9.2.1 ( October 16, 2024 ) = * Bug: Resolved vulnerability issue with question settings * Bug: Fixed issue with fill in the blanks question type while using random answers From b6abae0337e8834a1377ea1d5b3ae8e87e647632 Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Wed, 6 Nov 2024 16:36:55 +0530 Subject: [PATCH 2/2] update changelog date --- php/admin/options-page-text-tab.php | 3 ++- php/template-variables.php | 2 +- readme.txt | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/php/admin/options-page-text-tab.php b/php/admin/options-page-text-tab.php index ad85cf3ce..0404ce1cb 100644 --- a/php/admin/options-page-text-tab.php +++ b/php/admin/options-page-text-tab.php @@ -116,7 +116,7 @@ function mlw_options_text_tab_content() { ?> - +