diff --git a/css/jquery.multiselect.min.css b/css/jquery.multiselect.min.css
new file mode 100644
index 000000000..50c8479c6
--- /dev/null
+++ b/css/jquery.multiselect.min.css
@@ -0,0 +1 @@
+.ms-options-wrap,.ms-options-wrap *{box-sizing:border-box}.ms-options-wrap>button,.ms-options-wrap>button:focus{position:relative;width:100%;text-align:left;border:1px solid #ddd;background-color:#fff;margin-top:1px;font-size:13px;color:#2c3338;outline:0;white-space:nowrap;line-height:2;border-radius:3px;max-width:25rem;cursor:pointer;padding:3px 6px}.ms-options-wrap>button:after{content:" ";height:0;position:absolute;top:50%;right:5px;width:0;border:6px solid transparent;border-top-color:#999;margin-top:-3px}.ms-options-wrap>.ms-options{position:absolute;left:0;width:25rem;margin-top:1px;margin-bottom:20px;background:#fff;z-index:2000;border:1px solid #aaa;text-align:left}.ms-options-wrap>.ms-options>.ms-search input{width:calc(100% - 5px);padding:2px 5px;border:1px solid;outline:0;margin:3px}.ms-options ul{margin:5px 0}.ms-options-wrap>.ms-options .ms-selectall{display:inline-block;font-size:.9em;text-decoration:none}.ms-options-wrap>.ms-options .ms-selectall:hover{text-decoration:underline}.ms-options-wrap>.ms-options>.ms-selectall.global{margin:4px 5px}.ms-options-wrap>.ms-options>ul>li.optgroup{padding:5px}.ms-options-wrap>.ms-options>ul>li.optgroup+li.optgroup{border-top:1px solid #aaa}.ms-options-wrap>.ms-options>ul>li.optgroup .label{display:block;padding:5px 0 0 0;font-weight:700}.ms-options-wrap>.ms-options>ul label{position:relative;display:inline-block;width:100%;padding:2px 4px;margin:1px 0}.ms-options-wrap>.ms-options>ul label:hover,.ms-options-wrap>.ms-options>ul li.selected label{background-color:#efefef}.ms-options-wrap>.ms-options>ul input[type="checkbox"]{margin-right:5px;position:absolute;left:4px;top:7px}
\ No newline at end of file
diff --git a/js/jquery.multiselect.min.js b/js/jquery.multiselect.min.js
new file mode 100644
index 000000000..89497eb6f
--- /dev/null
+++ b/js/jquery.multiselect.min.js
@@ -0,0 +1 @@
+!function(t){var e={placeholder:"Select options",columns:1,search:!1,searchOptions:{default:"Search",showOptGroups:!1,onSearch:function(t){}},selectAll:!1,selectGroup:!1,minHeight:200,maxHeight:null,showCheckbox:!0,jqActualOpts:{},onLoad:function(e){t(e).hide()},onOptionClick:function(t,e){},maxWidth:null,minSelect:!1,maxSelect:!1},i=1;function o(i,o){this.element=i,this.options=t.extend({},e,o),this.load()}o.prototype={load:function(){var e=this;if("SELECT"!=e.element.nodeName||t(e.element).hasClass("jqmsLoaded"))return!0;t(e.element).addClass("jqmsLoaded"),t(e.element).after('
');var i=t(e.element).next(".ms-options-wrap").find("> button:first-child"),o=t(e.element).next(".ms-options-wrap").find("> .ms-options"),s=o.find("> ul"),n=!!t(e.element).find("optgroup").length,l=null;"number"==typeof e.options.width?(o.parent().css("position","relative"),l=e.options.width):"string"==typeof e.options.width?(t(e.options.width).css("position","relative"),l="100%"):o.parent().css("position","relative");var a=t(window).height()-o.offset().top-20;if(e.options.maxHeight&&(a=(a=t(window).height()-o.offset().top-20)t(this)[0].scrollHeight&&(e.preventDefault(),this.scrollTop+=o<0?1:-1)}}),t(document).off("click.ms-hideopts").on("click.ms-hideopts",function(e){t(e.target).closest(".ms-options-wrap").length||t(".ms-options-wrap > .ms-options:visible").hide()}),i.bind("mousedown",function(i){if(1!=i.which)return!0;if(t(".ms-options-wrap > .ms-options:visible").each(function(){t(this).parent().prev()[0]!=o.parent().prev()[0]&&t(this).hide()}),o.toggle(),o.is(":visible")){o.css("maxHeight","");var s=t(window).height()-o.offset().top-20;e.options.maxHeight&&(s=(s=t(window).height()-o.offset().top-20)');var p=o.find(".ms-search input");p.on("keyup",function(){if(t(this).data("lastsearch")==t(this).val())return!0;t(this).data("lastsearch",t(this).val()),"function"==typeof e.options.searchOptions.onSearch&&e.options.searchOptions.onSearch(e.element),s.find("li:not(.optgroup)").each(function(){t(this).text().toLowerCase().indexOf(p.val().toLowerCase())>-1?t(this).show():t(this).hasClass("selected")||t(this).hide(),!e.options.searchOptions.showOptGroups&&t(this).closest("li.optgroup")&&(t(this).closest("li.optgroup").show(),t(this).closest("li.optgroup").find("li:visible").length?t(this).closest("li.optgroup").show():t(this).closest("li.optgroup").hide())})})}e.options.selectAll&&s.before('Select all'),o.on("click",".ms-selectall",function(e){if(e.preventDefault(),t(this).hasClass("global"))s.find("li:not(.optgroup)").filter(":not(.selected)").length?s.find("li:not(.optgroup)").filter(":not(.selected)").find('input[type="checkbox"]').trigger("click"):s.find('li:not(.optgroup).selected input[type="checkbox"]').trigger("click");else if(t(this).closest("li").hasClass("optgroup")){var i=t(this).closest("li.optgroup");i.find("li:not(.selected)").length?i.find('li:not(.selected) input[type="checkbox"]').trigger("click"):i.find('li.selected input[type="checkbox"]').trigger("click")}});var c=[];t(e.element).children().each(function(){if("OPTGROUP"==this.nodeName){var e=[];t(this).children("option").each(function(){e[t(this).val()]={name:t(this).text(),value:t(this).val(),checked:t(this).prop("selected")}}),c.push({label:t(this).attr("label"),options:e})}else{if("OPTION"!=this.nodeName)return!0;c.push({name:t(this).text(),value:t(this).val(),checked:t(this).prop("selected")})}}),e.loadOptions(c),n?(s.find("> li:not(.optgroup)").css({float:"left",width:100/e.options.columns+"%"}),s.find("li.optgroup").css({clear:"both"}).find("> ul").css({"column-count":e.options.columns,"column-gap":0,"-webkit-column-count":e.options.columns,"-webkit-column-gap":0,"-moz-column-count":e.options.columns,"-moz-column-gap":0}),this._ieVersion()&&this._ieVersion()<10&&s.find("li.optgroup > ul > li").css({float:"left",width:100/e.options.columns+"%"})):(s.css({"column-count":e.options.columns,"column-gap":0,"-webkit-column-count":e.options.columns,"-webkit-column-gap":0,"-moz-column-count":e.options.columns,"-moz-column-gap":0}),this._ieVersion()&&this._ieVersion()<10&&s.find("> li").css({float:"left",width:100/e.options.columns+"%"})),o.on("click",'input[type="checkbox"]',function(){t(this).closest("li").toggleClass("selected"),o.parent().prev().find('option[value="'+t(this).val()+'"]').prop("selected",t(this).is(":checked")).closest("select").trigger("change"),"function"==typeof e.options.onOptionClick&&e.options.onOptionClick(),e._updatePlaceholderText()}),"function"==typeof e.options.onLoad?e.options.onLoad(e.element):t(e.element).hide()},loadOptions:function(e,i){i="boolean"!=typeof i||i;var o=t(this.element).next(".ms-options-wrap").find("> .ms-options > ul");for(var s in i&&o.find("> li").remove(),e){var n=e[s],l=t("");if(n.hasOwnProperty("options"))for(var a in l.addClass("optgroup"),l.append(''+n.label+""),l.find("> .label").css({clear:"both"}),this.options.selectGroup&&l.append('Select all'),l.append(""),n.options){var p=n.options[a],c=t("").addClass("ms-reflow");this._addOption(c,p),l.find("> ul").append(c)}else n.hasOwnProperty("value")&&(l.addClass("ms-reflow"),this._addOption(l,n));o.append(l)}o.find('.ms-reflow input[type="checkbox"]').each(function(e){if(t(this).css("display").match(/block$/)){var i=t(this).outerWidth();i=i||15,t(this).closest("label").css("padding-left",2*parseInt(t(this).closest("label").css("padding-left"))+i),t(this).closest(".ms-reflow").removeClass("ms-reflow")}}),this._updatePlaceholderText()},unload:function(){t(this.element).next(".ms-options-wrap").remove(),t(this.element).show(function(){t(this).css("display","").removeClass("jqmsLoaded")})},reload:function(){t(this.element).next(".ms-options-wrap").remove(),t(this.element).removeClass("jqmsLoaded"),this.load()},_updatePlaceholderText:function(){var e=t(this.element).next(".ms-options-wrap").find("> button:first-child"),i=t(this.element).next(".ms-options-wrap").find("> .ms-options"),o=i.parent().prev(),s=[];o.find("option:selected").each(function(){s.push(t(this).text())}),e.text(s.join(", "));var n=e.clone().css({display:"inline",width:"auto",visibility:"hidden"}).appendTo(i.parent());(void 0!==t.fn.actual?n.actual("width",this.options.jqActualOpts):n.width())>(void 0!==t.fn.actual?e.actual("width",this.options.jqActualOpts):e.width())?e.text(s.length+" selected"):s.length?e.text(s.join(", ")):e.text(this.options.placeholder),n.remove()},_addOption:function(e,o){e.text(o.name),e.prepend(t('').val(o.value).attr("title",o.name).attr("id","ms-opt-"+i)),o.checked&&(e.addClass("default"),e.addClass("selected"),e.find('input[type="checkbox"]').prop("checked",!0));var s=t("").attr("for","ms-opt-"+i);e.wrapInner(s),this.options.showCheckbox||e.find('input[id="ms-opt-'+i+'"]').hide(),i+=1},_ieVersion:function(){var t=navigator.userAgent.toLowerCase();return-1!=t.indexOf("msie")&&parseInt(t.split("msie")[1])}},t.fn.multiselect=function(e){var i,s=arguments;return void 0===e||"object"==typeof e?this.each(function(){t.data(this,"plugin_multiselect")||t.data(this,"plugin_multiselect",new o(this,e))}):"string"==typeof e&&"_"!==e[0]&&"init"!==e?(this.each(function(){var n=t.data(this,"plugin_multiselect");n instanceof o&&"function"==typeof n[e]&&(i=n[e].apply(n,Array.prototype.slice.call(s,1))),"unload"===e&&t.data(this,"plugin_multiselect",null)}),i):void 0}}(jQuery);
\ No newline at end of file
diff --git a/js/qsm-admin.js b/js/qsm-admin.js
index b626cee60..8208f1255 100644
--- a/js/qsm-admin.js
+++ b/js/qsm-admin.js
@@ -105,6 +105,12 @@ var QSMAdmin;
var checked_data = jQuery(this).val().toString();
jQuery('.catergory_comma_values').val(checked_data);
});
+ jQuery('.category_selection_random').multiselect( {
+ columns: 1,
+ placeholder: qsm_admin_messages.select_category,
+ search: true,
+ selectAll: true
+ } );
jQuery('.row-actions-c > .rtq-delete-result').click(function (e) {
e.preventDefault();
var $this = jQuery(this);
@@ -1604,15 +1610,14 @@ var import_button;
},
loadQuestionBank: function (action = '') {
if (action == 'change') {
- $('.qb-load-more-wrapper').remove();
- $('#question-bank').find('.question-bank-question').remove();
+ $('#question-bank').empty();
$('#question-bank').append('');
} else if ($('.qb-load-more-wrapper').length > 0) {
$('.qb-load-more-question').hide();
- $('.qb-load-more-wrapper').append('');
+ $('.qb-load-more-wrapper').append('');
} else {
$('#question-bank').empty();
- $('#question-bank').append('');
+ $('#question-bank').append('');
}
$.ajax({
url: wpApiSettings.root + 'quiz-survey-master/v1/bank_questions/0/',
@@ -1663,6 +1668,9 @@ var import_button;
$('#question-bank-cat').val(pagination.category);
}
}
+ if ( 1 > questions.length ) {
+ $('#question-bank').append('' + qsm_admin_messages.questions_not_found + '
');
+ }
},
addQuestionToQuestionBank: function (question) {
var questionText = QSMQuestion.prepareQuestionText(question.name);
@@ -1694,6 +1702,7 @@ var import_button;
},
questionBankSuccess: function (model) {
var newModel = _.clone(model.attributes);
+ newModel.question_id = newModel.id;
newModel.id = null;
QSMQuestion.questions.create(
newModel, {
@@ -1864,12 +1873,14 @@ var import_button;
model.set('page', page);
QSMQuestion.questions.add(model);
QSMQuestion.addQuestionToPage(model);
+ QSMQuestion.savePages();
+
$('.import-button').removeClass('disable_import');
QSMQuestion.countTotal();
import_button.html('').html(qsm_admin_messages.add_question);
import_button.attr("onclick", "return confirm(" + qsm_admin_messages.confirm_message + "' '" + qsm_admin_messages.import_question_again + ")");
QSMQuestion.openEditPopup(model.id, $('.question[data-question-id=' + model.id + ']').find('.edit-question-button'));
- $('#save-popup-button').trigger('click');
+ // $('#save-popup-button').trigger('click');
},
addNewQuestion: function (model) {
var default_answers = parseInt(qsmQuestionSettings.default_answers);
diff --git a/js/qsm-quiz.js b/js/qsm-quiz.js
index b421dc26e..48b41205e 100644
--- a/js/qsm-quiz.js
+++ b/js/qsm-quiz.js
@@ -1123,7 +1123,7 @@ function qmnValidatePage(quiz_form_id) {
// Show start quiz button if first page is visible
function check_if_show_start_quiz_button(container, total_pages, page_number) {
- if(jQuery('.quiz_begin').css('display') == 'block'){
+ if(container.find('.quiz_begin').css('display') == 'block'){
container.find(".mlw_custom_start").show();
container.find(".mlw_custom_next").hide();
}else{
@@ -1498,7 +1498,7 @@ jQuery(function () {
});
});
- jQuery(document).on('change', '.qmn_radio_answers input' , function (e) {
+ jQuery(document).on('change', '.qmn_radio_answers input, .qsm_dropdown' , function (e) {
var quizID = jQuery(this).parents('.qsm-quiz-container').find('.qmn_quiz_id').val();
if (qmn_quiz_data[quizID].enable_quick_result_mc == 1) {
let question_id = jQuery(this).attr('name').split('question')[1],
@@ -1508,7 +1508,7 @@ jQuery(function () {
}
});
let qsm_inline_result_timer;
- jQuery(document).on('keyup', '.mlw_answer_open_text, .mlw_answer_number', function (e) {
+ jQuery(document).on('keyup', '.mlw_answer_open_text, .mlw_answer_number, .qmn_fill_blank ', function (e) {
let $i_this = jQuery(this);
let quizID = jQuery(this).parents('.qsm-quiz-container').find('.qmn_quiz_id').val();
if (qmn_quiz_data[quizID].enable_quick_result_mc == 1) {
@@ -1517,13 +1517,13 @@ jQuery(function () {
let question_id = $i_this.attr('name').split('question')[1],
value = $i_this.val(),
$this = $i_this.parents('.quiz_section');
- qsm_show_inline_result(quizID, question_id, value, $this, 'input');
+ qsm_show_inline_result(quizID, question_id, value, $this, 'input',$this.find('.qmn_fill_blank').index($i_this));
}, 2000);
}
});
//inline result status function
- function qsm_show_inline_result(quizID, question_id, value, $this, answer_type) {
+ function qsm_show_inline_result(quizID, question_id, value, $this, answer_type, index = null ) {
jQuery.ajax({
type: 'POST',
url: qmn_ajax_object.ajaxurl,
@@ -1531,6 +1531,7 @@ jQuery(function () {
action: "qsm_get_question_quick_result",
question_id: question_id,
answer: value,
+ index: index,
answer_type: answer_type,
show_correct_info: qmn_quiz_data[quizID].enable_quick_correct_answer_info
},
diff --git a/mlw_quizmaster2.php b/mlw_quizmaster2.php
index 29d07853a..b6af284ca 100644
--- a/mlw_quizmaster2.php
+++ b/mlw_quizmaster2.php
@@ -2,7 +2,7 @@
/**
* Plugin Name: Quiz And Survey Master
* Description: Easily and quickly add quizzes and surveys to your website.
- * Version: 8.1.4
+ * Version: 8.1.5
* Author: ExpressTech
* Author URI: https://quizandsurveymaster.com/
* Plugin URI: https://expresstech.io/
@@ -43,7 +43,7 @@ class MLWQuizMasterNext {
* @var string
* @since 4.0.0
*/
- public $version = '8.1.4';
+ public $version = '8.1.5';
/**
* QSM Alert Manager Object
@@ -356,6 +356,8 @@ public function qsm_admin_scripts_style( $hook ) {
}
// load admin JS after all dependencies are loaded
wp_enqueue_script( 'qsm_admin_js', plugins_url( 'js/qsm-admin.js', __FILE__ ), array( 'jquery', 'backbone', 'underscore', 'wp-util', 'jquery-ui-sortable', 'jquery-touch-punch' ), $this->version, true );
+ wp_enqueue_style( 'jquer-multiselect-css', QSM_PLUGIN_CSS_URL . '/jquery.multiselect.min.css', array(), $this->version );
+ wp_enqueue_script( 'qsm-jquery-multiselect-js', QSM_PLUGIN_JS_URL . '/jquery.multiselect.min.js', array( 'jquery' ), $this->version, true );
wp_enqueue_script( 'micromodal_script', plugins_url( 'js/micromodal.min.js', __FILE__ ), array( 'jquery', 'qsm_admin_js' ), $this->version, true );
$qsm_admin_messages = array(
'error' => __('Error', 'quiz-master-next'),
@@ -428,6 +430,8 @@ public function qsm_admin_scripts_style( $hook ) {
'success_message' => __("Thanks, you are now subscribed to our mailing list!", 'quiz-master-next'),
'error_message' => __("Sorry, unable to subscribe. Please try again later!", 'quiz-master-next'),
),
+ 'select_category' => __("Select Category", 'quiz-master-next'),
+ 'questions_not_found' => __("Question not found!", 'quiz-master-next'),
);
wp_localize_script( 'qsm_admin_js', 'qsm_admin_messages', $qsm_admin_messages );
diff --git a/php/classes/class-qmn-quiz-manager.php b/php/classes/class-qmn-quiz-manager.php
index e9c5ebdee..1d8950b0a 100644
--- a/php/classes/class-qmn-quiz-manager.php
+++ b/php/classes/class-qmn-quiz-manager.php
@@ -221,8 +221,9 @@ public function qsm_get_question_quick_result() {
$question_id = isset( $_POST['question_id'] ) ? intval( $_POST['question_id'] ) : 0;
$answer = isset( $_POST['answer'] ) ? sanitize_text_field( wp_unslash( $_POST['answer'] ) ) : '';
$answer_type = isset( $_POST['answer_type'] ) ? sanitize_text_field( wp_unslash( $_POST['answer_type'] ) ) : '';
- $question_array = $wpdb->get_row( $wpdb->prepare( "SELECT answer_array, question_answer_info FROM {$wpdb->prefix}mlw_questions WHERE question_id = (%d)", $question_id ), 'ARRAY_A' );
+ $question_array = $wpdb->get_row( $wpdb->prepare( "SELECT answer_array, question_answer_info, question_type_new, question_settings FROM {$wpdb->prefix}mlw_questions WHERE question_id = (%d)", $question_id ), 'ARRAY_A' );
$answer_array = maybe_unserialize( $question_array['answer_array'] );
+ $settings = maybe_unserialize( $question_array['question_settings'] );
$correct_info_text = isset( $question_array['question_answer_info'] ) ? html_entity_decode( $question_array['question_answer_info'] ) : '';
$correct_info_text = $mlwQuizMasterNext->pluginHelper->qsm_language_support( $correct_info_text, "correctanswerinfo-{$question_id}" );
@@ -230,10 +231,15 @@ public function qsm_get_question_quick_result() {
$got_ans = false;
$correct_answer = false;
$count = 0;
+ $ans_index = isset( $_POST['index'] ) ? intval( $_POST['index'] ) : 0;
if ( $answer_array && false === $got_ans ) {
foreach ( $answer_array as $key => $value ) {
if ( 'input' === $answer_type ) {
- if ( $answer == $value[0] && 1 === intval( $value[2] ) ) {
+ if ( empty( $settings['case_sensitive'] ) ) {
+ $answer = mb_strtoupper($answer);
+ $value[0] = mb_strtoupper($value[0]);
+ }
+ if ( $answer == $value[0] && ( 1 === intval( $value[2] ) || 14 === intval( $question_array['question_type_new'] ) ) && ( empty( $settings['matchAnswer'] ) || 'random' === $settings['matchAnswer'] || $key == $ans_index ) ) {
$got_ans = true;
$correct_answer = true;
break;
@@ -702,6 +708,9 @@ public function load_questions( $quiz_id, $quiz_options, $is_quiz_page, $questio
if ( 1 == $quiz_options->randomness_order || 2 == $quiz_options->randomness_order ) {
if ( isset($_COOKIE[ 'question_ids_'.$quiz_id ]) ) {
$question_sql = sanitize_text_field( wp_unslash( $_COOKIE[ 'question_ids_'.$quiz_id ] ) );
+ if ( ! preg_match("/^\d+(,\d+)*$/", $question_sql) ) {
+ $question_sql = implode( ',', $question_ids );
+ }
}else {
$question_ids = apply_filters( 'qsm_load_questions_ids', $question_ids, $quiz_id, $quiz_options );
$question_ids = QMNPluginHelper::qsm_shuffle_assoc( $question_ids );
@@ -718,8 +727,8 @@ public function load_questions( $quiz_id, $quiz_options, $is_quiz_page, $questio
$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", esc_sql( $question_sql ), $cat_query, $order_by_sql, $limit_sql );
- $questions = $wpdb->get_results( stripslashes( $query ) );
+ $query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}mlw_questions WHERE question_id IN (%1s) %2s %3s %4s", esc_sql( $question_sql ), esc_sql( $cat_query ), esc_sql( $order_by_sql ), esc_sql( $limit_sql ) );
+ $questions = $wpdb->get_results( $query );
// If we are not using randomization, we need to put the questions in the order of the new question editor.
// If a user has saved the pages in the question editor but still uses the older pagination options
diff --git a/php/classes/class-qsm-contact-manager.php b/php/classes/class-qsm-contact-manager.php
index d0de56e1d..692ae9f1f 100644
--- a/php/classes/class-qsm-contact-manager.php
+++ b/php/classes/class-qsm-contact-manager.php
@@ -380,7 +380,7 @@ public static function generate_contact_field( $field, $index, $quiz_options, $d
$class = '';
if ( ( 'true' === $field["required"] || true === $field["required"] ) && ! $fields_hidden ) {
if ( 'radio' === $field["type"] ) {
- $class .= ' mlwRequiredRadiomlwRequiredRadio ';
+ $class .= ' mlwRequiredRadio ';
}elseif ( 'select' === $field["type"] ) {
$class .= 'qsmRequiredSelect';
}else {
diff --git a/php/classes/class-qsm-fields.php b/php/classes/class-qsm-fields.php
index 0c44790d6..cd70222e4 100644
--- a/php/classes/class-qsm-fields.php
+++ b/php/classes/class-qsm-fields.php
@@ -621,7 +621,7 @@ public static function generate_category_field( $field, $value ) {
}
$cat_array = array_unique( $cat_array );
if ( $cat_array || $categories_tree ) {
- ?>