diff --git a/js/qsm-admin.js b/js/qsm-admin.js
index d366354e5..dc7c58849 100644
--- a/js/qsm-admin.js
+++ b/js/qsm-admin.js
@@ -3714,6 +3714,7 @@ var import_button;
'value': $(this).find('.results-page-condition-value').val()
});
});
+ jQuery(document).trigger('qsm_save_result_page_before', [this, page]);
pages.push(page);
});
let _X_validation = false;
diff --git a/js/qsm-common.js b/js/qsm-common.js
index 936a1eb97..86b340fca 100644
--- a/js/qsm-common.js
+++ b/js/qsm-common.js
@@ -175,6 +175,7 @@
jQuery('.question-section-id-'+questionID+' .question-type-polar-s').find(
'.right-polar-title img').css('opacity', "0.8");
}
+ jQuery(document).trigger('qsm_polar_slider_change_after', [ui,questionID, answer1, answer2, value , isReverse]);
}
function qsmPolarSliderQuestionCreate(questionID){
@@ -187,5 +188,6 @@
'.right-polar-title').css('font-weight', '400');
jQuery('.question-section-id-'+questionID+' .question-type-polar-s img').find(
'.right-polar-title img').css('opacity', "0.5");
+ jQuery(document).trigger('qsm_polar_slider_create_after', [questionID]);
}
}(jQuery));
diff --git a/js/qsm-quiz.js b/js/qsm-quiz.js
index acf5af775..fb362c7aa 100644
--- a/js/qsm-quiz.js
+++ b/js/qsm-quiz.js
@@ -338,7 +338,7 @@ var qsmTimerInterval = [];
jQuery(document).trigger('qsm_init_progressbar_after', [quizID, qmn_quiz_data]);
}
QSM.goToPage(quizID, 1);
- jQuery(document).on('click', '.qsm-quiz-container-' + quizID + ' .qsm-pagination .qsm-next', function (event) {
+ jQuery(document).on('click', '.qsm-quiz-container-' + quizID + ' .qsm-next', function (event) {
jQuery(document).trigger('qsm_next_button_click_before', [quizID]);
event.preventDefault();
let $quizForm = QSM.getQuizForm(quizID);
@@ -365,7 +365,7 @@ var qsmTimerInterval = [];
}
jQuery(document).trigger('qsm_next_button_click_after', [quizID]);
});
- jQuery(document).on('click', '.qsm-quiz-container-' + quizID + ' .qsm-pagination .qsm-previous', function (event) {
+ jQuery(document).on('click', '.qsm-quiz-container-' + quizID + ' .qsm-previous', function (event) {
jQuery(document).trigger('qsm_previous_button_click_before', [quizID]);
event.preventDefault();
QSM.prevPage(quizID);
@@ -1466,7 +1466,7 @@ jQuery(function () {
});
});
- jQuery(document).on('change', '.qmn-multiple-choice-input, .qsm_dropdown' , function (e) {
+ jQuery(document).on('change', '.qmn-multiple-choice-input, .qsm_dropdown, .mlw_answer_date ' , function (e) {
let $i_this = jQuery(this);
var quizID = jQuery(this).parents('.qsm-quiz-container').find('.qmn_quiz_id').val();
var $quizForm = QSM.getQuizForm(quizID);
@@ -1607,6 +1607,8 @@ jQuery(function () {
$this.parent('.quiz_section').find('.qsm-file-upload-status').text('').text(obj.message);
$this.parent('.quiz_section').find('.qsm-file-upload-status').show();
}
+ // triggers after file remove
+ jQuery(document).trigger('qsm_after_file_remove', [$this.parent(), obj]);
}
});
return false;
diff --git a/php/admin/options-page-results-page-tab.php b/php/admin/options-page-results-page-tab.php
index 38ee12fbc..b463bd960 100644
--- a/php/admin/options-page-results-page-tab.php
+++ b/php/admin/options-page-results-page-tab.php
@@ -36,6 +36,7 @@ function qsm_options_results_tab_content() {
'rest_user_nonce' => wp_create_nonce( 'wp_rest_nonce_' . $quiz_id . '_' . $user_id ),
);
wp_localize_script( 'qsm_admin_js', 'qsmResultsObject', $js_data );
+ do_action( 'qsm_options_results_tab_content_before' );
?>
@@ -218,6 +219,7 @@ function qsm_options_results_tab_template(){
+
diff --git a/php/classes/class-qmn-plugin-helper.php b/php/classes/class-qmn-plugin-helper.php
index e131264f0..844198436 100644
--- a/php/classes/class-qmn-plugin-helper.php
+++ b/php/classes/class-qmn-plugin-helper.php
@@ -88,6 +88,72 @@ public function __construct() {
add_filter( 'qsm_language_support', array( $this, 'qsm_language_support' ), 10, 3 );
}
+ /**
+ * Calls all class functions to check if quiz is setup properly
+ *
+ * @param int $quiz_id The ID of the quiz or survey to load.
+ * @return array An array which contains boolean result of has_proper_quiz, message and/or qmn_quiz_options
+ */
+ public function has_proper_quiz( $quiz_id ) {
+ if ( empty( $quiz_id ) ) {
+ return array(
+ 'res' => false,
+ 'message' => __( 'Empty Quiz ID.', 'quiz-master-next' ),
+ );
+ }
+
+ $quiz_id = intval( $quiz_id );
+
+ // Tries to load quiz name to ensure this is a valid ID.
+ global $mlwQuizMasterNext, $qmn_allowed_visit, $qmn_json_data;
+ $qmn_json_data = array();
+ $qmn_allowed_visit = true;
+ if ( false === $this->prepare_quiz( $quiz_id ) ) {
+ return array(
+ 'res' => false,
+ 'message' => __( 'It appears that this quiz is not set up correctly.', 'quiz-master-next' ),
+ );
+ }
+
+ $has_result_id = ( ! isset( $_GET['result_id'] ) || '' === $_GET['result_id'] );
+
+ if ( $has_result_id ) {
+ global $mlw_qmn_quiz;
+ $mlw_qmn_quiz = $quiz_id;
+ }
+
+ $qmn_quiz_options = $mlwQuizMasterNext->quiz_settings->get_quiz_options();
+
+ if ( $has_result_id ) {
+ /**
+ * Filter Quiz Options before Quiz Display
+ */
+ $qmn_quiz_options = apply_filters( 'qsm_shortcode_quiz_options', $qmn_quiz_options );
+ }
+
+ // If quiz options isn't found, stop function.
+ if ( is_null( $qmn_quiz_options ) || ( ! empty( $qmn_quiz_options->deleted ) && 1 == $qmn_quiz_options->deleted ) ) {
+ return array(
+ 'res' => false,
+ 'message' => __( 'This quiz is no longer available.', 'quiz-master-next' ),
+ );
+ }
+
+ // If quiz options isn't found, stop function.
+ if ( is_null( $qmn_quiz_options ) || empty( $qmn_quiz_options->quiz_name ) ) {
+ return array(
+ 'res' => false,
+ 'message' => __( 'It appears that this quiz is not set up correctly.', 'quiz-master-next' ),
+ );
+ }
+
+ return array(
+ 'res' => true,
+ 'message' => __( 'Quiz is setup properly.', 'quiz-master-next' ),
+ 'qmn_quiz_options' => $qmn_quiz_options,
+ );
+ }
+
/**
* Calls all class functions to initialize quiz
*
diff --git a/php/classes/class-qmn-quiz-manager.php b/php/classes/class-qmn-quiz-manager.php
index 79495d8be..b9abf6369 100644
--- a/php/classes/class-qmn-quiz-manager.php
+++ b/php/classes/class-qmn-quiz-manager.php
@@ -331,6 +331,7 @@ public function qsm_clear_audit_data() {
* @return string The content for the shortcode
*/
public function display_shortcode( $atts ) {
+ global $wpdb, $mlwQuizMasterNext;
$shortcode_args = shortcode_atts(
array(
'quiz' => 0,
@@ -338,22 +339,25 @@ public function display_shortcode( $atts ) {
),
$atts
);
+
+ // Quiz ID.
$quiz = intval( $shortcode_args['quiz'] );
$question_amount = intval( $shortcode_args['question_amount'] );
+ // Check, if quiz is setup properly.
+ $has_proper_quiz = $mlwQuizMasterNext->pluginHelper->has_proper_quiz( $quiz );
+ if ( false === $has_proper_quiz['res'] ) {
+ return $has_proper_quiz['message'];
+ }
+
+ $qmn_quiz_options = $has_proper_quiz['qmn_quiz_options'];
+ $return_display = '';
+
ob_start();
- global $wpdb, $mlwQuizMasterNext;
if ( isset( $_GET['result_id'] ) && '' !== $_GET['result_id'] ) {
$result_unique_id = sanitize_text_field( wp_unslash( $_GET['result_id'] ) );
$result = $wpdb->get_row( $wpdb->prepare( "SELECT `result_id`, `quiz_id` FROM {$wpdb->prefix}mlw_results WHERE unique_id = %s", $result_unique_id ), ARRAY_A );
if ( ! empty( $result ) && isset( $result['result_id'] ) ) {
- $mlwQuizMasterNext->pluginHelper->prepare_quiz( $result['quiz_id'] );
- $qmn_quiz_options = $mlwQuizMasterNext->quiz_settings->get_quiz_options();
-
- // If quiz options isn't found, stop function.
- if ( is_null( $qmn_quiz_options ) || 1 == $qmn_quiz_options->deleted ) {
- return __( 'This quiz is no longer available.', 'quiz-master-next' );
- }
wp_enqueue_style( 'qmn_quiz_common_style', $this->common_css, array(), $mlwQuizMasterNext->version );
wp_style_add_data( 'qmn_quiz_common_style', 'rtl', 'replace' );
@@ -376,35 +380,8 @@ public function display_shortcode( $atts ) {
}
$return_display .= ob_get_clean();
} else {
- global $qmn_allowed_visit;
- global $qmn_json_data;
- $qmn_json_data = array();
- $qmn_allowed_visit = true;
- $success = $mlwQuizMasterNext->pluginHelper->prepare_quiz( $quiz );
- if ( false === $success ) {
- return __( 'It appears that this quiz is not set up correctly', 'quiz-master-next' );
- }
-
- global $mlw_qmn_quiz;
- $mlw_qmn_quiz = $quiz;
- $return_display = '';
- $qmn_quiz_options = $mlwQuizMasterNext->quiz_settings->get_quiz_options();
- // Legacy variable.
- /**
- * Filter Quiz Options before Quiz Display
- */
- $qmn_quiz_options = apply_filters( 'qsm_shortcode_quiz_options', $qmn_quiz_options );
-
- // If quiz options isn't found, stop function.
- if ( is_null( $qmn_quiz_options ) || 1 == $qmn_quiz_options->deleted ) {
- return __( 'This quiz is no longer available.', 'quiz-master-next' );
- }
-
- // If quiz options isn't found, stop function.
- if ( is_null( $qmn_quiz_options ) || empty( $qmn_quiz_options->quiz_name ) ) {
- return __( 'It appears that this quiz is not set up correctly', 'quiz-master-next' );
- }
-
+ global $qmn_allowed_visit, $qmn_json_data, $mlw_qmn_quiz;
+
// Loads Quiz Template.
wp_enqueue_style( 'qmn_quiz_animation_style', QSM_PLUGIN_CSS_URL . '/animate.css', array(), $mlwQuizMasterNext->version );
wp_enqueue_style( 'qmn_quiz_common_style', $this->common_css, array(), $mlwQuizMasterNext->version );
@@ -1935,6 +1912,7 @@ public function submit_results( $qmn_quiz_options, $qmn_array_for_variables ) {
$result_display .= $this->display_social( $qmn_quiz_options, $qmn_array_for_variables );
$result_display = apply_filters( 'qmn_after_social_media', $result_display, $qmn_quiz_options, $qmn_array_for_variables );
+ $qmn_quiz_options = apply_filters( 'qmn_retake_quiz_button_before', $qmn_quiz_options );
if ( 1 == $qmn_quiz_options->enable_retake_quiz_button ) {
$result_display .= '