Skip to content

Commit

Permalink
Merge pull request #2270 from QuizandSurveyMaster/dev
Browse files Browse the repository at this point in the history
Release 8.1.9
  • Loading branch information
etvarun authored Jun 28, 2023
2 parents 3fa2708 + 6ad704a commit ef51b0f
Show file tree
Hide file tree
Showing 17 changed files with 216 additions and 80 deletions.
17 changes: 10 additions & 7 deletions css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,17 @@ footer.qsm-popup__footer button.qsm-popup-secondary-button:hover {
min-height: 315px !important;
}
.qsm-progress-bar .progressbar-text {
position: absolute;
padding: 0px;
margin: 0px;
top: 20px !important;
right: 10px;
font-size: 13px;
font-weight: bold;
color: rgb(52, 152, 219);
font-weight: bold;
color: rgb(52, 152, 219);
width: 42px;
margin-left: 10px;
}
.qsm-progress-bar{
display: flex;
flex-direction: row-reverse;
align-items: center;
padding: 0;
}
.quiz_section .mlw-file-upload-error-msg {
color: red;
Expand Down
2 changes: 1 addition & 1 deletion data/parsing_script.json

Large diffs are not rendered by default.

42 changes: 32 additions & 10 deletions js/qsm-quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ var qsmTimerInterval = [];
} 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 @@ -296,9 +299,7 @@ var qsmTimerInterval = [];
* CHecking if the quiz is random
*/
$is_random = $('.qmn_quiz_container').hasClass('random');
if ($is_random) {
QSM.goToPage(quizID, 1);
} else if (0 < $quizForm.children('.qsm-page').length) {
if (0 < $quizForm.children('.qsm-page').length) {
$quizForm.children('.qsm-page').hide();
template = wp.template('qsm-pagination-' + quizID);
$quizForm.append(template());
Expand Down Expand Up @@ -804,6 +805,9 @@ 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();
}
});
}

Expand Down Expand Up @@ -935,7 +939,7 @@ function qmnValidation(element, quiz_form_id) {
}
if (jQuery(this).attr('class').indexOf('mlwRequiredRadio') > -1) {
check_val = jQuery(this).find('input:checked').val();
if (check_val == "No Answer Provided" || check_val == "" || check_val == undefined) {
if (check_val == "" || check_val == undefined) {
qmnDisplayError(error_messages.empty_error_text, jQuery(this), quiz_form_id);
show_result_validation = false;
}
Expand All @@ -949,7 +953,7 @@ function qmnValidation(element, quiz_form_id) {
}
if (jQuery(this).attr('class').indexOf('qsmRequiredSelect') > -1) {
check_val = jQuery(this).val();
if (check_val == "No Answer Provided" || check_val == "" || check_val == null) {
if (check_val == "" || check_val == null) {
qmnDisplayError(error_messages.empty_error_text, jQuery(this), quiz_form_id);
show_result_validation = false;
}
Expand Down Expand Up @@ -1680,14 +1684,32 @@ jQuery(function () {
// Autocomplete off
jQuery('.qsm-quiz-container').find('.qmn_quiz_id').each(function () {
var quizID = jQuery(this).val();
var $quizForm = QSM.getQuizForm(quizID);
if (qmn_quiz_data[quizID].form_disable_autofill == 1) {
jQuery('#quizForm' + quizID).attr('autocomplete', 'off');
}
});

jQuery(document).on('change ', '.qmn_check_answers input', function (e) {
let $i_this = jQuery(this);
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');
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 ) {
qsm_submit_quiz_if_answer_wrong(question_id, checkedValues, $this, $quizForm, 'checkbox');
}
if (qmn_quiz_data[quizID].enable_quick_result_mc == 1) {
qsm_show_inline_result(quizID, question_id, checkedValues, $this, 'checkbox', $i_this)
}
jQuery(document).trigger('qsm_after_select_answer', [quizID, question_id, checkedValues, $this, 'checkbox']);
});

// End Quiz If Wrong
jQuery(document).on('change ', '.qmn_radio_answers input , .qmn_check_answers input , .qsm_select', function (e) {
jQuery(document).on('change ', '.qmn_radio_answers input, .qsm_select', function (e) {
var quizID = jQuery(this).parents('.qsm-quiz-container').find('.qmn_quiz_id').val();
var $quizForm = QSM.getQuizForm(quizID);
if (qmn_quiz_data[quizID].end_quiz_if_wrong > 0 && !jQuery(this).parents('.qsm-quiz-container').find('.mlw_next:visible').length ) {
Expand Down Expand Up @@ -1775,8 +1797,7 @@ jQuery(function () {
jQuery('.qsm-deselect-answer').click(function (e) {
e.preventDefault();
jQuery(this).parents('.quiz_section').find('input[type="radio"]').prop('checked', false);
jQuery(this).parents('.quiz_section').find('input[type="radio"][value="No Answer Provided"]').prop('checked', true);
jQuery(this).parents('.quiz_section').find('input[type="radio"][value=""]').prop('checked', true);
jQuery(this).parents('.quiz_section').find('input[type="radio"]:hidden').prop('checked', true);
});

//Submit the form on popup click
Expand Down Expand Up @@ -1854,7 +1875,7 @@ function checkMaxLength(obj){
}
}
let submit_status = true;
function qsm_submit_quiz_if_answer_wrong(question_id, value, $this, $quizForm) {
function qsm_submit_quiz_if_answer_wrong(question_id, value, $this, $quizForm, answer_type = '') {
let quiz_id = $quizForm.closest('.qmn_quiz_container').find('.qmn_quiz_id').val();
jQuery.ajax({
type: 'POST',
Expand All @@ -1863,6 +1884,7 @@ function qsm_submit_quiz_if_answer_wrong(question_id, value, $this, $quizForm) {
action: "qsm_get_question_quick_result",
question_id: question_id,
answer: value,
answer_type: answer_type,
show_correct_info: qmn_quiz_data[quiz_id].enable_quick_correct_answer_info
},
success: function (response) {
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: 8.1.8
* Version: 8.1.9
* 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.9';

/**
* QSM Alert Manager Object
Expand Down Expand Up @@ -467,6 +467,7 @@ public function register_quiz_post_types() {
$cpt_slug = 'quiz';
$settings = (array) get_option( 'qmn-settings' );
$plural_name = __( 'Quizzes & Surveys', 'quiz-master-next' );
$publicly_queryable = ! empty( $settings['disable_quiz_public_link'] ) ? false : true;

// Checks if admin turned off archive.
if ( isset( $settings['cpt_archive'] ) && '1' === $settings['cpt_archive'] ) {
Expand Down Expand Up @@ -513,7 +514,7 @@ public function register_quiz_post_types() {
'show_in_menu' => 'qsm_dashboard',
'show_in_nav_menus' => true,
'labels' => $quiz_labels,
'publicly_queryable' => true,
'publicly_queryable' => $publicly_queryable,
'exclude_from_search' => $exclude_search,
'label' => $plural_name,
'rewrite' => array( 'slug' => $cpt_slug ),
Expand Down
22 changes: 10 additions & 12 deletions php/admin/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1017,17 +1017,15 @@ function qsm_get_installed_theme( $saved_quiz_theme, $wizard_theme_list = '' ) {
<h2 class="theme-name" id="emarket-name"><?php echo esc_attr( $theme['theme_name'] ); ?></h2>
<div class="theme-actions">
<?php
if ( $saved_quiz_theme != $theme_id ) {
if ( 'wizard_theme_list' !== $wizard_theme_list ) {
?>
<button class="button qsm-activate-theme"><?php esc_html_e( 'Activate', 'quiz-master-next' ); ?></button>
<?php
}
?>
<?php } ?>
<?php if ( $saved_quiz_theme === $theme_id ) { ?>
<a class="button button-primary qsm-customize-color-settings" href="javascript:void(0)"><?php esc_html_e( 'Customize', 'quiz-master-next' ); ?></a>
<?php } ?>
$button = "";
if ( $saved_quiz_theme === $theme_id ) {
$button = '<a class="button button-primary qsm-customize-color-settings" href="javascript:void(0)">' . esc_html__( 'Customize', 'quiz-master-next' ) .' </a>';
}elseif ( 'wizard_theme_list' !== $wizard_theme_list ) {
$button = '<button class="button qsm-activate-theme"> ' . esc_html__( 'Activate', 'quiz-master-next' ) . '</button>';
}
$button = apply_filters( 'qsm_themes_action_button', $button, $theme, $active_themes );
echo wp_kses_post($button);
?>
</div>
</div>
</div>
Expand Down Expand Up @@ -1297,7 +1295,7 @@ function qsm_quiz_theme_settings( $type, $label, $name, $value, $default_value,
'name' => "settings[". $name ."]",
'value' => $value,
);
qsm_get_input_label_selected( $param );
qsm_get_input_label_selected( $param );
break;
default:
?>
Expand Down
19 changes: 18 additions & 1 deletion php/admin/quizzes-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,18 @@ public function qsm_get_edit_post_link( $link, $post_id ) {
public function qsm_post_row_actions( $actions, $post ) {
$post_status = isset( $_REQUEST['post_status'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['post_status'] ) ) : 'all';
if ( 'qsm_quiz' == $post->post_type && 'trash' != $post_status ) {
$settings = (array) get_option( 'qmn-settings' );
$quiz_id = get_post_meta( $post->ID, 'quiz_id', true );
if ( ! empty( $quiz_id ) ) {
$actions = array(
'edit' => '<a class="qsm-action-link" href="admin.php?page=mlw_quiz_options&quiz_id=' . esc_attr( $quiz_id ) . '">' . esc_html__( 'Edit', 'quiz-master-next' ) . '</a>',
'duplicate' => '<a class="qsm-action-link qsm-action-link-duplicate" href="#" data-id="' . esc_attr( $quiz_id ) . '">' . esc_html__( 'Duplicate', 'quiz-master-next' ) . '</a>',
'delete' => '<a class="qsm-action-link qsm-action-link-delete" href="#" data-id="' . esc_attr( $quiz_id ) . '" data-name="' . esc_attr( $post->post_title ) . '">' . esc_html__( 'Delete', 'quiz-master-next' ) . '</a>',
'view_results' => '<a class="qsm-action-link" href="admin.php?page=mlw_quiz_results&quiz_id=' . esc_attr( $quiz_id ) . '">' . esc_html__( 'View Results', 'quiz-master-next' ) . '</a>',
'view' => '<a class="qsm-action-link" target="_blank" rel="noopener" href="' . esc_url( get_permalink( $post->ID ) ) . '">' . esc_html__( 'Preview', 'quiz-master-next' ) . '</a>',
);
if ( empty( $settings['disable_quiz_public_link'] ) ) {
$actions['view'] = '<a class="qsm-action-link" target="_blank" rel="noopener" href="' . esc_url( get_permalink( $post->ID ) ) . '">' . esc_html__( 'Preview', 'quiz-master-next' ) . '</a>';
}
$actions = apply_filters( 'qsm_quiz_actions_after', $actions, $post );
}
}
Expand All @@ -195,6 +198,7 @@ public function qsm_quiz_edit_bulk_actions( $bulk_actions ) {
unset( $bulk_actions['edit'] );
unset( $bulk_actions['trash'] );
$bulk_actions['delete_pr'] = __( 'Delete Permanently', 'quiz-master-next' );
$bulk_actions['set_global'] = __( 'Set Global Settings', 'quiz-master-next' );
return $bulk_actions;
}

Expand All @@ -219,6 +223,19 @@ public function qsm_quiz_bulk_action_handler( $redirect_to, $doaction, $post_ids
$QSMAlertManager = $mlwQuizMasterNext->alertManager->alerts;
setcookie( 'QSMAlertManager', wp_json_encode( $QSMAlertManager ), time() + 86400, COOKIEPATH, COOKIE_DOMAIN );
$redirect_to = add_query_arg( 'quiz_bulk_delete', count( $post_ids ), $redirect_to );
}elseif ( 'set_global' == $doaction && ! empty( $post_ids ) ) {
global $globalQuizsetting, $mlwQuizMasterNext;
foreach ( $post_ids as $post_id ) {
$quiz_id = get_post_meta( $post_id, 'quiz_id', true );
$mlwQuizMasterNext->pluginHelper->prepare_quiz( $quiz_id );
$quiz_options = $mlwQuizMasterNext->quiz_settings->get_setting( 'quiz_options');
$settings = wp_parse_args($globalQuizsetting,$quiz_options);
$mlwQuizMasterNext->quiz_settings->update_setting( 'quiz_options', $settings );
$mlwQuizMasterNext->audit_manager->new_audit( "Quiz/Survey Has Been updated to global settings: ".$settings['quiz_name'], $quiz_id, '' );
}
$mlwQuizMasterNext->alertManager->newAlert( count($post_ids) . __( ' Quiz/Survey has been updated successfully.', 'quiz-master-next' ), 'success' );
$QSMAlertManager = $mlwQuizMasterNext->alertManager->alerts;
setcookie( 'QSMAlertManager', wp_json_encode( $QSMAlertManager ), time() + 86400, COOKIEPATH, COOKIE_DOMAIN );
}
return $redirect_to;
}
Expand Down
46 changes: 33 additions & 13 deletions php/admin/settings-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ public function init() {
register_setting( 'qmn-settings-group', 'qmn-settings' );
add_settings_section( 'qmn-global-section', __( 'Main Settings', 'quiz-master-next' ), array( $this, 'global_section' ), 'qmn_global_settings' );
add_settings_field( 'usage-tracker', __( 'Allow Usage Tracking?', 'quiz-master-next' ), array( $this, 'usage_tracker_field' ), 'qmn_global_settings', 'qmn-global-section' );
add_settings_field( 'enable-qsm-log', __( 'Enable QSM log', 'quiz-master-next' ), array( $this, 'enable_qsm_log' ), 'qmn_global_settings', 'qmn-global-section' );
add_settings_field( 'ip-collection', __( 'Disable collecting and storing IP addresses?', 'quiz-master-next' ), array( $this, 'ip_collection_field' ), 'qmn_global_settings', 'qmn-global-section' );
add_settings_field( 'cpt-search', __( 'Disable Quiz Posts From Being Searched?', 'quiz-master-next' ), array( $this, 'cpt_search_field' ), 'qmn_global_settings', 'qmn-global-section' );
add_settings_field( 'cpt-archive', __( 'Disable Quiz Archive?', 'quiz-master-next' ), array( $this, 'cpt_archive_field' ), 'qmn_global_settings', 'qmn-global-section' );
add_settings_field( 'cpt-archive', __( 'Quiz Archive Settings', 'quiz-master-next' ), array( $this, 'cpt_archive_field' ), 'qmn_global_settings', 'qmn-global-section' );
add_settings_field( 'detele-qsm-data', __( 'Delete all the data related to QSM on deletion?', 'quiz-master-next' ), array( $this, 'qsm_delete_data' ), 'qmn_global_settings', 'qmn-global-section' );
add_settings_field( 'background-quiz-email-process', __( 'Process emails in background?', 'quiz-master-next' ), array( $this, 'qsm_background_quiz_email_process' ), 'qmn_global_settings', 'qmn-global-section' );
add_settings_field( 'cpt-slug', __( 'Quiz Url Slug', 'quiz-master-next' ), array( $this, 'cpt_slug_field' ), 'qmn_global_settings', 'qmn-global-section' );
Expand Down Expand Up @@ -375,18 +376,20 @@ public function cpt_search_field() {
*/
public function cpt_archive_field() {
$settings = (array) get_option( 'qmn-settings' );
$cpt_archive = '0';
if ( isset( $settings['cpt_archive'] ) ) {
$cpt_archive = esc_attr( $settings['cpt_archive'] );
}
$checked = '';
if ( '1' == $cpt_archive ) {
$checked = " checked='checked'";
}

echo '<label class="switch">';
echo '<input type="checkbox" name="qmn-settings[cpt_archive]" id="qmn-settings[cpt_archive]" value="1"' . esc_attr( $checked ) . '/>';
echo '<span class="slider round"></span></label>';
$cpt_archive = ! empty( $settings['cpt_archive'] ) ? esc_attr( $settings['cpt_archive'] ) : 0;
$cpt_link = ! empty( $settings['disable_quiz_public_link'] ) ? esc_attr( $settings['disable_quiz_public_link'] ) : 0;
?>
<fieldset>
<label for="qmn-settings-cpt_archive">
<input type="checkbox" name="qmn-settings[cpt_archive]" id="qmn-settings-cpt_archive" value="1" <?php checked( $cpt_archive, 1, true ); ?> />
<?php esc_html_e( 'Disable Quiz Archive', 'quiz-master-next'); ?>
</label><br/>
<label for="qmn-settings-qsm-quiz-public-link">
<input type="checkbox" name="qmn-settings[disable_quiz_public_link]" id="qmn-settings-qsm-quiz-public-link" value="1" <?php echo checked( $cpt_link, 1, true ); ?> />
<?php esc_html_e( 'Disable Quiz Public link', 'quiz-master-next'); ?>
</label>
</fieldset>
<?php
}

/**
Expand Down Expand Up @@ -485,6 +488,23 @@ public function usage_tracker_field() {
echo "<span class='global-sub-text' for='qmn-settings[tracking_allowed]'>" . esc_html__( "Allow Quiz And Survey Master to anonymously track this plugin's usage and help us make this plugin better.", 'quiz-master-next' ) . '</span>';
}

/**
* Generates Setting Field For QSM logs
*
* @since 8.1.9
* @return void
*/
public function enable_qsm_log() {
$settings = (array) get_option( 'qmn-settings' );
$enable_qsm_log = ! empty( $settings['enable_qsm_log'] ) ? esc_attr( $settings['enable_qsm_log'] ) : 0;
?>
<label class="switch">
<input type="checkbox" name="qmn-settings[enable_qsm_log]" id="qmn-settings[enable_qsm_log]" value="1"' <?php checked( $enable_qsm_log, 1, true ); ?>/><span class="slider round"></span>
</label>
<span class='global-sub-text' for='qmn-settings[enable_qsm_log]'><?php esc_html_e( "Enable this option to generate QSM error logs", 'quiz-master-next' );?></span>
<?php
}

/**
* Generates Setting Field For IP Collection
*
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 @@ -126,7 +126,7 @@ function qsm_audit_box() {
// Else, start at 0.
if ( isset( $_GET['audit_page'] ) ) {
$page = intval( $_GET['audit_page'] ) + 1;
$begin = $table_limit * $begin;
$begin = $table_limit;
} else {
$page = 0;
$begin = 0;
Expand Down
3 changes: 2 additions & 1 deletion php/classes/class-qmn-background-process.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ protected function handle() {
$this->really_long_running_task();
QSM_Emails::send_emails( $transient_id );
} catch ( Exception $e ) {
if ( defined('WP_DEBUG') && WP_DEBUG ) {
$settings = (array) get_option( 'qmn-settings' );
if ( ! empty( $settings['enable_qsm_log'] ) && $settings['enable_qsm_log'] ) {
trigger_error('Background email triggered fatal error for callback.', E_USER_WARNING); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
}
}
Expand Down
9 changes: 6 additions & 3 deletions php/classes/class-qmn-log-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ private function log_types() {
*/
public function register_post_type() {
/* logs post type */
$settings = (array) get_option( 'qmn-settings' );
$log_args = array(
'labels' => array( 'name' => 'QSM Logs' ),
'public' => defined( 'WP_DEBUG' ) && WP_DEBUG,
'public' => ! empty( $settings['enable_qsm_log'] ) && $settings['enable_qsm_log'],
'query_var' => false,
'rewrite' => false,
'capability_type' => 'post',
Expand All @@ -61,7 +62,8 @@ public function register_post_type() {
* @since 4.5.0
*/
public function register_taxonomy() {
register_taxonomy( 'qmn_log_type', 'qmn_log', array( 'public' => defined( 'WP_DEBUG' ) && WP_DEBUG ) );
$settings = (array) get_option( 'qmn-settings' );
register_taxonomy( 'qmn_log_type', 'qmn_log', array( 'public' => ! empty( $settings['enable_qsm_log'] ) && $settings['enable_qsm_log'] ) );
$types = $this->log_types();
foreach ( $types as $type ) {
if ( ! term_exists( $type, 'qmn_log_type' ) ) {
Expand Down Expand Up @@ -99,7 +101,8 @@ public function add( $title = '', $message = '', $parent = 0, $type = null ) {
'post_parent' => $parent,
'log_type' => $type,
);
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
$settings = (array) get_option( 'qmn-settings' );
if ( ! empty( $settings['enable_qsm_log'] ) && $settings['enable_qsm_log'] ) {
return $this->insert_log( $log_data );
}
return false;
Expand Down
Loading

0 comments on commit ef51b0f

Please sign in to comment.