Skip to content

Commit

Permalink
Merge pull request #1717 from QuizandSurveyMaster/dev
Browse files Browse the repository at this point in the history
Release 7.3.9
  • Loading branch information
etvarun authored Jan 20, 2022
2 parents 2f5b659 + 0651ecd commit 782444d
Show file tree
Hide file tree
Showing 14 changed files with 311 additions and 173 deletions.
5 changes: 5 additions & 0 deletions js/qsm-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2215,6 +2215,11 @@ if (jQuery('body').hasClass('admin_page_mlw_quiz_options')){
},
question_type_change: function (previous_question_val, questionID) {
//you can override this object
var ans_type = $('#change-answer-editor').val();
if (2 == questionID && 'text' !== ans_type){
$('#change-answer-editor').val('text');
$('.answers-single').remove();
}
}
};

Expand Down
23 changes: 20 additions & 3 deletions mlw_quizmaster2.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
/**
* Plugin Name: Quiz And Survey Master
* Description: Easily and quickly add quizzes and surveys to your website.
* Version: 7.3.8
* Version: 7.3.9
* Author: ExpressTech
* Author URI: https://quizandsurveymaster.com/
* Plugin URI: https://expresstech.io/
* Text Domain: quiz-master-next
*
* @author QSM Team
* @version 7.3.8
* @version 7.3.9
* @package QSM
*/

Expand Down Expand Up @@ -44,7 +44,7 @@ class MLWQuizMasterNext {
* @var string
* @since 4.0.0
*/
public $version = '7.3.8';
public $version = '7.3.9';

/**
* QSM Alert Manager Object
Expand Down Expand Up @@ -118,6 +118,19 @@ class MLWQuizMasterNext {
*/
public $quiz = array();

/*
* Default MathJax inline scripts.
*/
public static $default_MathJax_script = "MathJax = {
tex: {
inlineMath: [['$','$'],['\\\\(','\\\\)']],
processEscapes: true
},
options: {
ignoreHtmlClass: 'tex2jax_ignore|editor-rich-text'
}
};";

/**
* Main Construct Function
*
Expand Down Expand Up @@ -282,6 +295,7 @@ public function qsm_admin_scripts_style( $hook ) {
wp_enqueue_style( 'qsm_common_style', QSM_PLUGIN_CSS_URL . '/common.css', array(), $this->version );
wp_style_add_data( 'qsm_common_style', 'rtl', 'replace' );
wp_enqueue_script( 'math_jax', QSM_PLUGIN_JS_URL . '/mathjax/tex-mml-chtml.js', false, '3.2.0', true );
wp_add_inline_script( 'math_jax', self::$default_MathJax_script, 'before' );
wp_enqueue_script( 'jquery-ui-slider' );
wp_enqueue_script( 'jquery-ui-slider-rtl-js', QSM_PLUGIN_JS_URL . '/jquery.ui.slider-rtl.js', array( 'jquery-ui-core', 'jquery-ui-mouse', 'jquery-ui-slider' ), $this->version, true );
wp_enqueue_style( 'jquery-ui-slider-rtl-css', QSM_PLUGIN_CSS_URL . '/jquery.ui.slider-rtl.css', array(), $this->version );
Expand Down Expand Up @@ -313,6 +327,7 @@ public function qsm_admin_scripts_style( $hook ) {
case 'emails':
case 'results-pages':
wp_enqueue_script( 'math_jax', QSM_PLUGIN_JS_URL . '/mathjax/tex-mml-chtml.js', false, '3.2.0', true );
wp_add_inline_script( 'math_jax', self::$default_MathJax_script, 'before' );
wp_enqueue_editor();
wp_enqueue_media();
break;
Expand All @@ -332,11 +347,13 @@ public function qsm_admin_scripts_style( $hook ) {
wp_enqueue_script( 'jquery-effects-blind' );
wp_enqueue_script( 'jquery-effects-explode' );
wp_enqueue_script( 'math_jax', QSM_PLUGIN_JS_URL . '/mathjax/tex-mml-chtml.js', false, '3.2.0', true );
wp_add_inline_script( 'math_jax', self::$default_MathJax_script, 'before' );
break;
default:
wp_enqueue_style( 'qsm_admin_question_css', QSM_PLUGIN_CSS_URL . '/qsm-admin-question.css', array(), $this->version );
wp_style_add_data( 'qsm_admin_question_css', 'rtl', 'replace' );
wp_enqueue_script( 'math_jax', QSM_PLUGIN_JS_URL . '/mathjax/tex-mml-chtml.js', false, '3.2.0', true );
wp_add_inline_script( 'math_jax', self::$default_MathJax_script, 'before' );
wp_enqueue_editor();
wp_enqueue_media();
break;
Expand Down
14 changes: 2 additions & 12 deletions php/admin/options-page-questions-tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ class="question-type-description"><?php echo esc_attr( $value['description'] );
}
?>
</div>
<div id="qsm_optoins_wrapper" class="qsm-row qsm_hide_for_other qsm_show_question_type_0 qsm_show_question_type_1 qsm_show_question_type_2 qsm_show_question_type_3 qsm_show_question_type_4 qsm_show_question_type_5 qsm_show_question_type_7 qsm_show_question_type_10 qsm_show_question_type_12 qsm_show_question_type_14 <?php echo esc_attr( $polar_class . $show_answer_option ); ?>">
<div id="qsm_optoins_wrapper" class="qsm-row qsm_hide_for_other qsm_show_question_type_0 qsm_show_question_type_1 qsm_show_question_type_2 qsm_show_question_type_3 qsm_show_question_type_4 qsm_show_question_type_5 qsm_show_question_type_7 qsm_show_question_type_10 qsm_show_question_type_12 qsm_show_question_type_14 <?php echo apply_filters('qsm_polar_class',esc_attr( $polar_class . $show_answer_option )); ?>">
<label class="answer-header">
<?php esc_html_e( 'Answers', 'quiz-master-next' ); ?>
<a class="qsm-question-doc" rel="noopener"
Expand All @@ -317,6 +317,7 @@ class="question-type-description"><?php echo esc_attr( $value['description'] );
class="dashicons dashicons-plus"></span>
<?php esc_html_e( 'Add New Answer!', 'quiz-master-next' ); ?></a>
</div>
<?php do_action('qsm_after_options'); ?>
</div>
<hr style="margin-bottom:25px;">
<a href="#" class="qsm-show-correct-info-box button button-default"><span
Expand Down Expand Up @@ -437,17 +438,6 @@ class="dashicons dashicons-plus-alt2"></span>
'default' => 'random',
'show' => '14' . $show_match_answer,
),
'text-answer-editor' => array(
'label' => __( 'Answers Type', 'quiz-master-next' ),
'type' => 'select',
'priority' => '4',
'options' => array(
'text' => __( 'Text Answers', 'quiz-master-next' ),
),
'default' => 'text',
'show' => '2' . $show_change_answer_editor,
'documentation_link' => 'https://quizandsurveymaster.com/docs/v7/questions-tab/#Answer-Type',
),
);
$simple_question_option = apply_filters( 'qsm_question_format_option', $simple_question_option );
$keys = array_column( $simple_question_option, 'priority' );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?php

function qsm_bckcmp_tempvar_qa_text_qt_multi_choice_correct( $answers_from_db, $answers_from_response, $question_settings ) {
$question_with_answer_text = '';
$new_array_user_answer = isset($answers_from_response['user_compare_text']) ? explode('=====', $answers_from_response['user_compare_text']) : array();
foreach ( $answers_from_db as $single_answer ) {
$current_answer_text = trim(stripslashes(htmlspecialchars_decode($single_answer[0], ENT_QUOTES)));
$is_answer_correct = false;
if ( $new_array_user_answer ) {
foreach ( $new_array_user_answer as $new_array_value ) {
$new_array_value = trim(stripslashes(htmlspecialchars_decode($new_array_value, ENT_QUOTES)));
if ( $current_answer_text == $new_array_value ) {
$is_answer_correct = true;
break;
}
}
}
$image_class = '';
if ( isset($question_settings['answerEditor']) && 'image' == $question_settings['answerEditor'] ) {
$show_user_answer = '<img src="' . htmlspecialchars_decode($single_answer[0], ENT_QUOTES) . '"/>';
$image_class = 'qmn_image_option';
} else {
$show_user_answer = htmlspecialchars_decode($single_answer[0], ENT_QUOTES);
$image_class = '';
}
if ( isset($single_answer[2]) && 1 == $single_answer[2] && $is_answer_correct ) {
$question_with_answer_text .= '<span class="qsm-text-correct-option qsm-text-user-correct-answers_from_response ' . $image_class . '">' . $show_user_answer . '</span>';
} elseif ( isset($single_answer[2]) && 1 === $single_answer[2] ) {
$question_with_answer_text .= '<span class="qsm-text-correct-option ' . $image_class . '">' . $show_user_answer . '</span>';
} elseif ( $is_answer_correct && 1 !== $single_answer[2] ) {
$question_with_answer_text .= '<span class="qsm-text-wrong-option ' . $image_class . '">' . $show_user_answer . '</span>';
} else {
$question_with_answer_text .= '<span class="qsm-text-simple-option ' . $image_class . '">' . $show_user_answer . '</span>';
}
}

return $question_with_answer_text;
}

function qsm_bckcmp_tempvar_qa_text_qt_single_choice_correct( $answers_from_db, $answers_from_response, $question_settings ) {
$question_with_answer_text = '';
foreach ( $answers_from_db as $single_answer ) {
$single_answer_option = $single_answer[0];
if ( isset($question_settings['answerEditor']) && 'rich' == $question_settings['answerEditor'] ) {
$single_answer_option = htmlspecialchars_decode($single_answer[0], ENT_QUOTES);
$single_answer_option = htmlentities($single_answer_option);
if ( strpos($single_answer_option, '&lt;') !== false || strpos($single_answer_option, '&quot;') !== false ) {
$single_answer_option = htmlspecialchars($single_answer_option);
}
if ( strpos($answers_from_response[1], '&lt;') !== false || strpos($answers_from_response[1], '&quot;') !== false ) {
$answer_value = htmlentities($answers_from_response[1]);
} else {
$answer_value = htmlspecialchars_decode($answers_from_response[1], ENT_QUOTES);
$answer_value = htmlspecialchars_decode($answer_value, ENT_QUOTES);
$answer_value = htmlentities($answer_value);
$answer_value = htmlspecialchars($answer_value);
}
} else {
$answer_value = htmlspecialchars_decode($answers_from_response[1], ENT_QUOTES);
}
$image_class = '';
if ( isset($question_settings['answerEditor']) && 'image' == $question_settings['answerEditor'] ) {
$show_user_answer = '<img src="' . htmlspecialchars_decode($single_answer[0], ENT_QUOTES) . '"/>';
$image_class = 'qmn_image_option';
} else {
$show_user_answer = htmlspecialchars_decode($single_answer[0], ENT_QUOTES);
$image_class = '';
}
if ( isset($single_answer[2]) && 1 == $single_answer[2] && $answer_value == $single_answer_option ) {
$question_with_answer_text .= '<span class="qsm-text-correct-option qsm-text-user-correct-answer ' . $image_class . '">' . $show_user_answer . '</span>';
} elseif ( isset($single_answer[2]) && 1 == $single_answer[2] ) {
$question_with_answer_text .= '<span class="qsm-text-correct-option ' . $image_class . '">' . $show_user_answer . '</span>';
} elseif ( $answer_value == $single_answer_option && 1 !== $single_answer[2] ) {
$question_with_answer_text .= '<span class="qsm-text-wrong-option ' . $image_class . '">' . $show_user_answer . '</span>';
} else {
$question_with_answer_text .= '<span class="qsm-text-simple-option ' . $image_class . '">' . $show_user_answer . '</span>';
}
}
return $question_with_answer_text;
}

function qsm_bckcmp_tempvar_qa_text_qt_multi_choice_points( $answers_from_db, $answers_from_response, $question_settings ) {
$question_with_answer_text = '';
$user_selected_answer = htmlspecialchars_decode($answers_from_response[1], ENT_QUOTES);
foreach ( $answers_from_db as $single_answer ) {
$image_class = '';
if ( isset($question_settings['answerEditor']) && 'image' == $question_settings['answerEditor'] ) {
$show_user_answer = '<img src="' . htmlspecialchars_decode($single_answer[0], ENT_QUOTES) . '"/>';
$image_class = 'qmn_image_option';
} else {
$show_user_answer = htmlspecialchars_decode($single_answer[0], ENT_QUOTES);
$image_class = '';
}
if ( strpos($user_selected_answer, $single_answer[0]) !== false ) {
$question_with_answer_text .= '<span class="qsm-text-correct-option ' . $image_class . '">' . $show_user_answer . '</span>';
} else {
$question_with_answer_text .= '<span class="qsm-text-simple-option ' . $image_class . '">' . $show_user_answer . '</span>';
}
}
return $question_with_answer_text;
}

function qsm_bckcmp_tempvar_qa_text_qt_single_choice_points( $answers_from_db, $answers_from_response, $question_settings ) {
$question_with_answer_text = '';
foreach ( $answers_from_db as $single_answer ) {
$image_class = '';
if ( isset($question_settings['answerEditor']) && 'image' == $question_settings['answerEditor'] ) {
$show_user_answer = '<img src="' . htmlspecialchars_decode($single_answer[0], ENT_QUOTES) . '"/>';
$image_class = 'qmn_image_option';
} else {
$show_user_answer = htmlspecialchars_decode($single_answer[0], ENT_QUOTES);
$image_class = '';
}
if ( htmlspecialchars_decode($answers_from_response[1], ENT_QUOTES) == $single_answer[0] ) {
$question_with_answer_text .= '<span class="qsm-text-correct-option ' . $image_class . '">' . $show_user_answer . '</span>';
} else {
$question_with_answer_text .= '<span class="qsm-text-simple-option ' . $image_class . '">' . $show_user_answer . '</span>';
}
}
return $question_with_answer_text;
}
14 changes: 5 additions & 9 deletions php/classes/class-qmn-plugin-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -839,10 +839,6 @@ public function qsm_results_css_inliner( $html ) {
$simple_answer = "<span style='color:#808080;display:block;margin-bottom:5px;'>&#8226;&nbsp;";
$html = str_replace( '<br/>', '<br>', $html );
$html = str_replace( '<br />', '<br>', $html );
$html = str_replace( '<span class="qmn_user_incorrect_answer">', "<span style='color:red'>&#x2715; ", $html );
$html = str_replace( "<span class='qmn_user_incorrect_answer'>", "<span style='color:red'>&#x2715; ", $html );
$html = str_replace( '<span class="qmn_user_correct_answer">', "<span style='color:green'>&#10003; ", $html );
$html = str_replace( "<span class='qmn_user_correct_answer'>", "<span style='color:green'>&#10003; ", $html );
$html = str_replace( '<span class="qsm-text-wrong-option qmn_image_option">', "$incorrect_answer ", $html );
$html = str_replace( '<span class="qsm-text-correct-option qmn_image_option">', "$correct_answer ", $html );
$html = str_replace( '<span class="qsm-text-correct-option qsm-text-user-correct-answer qmn_image_option">', "$correct_answer ", $html );
Expand All @@ -852,7 +848,7 @@ public function qsm_results_css_inliner( $html ) {
$html = str_replace( '<span class="qsm-text-wrong-option ">', "$incorrect_answer ", $html );
$html = str_replace( '<span class="qsm-text-correct-option ">', "$correct_answer ", $html );
$html = str_replace( '<span class="qmn_user_incorrect_answer">', "$incorrect_answer ", $html );
$html = str_replace( '<span class="qmn_user_incorrect_answer">', "$correct_answer ", $html );
$html = str_replace( '<span class="qmn_user_correct_answer qsm-text-correct-option qsm-text-user-correct-answer">', "$correct_answer ", $html );
$html = str_replace( "class='qmn_question_answer", "style='margin-bottom:30px' class='", $html );

return $html;
Expand All @@ -869,18 +865,18 @@ public function categorize_question_types() {
if ( 'others' === mb_strtolower( $question_type ['category'] ) ) {
$question_type_others[ $question_type ['category'] ] [ $question_type['slug'] ] = array(
'slug' => $question_type['slug'],
'name' => $question_type['name'],
'name' => $question_type['name'],
);
} else {
$question_type_categorized[ $question_type ['category'] ] [ $question_type['slug'] ] = array(
'slug' => $question_type['slug'],
'name' => $question_type['name'],
'name' => $question_type['name'],
);
}
}
} else {
$question_type_uncategorized['uncategorized'][ $question_type['slug'] ] = array(
'slug' => $question_type['slug'],
'name' => $question_type['name'],
'name' => $question_type['name'],
);

}
Expand Down
Loading

0 comments on commit 782444d

Please sign in to comment.