Quiz And Survey Master (Formerly Quiz Master Next) - Version 6.0.3

Version Description

Upgrade for several bug fixes

Download this release

Release Info

Developer fpcorso
Plugin Icon 128x128 Quiz And Survey Master (Formerly Quiz Master Next)
Version 6.0.3
Comparing to
See all releases

Code changes from version 6.0.2 to 6.0.3

ISSUE_TEMPLATE.md CHANGED
@@ -1,8 +1,17 @@
 
 
1
  Please provide the following information when creating your issues:
2
 
 
 
 
 
 
3
  ## General description
4
  If this is a bug, give a general description of what you are experiencing. If this is a feature request, include what the feature is that you are requesting.
5
 
 
 
6
  ## Expected behavior
7
  If you are reporting a bug, please describe what you are expecting the plugin to do. If this is a feature request, delete this section.
8
 
1
+ **IF YOU DO NOT FOLLOW THIS TEMPLATE, YOUR ISSUE MAY BE CLOSED!!**
2
+
3
  Please provide the following information when creating your issues:
4
 
5
+ ## Site Info
6
+ WordPress Version:
7
+ QSM Version:
8
+ Browser:
9
+
10
  ## General description
11
  If this is a bug, give a general description of what you are experiencing. If this is a feature request, include what the feature is that you are requesting.
12
 
13
+ Link to quiz or screenshot (if relevant):
14
+
15
  ## Expected behavior
16
  If you are reporting a bug, please describe what you are expecting the plugin to do. If this is a feature request, delete this section.
17
 
js/{qmn_quiz.js → qsm-quiz.js} RENAMED
@@ -34,44 +34,177 @@ var QSM;
34
  initTimer: function( quizID ) {
35
 
36
  // Gets our form
37
- $quizForm = QSM.getQuizForm( quizID );
 
 
 
38
 
39
  // If we are using the newer pagination system...
40
  if ( 0 < $quizForm.children( '.qsm-page' ).length ) {
41
  // If there is a first page...
42
  if ( qmn_quiz_data[quizID].hasOwnProperty('first_page') && qmn_quiz_data[quizID].first_page ) {
43
  // ... attach an event handler to the click event to activate the timer.
44
- jQuery( '#quizForm' + quizID ).closest( '.qmn_quiz_container' ).find( '.mlw_next' ).on( 'click', function(event) {
45
  event.preventDefault();
46
- if ( !qmn_timer_activated && qmnValidatePage( 'quizForm' + quizID ) ) {
47
- qmnActivateTimer( quizID );
48
  }
49
  });
50
  // ...else, activate the timer on page load.
51
  } else {
52
- qmnActivateTimer( quizID );
53
  }
54
  // ...else, we must be using the questions per page option.
55
  } else {
56
  if ( qmn_quiz_data[quizID].hasOwnProperty('pagination') && qmn_quiz_data[quizID].first_page ) {
57
- jQuery( '#quizForm' + quizID ).closest( '.qmn_quiz_container' ).find( '.mlw_next' ).on( 'click', function(event) {
58
  event.preventDefault();
59
- if ( !qmn_timer_activated && ( 0 == $( '.quiz_begin:visible' ).length || ( 1 == $( '.quiz_begin:visible' ).length && qmnValidatePage( 'quizForm' + quizID ) ) ) ) {
60
- qmnActivateTimer( quizID );
61
  }
62
  });
63
  } else {
64
- qmnActivateTimer( quizID );
65
  }
66
  }
67
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  /**
69
  * Sets up pagination for a quiz
70
  *
71
  * @param int quizID The ID of the quiz.
72
  */
73
  initPagination: function( quizID ) {
74
- $quizForm = QSM.getQuizForm( quizID );
75
  if ( 0 < $quizForm.children( '.qsm-page' ).length ) {
76
  $quizForm.children( '.qsm-page' ).hide();
77
  template = wp.template( 'qsm-pagination' );
@@ -205,8 +338,7 @@ var QSM;
205
  }(jQuery));
206
 
207
  // Global Variables
208
- var qmn_timer_activated = false;
209
- var qsmTitleText = window.document.title;
210
 
211
  function qmnTimeTakenTimer() {
212
  var x = +jQuery( '#timer' ).val();
@@ -260,8 +392,7 @@ function qmnValidation( element, quiz_form_id ) {
260
  result = false;
261
  }
262
  }
263
- if ( ( qmn_quiz_data[quiz_id].hasOwnProperty('pagination') && qmn_quiz_data[quiz_id].first_page ) || ( window.localStorage.getItem( 'mlw_time_quiz' + quiz_id ) === null ||
264
- window.localStorage.getItem( 'mlw_time_quiz'+quiz_id ) > 0.08 ) ) {
265
 
266
  if( jQuery( this ).attr( 'class' ).indexOf( 'mlwRequiredNumber' ) > -1 && this.value === "" && +this.value != NaN ) {
267
  qmnDisplayError( number_error, jQuery( this ), quiz_form_id );
@@ -326,7 +457,7 @@ function qmnFormSubmit( quiz_form_id ) {
326
  qsmEndTimeTakenTimer();
327
 
328
  if ( qmn_quiz_data[quiz_id].hasOwnProperty( 'timer_limit' ) ) {
329
- qmnEndTimer( quiz_id );
330
  }
331
 
332
  jQuery( '#' + quiz_form_id + ' input[type=submit]' ).attr( 'disabled', 'disabled' );
@@ -395,98 +526,6 @@ function qmnInit() {
395
  }
396
  }
397
 
398
- function qmnActivateTimer( quiz_id ) {
399
- jQuery( '#quizForm' + quiz_id + ' .mlw_qmn_timer').show();
400
- qmn_timer_activated = true;
401
- var minutes = 0;
402
- if ( window.localStorage.getItem( 'mlw_started_quiz' + quiz_id ) == "yes" &&
403
- window.localStorage.getItem( 'mlw_time_quiz' + quiz_id ) >= 0 ) {
404
- minutes = window.localStorage.getItem( 'mlw_time_quiz' + quiz_id );
405
- } else {
406
- minutes = qmn_quiz_data[quiz_id].timer_limit;
407
- }
408
- window.amount = minutes * 60;
409
-
410
- jQuery( '#quizForm' + quiz_id + ' .mlw_qmn_timer').html( window.amount );
411
- window.qsmCounter = setInterval( qmnTimer, 1000, quiz_id );
412
- }
413
-
414
- function qmnTimer( quiz_id ) {
415
- window.amount = window.amount - 1;
416
- if (window.amount < 0) {
417
- window.amount = 0;
418
- }
419
- window.localStorage.setItem( 'mlw_time_quiz' + quiz_id, window.amount / 60 );
420
- window.localStorage.setItem( 'mlw_started_quiz' + quiz_id, "yes" );
421
- jQuery( '#quizForm' + quiz_id + ' .mlw_qmn_timer').html( qmnMinToSec( window.amount ) );
422
- window.document.title = qmnMinToSec( window.amount ) + " " + qsmTitleText;
423
- if ( window.amount <= 0 ) {
424
- clearInterval( window.qsmCounter );
425
- jQuery( ".mlw_qmn_quiz input:radio" ).attr( 'disabled',true );
426
- jQuery( ".mlw_qmn_quiz input:checkbox" ).attr( 'disabled',true );
427
- jQuery( ".mlw_qmn_quiz select" ).attr( 'disabled',true );
428
- jQuery( ".mlw_qmn_question_comment" ).attr( 'disabled',true );
429
- jQuery( ".mlw_answer_open_text" ).attr( 'disabled',true );
430
- jQuery( ".mlw_answer_number" ).attr( 'disabled',true );
431
- jQuery( '#quizForm' + quiz_id ).closest( '.qmn_quiz_container' ).addClass( 'qsm_timer_ended' );
432
- //document.quizForm.submit();
433
- return;
434
- }
435
- }
436
-
437
- function qmnEndTimer( quiz_id ) {
438
- window.localStorage.setItem('mlw_time_quiz' + quiz_id, 'completed');
439
- window.localStorage.setItem('mlw_started_quiz' + quiz_id, 'no');
440
- window.document.title = qsmTitleText;
441
- if ( typeof window.qsmCounter != 'undefined' ) {
442
- clearInterval( window.qsmCounter );
443
- }
444
- }
445
-
446
- function qmnMinToSec( amount ) {
447
- var timer_display = '';
448
- var hours = Math.floor(amount/3600);
449
- if (hours == '0')
450
- {
451
- timer_display = timer_display +"00:";
452
- }
453
- else if (hours < 10)
454
- {
455
- timer_display = timer_display + '0' + hours + ":";
456
- }
457
- else
458
- {
459
- timer_display = timer_display + hours + ":";
460
- }
461
- var minutes = Math.floor((amount % 3600)/60);
462
- if (minutes == '0')
463
- {
464
- timer_display = timer_display +"00:";
465
- }
466
- else if (minutes < 10)
467
- {
468
- timer_display = timer_display + '0' + minutes + ":";
469
- }
470
- else
471
- {
472
- timer_display = timer_display + minutes + ":";
473
- }
474
- var seconds = Math.floor(amount % 60);
475
- if (seconds == '0')
476
- {
477
- timer_display = timer_display +"00";
478
- }
479
- else if (seconds < 10)
480
- {
481
- timer_display = timer_display +'0' + seconds;
482
- }
483
- else
484
- {
485
- timer_display = timer_display + seconds;
486
- }
487
- return timer_display;
488
- }
489
-
490
  //Function to validate the answers provided in quiz
491
  function qmnValidatePage( quiz_form_id ) {
492
  var result = qmnValidation( '#' + quiz_form_id + ' .quiz_section:visible *', quiz_form_id );
34
  initTimer: function( quizID ) {
35
 
36
  // Gets our form
37
+ var $quizForm = QSM.getQuizForm( quizID );
38
+
39
+ // Creates timer status key.
40
+ qmn_quiz_data[ quizID ].timerStatus = false;
41
 
42
  // If we are using the newer pagination system...
43
  if ( 0 < $quizForm.children( '.qsm-page' ).length ) {
44
  // If there is a first page...
45
  if ( qmn_quiz_data[quizID].hasOwnProperty('first_page') && qmn_quiz_data[quizID].first_page ) {
46
  // ... attach an event handler to the click event to activate the timer.
47
+ $( '#quizForm' + quizID ).closest( '.qmn_quiz_container' ).find( '.mlw_next' ).on( 'click', function(event) {
48
  event.preventDefault();
49
+ if ( ! qmn_quiz_data[ quizID ].timerStatus && qmnValidatePage( 'quizForm' + quizID ) ) {
50
+ QSM.activateTimer( quizID );
51
  }
52
  });
53
  // ...else, activate the timer on page load.
54
  } else {
55
+ QSM.activateTimer( quizID );
56
  }
57
  // ...else, we must be using the questions per page option.
58
  } else {
59
  if ( qmn_quiz_data[quizID].hasOwnProperty('pagination') && qmn_quiz_data[quizID].first_page ) {
60
+ $( '#quizForm' + quizID ).closest( '.qmn_quiz_container' ).find( '.mlw_next' ).on( 'click', function(event) {
61
  event.preventDefault();
62
+ if ( ! qmn_quiz_data[ quizID ].timerStatus && ( 0 == $( '.quiz_begin:visible' ).length || ( 1 == $( '.quiz_begin:visible' ).length && qmnValidatePage( 'quizForm' + quizID ) ) ) ) {
63
+ QSM.activateTimer( quizID );
64
  }
65
  });
66
  } else {
67
+ QSM.activateTimer( quizID );
68
  }
69
  }
70
  },
71
+ /**
72
+ * Starts the timer for the quiz.
73
+ *
74
+ * @param int quizID The ID of the quiz.
75
+ */
76
+ activateTimer: function( quizID ) {
77
+
78
+ // Gets our form.
79
+ var $timer = QSM.getTimer( quizID );
80
+
81
+ // Sets up our variables.
82
+ qmn_quiz_data[ quizID ].timerStatus = true;
83
+ var seconds = 0;
84
+
85
+ // Calculates starting time.
86
+ var timerStarted = localStorage.getItem( 'mlw_started_quiz' + quizID );
87
+ var timerRemaning = localStorage.getItem( 'mlw_time_quiz' + quizID );
88
+ if ( 'yes' == timerStarted && 0 < timerRemaning ) {
89
+ seconds = parseInt( timerRemaning );
90
+ } else {
91
+ seconds = parseFloat( qmn_quiz_data[ quizID ].timer_limit ) * 60;
92
+ }
93
+ qmn_quiz_data[ quizID ].timerRemaning = seconds;
94
+
95
+ // Makes the timer appear.
96
+ $timer.show();
97
+ $timer.text( QSM.secondsToTimer( seconds ) );
98
+
99
+ // Sets up timer interval.
100
+ qmn_quiz_data[ quizID ].timerInterval = setInterval( QSM.timer, 1000, quizID );
101
+ },
102
+ /**
103
+ * Reduces the timer by one second and checks if timer is 0
104
+ *
105
+ * @param int quizID The ID of the quiz.
106
+ */
107
+ timer: function( quizID ) {
108
+ qmn_quiz_data[ quizID ].timerRemaning -= 1;
109
+ if ( 0 > qmn_quiz_data[ quizID ].timerRemaning ) {
110
+ qmn_quiz_data[ quizID ].timerRemaning = 0;
111
+ }
112
+ var secondsRemaining = qmn_quiz_data[ quizID ].timerRemaning;
113
+ var display = QSM.secondsToTimer( secondsRemaining );
114
+
115
+ // Sets our local storage values for the timer being started and current timer value.
116
+ localStorage.setItem( 'mlw_time_quiz' + quizID, secondsRemaining );
117
+ localStorage.setItem( 'mlw_started_quiz' + quizID, "yes" );
118
+
119
+ // Updates timer element and title on browser tab.
120
+ var $timer = QSM.getTimer( quizID );
121
+ $timer.text( display );
122
+ document.title = display + ' ' + qsmTitleText;
123
+
124
+ // If timer is run out, disable fields.
125
+ if ( 0 >= secondsRemaining ) {
126
+ clearInterval( qmn_quiz_data[ quizID ].timerInterval );
127
+ $( ".mlw_qmn_quiz input:radio" ).attr( 'disabled', true );
128
+ $( ".mlw_qmn_quiz input:checkbox" ).attr( 'disabled', true );
129
+ $( ".mlw_qmn_quiz select" ).attr( 'disabled', true );
130
+ $( ".mlw_qmn_question_comment" ).attr( 'disabled', true );
131
+ $( ".mlw_answer_open_text" ).attr( 'disabled', true );
132
+ $( ".mlw_answer_number" ).attr( 'disabled', true );
133
+
134
+ var $quizForm = QSM.getQuizForm( quizID );
135
+ $quizForm.closest( '.qmn_quiz_container' ).addClass( 'qsm_timer_ended' );
136
+ //document.quizForm.submit();
137
+ return;
138
+ }
139
+ },
140
+ /**
141
+ * Clears timer interval
142
+ *
143
+ * @param int quizID The ID of the quiz
144
+ */
145
+ endTimer: function( quizID ) {
146
+ localStorage.setItem( 'mlw_time_quiz' + quizID, 'completed' );
147
+ localStorage.setItem( 'mlw_started_quiz' + quizID, 'no' );
148
+ document.title = qsmTitleText;
149
+ if ( typeof qmn_quiz_data[ quizID ].timerInterval != 'undefined' ) {
150
+ clearInterval( qmn_quiz_data[ quizID ].timerInterval );
151
+ }
152
+ },
153
+ /**
154
+ * Converts seconds to 00:00:00 format
155
+ *
156
+ * @param int seconds The number of seconds
157
+ * @return string A string in H:M:S format
158
+ */
159
+ secondsToTimer: function( seconds ) {
160
+ var formattedTime = '';
161
+ seconds = parseInt( seconds );
162
+
163
+ // Prepares the hours part.
164
+ var hours = Math.floor( seconds / 3600 );
165
+ if ( 0 === hours) {
166
+ formattedTime = '00:';
167
+ } else if ( 10 > hours ) {
168
+ formattedTime = '0' + hours + ':';
169
+ } else {
170
+ formattedTime = hours + ':';
171
+ }
172
+
173
+ // Prepares the minutes part.
174
+ var minutes = Math.floor( ( seconds % 3600 ) / 60 );
175
+ if ( 0 === minutes) {
176
+ formattedTime = formattedTime + '00:';
177
+ } else if ( 10 > minutes ) {
178
+ formattedTime = formattedTime + '0' + minutes + ':';
179
+ } else {
180
+ formattedTime = formattedTime + minutes + ':';
181
+ }
182
+
183
+ // Prepares the seconds part.
184
+ var remainder = Math.floor( ( seconds % 60 ) );
185
+ if ( 0 === remainder) {
186
+ formattedTime = formattedTime + '00';
187
+ } else if ( 10 > remainder ) {
188
+ formattedTime = formattedTime + '0' + remainder;
189
+ } else {
190
+ formattedTime = formattedTime + remainder;
191
+ }
192
+ return formattedTime;
193
+ },
194
+ /**
195
+ * Gets the jQuery object for the timer
196
+ */
197
+ getTimer: function( quizID ) {
198
+ var $quizForm = QSM.getQuizForm( quizID );
199
+ return $quizForm.children( '.mlw_qmn_timer' );
200
+ },
201
  /**
202
  * Sets up pagination for a quiz
203
  *
204
  * @param int quizID The ID of the quiz.
205
  */
206
  initPagination: function( quizID ) {
207
+ var $quizForm = QSM.getQuizForm( quizID );
208
  if ( 0 < $quizForm.children( '.qsm-page' ).length ) {
209
  $quizForm.children( '.qsm-page' ).hide();
210
  template = wp.template( 'qsm-pagination' );
338
  }(jQuery));
339
 
340
  // Global Variables
341
+ var qsmTitleText = document.title;
 
342
 
343
  function qmnTimeTakenTimer() {
344
  var x = +jQuery( '#timer' ).val();
392
  result = false;
393
  }
394
  }
395
+ if ( localStorage.getItem( 'mlw_time_quiz' + quiz_id ) === null || localStorage.getItem( 'mlw_time_quiz'+quiz_id ) > 0.08 ) {
 
396
 
397
  if( jQuery( this ).attr( 'class' ).indexOf( 'mlwRequiredNumber' ) > -1 && this.value === "" && +this.value != NaN ) {
398
  qmnDisplayError( number_error, jQuery( this ), quiz_form_id );
457
  qsmEndTimeTakenTimer();
458
 
459
  if ( qmn_quiz_data[quiz_id].hasOwnProperty( 'timer_limit' ) ) {
460
+ QSM.endTimer( quiz_id );
461
  }
462
 
463
  jQuery( '#' + quiz_form_id + ' input[type=submit]' ).attr( 'disabled', 'disabled' );
526
  }
527
  }
528
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
529
  //Function to validate the answers provided in quiz
530
  function qmnValidatePage( quiz_form_id ) {
531
  var result = qmnValidation( '#' + quiz_form_id + ' .quiz_section:visible *', quiz_form_id );
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.0.2
6
  * Author: Frank Corso
7
  * Author URI: https://www.quizandsurveymaster.com/
8
  * Plugin URI: https://www.quizandsurveymaster.com/
9
  * Text Domain: quiz-master-next
10
  *
11
  * @author Frank Corso
12
- * @version 6.0.2
13
  * @package QSM
14
  */
15
 
@@ -33,7 +33,7 @@ class MLWQuizMasterNext {
33
  * @var string
34
  * @since 4.0.0
35
  */
36
- public $version = '6.0.2';
37
 
38
  /**
39
  * QSM Alert Manager Object
2
  /**
3
  * Plugin Name: Quiz And Survey Master
4
  * Description: Easily and quickly add quizzes and surveys to your website.
5
+ * Version: 6.0.3
6
  * Author: Frank Corso
7
  * Author URI: https://www.quizandsurveymaster.com/
8
  * Plugin URI: https://www.quizandsurveymaster.com/
9
  * Text Domain: quiz-master-next
10
  *
11
  * @author Frank Corso
12
+ * @version 6.0.3
13
  * @package QSM
14
  */
15
 
33
  * @var string
34
  * @since 4.0.0
35
  */
36
+ public $version = '6.0.3';
37
 
38
  /**
39
  * QSM Alert Manager Object
php/admin/about-page.php CHANGED
@@ -46,6 +46,7 @@ function mlw_generate_about_page() {
46
  </div>
47
  <div class="qsm-tab-content tab-2" style="display: none;">
48
  <h2>Changelog</h2>
 
49
  <?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 54 ); ?>
50
  <?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 53 ); ?>
51
  <?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 36 ); ?>
46
  </div>
47
  <div class="qsm-tab-content tab-2" style="display: none;">
48
  <h2>Changelog</h2>
49
+ <?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 55 ); ?>
50
  <?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 54 ); ?>
51
  <?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 53 ); ?>
52
  <?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 36 ); ?>
php/admin/quizzes-page.php CHANGED
@@ -193,9 +193,14 @@ function qsm_generate_quizzes_surveys_page() {
193
  ?>
194
  <div class="qsm-news-ads">
195
  <h3 class="qsm-news-ads-title"><?php _e( 'QSM News', 'quiz-master-next' ); ?></h3>
 
 
 
 
 
196
  <div class="qsm-info-widget">
197
  <h3><?php _e( 'Subscribe to our newsletter!', 'quiz-master-next' ); ?></h3>
198
- <p><?php _e( 'Join our mailing list and receive a discount on your next purchase! Learn about our newest features, receive email-only promotions, receive tips and guides, and more!', 'quiz-master-next' ); ?></p>
199
  <a target="_blank" href="http://quizandsurveymaster.com/subscribe-to-our-newsletter/?utm_source=qsm-quizzes-page&utm_medium=plugin&utm_campaign=qsm_plugin&utm_content=subscribe-to-newsletter" class="button-primary"><?php _e( 'Subscribe Now', 'quiz-master-next' ); ?></a>
200
  </div>
201
  <?php
193
  ?>
194
  <div class="qsm-news-ads">
195
  <h3 class="qsm-news-ads-title"><?php _e( 'QSM News', 'quiz-master-next' ); ?></h3>
196
+ <div class="qsm-info-widget">
197
+ <h3>Keep your WordPress site healthy and secure!</h3>
198
+ <p>Easily monitor your WordPress sites to ensure they stay up, healthy, and secure with our new WordPress plugin, WP Health!</p>
199
+ <a target="_blank" href="http://bit.ly/2Mr2SqC" class="button-primary"><?php esc_html_e( 'Learn More', 'quiz-master-next' ); ?></a>
200
+ </div>
201
  <div class="qsm-info-widget">
202
  <h3><?php _e( 'Subscribe to our newsletter!', 'quiz-master-next' ); ?></h3>
203
+ <p><?php _e( 'Join our mailing list to learn about our newest features, receive email-only promotions, receive tips and guides, and more!', 'quiz-master-next' ); ?></p>
204
  <a target="_blank" href="http://quizandsurveymaster.com/subscribe-to-our-newsletter/?utm_source=qsm-quizzes-page&utm_medium=plugin&utm_campaign=qsm_plugin&utm_content=subscribe-to-newsletter" class="button-primary"><?php _e( 'Subscribe Now', 'quiz-master-next' ); ?></a>
205
  </div>
206
  <?php
php/adverts-generate.php CHANGED
@@ -18,8 +18,8 @@ function mlw_qmn_show_adverts() {
18
  $mlw_random_int = rand( 0, 3 );
19
  switch ( $mlw_random_int ) {
20
  case 0:
21
- // Subscribe Newsletter 1
22
- $mlw_advert_text = "Want a discount on your next addon purchase? Keep updated on our news, updated, and more by <a href=\"http://quizandsurveymaster.com/subscribe-to-our-newsletter/?utm_source=qsm-plugin-ads&utm_medium=plugin&utm_content=subscribe-newsletter-1&utm_campaign=qsm_plugin\">subscribing to our mailing list</a> and receive a discount on your next purchase!";
23
  break;
24
  case 1:
25
  // Continued development 1
@@ -29,6 +29,10 @@ function mlw_qmn_show_adverts() {
29
  // Reporting and anaylsis 1
30
  $mlw_advert_text = "Are you receiving a lot of responses to your quizzes and surveys? Consider our Reporting and Anaylsis addon which analyzes the data for you and allows you to filter the data as well as export it! <a href=\"http://quizandsurveymaster.com/downloads/results-analysis/?utm_source=qsm-plugin-ads&utm_medium=plugin&utm_content=reporting-analysis-1&utm_campaign=qsm_plugin\">Click here for more details!</a>";
31
  break;
 
 
 
 
32
  default:
33
  // Reporting and anaylsis 2
34
  $mlw_advert_text = "Are you receiving a lot of responses to your quizzes and surveys? Consider our Reporting and Anaylsis addon which analyzes the data for you, graphs the data, allows you to filter the data, and export the data! <a href=\"http://quizandsurveymaster.com/downloads/results-analysis/?utm_source=qsm-plugin-ads&utm_medium=plugin&utm_content=reporting-analysis-2&utm_campaign=qsm_plugin\">Click here for more details!</a>";
@@ -38,7 +42,7 @@ function mlw_qmn_show_adverts() {
38
  div.help_decide {
39
  display: block;
40
  text-align:center;
41
- background: #0d97d8;
42
  border: 5px solid #1DD969;
43
  color: #000;
44
  font-weight: bold;
@@ -46,9 +50,6 @@ function mlw_qmn_show_adverts() {
46
  div.help_decide p {
47
  font-size: 14px;
48
  }
49
- div.help_decide a {
50
- color: yellow;
51
- }
52
  </style>";
53
  $mlw_advert .= "
54
  <div class=\"help_decide\">
18
  $mlw_random_int = rand( 0, 3 );
19
  switch ( $mlw_random_int ) {
20
  case 0:
21
+ // WP Health
22
+ $mlw_advert_text = 'Want to make sure your site is healthy, secure, and live? Check out our new free WordPress plugin: <a href="https://wordpress.org/plugins/my-wp-health-check/" target="_blank">WP Health</a>!';
23
  break;
24
  case 1:
25
  // Continued development 1
29
  // Reporting and anaylsis 1
30
  $mlw_advert_text = "Are you receiving a lot of responses to your quizzes and surveys? Consider our Reporting and Anaylsis addon which analyzes the data for you and allows you to filter the data as well as export it! <a href=\"http://quizandsurveymaster.com/downloads/results-analysis/?utm_source=qsm-plugin-ads&utm_medium=plugin&utm_content=reporting-analysis-1&utm_campaign=qsm_plugin\">Click here for more details!</a>";
31
  break;
32
+ case 3:
33
+ // Email marketing integrations.
34
+ $mlw_advert_text = 'Want to grow your email list? Check out our addons for adding your quiz or survey takers to your email lists! <a href="http://bit.ly/2Bsw0Je" target="_blank">View our addon store</a>.';
35
+ break;
36
  default:
37
  // Reporting and anaylsis 2
38
  $mlw_advert_text = "Are you receiving a lot of responses to your quizzes and surveys? Consider our Reporting and Anaylsis addon which analyzes the data for you, graphs the data, allows you to filter the data, and export the data! <a href=\"http://quizandsurveymaster.com/downloads/results-analysis/?utm_source=qsm-plugin-ads&utm_medium=plugin&utm_content=reporting-analysis-2&utm_campaign=qsm_plugin\">Click here for more details!</a>";
42
  div.help_decide {
43
  display: block;
44
  text-align:center;
45
+ background: #fff;
46
  border: 5px solid #1DD969;
47
  color: #000;
48
  font-weight: bold;
50
  div.help_decide p {
51
  font-size: 14px;
52
  }
 
 
 
53
  </style>";
54
  $mlw_advert .= "
55
  <div class=\"help_decide\">
php/classes/class-qmn-quiz-creator.php CHANGED
@@ -1,5 +1,8 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit;
 
 
 
3
  /**
4
  * QMN Quiz Creator Class
5
  *
@@ -9,8 +12,8 @@ if ( ! defined( 'ABSPATH' ) ) exit;
9
  *
10
  * @since 3.7.1
11
  */
12
- class QMNQuizCreator
13
- {
14
  /**
15
  * QMN ID of quiz
16
  *
@@ -24,11 +27,9 @@ class QMNQuizCreator
24
  *
25
  * @since 3.7.1
26
  */
27
- public function __construct()
28
- {
29
- if (isset($_GET["quiz_id"]))
30
- {
31
- $this->quiz_id = intval($_GET["quiz_id"]);
32
  }
33
  }
34
 
@@ -36,130 +37,28 @@ class QMNQuizCreator
36
  * Sets quiz ID
37
  *
38
  * @since 3.8.1
 
39
  * @access public
40
  * @return void
41
  */
42
- public function set_id($quiz_id)
43
- {
44
- $this->quiz_id = intval($quiz_id);
45
- }
46
-
47
- /**
48
- * Gets the quiz ID stored (for backwards compatibility)
49
- *
50
- * @since 5.0.0
51
- * @return int|false The ID of the quiz stored or false
52
- */
53
- public function get_id() {
54
- if ( $this->quiz_id ) {
55
- return intval( $this->quiz_id );
56
- } else {
57
- return false;
58
- }
59
- }
60
-
61
- /**
62
- * Retrieves setting store in quiz_settings
63
- *
64
- * @since 3.8.1
65
- * @access public
66
- * @return string The value of the setting
67
- */
68
- public function get_setting($setting_name)
69
- {
70
- global $wpdb;
71
- $qmn_settings_array = '';
72
- $qmn_quiz_settings = $wpdb->get_var( $wpdb->prepare( "SELECT quiz_settings FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=%d", $this->quiz_id ) );
73
- if (is_serialized($qmn_quiz_settings) && is_array(@unserialize($qmn_quiz_settings)))
74
- {
75
- $qmn_settings_array = @unserialize($qmn_quiz_settings);
76
- }
77
- if (is_array($qmn_settings_array) && isset($qmn_settings_array[$setting_name]))
78
- {
79
- return $qmn_settings_array[$setting_name];
80
- }
81
- else
82
- {
83
- return '';
84
- }
85
-
86
- }
87
-
88
- /**
89
- * Updates setting stored in quiz_settings
90
- *
91
- * @since 3.8.1
92
- * @access public
93
- * @return bool True if update was successful
94
- */
95
- public function update_setting($setting_name, $setting_value)
96
- {
97
- global $wpdb;
98
- $qmn_settings_array = array();
99
- $qmn_quiz_settings = $wpdb->get_var( $wpdb->prepare( "SELECT quiz_settings FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=%d", $this->quiz_id ) );
100
- if (is_serialized($qmn_quiz_settings) && is_array(@unserialize($qmn_quiz_settings)))
101
- {
102
- $qmn_settings_array = @unserialize($qmn_quiz_settings);
103
- }
104
- $qmn_settings_array[$setting_name] = $setting_value;
105
- $qmn_serialized_array = serialize($qmn_settings_array);
106
- $results = $wpdb->update(
107
- $wpdb->prefix . "mlw_quizzes",
108
- array(
109
- 'quiz_settings' => $qmn_serialized_array
110
- ),
111
- array( 'quiz_id' => $this->quiz_id ),
112
- array(
113
- '%s'
114
- ),
115
- array( '%d' )
116
- );
117
- if ($results != false)
118
- {
119
- return true;
120
- }
121
- else
122
- {
123
- return false;
124
- }
125
  }
126
 
127
  /**
128
- * Deletes setting stored in quiz_settings
129
  *
130
- * @since 3.8.1
131
- * @access public
132
- * @return void
133
  */
134
- public function delete_setting($setting_name)
135
- {
136
- global $wpdb;
137
- $qmn_settings_array = array();
138
- $qmn_quiz_settings = $wpdb->get_var( $wpdb->prepare( "SELECT quiz_settings FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=%d", $this->quiz_id ) );
139
- if (is_serialized($qmn_quiz_settings) && is_array(@unserialize($qmn_quiz_settings)))
140
- {
141
- $qmn_settings_array = @unserialize($qmn_quiz_settings);
142
- }
143
- if (is_array($qmn_settings_array) && isset($qmn_settings_array[$setting_name]))
144
- {
145
- unset($qmn_settings_array[$setting_name]);
146
  }
147
- $qmn_serialized_array = serialize($qmn_settings_array);
148
- $results = $wpdb->update(
149
- $wpdb->prefix . "mlw_quizzes",
150
- array(
151
- 'quiz_settings' => $qmn_serialized_array
152
- ),
153
- array( 'quiz_id' => $this->quiz_id ),
154
- array(
155
- '%s'
156
- ),
157
- array( '%d' )
158
- );
159
  }
160
 
161
-
162
-
163
  /**
164
  * Creates a new quiz with the default settings
165
  *
@@ -368,39 +267,47 @@ class QMNQuizCreator
368
  do_action('qmn_quiz_deleted', $quiz_id);
369
  }
370
 
371
- /**
372
  * Edits the name of the quiz with the given ID
373
  *
374
  * @access public
375
  * @since 3.7.1
 
 
376
  * @return void
377
  */
378
- public function edit_quiz_name($quiz_id, $quiz_name)
379
- {
380
- global $mlwQuizMasterNext;
381
  global $wpdb;
382
  $results = $wpdb->update(
383
- $wpdb->prefix . "mlw_quizzes",
384
- array(
385
- 'quiz_name' => $quiz_name
386
- ),
387
- array( 'quiz_id' => $quiz_id ),
388
- array(
389
- '%s'
390
- ),
391
- array( '%d' )
392
- );
393
- if ( false != $results ) {
394
- $mlwQuizMasterNext->alertManager->newAlert(__('The name of your quiz or survey has been updated successfully.', 'quiz-master-next'), 'success');
395
  $mlwQuizMasterNext->audit_manager->new_audit( "Quiz/Survey Name Has Been Edited: $quiz_name" );
 
 
 
 
 
 
 
396
  }
397
- else
398
- {
399
- $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0003'), 'error');
400
- $mlwQuizMasterNext->log_manager->add("Error 0003", $wpdb->last_error.' from '.$wpdb->last_query, 0, 'error');
401
- }
402
- do_action('qmn_quiz_name_edited', $quiz_id);
403
- }
404
 
405
  /**
406
  * Duplicates the quiz with the given ID and gives new quiz the given quiz name
@@ -616,6 +523,104 @@ class QMNQuizCreator
616
  }
617
  }
618
  }
619
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
620
  }
621
- ?>
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
  /**
7
  * QMN Quiz Creator Class
8
  *
12
  *
13
  * @since 3.7.1
14
  */
15
+ class QMNQuizCreator {
16
+
17
  /**
18
  * QMN ID of quiz
19
  *
27
  *
28
  * @since 3.7.1
29
  */
30
+ public function __construct() {
31
+ if ( isset( $_GET['quiz_id'] ) ) {
32
+ $this->quiz_id = intval( $_GET['quiz_id'] );
 
 
33
  }
34
  }
35
 
37
  * Sets quiz ID
38
  *
39
  * @since 3.8.1
40
+ * @param int $quiz_id The ID of the quiz.
41
  * @access public
42
  * @return void
43
  */
44
+ public function set_id( $quiz_id ) {
45
+ $this->quiz_id = intval( $quiz_id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  }
47
 
48
  /**
49
+ * Gets the quiz ID stored (for backwards compatibility)
50
  *
51
+ * @since 5.0.0
52
+ * @return int|false The ID of the quiz stored or false
 
53
  */
54
+ public function get_id() {
55
+ if ( $this->quiz_id ) {
56
+ return intval( $this->quiz_id );
57
+ } else {
58
+ return false;
 
 
 
 
 
 
 
59
  }
 
 
 
 
 
 
 
 
 
 
 
 
60
  }
61
 
 
 
62
  /**
63
  * Creates a new quiz with the default settings
64
  *
267
  do_action('qmn_quiz_deleted', $quiz_id);
268
  }
269
 
270
+ /**
271
  * Edits the name of the quiz with the given ID
272
  *
273
  * @access public
274
  * @since 3.7.1
275
+ * @param int $quiz_id The ID of the quiz.
276
+ * @param string $quiz_name The new name of the quiz.
277
  * @return void
278
  */
279
+ public function edit_quiz_name( $quiz_id, $quiz_name ) {
280
+ global $mlwQuizMasterNext;
 
281
  global $wpdb;
282
  $results = $wpdb->update(
283
+ $wpdb->prefix . 'mlw_quizzes',
284
+ array(
285
+ 'quiz_name' => $quiz_name,
286
+ ),
287
+ array( 'quiz_id' => $quiz_id ),
288
+ array(
289
+ '%s',
290
+ ),
291
+ array( '%d' )
292
+ );
293
+ if ( false !== $results ) {
294
+ $mlwQuizMasterNext->alertManager->newAlert( __( 'The name of your quiz or survey has been updated successfully.', 'quiz-master-next' ), 'success' );
295
  $mlwQuizMasterNext->audit_manager->new_audit( "Quiz/Survey Name Has Been Edited: $quiz_name" );
296
+ } else {
297
+ $error = $wpdb->last_error;
298
+ if ( empty( $error ) ) {
299
+ $error = __( 'Unknown error', 'quiz-master-next' );
300
+ }
301
+ $mlwQuizMasterNext->alertManager->newAlert( __( 'An error occurred while trying to update the name of your quiz or survey. Please try again.', 'quiz-master-next' ), 'error' );
302
+ $mlwQuizMasterNext->log_manager->add( 'Error when updating quiz name', "Tried {$wpdb->last_query} but got $error", 0, 'error' );
303
  }
304
+
305
+ // Fires when the name of a quiz/survey is edited.
306
+ do_action( 'qsm_quiz_name_edited', $quiz_id, $quiz_name );
307
+
308
+ // Legacy code.
309
+ do_action( 'qmn_quiz_name_edited', $quiz_id );
310
+ }
311
 
312
  /**
313
  * Duplicates the quiz with the given ID and gives new quiz the given quiz name
523
  }
524
  }
525
  }
526
+ }
527
+
528
+ /**
529
+ * Retrieves setting store in quiz_settings
530
+ *
531
+ * @deprecated 6.0.3 Use the get_quiz_setting function in the pluginHelper object.
532
+ * @since 3.8.1
533
+ * @access public
534
+ * @param string $setting_name The slug of the setting.
535
+ * @return string The value of the setting
536
+ */
537
+ public function get_setting( $setting_name ) {
538
+ global $wpdb;
539
+ $qmn_settings_array = '';
540
+ $qmn_quiz_settings = $wpdb->get_var( $wpdb->prepare( "SELECT quiz_settings FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=%d", $this->quiz_id ) );
541
+ if ( is_serialized( $qmn_quiz_settings ) && is_array( @unserialize( $qmn_quiz_settings ) ) ) {
542
+ $qmn_settings_array = @unserialize( $qmn_quiz_settings );
543
+ }
544
+ if ( is_array( $qmn_settings_array ) && isset( $qmn_settings_array[ $setting_name ] ) ) {
545
+ return $qmn_settings_array[ $setting_name ];
546
+ } else {
547
+ return '';
548
+ }
549
+
550
+ }
551
+
552
+ /**
553
+ * Updates setting stored in quiz_settings
554
+ *
555
+ * @deprecated 6.0.3 Use the update_quiz_setting function in the pluginHelper object.
556
+ * @since 3.8.1
557
+ * @access public
558
+ * @param string $setting_name The slug of the setting.
559
+ * @param mixed $setting_value The value for the setting.
560
+ * @return bool True if update was successful
561
+ */
562
+ public function update_setting( $setting_name, $setting_value ) {
563
+ global $wpdb;
564
+ $qmn_settings_array = array();
565
+ $qmn_quiz_settings = $wpdb->get_var( $wpdb->prepare( "SELECT quiz_settings FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=%d", $this->quiz_id ) );
566
+ if (is_serialized($qmn_quiz_settings) && is_array(@unserialize($qmn_quiz_settings)))
567
+ {
568
+ $qmn_settings_array = @unserialize($qmn_quiz_settings);
569
+ }
570
+ $qmn_settings_array[$setting_name] = $setting_value;
571
+ $qmn_serialized_array = serialize($qmn_settings_array);
572
+ $results = $wpdb->update(
573
+ $wpdb->prefix . "mlw_quizzes",
574
+ array(
575
+ 'quiz_settings' => $qmn_serialized_array
576
+ ),
577
+ array( 'quiz_id' => $this->quiz_id ),
578
+ array(
579
+ '%s'
580
+ ),
581
+ array( '%d' )
582
+ );
583
+ if ($results != false)
584
+ {
585
+ return true;
586
+ }
587
+ else
588
+ {
589
+ return false;
590
+ }
591
+ }
592
+
593
+ /**
594
+ * Deletes setting stored in quiz_settings
595
+ *
596
+ * @deprecated 6.0.3
597
+ * @since 3.8.1
598
+ * @access public
599
+ * @return void
600
+ */
601
+ public function delete_setting( $setting_name ) {
602
+ global $wpdb;
603
+ $qmn_settings_array = array();
604
+ $qmn_quiz_settings = $wpdb->get_var( $wpdb->prepare( "SELECT quiz_settings FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=%d", $this->quiz_id ) );
605
+ if (is_serialized($qmn_quiz_settings) && is_array(@unserialize($qmn_quiz_settings)))
606
+ {
607
+ $qmn_settings_array = @unserialize($qmn_quiz_settings);
608
+ }
609
+ if (is_array($qmn_settings_array) && isset($qmn_settings_array[$setting_name]))
610
+ {
611
+ unset($qmn_settings_array[$setting_name]);
612
+ }
613
+ $qmn_serialized_array = serialize($qmn_settings_array);
614
+ $results = $wpdb->update(
615
+ $wpdb->prefix . "mlw_quizzes",
616
+ array(
617
+ 'quiz_settings' => $qmn_serialized_array
618
+ ),
619
+ array( 'quiz_id' => $this->quiz_id ),
620
+ array(
621
+ '%s'
622
+ ),
623
+ array( '%d' )
624
+ );
625
+ }
626
  }
 
php/classes/class-qmn-quiz-manager.php CHANGED
@@ -106,7 +106,7 @@ class QMNQuizManager {
106
  }
107
  }
108
 
109
- // Start to prepare variable array for filters.
110
  $qmn_array_for_variables = array(
111
  'quiz_id' => $qmn_quiz_options->quiz_id,
112
  'quiz_name' => $qmn_quiz_options->quiz_name,
@@ -129,7 +129,7 @@ class QMNQuizManager {
129
 
130
  $return_display = apply_filters( 'qmn_begin_shortcode', $return_display, $qmn_quiz_options, $qmn_array_for_variables );
131
 
132
- // Check if we should be showing quiz or results page.
133
  if ( $qmn_allowed_visit && ! isset( $_POST["complete_quiz"] ) && ! empty( $qmn_quiz_options->quiz_name ) ) {
134
  $return_display .= $this->display_quiz( $qmn_quiz_options, $qmn_array_for_variables, $question_amount );
135
  } elseif ( isset( $_POST["complete_quiz"] ) && 'confirmation' == $_POST["complete_quiz"] && $_POST["qmn_quiz_id"] == $qmn_array_for_variables["quiz_id"] ) {
@@ -299,8 +299,8 @@ class QMNQuizManager {
299
  );
300
 
301
  wp_enqueue_script( 'progress-bar', plugins_url( '../../js/progressbar.min.js', __FILE__ ) );
302
- wp_enqueue_script( 'qmn_quiz', plugins_url( '../../js/qmn_quiz.js', __FILE__ ), array( 'wp-util', 'underscore', 'jquery', 'jquery-ui-tooltip', 'progress-bar' ), $mlwQuizMasterNext->version );
303
- wp_localize_script( 'qmn_quiz', 'qmn_ajax_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); // setting ajaxurl
304
  wp_enqueue_script( 'math_jax', '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML' );
305
 
306
  global $qmn_total_questions;
@@ -741,7 +741,7 @@ class QMNQuizManager {
741
  return $result_display;
742
  }
743
 
744
- // Gather contact information
745
  $qmn_array_for_variables['user_name'] = 'None';
746
  $qmn_array_for_variables['user_business'] = 'None';
747
  $qmn_array_for_variables['user_email'] = 'None';
@@ -794,7 +794,7 @@ class QMNQuizManager {
794
  $results_array = apply_filters( 'qsm_results_array', $results_array, $qmn_array_for_variables );
795
  $serialized_results = serialize( $results_array );
796
 
797
- // Inserts the responses in the database
798
  global $wpdb;
799
  $table_name = $wpdb->prefix . "mlw_results";
800
  $results_insert = $wpdb->insert(
@@ -814,9 +814,9 @@ class QMNQuizManager {
814
  'user' => $qmn_array_for_variables['user_id'],
815
  'user_ip' => $qmn_array_for_variables['user_ip'],
816
  'time_taken' => $qmn_array_for_variables['time_taken'],
817
- 'time_taken_real' => date( "Y-m-d H:i:s", strtotime( $qmn_array_for_variables['time_taken'] ) ),
818
  'quiz_results' => $serialized_results,
819
- 'deleted' => 0
820
  ),
821
  array(
822
  '%d',
@@ -835,35 +835,44 @@ class QMNQuizManager {
835
  '%s',
836
  '%s',
837
  '%s',
838
- '%d'
839
  )
840
  );
841
  }
842
 
843
- $this->send_user_email($qmn_quiz_options, $qmn_array_for_variables);
844
- $result_display = apply_filters('qmn_after_send_user_email', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
 
 
 
 
 
 
 
 
845
  $this->send_admin_email($qmn_quiz_options, $qmn_array_for_variables);
846
- $result_display = apply_filters('qmn_after_send_admin_email', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
847
- $result_display = apply_filters('qmn_end_results', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
848
- //Legacy Code
849
- do_action('mlw_qmn_load_results_page', $wpdb->insert_id, $qmn_quiz_options->quiz_settings);
 
 
 
850
  } else {
851
- $result_display .= "Thank you.";
852
  }
853
 
854
- //Check to see if we need to set up a redirect
855
- $redirect = false;
856
  $redirect_url = '';
857
- if (is_serialized($qmn_quiz_options->message_after) && is_array(@unserialize($qmn_quiz_options->message_after))) {
858
- $mlw_message_after_array = @unserialize($qmn_quiz_options->message_after);
859
-
860
- //Cycle through landing pages
861
- foreach($mlw_message_after_array as $mlw_each)
862
- {
863
- //Check to see if not default
864
- if ($mlw_each[0] != 0 || $mlw_each[1] != 0)
865
- {
866
- //Check to see if points fall in correct range
867
  if ($qmn_quiz_options->system == 1 && $qmn_array_for_variables['total_points'] >= $mlw_each[0] && $qmn_array_for_variables['total_points'] <= $mlw_each[1])
868
  {
869
  if (esc_url($mlw_each["redirect_url"]) != '')
@@ -896,11 +905,11 @@ class QMNQuizManager {
896
  }
897
  }
898
 
899
- //Prepare data to be sent back to front-end
900
  $return_array = array(
901
- 'display' => $result_display,
902
- 'redirect' => $redirect,
903
- 'redirect_url' => $redirect_url
904
  );
905
 
906
  return $return_array;
106
  }
107
  }
108
 
109
+ // Starts to prepare variable array for filters.
110
  $qmn_array_for_variables = array(
111
  'quiz_id' => $qmn_quiz_options->quiz_id,
112
  'quiz_name' => $qmn_quiz_options->quiz_name,
129
 
130
  $return_display = apply_filters( 'qmn_begin_shortcode', $return_display, $qmn_quiz_options, $qmn_array_for_variables );
131
 
132
+ // Checks if we should be showing quiz or results page.
133
  if ( $qmn_allowed_visit && ! isset( $_POST["complete_quiz"] ) && ! empty( $qmn_quiz_options->quiz_name ) ) {
134
  $return_display .= $this->display_quiz( $qmn_quiz_options, $qmn_array_for_variables, $question_amount );
135
  } elseif ( isset( $_POST["complete_quiz"] ) && 'confirmation' == $_POST["complete_quiz"] && $_POST["qmn_quiz_id"] == $qmn_array_for_variables["quiz_id"] ) {
299
  );
300
 
301
  wp_enqueue_script( 'progress-bar', plugins_url( '../../js/progressbar.min.js', __FILE__ ) );
302
+ wp_enqueue_script( 'qsm_quiz', plugins_url( '../../js/qsm-quiz.js', __FILE__ ), array( 'wp-util', 'underscore', 'jquery', 'jquery-ui-tooltip', 'progress-bar' ), $mlwQuizMasterNext->version );
303
+ wp_localize_script( 'qsm_quiz', 'qmn_ajax_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
304
  wp_enqueue_script( 'math_jax', '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML' );
305
 
306
  global $qmn_total_questions;
741
  return $result_display;
742
  }
743
 
744
+ // Gathers contact information.
745
  $qmn_array_for_variables['user_name'] = 'None';
746
  $qmn_array_for_variables['user_business'] = 'None';
747
  $qmn_array_for_variables['user_email'] = 'None';
794
  $results_array = apply_filters( 'qsm_results_array', $results_array, $qmn_array_for_variables );
795
  $serialized_results = serialize( $results_array );
796
 
797
+ // Inserts the responses in the database.
798
  global $wpdb;
799
  $table_name = $wpdb->prefix . "mlw_results";
800
  $results_insert = $wpdb->insert(
814
  'user' => $qmn_array_for_variables['user_id'],
815
  'user_ip' => $qmn_array_for_variables['user_ip'],
816
  'time_taken' => $qmn_array_for_variables['time_taken'],
817
+ 'time_taken_real' => date( 'Y-m-d H:i:s', strtotime( $qmn_array_for_variables['time_taken'] ) ),
818
  'quiz_results' => $serialized_results,
819
+ 'deleted' => 0,
820
  ),
821
  array(
822
  '%d',
835
  '%s',
836
  '%s',
837
  '%s',
838
+ '%d',
839
  )
840
  );
841
  }
842
 
843
+ $results_id = $wpdb->insert_id;
844
+
845
+ // Hook is fired after the responses are submitted. Passes responses, result ID, quiz settings, and response data.
846
+ do_action( 'qsm_quiz_submitted', $results_array, $results_id, $qmn_quiz_options, $qmn_array_for_variables );
847
+
848
+ // Sends user email.
849
+ $this->send_user_email( $qmn_quiz_options, $qmn_array_for_variables );
850
+ $result_display = apply_filters( 'qmn_after_send_user_email', $result_display, $qmn_quiz_options, $qmn_array_for_variables );
851
+
852
+ // Sends admin email.
853
  $this->send_admin_email($qmn_quiz_options, $qmn_array_for_variables);
854
+ $result_display = apply_filters( 'qmn_after_send_admin_email', $result_display, $qmn_quiz_options, $qmn_array_for_variables );
855
+
856
+ // Last time to filter the HTML results page.
857
+ $result_display = apply_filters( 'qmn_end_results', $result_display, $qmn_quiz_options, $qmn_array_for_variables );
858
+
859
+ // Legacy Code.
860
+ do_action( 'mlw_qmn_load_results_page', $wpdb->insert_id, $qmn_quiz_options->quiz_settings );
861
  } else {
862
+ $result_display .= 'Thank you.';
863
  }
864
 
865
+ // Checks to see if we need to set up a redirect.
866
+ $redirect = false;
867
  $redirect_url = '';
868
+ if ( is_serialized( $qmn_quiz_options->message_after ) && is_array( @unserialize( $qmn_quiz_options->message_after ) ) ) {
869
+ $mlw_message_after_array = @unserialize( $qmn_quiz_options->message_after );
870
+
871
+ // Cycles through landing pages.
872
+ foreach( $mlw_message_after_array as $mlw_each ) {
873
+ // Checks to see if not default.
874
+ if ( $mlw_each[0] != 0 || $mlw_each[1] != 0 ) {
875
+ // Checks to see if points fall in correct range.
 
 
876
  if ($qmn_quiz_options->system == 1 && $qmn_array_for_variables['total_points'] >= $mlw_each[0] && $qmn_array_for_variables['total_points'] <= $mlw_each[1])
877
  {
878
  if (esc_url($mlw_each["redirect_url"]) != '')
905
  }
906
  }
907
 
908
+ // Prepares data to be sent back to front-end.
909
  $return_array = array(
910
+ 'display' => $result_display,
911
+ 'redirect' => $redirect,
912
+ 'redirect_url' => $redirect_url,
913
  );
914
 
915
  return $return_array;
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: quiz, survey, lead, test, score, exam, questionnaire, question
4
  Requires at least: 4.8
5
  Tested up to: 4.9
6
  Requires PHP: 5.4
7
- Stable tag: 6.0.2
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -111,6 +111,13 @@ This is usually a theme conflict. You can [checkout out our common conflict solu
111
 
112
  == Changelog ==
113
 
 
 
 
 
 
 
 
114
  = 6.0.2 (July 18, 2018) =
115
  * Closed Bug: PHP warning thrown on Help page ([Issue #711](https://github.com/fpcorso/quiz_master_next/issues/711))
116
  * Closed Bug: Timer not working on certain sites when using questions per page option ([Issue #709](https://github.com/fpcorso/quiz_master_next/issues/709))
@@ -128,6 +135,9 @@ This is usually a theme conflict. You can [checkout out our common conflict solu
128
 
129
  == Upgrade Notice ==
130
 
 
 
 
131
  = 6.0.2 =
132
  Upgrade for fix for timer and blank pages
133
 
4
  Requires at least: 4.8
5
  Tested up to: 4.9
6
  Requires PHP: 5.4
7
+ Stable tag: 6.0.3
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
111
 
112
  == Changelog ==
113
 
114
+ = 6.0.3 (August 20, 2018) =
115
+ * Closed Bug: User gets 'trapped' if timer runs out on required question when questions are paginated ([Issue #583](https://github.com/fpcorso/quiz_master_next/issues/583))
116
+ * Closed Bug: If user refreshes quiz page when timer is at 0, cannot submit ([Issue #501](https://github.com/fpcorso/quiz_master_next/issues/501))
117
+ * Closed Bug: Saving quiz name when editing results in error if no changes are made ([Issue #391](https://github.com/fpcorso/quiz_master_next/issues/391))
118
+ * Adds deprecated notice to the quiz setting functions found in the quizCreator object
119
+ * Adds hook after results are stored in the database
120
+
121
  = 6.0.2 (July 18, 2018) =
122
  * Closed Bug: PHP warning thrown on Help page ([Issue #711](https://github.com/fpcorso/quiz_master_next/issues/711))
123
  * Closed Bug: Timer not working on certain sites when using questions per page option ([Issue #709](https://github.com/fpcorso/quiz_master_next/issues/709))
135
 
136
  == Upgrade Notice ==
137
 
138
+ = 6.0.3 =
139
+ Upgrade for several bug fixes
140
+
141
  = 6.0.2 =
142
  Upgrade for fix for timer and blank pages
143