From 39b3a308a30f70c2fef5dc6276be63b9ce28f4cb Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Wed, 28 Jun 2023 15:30:45 +0530 Subject: [PATCH 1/3] update option tab --- assets/calendar.png | Bin 0 -> 3677 bytes css/common.css | 17 +- css/qsm-admin.css | 28 +- js/qsm-admin.js | 64 ++-- php/classes/class-qsm-fields.php | 135 ++++++- php/classes/class-qsm-install.php | 541 +++++++++++++---------------- php/classes/class-qsm-settings.php | 6 +- templates/qmn_primary.css | 1 - 8 files changed, 441 insertions(+), 351 deletions(-) create mode 100644 assets/calendar.png diff --git a/assets/calendar.png b/assets/calendar.png new file mode 100644 index 0000000000000000000000000000000000000000..1c1baf7c39209929069e0d67a64722bf1c7e5d1e GIT binary patch literal 3677 zcmV-j4x;giP)X+uL$Nkc;* zP;zf(X>4Tx07!|IR|i;A$rhell8`_M5I{gm=uHr*0i=Y`0!S}{jgSNgCB%fFVn-Jh zT)SAnhOUYzc0lZiokg)>Uo5C7>teyKyh#CF_m%I>_syOE{&VI(XU?6u_YMHG6I`)4 z57h!7UsNcG4+~<9PEBKwo&o|e1T9|E#l}VfSO(g^mv=V+B5$uc$+iC3|6hwX zUm)cHfW$(a!I$##AwB>AUd0nj3IQO>dCN(KVmXEt=t^LK5YLz6EG4dz;|wL;VmoLfhFGr8%=kek z>u;JFgPL4!)*x2SMN!m(g;H@Icgp{nj{jZq^JD`)Y+%*MmW0R4=M3|9Gq)g8jx`|e z5oJWjK&%7t2O(c!4>3x~mW3xN?NMW%lnrwR^dWZPbAuxxHikG)#H)Ov^_dbjOU0k#N)&$OzV6F%lUOSK*VzJ&N*~iK z&Q45$m;$j?kuW(LVoivhrMU@_Dw~nT+3e^68;LAl9={dD@d8m;kWwEj%9Mo0tL)42 zr33TDHf9Ss(JH*JFgr0^nIEi$$5q4+=Ym}ph*(JjIs)nFsDZig1;HW8xns`+qND_s z&IfT}P`q+1P7&wDs_bzKL0*`gw}9APT9lv~izgSt1*z1>GsT6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u8GuK)%snwbf}>umr~QvsmE^BHA~^8BYLi1N&;K;S=NOU~I9JLG5uO7!hJ4M)&jA0XD9@Zf#Qk#% z8DTbsv`==~hpkjbyboz^@;}f` zY8l0D8&d6~#6G^|s=1ZH(sA)sfc3v>85aIA; v@I?1~y 0) { $('.footer-bar-notice').css('color', 'green'); } - + if ($('.footer-bar-notice').find('.notice-error').length > 0) { $('.footer-bar-notice').css('color', 'red'); } @@ -63,11 +63,11 @@ var QSMAdmin; jQuery(".add-more-link").hide(); } if (jQuery('#limit_category_checkbox-1:checked').length > 0) { - jQuery('.qsm_tab_content input[name="question_per_category"],.qsm_tab_content .category_selection_random').parents("tr").hide(); + jQuery('#question_per_category').hide(); jQuery('div.select-category-question-limit-maindiv').parents("tr").show(); } else { jQuery('div.select-category-question-limit-maindiv').parents("tr").hide(); - jQuery('.qsm_tab_content input[name="question_per_category"],.qsm_tab_content .category_selection_random .qsm_tab_content .category_selection_random').parents("tr").show(); + jQuery('#question_per_category').show(); } $('.qsm-tab').on('click', function (event) { event.preventDefault(); @@ -79,13 +79,13 @@ var QSMAdmin; $('.footer-bar-notice').css('color', 'green'); $('.footer-bar-notice .updated').fadeOut(5000); } - + if ($('.footer-bar-notice').find('.error').length > 0) { $('.footer-bar-notice').css('color', 'red'); $('.footer-bar-notice .error').fadeOut(5000); } }); - + $(document).on('click', '#close', function (e) { e.preventDefault(); $('.footer-bar-notice').empty(); @@ -359,22 +359,38 @@ var QSMAdmin; e.preventDefault(); MicroModal.show('show-all-variable'); }); - if ( "" != jQuery('#scheduled_time_end').val() ) { - jQuery('.not_allow_after_expired_time label').css('opacity', '1'); + if ( "" != jQuery('#scheduled_time_end-input').val() ) { + jQuery('#not_allow_after_expired_time label').css('opacity', '1'); jQuery('#not_allow_after_expired_time-1').attr('disabled', false); } else { - jQuery('.not_allow_after_expired_time label').css('opacity', '0.7'); + jQuery('#not_allow_after_expired_time label').css('opacity', '0.7'); jQuery('#not_allow_after_expired_time-1').attr('disabled', true); } - jQuery(document).on('change', '#scheduled_time_end', function () { + jQuery(document).on('change', '#scheduled_time_end-input', function () { if ( "" != jQuery(this).val() ) { - jQuery('.not_allow_after_expired_time label').css('opacity', '1'); + jQuery('#not_allow_after_expired_time label').css('opacity', '1'); jQuery('#not_allow_after_expired_time-1').attr('disabled', false); } else { - jQuery('.not_allow_after_expired_time label').css('opacity', '0.7'); + jQuery('#not_allow_after_expired_time label').css('opacity', '0.7'); 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); + } else { + jQuery('#limit_category_checkbox label').css('opacity', '0.7'); + jQuery('#limit_category_checkbox-1').attr('disabled', true); + } + 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-1').attr('disabled', false); + } else { + jQuery('#limit_category_checkbox label').css('opacity', '0.7'); + jQuery('#limit_category_checkbox-1').attr('disabled', true); + } + }); //Hide/show tr based on selection $('.qsm_tab_content .qsm-opt-tr select').each(function () { var name = $(this).attr('name'); @@ -383,39 +399,37 @@ var QSMAdmin; $('.' + name + '_' + value).show(); } }); - $(document).on('change', '.qsm_tab_content select:not(.question_limit_category), #quiz_settings_wrapper select:not(.question_limit_category)', function () { - var name = $(this).attr('name'); + $(document).on('change', '.qsm_tab_content #form_type input, #quiz_settings_wrapper input[name="form_type"]', function () { var value = $(this).val(); - $('.qsm_hidden_tr').hide(); - if ($('.' + name + '_' + value).length > 0) { - hide_show_quiz_options(value); - } + hide_show_quiz_options(value); }); // form_type (0, 1, 2). function hide_show_quiz_options(form_type) { if (0 == form_type) { - $('.qsm_tab_content input[name="system"], .qsm_tab_content input[name="score_roundoff"], .qsm_tab_content input[name="correct_answer_logic"]').parents('tr').show(); + $('#score_roundoff').parents('tr').show(); + $('#correct_answer_logic').show(); } else { - $('.qsm_tab_content input[name="score_roundoff"], .qsm_tab_content input[name="correct_answer_logic"]').parents('tr').hide(); + $('#score_roundoff').parents('tr').hide(); + $('#correct_answer_logic').hide(); } } $(document).on('click', '.qsm_tab_content input[name="system"]', function () { - var name = $(this).attr('name'); var value = $(this).val(); - $('.qsm_hidden_tr_gradingsystem').hide(); + $('#correct_answer_logic, #score_roundoff').hide(); if (value == 0 || value == 3) { - $('.qsm_hidden_tr_gradingsystem').show(); + $('#correct_answer_logic, #score_roundoff').show(); } }); $(document).ready(function () { var system_option = $("input[type=radio][name='system']:checked").val(); - $('.qsm_hidden_tr_gradingsystem').hide(); + $('#correct_answer_logic, #score_roundoff').hide(); if (system_option == 0 || system_option == 3) { - $('.qsm_hidden_tr_gradingsystem').show(); + $('#correct_answer_logic, #score_roundoff').show(); } - hide_show_quiz_options($("select[name='form_type']").find(":selected").val()); + hide_show_quiz_options($("input[name='form_type']:checked").val()); + jQuery('.qsm-date-picker').datetimepicker({ format: 'm/d/Y H:i', step: 1}); }); if ($('.qsm-text-label-wrapper').length > 0) { var element_position = $('.qsm-text-label-wrapper').offset().top; diff --git a/php/classes/class-qsm-fields.php b/php/classes/class-qsm-fields.php index 0e31153f8..b4b92de87 100644 --- a/php/classes/class-qsm-fields.php +++ b/php/classes/class-qsm-fields.php @@ -128,7 +128,11 @@ public static function generate_section( $fields, $section ) { foreach ( $fields as $field ) { // Generate the field if ( isset( $field['option_tab'] ) && 'general' === $field['option_tab'] ) { - QSM_Fields::generate_field( $field, $settings[ $field["id"] ] ); + if ( ! empty( $field['type'] ) && 'multiple_fields' === $field['type'] ) { + QSM_Fields::generate_field( $field, $settings ); + }else { + QSM_Fields::generate_field( $field, $settings[ $field["id"] ] ); + } } } ?> @@ -291,6 +295,110 @@ public static function generate_section( $fields, $section ) { + + + + + + + + + + + $field ) { + if ( isset( $value[ $key ] ) ) { + ?> +
+ + + + + + + + + + + + + + + + +
+ + + + + + null, @@ -312,7 +419,7 @@ public static function generate_field( $field, $value ) { $field = wp_parse_args( $field, $defaults ); // If id is not valid, return false - if ( is_null( $field["id"] ) || empty( $field["id"] ) ) { + if ( ( is_null( $field["id"] ) || empty( $field["id"] ) ) && 'multiple_fields' !== $field['type'] ) { return false; } @@ -457,11 +564,6 @@ public static function generate_editor_field( $field, $value ) { * @param mixed $value The current value of the setting */ public static function generate_date_field( $field, $value ) { - - $date_field_script = "jQuery(function() { jQuery('#" . $field["id"]."').datetimepicker({ format: 'm/d/Y H:i', step: 1});});"; - - wp_add_inline_script( 'qsm_admin_js', $date_field_script); - ?> @@ -476,7 +578,7 @@ public static function generate_date_field( $field, $value ) { - " name="" value="" /> + " name="" value="" /> @@ -512,7 +614,7 @@ public static function generate_number_field( $field, $value ) { - " name="" value="" /> + " name="" value="" /> @@ -549,8 +651,9 @@ public static function generate_radio_field( $field, $value ) { + @@ -764,10 +867,12 @@ public static function generate_checkbox_field( $field, $value ) { - " - name="" - value="" /> - + diff --git a/php/classes/class-qsm-install.php b/php/classes/class-qsm-install.php index 12d1c2fa8..9d20a2bba 100644 --- a/php/classes/class-qsm-install.php +++ b/php/classes/class-qsm-install.php @@ -41,131 +41,296 @@ public function add_hooks() { public function register_default_settings() { global $mlwQuizMasterNext; + // Registers require_log_in setting + $field_array = array( + 'label' => __( 'Select Type', 'quiz-master-next' ), + 'id' => '', + 'type' => 'multiple_fields', + 'fields' => array( + 'form_type' => array( + 'type' => 'radio', + 'options' => array( + array( + 'label' => __( 'Quiz', 'quiz-master-next' ), + 'value' => 0, + ), + array( + 'label' => __( 'Survey', 'quiz-master-next' ), + 'value' => 1, + ), + array( + 'label' => __( 'Simple Form', 'quiz-master-next' ), + 'value' => 2, + ), + ), + 'default' => 0, + ), + 'require_log_in' => array( + 'type' => 'checkbox', + 'options' => array( + array( + 'label' => __( 'Allow only logged-in users to access the content', 'quiz-master-next' ), + 'value' => 1, + ), + ), + 'default' => 0, + ), + ), + 'option_tab' => 'general', + ); + $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); // Registers system setting $field_array = array( - 'id' => 'form_type', - 'label' => __( 'Quiz Type', 'quiz-master-next' ), - 'type' => 'select', - 'options' => array( - array( - 'label' => __( 'Quiz', 'quiz-master-next' ), - 'value' => 0, - ), - array( - 'label' => __( 'Survey', 'quiz-master-next' ), - 'value' => 1, + + 'id' => '', + 'label' => __( 'Grading System', 'quiz-master-next' ), + 'type' => 'multiple_fields', + 'fields' => array( + 'system' => array( + 'type' => 'radio', + 'options' => array( + array( + 'label' => __( 'Correct/Incorrect', 'quiz-master-next' ), + 'value' => 0, + ), + array( + 'label' => __( 'Points', 'quiz-master-next' ), + 'value' => 1, + ), + array( + 'label' => __( 'Both', 'quiz-master-next' ), + 'value' => 3, + ), + ), + 'default' => 0, + ), + 'score_roundoff' => array( + 'type' => 'checkbox', + 'options' => array( + array( + 'label' => __( 'Allow Score Round-off', 'quiz-master-next' ), + 'value' => 1, + ), + ), + 'default' => 0, ), - array( - 'label' => __( 'Simple Form', 'quiz-master-next' ), - 'value' => 2, + ), + 'tooltip' => __( 'To know more about our grading systems please ', 'quiz-master-next' ) . '' . __( 'read the documentation.', 'quiz-master-next' ) . '', + 'option_tab' => 'general', + ); + $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); + + // Registers correct_answer_logic field + $field_array = array( + 'id' => '', + 'type' => 'multiple_fields', + 'label' => __( 'Answer Settings', 'quiz-master-next' ), + 'fields' => array( + 'correct_answer_logic' => array( + 'type' => 'radio', + 'prefix_text' => __( 'Correct Answer Logic:', 'quiz-master-next' ), + 'options' => array( + array( + 'label' => __( 'All correct answers', 'quiz-master-next' ), + 'value' => 1, + ), + array( + 'label' => __( 'Any correct answer', 'quiz-master-next' ), + 'value' => 0, + ), + ), + 'default' => 0, + ), + 'enable_deselect_option' => array( + 'type' => 'checkbox', + 'prefix_text' => __( 'Other Answer Settings:', 'quiz-master-next' ), + 'options' => array( + array( + 'label' => __( 'Allow user to deselect an answer and leave it blank. ', 'quiz-master-next' ) . '(' . __( 'Works with multiple choice & horizontal multiple choice questions only', 'quiz-master-next' ) . ')', + 'value' => 1, + ), + ), + 'default' => 0, + ), + 'form_disable_autofill' => array( + 'type' => 'checkbox', + 'options' => array( + array( + 'label' => __( 'Enable auto-fill suggestions for the quiz inputs.', 'quiz-master-next' ), + 'value' => 1, + ), + ), + 'default' => 0, + ), + 'disable_mathjax' => array( + 'type' => 'checkbox', + 'options' => array( + array( + 'label' => __( 'Allow math formulas for mathematical & technical questions, using TeX and LaTeX notation.', 'quiz-master-next' ), + 'value' => 1, + ), + ), + 'default' => 1, ), ), - 'default' => 0, 'option_tab' => 'general', ); $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - // Registers system setting + // Registers randomness_order setting $field_array = array( - 'id' => 'system', - 'label' => __( 'Grading System', 'quiz-master-next' ), - 'type' => 'radio', - 'options' => array( + 'id' => 'randomness_order', + 'label' => __( 'Random Questions', 'quiz-master-next' ), + 'type' => 'radio', + 'options' => array( array( - 'label' => __( 'Correct/Incorrect', 'quiz-master-next' ), - 'value' => 0, + 'label' => __( 'Random Questions', 'quiz-master-next' ), + 'value' => 1, ), array( - 'label' => __( 'Points', 'quiz-master-next' ), - 'value' => 1, + 'label' => __( 'Random Questions And Answers', 'quiz-master-next' ), + 'value' => 2, ), array( - 'label' => __( 'Both', 'quiz-master-next' ), + 'label' => __( 'Random Answers', 'quiz-master-next' ), 'value' => 3, ), + array( + 'label' => __( 'Disabled', 'quiz-master-next' ), + 'value' => 0, + ), ), - 'default' => 0, - 'help' => __( 'Select the system for grading the quiz.', 'quiz-master-next' ), - 'tooltip' => __( 'To know more about our grading systems please ', 'quiz-master-next' ) . '' . __( 'read the documentation.', 'quiz-master-next' ) . '', - 'show_option' => 'form_type_0', - 'option_tab' => 'general', + 'default' => 0, + 'tooltip' => __( 'Randomize the order of questions or answers every time a quiz loads', 'quiz-master-next' ), + 'option_tab' => 'general', ); $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - // Registers correct_answer_logic field + // Registers scheduled_time_start setting $field_array = array( - 'id' => 'correct_answer_logic', - 'label' => __( 'Correct Answer Logic', 'quiz-master-next' ), - 'type' => 'radio', - 'options' => array( - array( - 'label' => __( 'All correct answers', 'quiz-master-next' ), - 'value' => 1, + 'id' => '', + 'type' => 'multiple_fields', + 'label' => __( 'Quiz Dates', 'quiz-master-next' ), + 'fields' => array( + 'scheduled_time_start' => array( + 'type' => 'date', + 'default' => '', + 'placeholder' => __( 'Start Date', 'quiz-master-next' ), + ), + 'scheduled_time_end' => array( + 'type' => 'date', + 'default' => '', + 'placeholder' => __( 'End Date', 'quiz-master-next' ), + ), + 'not_allow_after_expired_time' => array( + 'type' => 'checkbox', + 'options' => array( + array( + 'label' => __( 'Do not allow quiz submission after the end date/time', 'quiz-master-next' ), + 'value' => 1, + ), + ), + 'default' => 0, ), - array( - 'label' => __( 'Any correct answer', 'quiz-master-next' ), - 'value' => 0, + ), + 'container_class' => 'qsm-quiz-dates', + 'tooltip' => __( 'Leave blank for no date limit', 'quiz-master-next' ), + 'option_tab' => 'general', + ); + $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); + + // Registers question_from_total setting + $field_array = array( + 'id' => '', + 'type' => 'multiple_fields', + 'label' => __( 'Limit number of Questions', 'quiz-master-next' ), + 'fields' => array( + 'question_from_total' => array( + 'type' => 'number', + 'suffix_text' => '' . __( 'Maximum question limit', 'quiz-master-next' ) . "", + 'default' => 0, + ), + 'limit_category_checkbox' => array( + 'type' => 'checkbox', + 'options' => array( + array( + 'label' => __( 'Set questions limit per category', 'quiz-master-next' ), + 'value' => 1, + ), + ), + 'default' => 0, + ), + 'question_per_category' => array( + 'type' => 'number', + 'suffix_text' => '' . __( "Limit number of questions per category", "quiz-master-next" ) . ' ' . __( "Show only limited number of category questions from your quiz.You also need to set Limit Number of questions.", "quiz-master-next" ) . '', + 'default' => 0, ), ), - 'default' => 0, - 'show_option' => 'qsm_hidden_tr_gradingsystem', - 'option_tab' => 'general', + 'container_class' => 'qsm-small-input-field', + 'tooltip' => __( 'Show only limited number of questions from your quiz.', 'quiz-master-next' ), + 'option_tab' => 'general', ); $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - // Registers default number of answers field + //Registers category setting $field_array = array( - 'id' => 'default_answers', - 'label' => __( 'Default Number of Answers', 'quiz-master-next' ), - 'type' => 'number', - 'options' => array(), - 'default' => 1, - 'help' => __( 'Adds number of answer fields', 'quiz-master-next' ), + 'id' => 'randon_category', + 'label' => __( 'Questions Categories', 'quiz-master-next' ), + 'type' => 'category', + 'default' => '', + 'help' => __( 'Questions will load only from selected categories.', 'quiz-master-next' ), 'option_tab' => 'general', ); $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - // Registers Rounding setting + // Registers system setting $field_array = array( - 'id' => 'score_roundoff', - 'label' => __( 'Allow Score Round-off', 'quiz-master-next' ), - 'type' => 'checkbox', - 'options' => array( - array( - 'value' => 1, - ), - ), - 'default' => 0, - 'show_option' => 'form_type_0', - 'option_tab' => 'general', + 'id' => 'select_category_question', + 'category_select_key' => 'question_limit_category', + 'question_limit_key' => 'question_limit_key', + 'label' => __( 'Select Category', 'quiz-master-next' ), + 'type' => 'selectinput', + 'default' => '', + 'option_tab' => 'general', + 'help' => __( 'You also need to set Limit Number of questions', 'quiz-master-next' ), ); $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - // Registers progress_bar setting + // Registers default number of answers field $field_array = array( - 'id' => 'progress_bar', - 'label' => __( 'Show progress bar', 'quiz-master-next' ), - 'type' => 'radio', + 'id' => 'default_answers', + 'label' => __( 'Default Number of Answers', 'quiz-master-next' ), + 'type' => 'number', + 'default' => 1, + 'container_class' => 'qsm-small-input-field', + 'suffix_text' => '' . __( 'Adds number of answer field', 'quiz-master-next' ) . "", + 'option_tab' => 'general', + ); + $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); + + // Registers comment_section setting + $field_array = array( + 'id' => 'comment_section', + 'label' => __( 'Enable comments', 'quiz-master-next' ), + 'type' => 'checkbox', 'options' => array( array( - 'label' => __( 'Yes', 'quiz-master-next' ), - 'value' => 1, - ), - array( - 'label' => __( 'No', 'quiz-master-next' ), + 'label' => __( 'Allow users to post comments after completion', 'quiz-master-next' ), 'value' => 0, ), ), - 'default' => 0, - 'option_tab' => 'display', + 'default' => 1, + 'option_tab' => 'general', ); $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - // Registers require_log_in setting + /* ===== Generat tab end ======== */ + + // Registers progress_bar setting $field_array = array( - 'id' => 'require_log_in', - 'label' => __( 'Require User Login', 'quiz-master-next' ), + 'id' => 'progress_bar', + 'label' => __( 'Show progress bar', 'quiz-master-next' ), 'type' => 'radio', 'options' => array( array( @@ -178,8 +343,7 @@ public function register_default_settings() { ), ), 'default' => 0, - 'help' => __( 'Enabling this allows only logged in users to take the quiz', 'quiz-master-next' ), - 'option_tab' => 'general', + 'option_tab' => 'display', ); $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); @@ -273,142 +437,6 @@ public function register_default_settings() { ); $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - // Registers question_from_total setting - $field_array = array( - 'id' => 'question_from_total', - 'label' => __( 'Limit number of Questions', 'quiz-master-next' ), - 'type' => 'number', - 'options' => array(), - 'default' => 0, - 'help' => __( 'Leave 0 to load all questions', 'quiz-master-next' ), - 'tooltip' => __( 'Show only limited number of questions from your quiz.', 'quiz-master-next' ), - 'option_tab' => 'general', - ); - - $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - // Registers Rounding setting - $field_array = array( - 'id' => 'limit_category_checkbox', - 'label' => __( 'Limit questions for each category', 'quiz-master-next' ), - 'type' => 'checkbox', - 'options' => array( - array( - 'value' => 1, - ), - ), - 'default' => 0, - 'show_option' => 'form_type_1', - 'option_tab' => 'general', - ); - $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - // Registers question_per_category setting - $field_array = array( - 'id' => 'question_per_category', - 'label' => __( 'Limit number of Questions Per Category ', 'quiz-master-next' ), - 'type' => 'number', - 'options' => array(), - 'default' => 0, - 'help' => __( 'Leave 0 to load all questions. You also need to set Limit Number of questions, as well as select Question Categories', 'quiz-master-next' ), - 'tooltip' => __( 'Show only limited number of category questions from your quiz.You also need to set Limit Number of questions.', 'quiz-master-next' ), - 'option_tab' => 'general', - ); - $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - //Registers category setting - $field_array = array( - 'id' => 'randon_category', - 'label' => __( 'Questions Categories', 'quiz-master-next' ), - 'type' => 'category', - 'default' => '', - 'help' => __( 'Questions will load only from selected categories.', 'quiz-master-next' ), - 'option_tab' => 'general', - ); - $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - - // Registers system setting - $field_array = array( - 'id' => 'select_category_question', - 'category_select_key' => 'question_limit_category', - 'question_limit_key' => 'question_limit_key', - 'label' => __( 'Select Category', 'quiz-master-next' ), - 'type' => 'selectinput', - 'default' => '', - 'option_tab' => 'general', - 'help' => __( 'You also need to set Limit Number of questions', 'quiz-master-next' ), - ); - $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - - - // Registers randomness_order setting - $field_array = array( - 'id' => 'randomness_order', - 'label' => __( 'Random Questions', 'quiz-master-next' ), - 'type' => 'select', - 'options' => array( - array( - 'label' => __( 'Random Questions', 'quiz-master-next' ), - 'value' => 1, - ), - array( - 'label' => __( 'Random Questions And Answers', 'quiz-master-next' ), - 'value' => 2, - ), - array( - 'label' => __( 'Random Answers', 'quiz-master-next' ), - 'value' => 3, - ), - array( - 'label' => __( 'Disabled', 'quiz-master-next' ), - 'value' => 0, - ), - ), - 'default' => 0, - 'tooltip' => __( 'Randomize the order of questions or answers every time a quiz loads', 'quiz-master-next' ), - 'option_tab' => 'general', - ); - $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - - // Registers scheduled_time_start setting - $field_array = array( - 'id' => 'scheduled_time_start', - 'label' => __( 'Quiz Dates', 'quiz-master-next' ), - 'type' => 'date', - 'options' => array(), - 'default' => '', - 'help' => '', - 'ph_text' => __( 'Start Date', 'quiz-master-next' ), - 'help' => __( 'If set, Quiz will be accessible only after this date', 'quiz-master-next' ), - 'tooltip' => __( 'Leave blank for no date limit', 'quiz-master-next' ), - 'option_tab' => 'general', - ); - $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - - // Registers scheduled_time_end setting - $field_array = array( - 'id' => 'scheduled_time_end', - 'label' => '', - 'type' => 'date', - 'options' => array(), - 'default' => '', - 'help' => __( ' If set, Quiz will not be accessible after this date', 'quiz-master-next' ), - 'ph_text' => __( 'End Date', 'quiz-master-next' ), - 'option_tab' => 'general', - ); - $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - $field_array = array( - 'id' => 'not_allow_after_expired_time', - 'label' => '', - 'type' => 'checkbox', - 'options' => array( - array( - 'value' => 1, - 'label' => __( 'Do not allow quiz submission after the end date/time', 'quiz-master-next' ), - ), - ), - 'default' => 0, - 'option_tab' => 'general', - ); - $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - // Registers contact_info_location setting $field_array = array( 'id' => 'contact_info_location', @@ -453,27 +481,6 @@ public function register_default_settings() { ); $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - // Registers comment_section setting - $field_array = array( - 'id' => 'comment_section', - 'label' => __( 'Enable comments', 'quiz-master-next' ), - 'type' => 'radio', - 'options' => array( - array( - 'label' => __( 'Yes', 'quiz-master-next' ), - 'value' => 0, - ), - array( - 'label' => __( 'No', 'quiz-master-next' ), - 'value' => 1, - ), - ), - 'default' => 1, - 'help' => __( 'Allow users to enter their comments after the quiz', 'quiz-master-next' ), - 'option_tab' => 'general', - ); - $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - // Registers question_numbering setting $field_array = array( 'id' => 'question_numbering', @@ -632,25 +639,6 @@ public function register_default_settings() { ); $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - $field_array = array( - 'id' => 'form_disable_autofill', - 'label' => __( 'Disable auto fill for Quiz input', 'quiz-master-next' ), - 'type' => 'radio', - 'options' => array( - array( - 'label' => __( 'Yes', 'quiz-master-next' ), - 'value' => 1, - ), - array( - 'label' => __( 'No', 'quiz-master-next' ), - 'value' => 0, - ), - ), - 'default' => 0, - 'option_tab' => 'general', - ); - $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - // Registers show category on front setting $field_array = array( 'id' => 'show_category_on_front', @@ -814,27 +802,6 @@ public function register_default_settings() { ); $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - // Setting for pagination of quiz - $field_array = array( - 'id' => 'enable_deselect_option', - 'label' => __( 'Deselect Answer', 'quiz-master-next' ), - 'type' => 'radio', - 'options' => array( - array( - 'label' => __( 'Yes', 'quiz-master-next' ), - 'value' => 1, - ), - array( - 'label' => __( 'No', 'quiz-master-next' ), - 'value' => 0, - ), - ), - 'default' => 0, - 'help' => __( 'Users are able deselect an answer and leave it blank. Works with Multiple Choice and Horizintal Multiple Choice questions only', 'quiz-master-next' ), - 'option_tab' => 'general', - ); - $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - // Setting for pagination of quiz $field_array = array( 'id' => 'disable_description_on_result', @@ -851,27 +818,7 @@ public function register_default_settings() { ), ), 'default' => 0, - 'option_tab' => 'general', - ); - $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); - - $field_array = array( - 'id' => 'disable_mathjax', - 'label' => __( 'Disable MathJax', 'quiz-master-next' ), - 'type' => 'radio', - 'options' => array( - array( - 'label' => __( 'Yes', 'quiz-master-next' ), - 'value' => 1, - ), - array( - 'label' => __( 'No', 'quiz-master-next' ), - 'value' => 0, - ), - ), - 'default' => 0, - 'tooltip' => __( 'Allows you to write math formulas using TeX and LaTeX notation.', 'quiz-master-next' ), - 'option_tab' => 'general', + 'option_tab' => 'display', ); $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); diff --git a/php/classes/class-qsm-settings.php b/php/classes/class-qsm-settings.php index e8a9e226e..e409aa2cb 100644 --- a/php/classes/class-qsm-settings.php +++ b/php/classes/class-qsm-settings.php @@ -427,7 +427,11 @@ private function load_settings() { // Cycle through each setting in section foreach ( $fields as $field ) { // Check if setting exists in section settings and, if not, set it to the default - if ( ! isset( $unserialized_section[ $field['id'] ] ) ) { + if ( ! empty( $field['type'] ) && 'multiple_fields' === $field['type'] ) { + foreach ( $field['fields'] as $key => $value ) { + $unserialized_section[ $key ] = $value['default']; + } + } elseif ( ! isset( $unserialized_section[ $field['id'] ] ) ) { $unserialized_section[ $field['id'] ] = $field['default']; } } diff --git a/templates/qmn_primary.css b/templates/qmn_primary.css index c80393031..008dd68c4 100644 --- a/templates/qmn_primary.css +++ b/templates/qmn_primary.css @@ -1,7 +1,6 @@ .qsm-progress-bar { position: relative; flex-grow: 2; - padding: 0px 10px 30px 10px } .ui-tooltip { From ae458c6867e0c1537e5c8a8cbc72100ba059c5b3 Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Mon, 9 Oct 2023 14:40:54 +0530 Subject: [PATCH 2/3] update option tab style --- css/qsm-admin.css | 12 +-- php/admin/quiz-options-page.php | 2 +- php/classes/class-qsm-fields.php | 126 +----------------------------- php/classes/class-qsm-install.php | 4 +- 4 files changed, 13 insertions(+), 131 deletions(-) diff --git a/css/qsm-admin.css b/css/qsm-admin.css index 9e387a366..f24be67b8 100644 --- a/css/qsm-admin.css +++ b/css/qsm-admin.css @@ -799,6 +799,7 @@ ul.changelog li.update div.two:before { flex-direction: row; flex-wrap: wrap; align-items: stretch; + border-bottom: 1px solid #cecece; } .qsm-sub-text-tab-menu { display: inline-block; @@ -891,10 +892,6 @@ ul.changelog li.update div.two:before { display: inline-block; box-sizing: border-box; } -.qsm_tab_content .subsubsub li { - border-left: 2px solid #aaa; - padding: 0 5px; -} .qsm_tab_content .subsubsub li:first-child { border-left: 0; padding-left: 0; @@ -902,7 +899,7 @@ ul.changelog li.update div.two:before { .qsm_tab_content .subsubsub li a { font-size: 14px; line-height: 1.2; - padding: 0; + padding: 10px; } .qsm_tab_content a:hover, .qsm_tab_content a:focus { @@ -910,6 +907,9 @@ ul.changelog li.update div.two:before { text-decoration: none; box-shadow: none; } +.qsm_tab_content .subsubsub li a.current{ + border-bottom: 3px solid #00BEE9; +} /* Popup */ .qsm-popup { font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, helvetica neue, helvetica, ubuntu, roboto, noto, segoe ui, arial, sans-serif; @@ -1335,7 +1335,7 @@ tr .qsm-opt-desc { #quiz_settings_wrapper .qsm-opt-desc { display: none !important; } -.form-table td fieldset label { +body:not(.qsm_page_qmn_global_settings) .form-table td fieldset label { margin-right: 20px !important; width: 100%; } diff --git a/php/admin/quiz-options-page.php b/php/admin/quiz-options-page.php index 491018de3..2755ba359 100644 --- a/php/admin/quiz-options-page.php +++ b/php/admin/quiz-options-page.php @@ -338,7 +338,7 @@ function qsm_generate_quiz_options() { function qsm_quiz_options_notice_template() { ?> -