Skip to content

Commit

Permalink
Merge pull request #2438 from QuizandSurveyMaster/dev2
Browse files Browse the repository at this point in the history
Release 8.2.1
  • Loading branch information
etvarun authored Jan 5, 2024
2 parents 40babbf + 7d47491 commit fa0252f
Show file tree
Hide file tree
Showing 16 changed files with 305 additions and 94 deletions.
32 changes: 29 additions & 3 deletions css/qsm-admin-question.css
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,14 @@
.page-header-buttons {
text-align: right;
}
.question, .question-bank-question {
.qsm-question-container, .question-bank-question {
box-sizing: border-box;
background: #ffffff;
border: 1px solid #dfd4d4;
border-radius: 3px;
padding: 6px 5px;
margin: 10px 20px 0;
margin: 10px 20px 0 35px;
position: relative;
}
.question a {
text-decoration: none;
Expand Down Expand Up @@ -194,6 +195,16 @@
font-style: italic;
margin: 3px 0;
}
.qsm-admin-select-question-input {
position: absolute;
top: calc(50% - 3px);
left: -25px;
visibility: hidden;
}
.question:hover .qsm-admin-select-question-input,
.qsm-admin-select-question-input:checked {
visibility: visible;
}
.question-content>div {
margin: 0 10px;
}
Expand Down Expand Up @@ -472,7 +483,7 @@ a.import-button.button.disable_import::before {
padding: 15px 10px;
background-color: #fafafa;
border: 1px solid #cbcbcb;
margin: 0 20px 0;
margin: 0 20px 0 35px;
box-sizing: border-box;
border-top: medium none;
}
Expand Down Expand Up @@ -620,6 +631,21 @@ a#qsm-category-add-toggle {
.question_info_tag {
float: right;
}
.qsm-admin-bulk-actions{
margin-top: 10px;
text-align: right;
display: none;
}
input.qsm-admin-select-page-question {
margin-left: 10px;
margin-right: 10px;
display: inline-block;
}
.qsm-admin-select-page-question-label{
color: #a6abaf;
font-size: 16px;
display: none;
}
@media (min-width: 783px) and (max-width: 1199px) {
#poststuff #post-body.columns-2 #side-sortables {
min-width: unset;
Expand Down
4 changes: 3 additions & 1 deletion css/qsm-admin-rtl.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@
.overview-main-wrapper .overview-inner-wrap {margin-left: 2%;margin-right: 0;}
div.qsm_icon_wrap{left:0;right:auto;}
.text-right{text-align: left !important;}
.text-left{text-align: right !important;}
.text-left{text-align: right !important;}
.wp-core-ui .button-danger { color: #DC3232; border-color: #DC3232; }
.wp-core-ui .button-danger:hover { color: #ca1010; border-color: #ca1010; }
14 changes: 13 additions & 1 deletion css/qsm-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,9 @@ tr .qsm-opt-desc {
.form-table td fieldset label {
margin-right: 20px !important;
}
.qsm-font-light {
font-weight: 300;
}
.form-table .qsm-opt-tr {
position: relative;
}
Expand Down Expand Up @@ -1950,7 +1953,9 @@ td.scheduled_time_start {
.notice-error.notice-advance-timer {
padding: 10px 15px;
}

.notice-error.notice-advance-timer {
padding: 10px 15px;
}
.qsm-page-setting-top {
display: flex;
}
Expand Down Expand Up @@ -3259,3 +3264,10 @@ input#duplicate_questions {
background-color: #fff;
color: #2c3338;
}
.wp-core-ui .button-danger {
color: #DC3232;
border-color: #DC3232;
}
.wp-core-ui .button-danger:hover {
color: #ca1010; border-color: #ca1010;
}
2 changes: 1 addition & 1 deletion data/parsing_script.json

Large diffs are not rendered by default.

182 changes: 156 additions & 26 deletions js/qsm-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -1511,10 +1511,11 @@ var QSMContact;
tinymce: {
forced_root_block: '',
toolbar1: 'formatselect,bold,italic,underline,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,wp_more,fullscreen,wp_adv',
toolbar2: 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help'
toolbar2: 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help,wp_code'
},
quicktags: true,
};
jQuery(document).trigger('qsm_tinyMCE_settings_after', [settings]);
wp.editor.initialize('email-template-' + QSMAdminEmails.total, settings);
}
jQuery(document).trigger('qsm_after_add_email_block', [conditions, to, subject, content, replyTo, QSMAdminEmails.total]);
Expand Down Expand Up @@ -2237,10 +2238,11 @@ var import_button;
tinymce: {
forced_root_block: '',
toolbar1: 'formatselect,bold,italic,underline,bullist,numlist,blockquote,alignleft,aligncenter,alignright,alignjustify,link,wp_more,fullscreen,wp_adv',
toolbar2: 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help'
toolbar2: 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help,wp_code'
},
quicktags: true,
};
jQuery(document).trigger('qsm_tinyMCE_settings_after', [settings]);
wp.editor.initialize(textarea_id, settings);
var anser = QSMQuestion.prepareQuestionText(answer[0]);
$(textarea_id).val(anser);
Expand Down Expand Up @@ -2477,10 +2479,11 @@ var import_button;
tinymce: {
forced_root_block: '',
toolbar1: 'formatselect,bold,italic,underline,bullist,numlist,blockquote,alignleft,aligncenter,alignright,alignjustify,link,wp_more,fullscreen,wp_adv',
toolbar2: 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help'
toolbar2: 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help,wp_code'
},
quicktags: true,
};
jQuery(document).trigger('qsm_tinyMCE_settings_after', [settings]);
wp.editor.initialize('question-text', settings);
wp.editor.initialize('correct_answer_info', settings);
},
Expand Down Expand Up @@ -2676,34 +2679,160 @@ var import_button;
$('#delete-question-button').attr('data-question-iid', $(this).data('question-iid'));
});
// removes question from database
$('#delete-question-button').click(function (event) {
event.preventDefault();
var question_id = $(this).data('question-iid');
$.ajax({
url: ajaxurl,
method: 'POST',
data: {
'action': 'qsm_delete_question_from_database',
'question_id': question_id,
'nonce': qsmQuestionSettings.single_question_nonce
},
success: function (response) {
// do nothing
$(document).on('click', '.qsm-delete-question-button-btn', function () {
let question_id = $(this).attr('data-question-iid');
let checkedValues = "";
if ("selected-questions" == question_id || "all-questions" == question_id) {
if ("all-questions" == question_id) {
checkedValues = $('.qsm-admin-select-question-input')
.map(function () {
return $(this).val();
})
.get();
} else {
checkedValues = $('.qsm-admin-select-question-input:checked')
.map(function () {
return $(this).val();
})
.get();
}
});
remove.parents('.question').remove();
QSMQuestion.countTotal();
$('.save-page-button').trigger('click');
let question_ids = checkedValues.join(',');
if (question_ids == undefined || question_ids == null || question_ids == '') {
return;
}
$.ajax({
url: ajaxurl,
method: 'POST',
data: {
'action': 'qsm_bulk_delete_question_from_database',
'question_id': question_ids,
'nonce': qsmQuestionSettings.single_question_nonce
},
success: function (response) {
if (response.success) {
checkedValues.forEach(function (questionId) {
$('.question[data-question-id="' + questionId + '"]').remove();
});
jQuery('.qsm-admin-select-page-question').prop('checked',false);
QSMQuestion.countTotal();
$('.save-page-button').trigger('click');
} else {
QSMAdmin.displayAlert(response.data, 'error');
}
jQuery('.qsm-admin-bulk-actions').fadeOut();
}
});
} else {
$.ajax({
url: ajaxurl,
method: 'POST',
data: {
'action': 'qsm_delete_question_from_database',
'question_id': question_id,
'nonce': qsmQuestionSettings.single_question_nonce
},
success: function (response) {
if (response.success) {
remove.parents('.question').remove();
QSMQuestion.countTotal();
$('.save-page-button').trigger('click');
} else {
QSMAdmin.displayAlert(response.data, 'error');
}
}
});
}
MicroModal.close('modal-7');
});
// delete bulk question from database
$(document).on('click', '#qsm-bulk-delete-question', function (event) {
event.preventDefault();
MicroModal.show('modal-7');
$('#unlink-question-button').attr('data-question-iid', 'selected-questions');
$('#delete-question-button').attr('data-question-iid', 'selected-questions');
});
// remove bulk question from quiz
$(document).on('click', '#qsm-bulk-delete-all-question', function (event) {
event.preventDefault();
MicroModal.show('modal-7');
$('#unlink-question-button').attr('data-question-iid', 'all-questions');
$('#delete-question-button').attr('data-question-iid', 'all-questions');
});

$(document).on('click', '.qsm-admin-select-page-question', function () {
let isChecked = $(this).prop('checked');
let checkboxesToToggle = $(this).closest('.page').find('.qsm-admin-select-question-input');
checkboxesToToggle.prop('checked', isChecked);
if (!isChecked) {
$('.qsm-admin-select-page-question').prop('checked', false);
} else {
let allCheckboxesChecked = checkboxesToToggle.length === checkboxesToToggle.filter(':checked').length;
$('.qsm-admin-select-page-question').prop('checked', allCheckboxesChecked);
}
let count = jQuery('.qsm-admin-select-question-input:checked').length;
jQuery('.qsm-selected-question-count').html(count);
if (count) {
jQuery('.qsm-admin-bulk-actions').fadeIn();
} else {
jQuery('.qsm-admin-bulk-actions').fadeOut();
}
});

$(document).on('click', '.qsm-admin-select-question-input', function () {
if (!$(this).prop('checked')) {
$(this).closest('.page').find('.qsm-admin-select-page-question').prop('checked', false);
} else {
let allCheckboxesChecked = $(this).closest('.page').find('.qsm-admin-select-question-input:checked').length === $(this).closest('.page').find('.qsm-admin-select-question-input').length;
$(this).closest('.page').find('.qsm-admin-select-page-question').prop('checked', allCheckboxesChecked);
}
if ( $(this).closest('.page').find('.qsm-admin-select-question-input:checked').length ) {
$(this).closest('.page').find('.qsm-admin-select-page-question-label').fadeIn();
} else {
$(this).closest('.page').find('.qsm-admin-select-page-question-label').fadeOut();
}
let count = jQuery('.qsm-admin-select-question-input:checked').length;
jQuery('.qsm-selected-question-count').html(count);
if (count) {
jQuery('.qsm-admin-bulk-actions').fadeIn();
} else {
jQuery('.qsm-admin-bulk-actions').fadeOut();
}
});

// unlink question from a particular quiz.
$('#unlink-question-button').click(function (event) {
$(document).on('click', '.qsm-unlink-question-button-btn', function (event) {
event.preventDefault();
var question_id = $(this).data('question-iid');
remove.parents('.question').remove();
QSMQuestion.countTotal();
$('.save-page-button').trigger('click');
let question_id = $(this).attr('data-question-iid');
let checkedValues = "";
if ("selected-questions" == question_id || "all-questions" == question_id) {
if ("all-questions" == question_id) {
checkedValues = $('.qsm-admin-select-question-input')
.map(function () {
return $(this).val();
})
.get();
} else {
checkedValues = $('.qsm-admin-select-question-input:checked')
.map(function () {
return $(this).val();
})
.get();
}
let question_ids = checkedValues.join(',');
if (undefined != question_ids && null != question_ids && '' != question_ids) {
checkedValues.forEach(function (questionId) {
$('.question[data-question-id="' + questionId + '"]').remove();
});
QSMQuestion.countTotal();
$('.save-page-button').trigger('click');
jQuery('.qsm-admin-bulk-actions').fadeOut();
jQuery('.qsm-admin-select-page-question').prop('checked',false);
}
} else {
remove.parents('.question').remove();
QSMQuestion.countTotal();
$('.save-page-button').trigger('click');
}
MicroModal.close('modal-7');
});

Expand Down Expand Up @@ -3348,10 +3477,11 @@ var import_button;
tinymce: {
forced_root_block: '',
toolbar1: 'formatselect,bold,italic,underline,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,wp_more,fullscreen,wp_adv',
toolbar2: 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help'
toolbar2: 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help,wp_code'
},
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]);
},
Expand Down
Loading

0 comments on commit fa0252f

Please sign in to comment.