Skip to content

Commit

Permalink
Merge pull request #2464 from QuizandSurveyMaster/CU-86795gc2y-access…
Browse files Browse the repository at this point in the history
…ibility-issues

added option to navigate quiz by using keyboard
  • Loading branch information
zubairraeen authored Feb 8, 2024
2 parents 16b4024 + 82b079e commit 66fca57
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
20 changes: 18 additions & 2 deletions js/qsm-quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -764,10 +764,9 @@ function qmnValidation(element, quiz_form_id) {
}
}
var by_pass = true;
if (qmn_quiz_data[quiz_id].timer_limit_val > 0 && qmn_quiz_data[quiz_id].hasOwnProperty('skip_validation_time_expire') && qmn_quiz_data[quiz_id].skip_validation_time_expire == 0) {
if (qmn_quiz_data[quiz_id].timer_limit_val > 0 && qmn_quiz_data[quiz_id].hasOwnProperty('skip_validation_time_expire') && qmn_quiz_data[quiz_id].skip_validation_time_expire != 1) {
by_pass = false;
}

if (localStorage.getItem('mlw_time_quiz' + quiz_id) === null || (0 == localStorage.getItem('mlw_time_quiz' + quiz_id) && by_pass == false) || localStorage.getItem('mlw_time_quiz' + quiz_id) > 0.08 || by_pass === false) {
if (jQuery(this).attr('class').indexOf('mlwRequiredNumber') > -1 && this.value === "" && +this.value != NaN) {
qmnDisplayError(error_messages.number_error_text, jQuery(this), quiz_form_id);
Expand Down Expand Up @@ -1891,3 +1890,20 @@ function qsm_question_quick_result_js(question_id, answer, answer_type = '', sho
return returnObject;
}
}

jQuery(document).on( 'click', '.qsm-quiz-container', function() {
jQuery('.qsm-quiz-container').removeClass('qsm-recently-active');
jQuery(this).addClass('qsm-recently-active');
});
jQuery(document).keydown(function(e) {
if (e.keyCode === 39) {
jQuery('.qsm-quiz-container.qsm-recently-active').find('.mlw_next:visible').click();
}
if (e.keyCode === 37) {
jQuery('.qsm-quiz-container.qsm-recently-active').find('.mlw_previous:visible').click();
}
if (e.keyCode === 13) {
jQuery('.qsm-quiz-container.qsm-recently-active').find('.qsm-submit-btn:visible').click();
}
});

12 changes: 6 additions & 6 deletions php/admin/admin-dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -567,14 +567,14 @@ function qsm_create_new_quiz_from_wizard() {
$quiz_options = array(
'quiz_name' => $quiz_name,
'quiz_featured_image' => isset( $_POST['quiz_featured_image'] ) ? esc_url_raw( wp_unslash( $_POST['quiz_featured_image'] ) ) : '',
'form_type' => isset( $_POST['form_type'] ) ? sanitize_text_field( wp_unslash( $_POST['form_type'] ) ) : '',
'system' => isset( $_POST['system'] ) ? sanitize_text_field( wp_unslash( $_POST['system'] ) ) : '',
'timer_limit' => isset( $_POST['timer_limit'] ) ? sanitize_text_field( wp_unslash( $_POST['timer_limit'] ) ) : '',
'pagination' => isset( $_POST['pagination'] ) ? sanitize_text_field( wp_unslash( $_POST['pagination'] ) ) : '',
'form_type' => isset( $_POST['form_type'] ) ? sanitize_text_field( wp_unslash( $_POST['form_type'] ) ) : 0,
'system' => isset( $_POST['system'] ) ? sanitize_text_field( wp_unslash( $_POST['system'] ) ) : 3,
'timer_limit' => ! empty( $_POST['timer_limit'] ) ? sanitize_text_field( wp_unslash( $_POST['timer_limit'] ) ) : 0,
'pagination' => ! empty( $_POST['pagination'] ) ? intval( $_POST['pagination'] ) : 0,
'enable_pagination_quiz' => isset( $_POST['enable_pagination_quiz'] ) ? sanitize_text_field( wp_unslash( $_POST['enable_pagination_quiz'] ) ) : 0,
'progress_bar' => isset( $_POST['progress_bar'] ) ? sanitize_text_field( wp_unslash( $_POST['progress_bar'] ) ) : 0,
'require_log_in' => isset( $_POST['require_log_in'] ) ? sanitize_text_field( wp_unslash( $_POST['require_log_in'] ) ) : '',
'disable_first_page' => isset( $_POST['disable_first_page'] ) ? sanitize_text_field( wp_unslash( $_POST['disable_first_page'] ) ) : '',
'require_log_in' => ! empty( $_POST['require_log_in'] ) ? sanitize_text_field( wp_unslash( $_POST['require_log_in'] ) ) : 0,
'disable_first_page' => isset( $_POST['disable_first_page'] ) ? sanitize_text_field( wp_unslash( $_POST['disable_first_page'] ) ) : 0,
'comment_section' => isset( $_POST['comment_section'] ) ? sanitize_text_field( wp_unslash( $_POST['comment_section'] ) ) : 1,
);
$get_saved_value = QMNGlobalSettingsPage::get_global_quiz_settings();
Expand Down

0 comments on commit 66fca57

Please sign in to comment.