Version Description
(May 19, 2019) = * Closed Bug: Duplicate post issue (Issue #758) * Closed Enhancement: Option to turn off autofill (WP Issue) * Added Feature: Preview quiz within the quiz edit page. * Added Feature: Auto save quiz and questions * Closed Enhancement: Disable autofill for contact fields (Issue #718) * Closed Enhancement: Added %POLL_RESULTS_X% tag for results page to show poll results (Issue #458) * Closed Bug: Facebook Share not working properly (WP Issue)
Download this release
Release Info
Developer | quizsurvey |
Plugin | Quiz And Survey Master (Formerly Quiz Master Next) |
Version | 6.3.1 |
Comparing to | |
See all releases |
Code changes from version 6.3.0 to 6.3.1
- js/qsm-admin-contact.js +5 -3
- js/qsm-admin-question.js +11 -0
- js/qsm-quiz.js +1 -1
- mlw_quizmaster2.php +4 -4
- php/admin/options-page-questions-tab.php +8 -1
- php/admin/options-page-results-page-tab.php +3 -0
- php/admin/quiz-options-page.php +29 -0
- php/classes/class-qmn-quiz-creator.php +22 -0
- php/classes/class-qmn-quiz-manager.php +1515 -1512
- php/classes/class-qsm-contact-manager.php +10 -8
- php/classes/class-qsm-install.php +19 -0
- php/question-types.php +7 -3
- php/rest-api.php +3 -1
- php/template-variables.php +54 -0
- readme.txt +12 -2
js/qsm-admin-contact.js
CHANGED
@@ -6,9 +6,11 @@ var QSMContact;
|
|
6 |
(function ($) {
|
7 |
QSMContact = {
|
8 |
load : function() {
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
12 |
},
|
13 |
addField : function( fieldArray ) {
|
14 |
var contactField = $( '<div class="contact-form-field new">' +
|
6 |
(function ($) {
|
7 |
QSMContact = {
|
8 |
load : function() {
|
9 |
+
if(qsmContactObject.contactForm.length > 0){
|
10 |
+
$.each( qsmContactObject.contactForm, function( i, val ) {
|
11 |
+
QSMContact.addField( val );
|
12 |
+
});
|
13 |
+
}
|
14 |
},
|
15 |
addField : function( fieldArray ) {
|
16 |
var contactField = $( '<div class="contact-form-field new">' +
|
js/qsm-admin-question.js
CHANGED
@@ -243,6 +243,7 @@ var QSMQuestion;
|
|
243 |
var comments = $( "#comments" ).val();
|
244 |
var required = $( "#required" ).val();
|
245 |
var category = $( ".category-radio:checked" ).val();
|
|
|
246 |
if ( 'new_category' == category ) {
|
247 |
category = $( '#new_category' ).val();
|
248 |
}
|
@@ -280,6 +281,7 @@ var QSMQuestion;
|
|
280 |
required: required,
|
281 |
answers: answers,
|
282 |
answer_editor: answerType,
|
|
|
283 |
},
|
284 |
{
|
285 |
headers: { 'X-WP-Nonce': qsmQuestionSettings.nonce },
|
@@ -338,6 +340,11 @@ var QSMQuestion;
|
|
338 |
if( answerEditor === null || typeof answerEditor === "undefined" ){
|
339 |
answerEditor = 'text';
|
340 |
}
|
|
|
|
|
|
|
|
|
|
|
341 |
var al = 0;
|
342 |
_.each( answers, function( answer ) {
|
343 |
answer.push(al + 1);
|
@@ -351,8 +358,10 @@ var QSMQuestion;
|
|
351 |
$( "#question_type" ).val( question.get( 'type' ) );
|
352 |
$( "#comments" ).val( question.get( 'comments' ) );
|
353 |
$( "#required" ).val( question.get( 'required' ) );
|
|
|
354 |
$( "#change-answer-editor" ).val( answerEditor );
|
355 |
$( ".category-radio" ).removeAttr( 'checked' );
|
|
|
356 |
if ( 0 !== question.get( 'category' ).length ) {
|
357 |
$( ".category-radio" ).val( [question.get( 'category' )] );
|
358 |
}
|
@@ -412,6 +421,7 @@ var QSMQuestion;
|
|
412 |
event.preventDefault();
|
413 |
$( this ).parents( '.question' ).remove();
|
414 |
QSMQuestion.countTotal();
|
|
|
415 |
});
|
416 |
$( '.questions' ).on( 'click', '.delete-page-button', function( event ) {
|
417 |
event.preventDefault();
|
@@ -424,6 +434,7 @@ var QSMQuestion;
|
|
424 |
$( '#save-popup-button' ).on( 'click', function( event ) {
|
425 |
event.preventDefault();
|
426 |
QSMQuestion.saveQuestion( $( this ).parent().siblings( 'main' ).children( '#edit_question_id' ).val() );
|
|
|
427 |
});
|
428 |
$( '#new-answer-button' ).on( 'click', function( event ) {
|
429 |
event.preventDefault();
|
243 |
var comments = $( "#comments" ).val();
|
244 |
var required = $( "#required" ).val();
|
245 |
var category = $( ".category-radio:checked" ).val();
|
246 |
+
var autofill = $( "#hide_autofill" ).val();
|
247 |
if ( 'new_category' == category ) {
|
248 |
category = $( '#new_category' ).val();
|
249 |
}
|
281 |
required: required,
|
282 |
answers: answers,
|
283 |
answer_editor: answerType,
|
284 |
+
autofill: autofill
|
285 |
},
|
286 |
{
|
287 |
headers: { 'X-WP-Nonce': qsmQuestionSettings.nonce },
|
340 |
if( answerEditor === null || typeof answerEditor === "undefined" ){
|
341 |
answerEditor = 'text';
|
342 |
}
|
343 |
+
//Check autofill setting
|
344 |
+
var disableAutofill = question.get( 'autofill' );
|
345 |
+
if( disableAutofill === null || typeof disableAutofill === "undefined" ){
|
346 |
+
disableAutofill = '0';
|
347 |
+
}
|
348 |
var al = 0;
|
349 |
_.each( answers, function( answer ) {
|
350 |
answer.push(al + 1);
|
358 |
$( "#question_type" ).val( question.get( 'type' ) );
|
359 |
$( "#comments" ).val( question.get( 'comments' ) );
|
360 |
$( "#required" ).val( question.get( 'required' ) );
|
361 |
+
$( "#hide_autofill" ).val( disableAutofill );
|
362 |
$( "#change-answer-editor" ).val( answerEditor );
|
363 |
$( ".category-radio" ).removeAttr( 'checked' );
|
364 |
+
$( "#edit-question-id" ).text('').text(questionID);
|
365 |
if ( 0 !== question.get( 'category' ).length ) {
|
366 |
$( ".category-radio" ).val( [question.get( 'category' )] );
|
367 |
}
|
421 |
event.preventDefault();
|
422 |
$( this ).parents( '.question' ).remove();
|
423 |
QSMQuestion.countTotal();
|
424 |
+
$('.save-page-button').trigger('click');
|
425 |
});
|
426 |
$( '.questions' ).on( 'click', '.delete-page-button', function( event ) {
|
427 |
event.preventDefault();
|
434 |
$( '#save-popup-button' ).on( 'click', function( event ) {
|
435 |
event.preventDefault();
|
436 |
QSMQuestion.saveQuestion( $( this ).parent().siblings( 'main' ).children( '#edit_question_id' ).val() );
|
437 |
+
$('.save-page-button').trigger('click');
|
438 |
});
|
439 |
$( '#new-answer-button' ).on( 'click', function( event ) {
|
440 |
event.preventDefault();
|
js/qsm-quiz.js
CHANGED
@@ -699,7 +699,7 @@ function qmnSocialShare( network, mlw_qmn_social_text, mlw_qmn_title, facebook_i
|
|
699 |
if ( network == 'facebook' ) {
|
700 |
url = "https://www.facebook.com/dialog/feed?" + "display=popup&" + "app_id="+facebook_id +
|
701 |
"&" + "link=" + pageUrlEncoded + "&" + "name=" + encodeURIComponent(mlw_qmn_social_text) +
|
702 |
-
"&" + "description=
|
703 |
}
|
704 |
if ( network == 'twitter' ) {
|
705 |
url = "https://twitter.com/intent/tweet?text=" + encodeURIComponent(mlw_qmn_social_text);
|
699 |
if ( network == 'facebook' ) {
|
700 |
url = "https://www.facebook.com/dialog/feed?" + "display=popup&" + "app_id="+facebook_id +
|
701 |
"&" + "link=" + pageUrlEncoded + "&" + "name=" + encodeURIComponent(mlw_qmn_social_text) +
|
702 |
+
"&" + "description=";
|
703 |
}
|
704 |
if ( network == 'twitter' ) {
|
705 |
url = "https://twitter.com/intent/tweet?text=" + encodeURIComponent(mlw_qmn_social_text);
|
mlw_quizmaster2.php
CHANGED
@@ -2,14 +2,14 @@
|
|
2 |
/**
|
3 |
* Plugin Name: Quiz And Survey Master
|
4 |
* Description: Easily and quickly add quizzes and surveys to your website.
|
5 |
-
* Version: 6.3.
|
6 |
* Author: QSM Team
|
7 |
* Author URI: https://quizandsurveymaster.com/
|
8 |
* Plugin URI: https://quizandsurveymaster.com/
|
9 |
* Text Domain: quiz-master-next
|
10 |
*
|
11 |
* @author QSM Team
|
12 |
-
* @version 6.3.
|
13 |
* @package QSM
|
14 |
*/
|
15 |
|
@@ -34,7 +34,7 @@ class MLWQuizMasterNext {
|
|
34 |
* @var string
|
35 |
* @since 4.0.0
|
36 |
*/
|
37 |
-
public $version = '6.3.
|
38 |
|
39 |
/**
|
40 |
* QSM Alert Manager Object
|
@@ -251,7 +251,7 @@ class MLWQuizMasterNext {
|
|
251 |
'label' => $plural_name,
|
252 |
'rewrite' => array( 'slug' => $cpt_slug ),
|
253 |
'has_archive' => $has_archive,
|
254 |
-
'supports' => array( 'title', 'author', 'comments' )
|
255 |
);
|
256 |
|
257 |
// Registers post type.
|
2 |
/**
|
3 |
* Plugin Name: Quiz And Survey Master
|
4 |
* Description: Easily and quickly add quizzes and surveys to your website.
|
5 |
+
* Version: 6.3.1
|
6 |
* Author: QSM Team
|
7 |
* Author URI: https://quizandsurveymaster.com/
|
8 |
* Plugin URI: https://quizandsurveymaster.com/
|
9 |
* Text Domain: quiz-master-next
|
10 |
*
|
11 |
* @author QSM Team
|
12 |
+
* @version 6.3.1
|
13 |
* @package QSM
|
14 |
*/
|
15 |
|
34 |
* @var string
|
35 |
* @since 4.0.0
|
36 |
*/
|
37 |
+
public $version = '6.3.1';
|
38 |
|
39 |
/**
|
40 |
* QSM Alert Manager Object
|
251 |
'label' => $plural_name,
|
252 |
'rewrite' => array( 'slug' => $cpt_slug ),
|
253 |
'has_archive' => $has_archive,
|
254 |
+
'supports' => array( 'title', 'author', 'comments', 'thumbnail' )
|
255 |
);
|
256 |
|
257 |
// Registers post type.
|
php/admin/options-page-questions-tab.php
CHANGED
@@ -119,7 +119,7 @@ function qsm_options_questions_tab_content() {
|
|
119 |
<div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close>
|
120 |
<div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-1-title">
|
121 |
<header class="qsm-popup__header">
|
122 |
-
|
123 |
<a class="qsm-popup__close" aria-label="Close modal" data-micromodal-close></a>
|
124 |
</header>
|
125 |
<main class="qsm-popup__content" id="modal-1-content">
|
@@ -184,6 +184,13 @@ function qsm_options_questions_tab_content() {
|
|
184 |
<input type="radio" name="category" class="category-radio" id="new_category_new" value="new_category"><label for="new_category_new">New: <input type='text' id='new_category' value='' /></label>
|
185 |
</div>
|
186 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
</div>
|
188 |
</main>
|
189 |
<footer class="qsm-popup__footer">
|
119 |
<div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close>
|
120 |
<div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-1-title">
|
121 |
<header class="qsm-popup__header">
|
122 |
+
<h2 class="qsm-popup__title" id="modal-1-title">Edit Question [ ID: <span id="edit-question-id"></span> ]</h2>
|
123 |
<a class="qsm-popup__close" aria-label="Close modal" data-micromodal-close></a>
|
124 |
</header>
|
125 |
<main class="qsm-popup__content" id="modal-1-content">
|
184 |
<input type="radio" name="category" class="category-radio" id="new_category_new" value="new_category"><label for="new_category_new">New: <input type='text' id='new_category' value='' /></label>
|
185 |
</div>
|
186 |
</div>
|
187 |
+
<div id="required_area" class="qsm-row">
|
188 |
+
<label><?php _e( 'Hide Autofill?', 'quiz-master-next' ); ?></label>
|
189 |
+
<select name="hide_autofill" id="hide_autofill">
|
190 |
+
<option value="0" selected="selected"><?php _e( 'No', 'quiz-master-next' ); ?></option>
|
191 |
+
<option value="1"><?php _e( 'Yes', 'quiz-master-next' ); ?></option>
|
192 |
+
</select>
|
193 |
+
</div>
|
194 |
</div>
|
195 |
</main>
|
196 |
<footer class="qsm-popup__footer">
|
php/admin/options-page-results-page-tab.php
CHANGED
@@ -114,6 +114,9 @@ function qsm_options_results_tab_content() {
|
|
114 |
<div class="template_variable">
|
115 |
<span class="template_name">%TWITTER_SHARE%</span> - <?php _e('Displays button to share on Twitter.', 'quiz-master-next'); ?>
|
116 |
</div>
|
|
|
|
|
|
|
117 |
<?php do_action('qmn_template_variable_list'); ?>
|
118 |
</div>
|
119 |
<div style="clear:both;"></div>
|
114 |
<div class="template_variable">
|
115 |
<span class="template_name">%TWITTER_SHARE%</span> - <?php _e('Displays button to share on Twitter.', 'quiz-master-next'); ?>
|
116 |
</div>
|
117 |
+
<div class="template_variable">
|
118 |
+
<span class="template_name">%POLL_RESULTS_X%</span> - <?php _e('X = Question ID Note: only supported for multiple choice answers', 'quiz-master-next'); ?>
|
119 |
+
</div>
|
120 |
<?php do_action('qmn_template_variable_list'); ?>
|
121 |
</div>
|
122 |
<div style="clear:both;"></div>
|
php/admin/quiz-options-page.php
CHANGED
@@ -64,6 +64,35 @@ function qsm_generate_quiz_options() {
|
|
64 |
<div class='mlw_quiz_options'>
|
65 |
<h1 style="display: inline-block;"><?php echo $quiz_name; ?></h1>
|
66 |
<a style="display: inline-block;margin-top: 10px;margin-bottom: 15px;margin-left: 10px;" hre="#" class="edit-quiz-name button button-primary">Edit Name</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
<?php
|
68 |
// Puts all output from tab into ob_get_contents below.
|
69 |
ob_start();
|
64 |
<div class='mlw_quiz_options'>
|
65 |
<h1 style="display: inline-block;"><?php echo $quiz_name; ?></h1>
|
66 |
<a style="display: inline-block;margin-top: 10px;margin-bottom: 15px;margin-left: 10px;" hre="#" class="edit-quiz-name button button-primary">Edit Name</a>
|
67 |
+
<?php
|
68 |
+
// Get quiz post based on quiz id
|
69 |
+
$args = array(
|
70 |
+
'posts_per_page' => 1,
|
71 |
+
'post_type' => 'quiz',
|
72 |
+
'meta_query' => array(
|
73 |
+
array(
|
74 |
+
'key' => 'quiz_id',
|
75 |
+
'value' => $quiz_id,
|
76 |
+
'compare' => '=',
|
77 |
+
),
|
78 |
+
),
|
79 |
+
);
|
80 |
+
$the_query = new WP_Query($args);
|
81 |
+
|
82 |
+
// The Loop
|
83 |
+
$post_permalink = '';
|
84 |
+
if ($the_query->have_posts()) {
|
85 |
+
while ($the_query->have_posts()) {
|
86 |
+
$the_query->the_post();
|
87 |
+
$post_permalink = get_the_permalink(get_the_ID());
|
88 |
+
}
|
89 |
+
/* Restore original Post Data */
|
90 |
+
wp_reset_postdata();
|
91 |
+
}
|
92 |
+
?>
|
93 |
+
<a style="text-decoration: none; position: relative; top: 9px; left: 5px;" target="_blank" href="<?php echo $post_permalink; ?>">
|
94 |
+
<span style="font-size: 30px;" class="dashicons dashicons-external"></span>
|
95 |
+
</a>
|
96 |
<?php
|
97 |
// Puts all output from tab into ob_get_contents below.
|
98 |
ob_start();
|
php/classes/class-qmn-quiz-creator.php
CHANGED
@@ -435,6 +435,11 @@ class QMNQuizCreator {
|
|
435 |
)
|
436 |
);
|
437 |
$mlw_new_id = $wpdb->insert_id;
|
|
|
|
|
|
|
|
|
|
|
438 |
if ( false != $results ) {
|
439 |
$current_user = wp_get_current_user();
|
440 |
$quiz_post = array(
|
@@ -516,12 +521,29 @@ class QMNQuizCreator {
|
|
516 |
'%d'
|
517 |
)
|
518 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
519 |
if ($question_results == false)
|
520 |
{
|
521 |
$mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0020'), 'error');
|
522 |
$mlwQuizMasterNext->log_manager->add("Error 0020", $wpdb->last_error.' from '.$wpdb->last_query, 0, 'error');
|
523 |
}
|
524 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
525 |
}
|
526 |
}
|
527 |
|
435 |
)
|
436 |
);
|
437 |
$mlw_new_id = $wpdb->insert_id;
|
438 |
+
|
439 |
+
//Update quiz settings
|
440 |
+
$update_quiz_settings = unserialize($mlw_qmn_duplicate_data->quiz_settings);
|
441 |
+
$update_pages = unserialize($update_quiz_settings['pages']);
|
442 |
+
|
443 |
if ( false != $results ) {
|
444 |
$current_user = wp_get_current_user();
|
445 |
$quiz_post = array(
|
521 |
'%d'
|
522 |
)
|
523 |
);
|
524 |
+
foreach ($update_pages as $pages_key => $pages_value) {
|
525 |
+
foreach ($pages_value as $pages_k_q => $page_q_id) {
|
526 |
+
if($page_q_id == $mlw_question->question_id){
|
527 |
+
$update_pages[$pages_key][$pages_k_q] = $wpdb->insert_id;
|
528 |
+
}
|
529 |
+
}
|
530 |
+
}
|
531 |
if ($question_results == false)
|
532 |
{
|
533 |
$mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0020'), 'error');
|
534 |
$mlwQuizMasterNext->log_manager->add("Error 0020", $wpdb->last_error.' from '.$wpdb->last_query, 0, 'error');
|
535 |
}
|
536 |
}
|
537 |
+
$update_quiz_settings['pages'] = serialize($update_pages);
|
538 |
+
$wpdb->update(
|
539 |
+
$wpdb->prefix . "mlw_quizzes",
|
540 |
+
array(
|
541 |
+
'quiz_settings' => serialize($update_quiz_settings),
|
542 |
+
),
|
543 |
+
array(
|
544 |
+
'quiz_id' => $mlw_new_id
|
545 |
+
)
|
546 |
+
);
|
547 |
}
|
548 |
}
|
549 |
|
php/classes/class-qmn-quiz-manager.php
CHANGED
@@ -4,9 +4,8 @@
|
|
4 |
*
|
5 |
* @package QSM
|
6 |
*/
|
7 |
-
|
8 |
-
|
9 |
-
exit;
|
10 |
}
|
11 |
|
12 |
/**
|
@@ -16,1420 +15,1431 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
16 |
*/
|
17 |
class QMNQuizManager {
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
if (window.qmn_quiz_data === undefined) {
|
122 |
window.qmn_quiz_data = new Object();
|
123 |
}
|
124 |
</script>";
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
window.qmn_quiz_data["' . $qmn_json_data["quiz_id"] . '"] = ' . json_encode(
|
146 |
</script>';
|
147 |
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
345 |
}
|
346 |
-
$quiz_display = apply_filters( 'qmn_end_quiz_form', $quiz_display, $options, $quiz_data );
|
347 |
-
$quiz_display .= '</form>';
|
348 |
-
$quiz_display .= '</div>';
|
349 |
-
|
350 |
-
$quiz_display = apply_filters( 'qmn_end_quiz', $quiz_display, $options, $quiz_data );
|
351 |
-
return $quiz_display;
|
352 |
-
}
|
353 |
-
|
354 |
-
/**
|
355 |
-
* Creates the pages of content for the quiz/survey
|
356 |
-
*
|
357 |
-
* @since 5.2.0
|
358 |
-
* @param array $options The settings for the quiz.
|
359 |
-
* @param array $quiz_data The array of quiz data.
|
360 |
-
* @return string The HTML for the pages
|
361 |
-
*/
|
362 |
-
public function display_pages( $options, $quiz_data ) {
|
363 |
-
global $mlwQuizMasterNext;
|
364 |
-
global $qmn_json_data;
|
365 |
-
ob_start();
|
366 |
-
$pages = $mlwQuizMasterNext->pluginHelper->get_quiz_setting( 'pages', array() );
|
367 |
-
$questions = QSM_Questions::load_questions_by_pages( $options->quiz_id );
|
368 |
-
$question_list = '';
|
369 |
-
$contact_fields = QSM_Contact_Manager::load_fields();
|
370 |
-
if ( count( $pages ) > 1 && ( ! empty( $options->message_before ) || ( 0 == $options->contact_info_location && $contact_fields ) ) ) {
|
371 |
-
$qmn_json_data['first_page'] = true;
|
372 |
-
$message_before = wpautop( htmlspecialchars_decode( $options->message_before, ENT_QUOTES ) );
|
373 |
-
$message_before = apply_filters( 'mlw_qmn_template_variable_quiz_page', $message_before, $quiz_data );
|
374 |
-
?>
|
375 |
-
<section class="qsm-page">
|
376 |
-
<div class="quiz_section quiz_begin">
|
377 |
-
<div class='qsm-before-message mlw_qmn_message_before'><?php echo $message_before; ?></div>
|
378 |
-
<?php
|
379 |
-
if ( 0 == $options->contact_info_location ) {
|
380 |
-
echo QSM_Contact_Manager::display_fields( $options );
|
381 |
-
}
|
382 |
-
?>
|
383 |
-
</div>
|
384 |
-
</section>
|
385 |
-
<?php
|
386 |
-
}
|
387 |
-
|
388 |
-
// If there is only one page.
|
389 |
-
if ( 1 == count( $pages ) ) {
|
390 |
-
?>
|
391 |
-
<section class="qsm-page">
|
392 |
-
<?php
|
393 |
-
if ( ! empty( $options->message_before ) || ( 0 == $options->contact_info_location && $contact_fields ) ) {
|
394 |
-
$qmn_json_data['first_page'] = false;
|
395 |
-
$message_before = wpautop( htmlspecialchars_decode( $options->message_before, ENT_QUOTES ) );
|
396 |
-
$message_before = apply_filters( 'mlw_qmn_template_variable_quiz_page', $message_before, $quiz_data );
|
397 |
-
?>
|
398 |
-
<div class="quiz_section quiz_begin">
|
399 |
-
<div class='qsm-before-message mlw_qmn_message_before'><?php echo $message_before; ?></div>
|
400 |
-
<?php
|
401 |
-
if ( 0 == $options->contact_info_location ) {
|
402 |
-
echo QSM_Contact_Manager::display_fields( $options );
|
403 |
-
}
|
404 |
-
?>
|
405 |
-
</div>
|
406 |
-
<?php
|
407 |
-
}
|
408 |
-
foreach ( $pages[0] as $question_id ) {
|
409 |
-
$question_list .= $question_id . 'Q';
|
410 |
-
$question = $questions[ $question_id ];
|
411 |
-
?>
|
412 |
-
<div class='quiz_section question-section-id-<?php echo esc_attr( $question_id ); ?>'>
|
413 |
-
<?php
|
414 |
-
echo $mlwQuizMasterNext->pluginHelper->display_question( $question['question_type_new'], $question_id, $options );
|
415 |
-
if ( 0 == $question['comments'] ) {
|
416 |
-
echo "<input type='text' class='qsm-question-comment qsm-question-comment-small mlw_qmn_question_comment' x-webkit-speech id='mlwComment$question_id' name='mlwComment$question_id' value='" . esc_attr( htmlspecialchars_decode( $options->comment_field_text, ENT_QUOTES ) ) . "' onclick='qmnClearField(this)'/>";
|
417 |
-
}
|
418 |
-
if ( 2 == $question['comments'] ) {
|
419 |
-
echo "<textarea class='qsm-question-comment qsm-question-comment-large mlw_qmn_question_comment' id='mlwComment$question_id' name='mlwComment$question_id' onclick='qmnClearField(this)'>" . htmlspecialchars_decode( $options->comment_field_text, ENT_QUOTES ) . "</textarea>";
|
420 |
-
}
|
421 |
-
// Checks if a hint is entered.
|
422 |
-
if ( ! empty( $question['hints'] ) ) {
|
423 |
-
echo '<div title="' . esc_attr( htmlspecialchars_decode( $question['hints'], ENT_QUOTES ) ) . '" class="qsm-hint qsm_hint mlw_qmn_hint_link">' . $options->hint_text . '</div>';
|
424 |
-
}
|
425 |
-
?>
|
426 |
-
</div>
|
427 |
-
<?php
|
428 |
-
}
|
429 |
-
if ( 0 == $options->comment_section ) {
|
430 |
-
$message_comments = wpautop( htmlspecialchars_decode( $options->message_comment, ENT_QUOTES ) );
|
431 |
-
$message_comments = apply_filters( 'mlw_qmn_template_variable_quiz_page', $message_comments, $quiz_data );
|
432 |
-
?>
|
433 |
-
<div class="quiz_section quiz_begin">
|
434 |
-
<label for='mlwQuizComments' class='qsm-comments-label mlw_qmn_comment_section_text'><?php echo $message_comments; ?></label>
|
435 |
-
<textarea id='mlwQuizComments' name='mlwQuizComments' class='qsm-comments qmn_comment_section'></textarea>
|
436 |
-
</div>
|
437 |
-
<?php
|
438 |
-
}
|
439 |
-
if ( ! empty( $options->message_end_template ) || ( 1 == $options->contact_info_location && $contact_fields ) ) {
|
440 |
-
$message_after = wpautop( htmlspecialchars_decode( $options->message_end_template, ENT_QUOTES ) );
|
441 |
-
$message_after = apply_filters( 'mlw_qmn_template_variable_quiz_page', $message_after, $quiz_data );
|
442 |
-
?>
|
443 |
-
<div class="quiz_section">
|
444 |
-
<div class='qsm-after-message mlw_qmn_message_end'><?php echo $message_after; ?></div>
|
445 |
-
<?php
|
446 |
-
if ( 1 == $options->contact_info_location ) {
|
447 |
-
echo QSM_Contact_Manager::display_fields( $options );
|
448 |
-
}
|
449 |
-
?>
|
450 |
-
</div>
|
451 |
-
<?php
|
452 |
-
}
|
453 |
-
?>
|
454 |
-
</section>
|
455 |
-
<?php
|
456 |
-
} else {
|
457 |
-
foreach ( $pages as $page ) {
|
458 |
-
?>
|
459 |
-
<section class="qsm-page">
|
460 |
-
<?php
|
461 |
-
foreach ( $page as $question_id ) {
|
462 |
-
$question_list .= $question_id . 'Q';
|
463 |
-
$question = $questions[ $question_id ];
|
464 |
-
?>
|
465 |
-
<div class='quiz_section question-section-id-<?php echo esc_attr( $question_id ); ?>'>
|
466 |
-
<?php
|
467 |
-
echo $mlwQuizMasterNext->pluginHelper->display_question( $question['question_type_new'], $question_id, $options );
|
468 |
-
if ( 0 == $question['comments'] ) {
|
469 |
-
echo "<input type='text' class='qsm-question-comment qsm-question-comment-small mlw_qmn_question_comment' x-webkit-speech id='mlwComment$question_id' name='mlwComment$question_id' value='" . esc_attr( htmlspecialchars_decode( $options->comment_field_text, ENT_QUOTES ) ) . "' onclick='qmnClearField(this)'/>";
|
470 |
-
}
|
471 |
-
if ( 2 == $question['comments'] ) {
|
472 |
-
echo "<textarea class='qsm-question-comment qsm-question-comment-large mlw_qmn_question_comment' id='mlwComment$question_id' name='mlwComment$question_id' onclick='qmnClearField(this)'>" . htmlspecialchars_decode( $options->comment_field_text, ENT_QUOTES ) . "</textarea>";
|
473 |
-
}
|
474 |
-
// Checks if a hint is entered.
|
475 |
-
if ( ! empty( $question['hints'] ) ) {
|
476 |
-
echo '<div title="' . esc_attr( htmlspecialchars_decode( $question['hints'], ENT_QUOTES ) ) . '" class="qsm-hint qsm_hint mlw_qmn_hint_link">' . $options->hint_text . '</div>';
|
477 |
-
}
|
478 |
-
?>
|
479 |
-
</div>
|
480 |
-
<?php
|
481 |
-
}
|
482 |
-
?>
|
483 |
-
</section>
|
484 |
-
<?php
|
485 |
-
}
|
486 |
-
}
|
487 |
-
|
488 |
-
if ( count( $pages ) > 1 && 0 == $options->comment_section ) {
|
489 |
-
$message_comments = wpautop( htmlspecialchars_decode( $options->message_comment, ENT_QUOTES ) );
|
490 |
-
$message_comments = apply_filters( 'mlw_qmn_template_variable_quiz_page', $message_comments, $quiz_data );
|
491 |
-
?>
|
492 |
-
<section class="qsm-page">
|
493 |
-
<div class="quiz_section quiz_begin">
|
494 |
-
<label for='mlwQuizComments' class='qsm-comments-label mlw_qmn_comment_section_text'><?php echo $message_comments; ?></label>
|
495 |
-
<textarea id='mlwQuizComments' name='mlwQuizComments' class='qsm-comments qmn_comment_section'></textarea>
|
496 |
-
</div>
|
497 |
-
</section>
|
498 |
-
<?php
|
499 |
-
}
|
500 |
-
if ( count( $pages ) > 1 && ( ! empty( $options->message_end_template ) || ( 1 == $options->contact_info_location && $contact_fields ) ) ) {
|
501 |
-
$message_after = wpautop( htmlspecialchars_decode( $options->message_end_template, ENT_QUOTES ) );
|
502 |
-
$message_after = apply_filters( 'mlw_qmn_template_variable_quiz_page', $message_after, $quiz_data );
|
503 |
-
?>
|
504 |
-
<section class="qsm-page">
|
505 |
-
<div class="quiz_section">
|
506 |
-
<div class='qsm-after-message mlw_qmn_message_end'><?php echo $message_after; ?></div>
|
507 |
-
<?php
|
508 |
-
if ( 1 == $options->contact_info_location ) {
|
509 |
-
echo QSM_Contact_Manager::display_fields( $options );
|
510 |
-
}
|
511 |
-
?>
|
512 |
-
</div>
|
513 |
-
<?php
|
514 |
-
// Legacy code.
|
515 |
-
do_action( 'mlw_qmn_end_quiz_section' );
|
516 |
-
?>
|
517 |
-
</section>
|
518 |
-
<?php
|
519 |
-
}
|
520 |
-
?>
|
521 |
-
<!-- View for pagination -->
|
522 |
-
<script type="text/template" id="tmpl-qsm-pagination">
|
523 |
-
<div class="qsm-pagination qmn_pagination border margin-bottom">
|
524 |
-
<a class="qsm-btn qsm-previous qmn_btn mlw_qmn_quiz_link mlw_previous" href="#"><?php echo esc_html( $options->previous_button_text ); ?></a>
|
525 |
-
<span class="qmn_page_message"></span>
|
526 |
-
<div class="qmn_page_counter_message"></div>
|
527 |
-
<div id="qsm-progress-bar" style="display:none;"></div>
|
528 |
-
<a class="qsm-btn qsm-next qmn_btn mlw_qmn_quiz_link mlw_next" href="#"><?php echo esc_html( $options->next_button_text ); ?></a>
|
529 |
-
<input type='submit' class='qsm-btn qsm-submit-btn qmn_btn' value='<?php echo esc_attr( htmlspecialchars_decode( $options->submit_button_text, ENT_QUOTES ) ); ?>' />
|
530 |
-
</div>
|
531 |
-
</script>
|
532 |
-
<input type='hidden' name='qmn_question_list' value='<?php echo esc_attr( $question_list ); ?>' />
|
533 |
-
<?php
|
534 |
-
return ob_get_clean();
|
535 |
-
}
|
536 |
-
|
537 |
-
/**
|
538 |
-
* Creates Display For Beginning Section
|
539 |
-
*
|
540 |
-
* Generates the content for the beginning section of the quiz page
|
541 |
-
*
|
542 |
-
* @since 4.0.0
|
543 |
-
* @param array $qmn_quiz_options The database row of the quiz.
|
544 |
-
* @param array $qmn_array_for_variables The array of results for the quiz.
|
545 |
-
* @return string The content for the beginning section
|
546 |
-
* @deprecated 5.2.0 Use new page system instead
|
547 |
-
*/
|
548 |
-
public function display_begin_section( $qmn_quiz_options, $qmn_array_for_variables ) {
|
549 |
-
$section_display = '';
|
550 |
-
global $qmn_json_data;
|
551 |
-
$contact_fields = QSM_Contact_Manager::load_fields();
|
552 |
-
if ( ! empty( $qmn_quiz_options->message_before ) || ( 0 == $qmn_quiz_options->contact_info_location && $contact_fields ) ) {
|
553 |
-
$qmn_json_data["first_page"] = true;
|
554 |
-
global $mlw_qmn_section_count;
|
555 |
-
$mlw_qmn_section_count +=1;
|
556 |
-
$section_display .= "<div class='quiz_section quiz_begin slide$mlw_qmn_section_count'>";
|
557 |
-
|
558 |
-
$message_before = wpautop(htmlspecialchars_decode($qmn_quiz_options->message_before, ENT_QUOTES));
|
559 |
-
$message_before = apply_filters( 'mlw_qmn_template_variable_quiz_page', $message_before, $qmn_array_for_variables);
|
560 |
-
|
561 |
-
$section_display .= "<div class='mlw_qmn_message_before'>$message_before</div>";
|
562 |
-
if ( 0 == $qmn_quiz_options->contact_info_location ) {
|
563 |
-
$section_display .= QSM_Contact_Manager::display_fields( $qmn_quiz_options );
|
564 |
-
}
|
565 |
-
$section_display .= "</div>";
|
566 |
-
} else {
|
567 |
-
$qmn_json_data["first_page"] = false;
|
568 |
-
}
|
569 |
-
return $section_display;
|
570 |
-
}
|
571 |
-
|
572 |
-
/**
|
573 |
-
* Creates Display For Questions
|
574 |
-
*
|
575 |
-
* Generates the content for the questions part of the quiz page
|
576 |
-
*
|
577 |
-
* @since 4.0.0
|
578 |
-
* @param array $qmn_quiz_options The database row of the quiz.
|
579 |
-
* @param array $qmn_quiz_questions The questions of the quiz.
|
580 |
-
* @param array $qmn_quiz_answers The answers of the quiz.
|
581 |
-
* @uses QMNPluginHelper:display_question() Displays a question
|
582 |
-
* @return string The content for the questions section
|
583 |
-
* @deprecated 5.2.0 Use new page system instead
|
584 |
-
*/
|
585 |
-
public function display_questions( $qmn_quiz_options, $qmn_quiz_questions, $qmn_quiz_answers ) {
|
586 |
-
$question_display = '';
|
587 |
-
global $mlwQuizMasterNext;
|
588 |
-
global $qmn_total_questions;
|
589 |
-
global $mlw_qmn_section_count;
|
590 |
-
$question_id_list = '';
|
591 |
-
foreach ( $qmn_quiz_questions as $mlw_question ) {
|
592 |
-
$question_id_list .= $mlw_question->question_id."Q";
|
593 |
-
$mlw_qmn_section_count = $mlw_qmn_section_count + 1;
|
594 |
-
$question_display .= "<div class='quiz_section question-section-id-{$mlw_question->question_id} slide{$mlw_qmn_section_count}'>";
|
595 |
-
|
596 |
-
$question_display .= $mlwQuizMasterNext->pluginHelper->display_question( $mlw_question->question_type_new, $mlw_question->question_id, $qmn_quiz_options );
|
597 |
-
|
598 |
-
if ( 0 == $mlw_question->comments ) {
|
599 |
-
$question_display .= "<input type='text' class='mlw_qmn_question_comment' x-webkit-speech id='mlwComment".$mlw_question->question_id."' name='mlwComment".$mlw_question->question_id."' value='".esc_attr(htmlspecialchars_decode($qmn_quiz_options->comment_field_text, ENT_QUOTES))."' onclick='qmnClearField(this)'/>";
|
600 |
-
$question_display .= "<br />";
|
601 |
-
}
|
602 |
-
if ( 2 == $mlw_question->comments ) {
|
603 |
-
$question_display .= "<textarea cols='70' rows='5' class='mlw_qmn_question_comment' id='mlwComment".$mlw_question->question_id."' name='mlwComment".$mlw_question->question_id."' onclick='qmnClearField(this)'>".htmlspecialchars_decode($qmn_quiz_options->comment_field_text, ENT_QUOTES)."</textarea>";
|
604 |
-
$question_display .= "<br />";
|
605 |
-
}
|
606 |
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
$question_display .= "<input type='hidden' name='qmn_question_list' value='$question_id_list' />";
|
615 |
-
return $question_display;
|
616 |
-
}
|
617 |
-
|
618 |
-
/**
|
619 |
-
* Creates Display For Comment Section
|
620 |
-
*
|
621 |
-
* Generates the content for the comment section part of the quiz page
|
622 |
-
*
|
623 |
-
* @since 4.0.0
|
624 |
-
* @param array $qmn_quiz_options The database row of the quiz.
|
625 |
-
* @param array $qmn_array_for_variables The array of results for the quiz.
|
626 |
-
* @return string The content for the comment section
|
627 |
-
* @deprecated 5.2.0 Use new page system instead
|
628 |
-
*/
|
629 |
-
public function display_comment_section( $qmn_quiz_options, $qmn_array_for_variables ) {
|
630 |
-
global $mlw_qmn_section_count;
|
631 |
-
$comment_display = '';
|
632 |
-
if ( 0 == $qmn_quiz_options->comment_section ) {
|
633 |
-
$mlw_qmn_section_count = $mlw_qmn_section_count + 1;
|
634 |
-
$comment_display .= "<div class='quiz_section slide".$mlw_qmn_section_count."'>";
|
635 |
-
$message_comments = wpautop(htmlspecialchars_decode($qmn_quiz_options->message_comment, ENT_QUOTES));
|
636 |
-
$message_comments = apply_filters( 'mlw_qmn_template_variable_quiz_page', $message_comments, $qmn_array_for_variables);
|
637 |
-
$comment_display .= "<label for='mlwQuizComments' class='mlw_qmn_comment_section_text'>$message_comments</label><br />";
|
638 |
-
$comment_display .= "<textarea cols='60' rows='10' id='mlwQuizComments' name='mlwQuizComments' class='qmn_comment_section'></textarea>";
|
639 |
-
$comment_display .= "</div>";
|
640 |
-
}
|
641 |
-
return $comment_display;
|
642 |
-
}
|
643 |
-
|
644 |
-
/**
|
645 |
-
* Creates Display For End Section Of Quiz Page
|
646 |
-
*
|
647 |
-
* Generates the content for the end section of the quiz page
|
648 |
-
*
|
649 |
-
* @since 4.0.0
|
650 |
-
* @param array $qmn_quiz_options The database row of the quiz.
|
651 |
-
* @param array $qmn_array_for_variables The array of results for the quiz.
|
652 |
-
* @return string The content for the end section
|
653 |
-
* @deprecated 5.2.0 Use new page system instead
|
654 |
-
*/
|
655 |
-
public function display_end_section( $qmn_quiz_options, $qmn_array_for_variables ) {
|
656 |
-
global $mlw_qmn_section_count;
|
657 |
-
$section_display = '';
|
658 |
-
$section_display .= '<br />';
|
659 |
-
$mlw_qmn_section_count = $mlw_qmn_section_count + 1;
|
660 |
-
$section_display .= "<div class='quiz_section slide$mlw_qmn_section_count quiz_end'>";
|
661 |
-
if ( ! empty( $qmn_quiz_options->message_end_template ) ) {
|
662 |
-
$message_end = wpautop( htmlspecialchars_decode( $qmn_quiz_options->message_end_template, ENT_QUOTES ) );
|
663 |
-
$message_end = apply_filters( 'mlw_qmn_template_variable_quiz_page', $message_end, $qmn_array_for_variables );
|
664 |
-
$section_display .= "<span class='mlw_qmn_message_end'>$message_end</span>";
|
665 |
-
$section_display .= '<br /><br />';
|
666 |
-
}
|
667 |
-
if ( 1 == $qmn_quiz_options->contact_info_location ) {
|
668 |
-
$section_display .= QSM_Contact_Manager::display_fields( $qmn_quiz_options );
|
669 |
-
}
|
670 |
-
|
671 |
-
// Legacy Code.
|
672 |
-
ob_start();
|
673 |
-
do_action( 'mlw_qmn_end_quiz_section' );
|
674 |
-
$section_display .= ob_get_contents();
|
675 |
-
ob_end_clean();
|
676 |
-
|
677 |
-
$section_display .= "<input type='submit' class='qsm-btn qsm-submit-btn qmn_btn' value='" . esc_attr( htmlspecialchars_decode( $qmn_quiz_options->submit_button_text, ENT_QUOTES ) ) . "' />";
|
678 |
-
$section_display .= "</div>";
|
679 |
-
|
680 |
-
return $section_display;
|
681 |
-
}
|
682 |
-
|
683 |
-
/**
|
684 |
-
* Generates Content Results Page
|
685 |
-
*
|
686 |
-
* Generates the content for the results page part of the shortcode
|
687 |
-
*
|
688 |
-
* @since 4.0.0
|
689 |
-
* @param array $options The database row of the quiz.
|
690 |
-
* @param array $data The array of results for the quiz.
|
691 |
-
* @uses QMNQuizManager:submit_results() Perform The Quiz/Survey Submission
|
692 |
-
* @return string The content for the results page section
|
693 |
-
*/
|
694 |
-
public function display_results( $options, $data ) {
|
695 |
-
$result = $this->submit_results( $options, $data );
|
696 |
-
$results_array = $result;
|
697 |
-
return $results_array['display'];
|
698 |
-
}
|
699 |
-
|
700 |
-
/**
|
701 |
-
* Calls the results page from ajax
|
702 |
-
*
|
703 |
-
* @since 4.6.0
|
704 |
-
* @uses QMNQuizManager:submit_results() Perform The Quiz/Survey Submission
|
705 |
-
* @return string The content for the results page section
|
706 |
-
*/
|
707 |
-
public function ajax_submit_results() {
|
708 |
-
global $qmn_allowed_visit;
|
709 |
-
global $mlwQuizMasterNext;
|
710 |
-
parse_str( $_POST["quizData"], $_POST );
|
711 |
-
$qmn_allowed_visit = true;
|
712 |
-
$quiz = intval( $_POST["qmn_quiz_id"] );
|
713 |
-
$mlwQuizMasterNext->pluginHelper->prepare_quiz( $quiz );
|
714 |
-
$options = $mlwQuizMasterNext->quiz_settings->get_quiz_options();
|
715 |
-
$data = array(
|
716 |
-
'quiz_id' => $options->quiz_id,
|
717 |
-
'quiz_name' => $options->quiz_name,
|
718 |
-
'quiz_system' => $options->system,
|
719 |
-
'quiz_payment_id' => isset($_POST['main_payment_id']) ? $_POST['main_payment_id'] : ''
|
720 |
-
);
|
721 |
-
echo json_encode( $this->submit_results( $options, $data ) );
|
722 |
-
die();
|
723 |
-
}
|
724 |
-
|
725 |
-
/**
|
726 |
-
* Perform The Quiz/Survey Submission
|
727 |
-
*
|
728 |
-
* Prepares and save the results, prepares and send emails, prepare results page
|
729 |
-
*
|
730 |
-
* @since 4.6.0
|
731 |
-
* @param array $qmn_quiz_options The database row of the quiz.
|
732 |
-
* @param array $qmn_array_for_variables The array of results for the quiz.
|
733 |
-
* @uses QMNQuizManager:check_answers() Creates display for beginning section
|
734 |
-
* @uses QMNQuizManager:check_comment_section() Creates display for questions
|
735 |
-
* @uses QMNQuizManager:display_results_text() Creates display for end section
|
736 |
-
* @uses QMNQuizManager:display_social() Creates display for comment section
|
737 |
-
* @uses QMNQuizManager:send_user_email() Creates display for end section
|
738 |
-
* @uses QMNQuizManager:send_admin_email() Creates display for end section
|
739 |
-
* @return string The content for the results page section
|
740 |
-
*/
|
741 |
-
public function submit_results( $qmn_quiz_options, $qmn_array_for_variables ) {
|
742 |
-
global $qmn_allowed_visit;
|
743 |
-
$result_display = '';
|
744 |
-
|
745 |
-
$qmn_array_for_variables['user_ip'] = $this->get_user_ip();
|
746 |
-
|
747 |
-
$result_display = apply_filters( 'qmn_begin_results', $result_display, $qmn_quiz_options, $qmn_array_for_variables );
|
748 |
-
if ( ! $qmn_allowed_visit ) {
|
749 |
-
return $result_display;
|
750 |
-
}
|
751 |
-
|
752 |
-
// Gathers contact information.
|
753 |
-
$qmn_array_for_variables['user_name'] = 'None';
|
754 |
-
$qmn_array_for_variables['user_business'] = 'None';
|
755 |
-
$qmn_array_for_variables['user_email'] = 'None';
|
756 |
-
$qmn_array_for_variables['user_phone'] = 'None';
|
757 |
-
$contact_responses = QSM_Contact_Manager::process_fields( $qmn_quiz_options );
|
758 |
-
foreach ( $contact_responses as $field ) {
|
759 |
-
if ( isset( $field['use'] ) ) {
|
760 |
-
if ( 'name' === $field['use'] ) {
|
761 |
-
$qmn_array_for_variables['user_name'] = $field["value"];
|
762 |
-
}
|
763 |
-
if ( 'comp' === $field['use'] ) {
|
764 |
-
$qmn_array_for_variables['user_business'] = $field["value"];
|
765 |
-
}
|
766 |
-
if ( 'email' === $field['use'] ) {
|
767 |
-
$qmn_array_for_variables['user_email'] = $field["value"];
|
768 |
-
}
|
769 |
-
if ( 'phone' === $field['use'] ) {
|
770 |
-
$qmn_array_for_variables['user_phone'] = $field["value"];
|
771 |
-
}
|
772 |
-
}
|
773 |
-
}
|
774 |
-
|
775 |
-
$mlw_qmn_timer = isset($_POST["timer"]) ? intval( $_POST["timer"] ) : 0;
|
776 |
-
$qmn_array_for_variables['user_id'] = get_current_user_id();
|
777 |
-
$qmn_array_for_variables['timer'] = $mlw_qmn_timer;
|
778 |
-
$qmn_array_for_variables['time_taken'] = current_time( 'h:i:s A m/d/Y' );
|
779 |
-
$qmn_array_for_variables['contact'] = $contact_responses;
|
780 |
-
|
781 |
-
if ( !isset( $_POST["mlw_code_captcha"] ) || ( isset( $_POST["mlw_code_captcha"] ) && $_POST["mlw_user_captcha"] == $_POST["mlw_code_captcha"] ) ) {
|
782 |
-
|
783 |
-
$qmn_array_for_variables = array_merge( $qmn_array_for_variables, $this->check_answers( $qmn_quiz_options, $qmn_array_for_variables ) );
|
784 |
-
$result_display = apply_filters('qmn_after_check_answers', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
|
785 |
-
$qmn_array_for_variables['comments'] = $this->check_comment_section($qmn_quiz_options, $qmn_array_for_variables);
|
786 |
-
$result_display = apply_filters('qmn_after_check_comments', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
|
787 |
-
|
788 |
-
// Determines redirect/results page.
|
789 |
-
$results_pages = $this->display_results_text( $qmn_quiz_options, $qmn_array_for_variables );
|
790 |
-
$result_display .= $results_pages['display'];
|
791 |
-
$result_display = apply_filters('qmn_after_results_text', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
|
792 |
-
|
793 |
-
$result_display .= $this->display_social($qmn_quiz_options, $qmn_array_for_variables);
|
794 |
-
$result_display = apply_filters('qmn_after_social_media', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
|
795 |
-
|
796 |
-
// If the store responses in database option is set to Yes.
|
797 |
-
if ( 0 != $qmn_quiz_options->store_responses ) {
|
798 |
-
|
799 |
-
// Creates our results array.
|
800 |
-
$results_array = array(
|
801 |
-
intval( $qmn_array_for_variables['timer'] ),
|
802 |
-
$qmn_array_for_variables['question_answers_array'],
|
803 |
-
htmlspecialchars( stripslashes( $qmn_array_for_variables['comments'] ), ENT_QUOTES ),
|
804 |
-
'contact' => $contact_responses,
|
805 |
-
);
|
806 |
-
$results_array = apply_filters( 'qsm_results_array', $results_array, $qmn_array_for_variables );
|
807 |
-
$serialized_results = serialize( $results_array );
|
808 |
-
|
809 |
-
// Inserts the responses in the database.
|
810 |
-
global $wpdb;
|
811 |
-
$table_name = $wpdb->prefix . "mlw_results";
|
812 |
-
$results_insert = $wpdb->insert(
|
813 |
-
$table_name,
|
814 |
-
array(
|
815 |
-
'quiz_id' => $qmn_array_for_variables['quiz_id'],
|
816 |
-
'quiz_name' => $qmn_array_for_variables['quiz_name'],
|
817 |
-
'quiz_system' => $qmn_array_for_variables['quiz_system'],
|
818 |
-
'point_score' => $qmn_array_for_variables['total_points'],
|
819 |
-
'correct_score' => $qmn_array_for_variables['total_score'],
|
820 |
-
'correct' => $qmn_array_for_variables['total_correct'],
|
821 |
-
'total' => $qmn_array_for_variables['total_questions'],
|
822 |
-
'name' => $qmn_array_for_variables['user_name'],
|
823 |
-
'business' => $qmn_array_for_variables['user_business'],
|
824 |
-
'email' => $qmn_array_for_variables['user_email'],
|
825 |
-
'phone' => $qmn_array_for_variables['user_phone'],
|
826 |
-
'user' => $qmn_array_for_variables['user_id'],
|
827 |
-
'user_ip' => $qmn_array_for_variables['user_ip'],
|
828 |
-
'time_taken' => $qmn_array_for_variables['time_taken'],
|
829 |
-
'time_taken_real' => date( 'Y-m-d H:i:s', strtotime( $qmn_array_for_variables['time_taken'] ) ),
|
830 |
-
'quiz_results' => $serialized_results,
|
831 |
-
'deleted' => 0,
|
832 |
-
),
|
833 |
-
array(
|
834 |
-
'%d',
|
835 |
-
'%s',
|
836 |
-
'%d',
|
837 |
-
'%d',
|
838 |
-
'%d',
|
839 |
-
'%d',
|
840 |
-
'%d',
|
841 |
-
'%s',
|
842 |
-
'%s',
|
843 |
-
'%s',
|
844 |
-
'%s',
|
845 |
-
'%d',
|
846 |
-
'%s',
|
847 |
-
'%s',
|
848 |
-
'%s',
|
849 |
-
'%s',
|
850 |
-
'%d',
|
851 |
-
)
|
852 |
-
);
|
853 |
-
}
|
854 |
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
} else {
|
1059 |
-
$total_score = 0;
|
1060 |
-
}
|
1061 |
-
|
1062 |
-
// Return array to be merged with main user response array
|
1063 |
-
return array(
|
1064 |
-
'total_points' => $points_earned,
|
1065 |
-
'total_score' => $total_score,
|
1066 |
-
'total_correct' => $total_correct,
|
1067 |
-
'total_questions' => $total_questions,
|
1068 |
-
'question_answers_display' => '', // Kept for backwards compatibility
|
1069 |
-
'question_answers_array' => $question_data,
|
1070 |
-
);
|
1071 |
-
}
|
1072 |
-
|
1073 |
-
/**
|
1074 |
-
* Retrieves User's Comments
|
1075 |
-
*
|
1076 |
-
* Checks to see if the user left a comment and returns the comment
|
1077 |
-
*
|
1078 |
-
* @since 4.0.0
|
1079 |
-
* @param array $qmn_quiz_options The database row of the quiz
|
1080 |
-
* @param array $qmn_array_for_variables The array of results for the quiz
|
1081 |
-
* @return string The user's comments
|
1082 |
-
*/
|
1083 |
-
public function check_comment_section($qmn_quiz_options, $qmn_array_for_variables)
|
1084 |
-
{
|
1085 |
-
$qmn_quiz_comments = "";
|
1086 |
-
if ( isset( $_POST["mlwQuizComments"] ) ) {
|
1087 |
-
$qmn_quiz_comments = esc_textarea( stripslashes( $_POST["mlwQuizComments"] ) );
|
1088 |
-
}
|
1089 |
-
return apply_filters( 'qmn_returned_comments', $qmn_quiz_comments, $qmn_quiz_options, $qmn_array_for_variables );
|
1090 |
-
}
|
1091 |
-
|
1092 |
-
|
1093 |
-
/**
|
1094 |
-
* Displays Results Text
|
1095 |
-
*
|
1096 |
-
* @since 4.0.0
|
1097 |
-
* @deprecated 6.1.0 Use the newer results page class instead.
|
1098 |
-
* @param array $options The quiz settings.
|
1099 |
-
* @param array $response_data The array of results for the quiz.
|
1100 |
-
* @return string The contents for the results text
|
1101 |
-
*/
|
1102 |
-
public function display_results_text( $options, $response_data ) {
|
1103 |
-
return QSM_Results_Pages::generate_pages( $response_data );
|
1104 |
-
}
|
1105 |
-
|
1106 |
-
/**
|
1107 |
-
* Displays social media buttons
|
1108 |
-
*
|
1109 |
-
* @deprecated 6.1.0 Use the social media template variables instead.
|
1110 |
-
* @since 4.0.0
|
1111 |
-
* @param array $qmn_quiz_options The database row of the quiz.
|
1112 |
-
* @param array $qmn_array_for_variables The array of results for the quiz.
|
1113 |
-
* @return string The content of the social media button section
|
1114 |
-
*/
|
1115 |
-
public function display_social( $qmn_quiz_options, $qmn_array_for_variables ) {
|
1116 |
-
$social_display = '';
|
1117 |
-
if ( $qmn_quiz_options->social_media == 1 ) {
|
1118 |
-
$settings = (array) get_option( 'qmn-settings' );
|
1119 |
-
$facebook_app_id = '483815031724529';
|
1120 |
-
if ( isset( $settings['facebook_app_id'] ) ) {
|
1121 |
-
$facebook_app_id = esc_js( $settings['facebook_app_id'] );
|
1122 |
-
}
|
1123 |
|
1124 |
-
// Loads Social Media Text.
|
1125 |
-
$qmn_social_media_text = "";
|
1126 |
-
if ( is_serialized( $qmn_quiz_options->social_media_text ) && is_array( @unserialize( $qmn_quiz_options->social_media_text ) ) ) {
|
1127 |
-
$qmn_social_media_text = @unserialize($qmn_quiz_options->social_media_text);
|
1128 |
-
} else {
|
1129 |
-
$qmn_social_media_text = array(
|
1130 |
-
'twitter' => $qmn_quiz_options->social_media_text,
|
1131 |
-
'facebook' => $qmn_quiz_options->social_media_text,
|
1132 |
-
);
|
1133 |
-
}
|
1134 |
-
$qmn_social_media_text["twitter"] = apply_filters( 'mlw_qmn_template_variable_results_page', $qmn_social_media_text["twitter"], $qmn_array_for_variables);
|
1135 |
-
$qmn_social_media_text["facebook"] = apply_filters( 'mlw_qmn_template_variable_results_page', $qmn_social_media_text["facebook"], $qmn_array_for_variables);
|
1136 |
-
$social_display .= "<br />
|
1137 |
-
<a class=\"mlw_qmn_quiz_link\" onclick=\"qmnSocialShare('facebook', '".esc_js($qmn_social_media_text["facebook"])."', '".esc_js($qmn_quiz_options->quiz_name)."', '$facebook_app_id');\">Facebook</a>
|
1138 |
-
<a class=\"mlw_qmn_quiz_link\" onclick=\"qmnSocialShare('twitter', '".esc_js($qmn_social_media_text["twitter"])."', '".esc_js($qmn_quiz_options->quiz_name)."');\">Twitter</a>
|
1139 |
-
<br />";
|
1140 |
-
}
|
1141 |
-
return apply_filters( 'qmn_returned_social_buttons', $social_display, $qmn_quiz_options, $qmn_array_for_variables );
|
1142 |
-
}
|
1143 |
-
|
1144 |
-
/**
|
1145 |
-
* Send User Email
|
1146 |
-
*
|
1147 |
-
* Prepares the email to the user and then sends the email
|
1148 |
-
*
|
1149 |
-
* @deprecated 6.2.0 Use the newer QSM_Emails class instead.
|
1150 |
-
* @since 4.0.0
|
1151 |
-
* @param array $qmn_quiz_options The database row of the quiz
|
1152 |
-
* @param array $qmn_array_for_variables The array of results for the quiz
|
1153 |
-
*/
|
1154 |
-
public function send_user_email($qmn_quiz_options, $qmn_array_for_variables)
|
1155 |
-
{
|
1156 |
-
add_filter( 'wp_mail_content_type', 'mlw_qmn_set_html_content_type' );
|
1157 |
-
$mlw_message = "";
|
1158 |
-
|
1159 |
-
//Check if this quiz has user emails turned on
|
1160 |
-
if ( $qmn_quiz_options->send_user_email == "0" ) {
|
1161 |
-
|
1162 |
-
//Make sure that the user filled in the email field
|
1163 |
-
if ( $qmn_array_for_variables['user_email'] != "" ) {
|
1164 |
-
|
1165 |
-
//Prepare from email and name
|
1166 |
-
$from_email_array = maybe_unserialize( $qmn_quiz_options->email_from_text );
|
1167 |
-
if ( ! isset( $from_email_array["from_email"] ) ) {
|
1168 |
-
$from_email_array = array(
|
1169 |
-
'from_name' => $qmn_quiz_options->email_from_text,
|
1170 |
-
'from_email' => $qmn_quiz_options->admin_email,
|
1171 |
-
'reply_to' => 1
|
1172 |
-
);
|
1173 |
-
}
|
1174 |
-
|
1175 |
-
if ( ! is_email( $from_email_array["from_email"] ) ) {
|
1176 |
-
if ( is_email( $qmn_quiz_options->admin_email ) ) {
|
1177 |
-
$from_email_array["from_email"] = $qmn_quiz_options->admin_email;
|
1178 |
-
} else {
|
1179 |
-
$from_email_array["from_email"] = get_option( 'admin_email ', 'test@example.com' );
|
1180 |
-
}
|
1181 |
-
}
|
1182 |
-
|
1183 |
-
//Prepare email attachments
|
1184 |
-
$attachments = array();
|
1185 |
-
$attachments = apply_filters( 'qsm_user_email_attachments', $attachments, $qmn_array_for_variables );
|
1186 |
-
|
1187 |
-
if ( is_serialized( $qmn_quiz_options->user_email_template ) && is_array( @unserialize( $qmn_quiz_options->user_email_template ) ) ) {
|
1188 |
-
|
1189 |
-
$mlw_user_email_array = @unserialize( $qmn_quiz_options->user_email_template );
|
1190 |
-
|
1191 |
-
//Cycle through emails
|
1192 |
-
foreach( $mlw_user_email_array as $mlw_each ) {
|
1193 |
-
|
1194 |
-
//Generate Email Subject
|
1195 |
-
if ( !isset( $mlw_each[3] ) ) {
|
1196 |
-
$mlw_each[3] = "Quiz Results For %QUIZ_NAME";
|
1197 |
-
}
|
1198 |
-
$mlw_each[3] = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_each[3], $qmn_array_for_variables );
|
1199 |
-
|
1200 |
-
//Check to see if default
|
1201 |
-
if ( $mlw_each[0] == 0 && $mlw_each[1] == 0 ) {
|
1202 |
-
$mlw_message = htmlspecialchars_decode( $mlw_each[2], ENT_QUOTES );
|
1203 |
-
$mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $qmn_array_for_variables );
|
1204 |
-
$mlw_message = str_replace( "\n" , "<br>", $mlw_message );
|
1205 |
-
$mlw_message = str_replace( "<br/>" , "<br>", $mlw_message );
|
1206 |
-
$mlw_message = str_replace( "<br />" , "<br>", $mlw_message );
|
1207 |
-
$mlw_headers = 'From: '.$from_email_array["from_name"].' <'.$from_email_array["from_email"].'>' . "\r\n";
|
1208 |
-
wp_mail( $qmn_array_for_variables['user_email'], $mlw_each[3], $mlw_message, $mlw_headers, $attachments );
|
1209 |
-
break;
|
1210 |
-
} else {
|
1211 |
-
|
1212 |
-
//Check to see if this quiz uses points and check if the points earned falls in the point range for this email
|
1213 |
-
if ( $qmn_quiz_options->system == 1 && $qmn_array_for_variables['total_points'] >= $mlw_each[0] && $qmn_array_for_variables['total_points'] <= $mlw_each[1] ) {
|
1214 |
-
$mlw_message = htmlspecialchars_decode( $mlw_each[2], ENT_QUOTES );
|
1215 |
-
$mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $qmn_array_for_variables );
|
1216 |
-
$mlw_message = str_replace( "\n" , "<br>", $mlw_message );
|
1217 |
-
$mlw_message = str_replace( "<br/>" , "<br>", $mlw_message );
|
1218 |
-
$mlw_message = str_replace( "<br />" , "<br>", $mlw_message );
|
1219 |
-
$mlw_headers = 'From: '.$from_email_array["from_name"].' <'.$from_email_array["from_email"].'>' . "\r\n";
|
1220 |
-
wp_mail( $qmn_array_for_variables['user_email'], $mlw_each[3], $mlw_message, $mlw_headers, $attachments );
|
1221 |
-
break;
|
1222 |
-
}
|
1223 |
-
|
1224 |
-
//Check to see if score fall in correct range
|
1225 |
-
if ( $qmn_quiz_options->system == 0 && $qmn_array_for_variables['total_score'] >= $mlw_each[0] && $qmn_array_for_variables['total_score'] <= $mlw_each[1] ) {
|
1226 |
-
$mlw_message = htmlspecialchars_decode( $mlw_each[2], ENT_QUOTES );
|
1227 |
-
$mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $qmn_array_for_variables );
|
1228 |
-
$mlw_message = str_replace( "\n" , "<br>", $mlw_message );
|
1229 |
-
$mlw_message = str_replace( "<br/>" , "<br>", $mlw_message );
|
1230 |
-
$mlw_message = str_replace( "<br />" , "<br>", $mlw_message );
|
1231 |
-
$mlw_headers = 'From: '.$from_email_array["from_name"].' <'.$from_email_array["from_email"].'>' . "\r\n";
|
1232 |
-
wp_mail( $qmn_array_for_variables['user_email'], $mlw_each[3], $mlw_message, $mlw_headers, $attachments );
|
1233 |
-
break;
|
1234 |
-
}
|
1235 |
-
}
|
1236 |
-
}
|
1237 |
-
} else {
|
1238 |
-
|
1239 |
-
//Uses older email system still which was before different emails were created.
|
1240 |
-
$mlw_message = htmlspecialchars_decode( $qmn_quiz_options->user_email_template, ENT_QUOTES );
|
1241 |
-
$mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $qmn_array_for_variables );
|
1242 |
-
$mlw_message = str_replace( "\n" , "<br>", $mlw_message );
|
1243 |
-
$mlw_message = str_replace( "<br/>" , "<br>", $mlw_message );
|
1244 |
-
$mlw_message = str_replace( "<br />" , "<br>", $mlw_message );
|
1245 |
-
$mlw_headers = 'From: '.$from_email_array["from_name"].' <'.$from_email_array["from_email"].'>' . "\r\n";
|
1246 |
-
wp_mail( $qmn_array_for_variables['user_email'], "Quiz Results For ".$qmn_quiz_options->quiz_name, $mlw_message, $mlw_headers, $attachments );
|
1247 |
-
}
|
1248 |
-
}
|
1249 |
-
}
|
1250 |
-
remove_filter( 'wp_mail_content_type', 'mlw_qmn_set_html_content_type' );
|
1251 |
-
}
|
1252 |
-
|
1253 |
-
/**
|
1254 |
-
* Send Admin Email
|
1255 |
-
*
|
1256 |
-
* Prepares the email to the admin and then sends the email
|
1257 |
-
*
|
1258 |
-
* @deprecated 6.2.0 Use the newer QSM_Emails class instead.
|
1259 |
-
* @since 4.0.0
|
1260 |
-
* @param array $qmn_quiz_options The database row of the quiz
|
1261 |
-
* @param arrar $qmn_array_for_variables The array of results for the quiz
|
1262 |
-
*/
|
1263 |
-
public function send_admin_email($qmn_quiz_options, $qmn_array_for_variables)
|
1264 |
-
{
|
1265 |
-
//Switch email type to HTML
|
1266 |
-
add_filter( 'wp_mail_content_type', 'mlw_qmn_set_html_content_type' );
|
1267 |
-
|
1268 |
-
$mlw_message = "";
|
1269 |
-
if ( $qmn_quiz_options->send_admin_email == "0" ) {
|
1270 |
-
if ( $qmn_quiz_options->admin_email != "" ) {
|
1271 |
-
$from_email_array = maybe_unserialize( $qmn_quiz_options->email_from_text );
|
1272 |
-
if ( ! isset( $from_email_array["from_email"] ) ) {
|
1273 |
-
$from_email_array = array(
|
1274 |
-
'from_name' => $qmn_quiz_options->email_from_text,
|
1275 |
-
'from_email' => $qmn_quiz_options->admin_email,
|
1276 |
-
'reply_to' => 1
|
1277 |
-
);
|
1278 |
-
}
|
1279 |
-
|
1280 |
-
if ( ! is_email( $from_email_array["from_email"] ) ) {
|
1281 |
-
if ( is_email( $qmn_quiz_options->admin_email ) ) {
|
1282 |
-
$from_email_array["from_email"] = $qmn_quiz_options->admin_email;
|
1283 |
-
} else {
|
1284 |
-
$from_email_array["from_email"] = get_option( 'admin_email ', 'test@example.com' );
|
1285 |
-
}
|
1286 |
-
}
|
1287 |
-
|
1288 |
-
$mlw_message = "";
|
1289 |
-
$mlw_subject = "";
|
1290 |
-
if (is_serialized($qmn_quiz_options->admin_email_template) && is_array(@unserialize($qmn_quiz_options->admin_email_template)))
|
1291 |
-
{
|
1292 |
-
$mlw_admin_email_array = @unserialize($qmn_quiz_options->admin_email_template);
|
1293 |
-
|
1294 |
-
//Cycle through landing pages
|
1295 |
-
foreach($mlw_admin_email_array as $mlw_each)
|
1296 |
-
{
|
1297 |
-
|
1298 |
-
//Generate Email Subject
|
1299 |
-
if (!isset($mlw_each["subject"]))
|
1300 |
-
{
|
1301 |
-
$mlw_each["subject"] = "Quiz Results For %QUIZ_NAME";
|
1302 |
-
}
|
1303 |
-
$mlw_each["subject"] = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_each["subject"], $qmn_array_for_variables);
|
1304 |
-
|
1305 |
-
//Check to see if default
|
1306 |
-
if ($mlw_each["begin_score"] == 0 && $mlw_each["end_score"] == 0)
|
1307 |
-
{
|
1308 |
-
$mlw_message = htmlspecialchars_decode($mlw_each["message"], ENT_QUOTES);
|
1309 |
-
$mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $qmn_array_for_variables);
|
1310 |
-
$mlw_message = str_replace( "\n" , "<br>", $mlw_message);
|
1311 |
-
$mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
|
1312 |
-
$mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
|
1313 |
-
$mlw_subject = $mlw_each["subject"];
|
1314 |
-
break;
|
1315 |
-
}
|
1316 |
-
else
|
1317 |
-
{
|
1318 |
-
//Check to see if points fall in correct range
|
1319 |
-
if ($qmn_quiz_options->system == 1 && $qmn_array_for_variables['total_points'] >= $mlw_each["begin_score"] && $qmn_array_for_variables['total_points'] <= $mlw_each["end_score"])
|
1320 |
-
{
|
1321 |
-
$mlw_message = htmlspecialchars_decode($mlw_each["message"], ENT_QUOTES);
|
1322 |
-
$mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $qmn_array_for_variables);
|
1323 |
-
$mlw_message = str_replace( "\n" , "<br>", $mlw_message);
|
1324 |
-
$mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
|
1325 |
-
$mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
|
1326 |
-
$mlw_subject = $mlw_each["subject"];
|
1327 |
-
break;
|
1328 |
-
}
|
1329 |
-
|
1330 |
-
//Check to see if score fall in correct range
|
1331 |
-
if ($qmn_quiz_options->system == 0 && $qmn_array_for_variables['total_score'] >= $mlw_each["begin_score"] && $qmn_array_for_variables['total_score'] <= $mlw_each["end_score"])
|
1332 |
-
{
|
1333 |
-
$mlw_message = htmlspecialchars_decode($mlw_each["message"], ENT_QUOTES);
|
1334 |
-
$mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $qmn_array_for_variables);
|
1335 |
-
$mlw_message = str_replace( "\n" , "<br>", $mlw_message);
|
1336 |
-
$mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
|
1337 |
-
$mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
|
1338 |
-
$mlw_subject = $mlw_each["subject"];
|
1339 |
-
break;
|
1340 |
-
}
|
1341 |
-
}
|
1342 |
-
}
|
1343 |
-
}
|
1344 |
-
else
|
1345 |
-
{
|
1346 |
-
$mlw_message = htmlspecialchars_decode($qmn_quiz_options->admin_email_template, ENT_QUOTES);
|
1347 |
-
$mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $qmn_array_for_variables);
|
1348 |
-
$mlw_message = str_replace( "\n" , "<br>", $mlw_message);
|
1349 |
-
$mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
|
1350 |
-
$mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
|
1351 |
-
$mlw_subject = "Quiz Results For ".$qmn_quiz_options->quiz_name;
|
1352 |
-
}
|
1353 |
-
}
|
1354 |
-
if ( get_option('mlw_advert_shows') == 'true' ) {$mlw_message .= "<br>This email was generated by the Quiz And Survey Master plugin";}
|
1355 |
-
$headers = array(
|
1356 |
-
'From: '.$from_email_array["from_name"].' <'.$from_email_array["from_email"].'>'
|
1357 |
-
);
|
1358 |
-
if ( $from_email_array["reply_to"] == 0 ) {
|
1359 |
-
$headers[] = 'Reply-To: '.$qmn_array_for_variables["user_name"]." <".$qmn_array_for_variables["user_email"].">";
|
1360 |
-
}
|
1361 |
-
$admin_emails = explode( ",", $qmn_quiz_options->admin_email );
|
1362 |
-
foreach( $admin_emails as $admin_email ) {
|
1363 |
-
if ( is_email( $admin_email ) ) {
|
1364 |
-
wp_mail( $admin_email, $mlw_subject, $mlw_message, $headers );
|
1365 |
-
}
|
1366 |
-
}
|
1367 |
-
}
|
1368 |
-
|
1369 |
-
//Remove HTML type for emails
|
1370 |
-
remove_filter( 'wp_mail_content_type', 'mlw_qmn_set_html_content_type' );
|
1371 |
-
}
|
1372 |
-
|
1373 |
-
/**
|
1374 |
-
* Returns the quiz taker's IP if IP collection is enabled
|
1375 |
-
*
|
1376 |
-
* @since 5.3.0
|
1377 |
-
* @return string The IP address or a phrase if not collected
|
1378 |
-
*/
|
1379 |
-
private function get_user_ip() {
|
1380 |
-
$ip = __( 'Not collected', 'quiz-master-next' );
|
1381 |
-
$settings = (array) get_option( 'qmn-settings' );
|
1382 |
-
$ip_collection = '0';
|
1383 |
-
if ( isset( $settings['ip_collection'] ) ) {
|
1384 |
-
$ip_collection = $settings['ip_collection'];
|
1385 |
-
}
|
1386 |
-
if ( '1' != $ip_collection ) {
|
1387 |
-
if ( $_SERVER['REMOTE_ADDR'] ) {
|
1388 |
-
$ip = $_SERVER['REMOTE_ADDR'];
|
1389 |
-
} else {
|
1390 |
-
$ip = __( 'Unknown', 'quiz-master-next' );
|
1391 |
-
}
|
1392 |
-
}
|
1393 |
-
return $ip;
|
1394 |
-
}
|
1395 |
}
|
|
|
1396 |
global $qmnQuizManager;
|
1397 |
$qmnQuizManager = new QMNQuizManager();
|
1398 |
|
1399 |
add_filter('qmn_begin_shortcode', 'qmn_require_login_check', 10, 3);
|
1400 |
-
|
1401 |
-
{
|