Skip to content

Commit

Permalink
Merge pull request #2699 from QuizandSurveyMaster/pre-release
Browse files Browse the repository at this point in the history
Release 9.2.2
  • Loading branch information
etvarun authored Nov 6, 2024
2 parents f47c9e3 + b6abae0 commit 44a7fed
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 41 deletions.
10 changes: 5 additions & 5 deletions blocks/block.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
},
)
);
Expand All @@ -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' );
},
)
);
Expand All @@ -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' );
},
)
);
Expand All @@ -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' );
},
)
);
Expand All @@ -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' );
},
)
);
Expand Down
12 changes: 7 additions & 5 deletions js/qsm-quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 4 additions & 3 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: 9.2.1
* Version: 9.2.2
* 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 = '9.2.1';
public $version = '9.2.2';

/**
* QSM Alert Manager Object
Expand Down Expand Up @@ -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 );
Expand All @@ -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' );
Expand Down
2 changes: 1 addition & 1 deletion php/admin/about-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion php/admin/addons-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion php/admin/admin-dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion php/admin/options-page-text-tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function mlw_options_text_tab_content() {
?>
</div>
</div>
<?php do_action( 'qsm_add_list_menu_content_text_tab_after', $text_text_arr ); ?>
<?php do_action( 'qsm_add_list_menu_content_text_tab_after', array_merge( $editor_text_arr, $text_text_arr ) ); ?>
<!-- Variable text -->
<div class="quiz_text_tab_content qsm_variable_text" style="display:none;" id="qsm_variable_text" >
<div class="left-bar">
Expand Down Expand Up @@ -221,6 +221,7 @@ function qsm_get_question_text_message() {
exit;
} else {
$settings = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', $text_id );
$settings = ! empty( $settings ) ? $settings : '';
$quiz_text_arr = $mlwQuizMasterNext->quiz_settings->load_setting_fields( 'quiz_text' );
$key = array_search( $text_id, array_column( $quiz_text_arr, 'id' ), true );
$allowed_text = '';
Expand Down
2 changes: 1 addition & 1 deletion php/admin/stats-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion php/admin/tools-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down
2 changes: 1 addition & 1 deletion php/classes/class-qmn-plugin-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
17 changes: 11 additions & 6 deletions php/classes/class-qsm-quiz-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 );
}
Expand Down Expand Up @@ -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();
Expand All @@ -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(
Expand All @@ -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 ) {
Expand Down
2 changes: 1 addition & 1 deletion php/classes/class-qsm-results-pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
6 changes: 1 addition & 5 deletions php/classes/class-qsm-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions php/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
},
)
);
Expand All @@ -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' );
},
)
);
Expand Down Expand Up @@ -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' );
},
)
);
Expand All @@ -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' );
},
)
);
Expand Down Expand Up @@ -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' );
},
)
);
Expand Down
6 changes: 3 additions & 3 deletions php/template-variables.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ function mlw_qmn_variable_user_full_name( $content, $mlw_quiz_array ) {
if ( ! empty( $firstname ) && ! empty( $lastname ) ) {
$full_name = $firstname . ' ' . $lastname;
} else {
$full_name = $current_user->display_name;
$full_name = $user->display_name;
}
}

Expand Down Expand Up @@ -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 .= '<span class="qsm-text-correct-option">(' . $key + 1 . ') ' . strval( $mlwQuizMasterNext->pluginHelper->qsm_language_support( $single_answer[0], 'answer-' . $answer['id'] . '-' . $key, 'QSM Answers' ) ) . '</span>';
$question_correct_fill_answer_text .= '<span class="qsm-text-correct-option">(' . ($key + 1) . ') ' . strval( $mlwQuizMasterNext->pluginHelper->qsm_language_support( $single_answer[0], 'answer-' . $answer['id'] . '-' . $key, 'QSM Answers' ) ) . '</span>';
}
$is_any_incorrect = false;
if ( sizeof( $new_array_user_answer ) < sizeof( $total_answers ) ) {
Expand Down Expand Up @@ -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 );
Expand Down
7 changes: 6 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 06, 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
Expand Down

0 comments on commit 44a7fed

Please sign in to comment.