Skip to content

Commit

Permalink
update option tab UI
Browse files Browse the repository at this point in the history
  • Loading branch information
zubairraeen committed Mar 18, 2024
1 parent ab1c380 commit 420b524
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 99 deletions.
14 changes: 14 additions & 0 deletions css/qsm-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,10 @@ tr .qsm-opt-desc {
font-size: 14px;
font-weight: 400;
}
.qsm-image-input{
margin-right: 5px;
margin-top: 5px;
}
.form-table .send_email .qsm-opt-tr, .form-table .send_email td {
padding-top: 0;
}
Expand Down Expand Up @@ -3311,6 +3315,16 @@ body .qsm_tab_content .qsm-small-input-field input[type="text"] {
padding: 3px 10px;
min-width: 100px;
background-color: #fff;
width: 157px;
}
.qsm-option-label input:disabled {
border-color: #3c434a;
}
.qsm-category-list-row td {
padding-top: 0;
}
.qsm-question-limit-row td{
padding-bottom: 0;
}
.qsm-quiz-dates fieldset#scheduled_time_start, .qsm-quiz-dates fieldset#scheduled_time_end {
display: inline-block;
Expand Down
64 changes: 25 additions & 39 deletions js/qsm-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,23 @@ var QSMAdmin;
});

$(document).on('change', '#limit_category_checkbox-1', function (event) {
event.preventDefault();
if (jQuery('#limit_category_checkbox-1:checked').length > 0) {
jQuery('#question_per_category').hide();
jQuery('div.select-category-question-limit-maindiv').parents("tr").show();
jQuery('.category_selection_random').parents("tr").hide();
} else {
jQuery('div.select-category-question-limit-maindiv').parents("tr").hide();
jQuery('#question_per_category').show();
if ( 0 < jQuery('#question_per_category-input').val() ) {
jQuery('.category_selection_random').parents("tr").show();
}
}
});
$(document).on('change', '#question_per_category-input', function (event) {
if ( 0 < jQuery('#question_per_category-input').val() ) {
jQuery('.category_selection_random').parents("tr").show();
} else {
jQuery('.category_selection_random').parents("tr").hide();
}
});
show_hide_show_correct_answer();
Expand Down Expand Up @@ -361,37 +369,29 @@ var QSMAdmin;
jQuery('#not_allow_after_expired_time-1').attr('disabled', true);
}
});
if ( 0 != jQuery('#question_from_total-input').val() ) {
jQuery('#limit_category_checkbox label').css('opacity', '1');
jQuery('#limit_category_checkbox-1').attr('disabled', false);
jQuery('#question_per_category').show();
} else {
jQuery('#limit_category_checkbox label').css('opacity', '0.7');
jQuery('#limit_category_checkbox-1').attr('disabled', true);
jQuery('#question_per_category').hide();
}
if (jQuery('#limit_category_checkbox-1:checked').length > 0) {
jQuery('#question_per_category').hide();
jQuery('.category_selection_random').parents("tr").hide();
jQuery('div.select-category-question-limit-maindiv').parents("tr").show();
} else {
jQuery('div.select-category-question-limit-maindiv').parents("tr").hide();
jQuery('.category_selection_random').parents("tr").show();
jQuery('#question_per_category').show();
}
jQuery(document).on('change', '#question_from_total-input', function () {
if ( 0 != jQuery(this).val() ) {
jQuery('#limit_category_checkbox label').css('opacity', '1');
jQuery('#limit_category_checkbox label, #question_per_category').css('opacity', '1');
jQuery('#limit_category_checkbox-1').attr('disabled', false);
if (!jQuery('#limit_category_checkbox-1:checked').length) {
jQuery('#question_per_category').show();
}
} else {
jQuery('#limit_category_checkbox label').css('opacity', '0.7');
jQuery('#limit_category_checkbox label, #question_per_category').css('opacity', '0.7');
jQuery('#limit_category_checkbox-1').attr('disabled', true);
jQuery('#question_per_category').hide();
jQuery('#question_per_category-input').val(0);
jQuery('.category_selection_random').parents("tr").hide();
}
});
if ( 0 != jQuery('#question_from_total-input').val() ) {
jQuery('#limit_category_checkbox label, #question_per_category').css('opacity', '1');
jQuery('#limit_category_checkbox-1').attr('disabled', false);
} else {
jQuery('#limit_category_checkbox label, #question_per_category').css('opacity', '0.7');
jQuery('#limit_category_checkbox-1').attr('disabled', true);
jQuery('#question_per_category-input').val(0);
jQuery('.category_selection_random').parents("tr").hide();
}
if ( !jQuery('.category_selection_random').length ) {
jQuery('#limit_category_checkbox, #question_per_category').hide();
}
//Hide/show tr based on selection
$('.qsm_tab_content .qsm-opt-tr select').each(function () {
var name = $(this).attr('name');
Expand All @@ -400,22 +400,8 @@ var QSMAdmin;
$('.' + name + '_' + value).show();
}
});
$(document).on('change', '.qsm_tab_content select:not(.question_limit_category,.qsm-woo-result-related-products, .qsm-woo-email-related-products), #quiz_settings_wrapper select:not(.question_limit_category)', function () {
var value = $(this).val();
hide_show_quiz_options(value);
});

// form_type (0, 1, 2).
function hide_show_quiz_options(form_type) {
if (0 == form_type) {
$('#correct_answer_logic').show();
} else {
$('#correct_answer_logic').hide();
}
}

$(document).ready(function () {
hide_show_quiz_options($("input[name='form_type']:checked").val());
if (jQuery('.qsm-date-picker').length) {
jQuery('.qsm-date-picker').datetimepicker({ format: 'm/d/Y H:i', step: 1});
}
Expand Down
22 changes: 11 additions & 11 deletions php/admin/settings-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ public function correct_answer_logic(){
</label>
<label class="qsm-option-label" for="qsm-disable-mathjax">
<input type="checkbox" id="qsm-disable-mathjax" name="qsm-quiz-settings[disable_mathjax]" value="1" <?php checked( $qsm_disable_mathjax, 1 ); ?>>
<?php esc_html_e( 'Allow entering math formulas in questions, using TeX and LaTeX notation.', 'quiz-master-next' ); ?>
<?php esc_html_e( 'Disable entering math formulas in questions, using TeX and LaTeX notation.', 'quiz-master-next' ); ?>
</label>
</fieldset>
<?php
Expand Down Expand Up @@ -1102,7 +1102,7 @@ public function qsm_global_questions_per_page() {
<?php esc_html_e('Show ', 'quiz-master-next'); ?>
<input class="small-text" type="number" placeholder="<?php esc_html_e('Set Limit', 'quiz-master-next'); ?>" step="1" min="0" name="qsm-quiz-settings[pagination]" value="<?php echo esc_attr( $qsm_pagination ); ?>">
<?php esc_html_e('Questions Per Page', 'quiz-master-next'); ?>
<label class="qsm-opt-desc"><?php esc_html_e('Setting a limit overrides the quiz questions default pagination. Set it to 0 or blank for default pagination.', 'quiz-master-next'); ?></label>
<label class="qsm-opt-desc"><i><?php esc_html_e('Setting a limit overrides the quiz questions default pagination. Set it to 0 or blank for default pagination.', 'quiz-master-next'); ?></i></label>
</fieldset>
<fieldset class="buttonset buttonset-hide" data-hide="1">
<label class="qsm-option-label" for="qsm-question-numbering">
Expand Down Expand Up @@ -1176,6 +1176,7 @@ public function qsm_global_quiz_animation() {
$qsm_quiz_animation = ( isset( $globalQuizsetting['quiz_animation'] ) && '' !== $globalQuizsetting['quiz_animation'] ? $globalQuizsetting['quiz_animation'] : '' );
$options = $mlwQuizMasterNext->pluginHelper->quiz_animation_effect();
$qsm_enable_pagination_quiz = ( isset( $globalQuizsetting['enable_pagination_quiz'] ) && '' !== $globalQuizsetting['enable_pagination_quiz'] ? $globalQuizsetting['enable_pagination_quiz'] : 0 );
$qsm_disable_scroll_next_previous_click = ( isset( $globalQuizsetting['disable_scroll_next_previous_click'] ) && '' !== $globalQuizsetting['disable_scroll_next_previous_click'] ? $globalQuizsetting['disable_scroll_next_previous_click'] : 0 );
?>
<select name="qsm-quiz-settings[quiz_animation]">
<?php foreach ( $options as $value ) { ?>
Expand All @@ -1188,6 +1189,12 @@ public function qsm_global_quiz_animation() {
<?php esc_html_e('Display current page number of the quiz', 'quiz-master-next'); ?>
</label>
</fieldset>
<fieldset class="buttonset buttonset-hide" data-hide="1">
<label class="qsm-option-label" for="qsm-disable-scroll-next-previous-click">
<input type="checkbox" id="qsm-disable-scroll-next-previous-click" name="qsm-quiz-settings[disable_scroll_next_previous_click]" <?php checked( $qsm_disable_scroll_next_previous_click, 1 ); ?> value="1">
<?php esc_html_e('Do not scroll the page on clicking next/previous buttons', 'quiz-master-next'); ?>
</label>
</fieldset>
<?php
}
/**
Expand All @@ -1200,29 +1207,22 @@ public function qsm_global_logo_url() {
global $globalQuizsetting;
$qsm_result_page_fb_image = ( isset( $globalQuizsetting['result_page_fb_image'] ) && '' !== $globalQuizsetting['result_page_fb_image'] ? $globalQuizsetting['result_page_fb_image'] : QSM_PLUGIN_URL . 'assets/icon-200x200.png' );
$qsm_ajax_show_correct = ( isset( $globalQuizsetting['ajax_show_correct'] ) && '' !== $globalQuizsetting['ajax_show_correct'] ? $globalQuizsetting['ajax_show_correct'] : 0 );
$qsm_disable_scroll_next_previous_click = ( isset( $globalQuizsetting['disable_scroll_next_previous_click'] ) && '' !== $globalQuizsetting['disable_scroll_next_previous_click'] ? $globalQuizsetting['disable_scroll_next_previous_click'] : 0 );
$preferred_date_format = ( isset( $globalQuizsetting['preferred_date_format'] ) ? $globalQuizsetting['preferred_date_format'] : get_option( 'date_format' ) );
?>
<fieldset class="buttonset buttonset-hide" data-hide="1">
<span><?php esc_html_e('Set a logo for Facebook sharing', 'quiz-master-next'); ?></span>
<span><strong><?php esc_html_e('Set a logo for Facebook sharing', 'quiz-master-next'); ?></strong></span>
<div class="qsm-image-field">
<input type="text" class="qsm-image-input" name="qsm-quiz-settings[result_page_fb_image]" value="<?php echo esc_url( $qsm_result_page_fb_image ); ?>">
<a class="qsm-image-btn button"><span class="dashicons dashicons-format-image"></span><?php esc_html_e('Select Logo', 'quiz-master-next'); ?></a>
</div>
<label><small class="qsm-font-light"><?php esc_html_e('This logo will be used for Facebook sharing. If left blank, QSM\'s logo will appear.', 'quiz-master-next'); ?></small></label>
<label class="qsm-font-light"><i><?php esc_html_e('This logo will be used for Facebook sharing. If left blank, QSM\'s logo will appear.', 'quiz-master-next'); ?></i></label>
</fieldset>
<fieldset class="buttonset buttonset-hide" data-hide="1">
<label class="qsm-option-label" for="qsm-ajax-show-correct">
<input type="checkbox" id="qsm-ajax-show-correct" name="qsm-quiz-settings[ajax_show_correct]" <?php checked( $qsm_ajax_show_correct, 1 ); ?> value="1">
<?php esc_html_e('Add class for correct/incorrect answers', 'quiz-master-next'); ?>
</label>
</fieldset>
<fieldset class="buttonset buttonset-hide" data-hide="1">
<label class="qsm-option-label" for="qsm-disable-scroll-next-previous-click">
<input type="checkbox" id="qsm-disable-scroll-next-previous-click" name="qsm-quiz-settings[disable_scroll_next_previous_click]" <?php checked( $qsm_disable_scroll_next_previous_click, 1 ); ?> value="1">
<?php esc_html_e('Do not scroll the page on clicking next/previous buttons', 'quiz-master-next'); ?>
</label>
</fieldset>
<fieldset class="buttonset buttonset-hide" data-hide="1" id="preferred_date_format">
<label class="qsm-option-label" for="qsm-preferred-date-format-1">
<input type="radio" id="qsm-preferred-date-format-1" name="qsm-quiz-settings[preferred_date_format]" <?php checked( $preferred_date_format, 'F j, Y' ); ?> value="F j, Y">
Expand Down
2 changes: 1 addition & 1 deletion php/classes/class-qmn-quiz-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ public function load_questions( $quiz_id, $quiz_options, $is_quiz_page, $questio
if ( 1 == $quiz_options->randomness_order || 2 == $quiz_options->randomness_order ) {
shuffle( $tv );
}
$random = array_merge( $random, array_slice( array_unique( $tv ), 0, $quiz_options->question_per_category ) );
$random = array_merge( $random, array_slice( array_unique( $tv ), 0, intval( $quiz_options->question_per_category ) ) );
}
}
$question_ids = array_unique( $random );
Expand Down
33 changes: 10 additions & 23 deletions php/classes/class-qsm-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -768,20 +768,14 @@ public static function generate_category_field( $field, $value ) {
$quiz_id = isset($_GET['quiz_id']) ? sanitize_text_field( wp_unslash( $_GET['quiz_id'] ) ) : 0;
$explode_cat = explode(',', $value);
$limit_category_checkbox = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_options','limit_category_checkbox');
$display = "";
if ( ! empty($limit_category_checkbox) ) {
$display = "style='display:none;'";
} ?>
<tr valign="top" <?php echo esc_html( $display );?> >
$question_per_category = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_options','question_per_category');
?>
<tr valign="top" <?php echo ! empty($limit_category_checkbox) || empty( $question_per_category ) ? 'style="display:none;"' : '';?> class="qsm-category-list-row">
<th scope="row" class="qsm-opt-tr">
<label for="<?php echo esc_attr( $field["id"] ); ?>"><?php echo wp_kses_post( $field['label'] ); ?></label>
<?php if ( isset($field['tooltip']) && '' !== $field['tooltip'] ) { ?>
<span class="dashicons dashicons-editor-help qsm-tooltips-icon">
<span class="qsm-tooltips"><?php echo wp_kses_post( $field['tooltip'] ); ?></span>
</span>
<?php } ?>

</th>
<td>
<label for="<?php echo esc_attr( $field["id"] ); ?>"><strong><?php echo wp_kses_post( $field['label'] ); ?></strong></label>
<?php
$categories = QSM_Questions::get_quiz_categories( $quiz_id );
$categories_tree = (isset($categories['tree']) ? $categories['tree'] : array());
Expand Down Expand Up @@ -958,21 +952,14 @@ public static function generate_selectinput_field( $field, $value ) {
) ;
$quiz_id = isset($_GET['quiz_id']) ? sanitize_text_field( wp_unslash( $_GET['quiz_id'] ) ) : 0;
$limit_category_checkbox = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_options','limit_category_checkbox');
$display = "";
if ( '' == $limit_category_checkbox ) {
$display = "style='display:none;'";
} ?>
<tr valign="top" <?php echo esc_html( $display );?> >
?>
<tr valign="top" <?php echo empty( $limit_category_checkbox ) ? 'style="display:none;"' : '';?> class="qsm-category-list-row" >
<th scope="row" class="qsm-opt-tr">
<label for="<?php echo esc_attr( $field["id"] ); ?>"><?php echo wp_kses_post( $field['label'] ); ?></label>
<?php if ( isset($field['tooltip']) && '' !== $field['tooltip'] ) { ?>
<span class="dashicons dashicons-editor-help qsm-tooltips-icon">
<span class="qsm-tooltips"><?php echo wp_kses_post( $field['tooltip'] ); ?></span>
</span>
<?php } ?>

</th>
<td>
<div class = "select-category-question-limit-maindiv">
<label for="<?php echo esc_attr( $field["id"] ); ?>"><strong><?php echo wp_kses_post( $field['label'] ); ?></strong></label>
<div class="select-category-question-limit-maindiv">
<?php
$categories = QSM_Questions::get_quiz_categories( $quiz_id );
$category_select_key = ( ! empty( $value['category_select_key'] ) ) ? $value['category_select_key'] : array();
Expand Down
Loading

0 comments on commit 420b524

Please sign in to comment.