Skip to content

Commit

Permalink
update style tab design
Browse files Browse the repository at this point in the history
  • Loading branch information
zubairraeen committed Jul 7, 2023
2 parents 39b3a30 + 0cf38fa commit f4b36dd
Show file tree
Hide file tree
Showing 10 changed files with 469 additions and 466 deletions.
2 changes: 1 addition & 1 deletion css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ footer.qsm-popup__footer button.qsm-popup-secondary-button:hover {
font-size: 13px;
font-weight: bold;
color: rgb(52, 152, 219);
width: 42px;
width: 50px;
margin-left: 10px;
}
.qsm-progress-bar{
Expand Down
10 changes: 10 additions & 0 deletions css/qsm-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -3196,3 +3196,13 @@ body .qsm_tab_content .qsm-small-input-field input[type="text"] {
.qsm-quiz-dates fieldset#scheduled_time_start, .qsm-quiz-dates fieldset#scheduled_time_end {
display: inline-block;
}
.qsm-image-field {
display: flex;
}
.qsm-image-field span {
padding-top: 4px;
}
fieldset#enable_quick_correct_answer_info {
margin-left: 25px;
margin-top: 4px;
}
2 changes: 1 addition & 1 deletion data/parsing_script.json

Large diffs are not rendered by default.

50 changes: 47 additions & 3 deletions js/qsm-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ var QSMAdmin;
}
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();
}
$('.qsm-tab').on('click', function (event) {
Expand Down Expand Up @@ -150,13 +152,31 @@ var QSMAdmin;
$(document).on('change', '#limit_category_checkbox-1', function (event) {
event.preventDefault();
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();
jQuery('.category_selection_random').parents("tr").hide();
} 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').parents("tr").show();
jQuery('#question_per_category').show();
jQuery('.category_selection_random').parents("tr").show();
}
});
show_hide_show_correct_answer();
$(document).on('change', '#enable_quick_result_mc-1', function (event) {
show_hide_show_correct_answer();
});
function show_hide_show_correct_answer() {
if (jQuery('#enable_quick_result_mc-1:checked').length > 0) {
jQuery('#enable_quick_correct_answer_info').css('opacity', '1');
} else {
jQuery('#enable_quick_correct_answer_info').css('opacity', '0.5');
}
}
jQuery(document).on('change', '#preferred-date-format-custom', function() {
var customValue = jQuery(this).val();
jQuery('#preferred_date_format label.qsm-option-label:last input[type="radio"]').val(customValue);
});

jQuery(document).on('click','.add-more-category', function () {
let original = jQuery('div.select-category-question-limit-maindiv');
let lastChild = original.children().last();
Expand Down Expand Up @@ -378,17 +398,21 @@ var QSMAdmin;
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();
}
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);
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();
}
});
//Hide/show tr based on selection
Expand Down Expand Up @@ -429,7 +453,9 @@ var QSMAdmin;
$('#correct_answer_logic, #score_roundoff').show();
}
hide_show_quiz_options($("input[name='form_type']:checked").val());
jQuery('.qsm-date-picker').datetimepicker({ format: 'm/d/Y H:i', step: 1});
if (jQuery('.qsm-date-picker').length) {
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;
Expand Down Expand Up @@ -523,6 +549,24 @@ var QSMAdmin;
}).open();
});

$(document).on('click', '.qsm-image-btn', function (e) {
var button = $(this);
e.preventDefault();
custom_uploader = wp.media({
title: qsm_admin_messages.set_feature_img,
library: {
type: 'image'
},
button: {
text: qsm_admin_messages.use_img // button label text
},
multiple: false
}).on('select', function () { // it also has "open" and "close" events
var attachment = custom_uploader.state().get('selection').first().toJSON();
button.prev('.qsm-image-input').val(attachment.url);
}).open();
});

// opens media library o set background image for quiz
$(document).on('click', '.set_background_image', function (e) {
let button = $(this);
Expand Down
14 changes: 7 additions & 7 deletions js/qsm-quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -805,8 +805,8 @@ function qmnDoInit() {
});
}
}
if ( jQuery('.qsm-quiz-container-' + quizID + ' .qsm-submit-btn').is(':visible') || jQuery('.qsm-quiz-container-' + quizID + ' .qsm-quiz-comment-section').closest('.qsm-page').is(':visible') ) {
jQuery('.qsm-quiz-container-' + quizID + ' .qsm-quiz-comment-section').fadeIn();
if ( jQuery('.qsm-quiz-container-' + _quiz_id + ' .qsm-submit-btn').is(':visible') || jQuery('.qsm-quiz-container-' + _quiz_id + ' .qsm-quiz-comment-section').closest('.qsm-page').is(':visible') ) {
jQuery('.qsm-quiz-container-' + _quiz_id + ' .qsm-quiz-comment-section').fadeIn();
}
});
}
Expand Down Expand Up @@ -1691,12 +1691,12 @@ jQuery(function () {

jQuery(document).on('change ', '.qmn_check_answers input', function (e) {
let $i_this = jQuery(this);
var quizID = jQuery(this).parents('.qsm-quiz-container').find('.qmn_quiz_id').val();
var $quizForm = QSM.getQuizForm(quizID);
var question_id = jQuery(this).attr('name').split('question')[1],
let quizID = jQuery(this).parents('.qsm-quiz-container').find('.qmn_quiz_id').val();
let $quizForm = QSM.getQuizForm(quizID);
let question_id = jQuery(this).attr('name').split('question')[1],
$this = jQuery(this).parents('.quiz_section');
var parent = jQuery(this).closest('.qmn_check_answers');
var checkedValues = parent.find('input[type="checkbox"]:checked').map(function() {
let parent = jQuery(this).closest('.qmn_check_answers');
let checkedValues = parent.find('input[type="checkbox"]:checked').map(function() {
return jQuery(this).val();
}).get();
if (qmn_quiz_data[quizID].end_quiz_if_wrong > 0 && !jQuery(this).parents('.qsm-quiz-container').find('.mlw_next:visible').length ) {
Expand Down
5 changes: 3 additions & 2 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: 8.1.8
* Version: 8.1.10
* 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 = '8.1.8';
public $version = '8.1.10';

/**
* QSM Alert Manager Object
Expand Down Expand Up @@ -361,6 +361,7 @@ public function qsm_admin_scripts_style( $hook ) {
wp_enqueue_script( 'jquery-ui-tabs' );
wp_enqueue_script( 'jquery-effects-blind' );
wp_enqueue_script( 'jquery-effects-explode' );
wp_enqueue_media();
break;
default:
wp_enqueue_editor();
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 @@ -980,7 +980,7 @@ public function quiz_animation_effect() {
'value' => 'heartBeat',
),
array(
'label' => __( 'No animation', 'quiz-master-next' ),
'label' => __( 'Select Quiz Animation', 'quiz-master-next' ),
'value' => '',
),
);
Expand Down
76 changes: 62 additions & 14 deletions php/classes/class-qsm-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function generate_section( $fields, $section ) {
foreach ( $fields as $field ) {
// Sanitize the values based on type
$sanitized_value = '';
if ( isset( $_POST[ $field["id"] ] ) || 'selectinput' == $field["type"] ) {
if ( ( isset( $_POST[ $field["id"] ] ) && 'multiple_fields' !== $field["type"] ) || 'selectinput' == $field["type"] ) {
switch ( $field["type"] ) {
case 'text':
$sanitized_value = sanitize_text_field( wp_unslash( $_POST[ $field["id"] ] ) );
Expand Down Expand Up @@ -65,7 +65,27 @@ public static function generate_section( $fields, $section ) {
break;
}
}
$settings_array[ $field["id"] ] = $sanitized_value;
if ( 'multiple_fields' == $field["type"] ) {
foreach ( $field["fields"] as $key => $value ) {
switch ( $value["type"] ) {
case 'url':
$sanitized_value = esc_url_raw( wp_unslash( $_POST[ $key ] ) );
break;
case 'checkbox':
$sanitized_value = isset( $_POST[ $key ] ) ? sanitize_text_field( wp_unslash( $_POST[ $key ] ) ) : 0;
break;
case 'number':
$sanitized_value = intval( $_POST[ $key ] );
break;
default:
$sanitized_value = sanitize_text_field( wp_unslash( $_POST[ $key ] ) );
break;
}
$settings_array[ $key ] = $sanitized_value;
}
}else {
$settings_array[ $field["id"] ] = $sanitized_value;
}
}

$quiz_id = isset( $_GET["quiz_id"] ) ? intval( $_GET["quiz_id"] ) : 0;
Expand Down Expand Up @@ -145,7 +165,11 @@ public static function generate_section( $fields, $section ) {
foreach ( $fields as $field ) {
// Generate the field
if ( isset( $field['option_tab'] ) && 'quiz_submission' === $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"] ] );
}
}
}
?>
Expand All @@ -158,7 +182,11 @@ public static function generate_section( $fields, $section ) {
foreach ( $fields as $field ) {
// Generate the field
if ( isset( $field['option_tab'] ) && 'display' === $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"] ] );
}
}
}
?>
Expand All @@ -171,7 +199,11 @@ public static function generate_section( $fields, $section ) {
foreach ( $fields as $field ) {
// Generate the field
if ( isset( $field['option_tab'] ) && 'contact_form' === $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"] ] );
}
}
}
?>
Expand Down Expand Up @@ -328,8 +360,8 @@ public static function generate_multiple_fields_field( $fields, $value ) {
case 'checkbox':
foreach ( $field["options"] as $option ) {
?>
<label class="qsm-option-label" for="<?php echo esc_attr( $key . '-' . $option["value"] ); ?>">
<input type="checkbox" id="<?php echo esc_attr( $key . '-' . $option["value"] ); ?>"
<label class="qsm-option-label" for="<?php echo sanitize_title( $key . '-' . $option["value"] ); ?>">
<input type="checkbox" id="<?php echo sanitize_title( $key . '-' . $option["value"] ); ?>"
name="<?php echo esc_attr( $key ); ?>" <?php checked( $option["value"], $value[ $key ] ); ?>
value="<?php echo esc_attr( $option["value"] ); ?>" />
<?php echo isset( $option["label"] ) ? wp_kses_post( $option["label"] ) : ""; ?>
Expand All @@ -340,26 +372,43 @@ public static function generate_multiple_fields_field( $fields, $value ) {
case 'radio':
foreach ( $field["options"] as $option ) {
?>
<label class="qsm-option-label" for="<?php echo esc_attr( $key . '-' . $option["value"] ); ?>">
<input type="radio" id="<?php echo esc_attr( $key . '-' . $option["value"] ); ?>" name="<?php echo esc_attr( $key ); ?>" <?php checked( $option["value"], $value[ $key ] ); ?> value="<?php echo esc_attr( $option["value"] ); ?>" />
<?php echo isset( $option["label"] ) ? wp_kses_post( $option["label"] ) : ""; ?>
<label class="qsm-option-label" for="<?php echo sanitize_title( $key . '-' . $option["value"] ); ?>">
<input type="radio" id="<?php echo sanitize_title( $key . '-' . $option["value"] ); ?>" name="<?php echo esc_attr( $key ); ?>" <?php checked( $option["value"], $value[ $key ] ); ?> value="<?php echo esc_attr( $option["value"] ); ?>" />
<?php
$allowed_tags = wp_kses_allowed_html('post');
$allowed_tags['input'] = array(
'class' => 1,
'id' => 1,
'type' => 1,
'name' => 1,
'value' => 1,
);
echo isset( $option["label"] ) ? wp_kses( $option["label"], $allowed_tags ) : ""; ?>
</label>
<?php
}
break;
case 'date':
?>
<input autocomplete="off" class="qsm-date-picker" type="text" placeholder="<?php echo ! empty( $field['placeholder'] ) ? $field['placeholder'] : ''; ?>" id="<?php echo esc_attr( $key ); ?>-input" name="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $value[ $key ] ); ?>" />
<input autocomplete="off" class="qsm-date-picker" type="text" placeholder="<?php echo ! empty( $field['placeholder'] ) ? $field['placeholder'] : ''; ?>" id="<?php echo sanitize_title( $key ); ?>-input" name="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $value[ $key ] ); ?>" />
<?php
break;
case 'number':
?>
<input class="small-text" type="number" placeholder="<?php echo ! empty( $field['placeholder'] ) ? $field['placeholder'] : ''; ?>" step="1" min="<?php echo ! empty($field['min']) ? esc_attr($field['min']) : 0; ?>" id="<?php echo esc_attr( $key ); ?>-input" name="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $value[ $key ] ); ?>" />
<input class="small-text" type="number" placeholder="<?php echo ! empty( $field['placeholder'] ) ? $field['placeholder'] : ''; ?>" step="1" min="<?php echo ! empty($field['min']) ? esc_attr($field['min']) : 0; ?>" id="<?php echo sanitize_title( $key ); ?>-input" name="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $value[ $key ] ); ?>" />
<?php
break;
case 'textarea':
?>
<textarea placeholder="<?php echo ! empty( $field['placeholder'] ) ? $field['placeholder'] : ''; ?>" id="<?php echo esc_attr( $key ); ?>-input" name="<?php echo esc_attr( $key ); ?>"><?php echo esc_attr( $value[ $key ] ); ?></textarea>
<textarea placeholder="<?php echo ! empty( $field['placeholder'] ) ? $field['placeholder'] : ''; ?>" id="<?php echo sanitize_title( $key ); ?>-input" name="<?php echo esc_attr( $key ); ?>"><?php echo esc_attr( $value[ $key ] ); ?></textarea>
<?php
break;
case 'image':
?>
<div class="qsm-image-field">
<input placeholder="<?php echo ! empty( $field['placeholder'] ) ? $field['placeholder'] : ''; ?>" type="text" class="qsm-image-input" name="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $value[ $key ] ); ?>">
<a class="qsm-image-btn button" class="button"><span class="dashicons dashicons-format-image"></span> <?php echo esc_html( $field['button_label'] ); ?></a>
</div>
<?php
break;
case 'select':
Expand Down Expand Up @@ -422,7 +471,6 @@ public static function generate_field( $field, $value ) {
if ( ( is_null( $field["id"] ) || empty( $field["id"] ) ) && 'multiple_fields' !== $field['type'] ) {
return false;
}

// If type is empty, assume text
if ( empty( $field["type"] ) ) {
$field["type"] = "text";
Expand Down
Loading

0 comments on commit f4b36dd

Please sign in to comment.