Skip to content

Commit

Permalink
Merged with dev
Browse files Browse the repository at this point in the history
  • Loading branch information
iam-pranav committed Sep 6, 2024
2 parents 9fb7c69 + e74d219 commit e330218
Show file tree
Hide file tree
Showing 24 changed files with 348 additions and 97 deletions.
3 changes: 3 additions & 0 deletions css/qsm-admin-question.css
Original file line number Diff line number Diff line change
Expand Up @@ -743,3 +743,6 @@ input.qsm-admin-select-page-question {
width: 330px;
}
}
#placeholder_text{
width: 100%;
}
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;
}
56 changes: 49 additions & 7 deletions js/qsm-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,13 @@ var QSMAdmin;
});
jQuery(document).on('change', '#preferred-date-format-custom', function() {
let customValue = jQuery(this).val();
jQuery('#preferred_date_format label.qsm-option-label:last input[type="radio"]').val(customValue);
let validDateFormat = /^[djDlmnMFYy\-\/\. ,]+$/;
if (validDateFormat.test(customValue)) {
jQuery(this).css("border-color", "");
jQuery('#preferred_date_format label.qsm-option-label:last input[type="radio"]').val(customValue);
} else {
jQuery(this).css("border-color", "#e54444");
}
});
if( jQuery('#qsm-select-quiz-apply').length ) {
$('#qsm-select-quiz-apply').multiselect({
Expand Down Expand Up @@ -606,6 +612,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 +790,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 +1181,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 +1385,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 +1537,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 +1549,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 +3801,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 +3837,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 +3859,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
34 changes: 20 additions & 14 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 @@ -2005,7 +2013,7 @@ jQuery(document).keydown(function(event) {
return;
}
}
if ([39, 37, 13, 9].includes(event.keyCode)) {
if ([39, 37, 13, 9].includes(event.keyCode) && jQuery('textarea:focus').length === 0) {
event.preventDefault();
}
if (event.keyCode === 39) {
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
Loading

0 comments on commit e330218

Please sign in to comment.