Skip to content

Commit

Permalink
Merge branch 'dev' into CU-86cwbwgmz-paragraph-allow-enter-key
Browse files Browse the repository at this point in the history
  • Loading branch information
Mann47 committed Aug 30, 2024
2 parents 333b87a + f518d7a commit 09ade61
Show file tree
Hide file tree
Showing 17 changed files with 318 additions and 90 deletions.
49 changes: 41 additions & 8 deletions css/qsm-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -833,17 +833,18 @@ ul.changelog li.update div.two:before {
.qsm_tab_content label {
margin-right: 5px;
}
.qsm-sub-text-tab-menu,
.qsm-sub-tab-menu {
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: stretch;
border-bottom: 1px solid #cecece;
}
.qsm-sub-text-tab-menu {
/* .qsm-sub-text-tab-menu {
display: inline-block;
width: 100%;
}
} */
.save-text-changes {
display: flex;
flex-direction: row-reverse;
Expand Down Expand Up @@ -925,6 +926,7 @@ ul.changelog li.update div.two:before {
padding: 10px 6px;
width: 100%;
}
.qsm-sub-text-tab-menu a,
.qsm-sub-tab-menu a,
.qsm_tab_content a {
cursor: pointer;
Expand All @@ -933,10 +935,12 @@ ul.changelog li.update div.two:before {
display: inline-block;
box-sizing: border-box;
}
.qsm-sub-text-tab-menu .subsubsub li:first-child,
.qsm-sub-tab-menu .subsubsub li:first-child {
border-left: 0;
padding-left: 0;
}
.qsm-sub-text-tab-menu .subsubsub li a,
.qsm-sub-tab-menu .subsubsub li a {
font-size: 14px;
line-height: 1.2;
Expand All @@ -948,6 +952,7 @@ ul.changelog li.update div.two:before {
text-decoration: none;
box-shadow: none;
}
.qsm-sub-text-tab-menu .subsubsub li a.current,
.qsm-sub-tab-menu .subsubsub li a.current{
border-bottom: 3px solid #00BEE9;
}
Expand Down Expand Up @@ -3120,7 +3125,7 @@ input#duplicate_questions {
.auto-fold .option-page-result-page-tab-footer {
left: 36px;
}
.option-page-option-tab-footer, .option-page-result-page-tab-footer {
.option-page-option-tab-footer, .option-page-result-page-tab-footer, .contact-page-tab-footer {
position: fixed;
bottom: 0;
right: 0;
Expand All @@ -3132,7 +3137,7 @@ input#duplicate_questions {
align-items: center;
background: #ffffff;
border-top: 1px solid #DADADA;
z-index: 9999;
z-index: 9998;
padding: 10px 30px 8px 10px;
min-height: 37px;
}
Expand All @@ -3147,7 +3152,7 @@ input#duplicate_questions {
width: 60%;
}
@media screen and (min-width: 1900px) {
.option-page-option-tab-footer,.option-page-result-page-tab-footer {
.option-page-option-tab-footer,.option-page-result-page-tab-footer,.contact-page-tab-footer {
flex-direction: row-reverse;
}
}
Expand Down Expand Up @@ -3190,18 +3195,21 @@ input#duplicate_questions {
.option-page-result-page-tab-footer {
left: 160px !important;
}
.folded .option-page-option-tab-footer {
.folded .option-page-option-tab-footer,
.folded .contact-page-tab-footer {
left: 36px !important;
}
.option-page-option-tab-footer {
.option-page-option-tab-footer,
.contact-page-tab-footer {
left: 160px !important;
}
}
@media screen and (max-width: 782px) {
.option-page-result-page-tab-footer {
left: 0 !important;
}
.option-page-option-tab-footer {
.option-page-option-tab-footer,
.contact-page-tab-footer {
left: 0 !important;
}
}
Expand Down Expand Up @@ -3461,4 +3469,29 @@ input#preferred-date-format-custom {
margin: 13px -15px 8px;
content: "";
width: calc(100% + 26px);
}

/* Extra shortcodes popup */
button.button.qsm-extra-shortcode-popup {
display: flex;
align-items: center;
position: relative;
top: 30px;
left: 197px;
z-index: 10;
}

button.button.qsm-slashcommand-variables-button {
display: flex;
align-items: center;
position: relative;
top: 30px;
left: 110px;
z-index: 10;
margin: -30px 0;
}

button.button.qsm-slashcommand-variables-button .qsm-slash-inside {
margin: 0 4px 0 -1px;
font-weight: 1000;
}
48 changes: 42 additions & 6 deletions js/qsm-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,11 @@ var QSMAdmin;
MicroModal.show('modal-proctor-quiz');
});

$(document).on('click', '.quiz_style_tab_content #qsm_ultimate_progress_bar', function (e) {
e.preventDefault();
MicroModal.show('qsm-ultimate-upgrade');
});

jQuery(document).on('click', '#btn_export', function (e) {
e.preventDefault();
jQuery.ajax({
Expand Down Expand Up @@ -779,7 +784,15 @@ jQuery('.quiz_text_tab').click(function (e) {
if(current_id == 'qsm_general_text'){ jQuery(".current_general")[0].click();}
if(current_id == 'qsm_variable_text'){ jQuery(".current_variable")[0].click();}
if(current_id == 'qsm_custom_label'){ jQuery("#postbox-container-1").css("display", "none");}
if(current_id == 'qsm_button_custom_class') {
jQuery("#postbox-container-1").css("display", "none");
if ( jQuery("#qsm_button_custom_class").find('.left-bar').length == 0 ) {
jQuery(".qsm-text-main-wrap #post-body-content").css("background", "transparent");
jQuery(".quiz_text_tab_content").css("border", "none");
}
}
jQuery('#' + current_id).show();
jQuery(document).trigger('qsm_quiz_text_tab_after', [current_id]);
});
if (jQuery('body').hasClass('admin_page_mlw_quiz_options')) { var current_id = jQuery(this).attr('data-id'); if(current_id == 'qsm_general_text'){ jQuery(".current_general")[0].click();}
if(current_id == 'qsm_variable_text'){ jQuery(".current_variable")[0].click();}
Expand Down Expand Up @@ -1162,7 +1175,7 @@ function qsm_is_substring_in_array( text, array ) {
//TinyMCE slash command auto suggest
(function ($) {
if (jQuery('body').hasClass('admin_page_mlw_quiz_options')) {
if ( window.location.href.indexOf('tab=emails') > 0 || window.location.href.indexOf('tab=results-pages') > 0 ) {
if ( window.location.href.indexOf('tab=emails') > 0 || window.location.href.indexOf('tab=results-pages') > 0 || window.location.href.indexOf('tab=contact') > 0 ) {
function addTinyMceAutoSuggestion() {
if ( 'undefined' !== typeof tinymce && null !== tinymce && 'undefined' !== typeof qsm_admin_messages && null !== qsm_admin_messages ) {
tinymce.PluginManager.add('qsmslashcommands', function(editor) {
Expand Down Expand Up @@ -1366,10 +1379,32 @@ function qsm_is_substring_in_array( text, array ) {
editor.execCommand('mceInsertContent', false, pastedValue.replace(/%([^%]+)%/g, '<qsmvariabletag>$1</qsmvariabletag>&nbsp;') );
}
});

// Stop multiple times registering click event
$(document).off('click', '.qsm-slashcommand-variables-button').on('click', '.qsm-slashcommand-variables-button', function(e) {
e.preventDefault();
let id = $(this).data('id');
let editor = tinymce.get(id);
let contentToInsert = '/';
editor.focus();
editor.selection.setContent(contentToInsert);
showAutocomplete(editor, true);
});
});
}
}
addTinyMceAutoSuggestion();

$( document ).on( 'click', '.qsm-extra-shortcode-popup', function( e ) {
e.preventDefault();
MicroModal.show('modal-extra-shortcodes');
} );

jQuery(document).on('qsm_after_add_result_block', function(event, conditions, page, redirect, total) {
let $matchingElement = $(`#results-page-${total}`);
let $button = $matchingElement.parents('.results-page-show').find('.qsm-result-editor-custom-button');
$button.attr('data-id', total - 1);
});
}
}
}(jQuery));
Expand Down Expand Up @@ -1496,7 +1531,7 @@ var QSMContact;
$('#contactformsettings input').each(function () {
if ('checkbox' == $(this).attr('type')) {
settings[$(this).attr('name')] = ($(this).prop('checked') ? '1' : '0');
} else {
} else if ('radio' == $(this).attr('type') && $(this).prop('checked')) {
settings[$(this).attr('name')] = $(this).val();
}
});
Expand All @@ -1508,6 +1543,7 @@ var QSMContact;
quiz_id: qsmContactObject.quizID,
nonce: qsmContactObject.saveNonce,
};
jQuery(document).trigger('qsm_contact_field_save_settings_before', [data]);

jQuery.post(ajaxurl, data, function (response) {
QSMContact.saved(JSON.parse(response));
Expand Down Expand Up @@ -3759,7 +3795,7 @@ var import_button;
.done(function (pages) {
$('#results-pages').find('.qsm-spinner-loader').remove();
pages.forEach(function (page, i, pages) {
QSMAdminResults.addResultsPage(page.conditions, page.page, page.redirect, page.default_mark);
QSMAdminResults.addResultsPage(page.conditions, page.page, page.redirect, page.default_mark, page);
});
QSMAdmin.clearAlerts();
})
Expand Down Expand Up @@ -3795,7 +3831,7 @@ var import_button;
newCondition: function ($page) {
QSMAdminResults.addCondition($page, 'quiz', '', 'score', 'equal', 0);
},
addResultsPage: function (conditions, page, redirect, default_mark = false) {
addResultsPage: function (conditions, page, redirect, default_mark = false, singlePage = {}) {
const parser = new DOMParser();
let parseRedirect = parser.parseFromString(redirect, 'text/html');
redirect = parseRedirect.documentElement.textContent;
Expand All @@ -3817,14 +3853,14 @@ var import_button;
tinymce: {
plugins: "qsmslashcommands link image lists charmap colorpicker textcolor hr fullscreen wordpress",
forced_root_block: '',
toolbar1: 'formatselect,bold,italic,underline,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,qsm_slash_command,wp_adv',
toolbar1: 'formatselect,bold,italic,underline,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,wp_adv',
toolbar2: 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help,wp_code,fullscreen',
},
quicktags: true,
};
jQuery(document).trigger('qsm_tinyMCE_settings_after', [settings]);
wp.editor.initialize('results-page-' + QSMAdminResults.total, settings);
jQuery(document).trigger('qsm_after_add_result_block', [conditions, page, redirect, QSMAdminResults.total]);
jQuery(document).trigger('qsm_after_add_result_block', [conditions, page, redirect, QSMAdminResults.total, singlePage]);
},
newResultsPage: function () {
var conditions = [{
Expand Down
32 changes: 19 additions & 13 deletions js/qsm-quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ var qsmTimerInterval = [];
if ($quizForm.find('.qsm-pagination > .current_page_hidden').length == 0) {
$quizForm.find('.qsm-pagination').append('<input type="hidden" value="0" name="current_page" class="current_page_hidden" />');
}
if ('1' == qmn_quiz_data[quizID].progress_bar) {
if ('0' != qmn_quiz_data[quizID].progress_bar) {
jQuery(document).trigger('qsm_init_progressbar_before', [quizID, qmn_quiz_data]);
$('#quizForm' + quizID).find('.qsm-progress-bar').show();
qmn_quiz_data[quizID].bar = createQSMProgressBar(quizID, '#quizForm' + quizID + ' .qsm-progress-bar');
Expand Down Expand Up @@ -405,7 +405,7 @@ var qsmTimerInterval = [];
$quizForm.find('.qsm-page-' + (parseInt(pageNumber))).show();
}
}
if ('1' == qmn_quiz_data[quizID].progress_bar) {
if ('0' != qmn_quiz_data[quizID].progress_bar) {
var current_page = jQuery('#quizForm' + quizID).find('.current_page_hidden').val();
var total_page_length = $pages.length - 1;
if (qmn_quiz_data[quizID].contact_info_location == 0) {
Expand Down Expand Up @@ -1241,7 +1241,7 @@ function qmnPrevSlide(pagination, go_to_top, quiz_form_id) {
* @returns Change progress bar on next and previous button click
*/
function qmnInitProgressbarOnClick(quiz_id, page_number, total_page_number) {
if ('1' == qmn_quiz_data[quiz_id].progress_bar) {
if ('0' != qmn_quiz_data[quiz_id].progress_bar) {
if ( ( !qmn_quiz_data[quiz_id].hasOwnProperty('first_page') || !qmn_quiz_data[quiz_id].first_page ) && 0 == page_number ) {
page_number++;
}
Expand Down Expand Up @@ -1301,7 +1301,7 @@ function qmnInitPagination(quiz_id) {
.append('<input type="submit" value="' + qmn_quiz_data[quiz_id].pagination.submit_quiz_text + '" class="qsm-btn qsm-submit-btn qmn_btn" style="display:none;"/>')
.append('<a class="qmn_btn mlw_qmn_quiz_link mlw_next mlw_custom_next" href="javascript:void(0)">' + qmn_quiz_data[quiz_id].pagination.next_text + '</a>');

if ('1' == qmn_quiz_data[quiz_id].progress_bar) {
if ('0' != qmn_quiz_data[quiz_id].progress_bar) {
jQuery(document).trigger('qsm_init_progressbar_before', [quiz_id, qmn_quiz_data]);
jQuery('#quizForm' + quiz_id).closest('.qmn_quiz_container').find('.qsm-progress-bar').show();
qmn_quiz_data[quiz_id].bar = createQSMProgressBar(quiz_id, '#qsm_progress_bar_' + quiz_id);
Expand Down Expand Up @@ -1487,9 +1487,9 @@ jQuery(function () {
if (qmn_quiz_data[quizID].enable_quick_result_mc == 1) {
qsm_show_inline_result(quizID, question_id, value, $this, 'radio', $i_this)
} else if (qmn_quiz_data[quizID].enable_quick_correct_answer_info != 0) {
let data = qsm_question_quick_result_js(question_id, value, 'radio', qmn_quiz_data[quizID].enable_quick_correct_answer_info, quizID);
let data = qsm_question_quick_result_js(question_id, value, 'radio', qmn_quiz_data[quizID].enable_quick_correct_answer_info,quizID);
$this.find('.quick-question-res-p, .qsm-inline-correct-info').remove();
if (0 < value.length && data.success != '') {
if ( 0 < value.length && data.success != '') {
$this.append('<div class="qsm-inline-correct-info">' + qsm_check_shortcode(data.message) + '</div>');
}
}
Expand All @@ -1503,8 +1503,16 @@ jQuery(function () {
let $i_this = jQuery(this);
let quizID = jQuery(this).parents('.qsm-quiz-container').find('.qmn_quiz_id').val();
let question_id = $i_this.attr('name').split('question')[1];
let value = $i_this.val();
let $this = $i_this.parents('.quiz_section');
let value;
if ($i_this.hasClass('qmn_fill_blank')) {
value = $this.find('.qmn_fill_blank').map(function() {
let val = jQuery(this).val();
return val ? val : null;
}).get().filter(function(v) { return v !== null; });
} else {
value = $i_this.val();
}
let sendValue;
if (typeof value === 'string') {
sendValue = value.trim();
Expand All @@ -1518,9 +1526,9 @@ jQuery(function () {
if (qmn_quiz_data[quizID].enable_quick_result_mc == 1) {
qsm_show_inline_result(quizID, question_id, sendValue, $this, 'input', $i_this, $this.find('.qmn_fill_blank').index($i_this));
} else if (qmn_quiz_data[quizID].enable_quick_correct_answer_info != 0) {
let data = qsm_question_quick_result_js(question_id, sendValue, 'input', qmn_quiz_data[quizID].enable_quick_correct_answer_info, quizID);
let data = qsm_question_quick_result_js(question_id, sendValue, 'input', qmn_quiz_data[quizID].enable_quick_correct_answer_info,quizID);
$this.find('.quick-question-res-p, .qsm-inline-correct-info').remove();
if (0 < value.length && data.success != '') {
if ( 0 < value.length && data.success != '') {
$this.append('<div class="qsm-inline-correct-info">' + qsm_check_shortcode(data.message) + '</div>');
}
}
Expand Down Expand Up @@ -1553,7 +1561,7 @@ jQuery(function () {
}
if (qmn_quiz_data[quizID].enable_quick_result_mc == 1) {
qsm_show_inline_result(quizID, question_id, checkedValues, $this, 'checkbox', $i_this)
}else if (qmn_quiz_data[quizID].enable_quick_correct_answer_info != 0) {
} else if (qmn_quiz_data[quizID].enable_quick_correct_answer_info != 0) {
let data = qsm_question_quick_result_js(question_id, checkedValues, 'checkbox', qmn_quiz_data[quizID].enable_quick_correct_answer_info,quizID);
$this.find('.quick-question-res-p, .qsm-inline-correct-info').remove();
if ( 0 < checkedValues.length && data.success != '') {
Expand Down Expand Up @@ -2071,6 +2079,4 @@ jQuery(document).keydown(function(event) {
}
jQuery(document).trigger('qsm_keyboard_quiz_action_end', event);
}
});


});
3 changes: 2 additions & 1 deletion php/admin/admin-results-details-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function qsm_generate_results_details_tab() {
// Gets results data.
$result_id = isset( $_GET["result_id"] ) ? intval( $_GET["result_id"] ) : 0;
$results_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}mlw_results WHERE result_id = %d", $result_id ) );

$results_data = apply_filters( 'qsm_admin_result_page_before', $results_data );
// Prepare plugin helper.
$quiz_id = intval( $results_data->quiz_id );
$mlwQuizMasterNext->pluginHelper->prepare_quiz( $quiz_id );
Expand All @@ -84,6 +84,7 @@ function qsm_generate_results_details_tab() {
}
echo '<div style="text-align:right; margin-top: 20px; margin-bottom: 20px;">';
echo '<h3 class="result-page-title">'.esc_html__('Quiz Result','quiz-master-next').' - '. esc_html( $results_data->quiz_name ) .'</h3>';
do_action( 'qsm_above_admin_results' );
echo '<a style="margin-right: 15px;" href="?page=mlw_quiz_results" class="button button-primary" title="Return to results">'. esc_html__( 'Back to Results', 'quiz-master-next' ) .'</a>';
if ( ! is_null( $previous_results ) && $previous_results ) {
echo "<a class='button button-primary' title='View Previous Result' href=\"?page=qsm_quiz_result_details&&result_id=" . intval( $previous_results ) . "\" ><span class='dashicons dashicons-arrow-left-alt2'></span></a> ";
Expand Down
16 changes: 16 additions & 0 deletions php/admin/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ function qsm_generate_question_option( $key, $single_option ) {
break;

default:
do_action( 'qsm_generate_question_option_after', $key, $single_option );
// Do nothing
}
?>
Expand Down Expand Up @@ -1655,4 +1656,19 @@ function qsm_advanced_assessment_quiz_page_content() {
"addon_link" => qsm_get_plugin_link( 'downloads/advanced-assessment', 'quiz-documentation', 'plugin', 'advanced-assessment', 'qsm_plugin_upsell' ),
);
qsm_admin_upgrade_content( $args, 'page' );
}
function qsm_ultimate_addon_upgrade_content() {
$args = array(
"id" => 'qsm-ultimate-upgrade',
"title" => __( 'QSM Ultimate Addon', 'quiz-master-next' ),
"description" => __( 'Enjoy features like adding "other" options, bulk answer input, question-based progress bars, automatic page navigation, and showing detailed results after collecting contact details. Customize buttons, progress bar placement, and colors schemes and more with QSM Ultimate addon', 'quiz-master-next' ),
"chart_image" => plugins_url( '', dirname( __FILE__ ) ) . '/images/ultimate_upgrade.png',
"warning" => __( 'Missing Feature - QSM Ultimate Add-on required', 'quiz-master-next' ),
"information" => __( 'QSM Addon Bundle is the best way to get all our add-ons at a discount. Upgrade to save 95% today. OR you can buy QSM Ultimate Addon separately.', 'quiz-master-next' ),
"buy_btn_text" => __( 'Buy QSM Ultimate Addon', 'quiz-master-next' ),
"doc_link" => qsm_get_plugin_link( 'docs/add-ons/ultimate', 'quiz-documentation', 'plugin', 'ultimate', 'qsm_plugin_upsell' ),
"upgrade_link" => qsm_get_plugin_link( 'pricing', 'quiz-documentation', 'plugin', 'ultimate', 'qsm_plugin_upsell' ),
"addon_link" => qsm_get_plugin_link( 'downloads/ultimate', 'quiz-documentation', 'plugin', 'ultimate', 'qsm_plugin_upsell' ),
);
qsm_admin_upgrade_content( $args, 'page' );
}
Loading

0 comments on commit 09ade61

Please sign in to comment.