Skip to content

Commit

Permalink
Merge pull request #2148 from QuizandSurveyMaster/dev
Browse files Browse the repository at this point in the history
Release 8.1.3
  • Loading branch information
etvarun authored Mar 29, 2023
2 parents ec3c169 + b0f28a9 commit 9872f4d
Show file tree
Hide file tree
Showing 17 changed files with 141 additions and 41 deletions.
3 changes: 1 addition & 2 deletions css/qsm-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -2526,7 +2526,6 @@ input#duplicate_questions {
top: 5px;
border-radius: 10px;
padding: 0 10px;
text-transform: uppercase;
}
.themes-container .market-theme:hover .market-theme-url {
opacity: 1;
Expand Down Expand Up @@ -3047,7 +3046,7 @@ input#duplicate_questions {
bottom: 35px;
left: 70%;
}
.contact-form-field .contact-form-actions,
.contact-form-field .contact-form-actions,
.contact-form-field .contact-form-switch {
margin-top: 5px;
}
Expand Down
5 changes: 4 additions & 1 deletion js/qsm-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ var QSMAdmin;
}
});
//Hide/show tr based on selection
$('.qsm_tab_content select').each(function () {
$('.qsm_tab_content .qsm-opt-tr select').each(function () {
var name = $(this).attr('name');
var value = $(this).val();
if ($('.' + name + '_' + value).length > 0) {
Expand Down Expand Up @@ -1299,6 +1299,9 @@ var QSMContact;
if ('email' == type) {
field.find('.contact-form-field-settings .email-option').show();
}
if ('radio' == type || 'select' == type) {
field.find('.contact-form-field-settings .field-options').show();
}
jQuery(document).trigger('qsm_contact_field_hide_show_settings', [field, type]);
}
};
Expand Down
13 changes: 10 additions & 3 deletions js/qsm-quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ function qmnValidation(element, quiz_form_id) {
var error_messages = qmn_quiz_data[quiz_id].error_messages;
qmnResetError(quiz_form_id);
jQuery(element).each(function () {
if ( jQuery(this).attr('class') && ( jQuery(this).is(':visible') || ( jQuery(this).attr('class').indexOf('mlwRequiredPolar') > -1 && jQuery(this).parent().is(':visible') ) ) ) {
if ( jQuery(this).attr('class') && ( jQuery(this).is(':visible') || jQuery(this).attr('class').indexOf('mlwRequiredAccept') || ( jQuery(this).attr('class').indexOf('mlwRequiredPolar') > -1 && jQuery(this).parent().is(':visible') ) ) ) {
if (jQuery(this).attr('class').indexOf('mlwEmail') !== -1 && this.value !== "") {
// Remove any trailing and preceeding space.
var x = jQuery.trim(this.value);
Expand Down Expand Up @@ -992,6 +992,11 @@ function qmnFormSubmit(quiz_form_id) {
jQuery(document).trigger('qsm_after_quiz_submit', [quiz_form_id]);
jQuery(".hide").parent().css('display', 'none');
}
},
error: function (errorThrown) {
let response = { display: errorThrown.responseText + "<br/> Error:" + errorThrown.statusText};
qmnDisplayResults(response, quiz_form_id, $container, quiz_id);
console.log(errorThrown);
}
});

Expand Down Expand Up @@ -1149,6 +1154,7 @@ function qmnNextSlide(pagination, go_to_top, quiz_form_id) {
if (page_number >= total_pages) {
alert('Next page not found.');
$container.find(".mlw_next").hide();
$container.find(".qsm-submit-btn").show();
jQuery(quiz_form_id + " .qsm-auto-page-row.quiz_end").show();
return true;
}
Expand All @@ -1158,6 +1164,7 @@ function qmnNextSlide(pagination, go_to_top, quiz_form_id) {
$container.find('.current_page_hidden').val('1');
} else if (total_pages == parseInt(page_number) + 1) { //Last page
$container.find(".mlw_next").hide();
$container.find(".qsm-submit-btn").show();
jQuery(quiz_form_id + " .qsm-auto-page-row.quiz_end").show();
$container.find('.slide_number_hidden').val(parseInt(slide_number) + 1);
$container.find('.current_page_hidden').val(parseInt(page_number) + 1);
Expand All @@ -1166,9 +1173,8 @@ function qmnNextSlide(pagination, go_to_top, quiz_form_id) {
} else if (slide_number >= 0 && page_number >= 1) {
if (total_pages == parseInt(page_number) + 2) { // if last page empty
if (jQuery(quiz_form_id + " .qsm-auto-page-row.empty_quiz_end").length) {
submit_button = jQuery(quiz_form_id + " .qsm-auto-page-row.empty_quiz_end").html();
jQuery(quiz_form_id + " .qsm-auto-page-row.empty_quiz_end").show();
jQuery(".qsm-quiz-container-" + quiz_id + " .qsm-submit-btn").show();
$container.find(".qsm-submit-btn").show();
$container.find(".mlw_next").hide();
$container.find('.g-recaptcha').show();
}
Expand Down Expand Up @@ -1444,6 +1450,7 @@ jQuery(function () {
event.preventDefault();
let quiz_id = +jQuery(this).closest('.qmn_quiz_container').find('.qmn_quiz_id').val();
let form_id = "quizForm"+quiz_id;
jQuery(document).trigger('qsm_quiz_submit_trigger', [quiz_id]);
let recaptcha = jQuery('#' + form_id).find("#qsm_grecaptcha_v3");
if (!recaptcha.length) {
qmnFormSubmit(form_id);
Expand Down
4 changes: 2 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.2
* Version: 8.1.3
* 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.2';
public $version = '8.1.3';

/**
* QSM Alert Manager Object
Expand Down
4 changes: 2 additions & 2 deletions php/admin/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ function qsm_get_default_wizard_themes() {
<div class="theme-wrapper theme market-theme">
<div class="theme-screenshot" id="qsm-theme-screenshot">
<?php if ( in_array( $theme_name, $pro_themes, true ) ) { ?>
<span class="qsm-badge"><?php esc_html_e( 'Pro', 'quiz-master-next' ); ?></span>
<span class="qsm-badge"><?php esc_html_e( 'Paid', 'quiz-master-next' ); ?></span>
<?php } ?>
<img alt="" src="<?php echo esc_url( $theme_screenshot ); ?>" />
<div class="market-theme-url">
Expand Down Expand Up @@ -1113,7 +1113,7 @@ function qsm_get_market_themes() {
<div class="theme-wrapper theme market-theme">
<div class="theme-screenshot" id="qsm-theme-screenshot">
<?php if ( in_array( $theme_name, $pro_themes, true ) ) { ?>
<span class="qsm-badge"><?php esc_html_e( 'Pro', 'quiz-master-next' ); ?></span>
<span class="qsm-badge"><?php esc_html_e( 'Paid', 'quiz-master-next' ); ?></span>
<?php } ?>
<img alt="" src="<?php echo esc_url( $theme_screenshot ); ?>" />
<div class="market-theme-url">
Expand Down
8 changes: 7 additions & 1 deletion php/admin/options-page-contact-tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,16 @@ function qsm_options_contact_tab_template() {
<option value="number" <# if (data.type == 'number') { #>selected<# } #> ><?php esc_html_e('Number', 'quiz-master-next');?></option>
<option value="date" <# if (data.type == 'date') { #>selected<# } #> ><?php esc_html_e('Date', 'quiz-master-next');?></option>
<option value="checkbox" <# if (data.type == 'checkbox') { #>selected<# } #> ><?php esc_html_e('Checkbox', 'quiz-master-next');?></option>
<option value="radio" <# if (data.type == 'radio') { #>selected<# } #> ><?php esc_html_e('Radio', 'quiz-master-next');?></option>
<option value="select" <# if (data.type == 'select') { #>selected<# } #> ><?php esc_html_e('Select', 'quiz-master-next');?></option>
<?php do_action('qsm_extra_contact_form_field_type'); ?>
</select>
</div>
<div class="contact-form-group contact-form-inputs">
<label class="contact-form-label"><?php esc_html_e('Label', 'quiz-master-next');?></label>
<input type="text" class="contact-form-control label-control" value="{{data.label}}">
<input type="hidden" class="use-control" value="{{data.use}}">
</div>
</div>
<div class="contact-form-group contact-form-actions">
<div class="qsm-actions-link-box contact-form-actions-box">
<a href="javascript:void(0)" class="settings-field" title="<?php esc_html_e('Settings', 'quiz-master-next');?>"><span class="dashicons dashicons-admin-generic"></span></a>
Expand All @@ -170,6 +172,10 @@ function qsm_options_contact_tab_template() {
<div class="contact-form-group required-option">
<label class="contact-form-label"><input type="checkbox" name="required" class="required-control" <# if ( "true" == data.required || true == data.required ) { #>checked<# } #> ><span><?php esc_html_e('Required?', 'quiz-master-next');?></span></label>
</div>
<div class="contact-form-group field-options">
<label class="contact-form-label"><?php esc_html_e('Options', 'quiz-master-next');?></label>
<textarea title="<?php esc_html_e('Use comma seperated values.', 'quiz-master-next');?>" class="contact-form-control" placeholder="<?php esc_html_e('Option-1, Option-2, Option-3', 'quiz-master-next');?>" name="options" cols="30" rows="5">{{data.options}}</textarea>
</div>
<div class="contact-form-group min-max-option">
<label class="contact-form-label"><?php esc_html_e('Min Length', 'quiz-master-next');?></label>
<input type="number" class="contact-form-control" name="minlength" value="{{data.minlength}}">
Expand Down
22 changes: 14 additions & 8 deletions php/classes/class-qmn-quiz-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -715,10 +715,10 @@ public function load_questions( $quiz_id, $quiz_options, $is_quiz_page, $questio
</script>
<?php
}
$order_by_sql = 'ORDER BY FIELD(question_id,'.$question_sql.')';
$order_by_sql = 'ORDER BY FIELD(question_id,'. esc_sql( $question_sql ) .')';
}

$query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}mlw_questions WHERE question_id IN (%1s) %2s %3s %4s", $question_sql, $cat_query, $order_by_sql, $limit_sql );
$query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}mlw_questions WHERE question_id IN (%1s) %2s %3s %4s", esc_sql( $question_sql ), $cat_query, $order_by_sql, $limit_sql );
$questions = $wpdb->get_results( stripslashes( $query ) );

// If we are not using randomization, we need to put the questions in the order of the new question editor.
Expand Down Expand Up @@ -1395,7 +1395,9 @@ public function display_end_section( $qmn_quiz_options, $qmn_array_for_variables
echo QSM_Contact_Manager::display_fields( $qmn_quiz_options );
}
?>
<input type='submit' class='qsm-btn qsm-submit-btn qmn_btn' value="<?php echo esc_attr( $mlwQuizMasterNext->pluginHelper->qsm_language_support( $qmn_quiz_options->submit_button_text, "quiz_submit_button_text-{$qmn_quiz_options->quiz_id}" ) ); ?>" />
<?php if ( 0 === intval( $pagination_option ) ) : ?>
<input type='submit' class='qsm-btn qsm-submit-btn qmn_btn' value="<?php echo esc_attr( $mlwQuizMasterNext->pluginHelper->qsm_language_support( $qmn_quiz_options->submit_button_text, "quiz_submit_button_text-{$qmn_quiz_options->quiz_id}" ) ); ?>" />
<?php endif; ?>
</div>
<?php
} else {
Expand Down Expand Up @@ -1521,7 +1523,7 @@ public function qsm_get_quiz_to_reload() {
* @return string The content for the results page section
*/
public function submit_results( $qmn_quiz_options, $qmn_array_for_variables ) {
global $wpdb, $qmn_allowed_visit;
global $wpdb, $qmn_allowed_visit, $mlwQuizMasterNext;
$result_display = '';
do_action( 'qsm_submit_results_before', $qmn_quiz_options, $qmn_array_for_variables );
$qmn_array_for_variables['user_ip'] = $this->get_user_ip();
Expand Down Expand Up @@ -1626,6 +1628,9 @@ public function submit_results( $qmn_quiz_options, $qmn_array_for_variables ) {
),
array( 'result_id' => $results_id )
);
if ( false === $results_update ) {
$mlwQuizMasterNext->log_manager->add( 'Error 0001', $wpdb->last_error . ' from ' . $wpdb->last_query, 0, 'error' );
}
} else {
$http_referer = isset( $_SERVER['HTTP_REFERER'] ) ? esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '';
$results_insert = $wpdb->insert(
Expand Down Expand Up @@ -1678,14 +1683,16 @@ public function submit_results( $qmn_quiz_options, $qmn_array_for_variables ) {
)
);
$results_id = $wpdb->insert_id;
if ( false === $results_insert ) {
$mlwQuizMasterNext->log_manager->add( 'Error 0001', $wpdb->last_error . ' from ' . $wpdb->last_query, 0, 'error' );
}
}
}
$qmn_array_for_variables['response_saved'] = isset( $results_insert ) ? $results_insert : false;
$qmn_array_for_variables['result_id'] = $results_id;
$qmn_array_for_variables['result_unique_id'] = $unique_id;
setcookie("question_ids_".$qmn_array_for_variables['quiz_id'], "", time() - 36000, "/");
// Converts date to the preferred format
global $mlwQuizMasterNext;
$qmn_array_for_variables = $mlwQuizMasterNext->pluginHelper->convert_to_preferred_date_format( $qmn_array_for_variables );

// Determines redirect/results page.
Expand Down Expand Up @@ -2448,7 +2455,7 @@ public function send_admin_email( $qmn_quiz_options, $qmn_array_for_variables )
* @since 5.3.0
* @return string The IP address or a phrase if not collected
*/
private function get_user_ip() {
public function get_user_ip() {
$ip = __( 'Not collected', 'quiz-master-next' );
$settings = (array) get_option( 'qmn-settings' );
$ip_collection = '0';
Expand Down Expand Up @@ -2678,15 +2685,14 @@ function qmn_pagination_check( $display, $qmn_quiz_options, $qmn_array_for_varia
if ( isset($qmn_quiz_options->start_quiz_survey_text) && "" != $qmn_quiz_options->start_quiz_survey_text ) {
$quiz_btn_display_text = $qmn_quiz_options->start_quiz_survey_text; // For old quizes set default here
}

$qmn_json_data['pagination'] = array(
'amount' => $qmn_quiz_options->pagination,
'section_comments' => $qmn_quiz_options->comment_section,
'total_questions' => $total_questions,
'previous_text' => $mlwQuizMasterNext->pluginHelper->qsm_language_support( $qmn_quiz_options->previous_button_text, "quiz_previous_button_text-{$qmn_quiz_options->quiz_id}" ),
'next_text' => $mlwQuizMasterNext->pluginHelper->qsm_language_support( $qmn_quiz_options->next_button_text, "quiz_next_button_text-{$qmn_quiz_options->quiz_id}" ),
'start_quiz_survey_text' => $mlwQuizMasterNext->pluginHelper->qsm_language_support( $quiz_btn_display_text, "quiz_next_button_text-{$qmn_quiz_options->quiz_id}" ),
'submit_quiz_text' => $mlwQuizMasterNext->pluginHelper->qsm_language_support( $quiz_btn_submit_text, "quiz_submit_button_text-{$qmn_quiz_options->quiz_id}" ),
'submit_quiz_text' => $mlwQuizMasterNext->pluginHelper->qsm_language_support($qmn_quiz_options->submit_button_text, "quiz_submit_button_text-{$qmn_quiz_options->quiz_id}" ),
);
}
return $display;
Expand Down
84 changes: 78 additions & 6 deletions php/classes/class-qsm-contact-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public static function display_fields( $options ) {
}
if ( 'email' === $fields[ $i ]['use'] ) {
$value = $email;
}
}
self::generate_contact_field($fields[ $i ], $i, $options, $value);
?>
</div>
Expand Down Expand Up @@ -379,10 +379,16 @@ public static function generate_contact_field( $field, $index, $quiz_options, $d
$fieldAttr = " name='contact_field_" . esc_attr( $index ) . "' id='contact_field_" . esc_attr( $index ) . "' ";
$class = '';
if ( ( 'true' === $field["required"] || true === $field["required"] ) && ! $fields_hidden ) {
$class .= 'mlwRequiredText qsm_required_text';
if ( 'checkbox' === $field["type"] ) {
$class .= ' mlwRequiredAccept';
}
if ( 'radio' === $field["type"] ) {
$class .= ' mlwRequiredRadiomlwRequiredRadio ';
}elseif ( 'select' === $field["type"] ) {
$class .= 'qsmRequiredSelect';
}else {
$class .= 'mlwRequiredText qsm_required_text';
if ( 'checkbox' === $field["type"] ) {
$class .= ' mlwRequiredAccept';
}
}
}
switch ( $field['type'] ) {
case 'text':
Expand Down Expand Up @@ -424,7 +430,6 @@ public static function generate_contact_field( $field, $index, $quiz_options, $d
<input type='text' class='<?php echo esc_attr( $class ); ?>' <?php echo $fieldAttr; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> />
<?php
break;

case 'email':
// Filer Value
if ( empty( $contact_disable_autofill ) ) {
Expand Down Expand Up @@ -512,6 +517,73 @@ public static function generate_contact_field( $field, $index, $quiz_options, $d
<input type='number' class='mlwRequiredNumber <?php echo esc_attr( $class ); ?>' <?php echo $fieldAttr; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> <?php if ( isset( $field['maxlength'] ) && 0 < intval( $field['maxlength'] ) ) : ?>maxlength='<?php echo intval( $field['maxlength'] ); ?>' oninput='maxLengthCheck(this)' <?php endif; ?> />
<?php
break;

case 'radio':
// Filer Value
if ( empty( $contact_disable_autofill ) ) {
$default_value = apply_filters( 'qsm_contact_radio_field_value', $default_value, $field['use'] );
$fieldAttr .= " value='" . esc_attr( $default_value ) . "' ";
} else {
$fieldAttr .= " autocomplete='off' ";
}
/**
* Add options validation
*/
if ( isset( $field['options'] ) ) {
?>
<span class='mlw_qmn_question qsm_question'><?php echo esc_attr( $field_label ); ?></span>
<div class='qmn_radio_answers <?php echo esc_attr( $class ); ?>'>
<?php
$option_values = explode(",", $field['options']);
for ( $i = 0; $i < count($option_values); $i++ ) {
?>
<div class='qmn_mc_answer_wrap'>
<input
type='radio'
class='qmn_quiz_radio'
name='contact_field_<?php echo esc_attr( $index ); ?>'
value='<?php echo esc_attr( $option_values[ $i ] ); ?>'
/>
<label class='qsm_input_label' for='<?php echo esc_attr( $field_label ); ?>'>
<?php echo esc_html( trim($option_values[ $i ]) ); ?>
</label>
</div>
<?php
}
}
echo '</div>';
break;
case 'select':
// Filer Value
if ( empty( $contact_disable_autofill ) ) {
$default_value = apply_filters( 'qsm_contact_select_field_value', $default_value, $field['use'] );
$fieldAttr .= " value='" . esc_attr( $default_value ) . "' ";
} else {
$fieldAttr .= " autocomplete='off' ";
}
// If REQUIRED is set then assigning the required class
if ( isset( $field['options'] ) ) {
?>
<span class='mlw_qmn_question qsm_question'><?php echo esc_attr( $field_label ); ?></span>
<select class='<?php echo esc_attr( $class ); ?>' name='contact_field_<?php echo esc_attr( $index ); ?>' id='contact_field_<?php echo esc_attr( $index ); ?>'>
<option value=''>
<?php echo esc_html( __('Choose ', 'quiz-master-next').$field_label ); ?>
</option>
<?php
$option_values = explode( ",", $field['options'] );
// Iterating over comma separeted values to populate option tag
for ( $i = 0; $i < count($option_values); $i++ ) {
?>
<option value='<?php echo esc_attr( trim($option_values[ $i ]) ); ?>'>
<?php echo esc_html( trim($option_values[ $i ]) ); ?>
</option>
<?php
}
}
?>
</select>
<?php
break;
default:
do_action( 'qsm_extra_contact_form_field_display', $field, $quiz_options, $index,$default_value );
break;
Expand Down
8 changes: 7 additions & 1 deletion php/classes/class-qsm-emails.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public static function send_emails( $transient_id ) {
*/
public static function send_results_email( $response_data, $to, $subject, $content, $reply_to ) {

do_action( 'qsm_start_sending_email', $response_data, $to, $subject );
global $mlwQuizMasterNext;
global $qmn_total_questions;
$qmn_total_questions = 0;
Expand Down Expand Up @@ -239,7 +240,12 @@ public static function send_results_email( $response_data, $to, $subject, $conte
// Cycle through each to email address and send the email.
foreach ( $to_array as $to_email ) {
if ( is_email( $to_email ) ) {
wp_mail( $to_email, $subject, $content, $headers, $attachments );
$mailResult = wp_mail( $to_email, $subject, $content, $headers, $attachments );
if ( $mailResult ) {
do_action( 'qsm_after_sending_email', $response_data, $to_email, $subject );
}else {
$mlwQuizMasterNext->log_manager->add( 'There has been an error in wp_mail. Please check SMTP details mail not sending. Error Code: 0001', 0, 'error' );
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions php/template-variables.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ function qsm_variable_result_id( $content, $mlw_quiz_array ) {
}

function mlw_qmn_variable_point_score( $content, $mlw_quiz_array ) {
global $mlwQuizMasterNext;
$score_roundoff = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_options', 'score_roundoff' );
if ( $score_roundoff && isset( $mlw_quiz_array['total_points'] ) ) {
$mlw_quiz_array['total_points'] = round( $mlw_quiz_array['total_points'] );
}
$content = str_replace( '%POINT_SCORE%', ( isset( $mlw_quiz_array['total_points'] ) ? $mlw_quiz_array['total_points'] : '' ), $content );
return $content;
}
Expand Down
Loading

0 comments on commit 9872f4d

Please sign in to comment.