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

Version Description

(March 25, 2017) = * Closed: Fix delete custom post types during uninstall bug (Issue #527) * Closed: Change Shortcode To QSM (Issue #515) * Closed: Search function for quizzes/surveys (Issue #492) * Closed: Create new fields class to handle creation/post data of settings fields (Issue #450) * Closed: Create new settings class to handle the settings data (Issue #449) * Closed: Rewrite options system to allow for extendibility (Issue #448) * Closed: Enable tabs for the admin results page (Issue #408) * Closed: Create onboarding process (Issue #397) * Closed: Create new contact tab to allow form creation (Issue #394) * Closed: Move Certificate to free addon (Issue #381) * Closed: Ability to add check box for privacy statement with the contact fields (Issue #372) * Closed: Customize the "Please complete all required fields!" text (Issue #371) * Closed: Allow admins to customize the validation error messages (Issue #346) * Closed: Hint field cannot be customized (Issue #262) * Closed: Add custom fields to the contact form (Issue #211) * Closed: Scrollable List of Quizzes (Issue #46)

Download this release

Release Info

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

Code changes from version 4.7.10 to 5.0.0

CHANGELOG.md CHANGED
@@ -1,8 +1,18 @@
 
 
 
 
 
 
 
 
 
 
1
  = 4.7.7 (September 10, 2016) =
2
  * Closed Bug: From Email Bug Causing 500 Error On WP 4.6 - Issue #473
3
  * Closed Enhancement: Table Styles Don't Match Default WordPress Styles. - Issue #471
4
  * Closed Bug: Tracking manager causes admin server error when request error occurs. - Issue #470
5
-
6
  = 4.7.6 (July 11, 2016) =
7
  * Closed: Add language and error logs to usage tracking - Issue #457
8
 
1
+ = 4.7.9 (December 13, 2016) =
2
+ * Closed Security: CSRF vulnerability on Questions tab
3
+
4
+ = 4.7.8 (November 2, 2016) =
5
+ * Closed Bug: Apostrophe in translation for tab name text causing errors - Issue #490
6
+ * Closed Bug: Timer resets if user copies link, opens new tab, and pastes link - Issue #489
7
+ * Closed Enhancement: Add Business, Email, And Phone To Quiz Results Search - Issue #485
8
+ * Closed Bug: "You Deserve It" button in review message leads to 404 - Issue #476
9
+ * Closed Bug: In the Hint dropdown text, the 'apostrophe' does not display properly - Issue #453
10
+
11
  = 4.7.7 (September 10, 2016) =
12
  * Closed Bug: From Email Bug Causing 500 Error On WP 4.6 - Issue #473
13
  * Closed Enhancement: Table Styles Don't Match Default WordPress Styles. - Issue #471
14
  * Closed Bug: Tracking manager causes admin server error when request error occurs. - Issue #470
15
+
16
  = 4.7.6 (July 11, 2016) =
17
  * Closed: Add language and error logs to usage tracking - Issue #457
18
 
css/qsm-admin-contact.css ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .contact-form-field {
2
+ padding: 25px 10px 10px;
3
+ margin: 15px 0;
4
+ background: #fff;
5
+ }
6
+
7
+ .contact-form-field.new {
8
+ background: #ffff66;
9
+ }
10
+
11
+ .contact-form-field.deleting {
12
+ background: #ff6666;
13
+ }
14
+
15
+ .contact-form-group {
16
+ margin: 0px 0px 15px;
17
+ }
18
+
19
+ .contact-form-label {
20
+ font-weight: bold;
21
+ margin-right: 10px;
22
+ }
23
+
24
+ .contact-form-control {
25
+ height: 35px;
26
+ padding: 6px 12px;
27
+ font-size: 14px;
28
+ line-height: 1.4;
29
+ }
30
+
31
+ .contact-form-control.wide {
32
+ width: 100%;
33
+ }
css/{qmn_admin.css → qsm-admin.css} RENAMED
@@ -103,7 +103,7 @@ Options Page
103
  About/Credits Page
104
  *********************/
105
 
106
- div.mlw_qmn_icon_wrap {
107
  position: absolute;
108
  top: 0;
109
  right: 0;
@@ -127,6 +127,23 @@ div.mlw_qmn_icon_wrap {
127
  border-radius: 20px;
128
  }
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  ul.changelog {
131
  background-color: #fff;
132
  padding: 10px 10px;
103
  About/Credits Page
104
  *********************/
105
 
106
+ div.qsm_icon_wrap {
107
  position: absolute;
108
  top: 0;
109
  right: 0;
127
  border-radius: 20px;
128
  }
129
 
130
+ .qsm-tab-content .feature {
131
+ margin-bottom: 20px;
132
+ }
133
+
134
+ .qsm-tab-content .feature .feature-headline {
135
+ margin: 1.1em 0 .2em;
136
+ font-size: 40px;
137
+ font-weight: 300;
138
+ line-height: 1.3;
139
+ text-align: center;
140
+ }
141
+
142
+ .qsm-tab-content .feature .feature-text {
143
+ text-align: center;
144
+ font-size: 16px;
145
+ }
146
+
147
  ul.changelog {
148
  background-color: #fff;
149
  padding: 10px 10px;
js/admin.js CHANGED
@@ -1,9 +1,23 @@
1
- function qmn_select_tab(tab, content) {
2
- jQuery("a.nav-tab-active").toggleClass("nav-tab-active");
3
- jQuery(".qmn_tab").hide();
4
- jQuery("#"+content).show();
5
- jQuery("#mlw_qmn_tab_"+tab).toggleClass("nav-tab-active");
6
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  jQuery("#qmn_check_all").change( function() {
9
  jQuery('.qmn_delete_checkbox').prop( 'checked', jQuery('#qmn_check_all').prop('checked') );
1
+
2
+ var QSMAdmin;
3
+ (function ($) {
4
+
5
+ QSMAdmin = {
6
+ selectTab: function( tab ) {
7
+ $( '.qsm-tab' ).removeClass( 'nav-tab-active' );
8
+ $( '.qsm-tab-content' ).hide();
9
+ tab.addClass( 'nav-tab-active' );
10
+ tabID = tab.data( 'tab' );
11
+ $( '.tab-' + tabID ).show();
12
+ }
13
+ };
14
+ $(function() {
15
+ $( '.qsm-tab' ).on( 'click', function( event ) {
16
+ event.preventDefault();
17
+ QSMAdmin.selectTab( $( this ) );
18
+ });
19
+ });
20
+ }(jQuery));
21
 
22
  jQuery("#qmn_check_all").change( function() {
23
  jQuery('.qmn_delete_checkbox').prop( 'checked', jQuery('#qmn_check_all').prop('checked') );
js/qmn_quiz.js CHANGED
@@ -66,7 +66,7 @@ function qmnValidation( element, quiz_form_id ) {
66
  qmnDisplayError( incorrect_error, jQuery( this ), quiz_form_id );
67
  result = false;
68
  }
69
- if( jQuery( this ).attr( 'class' ).indexOf( 'mlwRequiredAccept' ) > -1 && !this.checked ) {
70
  qmnDisplayError( empty_error, jQuery( this ), quiz_form_id );
71
  result = false;
72
  }
66
  qmnDisplayError( incorrect_error, jQuery( this ), quiz_form_id );
67
  result = false;
68
  }
69
+ if( jQuery( this ).attr( 'class' ).indexOf( 'mlwRequiredAccept' ) > -1 && ! jQuery( this ).prop( 'checked' ) ) {
70
  qmnDisplayError( empty_error, jQuery( this ), quiz_form_id );
71
  result = false;
72
  }
js/qsm-admin-contact.js ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * QSM - Contact Form
3
+ */
4
+
5
+ var QSMContact;
6
+ (function ($) {
7
+ QSMContact = {
8
+ load : function() {
9
+ $.each( qsmContactObject.contactForm, function( i, val ) {
10
+ QSMContact.addField( val );
11
+ });
12
+ },
13
+ addField : function( fieldArray ) {
14
+ var contactField = $( '<div class="contact-form-field new">' +
15
+ '<div class="contact-form-group">' +
16
+ '<select class="contact-form-control wide type-control">' +
17
+ '<option value="none">Select a type...</option>' +
18
+ '<option value="text">Small Open Answer</option>' +
19
+ '<option value="email">Email</option>' +
20
+ '<option value="checkbox">Checkbox</option>' +
21
+ '</select>' +
22
+ '</div>' +
23
+ '<div class="contact-form-group">' +
24
+ '<label class="contact-form-label">Label</label>' +
25
+ '<input type="text" class="contact-form-control label-control" value="' + fieldArray.label + '">' +
26
+ '</div>' +
27
+ '<div class="contact-form-group">' +
28
+ '<label class="contact-form-label">Used For</label>' +
29
+ '<select class="contact-form-control use-control">' +
30
+ '<option value="none"></option>' +
31
+ '<option value="name">Name</option>' +
32
+ '<option value="email">Email</option>' +
33
+ '<option value="comp">Business</option>' +
34
+ '<option value="phone">Phone</option>' +
35
+ '</select>' +
36
+ '</div>' +
37
+ '<div class="contact-form-group">' +
38
+ '<label class="contact-form-label">Required?</label>' +
39
+ '<input type="checkbox" class="required-control">' +
40
+ '</div>' +
41
+ '<div class="contact-form-group">' +
42
+ '<a href="#" class="delete-field">Delete</a> | ' +
43
+ '<a href="#" class="copy-field">Duplicate</a>' +
44
+ '</div>' +
45
+ '</div>'
46
+ );
47
+ if ( true === fieldArray.required || "true" === fieldArray.required ) {
48
+ contactField.find( '.required-control' ).prop( 'checked', true );
49
+ }
50
+ switch ( fieldArray.type ) {
51
+ case 'text':
52
+ contactField.find( '.type-control option[value="text"]').prop( 'selected', true );
53
+ break;
54
+ case 'email':
55
+ contactField.find( '.type-control option[value="email"]').prop( 'selected', true );
56
+ break;
57
+ case 'checkbox':
58
+ contactField.find( '.type-control option[value="checkbox"]').prop( 'selected', true );
59
+ break;
60
+ default:
61
+
62
+ }
63
+ switch ( fieldArray.use ) {
64
+ case 'name':
65
+ contactField.find( '.use-control option[value="name"]').prop( 'selected', true );
66
+ break;
67
+ case 'email':
68
+ contactField.find( '.use-control option[value="email"]').prop( 'selected', true );
69
+ break;
70
+ case 'comp':
71
+ contactField.find( '.use-control option[value="comp"]').prop( 'selected', true );
72
+ break;
73
+ case 'phone':
74
+ contactField.find( '.use-control option[value="phone"]').prop( 'selected', true );
75
+ break;
76
+ default:
77
+
78
+ }
79
+ $( '.contact-form' ).append( contactField );
80
+ setTimeout( QSMContact.removeNew, 250 );
81
+ },
82
+ removeNew: function() {
83
+ $( '.contact-form-field' ).removeClass( 'new' );
84
+ },
85
+ duplicateField: function( linkClicked ) {
86
+ var field = linkClicked.parents( '.contact-form-field' );
87
+ var fieldArray = {
88
+ label: field.find( '.label-control' ).val(),
89
+ type: field.find( '.type-control' ).val(),
90
+ required: field.find( '.required-control' ).prop( 'checked' ),
91
+ use: field.find( '.use-control' ).val()
92
+ };
93
+ QSMContact.addField( fieldArray );
94
+ },
95
+ deleteField: function( field ) {
96
+ var parent = field.parents( '.contact-form-field' );
97
+ parent.addClass( 'deleting' );
98
+ setTimeout( function() {
99
+ parent.remove();
100
+ }, 250 );
101
+ },
102
+ newField : function() {
103
+ var fieldArray = {
104
+ label : '',
105
+ type : 'text',
106
+ answers : [],
107
+ required : false,
108
+ use: ''
109
+ };
110
+ QSMContact.addField( fieldArray );
111
+ },
112
+ save : function() {
113
+ QSMContact.displayAlert( 'Saving contact fields...', 'info' );
114
+ var contactFields = $( '.contact-form-field' );
115
+ var contactForm = [];
116
+ var contactEach;
117
+ $.each( contactFields, function( i, val ) {
118
+ contactEach = {
119
+ label: $( this ).find( '.label-control' ).val(),
120
+ type: $( this ).find( '.type-control' ).val(),
121
+ required: $( this ).find( '.required-control' ).prop( 'checked' ),
122
+ use: $( this ).find( '.use-control' ).val()
123
+ };
124
+ contactForm.push( contactEach );
125
+ });
126
+ var data = {
127
+ action: 'qsm_save_contact',
128
+ contact_form: contactForm,
129
+ quiz_id : qsmContactObject.quizID
130
+ };
131
+
132
+ jQuery.post( ajaxurl, data, function( response ) {
133
+ QSMContact.saved( JSON.parse( response ) );
134
+ });
135
+ },
136
+ saved : function( response ) {
137
+ if ( response.status ) {
138
+ QSMContact.displayAlert( '<strong>Success</strong> Your rules have been saved!', 'success' );
139
+ } else {
140
+ QSMContact.displayAlert( '<strong>Error</strong> There was an error encountered when saving your rules. Please try again.', 'error' );
141
+ }
142
+ },
143
+ displayAlert: function( message, type ) {
144
+ QSMContact.clearAlerts();
145
+ $( '.contact-message' ).addClass( 'notice' );
146
+ switch ( type ) {
147
+ case 'info':
148
+ $( '.contact-message' ).addClass( 'notice-info' );
149
+ break;
150
+ case 'error':
151
+ $( '.contact-message' ).addClass( 'notice-error' );
152
+ break;
153
+ case 'success':
154
+ $( '.contact-message' ).addClass( 'notice-success' );
155
+ break;
156
+ default:
157
+ }
158
+ $( '.contact-message' ).append( '<p>' + message + '</p>' );
159
+ },
160
+ clearAlerts: function() {
161
+ $( '.contact-message' ).empty().removeClass().addClass( 'contact-message' );
162
+ }
163
+ };
164
+ $(function() {
165
+ QSMContact.load();
166
+ $( '.add-contact-field' ).on( 'click', function() {
167
+ QSMContact.newField();
168
+ });
169
+ $( '.save-contact' ).on( 'click', function() {
170
+ QSMContact.save();
171
+ });
172
+ $( '.contact-form' ).on( 'click', '.delete-field', function( event ) {
173
+ event.preventDefault();
174
+ QSMContact.deleteField( $( this ) );
175
+ });
176
+ $( '.contact-form' ).on( 'click', '.copy-field', function( event ) {
177
+ event.preventDefault();
178
+ QSMContact.duplicateField( $( this ) );
179
+ });
180
+ $( '.contact-form' ).sortable({
181
+ containment: "parent",
182
+ cursor: 'move',
183
+ opacity: 0.6
184
+ });
185
+ });
186
+ }(jQuery));
js/qsm-admin.js ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * QSM - Quizzes/Surveys Page
3
+ */
4
+
5
+ var QSMQuizzesSurveys;
6
+ (function ($) {
7
+ QSMQuizzesSurveys = {
8
+ load: function() {
9
+ if ( 0 !== qsmQuizObject.length ) {
10
+ $.each( qsmQuizObject, function( i, val ) {
11
+ QSMQuizzesSurveys.addQuizRow( val );
12
+ });
13
+ $( '#the-list tr' ).filter( ':even' ).addClass( 'alternate' );
14
+ } else {
15
+ $( '.qsm-quizzes-page-content' ).hide();
16
+ $( '#new_quiz_button' ).parent().after( '<h2>You do not have any quizzes or surveys. Click "Add New" to get started.</h2> ' +
17
+ '<h2>Is this your first time using this plugin? Check out our <a href="https://quizandsurveymaster.com/documentation/?utm_source=qsm-quizzes-page&utm_medium=plugin&utm_campaign=qsm_plugin&utm_content=documentation" target="_blank">Documentation</a> or watch our Getting Started Video below</h2>' +
18
+ '<iframe width="560" height="315" src="https://www.youtube.com/embed/n8xfNk490Wg" frameborder="0" allowfullscreen></iframe>' );
19
+ }
20
+ },
21
+ addQuizRow: function( quizData ) {
22
+ var row = $( '<tr class="qsm-quiz-row" data-id="' + quizData.id + '">' +
23
+ '<td class="post-title column-title"><span class="qsm-quiz-name">' + quizData.name + '</span> <a class="qsm-edit-name" href="#">Edit Name</a>' +
24
+ '<div class="row-actions">' +
25
+ '<a class="qsm-action-link" href="admin.php?page=mlw_quiz_options&&quiz_id=' + quizData.id + '">Edit</a> | ' +
26
+ '<a class="qsm-action-link" href="admin.php?page=mlw_quiz_results&&quiz_id' + quizData.id + '">Results</a> | ' +
27
+ '<a class="qsm-action-link qsm-action-link-duplicate" href="#">Duplicate</a> | ' +
28
+ '<a class="qsm-action-link qsm-action-link-delete" href="#">Delete</a>' +
29
+ '</div>' +
30
+ '</td>' +
31
+ '<td><a href="' + quizData.link + '">View Quiz</a>' +
32
+ '<div class="row-actions">' +
33
+ '<a class="qsm-action-link" href="post.php?post=' + quizData.postID + '&action=edit">Edit Post Settings</a>' +
34
+ '</div>' +
35
+ '</td>' +
36
+ '<td>[qsm quiz=' + quizData.id + ']</td>' +
37
+ '<td>[mlw_quizmaster_leaderboard mlw_quiz=' + quizData.id + ']</td>' +
38
+ '<td>' + quizData.views + '</td>' +
39
+ '<td>' + quizData.taken + '</td>' +
40
+ '<td>' + quizData.lastActivity + '</td>' +
41
+ '</tr>'
42
+ );
43
+ $( '#the-list' ).append( row );
44
+ },
45
+ searchQuizzes: function( query ) {
46
+ $( ".qsm-quiz-row" ).each(function() {
47
+ if ( -1 === $( this ).find( '.qsm-quiz-name' ).text().toLowerCase().indexOf( query.toLowerCase() ) ) {
48
+ $( this ).hide();
49
+ } else {
50
+ $( this ).show();
51
+ }
52
+ });
53
+ },
54
+ deleteQuiz: function( quiz_id ) {
55
+ $( '#delete_quiz_id' ).val( quiz_id );
56
+ $.each( qsmQuizObject, function( i, val ) {
57
+ if ( val.id == quiz_id ) {
58
+ $( '#delete_quiz_name' ).val( val.name );
59
+ }
60
+ });
61
+ $( '#delete_dialog' ).dialog( 'open' );
62
+ },
63
+ editQuizName: function( quiz_id ) {
64
+ $( '#edit_quiz_id' ).val( quiz_id );
65
+ $.each( qsmQuizObject, function( i, val ) {
66
+ if ( val.id == quiz_id ) {
67
+ $( '#edit_quiz_name' ).val( val.name );
68
+ }
69
+ });
70
+ $( '#edit_dialog' ).dialog( 'open' );
71
+ },
72
+ duplicateQuiz: function( quiz_id ) {
73
+ $( '#duplicate_quiz_id' ).val( quiz_id );
74
+ $( '#duplicate_dialog' ).dialog( 'open' );
75
+ }
76
+ };
77
+ $(function() {
78
+ $( '#new_quiz_dialog' ).dialog({
79
+ autoOpen: false,
80
+ buttons: {
81
+ Cancel: function() {
82
+ $( this ).dialog( 'close' );
83
+ }
84
+ }
85
+ });
86
+ $( '#delete_dialog' ).dialog({
87
+ autoOpen: false,
88
+ buttons: {
89
+ Cancel: function() {
90
+ $( this ).dialog( 'close' );
91
+ }
92
+ }
93
+ });
94
+ $( '#edit_dialog' ).dialog({
95
+ autoOpen: false,
96
+ buttons: {
97
+ Cancel: function() {
98
+ $( this ).dialog( 'close' );
99
+ }
100
+ }
101
+ });
102
+ $( '#duplicate_dialog' ).dialog({
103
+ autoOpen: false,
104
+ buttons: {
105
+ Cancel: function() {
106
+ $( this ).dialog( 'close' );
107
+ }
108
+ }
109
+ });
110
+ $( '#new_quiz_button, #new_quiz_button_two' ).on( 'click', function( event ) {
111
+ event.preventDefault();
112
+ $( '#new_quiz_dialog' ).dialog( 'open' );
113
+ });
114
+ $( '#quiz_search' ).keyup( function() {
115
+ QSMQuizzesSurveys.searchQuizzes( $( this ).val() );
116
+ });
117
+ $( '#the-list' ).on( 'click', '.qsm-action-link-delete', function( event ) {
118
+ event.preventDefault();
119
+ QSMQuizzesSurveys.deleteQuiz( $( this ).parents( '.qsm-quiz-row' ).data( 'id' ) );
120
+ });
121
+ $( '#the-list' ).on( 'click', '.qsm-action-link-duplicate', function( event ) {
122
+ event.preventDefault();
123
+ QSMQuizzesSurveys.duplicateQuiz( $( this ).parents( '.qsm-quiz-row' ).data( 'id' ) );
124
+ });
125
+ $( '#the-list' ).on( 'click', '.qsm-edit-name', function( event ) {
126
+ event.preventDefault();
127
+ QSMQuizzesSurveys.editQuizName( $( this ).parents( '.qsm-quiz-row' ).data( 'id' ) );
128
+ });
129
+ QSMQuizzesSurveys.load();
130
+ });
131
+ }(jQuery));
mlw_quizmaster2.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: Quiz And Survey Master
4
  * Description: Easily and quickly add quizzes and surveys to your website.
5
- * Version: 4.7.10
6
  * Author: Frank Corso
7
  * Author URI: http://www.quizandsurveymaster.com/
8
  * Plugin URI: http://www.quizandsurveymaster.com/
@@ -10,7 +10,7 @@
10
  * Domain Path: /languages
11
  *
12
  * @author Frank Corso
13
- * @version 4.7.10
14
  */
15
  if ( ! defined( 'ABSPATH' ) ) exit;
16
 
@@ -30,7 +30,7 @@ class MLWQuizMasterNext {
30
  * @var string
31
  * @since 4.0.0
32
  */
33
- public $version = '4.7.10';
34
 
35
  /**
36
  * QMN Alert Manager Object
@@ -72,6 +72,14 @@ class MLWQuizMasterNext {
72
  */
73
  public $audit_manager;
74
 
 
 
 
 
 
 
 
 
75
  /**
76
  * Main Construct Function
77
  *
@@ -93,60 +101,64 @@ class MLWQuizMasterNext {
93
  * @since 3.6.1
94
  * @return void
95
  */
96
- private function load_dependencies()
97
- {
98
 
99
- include("php/class-qsm-install.php");
 
100
 
101
- include("php/class-qmn-log-manager.php");
102
  $this->log_manager = new QMN_Log_Manager;
103
 
104
  include( "php/class-qsm-audit.php" );
105
  $this->audit_manager = new QSM_Audit();
106
 
107
  if ( is_admin() ) {
108
- include("php/stats-page.php");
109
- include("php/quizzes-page.php");
110
- include("php/quiz-options-page.php");
111
- include("php/admin-results-page.php");
112
- include("php/admin-results-details-page.php");
113
- include("php/tools-page.php");
114
- include("php/class-qsm-changelog-generator.php");
115
- include("php/about-page.php");
116
- include("php/help-page.php");
117
- include("php/dashboard-widgets.php");
118
- include("php/options-page-questions-tab.php");
119
- include("php/options-page-text-tab.php");
120
- include("php/options-page-option-tab.php");
121
- include("php/options-page-leaderboard-tab.php");
122
- include("php/options-page-certificate-tab.php");
123
- include("php/options-page-email-tab.php");
124
- include("php/options-page-results-page-tab.php");
125
- include("php/options-page-style-tab.php");
126
- include("php/options-page-tools-tab.php");
127
- include("php/options-page-preview-tab.php");
128
- include("php/addons-page.php");
129
- include("php/settings-page.php");
130
- include("php/class-qmn-tracking.php");
131
- include("php/class-qmn-review-message.php");
132
  }
133
- include("php/class-qmn-quiz-manager.php");
 
134
 
135
- include("php/leaderboard-shortcode.php");
136
- include("php/widgets.php");
137
- include("php/template-variables.php");
138
- include("php/adverts-generate.php");
139
- include("php/question-types.php");
140
- include("php/default-templates.php");
141
 
142
- include("php/class-qmn-alert-manager.php");
143
  $this->alertManager = new MlwQmnAlertManager();
144
 
145
- include("php/class-qmn-quiz-creator.php");
146
  $this->quizCreator = new QMNQuizCreator();
147
 
148
- include("php/class-qmn-plugin-helper.php");
149
  $this->pluginHelper = new QMNPluginHelper();
 
 
 
150
  }
151
 
152
  /**
@@ -157,14 +169,13 @@ class MLWQuizMasterNext {
157
  * @since 3.6.1
158
  * @return void
159
  */
160
- private function add_hooks()
161
- {
162
- add_action('admin_menu', array( $this, 'setup_admin_menu'));
163
- add_action('admin_head', array( $this, 'admin_head'), 900);
164
- add_action('widgets_init', create_function('', 'return register_widget("Mlw_Qmn_Leaderboard_Widget");'));
165
- add_shortcode('mlw_quizmaster_leaderboard', 'mlw_quiz_leaderboard_shortcode');
166
- add_action('plugins_loaded', array( $this, 'setup_translations'));
167
- add_action('init', array( $this, 'register_quiz_post_types'));
168
  }
169
 
170
  /**
@@ -173,8 +184,9 @@ class MLWQuizMasterNext {
173
  * @since 4.1.0
174
  * @return void
175
  */
176
- public function register_quiz_post_types()
177
- {
 
178
  $quiz_labels = array(
179
  'name' => 'Quizzes',
180
  'singular_name' => 'Quiz',
@@ -191,22 +203,29 @@ class MLWQuizMasterNext {
191
  'not_found' => 'No Quiz Found',
192
  'not_found_in_trash' => 'No Quiz Found In Trash'
193
  );
 
 
194
  $has_archive = true;
195
  $exclude_search = false;
196
  $cpt_slug = 'quiz';
197
  $settings = (array) get_option( 'qmn-settings' );
198
- if (isset($settings['cpt_archive']) && $settings['cpt_archive'] == '1')
199
- {
 
200
  $has_archive = false;
201
  }
202
- if (isset($settings['cpt_search']) && $settings['cpt_search'] == '1')
203
- {
 
204
  $exclude_search = true;
205
  }
206
- if (isset($settings['cpt_slug']))
207
- {
208
- $cpt_slug = trim(strtolower(str_replace(" ", "-", $settings['cpt_slug'])));
 
209
  }
 
 
210
  $quiz_args = array(
211
  'show_ui' => true,
212
  'show_in_menu' => false,
@@ -215,11 +234,12 @@ class MLWQuizMasterNext {
215
  'publicly_queryable' => true,
216
  'exclude_from_search' => $exclude_search,
217
  'label' => 'Quizzes',
218
- 'rewrite' => array('slug' => $cpt_slug),
219
  'has_archive' => $has_archive,
220
  'supports' => array( 'title', 'author', 'comments' )
221
  );
222
 
 
223
  register_post_type( 'quiz', $quiz_args );
224
  }
225
 
@@ -231,19 +251,17 @@ class MLWQuizMasterNext {
231
  * @since 3.6.1
232
  * @return void
233
  */
234
- public function setup_admin_menu()
235
- {
236
- if (function_exists('add_menu_page'))
237
- {
238
- add_menu_page('Quiz And Survey Master', __('Quizzes/Surveys', 'quiz-master-next'), 'moderate_comments', __FILE__, 'mlw_generate_quiz_admin', 'dashicons-feedback');
239
- add_submenu_page(__FILE__, __('Settings', 'quiz-master-next'), __('Settings', 'quiz-master-next'), 'moderate_comments', 'mlw_quiz_options', 'mlw_generate_quiz_options');
240
- add_submenu_page(__FILE__, __('Results', 'quiz-master-next'), __('Results', 'quiz-master-next'), 'moderate_comments', 'mlw_quiz_results', 'mlw_generate_quiz_results');
241
- add_submenu_page(__FILE__, __('Result Details', 'quiz-master-next'), __('Result Details', 'quiz-master-next'), 'moderate_comments', 'mlw_quiz_result_details', 'mlw_generate_result_details');
242
- add_submenu_page(__FILE__, __('Settings', 'quiz-master-next'), __('Settings', 'quiz-master-next'), 'manage_options', 'qmn_global_settings', array('QMNGlobalSettingsPage', 'display_page'));
243
- add_submenu_page(__FILE__, __('Tools', 'quiz-master-next'), __('Tools', 'quiz-master-next'), 'manage_options', 'mlw_quiz_tools', 'mlw_generate_quiz_tools');
244
- add_submenu_page(__FILE__, __('Stats', 'quiz-master-next'), __('Stats', 'quiz-master-next'), 'moderate_comments', 'qmn_stats', 'qmn_generate_stats_page');
245
- add_submenu_page(__FILE__, __('Addon Settings', 'quiz-master-next'), __('Addon Settings', 'quiz-master-next'), 'manage_options', 'qmn_addons', 'qmn_addons_page');
246
- add_submenu_page(__FILE__, __('Help', 'quiz-master-next'), __('Help', 'quiz-master-next'), 'moderate_comments', 'mlw_quiz_help', 'mlw_generate_help_page');
247
 
248
  add_dashboard_page(
249
  __( 'QSM About', 'quiz' ),
@@ -263,8 +281,7 @@ class MLWQuizMasterNext {
263
  * @since 4.1.0
264
  * @return void
265
  */
266
- public function admin_head()
267
- {
268
  remove_submenu_page( 'index.php', 'qsm_about' );
269
  remove_submenu_page( 'quiz-master-next/mlw_quizmaster2.php', 'mlw_quiz_options' );
270
  remove_submenu_page( 'quiz-master-next/mlw_quizmaster2.php', 'mlw_quiz_result_details' );
@@ -276,8 +293,7 @@ class MLWQuizMasterNext {
276
  * @since 3.6.1
277
  * @return void
278
  */
279
- public function setup_translations()
280
- {
281
  load_plugin_textdomain( 'quiz-master-next', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
282
  }
283
  }
2
  /**
3
  * Plugin Name: Quiz And Survey Master
4
  * Description: Easily and quickly add quizzes and surveys to your website.
5
+ * Version: 5.0.0
6
  * Author: Frank Corso
7
  * Author URI: http://www.quizandsurveymaster.com/
8
  * Plugin URI: http://www.quizandsurveymaster.com/
10
  * Domain Path: /languages
11
  *
12
  * @author Frank Corso
13
+ * @version 5.0.0
14
  */
15
  if ( ! defined( 'ABSPATH' ) ) exit;
16
 
30
  * @var string
31
  * @since 4.0.0
32
  */
33
+ public $version = '5.0.0';
34
 
35
  /**
36
  * QMN Alert Manager Object
72
  */
73
  public $audit_manager;
74
 
75
+ /**
76
+ * QSM Settings Object
77
+ *
78
+ * @var object
79
+ * @since 5.0.0
80
+ */
81
+ public $quiz_settings;
82
+
83
  /**
84
  * Main Construct Function
85
  *
101
  * @since 3.6.1
102
  * @return void
103
  */
104
+ private function load_dependencies() {
 
105
 
106
+ include( "php/class-qsm-install.php" );
107
+ include( "php/class-qsm-fields.php" );
108
 
109
+ include( "php/class-qmn-log-manager.php" );
110
  $this->log_manager = new QMN_Log_Manager;
111
 
112
  include( "php/class-qsm-audit.php" );
113
  $this->audit_manager = new QSM_Audit();
114
 
115
  if ( is_admin() ) {
116
+ include( "php/stats-page.php" );
117
+ include( "php/quizzes-page.php" );
118
+ include( "php/quiz-options-page.php" );
119
+ include( "php/admin-results-page.php" );
120
+ include( "php/admin-results-details-page.php" );
121
+ include( "php/tools-page.php" );
122
+ include( "php/class-qsm-changelog-generator.php" );
123
+ include( "php/about-page.php" );
124
+ include( "php/help-page.php" );
125
+ include( "php/dashboard-widgets.php" );
126
+ include( "php/options-page-questions-tab.php" );
127
+ include("php/options-page-contact-tab.php");
128
+ include( "php/options-page-text-tab.php" );
129
+ include( "php/options-page-option-tab.php" );
130
+ include( "php/options-page-leaderboard-tab.php" );
131
+ include( "php/options-page-email-tab.php" );
132
+ include( "php/options-page-results-page-tab.php" );
133
+ include( "php/options-page-style-tab.php" );
134
+ include( "php/options-page-tools-tab.php" );
135
+ include( "php/options-page-preview-tab.php" );
136
+ include( "php/addons-page.php" );
137
+ include( "php/settings-page.php" );
138
+ include( "php/class-qmn-tracking.php" );
139
+ include( "php/class-qmn-review-message.php" );
140
  }
141
+ include( "php/class-qsm-contact-manager.php" );
142
+ include( "php/class-qmn-quiz-manager.php" );
143
 
144
+ include( "php/leaderboard-shortcode.php" );
145
+ include( "php/widgets.php" );
146
+ include( "php/template-variables.php" );
147
+ include( "php/adverts-generate.php" );
148
+ include( "php/question-types.php" );
149
+ include( "php/default-templates.php" );
150
 
151
+ include( "php/class-qmn-alert-manager.php" );
152
  $this->alertManager = new MlwQmnAlertManager();
153
 
154
+ include( "php/class-qmn-quiz-creator.php" );
155
  $this->quizCreator = new QMNQuizCreator();
156
 
157
+ include( "php/class-qmn-plugin-helper.php" );
158
  $this->pluginHelper = new QMNPluginHelper();
159
+
160
+ include( "php/class-qsm-settings.php" );
161
+ $this->quiz_settings = new QSM_Quiz_Settings();
162
  }
163
 
164
  /**
169
  * @since 3.6.1
170
  * @return void
171
  */
172
+ private function add_hooks() {
173
+ add_action( 'admin_menu', array( $this, 'setup_admin_menu' ) );
174
+ add_action( 'admin_head', array( $this, 'admin_head' ), 900 );
175
+ add_action( 'widgets_init', create_function( '', 'return register_widget("Mlw_Qmn_Leaderboard_Widget");' ) );
176
+ add_shortcode( 'mlw_quizmaster_leaderboard', 'mlw_quiz_leaderboard_shortcode' );
177
+ add_action( 'plugins_loaded', array( $this, 'setup_translations' ) );
178
+ add_action( 'init', array( $this, 'register_quiz_post_types' ) );
 
179
  }
180
 
181
  /**
184
  * @since 4.1.0
185
  * @return void
186
  */
187
+ public function register_quiz_post_types() {
188
+
189
+ // Prepares labels
190
  $quiz_labels = array(
191
  'name' => 'Quizzes',
192
  'singular_name' => 'Quiz',
203
  'not_found' => 'No Quiz Found',
204
  'not_found_in_trash' => 'No Quiz Found In Trash'
205
  );
206
+
207
+ // Checks settings to see if we need to alter the defaults
208
  $has_archive = true;
209
  $exclude_search = false;
210
  $cpt_slug = 'quiz';
211
  $settings = (array) get_option( 'qmn-settings' );
212
+
213
+ // Checks if admin turned off archive
214
+ if ( isset( $settings['cpt_archive'] ) && '1' == $settings['cpt_archive'] ) {
215
  $has_archive = false;
216
  }
217
+
218
+ // Checks if admin turned off search
219
+ if ( isset( $settings['cpt_search'] ) && '1' == $settings['cpt_search'] ) {
220
  $exclude_search = true;
221
  }
222
+
223
+ // Checks if admin changed slug
224
+ if ( isset( $settings['cpt_slug'] ) ) {
225
+ $cpt_slug = trim( strtolower( str_replace( " ", "-", $settings['cpt_slug'] ) ) );
226
  }
227
+
228
+ // Prepares post type array
229
  $quiz_args = array(
230
  'show_ui' => true,
231
  'show_in_menu' => false,
234
  'publicly_queryable' => true,
235
  'exclude_from_search' => $exclude_search,
236
  'label' => 'Quizzes',
237
+ 'rewrite' => array( 'slug' => $cpt_slug ),
238
  'has_archive' => $has_archive,
239
  'supports' => array( 'title', 'author', 'comments' )
240
  );
241
 
242
+ // Registers post type
243
  register_post_type( 'quiz', $quiz_args );
244
  }
245
 
251
  * @since 3.6.1
252
  * @return void
253
  */
254
+ public function setup_admin_menu() {
255
+ if ( function_exists( 'add_menu_page' ) ) {
256
+ add_menu_page( 'Quiz And Survey Master', __( 'Quizzes/Surveys', 'quiz-master-next' ), 'moderate_comments', __FILE__, 'qsm_generate_quizzes_surveys_page', 'dashicons-feedback' );
257
+ add_submenu_page( __FILE__, __( 'Settings', 'quiz-master-next' ), __( 'Settings', 'quiz-master-next' ), 'moderate_comments', 'mlw_quiz_options', 'mlw_generate_quiz_options' );
258
+ add_submenu_page( __FILE__, __( 'Results', 'quiz-master-next' ), __( 'Results', 'quiz-master-next' ), 'moderate_comments', 'mlw_quiz_results', 'qsm_generate_admin_results_page' );
259
+ add_submenu_page( __FILE__, __( 'Result Details', 'quiz-master-next' ), __( 'Result Details', 'quiz-master-next' ), 'moderate_comments', 'mlw_quiz_result_details', 'mlw_generate_result_details' );
260
+ add_submenu_page( __FILE__, __( 'Settings', 'quiz-master-next' ), __( 'Settings', 'quiz-master-next' ), 'manage_options', 'qmn_global_settings', array( 'QMNGlobalSettingsPage', 'display_page' ) );
261
+ add_submenu_page( __FILE__, __( 'Tools', 'quiz-master-next' ), __( 'Tools', 'quiz-master-next' ), 'manage_options', 'mlw_quiz_tools', 'mlw_generate_quiz_tools' );
262
+ add_submenu_page( __FILE__, __( 'Stats', 'quiz-master-next' ), __( 'Stats', 'quiz-master-next' ), 'moderate_comments', 'qmn_stats', 'qmn_generate_stats_page' );
263
+ add_submenu_page( __FILE__, __( 'Addon Settings', 'quiz-master-next' ), __( 'Addon Settings', 'quiz-master-next' ), 'manage_options', 'qmn_addons', 'qmn_addons_page' );
264
+ add_submenu_page( __FILE__, __( 'Help', 'quiz-master-next' ), __( 'Help', 'quiz-master-next' ), 'moderate_comments', 'mlw_quiz_help', 'mlw_generate_help_page' );
 
 
265
 
266
  add_dashboard_page(
267
  __( 'QSM About', 'quiz' ),
281
  * @since 4.1.0
282
  * @return void
283
  */
284
+ public function admin_head() {
 
285
  remove_submenu_page( 'index.php', 'qsm_about' );
286
  remove_submenu_page( 'quiz-master-next/mlw_quizmaster2.php', 'mlw_quiz_options' );
287
  remove_submenu_page( 'quiz-master-next/mlw_quizmaster2.php', 'mlw_quiz_result_details' );
293
  * @since 3.6.1
294
  * @return void
295
  */
296
+ public function setup_translations() {
 
297
  load_plugin_textdomain( 'quiz-master-next', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
298
  }
299
  }
php/about-page.php CHANGED
@@ -10,47 +10,69 @@ if ( ! defined( 'ABSPATH' ) ) exit;
10
  function mlw_generate_about_page() {
11
 
12
  global $mlwQuizMasterNext;
13
- $mlw_quiz_version = $mlwQuizMasterNext->version;
14
- wp_enqueue_script( 'jquery' );
15
- wp_enqueue_script( 'jquery-ui-core' );
16
- wp_enqueue_script( 'jquery-ui-dialog' );
17
- wp_enqueue_script( 'jquery-ui-button' );
18
- wp_enqueue_script( 'jquery-effects-blind' );
19
- wp_enqueue_script( 'jquery-effects-explode' );
20
- wp_enqueue_style( 'qmn_admin_style', plugins_url( '../css/qmn_admin.css' , __FILE__ ) );
21
- wp_enqueue_script('qmn_admin_js', plugins_url( '../js/admin.js' , __FILE__ ));
22
  ?>
23
  <style>
24
- div.mlw_qmn_icon_wrap
25
- {
26
  background: <?php echo 'url("'.plugins_url( '../assets/icon-128x128.png' , __FILE__ ).'")'; ?> no-repeat;
27
  }
28
  </style>
29
  <div class="wrap about-wrap">
30
  <h1><?php _e('Welcome To Quiz And Survey Master (Formerly Quiz Master Next)', 'quiz-master-next'); ?></h1>
31
  <div class="about-text"><?php _e('Thank you for updating!', 'quiz-master-next'); ?></div>
32
- <div class="mlw_qmn_icon_wrap"><?php echo $mlw_quiz_version; ?></div>
33
  <h2 class="nav-tab-wrapper">
34
- <a href="javascript:qmn_select_tab(1, 'mlw_quiz_what_new');" id="mlw_qmn_tab_1" class="nav-tab nav-tab-active">
35
  <?php _e("What's New!", 'quiz-master-next'); ?></a>
36
- <a href="javascript:qmn_select_tab(2, 'mlw_quiz_changelog');" id="mlw_qmn_tab_2" class="nav-tab">
37
  <?php _e('Changelog', 'quiz-master-next'); ?></a>
38
- <a href="javascript:qmn_select_tab(3, 'qmn_contributors');" id="mlw_qmn_tab_3" class="nav-tab">
39
  <?php _e('People Who Make QSM Possible', 'quiz-master-next'); ?></a>
40
  </h2>
41
- <div id="mlw_quiz_what_new" class="qmn_tab">
42
- <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">Notice: Certificates Are Being Moved</h2>
43
- <p style="text-align: center;">The certificate feature is being moved from core to a free addon. If you use certificates, please <a target="_blank" href="http://quizandsurveymaster.com/certificate-feature-moved/?utm_source=about_page&utm_medium=plugin&utm_campaign=qsm_plugin&utm_content=certificate_removal_notice">read our post about certificates being moved.</a></p>
44
- <br />
45
- <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">Major Coming Changes In 5.0.0</h2>
46
- <p style="text-align: center;">We have several major changes and features we are planning for version 5.0.0. To keep up with the changes and be notified when the beta becomes available. Please <a target="_blank" href="http://quizandsurveymaster.com/subscribe-to-our-newsletter/?utm_source=about_page&utm_medium=plugin&utm_campaign=qsm_plugin&utm_content=subscribe_for_beta_notices">subscribe to our newsletter</a>.</p>
47
- <br />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  </div>
49
- <div id="mlw_quiz_changelog" class="qmn_tab" style="display: none;">
50
  <h2>Changelog</h2>
51
- <?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 31 ); ?>
52
  </div>
53
- <div id="qmn_contributors" class="qmn_tab" style="display:none;">
54
  <h2>GitHub Contributors</h2>
55
  <?php
56
  $contributors = get_transient( 'qmn_contributors' );
10
  function mlw_generate_about_page() {
11
 
12
  global $mlwQuizMasterNext;
13
+ $version = $mlwQuizMasterNext->version;
14
+ wp_enqueue_style( 'qsm_admin_style', plugins_url( '../css/qsm-admin.css' , __FILE__ ), array(), '5.0.0' );
15
+ wp_enqueue_script( 'qsm_admin_js', plugins_url( '../js/admin.js' , __FILE__ ), array( 'jquery' ), '5.0.0' );
 
 
 
 
 
 
16
  ?>
17
  <style>
18
+ div.qsm_icon_wrap {
 
19
  background: <?php echo 'url("'.plugins_url( '../assets/icon-128x128.png' , __FILE__ ).'")'; ?> no-repeat;
20
  }
21
  </style>
22
  <div class="wrap about-wrap">
23
  <h1><?php _e('Welcome To Quiz And Survey Master (Formerly Quiz Master Next)', 'quiz-master-next'); ?></h1>
24
  <div class="about-text"><?php _e('Thank you for updating!', 'quiz-master-next'); ?></div>
25
+ <div class="qsm_icon_wrap"><?php echo $version; ?></div>
26
  <h2 class="nav-tab-wrapper">
27
+ <a href="#" data-tab='1' class="nav-tab nav-tab-active qsm-tab">
28
  <?php _e("What's New!", 'quiz-master-next'); ?></a>
29
+ <a href="#" data-tab='2' class="nav-tab qsm-tab">
30
  <?php _e('Changelog', 'quiz-master-next'); ?></a>
31
+ <a href="#" data-tab='3' class="nav-tab qsm-tab">
32
  <?php _e('People Who Make QSM Possible', 'quiz-master-next'); ?></a>
33
  </h2>
34
+ <div class="qsm-tab-content tab-1">
35
+ <div class="feature">
36
+ <h2 class="feature-headline">Welcome to QSM 5.0!</h2>
37
+ <p class="feature-text">There are many changes in version 5.0. From a contact fields system to new developer functions, there are a lot to see.</p>
38
+ </div>
39
+ <div class="feature">
40
+ <h2 class="feature-headline">New Contact Fields System</h2>
41
+ <p class="feature-text">The biggest change is our new contact fields. Instead of having to edit some of the options on one tab, the text on another tab, and final settings on another tab, all of the contact field options are on the new "Contact" tab.</p>
42
+ <p class="feature-text">Even better, you can now create new contact fields for anything you need! Need an "Age" field or an "Attendee ID" field? Now you can!</p>
43
+ <p class="feature-text">You can now choose from three different contact field types: Small Open Answer, Email, or Checkbox.</p>
44
+ </div>
45
+ <div class="feature">
46
+ <h2 class="feature-headline">More Text Is Editable</h2>
47
+ <p class="feature-text">You can now edit the text for the "Hint" as well as all 4 of the error messages that are used when validating a user's responses. You can edit these on the "Text" tab.</p>
48
+ </div>
49
+ <div class="feature">
50
+ <h2 class="feature-headline">Scrollable And Searchable Quizzes/Surveys</h2>
51
+ <p class="feature-text">For the users who have many quizzes and surveys on their site, it has been difficult and frustrating to find a particular quiz/survey to edit it on the Quizzes page. Now, the quizzes/surveys can be searched using the new searchbox in the top-right! Also, there are no more pages of quizzes/surveys to look through as the quizzes/surveys load as you scroll down making editing much quicker and more efficient.</p>
52
+ </div>
53
+ <div class="feature">
54
+ <h2 class="feature-headline">Introduction Of Onboarding Process</h2>
55
+ <p class="feature-text">New users of this plugin will now see a getting started video and documentation when first accessing the Quizzes/Surveys page.</p>
56
+ </div>
57
+ <div class="feature">
58
+ <h2 class="feature-headline">Certificate Is Now An Addon</h2>
59
+ <p class="feature-text">As we stated 8 months ago, the certificate feature is no longer built into the plugin and is available as a free addon.</p>
60
+ </div>
61
+ <hr />
62
+ <div class="feature">
63
+ <h2 class="feature-headline">For Developers: New Settings System</h2>
64
+ <p class="feature-text">The settings system has been completely rewritten and is now stored as serialized arrays that can be extended instead of hardcoded as columns in the database. You can now "register" settings with defaults and assign which tab they belong to. Documentation coming soon.</p>
65
+ </div>
66
+ <div class="feature">
67
+ <h2 class="feature-headline">For Developers: New Results Page Tabs</h2>
68
+ <p class="feature-text">The "Results" page in the admin can now be extended with tabs. A great location for adding features that affect or analyze the results.</p>
69
+ </div>
70
  </div>
71
+ <div class="qsm-tab-content tab-2" style="display: none;">
72
  <h2>Changelog</h2>
73
+ <?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 19 ); ?>
74
  </div>
75
+ <div class="qsm-tab-content tab-3" style="display:none;">
76
  <h2>GitHub Contributors</h2>
77
  <?php
78
  $contributors = get_transient( 'qmn_contributors' );
php/admin-results-details-page.php CHANGED
@@ -67,6 +67,7 @@ function qmn_generate_results_details_tab() {
67
  $template = htmlspecialchars_decode( $settings['results_details_template'], ENT_QUOTES );
68
  } else {
69
  $template = "<h2>Quiz Results for %QUIZ_NAME%</h2>
 
70
  <p>Name Provided: %USER_NAME%</p>
71
  <p>Business Provided: %USER_BUSINESS%</p>
72
  <p>Phone Provided: %USER_PHONE%</p>
@@ -80,6 +81,9 @@ function qmn_generate_results_details_tab() {
80
  }
81
  if ( is_serialized( $mlw_results_data->quiz_results ) && is_array( @unserialize( $mlw_results_data->quiz_results ) ) ) {
82
  $results = unserialize($mlw_results_data->quiz_results);
 
 
 
83
  } else {
84
  $template = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_results_data->quiz_results, $template);
85
  $template = str_replace( "%TIMER%" , '', $template);
@@ -87,7 +91,8 @@ function qmn_generate_results_details_tab() {
87
  $results = array(
88
  0,
89
  array(),
90
- ''
 
91
  );
92
  }
93
  $qmn_array_for_variables = array(
@@ -106,7 +111,8 @@ function qmn_generate_results_details_tab() {
106
  'total_correct' => $mlw_results_data->correct,
107
  'total_questions' => $mlw_results_data->total,
108
  'comments' => $results[2],
109
- 'question_answers_array' => $results[1]
 
110
  );
111
  $template = apply_filters( 'mlw_qmn_template_variable_results_page', $template, $qmn_array_for_variables );
112
  $template = str_replace( "\n" , "<br>", $template );
@@ -125,100 +131,4 @@ function qmn_results_details_tab() {
125
  $mlwQuizMasterNext->pluginHelper->register_results_settings_tab( __( "Results", 'quiz-master-next' ), "qmn_generate_results_details_tab" );
126
  }
127
  add_action( "plugins_loaded", 'qmn_results_details_tab' );
128
-
129
-
130
- /**
131
- * Creates the certificate in the certificate tab.
132
- *
133
- * @param type description
134
- * @return type description
135
- * @since 4.4.0
136
- */
137
- function qmn_generate_results_certificate_tab() {
138
- //Check if user wants to create certificate
139
- if ( isset( $_POST["create_certificate"] ) && "confirmation" == $_POST["create_certificate"] ) {
140
- global $wpdb;
141
- $mlw_certificate_id = intval( $_GET["result_id"] );
142
- $mlw_quiz_results = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM ".$wpdb->prefix."mlw_results WHERE result_id=%d", $mlw_certificate_id ) );
143
-
144
- $mlw_certificate_results = $wpdb->get_var( $wpdb->prepare( "SELECT certificate_template FROM ".$wpdb->prefix."mlw_quizzes WHERE quiz_id=%d", $mlw_quiz_results->quiz_id ) );
145
-
146
- //Prepare Certificate
147
- if ( is_serialized( $mlw_certificate_results ) && is_array( @unserialize( $mlw_certificate_results ) ) ) {
148
- $mlw_certificate_options = unserialize( $mlw_certificate_results );
149
- } else {
150
- $mlw_certificate_options = array( 'Enter title here', 'Enter text here', '', '' );
151
- }
152
- if ( is_serialized( $mlw_quiz_results->quiz_results ) && is_array( @unserialize( $mlw_quiz_results->quiz_results ) ) ) {
153
- $results = unserialize($mlw_quiz_results->quiz_results);
154
- } else {
155
- $results = array( 0, '', '' );
156
- }
157
- $qmn_array_for_variables = array(
158
- 'quiz_id' => $mlw_quiz_results->quiz_id,
159
- 'quiz_name' => $mlw_quiz_results->quiz_name,
160
- 'quiz_system' => $mlw_quiz_results->quiz_system,
161
- 'user_name' => $mlw_quiz_results->name,
162
- 'user_business' => $mlw_quiz_results->business,
163
- 'user_email' => $mlw_quiz_results->email,
164
- 'user_phone' => $mlw_quiz_results->phone,
165
- 'user_id' => $mlw_quiz_results->user,
166
- 'timer' => $results[0],
167
- 'time_taken' => $mlw_quiz_results->time_taken,
168
- 'total_points' => $mlw_quiz_results->point_score,
169
- 'total_score' => $mlw_quiz_results->correct_score,
170
- 'total_correct' => $mlw_quiz_results->correct,
171
- 'total_questions' => $mlw_quiz_results->total,
172
- 'comments' => $results[2],
173
- 'question_answers_array' => $results[1]
174
- );
175
- $template = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_certificate_options[1], $qmn_array_for_variables );
176
- $template = str_replace( "\n" , "<br>", $template );
177
- $plugindirpath=plugin_dir_path( __FILE__ );
178
- $mlw_qmn_certificate_file=<<<EOC
179
- <?php
180
- include("$plugindirpath/fpdf/WriteHTML.php");
181
- \$pdf=new PDF_HTML();
182
- \$pdf->AddPage('L');
183
- EOC;
184
- $mlw_qmn_certificate_file.=$mlw_certificate_options[3] != '' ? '$pdf->Image("'.$mlw_certificate_options[3].'",0,0,$pdf->w, $pdf->h);' : '';
185
- $mlw_qmn_certificate_file.=<<<EOC
186
- \$pdf->Ln(20);
187
- \$pdf->SetFont('Arial','B',24);
188
- \$pdf->MultiCell(280,20,'$mlw_certificate_options[0]',0,'C');
189
- \$pdf->Ln(15);
190
- \$pdf->SetFont('Arial','',16);
191
- \$pdf->WriteHTML("<p align='center'>$template</p>");
192
- EOC;
193
- $mlw_qmn_certificate_file.=$mlw_certificate_options[2] != '' ? '$pdf->Image("'.$mlw_certificate_options[2].'",110,130);' : '';
194
- $mlw_qmn_certificate_file.=<<<EOC
195
- \$pdf->Output('mlw_qmn_certificate.pdf','D');
196
- EOC;
197
- $mlw_qmn_certificate_filename = "../".str_replace(site_url()."/", '', plugin_dir_url( __FILE__ ))."certificates/mlw_qmn_quiz".date("YmdHis")."admin.php";
198
- file_put_contents($mlw_qmn_certificate_filename, $mlw_qmn_certificate_file);
199
- $mlw_qmn_certificate_filename = plugin_dir_url( __FILE__ )."certificates/mlw_qmn_quiz".date("YmdHis")."admin.php";
200
- }
201
- ?>
202
- <form action="" method="post" name="create_certificate_form">
203
- <input type="hidden" name="create_certificate" value="confirmation" />
204
- <input type="submit" value="<?php _e('Create Certificate','quiz-master-next'); ?>" class="button"/>
205
- </form>
206
- <?php
207
- if ( isset( $_POST["create_certificate"] ) && "confirmation" == $_POST["create_certificate"] ) {
208
- echo "<a href='$mlw_qmn_certificate_filename' style='color: blue;'>" . __( 'Download Certificate Here','quiz-master-next' ) . "</a><br />";
209
- }
210
- }
211
-
212
-
213
- /**
214
- * Registers the tab on the quiz details page
215
- *
216
- * @return void
217
- * @since 4.4.0
218
- */
219
- function qmn_results_certificate_tab() {
220
- global $mlwQuizMasterNext;
221
- $mlwQuizMasterNext->pluginHelper->register_results_settings_tab( __( "Certificate", 'quiz-master-next' ), "qmn_generate_results_certificate_tab" );
222
- }
223
- add_action( "plugins_loaded", 'qmn_results_certificate_tab' );
224
  ?>
67
  $template = htmlspecialchars_decode( $settings['results_details_template'], ENT_QUOTES );
68
  } else {
69
  $template = "<h2>Quiz Results for %QUIZ_NAME%</h2>
70
+ <p>%CONTACT_ALL%</p>
71
  <p>Name Provided: %USER_NAME%</p>
72
  <p>Business Provided: %USER_BUSINESS%</p>
73
  <p>Phone Provided: %USER_PHONE%</p>
81
  }
82
  if ( is_serialized( $mlw_results_data->quiz_results ) && is_array( @unserialize( $mlw_results_data->quiz_results ) ) ) {
83
  $results = unserialize($mlw_results_data->quiz_results);
84
+ if ( ! isset( $results["contact"] ) ) {
85
+ $results["contact"] = array();
86
+ }
87
  } else {
88
  $template = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_results_data->quiz_results, $template);
89
  $template = str_replace( "%TIMER%" , '', $template);
91
  $results = array(
92
  0,
93
  array(),
94
+ '',
95
+ 'contact' => array()
96
  );
97
  }
98
  $qmn_array_for_variables = array(
111
  'total_correct' => $mlw_results_data->correct,
112
  'total_questions' => $mlw_results_data->total,
113
  'comments' => $results[2],
114
+ 'question_answers_array' => $results[1],
115
+ 'contact' => $results["contact"]
116
  );
117
  $template = apply_filters( 'mlw_qmn_template_variable_results_page', $template, $qmn_array_for_variables );
118
  $template = str_replace( "\n" , "<br>", $template );
131
  $mlwQuizMasterNext->pluginHelper->register_results_settings_tab( __( "Results", 'quiz-master-next' ), "qmn_generate_results_details_tab" );
132
  }
133
  add_action( "plugins_loaded", 'qmn_results_details_tab' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  ?>
php/admin-results-page.php CHANGED
@@ -7,20 +7,82 @@ if ( ! defined( 'ABSPATH' ) ) exit;
7
  * @return void
8
  * @since 4.4.0
9
  */
10
- function mlw_generate_quiz_results()
11
- {
12
- if ( !current_user_can('moderate_comments') )
13
- {
14
  return;
15
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  global $wpdb;
17
  global $mlwQuizMasterNext;
18
 
19
- ///Delete Results Function
20
- if ( isset( $_POST["delete_results"] ) && $_POST["delete_results"] == "confirmation" ) {
21
- ///Variables from delete result form
 
22
  $mlw_delete_results_id = intval( $_POST["result_id"] );
23
  $mlw_delete_results_name = sanitize_text_field( $_POST["delete_quiz_name"] );
 
 
24
  $results = $wpdb->update(
25
  $wpdb->prefix . "mlw_results",
26
  array(
@@ -32,6 +94,7 @@ function mlw_generate_quiz_results()
32
  ),
33
  array( '%d' )
34
  );
 
35
  if ( $results ) {
36
  $mlwQuizMasterNext->alertManager->newAlert(__('Your results has been deleted successfully.','quiz-master-next'), 'success');
37
  $mlwQuizMasterNext->audit_manager->new_audit( "Results Has Been Deleted From: $mlw_delete_results_name" );
@@ -43,13 +106,16 @@ function mlw_generate_quiz_results()
43
  }
44
  }
45
 
46
- //Check if bulk delete has been selected. If so, verify nonce.
47
  if ( isset( $_POST["bulk_delete"] ) && wp_verify_nonce( $_POST['bulk_delete_nonce'], 'bulk_delete') ) {
48
- //Ensure the POST variable is an array
 
49
  if ( is_array( $_POST["delete_results"] ) ) {
50
- //Cycle through the POST array which should be an array of the result ids of the results the user wishes to delete
51
- foreach($_POST["delete_results"] as $result) {
52
- //Santize by ensuring the value is an int
 
 
53
  $result_id = intval( $result );
54
  $wpdb->update(
55
  $wpdb->prefix."mlw_results",
@@ -68,8 +134,7 @@ function mlw_generate_quiz_results()
68
  }
69
  }
70
 
71
- global $wpdb;
72
-
73
  $mlw_qmn_table_limit = 40;
74
  $search_phrase_sql = '';
75
  $order_by_sql = 'ORDER BY result_id DESC';
@@ -101,24 +166,18 @@ function mlw_generate_quiz_results()
101
  }
102
 
103
 
104
- if( isset($_GET['mlw_result_page'] ) )
105
- {
106
  $mlw_qmn_result_page = intval( $_GET['mlw_result_page'] ) + 1;
107
  $mlw_qmn_result_begin = $mlw_qmn_table_limit * $mlw_qmn_result_page ;
108
- }
109
- else
110
- {
111
  $mlw_qmn_result_page = 0;
112
  $mlw_qmn_result_begin = 0;
113
  }
114
  $mlw_qmn_result_left = $mlw_qmn_results_count - ($mlw_qmn_result_page * $mlw_qmn_table_limit);
115
- if (isset($_GET["quiz_id"]) && $_GET["quiz_id"] != "")
116
- {
117
  $quiz_id = intval( $_GET["quiz_id"] );
118
  $mlw_quiz_data = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "mlw_results WHERE deleted='0' AND quiz_id=$quiz_id $search_phrase_sql $order_by_sql LIMIT $mlw_qmn_result_begin, $mlw_qmn_table_limit" );
119
- }
120
- else
121
- {
122
  $mlw_quiz_data = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "mlw_results WHERE deleted='0'$search_phrase_sql $order_by_sql LIMIT $mlw_qmn_result_begin, $mlw_qmn_table_limit" );
123
  }
124
 
@@ -158,176 +217,170 @@ function mlw_generate_quiz_results()
158
  idHiddenName.value = quizName;
159
  };
160
  </script>
161
- <div class="wrap">
162
- <h2><?php _e('Quiz Results','quiz-master-next'); ?></h2>
163
- <?php
164
- $mlwQuizMasterNext->alertManager->showAlerts();
165
- ?>
166
- <div class="tablenav top">
167
- <div class="alignleft actions bulkactions">
168
- <a href="javascript: document.bulk_delete_form.submit();" class="button action">Bulk Delete</a>
169
- </div>
170
- <div class="tablenav-pages">
171
- <span class="displaying-num"><?php echo sprintf(_n('One result', '%s results', $mlw_qmn_results_count, 'quiz-master-next'), number_format_i18n($mlw_qmn_results_count)); ?></span>
172
- <span class="pagination-links">
173
- <?php
174
- $mlw_qmn_previous_page = 0;
175
- $mlw_current_page = $mlw_qmn_result_page+1;
176
- $mlw_total_pages = ceil($mlw_qmn_results_count/$mlw_qmn_table_limit);
177
 
178
- $url_query_string = '';
179
- if ( isset( $_GET["quiz_id"] ) && $_GET["quiz_id"] != "" ) {
180
- $url_query_string .= '&&quiz_id='.intval( $_GET["quiz_id"] );
181
- }
182
 
183
- if ( isset( $_GET["qmn_search_phrase"] ) && !empty( $_GET["qmn_search_phrase"] ) ) {
184
- $url_query_string .= '&&qmn_search_phrase='.$_GET["qmn_search_phrase"];
185
- }
186
 
187
- if ( isset( $_GET["qmn_order_by"] ) && !empty( $_GET["qmn_order_by"] ) ) {
188
- $url_query_string .= '&&qmn_order_by='.$_GET["qmn_order_by"];
189
- }
190
 
191
- if( $mlw_qmn_result_page > 0 )
192
- {
193
- $mlw_qmn_previous_page = $mlw_qmn_result_page - 2;
194
- echo "<a class=\"prev-page\" title=\"Go to the previous page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_previous_page$url_query_string\"><</a>";
195
- echo "<span class=\"paging-input\">$mlw_current_page of $mlw_total_pages</span>";
196
- if( $mlw_qmn_result_left > $mlw_qmn_table_limit )
197
- {
198
- echo "<a class=\"next-page\" title=\"Go to the next page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_result_page$url_query_string\">></a>";
199
- }
200
- else
201
- {
202
- echo "<a class=\"next-page disabled\" title=\"Go to the next page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_result_page$url_query_string\">></a>";
203
- }
204
- }
205
- else if( $mlw_qmn_result_page == 0 )
206
- {
207
  if( $mlw_qmn_result_left > $mlw_qmn_table_limit )
208
  {
209
- echo "<a class=\"prev-page disabled\" title=\"Go to the previous page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_previous_page$url_query_string\"><</a>";
210
- echo "<span class=\"paging-input\">$mlw_current_page of $mlw_total_pages</span>";
211
  echo "<a class=\"next-page\" title=\"Go to the next page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_result_page$url_query_string\">></a>";
212
  }
 
 
 
213
  }
214
- else if( $mlw_qmn_result_left < $mlw_qmn_table_limit )
 
 
 
215
  {
216
- $mlw_qmn_previous_page = $mlw_qmn_result_page - 2;
217
- echo "<a class=\"prev-page\" title=\"Go to the previous page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_previous_page$url_query_string\"><</a>";
218
  echo "<span class=\"paging-input\">$mlw_current_page of $mlw_total_pages</span>";
219
- echo "<a class=\"next-page disabled\" title=\"Go to the next page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_result_page$url_query_string\">></a>";
220
  }
221
- ?>
222
- </span>
223
- <br class="clear">
224
- </div>
225
- </div>
226
- <form action='' method="get">
227
- <?php
228
- if ( isset( $_GET["quiz_id"] ) ) {
229
  ?>
230
- <input type="hidden" name="quiz_id" value="<?php echo $_GET["quiz_id"]; ?>" />
231
- <?php
232
- }
 
 
 
 
233
  ?>
234
- <input type="hidden" name="page" value="mlw_quiz_results">
235
- <p class="search-box" style="margin-bottom: 10px;">
236
- <label for="qmn_search_phrase">Search Results:</label>
237
- <input type="search" id="qmn_search_phrase" name="qmn_search_phrase" value="">
238
- <label for="qmn_order_by">Order By:</label>
239
- <select id="qmn_order_by" name="qmn_order_by">
240
- <option value="quiz_name">Quiz Name</option>
241
- <option value="name">User Name</option>
242
- <option value="point_score">Points</option>
243
- <option value="correct_score">Correct Percent</option>
244
- <option value="default">Default (time)</option>
245
- </select>
246
- <button class="button">Search Results</button>
247
- </p>
248
- </form>
249
- <form action="" method="post" name="bulk_delete_form">
250
- <input type="hidden" name="bulk_delete" value="confirmation" />
251
- <?php wp_nonce_field('bulk_delete','bulk_delete_nonce'); ?>
252
- <table class=widefat>
253
- <thead>
254
- <tr>
255
- <th><input type="checkbox" id="qmn_check_all" style="margin-left: 0;"/></th>
256
- <th><?php _e('Actions','quiz-master-next'); ?></th>
257
- <th><?php _e('Quiz Name','quiz-master-next'); ?></th>
258
- <th><?php _e('Score','quiz-master-next'); ?></th>
259
- <th><?php _e('Time To Complete','quiz-master-next'); ?></th>
260
- <th><?php _e('Name','quiz-master-next'); ?></th>
261
- <th><?php _e('Business','quiz-master-next'); ?></th>
262
- <th><?php _e('Email','quiz-master-next'); ?></th>
263
- <th><?php _e('Phone','quiz-master-next'); ?></th>
264
- <th><?php _e('Time Taken','quiz-master-next'); ?></th>
265
- </tr>
266
- </thead>
267
- <?php
268
- $quotes_list = "";
269
- $display = "";
270
- $alternate = "";
271
- foreach($mlw_quiz_data as $mlw_quiz_info) {
272
- if($alternate) $alternate = "";
273
- else $alternate = " class=\"alternate\"";
274
- $mlw_complete_time = '';
275
- $mlw_qmn_results_array = @unserialize($mlw_quiz_info->quiz_results);
276
- if (is_array($mlw_qmn_results_array))
277
- {
278
- $mlw_complete_hours = floor($mlw_qmn_results_array[0] / 3600);
279
- if ($mlw_complete_hours > 0)
280
- {
281
- $mlw_complete_time .= "$mlw_complete_hours hours ";
282
- }
283
- $mlw_complete_minutes = floor(($mlw_qmn_results_array[0] % 3600) / 60);
284
- if ($mlw_complete_minutes > 0)
285
- {
286
- $mlw_complete_time .= "$mlw_complete_minutes minutes ";
287
- }
288
- $mlw_complete_seconds = $mlw_qmn_results_array[0] % 60;
289
- $mlw_complete_time .= "$mlw_complete_seconds seconds";
290
- }
291
-
292
- $quotes_list .= "<tr{$alternate}>";
293
- $quotes_list .= "<td><input type='checkbox' class='qmn_delete_checkbox' name='delete_results[]' value='".$mlw_quiz_info->result_id. "' /></td>";
294
- $quotes_list .= "<td><span><a href='admin.php?page=mlw_quiz_result_details&&result_id=".$mlw_quiz_info->result_id."'>View</a>|<a style='color:red;' onclick=\"deleteResults('".$mlw_quiz_info->result_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='#'>Delete</a></span></td>";
295
- $quotes_list .= "<td><span>" . $mlw_quiz_info->quiz_name . "</span></td>";
296
- if ($mlw_quiz_info->quiz_system == 0)
297
- {
298
- $quotes_list .= "<td class='post-title column-title'><span>" . $mlw_quiz_info->correct ." out of ".$mlw_quiz_info->total." or ".$mlw_quiz_info->correct_score."%</span></td>";
299
- }
300
- if ($mlw_quiz_info->quiz_system == 1)
301
  {
302
- $quotes_list .= "<td><span>" . $mlw_quiz_info->point_score . " Points</span></td>";
303
  }
304
- if ($mlw_quiz_info->quiz_system == 2)
 
305
  {
306
- $quotes_list .= "<td><span>".__('Not Graded','quiz-master-next')."</span></td>";
307
  }
308
- $quotes_list .= "<td><span>" . $mlw_complete_time ."</span></td>";
309
- $quotes_list .= "<td><span>" . $mlw_quiz_info->name ."</span></td>";
310
- $quotes_list .= "<td><span>" . $mlw_quiz_info->business ."</span></td>";
311
- $quotes_list .= "<td><span>" . $mlw_quiz_info->email ."</span></td>";
312
- $quotes_list .= "<td><span>" . $mlw_quiz_info->phone ."</span></td>";
313
- $quotes_list .= "<td><span>" . $mlw_quiz_info->time_taken ."</span></td>";
314
- $quotes_list .= "</tr>";
315
  }
316
- $display .= "<tbody id=\"the-list\">{$quotes_list}</tbody>";
317
- echo $display;
318
- ?>
319
- </table>
320
- </form>
321
 
322
- <div id="delete_dialog" title="Delete Results?" style="display:none;">
323
- <h3><b><?php _e('Are you sure you want to delete these results?','quiz-master-next'); ?></b></h3>
324
- <form action='' method='post'>
325
- <input type='hidden' name='delete_results' value='confirmation' />
326
- <input type='hidden' id='result_id' name='result_id' value='' />
327
- <input type='hidden' id='delete_quiz_name' name='delete_quiz_name' value='' />
328
- <p class='submit'><input type='submit' class='button-primary' value='<?php _e('Delete Results','quiz-master-next'); ?>' /></p>
329
- </form>
330
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  </div>
332
  <?php
333
  }
7
  * @return void
8
  * @since 4.4.0
9
  */
10
+ function qsm_generate_admin_results_page() {
11
+
12
+ // Makes sure user has the right privledges
13
+ if ( ! current_user_can('moderate_comments') ) {
14
  return;
15
  }
16
+
17
+ // Retrieves the current stab and all registered tabs
18
+ global $mlwQuizMasterNext;
19
+ $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'quiz-results';
20
+ $tab_array = $mlwQuizMasterNext->pluginHelper->get_admin_results_tabs();
21
+
22
+ ?>
23
+ <div class="wrap">
24
+ <h2><?php _e('Quiz Results', 'quiz-master-next'); ?></h2>
25
+ <?php $mlwQuizMasterNext->alertManager->showAlerts(); ?>
26
+ <?php echo mlw_qmn_show_adverts(); ?>
27
+ <h2 class="nav-tab-wrapper">
28
+ <?php
29
+ // Cycles through the tabs and creates the navigation
30
+ foreach( $tab_array as $tab ) {
31
+ $active_class = '';
32
+ if ( $active_tab == $tab['slug'] ) {
33
+ $active_class = 'nav-tab-active';
34
+ }
35
+ echo "<a href=\"?page=mlw_quiz_results&tab={$tab['slug']}\" class=\"nav-tab $active_class\">{$tab['title']}</a>";
36
+ }
37
+ ?>
38
+ </h2>
39
+ <div>
40
+ <?php
41
+ // Locates the active tab and calls its content function
42
+ foreach( $tab_array as $tab ) {
43
+ if ( $active_tab == $tab['slug'] ) {
44
+ call_user_func( $tab['function'] );
45
+ }
46
+ }
47
+ ?>
48
+ </div>
49
+ </div>
50
+
51
+ <?php
52
+
53
+ }
54
+
55
+ /**
56
+ * Adds Overview Tab To Admin Results Page
57
+ *
58
+ * @since 5.0.0
59
+ * @return void
60
+ */
61
+ function qsm_results_overview_tab() {
62
+ global $mlwQuizMasterNext;
63
+ $mlwQuizMasterNext->pluginHelper->register_admin_results_tab( __( "Quiz Results", 'quiz-master-next' ), "qsm_results_overview_tab_content" );
64
+ }
65
+ add_action( 'plugins_loaded', 'qsm_results_overview_tab' );
66
+
67
+ /**
68
+ * Generates HTML For Overview Tab
69
+ *
70
+ * @since 5.0.0
71
+ * @return void
72
+ */
73
+ function qsm_results_overview_tab_content() {
74
+
75
  global $wpdb;
76
  global $mlwQuizMasterNext;
77
 
78
+ // If nonce is correct, delete results
79
+ if ( isset( $_POST["delete_results_nonce"] ) && wp_verify_nonce( $_POST['delete_results_nonce'], 'delete_results') ) {
80
+
81
+ // Variables from delete result form
82
  $mlw_delete_results_id = intval( $_POST["result_id"] );
83
  $mlw_delete_results_name = sanitize_text_field( $_POST["delete_quiz_name"] );
84
+
85
+ // Update table to mark results as deleted
86
  $results = $wpdb->update(
87
  $wpdb->prefix . "mlw_results",
88
  array(
94
  ),
95
  array( '%d' )
96
  );
97
+
98
  if ( $results ) {
99
  $mlwQuizMasterNext->alertManager->newAlert(__('Your results has been deleted successfully.','quiz-master-next'), 'success');
100
  $mlwQuizMasterNext->audit_manager->new_audit( "Results Has Been Deleted From: $mlw_delete_results_name" );
106
  }
107
  }
108
 
109
+ // Check if bulk delete has been selected. If so, verify nonce.
110
  if ( isset( $_POST["bulk_delete"] ) && wp_verify_nonce( $_POST['bulk_delete_nonce'], 'bulk_delete') ) {
111
+
112
+ // Ensure the POST variable is an array
113
  if ( is_array( $_POST["delete_results"] ) ) {
114
+
115
+ // Cycle through the POST array which should be an array of the result ids of the results the user wishes to delete
116
+ foreach( $_POST["delete_results"] as $result ) {
117
+
118
+ // Santize by ensuring the value is an int
119
  $result_id = intval( $result );
120
  $wpdb->update(
121
  $wpdb->prefix."mlw_results",
134
  }
135
  }
136
 
137
+ // Prepares the SQL to retrieve the results
 
138
  $mlw_qmn_table_limit = 40;
139
  $search_phrase_sql = '';
140
  $order_by_sql = 'ORDER BY result_id DESC';
166
  }
167
 
168
 
169
+ if( isset( $_GET['mlw_result_page'] ) ) {
 
170
  $mlw_qmn_result_page = intval( $_GET['mlw_result_page'] ) + 1;
171
  $mlw_qmn_result_begin = $mlw_qmn_table_limit * $mlw_qmn_result_page ;
172
+ } else {
 
 
173
  $mlw_qmn_result_page = 0;
174
  $mlw_qmn_result_begin = 0;
175
  }
176
  $mlw_qmn_result_left = $mlw_qmn_results_count - ($mlw_qmn_result_page * $mlw_qmn_table_limit);
177
+ if ( isset( $_GET["quiz_id"] ) && $_GET["quiz_id"] != "" ) {
 
178
  $quiz_id = intval( $_GET["quiz_id"] );
179
  $mlw_quiz_data = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "mlw_results WHERE deleted='0' AND quiz_id=$quiz_id $search_phrase_sql $order_by_sql LIMIT $mlw_qmn_result_begin, $mlw_qmn_table_limit" );
180
+ } else {
 
 
181
  $mlw_quiz_data = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "mlw_results WHERE deleted='0'$search_phrase_sql $order_by_sql LIMIT $mlw_qmn_result_begin, $mlw_qmn_table_limit" );
182
  }
183
 
217
  idHiddenName.value = quizName;
218
  };
219
  </script>
220
+ <div class="tablenav top">
221
+ <div class="alignleft actions bulkactions">
222
+ <a href="javascript: document.bulk_delete_form.submit();" class="button action">Bulk Delete</a>
223
+ </div>
224
+ <div class="tablenav-pages">
225
+ <span class="displaying-num"><?php echo sprintf(_n('One result', '%s results', $mlw_qmn_results_count, 'quiz-master-next'), number_format_i18n($mlw_qmn_results_count)); ?></span>
226
+ <span class="pagination-links">
227
+ <?php
228
+ $mlw_qmn_previous_page = 0;
229
+ $mlw_current_page = $mlw_qmn_result_page+1;
230
+ $mlw_total_pages = ceil($mlw_qmn_results_count/$mlw_qmn_table_limit);
 
 
 
 
 
231
 
232
+ $url_query_string = '';
233
+ if ( isset( $_GET["quiz_id"] ) && $_GET["quiz_id"] != "" ) {
234
+ $url_query_string .= '&&quiz_id='.intval( $_GET["quiz_id"] );
235
+ }
236
 
237
+ if ( isset( $_GET["qmn_search_phrase"] ) && !empty( $_GET["qmn_search_phrase"] ) ) {
238
+ $url_query_string .= '&&qmn_search_phrase='.$_GET["qmn_search_phrase"];
239
+ }
240
 
241
+ if ( isset( $_GET["qmn_order_by"] ) && !empty( $_GET["qmn_order_by"] ) ) {
242
+ $url_query_string .= '&&qmn_order_by='.$_GET["qmn_order_by"];
243
+ }
244
 
245
+ if( $mlw_qmn_result_page > 0 )
246
+ {
247
+ $mlw_qmn_previous_page = $mlw_qmn_result_page - 2;
248
+ echo "<a class=\"prev-page\" title=\"Go to the previous page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_previous_page$url_query_string\"><</a>";
249
+ echo "<span class=\"paging-input\">$mlw_current_page of $mlw_total_pages</span>";
 
 
 
 
 
 
 
 
 
 
 
250
  if( $mlw_qmn_result_left > $mlw_qmn_table_limit )
251
  {
 
 
252
  echo "<a class=\"next-page\" title=\"Go to the next page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_result_page$url_query_string\">></a>";
253
  }
254
+ else
255
+ {
256
+ echo "<a class=\"next-page disabled\" title=\"Go to the next page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_result_page$url_query_string\">></a>";
257
  }
258
+ }
259
+ else if( $mlw_qmn_result_page == 0 )
260
+ {
261
+ if( $mlw_qmn_result_left > $mlw_qmn_table_limit )
262
  {
263
+ echo "<a class=\"prev-page disabled\" title=\"Go to the previous page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_previous_page$url_query_string\"><</a>";
 
264
  echo "<span class=\"paging-input\">$mlw_current_page of $mlw_total_pages</span>";
265
+ echo "<a class=\"next-page\" title=\"Go to the next page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_result_page$url_query_string\">></a>";
266
  }
267
+ }
268
+ else if( $mlw_qmn_result_left < $mlw_qmn_table_limit )
269
+ {
270
+ $mlw_qmn_previous_page = $mlw_qmn_result_page - 2;
271
+ echo "<a class=\"prev-page\" title=\"Go to the previous page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_previous_page$url_query_string\"><</a>";
272
+ echo "<span class=\"paging-input\">$mlw_current_page of $mlw_total_pages</span>";
273
+ echo "<a class=\"next-page disabled\" title=\"Go to the next page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_result_page$url_query_string\">></a>";
274
+ }
275
  ?>
276
+ </span>
277
+ <br class="clear">
278
+ </div>
279
+ </div>
280
+ <form action='' method="get">
281
+ <?php
282
+ if ( isset( $_GET["quiz_id"] ) ) {
283
  ?>
284
+ <input type="hidden" name="quiz_id" value="<?php echo $_GET["quiz_id"]; ?>" />
285
+ <?php
286
+ }
287
+ ?>
288
+ <input type="hidden" name="page" value="mlw_quiz_results">
289
+ <p class="search-box">
290
+ <label for="qmn_search_phrase">Search Results:</label>
291
+ <input type="search" id="qmn_search_phrase" name="qmn_search_phrase" value="">
292
+ <label for="qmn_order_by">Order By:</label>
293
+ <select id="qmn_order_by" name="qmn_order_by">
294
+ <option value="quiz_name">Quiz Name</option>
295
+ <option value="name">User Name</option>
296
+ <option value="point_score">Points</option>
297
+ <option value="correct_score">Correct Percent</option>
298
+ <option value="default">Default (time)</option>
299
+ </select>
300
+ <button class="button">Search Results</button>
301
+ </p>
302
+ </form>
303
+ <form action="" method="post" name="bulk_delete_form">
304
+ <input type="hidden" name="bulk_delete" value="confirmation" />
305
+ <?php wp_nonce_field('bulk_delete','bulk_delete_nonce'); ?>
306
+ <table class=widefat>
307
+ <thead>
308
+ <tr>
309
+ <th><input type="checkbox" id="qmn_check_all" /></th>
310
+ <th><?php _e('Actions','quiz-master-next'); ?></th>
311
+ <th><?php _e('Quiz Name','quiz-master-next'); ?></th>
312
+ <th><?php _e('Score','quiz-master-next'); ?></th>
313
+ <th><?php _e('Time To Complete','quiz-master-next'); ?></th>
314
+ <th><?php _e('Name','quiz-master-next'); ?></th>
315
+ <th><?php _e('Business','quiz-master-next'); ?></th>
316
+ <th><?php _e('Email','quiz-master-next'); ?></th>
317
+ <th><?php _e('Phone','quiz-master-next'); ?></th>
318
+ <th><?php _e('Time Taken','quiz-master-next'); ?></th>
319
+ </tr>
320
+ </thead>
321
+ <?php
322
+ $quotes_list = "";
323
+ $display = "";
324
+ $alternate = "";
325
+ foreach($mlw_quiz_data as $mlw_quiz_info) {
326
+ if($alternate) $alternate = "";
327
+ else $alternate = " class=\"alternate\"";
328
+ $mlw_complete_time = '';
329
+ $mlw_qmn_results_array = @unserialize($mlw_quiz_info->quiz_results);
330
+ if (is_array($mlw_qmn_results_array))
331
+ {
332
+ $mlw_complete_hours = floor($mlw_qmn_results_array[0] / 3600);
333
+ if ($mlw_complete_hours > 0)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
334
  {
335
+ $mlw_complete_time .= "$mlw_complete_hours hours ";
336
  }
337
+ $mlw_complete_minutes = floor(($mlw_qmn_results_array[0] % 3600) / 60);
338
+ if ($mlw_complete_minutes > 0)
339
  {
340
+ $mlw_complete_time .= "$mlw_complete_minutes minutes ";
341
  }
342
+ $mlw_complete_seconds = $mlw_qmn_results_array[0] % 60;
343
+ $mlw_complete_time .= "$mlw_complete_seconds seconds";
 
 
 
 
 
344
  }
 
 
 
 
 
345
 
346
+ $quotes_list .= "<tr{$alternate}>";
347
+ $quotes_list .= "<td><input type='checkbox' class='qmn_delete_checkbox' name='delete_results[]' value='".$mlw_quiz_info->result_id. "' /></td>";
348
+ $quotes_list .= "<td><span style='color:green;font-size:16px;'><a href='admin.php?page=mlw_quiz_result_details&&result_id=".$mlw_quiz_info->result_id."'>View</a>|<a onclick=\"deleteResults('".$mlw_quiz_info->result_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='#'>Delete</a></span></td>";
349
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_name . "</span></td>";
350
+ if ($mlw_quiz_info->quiz_system == 0)
351
+ {
352
+ $quotes_list .= "<td class='post-title column-title'><span style='font-size:16px;'>" . $mlw_quiz_info->correct ." out of ".$mlw_quiz_info->total." or ".$mlw_quiz_info->correct_score."%</span></td>";
353
+ }
354
+ if ($mlw_quiz_info->quiz_system == 1)
355
+ {
356
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->point_score . " Points</span></td>";
357
+ }
358
+ if ($mlw_quiz_info->quiz_system == 2)
359
+ {
360
+ $quotes_list .= "<td><span style='font-size:16px;'>".__('Not Graded','quiz-master-next')."</span></td>";
361
+ }
362
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_complete_time ."</span></td>";
363
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->name ."</span></td>";
364
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->business ."</span></td>";
365
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->email ."</span></td>";
366
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->phone ."</span></td>";
367
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->time_taken ."</span></td>";
368
+ $quotes_list .= "</tr>";
369
+ }
370
+ $display .= "<tbody id=\"the-list\">{$quotes_list}</tbody>";
371
+ echo $display;
372
+ ?>
373
+ </table>
374
+ </form>
375
+
376
+ <div id="delete_dialog" title="Delete Results?" style="display:none;">
377
+ <h3><b><?php _e('Are you sure you want to delete these results?','quiz-master-next'); ?></b></h3>
378
+ <form action='' method='post'>
379
+ <?php wp_nonce_field( 'delete_results','delete_results_nonce' ); ?>
380
+ <input type='hidden' id='result_id' name='result_id' value='' />
381
+ <input type='hidden' id='delete_quiz_name' name='delete_quiz_name' value='' />
382
+ <p class='submit'><input type='submit' class='button-primary' value='<?php _e('Delete Results','quiz-master-next'); ?>' /></p>
383
+ </form>
384
  </div>
385
  <?php
386
  }
php/class-qmn-plugin-helper.php CHANGED
@@ -1,15 +1,15 @@
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) ) exit;
 
3
  /**
4
  * This class is a helper class to be used for extending the plugin
5
  *
6
  * This class contains many functions for extending the plugin
7
  *
8
- *
9
  * @since 4.0.0
10
  */
11
- class QMNPluginHelper
12
- {
13
  /**
14
  * Addon Page tabs array
15
  *
@@ -27,7 +27,15 @@ class QMNPluginHelper
27
  public $stats_tabs = array();
28
 
29
  /**
30
- * Results Page tabs array
 
 
 
 
 
 
 
 
31
  *
32
  * @var array
33
  * @since 4.1.0
@@ -66,11 +74,83 @@ class QMNPluginHelper
66
  * @since 4.0.0
67
  * @return void
68
  */
69
- public function __construct()
70
- {
71
  add_action( 'wp_ajax_qmn_question_type_change', array( $this, 'get_question_type_edit_content' ) );
72
  }
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  /**
75
  * Registers Quiz Templates
76
  *
@@ -324,37 +404,6 @@ class QMNPluginHelper
324
  }
325
  }
326
 
327
- /**
328
- * Retrieves A Quiz Setting
329
- *
330
- * Retrieves a setting stored in the quiz settings array
331
- *
332
- * @since 4.0.0
333
- * @param string $setting The name of the setting
334
- * @return string The value stored for the setting
335
- */
336
- public function get_quiz_setting($setting)
337
- {
338
- global $mlwQuizMasterNext;
339
- return $mlwQuizMasterNext->quizCreator->get_setting($setting);
340
- }
341
-
342
- /**
343
- * Updates A Quiz Setting
344
- *
345
- * Sets the value of a setting stored in the quiz settings array
346
- *
347
- * @since 4.0.0
348
- * @param string $setting The name of the setting
349
- * @param any $value The value to be store in the setting
350
- * @return bool True if update was successful
351
- */
352
- public function update_quiz_setting($setting, $value)
353
- {
354
- global $mlwQuizMasterNext;
355
- return $mlwQuizMasterNext->quizCreator->update_setting($setting, $value);
356
- }
357
-
358
  /**
359
  * Registers Addon Settings Tab
360
  *
@@ -423,6 +472,38 @@ class QMNPluginHelper
423
  return $this->stats_tabs;
424
  }
425
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
426
  /**
427
  * Registers Results Tab
428
  *
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) ) exit;
3
+
4
  /**
5
  * This class is a helper class to be used for extending the plugin
6
  *
7
  * This class contains many functions for extending the plugin
8
  *
 
9
  * @since 4.0.0
10
  */
11
+ class QMNPluginHelper {
12
+
13
  /**
14
  * Addon Page tabs array
15
  *
27
  public $stats_tabs = array();
28
 
29
  /**
30
+ * Admin Results Page tabs array
31
+ *
32
+ * @var array
33
+ * @since 5.0.0
34
+ */
35
+ public $admin_results_tabs = array();
36
+
37
+ /**
38
+ * Results Details Page tabs array
39
  *
40
  * @var array
41
  * @since 4.1.0
74
  * @since 4.0.0
75
  * @return void
76
  */
77
+ public function __construct() {
 
78
  add_action( 'wp_ajax_qmn_question_type_change', array( $this, 'get_question_type_edit_content' ) );
79
  }
80
 
81
+ /**
82
+ * Calls all class functions to initialize quiz
83
+ */
84
+ public function prepare_quiz( $quiz_id ) {
85
+ $quiz_id = intval( $quiz_id );
86
+ global $mlwQuizMasterNext;
87
+ $mlwQuizMasterNext->quizCreator->set_id( $quiz_id );
88
+ $mlwQuizMasterNext->quiz_settings->prepare_quiz( intval( $quiz_id ) );
89
+ }
90
+
91
+ /**
92
+ * Registers a quiz setting
93
+ *
94
+ * @since 5.0.0
95
+ * @param array $field_array An array of the components for the settings field
96
+ */
97
+ public function register_quiz_setting( $field_array, $section = 'quiz_options' ) {
98
+ global $mlwQuizMasterNext;
99
+ $mlwQuizMasterNext->quiz_settings->register_setting( $field_array, $section );
100
+ }
101
+
102
+ /**
103
+ * Retrieves a setting value from a section based on name of section and setting
104
+ *
105
+ * @since 5.0.0
106
+ * @param string $section The name of the section the setting is registered in
107
+ * @param string $setting The name of the setting whose value we need to retrieve
108
+ * @param mixed $default What we need to return if no setting exists with given $setting
109
+ * @return $mixed Value set for $setting or $default if setting does not exist
110
+ */
111
+ public function get_section_setting( $section, $setting, $default = false ) {
112
+ global $mlwQuizMasterNext;
113
+ return $mlwQuizMasterNext->quiz_settings->get_section_setting( $section, $setting, $default );
114
+ }
115
+
116
+ /**
117
+ * Retrieves setting value based on name of setting
118
+ *
119
+ * @since 4.0.0
120
+ * @param string $setting The name of the setting whose value we need to retrieve
121
+ * @param mixed $default What we need to return if no setting exists with given $setting
122
+ * @return $mixed Value set for $setting or $default if setting does not exist
123
+ */
124
+ public function get_quiz_setting( $setting, $default = false ) {
125
+ global $mlwQuizMasterNext;
126
+ return $mlwQuizMasterNext->quiz_settings->get_setting( $setting, $default );
127
+ }
128
+
129
+
130
+ /**
131
+ * Updates a settings value, adding it if it didn't already exist
132
+ *
133
+ * @since 4.0.0
134
+ * @param string $setting The name of the setting whose value we need to retrieve
135
+ * @param mixed $value The value that needs to be stored for the setting
136
+ * @return bool True if successful or false if fails
137
+ */
138
+ public function update_quiz_setting( $setting, $value ) {
139
+ global $mlwQuizMasterNext;
140
+ return $mlwQuizMasterNext->quiz_settings->update_setting( $setting, $value );
141
+ }
142
+
143
+ /**
144
+ * Outputs the section of input fields
145
+ *
146
+ * @since 5.0.0
147
+ * @param string $section The section that the settings were registered with
148
+ */
149
+ public function generate_settings_section( $section = 'quiz_options' ) {
150
+ global $mlwQuizMasterNext;
151
+ QSM_Fields::generate_section( $mlwQuizMasterNext->quiz_settings->load_setting_fields( $section ), $section );
152
+ }
153
+
154
  /**
155
  * Registers Quiz Templates
156
  *
404
  }
405
  }
406
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
407
  /**
408
  * Registers Addon Settings Tab
409
  *
472
  return $this->stats_tabs;
473
  }
474
 
475
+ /**
476
+ * Registers tabs for the Admin Results page
477
+ *
478
+ * Registers a new tab on the admin results page
479
+ *
480
+ * @since 5.0.0
481
+ * @param string $title The name of the tab
482
+ * @param string $function The function that displays the tab's content
483
+ * @return void
484
+ */
485
+ public function register_admin_results_tab( $title, $function) {
486
+ $slug = strtolower( str_replace( " ", "-", $title ) );
487
+ $new_tab = array(
488
+ 'title' => $title,
489
+ 'function' => $function,
490
+ 'slug' => $slug
491
+ );
492
+ $this->admin_results_tabs[] = $new_tab;
493
+ }
494
+
495
+ /**
496
+ * Retrieves Admin Results Tab Array
497
+ *
498
+ * Retrieves the array of titles and functions for the tabs registered for the admin results page
499
+ *
500
+ * @since 5.0.0
501
+ * @return array The array of registered tabs
502
+ */
503
+ public function get_admin_results_tabs() {
504
+ return $this->admin_results_tabs;
505
+ }
506
+
507
  /**
508
  * Registers Results Tab
509
  *
php/class-qmn-quiz-creator.php CHANGED
@@ -44,6 +44,20 @@ class QMNQuizCreator
44
  $this->quiz_id = intval($quiz_id);
45
  }
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  /**
48
  * Retrieves setting store in quiz_settings
49
  *
@@ -283,16 +297,16 @@ class QMNQuizCreator
283
  'send_user_email' => 0,
284
  'send_admin_email' => 0,
285
  'contact_info_location' => 0,
286
- 'user_name' => 0,
287
- 'user_comp' => 0,
288
- 'user_email' => 0,
289
- 'user_phone' => 0,
290
  'admin_email' => get_option( 'admin_email', 'Enter email' ),
291
  'comment_section' => 1,
292
  'question_from_total' => 0,
293
  'total_user_tries' => 0,
294
  'total_user_tries_text' => 'You are only allowed 1 try and have already submitted your quiz.',
295
- 'certificate_template' => 'Enter Your Text Here!',
296
  'social_media' => 0,
297
  'social_media_text' => 'I just scored %CORRECT_SCORE%% on %QUIZ_NAME%!',
298
  'pagination' => 0,
@@ -436,7 +450,7 @@ class QMNQuizCreator
436
  $my_query->the_post();
437
  $my_post = array(
438
  'ID' => get_the_ID(),
439
- 'post_status' => 'draft'
440
  );
441
  wp_update_post( $my_post );
442
  }
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
  *
297
  'send_user_email' => 0,
298
  'send_admin_email' => 0,
299
  'contact_info_location' => 0,
300
+ 'user_name' => 2,
301
+ 'user_comp' => 2,
302
+ 'user_email' => 2,
303
+ 'user_phone' => 2,
304
  'admin_email' => get_option( 'admin_email', 'Enter email' ),
305
  'comment_section' => 1,
306
  'question_from_total' => 0,
307
  'total_user_tries' => 0,
308
  'total_user_tries_text' => 'You are only allowed 1 try and have already submitted your quiz.',
309
+ 'certificate_template' => '',
310
  'social_media' => 0,
311
  'social_media_text' => 'I just scored %CORRECT_SCORE%% on %QUIZ_NAME%!',
312
  'pagination' => 0,
450
  $my_query->the_post();
451
  $my_post = array(
452
  'ID' => get_the_ID(),
453
+ 'post_status' => 'trash'
454
  );
455
  wp_update_post( $my_post );
456
  }
php/class-qmn-quiz-manager.php CHANGED
@@ -1,12 +1,13 @@
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) ) exit;
 
3
  /**
4
  * This class generates the contents of the quiz shortcode
5
  *
6
  * @since 4.0.0
7
  */
8
- class QMNQuizManager
9
- {
10
  /**
11
  * Main Construct Function
12
  *
@@ -16,8 +17,7 @@ class QMNQuizManager
16
  * @uses QMNQuizManager::add_hooks() Adds actions to hooks and filters
17
  * @return void
18
  */
19
- public function __construct()
20
- {
21
  $this->add_hooks();
22
  }
23
 
@@ -29,9 +29,9 @@ class QMNQuizManager
29
  * @since 4.0.0
30
  * @return void
31
  */
32
- public function add_hooks()
33
- {
34
  add_shortcode( 'mlw_quizmaster', array( $this, 'display_shortcode' ) );
 
35
  add_action( 'wp_ajax_qmn_process_quiz', array( $this, 'ajax_submit_results' ) );
36
  add_action( 'wp_ajax_nopriv_qmn_process_quiz', array( $this, 'ajax_submit_results' ) );
37
  }
@@ -42,15 +42,13 @@ class QMNQuizManager
42
  * Generates the content for the [mlw_quizmaster] shortcode
43
  *
44
  * @since 4.0.0
45
- * @uses QMNQuizManager:load_quiz_options() Loads quiz
46
  * @uses QMNQuizManager:load_questions() Loads questions
47
  * @uses QMNQuizManager:create_answer_array() Prepares answers
48
  * @uses QMNQuizManager:display_quiz() Generates and prepares quiz page
49
  * @uses QMNQuizManager:display_results() Generates and prepares results page
50
  * @return string The content for the shortcode
51
  */
52
- public function display_shortcode($atts)
53
- {
54
  extract(shortcode_atts(array(
55
  'quiz' => 0,
56
  'question_amount' => 0
@@ -62,7 +60,7 @@ class QMNQuizManager
62
  global $qmn_json_data;
63
  $qmn_json_data = array();
64
  $qmn_allowed_visit = true;
65
- $mlwQuizMasterNext->quizCreator->set_id($quiz);
66
  $question_amount = intval( $question_amount );
67
 
68
  //Legacy variable
@@ -74,7 +72,7 @@ class QMNQuizManager
74
  date_default_timezone_set(get_option('timezone_string'));
75
  }
76
  $return_display = '';
77
- $qmn_quiz_options = $this->load_quiz_options($quiz);
78
 
79
  //If quiz options isn't found, stop function
80
  if (is_null($qmn_quiz_options) || $qmn_quiz_options->quiz_name == '')
@@ -94,11 +92,11 @@ class QMNQuizManager
94
  // Check direct file first, then check templates folder in plugin, then check templates file in theme.
95
  // If all fails, then load custom styling instead
96
  if ( $registered_template && file_exists( $registered_template["path"] ) ) {
97
- wp_enqueue_style( 'qmn_quiz_template', $registered_template["path"] );
98
  } elseif ( $registered_template && file_exists( plugin_dir_path(__FILE__).'../templates/'.$registered_template["path"] ) ) {
99
- wp_enqueue_style( 'qmn_quiz_template', plugins_url( '../templates/'.$registered_template["path"], __FILE__ ) );
100
  } elseif ( $registered_template && file_exists( get_stylesheet_directory_uri().'/templates/'.$registered_template["path"] ) ) {
101
- wp_enqueue_style( 'qmn_quiz_template', get_stylesheet_directory_uri().'/templates/'.$registered_template["path"] );
102
  } else {
103
  echo "<style type='text/css'>".$qmn_quiz_options->quiz_stye."</style>";
104
  }
@@ -158,21 +156,6 @@ class QMNQuizManager
158
  return $return_display;
159
  }
160
 
161
- /**
162
- * Loads Quiz
163
- *
164
- * Retrieves the quiz from the database
165
- *
166
- * @since 4.0.0
167
- * @param int $quiz_id The id for the quiz
168
- * @return array Columns for the row from the database of the quiz
169
- */
170
- public function load_quiz_options($quiz_id)
171
- {
172
- global $wpdb;
173
- return $wpdb->get_row($wpdb->prepare('SELECT * FROM '.$wpdb->prefix.'mlw_quizzes WHERE quiz_id=%d AND deleted=0', $quiz_id));
174
- }
175
-
176
  /**
177
  * Loads Questions
178
  *
@@ -291,10 +274,10 @@ class QMNQuizManager
291
 
292
  global $qmn_json_data;
293
  $qmn_json_data["error_messages"] = array(
294
- 'email' => __('Not a valid e-mail address!', 'quiz-master-next'),
295
- 'number' => __('This field must be a number!', 'quiz-master-next'),
296
- 'incorrect' => __('The entered text is not correct!', 'quiz-master-next'),
297
- 'empty' => __('Please complete all required fields!', 'quiz-master-next')
298
  );
299
 
300
  wp_enqueue_script( 'qmn_quiz', plugins_url( '../js/qmn_quiz.js' , __FILE__ ), array( 'jquery', 'jquery-ui-tooltip' ) );
@@ -355,10 +338,8 @@ class QMNQuizManager
355
  $message_before = apply_filters( 'mlw_qmn_template_variable_quiz_page', $message_before, $qmn_array_for_variables);
356
 
357
  $section_display .= "<div class='mlw_qmn_message_before'>$message_before</div>";
358
-
359
- if ($qmn_quiz_options->contact_info_location == 0)
360
- {
361
- $section_display .= mlwDisplayContactInfo($qmn_quiz_options);
362
  }
363
  $section_display .= "</div>";
364
  } else {
@@ -407,7 +388,7 @@ class QMNQuizManager
407
 
408
  // Checks if a hint is entered
409
  if ( ! empty( $mlw_question->hints ) ) {
410
- $question_display .= "<span title=\"" . esc_attr( htmlspecialchars_decode( $mlw_question->hints, ENT_QUOTES ) ) . "\" class='qsm_hint mlw_qmn_hint_link'>" . __( 'Hint', 'quiz-master-next' ) . "</span>";
411
  $question_display .= "<br /><br />";
412
  }
413
  $question_display .= "</div>";
@@ -426,8 +407,7 @@ class QMNQuizManager
426
  * @param array $qmn_array_for_variables The array of results for the quiz
427
  * @return string The content for the comment section
428
  */
429
- public function display_comment_section($qmn_quiz_options, $qmn_array_for_variables)
430
- {
431
  global $mlw_qmn_section_count;
432
  $comment_display = '';
433
  if ($qmn_quiz_options->comment_section == 0)
@@ -439,7 +419,6 @@ class QMNQuizManager
439
  $comment_display .= "<label for='mlwQuizComments' class='mlw_qmn_comment_section_text'>$message_comments</label><br />";
440
  $comment_display .= "<textarea cols='60' rows='10' id='mlwQuizComments' name='mlwQuizComments' class='qmn_comment_section'></textarea>";
441
  $comment_display .= "</div>";
442
- if ( $qmn_quiz_options->pagination == 0) { $comment_display .= "<br /><br />"; }
443
  }
444
  return $comment_display;
445
  }
@@ -468,9 +447,8 @@ class QMNQuizManager
468
  $section_display .= "<span class='mlw_qmn_message_end'>$message_end</span>";
469
  $section_display .= "<br /><br />";
470
  }
471
- if ($qmn_quiz_options->contact_info_location == 1)
472
- {
473
- $section_display .= mlwDisplayContactInfo($qmn_quiz_options);
474
  }
475
 
476
  //Legacy Code
@@ -479,7 +457,7 @@ class QMNQuizManager
479
  $section_display .= ob_get_contents();
480
  ob_end_clean();
481
 
482
- $section_display .= "<input type='submit' class='qmn_btn' value='".esc_attr(htmlspecialchars_decode($qmn_quiz_options->submit_button_text, ENT_QUOTES))."' />";
483
  $section_display .= "</div>";
484
 
485
  return $section_display;
@@ -517,8 +495,8 @@ class QMNQuizManager
517
  parse_str( $_POST["quizData"], $_POST );
518
  $qmn_allowed_visit = true;
519
  $quiz = intval( $_POST["qmn_quiz_id"] );
520
- $mlwQuizMasterNext->quizCreator->set_id($quiz);
521
- $qmn_quiz_options = $this->load_quiz_options( $quiz );
522
  $qmn_quiz_questions = $this->load_questions( $quiz, $qmn_quiz_options, false );
523
  $qmn_quiz_answers = $this->create_answer_array( $qmn_quiz_questions, true );
524
  $qmn_array_for_variables = array(
@@ -542,7 +520,6 @@ class QMNQuizManager
542
  * @param array $qmn_array_for_variables The array of results for the quiz
543
  * @uses QMNQuizManager:check_answers() Creates display for beginning section
544
  * @uses QMNQuizManager:check_comment_section() Creates display for questions
545
- * @uses QMNQuizManager:generate_certificate() Creates display for comment section
546
  * @uses QMNQuizManager:display_results_text() Creates display for end section
547
  * @uses QMNQuizManager:display_social() Creates display for comment section
548
  * @uses QMNQuizManager:send_user_email() Creates display for end section
@@ -566,18 +543,34 @@ class QMNQuizManager
566
  return $result_display;
567
  }
568
 
569
- $mlw_user_name = isset($_POST["mlwUserName"]) ? sanitize_text_field( $_POST["mlwUserName"] ) : 'None';
570
- $mlw_user_comp = isset($_POST["mlwUserComp"]) ? sanitize_text_field( $_POST["mlwUserComp"] ) : 'None';
571
- $mlw_user_email = isset($_POST["mlwUserEmail"]) ? sanitize_text_field( $_POST["mlwUserEmail"] ) : 'None';
572
- $mlw_user_phone = isset($_POST["mlwUserPhone"]) ? sanitize_text_field( $_POST["mlwUserPhone"] ) : 'None';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
573
  $mlw_qmn_timer = isset($_POST["timer"]) ? intval( $_POST["timer"] ) : 0;
574
- $qmn_array_for_variables['user_name'] = $mlw_user_name;
575
- $qmn_array_for_variables['user_business'] = $mlw_user_comp;
576
- $qmn_array_for_variables['user_email'] = $mlw_user_email;
577
- $qmn_array_for_variables['user_phone'] = $mlw_user_phone;
578
  $qmn_array_for_variables['user_id'] = get_current_user_id();
579
  $qmn_array_for_variables['timer'] = $mlw_qmn_timer;
580
  $qmn_array_for_variables['time_taken'] = date("h:i:s A m/d/Y");
 
581
 
582
  if (!isset($_POST["mlw_code_captcha"]) || (isset($_POST["mlw_code_captcha"]) && $_POST["mlw_user_captcha"] == $_POST["mlw_code_captcha"]))
583
  {
@@ -586,8 +579,6 @@ class QMNQuizManager
586
  $result_display = apply_filters('qmn_after_check_answers', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
587
  $qmn_array_for_variables['comments'] = $this->check_comment_section($qmn_quiz_options, $qmn_array_for_variables);
588
  $result_display = apply_filters('qmn_after_check_comments', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
589
- $qmn_array_for_variables['certificate_link'] = $this->generate_certificate($qmn_quiz_options, $qmn_array_for_variables);
590
- $result_display = apply_filters('qmn_after_generate_certificate', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
591
  $result_display .= $this->display_results_text($qmn_quiz_options, $qmn_array_for_variables);
592
  $result_display = apply_filters('qmn_after_results_text', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
593
  $result_display .= $this->display_social($qmn_quiz_options, $qmn_array_for_variables);
@@ -601,7 +592,8 @@ class QMNQuizManager
601
  $mlw_quiz_results_array = array(
602
  intval($qmn_array_for_variables['timer']),
603
  $qmn_array_for_variables['question_answers_array'],
604
- htmlspecialchars(stripslashes($qmn_array_for_variables['comments']), ENT_QUOTES)
 
605
  );
606
  $mlw_quiz_results = serialize($mlw_quiz_results_array);
607
 
@@ -821,59 +813,6 @@ class QMNQuizManager
821
  return apply_filters( 'qmn_returned_comments', $qmn_quiz_comments, $qmn_quiz_options, $qmn_array_for_variables );
822
  }
823
 
824
- /**
825
- * Generates Certificate
826
- *
827
- * Generates the certificate for the user using fpdf
828
- *
829
- * @since 4.0.0
830
- * @param array $qmn_quiz_options The database row of the quiz
831
- * @param array $qmn_array_for_variables The array of results for the quiz
832
- * @return string The link to the certificate
833
- */
834
- public function generate_certificate($qmn_quiz_options, $qmn_array_for_variables)
835
- {
836
- $mlw_certificate_link = "";
837
- if (is_serialized($qmn_quiz_options->certificate_template) && is_array(@unserialize($qmn_quiz_options->certificate_template)))
838
- {
839
- $mlw_certificate_options = unserialize($qmn_quiz_options->certificate_template);
840
- }
841
- else
842
- {
843
- $mlw_certificate_options = array('Enter title here', 'Enter text here', '', '', 1);
844
- }
845
- if ($mlw_certificate_options[4] == 0)
846
- {
847
- $mlw_message_certificate = $mlw_certificate_options[1];
848
- $mlw_message_certificate = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message_certificate, $qmn_array_for_variables);
849
- $mlw_message_certificate = str_replace( "\n" , "<br>", $mlw_message_certificate);
850
- $path_to_fpdf = plugin_dir_path( __FILE__ )."fpdf/WriteHTML.php";
851
- $mlw_qmn_certificate_file=<<<EOC
852
- <?php
853
- include("$path_to_fpdf");
854
- \$pdf=new PDF_HTML();
855
- \$pdf->AddPage('L');
856
- EOC;
857
- $mlw_qmn_certificate_file.=$mlw_certificate_options[3] != '' ? '$pdf->Image("'.$mlw_certificate_options[3].'",0,0,$pdf->w, $pdf->h);' : '';
858
- $mlw_qmn_certificate_file.=<<<EOC
859
- \$pdf->Ln(20);
860
- \$pdf->SetFont('Arial','B',24);
861
- \$pdf->MultiCell(280,20,'$mlw_certificate_options[0]',0,'C');
862
- \$pdf->Ln(15);
863
- \$pdf->SetFont('Arial','',16);
864
- \$pdf->WriteHTML("<p align='center'>$mlw_message_certificate</p>");
865
- EOC;
866
- $mlw_qmn_certificate_file.=$mlw_certificate_options[2] != '' ? '$pdf->Image("'.$mlw_certificate_options[2].'",110,130);' : '';
867
- $mlw_qmn_certificate_file.=<<<EOC
868
- \$pdf->Output('mlw_qmn_certificate.pdf','D');
869
- EOC;
870
- $mlw_qmn_certificate_filename = plugin_dir_path( __FILE__ )."certificates/mlw_qmn_quiz".date("YmdHis").$qmn_array_for_variables['timer'].".php";
871
- file_put_contents($mlw_qmn_certificate_filename, $mlw_qmn_certificate_file);
872
- $mlw_qmn_certificate_filename = plugin_dir_url( __FILE__ )."certificates/mlw_qmn_quiz".date("YmdHis").$qmn_array_for_variables['timer'].".php";
873
- $mlw_certificate_link = "<a href='".$mlw_qmn_certificate_filename."' class='qmn_certificate_link'>Download Certificate</a>";
874
- }
875
- return $mlw_certificate_link;
876
- }
877
 
878
  /**
879
  * Displays Results Text
@@ -1253,7 +1192,7 @@ add_filter('qmn_begin_shortcode', 'qmn_total_user_tries_check', 10, 3);
1253
  /**
1254
  * Checks if user has already reach the user limit of the quiz
1255
  *
1256
- * @since 4.8.0
1257
  * @param string $display The HTML displayed for the quiz
1258
  * @param array $qmn_quiz_options The settings for the quiz
1259
  * @param array $qmn_array_for_variables The array of data by the quiz
@@ -1321,20 +1260,12 @@ function qmn_pagination_check( $display, $qmn_quiz_options, $qmn_array_for_varia
1321
  }
1322
  $display .= "<style>.quiz_section { display: none; }</style>";
1323
 
1324
- //Gather text for pagination buttons
1325
- $mlw_qmn_pagination_text = "";
1326
- if ( is_serialized( $qmn_quiz_options->pagination_text ) && is_array( @unserialize( $qmn_quiz_options->pagination_text ) ) ) {
1327
- $mlw_qmn_pagination_text = @unserialize($qmn_quiz_options->pagination_text);
1328
- } else {
1329
- $mlw_qmn_pagination_text = array(__('Previous', 'quiz-master-next'), $qmn_quiz_options->pagination_text);
1330
- }
1331
-
1332
  $qmn_json_data["pagination"] = array(
1333
  'amount' => $qmn_quiz_options->pagination,
1334
  'section_comments' => $qmn_quiz_options->comment_section,
1335
  'total_questions' => $total_questions,
1336
- 'previous_text' => $mlw_qmn_pagination_text[0],
1337
- 'next_text' => $mlw_qmn_pagination_text[1]
1338
  );
1339
  }
1340
  return $display;
@@ -1391,126 +1322,6 @@ function qmn_update_taken($display, $qmn_quiz_options, $qmn_array_for_variables)
1391
  return $display;
1392
  }
1393
 
1394
- /*
1395
- This function displays fields to ask for contact information
1396
- */
1397
- function mlwDisplayContactInfo($mlw_quiz_options)
1398
- {
1399
- $mlw_contact_display = "";
1400
- //Check to see if user is logged in, then ask for contact if not
1401
- if ( is_user_logged_in() )
1402
- {
1403
- //If this quiz does not let user edit contact information we hide this section
1404
- if ($mlw_quiz_options->loggedin_user_contact == 1)
1405
- {
1406
- $mlw_contact_display .= "<div style='display:none;'>";
1407
- }
1408
-
1409
- //Retrieve current user information and save into text fields for contact information
1410
- $current_user = wp_get_current_user();
1411
- if ($mlw_quiz_options->user_name != 2)
1412
- {
1413
- $mlw_contact_class = "class=\"\"";
1414
- if ($mlw_quiz_options->user_name == 1 && $mlw_quiz_options->loggedin_user_contact != 1)
1415
- {
1416
- $mlw_contact_class = "class=\"mlwRequiredText\"";
1417
- }
1418
- $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->name_field_text, ENT_QUOTES)."</span>";
1419
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserName' value='".$current_user->display_name."' />";
1420
- $mlw_contact_display .= "<br /><br />";
1421
-
1422
- }
1423
- if ($mlw_quiz_options->user_comp != 2)
1424
- {
1425
- $mlw_contact_class = "class=\"\"";
1426
- if ($mlw_quiz_options->user_comp == 1 && $mlw_quiz_options->loggedin_user_contact != 1)
1427
- {
1428
- $mlw_contact_class = "class=\"mlwRequiredText\"";
1429
- }
1430
- $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->business_field_text, ENT_QUOTES)."</span>";
1431
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserComp' value='' />";
1432
- $mlw_contact_display .= "<br /><br />";
1433
- }
1434
- if ($mlw_quiz_options->user_email != 2)
1435
- {
1436
- $mlw_contact_class = "class=\"mlwEmail\"";
1437
- if ($mlw_quiz_options->user_email == 1 && $mlw_quiz_options->loggedin_user_contact != 1)
1438
- {
1439
- $mlw_contact_class = "class=\"mlwEmail mlwRequiredText\"";
1440
- }
1441
- $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->email_field_text, ENT_QUOTES)."</span>";
1442
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserEmail' value='".$current_user->user_email."' />";
1443
- $mlw_contact_display .= "<br /><br />";
1444
- }
1445
- if ($mlw_quiz_options->user_phone != 2)
1446
- {
1447
- $mlw_contact_class = "class=\"\"";
1448
- if ($mlw_quiz_options->user_phone == 1 && $mlw_quiz_options->loggedin_user_contact != 1)
1449
- {
1450
- $mlw_contact_class = "class=\"mlwRequiredText\"";
1451
- }
1452
- $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->phone_field_text, ENT_QUOTES)."</span>";
1453
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserPhone' value='' />";
1454
- $mlw_contact_display .= "<br /><br />";
1455
- }
1456
-
1457
- //End of hidden section div
1458
- if ($mlw_quiz_options->loggedin_user_contact == 1)
1459
- {
1460
- $mlw_contact_display .= "</div>";
1461
- }
1462
- }
1463
- else
1464
- {
1465
- //See if the site wants to ask for any contact information, then ask for it
1466
- if ($mlw_quiz_options->user_name != 2)
1467
- {
1468
- $mlw_contact_class = "class=\"\"";
1469
- if ($mlw_quiz_options->user_name == 1)
1470
- {
1471
- $mlw_contact_class = "class=\"mlwRequiredText\"";
1472
- }
1473
- $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->name_field_text, ENT_QUOTES)."</span>";
1474
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserName' value='' />";
1475
- $mlw_contact_display .= "<br /><br />";
1476
- }
1477
- if ($mlw_quiz_options->user_comp != 2)
1478
- {
1479
- $mlw_contact_class = "class=\"\"";
1480
- if ($mlw_quiz_options->user_comp == 1)
1481
- {
1482
- $mlw_contact_class = "class=\"mlwRequiredText\"";
1483
- }
1484
- $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->business_field_text, ENT_QUOTES)."</span>";
1485
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserComp' value='' />";
1486
- $mlw_contact_display .= "<br /><br />";
1487
- }
1488
- if ($mlw_quiz_options->user_email != 2)
1489
- {
1490
- $mlw_contact_class = "class=\"mlwEmail\"";
1491
- if ($mlw_quiz_options->user_email == 1)
1492
- {
1493
- $mlw_contact_class = "class=\"mlwEmail mlwRequiredText\"";
1494
- }
1495
- $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->email_field_text, ENT_QUOTES)."</span>";
1496
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserEmail' value='' />";
1497
- $mlw_contact_display .= "<br /><br />";
1498
- }
1499
- if ($mlw_quiz_options->user_phone != 2)
1500
- {
1501
- $mlw_contact_class = "class=\"\"";
1502
- if ($mlw_quiz_options->user_phone == 1)
1503
- {
1504
- $mlw_contact_class = "class=\"mlwRequiredText\"";
1505
- }
1506
- $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->phone_field_text, ENT_QUOTES)."</span>";
1507
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserPhone' value='' />";
1508
- $mlw_contact_display .= "<br /><br />";
1509
- }
1510
- }
1511
- return $mlw_contact_display;
1512
- }
1513
-
1514
  /*
1515
  This function helps set the email type to HTML
1516
  */
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) ) exit;
3
+
4
  /**
5
  * This class generates the contents of the quiz shortcode
6
  *
7
  * @since 4.0.0
8
  */
9
+ class QMNQuizManager {
10
+
11
  /**
12
  * Main Construct Function
13
  *
17
  * @uses QMNQuizManager::add_hooks() Adds actions to hooks and filters
18
  * @return void
19
  */
20
+ public function __construct() {
 
21
  $this->add_hooks();
22
  }
23
 
29
  * @since 4.0.0
30
  * @return void
31
  */
32
+ public function add_hooks() {
 
33
  add_shortcode( 'mlw_quizmaster', array( $this, 'display_shortcode' ) );
34
+ add_shortcode( 'qsm', array( $this, 'display_shortcode' ) );
35
  add_action( 'wp_ajax_qmn_process_quiz', array( $this, 'ajax_submit_results' ) );
36
  add_action( 'wp_ajax_nopriv_qmn_process_quiz', array( $this, 'ajax_submit_results' ) );
37
  }
42
  * Generates the content for the [mlw_quizmaster] shortcode
43
  *
44
  * @since 4.0.0
 
45
  * @uses QMNQuizManager:load_questions() Loads questions
46
  * @uses QMNQuizManager:create_answer_array() Prepares answers
47
  * @uses QMNQuizManager:display_quiz() Generates and prepares quiz page
48
  * @uses QMNQuizManager:display_results() Generates and prepares results page
49
  * @return string The content for the shortcode
50
  */
51
+ public function display_shortcode( $atts ) {
 
52
  extract(shortcode_atts(array(
53
  'quiz' => 0,
54
  'question_amount' => 0
60
  global $qmn_json_data;
61
  $qmn_json_data = array();
62
  $qmn_allowed_visit = true;
63
+ $mlwQuizMasterNext->pluginHelper->prepare_quiz( $quiz );
64
  $question_amount = intval( $question_amount );
65
 
66
  //Legacy variable
72
  date_default_timezone_set(get_option('timezone_string'));
73
  }
74
  $return_display = '';
75
+ $qmn_quiz_options = $mlwQuizMasterNext->quiz_settings->get_quiz_options();
76
 
77
  //If quiz options isn't found, stop function
78
  if (is_null($qmn_quiz_options) || $qmn_quiz_options->quiz_name == '')
92
  // Check direct file first, then check templates folder in plugin, then check templates file in theme.
93
  // If all fails, then load custom styling instead
94
  if ( $registered_template && file_exists( $registered_template["path"] ) ) {
95
+ wp_enqueue_style( 'qmn_quiz_template', $registered_template["path"], array(), $mlwQuizMasterNext->version );
96
  } elseif ( $registered_template && file_exists( plugin_dir_path(__FILE__).'../templates/'.$registered_template["path"] ) ) {
97
+ wp_enqueue_style( 'qmn_quiz_template', plugins_url( '../templates/'.$registered_template["path"], __FILE__ ), array(), $mlwQuizMasterNext->version );
98
  } elseif ( $registered_template && file_exists( get_stylesheet_directory_uri().'/templates/'.$registered_template["path"] ) ) {
99
+ wp_enqueue_style( 'qmn_quiz_template', get_stylesheet_directory_uri().'/templates/'.$registered_template["path"], array(), $mlwQuizMasterNext->version );
100
  } else {
101
  echo "<style type='text/css'>".$qmn_quiz_options->quiz_stye."</style>";
102
  }
156
  return $return_display;
157
  }
158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  /**
160
  * Loads Questions
161
  *
274
 
275
  global $qmn_json_data;
276
  $qmn_json_data["error_messages"] = array(
277
+ 'email' => $qmn_quiz_options->email_error_text,
278
+ 'number' => $qmn_quiz_options->number_error_text,
279
+ 'incorrect' => $qmn_quiz_options->incorrect_error_text,
280
+ 'empty' => $qmn_quiz_options->empty_error_text
281
  );
282
 
283
  wp_enqueue_script( 'qmn_quiz', plugins_url( '../js/qmn_quiz.js' , __FILE__ ), array( 'jquery', 'jquery-ui-tooltip' ) );
338
  $message_before = apply_filters( 'mlw_qmn_template_variable_quiz_page', $message_before, $qmn_array_for_variables);
339
 
340
  $section_display .= "<div class='mlw_qmn_message_before'>$message_before</div>";
341
+ if ( 0 == $qmn_quiz_options->contact_info_location ) {
342
+ $section_display .= QSM_Contact_Manager::display_fields( $qmn_quiz_options );
 
 
343
  }
344
  $section_display .= "</div>";
345
  } else {
388
 
389
  // Checks if a hint is entered
390
  if ( ! empty( $mlw_question->hints ) ) {
391
+ $question_display .= "<span title=\"" . esc_attr( htmlspecialchars_decode( $mlw_question->hints, ENT_QUOTES ) ) . "\" class='qsm_hint mlw_qmn_hint_link'>{$qmn_quiz_options->hint_text}</span>";
392
  $question_display .= "<br /><br />";
393
  }
394
  $question_display .= "</div>";
407
  * @param array $qmn_array_for_variables The array of results for the quiz
408
  * @return string The content for the comment section
409
  */
410
+ public function display_comment_section( $qmn_quiz_options, $qmn_array_for_variables ) {
 
411
  global $mlw_qmn_section_count;
412
  $comment_display = '';
413
  if ($qmn_quiz_options->comment_section == 0)
419
  $comment_display .= "<label for='mlwQuizComments' class='mlw_qmn_comment_section_text'>$message_comments</label><br />";
420
  $comment_display .= "<textarea cols='60' rows='10' id='mlwQuizComments' name='mlwQuizComments' class='qmn_comment_section'></textarea>";
421
  $comment_display .= "</div>";
 
422
  }
423
  return $comment_display;
424
  }
447
  $section_display .= "<span class='mlw_qmn_message_end'>$message_end</span>";
448
  $section_display .= "<br /><br />";
449
  }
450
+ if ( 1 == $qmn_quiz_options->contact_info_location ) {
451
+ $section_display .= QSM_Contact_Manager::display_fields( $qmn_quiz_options );
 
452
  }
453
 
454
  //Legacy Code
457
  $section_display .= ob_get_contents();
458
  ob_end_clean();
459
 
460
+ $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))."' />";
461
  $section_display .= "</div>";
462
 
463
  return $section_display;
495
  parse_str( $_POST["quizData"], $_POST );
496
  $qmn_allowed_visit = true;
497
  $quiz = intval( $_POST["qmn_quiz_id"] );
498
+ $mlwQuizMasterNext->pluginHelper->prepare_quiz( $quiz );
499
+ $qmn_quiz_options = $mlwQuizMasterNext->quiz_settings->get_quiz_options();
500
  $qmn_quiz_questions = $this->load_questions( $quiz, $qmn_quiz_options, false );
501
  $qmn_quiz_answers = $this->create_answer_array( $qmn_quiz_questions, true );
502
  $qmn_array_for_variables = array(
520
  * @param array $qmn_array_for_variables The array of results for the quiz
521
  * @uses QMNQuizManager:check_answers() Creates display for beginning section
522
  * @uses QMNQuizManager:check_comment_section() Creates display for questions
 
523
  * @uses QMNQuizManager:display_results_text() Creates display for end section
524
  * @uses QMNQuizManager:display_social() Creates display for comment section
525
  * @uses QMNQuizManager:send_user_email() Creates display for end section
543
  return $result_display;
544
  }
545
 
546
+ // Gather contact information
547
+ $qmn_array_for_variables['user_name'] = 'None';
548
+ $qmn_array_for_variables['user_business'] = 'None';
549
+ $qmn_array_for_variables['user_email'] = 'None';
550
+ $qmn_array_for_variables['user_phone'] = 'None';
551
+ $contact_responses = QSM_Contact_Manager::process_fields( $qmn_quiz_options );
552
+ foreach ( $contact_responses as $field ) {
553
+ if ( isset( $field['use'] ) ) {
554
+ if ( 'name' === $field['use'] ) {
555
+ $qmn_array_for_variables['user_name'] = $field["value"];
556
+ }
557
+ if ( 'comp' === $field['use'] ) {
558
+ $qmn_array_for_variables['user_business'] = $field["value"];
559
+ }
560
+ if ( 'email' === $field['use'] ) {
561
+ $qmn_array_for_variables['user_email'] = $field["value"];
562
+ }
563
+ if ( 'phone' === $field['use'] ) {
564
+ $qmn_array_for_variables['user_phone'] = $field["value"];
565
+ }
566
+ }
567
+ }
568
+
569
  $mlw_qmn_timer = isset($_POST["timer"]) ? intval( $_POST["timer"] ) : 0;
 
 
 
 
570
  $qmn_array_for_variables['user_id'] = get_current_user_id();
571
  $qmn_array_for_variables['timer'] = $mlw_qmn_timer;
572
  $qmn_array_for_variables['time_taken'] = date("h:i:s A m/d/Y");
573
+ $qmn_array_for_variables['contact'] = $contact_responses;
574
 
575
  if (!isset($_POST["mlw_code_captcha"]) || (isset($_POST["mlw_code_captcha"]) && $_POST["mlw_user_captcha"] == $_POST["mlw_code_captcha"]))
576
  {
579
  $result_display = apply_filters('qmn_after_check_answers', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
580
  $qmn_array_for_variables['comments'] = $this->check_comment_section($qmn_quiz_options, $qmn_array_for_variables);
581
  $result_display = apply_filters('qmn_after_check_comments', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
 
 
582
  $result_display .= $this->display_results_text($qmn_quiz_options, $qmn_array_for_variables);
583
  $result_display = apply_filters('qmn_after_results_text', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
584
  $result_display .= $this->display_social($qmn_quiz_options, $qmn_array_for_variables);
592
  $mlw_quiz_results_array = array(
593
  intval($qmn_array_for_variables['timer']),
594
  $qmn_array_for_variables['question_answers_array'],
595
+ htmlspecialchars(stripslashes($qmn_array_for_variables['comments']), ENT_QUOTES),
596
+ 'contact' => $contact_responses
597
  );
598
  $mlw_quiz_results = serialize($mlw_quiz_results_array);
599
 
813
  return apply_filters( 'qmn_returned_comments', $qmn_quiz_comments, $qmn_quiz_options, $qmn_array_for_variables );
814
  }
815
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
816
 
817
  /**
818
  * Displays Results Text
1192
  /**
1193
  * Checks if user has already reach the user limit of the quiz
1194
  *
1195
+ * @since 5.0.0
1196
  * @param string $display The HTML displayed for the quiz
1197
  * @param array $qmn_quiz_options The settings for the quiz
1198
  * @param array $qmn_array_for_variables The array of data by the quiz
1260
  }
1261
  $display .= "<style>.quiz_section { display: none; }</style>";
1262
 
 
 
 
 
 
 
 
 
1263
  $qmn_json_data["pagination"] = array(
1264
  'amount' => $qmn_quiz_options->pagination,
1265
  'section_comments' => $qmn_quiz_options->comment_section,
1266
  'total_questions' => $total_questions,
1267
+ 'previous_text' => $qmn_quiz_options->previous_button_text,
1268
+ 'next_text' => $qmn_quiz_options->next_button_text
1269
  );
1270
  }
1271
  return $display;
1322
  return $display;
1323
  }
1324
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1325
  /*
1326
  This function helps set the email type to HTML
1327
  */
php/class-qmn-review-message.php CHANGED
@@ -28,7 +28,7 @@ class QMN_Review_Message {
28
  /**
29
  * Adds check message to admin_init hook
30
  *
31
- * @since 4.8.0
32
  */
33
  public function add_hooks() {
34
  add_action( 'admin_init', array( $this, 'check_message_display' ) );
28
  /**
29
  * Adds check message to admin_init hook
30
  *
31
+ * @since 5.0.0
32
  */
33
  public function add_hooks() {
34
  add_action( 'admin_init', array( $this, 'check_message_display' ) );
php/class-qsm-contact-manager.php ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Exit if accessed directly
4
+ if ( ! defined( 'ABSPATH' ) ) exit;
5
+
6
+ /**
7
+ *
8
+ */
9
+ class QSM_Contact_Manager {
10
+
11
+ private static $fields = array();
12
+
13
+ function __construct() {
14
+ # code...
15
+ }
16
+
17
+ /**
18
+ * Displays the contact fields during form
19
+ *
20
+ * @since 5.0.0
21
+ * @param $options The quiz options
22
+ * @return string The HTML for the contact fields
23
+ */
24
+ public static function display_fields( $options ) {
25
+ $return = '';
26
+
27
+ // Prepare name and email values from profile if logged in
28
+ $name = '';
29
+ $email = '';
30
+ if ( is_user_logged_in() ) {
31
+ $current_user = wp_get_current_user();
32
+ $name = $current_user->display_name;
33
+ $email = $current_user->user_email;
34
+ }
35
+
36
+ // If logged in user should see fields
37
+ if ( 1 == $options->loggedin_user_contact ) {
38
+ $return = '<div style="display:none;">';
39
+ }
40
+
41
+ // Loads fields
42
+ $fields = self::load_fields();
43
+
44
+ // If fields are empty, check for backwards compatibility
45
+ if ( ( empty( $fields ) || ! is_array( $fields ) ) && ( 2 != $options->user_name || 2 != $options->user_comp || 2 != $options->user_email || 2 != $options->user_phone ) ) {
46
+
47
+ // Check for name field
48
+ if ( 2 != $options->user_name ) {
49
+ $class = '';
50
+ if ( 1 == $options->user_name && 1 != $options->loggedin_user_contact ) {
51
+ $class = 'mlwRequiredText qsm_required_text';
52
+ }
53
+ $return .= "<span class='mlw_qmn_question qsm_question'>" . htmlspecialchars_decode( $options->name_field_text, ENT_QUOTES ) . "</span>";
54
+ $return .= "<input type='text' class='$class' x-webkit-speech name='mlwUserName' value='$name' />";
55
+ }
56
+
57
+ // Check for comp field
58
+ if ( 2 != $options->user_comp ) {
59
+ $class = '';
60
+ if ( 1 == $options->user_comp && 1 != $options->loggedin_user_contact ) {
61
+ $class = 'mlwRequiredText qsm_required_text';
62
+ }
63
+ $return .= "<span class='mlw_qmn_question qsm_question'>" . htmlspecialchars_decode( $options->business_field_text, ENT_QUOTES ) . "</span>";
64
+ $return .= "<input type='text' class='$class' x-webkit-speech name='mlwUserComp' value='' />";
65
+ }
66
+
67
+ // Check for email field
68
+ if ( 2 != $options->user_email ) {
69
+ $class = '';
70
+ if ( 1 == $options->user_email && 1 != $options->loggedin_user_contact ) {
71
+ $class = 'mlwRequiredText qsm_required_text';
72
+ }
73
+ $return .= "<span class='mlw_qmn_question qsm_question'>" . htmlspecialchars_decode( $options->email_field_text, ENT_QUOTES ) . "</span>";
74
+ $return .= "<input type='email' class='mlwEmail $class' x-webkit-speech name='mlwUserEmail' value='$email' />";
75
+ }
76
+
77
+ // Check for phone field
78
+ if ( 2 != $options->user_phone ) {
79
+ $class = '';
80
+ if ( 1 == $options->user_phone && 1 != $options->loggedin_user_contact ) {
81
+ $class = 'mlwRequiredText qsm_required_text';
82
+ }
83
+ $return .= "<span class='mlw_qmn_question qsm_question'>" . htmlspecialchars_decode( $options->phone_field_text, ENT_QUOTES ) . "</span>";
84
+ $return .= "<input type='text' class='$class' x-webkit-speech name='mlwUserPhone' value='' />";
85
+ }
86
+ } elseif ( ! empty( $fields ) && is_array( $fields ) ) {
87
+
88
+ // Cycle through each of the contact fields
89
+ for ( $i = 0; $i < count( $fields ); $i++ ) {
90
+
91
+ $return .= '<div class="qsm_contact_div">';
92
+ $class = '';
93
+ $return .= "<span class='mlw_qmn_question qsm_question'>{$fields[ $i ]['label']}</span>";
94
+ $value = '';
95
+ if ( 'name' == $fields[ $i ]['use'] ) {
96
+ $value = $name;
97
+ }
98
+ if ( 'email' == $fields[ $i ]['use'] ) {
99
+ $value = $email;
100
+ }
101
+
102
+ // Switch for contact field type
103
+ switch ( $fields[ $i ]['type'] ) {
104
+ case 'text':
105
+ if ( ( "true" === $fields[ $i ]["required"] || true === $fields[ $i ]["required"] ) && 1 != $options->loggedin_user_contact ) {
106
+ $class = 'mlwRequiredText qsm_required_text';
107
+ }
108
+ $return .= "<input type='text' class='$class' x-webkit-speech name='contact_field_$i' value='$value' />";
109
+ break;
110
+
111
+ case 'email':
112
+ if ( ( "true" === $fields[ $i ]["required"] || true === $fields[ $i ]["required"] ) && 1 != $options->loggedin_user_contact ) {
113
+ $class = 'mlwRequiredText qsm_required_text';
114
+ }
115
+ $return .= "<input type='text' class='mlwEmail $class' x-webkit-speech name='contact_field_$i' value='$value' />";
116
+ break;
117
+
118
+ case 'checkbox':
119
+ if ( ( "true" === $fields[ $i ]["required"] || true === $fields[ $i ]["required"] ) && 1 != $options->loggedin_user_contact ) {
120
+ $class = 'mlwRequiredAccept qsm_required_accept';
121
+ }
122
+ $return .= "<input type='checkbox' class='$class' x-webkit-speech name='contact_field_$i' value='checked' />";
123
+ break;
124
+
125
+ default:
126
+ break;
127
+ }
128
+
129
+ $return .= '</div>';
130
+ }
131
+ }
132
+
133
+ // If logged in user should see fields
134
+ if ( 1 == $options->loggedin_user_contact ) {
135
+ $return .= '</div>';
136
+ }
137
+
138
+ // Return contact field HTML
139
+ return $return;
140
+ }
141
+
142
+ /**
143
+ * Process the contact fields and return the values
144
+ *
145
+ * @since 5.0.0
146
+ * @return array An array of all labels and values for the contact fields
147
+ */
148
+ public static function process_fields( $options ) {
149
+
150
+ $responses = array();
151
+
152
+ // Loads fields
153
+ $fields = self::load_fields();
154
+
155
+ // If fields are empty, check for backwards compatibility
156
+ if ( ( empty( $fields ) || ! is_array( $fields ) ) && ( 2 != $options->user_name || 2 != $options->user_comp || 2 != $options->user_email || 2 != $options->user_phone ) ) {
157
+ $responses[] = array(
158
+ 'label' => 'Name',
159
+ 'value' => isset( $_POST["mlwUserName"] ) ? sanitize_text_field( $_POST["mlwUserName"] ) : 'None',
160
+ 'use' => 'name'
161
+ );
162
+ $responses[] = array(
163
+ 'label' => 'Business',
164
+ 'value' => isset( $_POST["mlwUserComp"] ) ? sanitize_text_field( $_POST["mlwUserComp"] ) : 'None',
165
+ 'use' => 'comp'
166
+ );
167
+ $responses[] = array(
168
+ 'label' => 'Email',
169
+ 'value' => isset( $_POST["mlwUserEmail"] ) ? sanitize_text_field( $_POST["mlwUserEmail"] ) : 'None',
170
+ 'use' => 'email'
171
+ );
172
+ $responses[] = array(
173
+ 'label' => 'Phone',
174
+ 'value' => isset( $_POST["mlwUserPhone"] ) ? sanitize_text_field( $_POST["mlwUserPhone"] ) : 'None',
175
+ 'use' => 'phone'
176
+ );
177
+ } elseif ( ! empty( $fields ) && is_array( $fields ) ) {
178
+ for ( $i = 0; $i < count( $fields ); $i++ ) {
179
+ $fieldArray = array(
180
+ 'label' => $fields[ $i ]['label'],
181
+ 'value' => isset( $_POST["contact_field_$i"] ) ? sanitize_text_field( $_POST["contact_field_$i"] ) : 'None'
182
+ );
183
+ if ( isset( $fields[ $i ]['use'] ) ) {
184
+ $fieldArray['use'] = $fields[ $i ]['use'];
185
+ }
186
+ $responses[] = $fieldArray;
187
+ }
188
+ }
189
+
190
+ // For backwards compatibility, use the 'use' fields for setting $_POST values of older version of contact fields
191
+ foreach ( $responses as $field ) {
192
+ if ( isset( $field['use'] ) ) {
193
+ if ( 'name' === $field['use'] ) {
194
+ $_POST["mlwUserName"] = $field["value"];
195
+ }
196
+ if ( 'comp' === $field['use'] ) {
197
+ $_POST["mlwUserComp"] = $field["value"];
198
+ }
199
+ if ( 'email' === $field['use'] ) {
200
+ $_POST["mlwUserEmail"] = $field["value"];
201
+ }
202
+ if ( 'phone' === $field['use'] ) {
203
+ $_POST["mlwUserPhone"] = $field["value"];
204
+ }
205
+ }
206
+ }
207
+
208
+ return $responses;
209
+ }
210
+
211
+ /**
212
+ * Loads the fields
213
+ *
214
+ * @since 5.0.0
215
+ * @uses QMNPluginHelper::get_quiz_setting
216
+ * @return array The array of contact fields
217
+ */
218
+ public static function load_fields() {
219
+ global $mlwQuizMasterNext;
220
+ return maybe_unserialize( $mlwQuizMasterNext->pluginHelper->get_quiz_setting( "contact_form" ) );
221
+ }
222
+
223
+ /**
224
+ * Saves the contact fields
225
+ *
226
+ * @since 5.0.0
227
+ * @uses QMNPluginHelper::prepare_quiz
228
+ * @uses QMNPluginHelper::update_quiz_setting
229
+ */
230
+ public static function save_fields( $quiz_id, $fields ) {
231
+ if ( self::load_fields() === $fields ) {
232
+ return true;
233
+ }
234
+ global $mlwQuizMasterNext;
235
+ $mlwQuizMasterNext->pluginHelper->prepare_quiz( intval( $quiz_id ) );
236
+ return $mlwQuizMasterNext->pluginHelper->update_quiz_setting( "contact_form", serialize( $fields ) );
237
+ }
238
+ }
239
+ ?>
php/class-qsm-fields.php ADDED
@@ -0,0 +1,248 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ /**
6
+ * This class handles creating form fields based on supplied arrays
7
+ *
8
+ * @since 5.0.0
9
+ */
10
+ class QSM_Fields {
11
+
12
+ /**
13
+ * Cycles through the fields in the array and generates each field
14
+ *
15
+ * @since 5.0.0
16
+ * @param array $fields The array that contains the data for all fields
17
+ * @param array $settings The array that holds the settings for this section
18
+ */
19
+ public static function generate_section( $fields, $section ) {
20
+
21
+ global $mlwQuizMasterNext;
22
+
23
+ // If nonce is correct, save settings
24
+ if ( isset( $_POST["save_settings_nonce"] ) && wp_verify_nonce( $_POST['save_settings_nonce'], 'save_settings') ) {
25
+
26
+ // Cycle through fields to retrieve all posted values
27
+ $settings_array = array();
28
+ foreach ( $fields as $field ) {
29
+
30
+ // Sanitize the values based on type
31
+ $sanitized_value = '';
32
+ switch ( $field["type"] ) {
33
+ case 'text':
34
+ $sanitized_value = sanitize_text_field( stripslashes( $_POST[ $field["id"] ] ) );
35
+ break;
36
+
37
+ case 'radio':
38
+ case 'date':
39
+ $sanitized_value = sanitize_text_field( $_POST[ $field["id"] ] );
40
+ break;
41
+
42
+ case 'number':
43
+ $sanitized_value = intval( $_POST[ $field["id"] ] );
44
+ break;
45
+
46
+ case 'editor':
47
+ $sanitized_value = wp_kses_post( stripslashes( $_POST[ $field["id"] ] ) );
48
+ break;
49
+
50
+ default:
51
+ $sanitized_value = sanitize_text_field( $_POST[ $field["id"] ] );
52
+ break;
53
+ }
54
+ $settings_array[ $field["id"] ] = $sanitized_value;
55
+ }
56
+
57
+ // Update the settings and show alert based on outcome
58
+ $results = $mlwQuizMasterNext->pluginHelper->update_quiz_setting( $section, $settings_array );
59
+ if ( false != $results ) {
60
+ $mlwQuizMasterNext->alertManager->newAlert(__('The settings has been updated successfully.', 'quiz-master-next'), 'success');
61
+ $mlwQuizMasterNext->audit_manager->new_audit( "Settings Have Been Edited" );
62
+ } else {
63
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0008'), 'error');
64
+ $mlwQuizMasterNext->log_manager->add("Error 0008", $wpdb->last_error.' from '.$wpdb->last_query, 0, 'error');
65
+ }
66
+ }
67
+
68
+ // Retrieve the settings for this section
69
+ $settings = $mlwQuizMasterNext->pluginHelper->get_quiz_setting( $section );
70
+
71
+ ?>
72
+ <form action="" method="post">
73
+ <?php wp_nonce_field( 'save_settings','save_settings_nonce' ); ?>
74
+ <button class="button-primary"><?php _e('Save Changes', 'quiz-master-next'); ?></button>
75
+ <table class="form-table" style="width: 100%;">
76
+ <?php
77
+
78
+ // Cycles through each field
79
+ foreach ( $fields as $field ) {
80
+
81
+ // Generate the field
82
+ QSM_Fields::generate_field( $field, $settings[ $field["id"] ] );
83
+ }
84
+ ?>
85
+ </table>
86
+ <button class="button-primary"><?php _e('Save Changes', 'quiz-master-next'); ?></button>
87
+ </form>
88
+ <?php
89
+ }
90
+
91
+ /**
92
+ * Prepares the field and calls the correct generate field function based on field's type
93
+ *
94
+ * @since 5.0.0
95
+ * @param array $field The array that contains the data for the input field
96
+ * @param mixed $value The current value of the setting
97
+ * @return bool False if the field is invalid, true if successful
98
+ */
99
+ public static function generate_field( $field, $value ) {
100
+
101
+ // Load default
102
+ $defaults = array(
103
+ 'id' => null,
104
+ 'label' => '',
105
+ 'type' => '',
106
+ 'options' => array(),
107
+ 'variables' => array()
108
+ );
109
+ $field = wp_parse_args( $field, $defaults );
110
+
111
+ // If id is not valid, return false
112
+ if ( is_null( $field["id"] ) || empty( $field["id"] ) ) {
113
+ return false;
114
+ }
115
+
116
+ // If type is empty, assume text
117
+ if ( empty( $field["type"] ) ) {
118
+ $field["type"] = "text";
119
+ }
120
+
121
+ // Prepare function to call for field type
122
+ $method = "generate_{$field["type"]}_field";
123
+ QSM_Fields::$method( $field, $value );
124
+
125
+ return true;
126
+ }
127
+
128
+ /**
129
+ * Generates a text field
130
+ *
131
+ * @since 5.0.0
132
+ * @param array $field The array that contains the data for the input field
133
+ * @param mixed $value The current value of the setting
134
+ */
135
+ public static function generate_text_field( $field, $value ) {
136
+ ?>
137
+ <tr valign="top">
138
+ <th scope="row"><label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label></th>
139
+ <td>
140
+ <input type="text" id="<?php echo $field["id"]; ?>" name="<?php echo $field["id"]; ?>" value="<?php echo $value; ?>" />
141
+ </td>
142
+ </tr>
143
+ <?php
144
+ }
145
+
146
+ /**
147
+ * Generates a textarea field using the WP Editor
148
+ *
149
+ * @since 5.0.0
150
+ * @param array $field The array that contains the data for the input field
151
+ * @param mixed $value The current value of the setting
152
+ */
153
+ public static function generate_editor_field( $field, $value ) {
154
+ ?>
155
+ <tr>
156
+ <th scope="row">
157
+ <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?>
158
+ <?php
159
+ if ( is_array( $field["variables"] ) ) {
160
+ ?>
161
+ <br>
162
+ <p><?php _e( "Allowed Variables:", 'quiz-master-next' ); ?></p>
163
+ <?php
164
+ foreach ( $field["variables"] as $variable ) {
165
+ ?>
166
+ <p style="margin: 2px 0">- <?php echo $variable; ?></p>
167
+ <?php
168
+ }
169
+ }
170
+ ?>
171
+ </label>
172
+ </th>
173
+ <td>
174
+ <?php wp_editor( htmlspecialchars_decode( $value, ENT_QUOTES ), $field["id"] ); ?>
175
+ </td>
176
+ </tr>
177
+ <?php
178
+ }
179
+
180
+ /**
181
+ * Generates a date field
182
+ *
183
+ * @since 5.0.0
184
+ * @param array $field The array that contains the data for the input field
185
+ * @param mixed $value The current value of the setting
186
+ */
187
+ public static function generate_date_field( $field, $value ) {
188
+ wp_enqueue_script( 'jquery-ui-datepicker' );
189
+ ?>
190
+ <script>
191
+ jQuery(function() {
192
+ jQuery( "#<?php echo $field["id"]; ?>" ).datepicker();
193
+ });
194
+ </script>
195
+ <tr valign="top">
196
+ <th scope="row"><label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label></th>
197
+ <td>
198
+ <input type="text" id="<?php echo $field["id"]; ?>" name="<?php echo $field["id"]; ?>" value="<?php echo $value; ?>" />
199
+ </td>
200
+ </tr>
201
+ <?php
202
+ }
203
+
204
+ /**
205
+ * Generates a number field
206
+ *
207
+ * @since 5.0.0
208
+ * @param array $field The array that contains the data for the input field
209
+ * @param mixed $value The current value of the setting
210
+ */
211
+ public static function generate_number_field( $field, $value ) {
212
+ ?>
213
+ <tr valign="top">
214
+ <th scope="row"><label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label></th>
215
+ <td>
216
+ <input type="number" step="1" min="0" id="<?php echo $field["id"]; ?>" name="<?php echo $field["id"]; ?>" value="<?php echo $value; ?>" />
217
+ </td>
218
+ </tr>
219
+ <?php
220
+ }
221
+
222
+ /**
223
+ * Generates radio inputs
224
+ *
225
+ * @since 5.0.0
226
+ * @param array $field The array that contains the data for the input field
227
+ * @param mixed $value The current value of the setting
228
+ */
229
+ public static function generate_radio_field( $field, $value ) {
230
+ ?>
231
+ <tr valign="top">
232
+ <th scope="row"><label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label></th>
233
+ <td>
234
+ <?php
235
+ foreach ( $field["options"] as $option ) {
236
+ ?>
237
+ <input type="radio" id="<?php echo $field["id"] . '-' . $option["value"]; ?>" name="<?php echo $field["id"]; ?>" <?php checked( $option["value"], $value ); ?> value="<?php echo $option["value"]; ?>" />
238
+ <label for="<?php echo $field["id"] . '-' . $option["value"]; ?>"><?php echo $option["label"]; ?></label><br>
239
+ <?php
240
+ }
241
+ ?>
242
+ </td>
243
+ </tr>
244
+ <?php
245
+ }
246
+ }
247
+
248
+ ?>
php/class-qsm-install.php CHANGED
@@ -28,6 +28,679 @@ class QSM_Install {
28
  add_action( 'admin_init', array( $this, 'update' ) );
29
  add_filter( 'plugin_action_links_' . QSM_PLUGIN_BASENAME, array( $this, 'plugin_action_links' ) );
30
  add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  }
32
 
33
  /**
@@ -592,7 +1265,7 @@ class QSM_Install {
592
  $results = $wpdb->query( $update_sql );
593
  }
594
 
595
- // Update 4.8.0
596
  if( $wpdb->get_var( "SHOW COLUMNS FROM $table_name LIKE 'user_ip'" ) != "user_ip" ) {
597
  $sql = "ALTER TABLE $table_name ADD user_ip TEXT NOT NULL AFTER user";
598
  $results = $wpdb->query( $sql );
@@ -600,6 +1273,26 @@ class QSM_Install {
600
  $results = $wpdb->query( $update_sql );
601
  }
602
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
603
 
604
  update_option('mlw_quiz_master_version' , $data);
605
  if( ! isset( $_GET['activate-multi'] ) ) {
28
  add_action( 'admin_init', array( $this, 'update' ) );
29
  add_filter( 'plugin_action_links_' . QSM_PLUGIN_BASENAME, array( $this, 'plugin_action_links' ) );
30
  add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
31
+ add_action( 'plugins_loaded', array( $this, 'register_default_settings' ) );
32
+ }
33
+
34
+ /**
35
+ * Adds the default quiz settings
36
+ *
37
+ * @since 5.0.0
38
+ */
39
+ public function register_default_settings() {
40
+
41
+ global $mlwQuizMasterNext;
42
+
43
+ // Registers system setting
44
+ $field_array = array(
45
+ 'id' => 'system',
46
+ 'label' => __('Which system is this quiz graded on?', 'quiz-master-next'),
47
+ 'type' => 'radio',
48
+ 'options' => array(
49
+ array(
50
+ 'label' => __('Correct/Incorrect', 'quiz-master-next'),
51
+ 'value' => 0
52
+ ),
53
+ array(
54
+ 'label' => __('Points', 'quiz-master-next'),
55
+ 'value' => 1
56
+ ),
57
+ array(
58
+ 'label' => __('Not Graded', 'quiz-master-next'),
59
+ 'value' => 2
60
+ )
61
+ ),
62
+ 'default' => 0
63
+ );
64
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
65
+
66
+ // Registers require_log_in setting
67
+ $field_array = array(
68
+ 'id' => 'require_log_in',
69
+ 'label' => __('Should the user be required to be logged in to take this quiz?', 'quiz-master-next'),
70
+ 'type' => 'radio',
71
+ 'options' => array(
72
+ array(
73
+ 'label' => __('Yes', 'quiz-master-next'),
74
+ 'value' => 1
75
+ ),
76
+ array(
77
+ 'label' => __('No', 'quiz-master-next'),
78
+ 'value' => 0
79
+ )
80
+ ),
81
+ 'default' => 0
82
+ );
83
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
84
+
85
+ // Registers pagination setting
86
+ $field_array = array(
87
+ 'id' => 'pagination',
88
+ 'label' => __('How many questions per page would you like? (Leave 0 for all questions on one page)', 'quiz-master-next'),
89
+ 'type' => 'number',
90
+ 'options' => array(
91
+
92
+ ),
93
+ 'default' => 0
94
+ );
95
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
96
+
97
+ // Registers timer_limit setting
98
+ $field_array = array(
99
+ 'id' => 'timer_limit',
100
+ 'label' => __('How many minutes does the user have to finish the quiz? (Leave 0 for no time limit)', 'quiz-master-next'),
101
+ 'type' => 'number',
102
+ 'options' => array(
103
+
104
+ ),
105
+ 'default' => 0
106
+ );
107
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
108
+
109
+ // Registers total_user_tries setting
110
+ $field_array = array(
111
+ 'id' => 'total_user_tries',
112
+ 'label' => __('How many times can a user take this quiz? (Leave 0 for as many times as the user wants to.)', 'quiz-master-next'),
113
+ 'type' => 'number',
114
+ 'options' => array(
115
+
116
+ ),
117
+ 'default' => 0
118
+ );
119
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
120
+
121
+ // Registers limit_total_entries setting
122
+ $field_array = array(
123
+ 'id' => 'limit_total_entries',
124
+ 'label' => __('How many total entries can this quiz have? (Leave 0 for unlimited entries)', 'quiz-master-next'),
125
+ 'type' => 'number',
126
+ 'options' => array(
127
+
128
+ ),
129
+ 'default' => 0
130
+ );
131
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
132
+
133
+ // Registers question_from_total setting
134
+ $field_array = array(
135
+ 'id' => 'question_from_total',
136
+ 'label' => __('How many questions should be loaded for quiz? (Leave 0 to load all questions)', 'quiz-master-next'),
137
+ 'type' => 'number',
138
+ 'options' => array(
139
+
140
+ ),
141
+ 'default' => 0
142
+ );
143
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
144
+
145
+ // Registers scheduled_time_start setting
146
+ $field_array = array(
147
+ 'id' => 'scheduled_time_start',
148
+ 'label' => __('When should the user be able to start accessing the quiz? (Leave blank if the user can access anytime)', 'quiz-master-next'),
149
+ 'type' => 'date',
150
+ 'options' => array(
151
+
152
+ ),
153
+ 'default' => ''
154
+ );
155
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
156
+
157
+ // Registers scheduled_time_end setting
158
+ $field_array = array(
159
+ 'id' => 'scheduled_time_end',
160
+ 'label' => __('When should the user stop accessing the quiz? (Leave blank if the user can access anytime)', 'quiz-master-next'),
161
+ 'type' => 'date',
162
+ 'options' => array(
163
+
164
+ ),
165
+ 'default' => ''
166
+ );
167
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
168
+
169
+ // Registers randomness_order setting
170
+ $field_array = array(
171
+ 'id' => 'randomness_order',
172
+ 'label' => __('Are the questions random? (Question Order will not apply if this is yes)', 'quiz-master-next'),
173
+ 'type' => 'radio',
174
+ 'options' => array(
175
+ array(
176
+ 'label' => __('Random Questions', 'quiz-master-next'),
177
+ 'value' => 1
178
+ ),
179
+ array(
180
+ 'label' => __('Random Questions And Answers', 'quiz-master-next'),
181
+ 'value' => 2
182
+ ),
183
+ array(
184
+ 'label' => __('Random Answers', 'quiz-master-next'),
185
+ 'value' => 3
186
+ ),
187
+ array(
188
+ 'label' => __('No', 'quiz-master-next'),
189
+ 'value' => 0
190
+ )
191
+ ),
192
+ 'default' => 0
193
+ );
194
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
195
+
196
+ // Registers contact_info_location setting
197
+ $field_array = array(
198
+ 'id' => 'contact_info_location',
199
+ 'label' => __('Would you like to ask for the contact information at the beginning or at the end of the quiz?', 'quiz-master-next'),
200
+ 'type' => 'radio',
201
+ 'options' => array(
202
+ array(
203
+ 'label' => __('Beginning', 'quiz-master-next'),
204
+ 'value' => 0
205
+ ),
206
+ array(
207
+ 'label' => __('End', 'quiz-master-next'),
208
+ 'value' => 1
209
+ )
210
+ ),
211
+ 'default' => 0
212
+ );
213
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
214
+
215
+ // Registers loggedin_user_contact setting
216
+ $field_array = array(
217
+ 'id' => 'loggedin_user_contact',
218
+ 'label' => __('If a logged-in user takes the quiz, would you like them to be able to edit contact information? If set to no, the fields will not show up for logged in users; however, the users information will be saved for the fields.', 'quiz-master-next'),
219
+ 'type' => 'radio',
220
+ 'options' => array(
221
+ array(
222
+ 'label' => __('Yes', 'quiz-master-next'),
223
+ 'value' => 0
224
+ ),
225
+ array(
226
+ 'label' => __('No', 'quiz-master-next'),
227
+ 'value' => 1
228
+ )
229
+ ),
230
+ 'default' => 0
231
+ );
232
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
233
+
234
+ // Registers comment_section setting
235
+ $field_array = array(
236
+ 'id' => 'comment_section',
237
+ 'label' => __('Would you like a place for the user to enter comments?', 'quiz-master-next'),
238
+ 'type' => 'radio',
239
+ 'options' => array(
240
+ array(
241
+ 'label' => __('Yes', 'quiz-master-next'),
242
+ 'value' => 0
243
+ ),
244
+ array(
245
+ 'label' => __('No', 'quiz-master-next'),
246
+ 'value' => 1
247
+ )
248
+ ),
249
+ 'default' => 1
250
+ );
251
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
252
+
253
+ // Registers question_numbering setting
254
+ $field_array = array(
255
+ 'id' => 'question_numbering',
256
+ 'label' => __('Show question number on quiz?', 'quiz-master-next'),
257
+ 'type' => 'radio',
258
+ 'options' => array(
259
+ array(
260
+ 'label' => __('Yes', 'quiz-master-next'),
261
+ 'value' => 1
262
+ ),
263
+ array(
264
+ 'label' => __('No', 'quiz-master-next'),
265
+ 'value' => 0
266
+ )
267
+ ),
268
+ 'default' => 0
269
+ );
270
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
271
+
272
+ // Registers social_media setting
273
+ $field_array = array(
274
+ 'id' => 'social_media',
275
+ 'label' => __('Show social media sharing buttons? (Twitter & Facebook) This option is for here only for users of older versions. Please use the new template variables %FACEBOOK_SHARE% %TWITTER_SHARE% on your results pages instead of using this option!', 'quiz-master-next'),
276
+ 'type' => 'radio',
277
+ 'options' => array(
278
+ array(
279
+ 'label' => __('Yes', 'quiz-master-next'),
280
+ 'value' => 1
281
+ ),
282
+ array(
283
+ 'label' => __('No', 'quiz-master-next'),
284
+ 'value' => 0
285
+ )
286
+ ),
287
+ 'default' => 0
288
+ );
289
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
290
+
291
+ // Registers disable_answer_onselect setting
292
+ $field_array = array(
293
+ 'id' => 'disable_answer_onselect',
294
+ 'label' => __('Disable question once user selects answer? (Currently only work on multiple choice)', 'quiz-master-next'),
295
+ 'type' => 'radio',
296
+ 'options' => array(
297
+ array(
298
+ 'label' => __('Yes', 'quiz-master-next'),
299
+ 'value' => 1
300
+ ),
301
+ array(
302
+ 'label' => __('No', 'quiz-master-next'),
303
+ 'value' => 0
304
+ )
305
+ ),
306
+ 'default' => 0
307
+ );
308
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
309
+
310
+ // Registers ajax_show_correct setting
311
+ $field_array = array(
312
+ 'id' => 'ajax_show_correct',
313
+ 'label' => __('Dynamically add class for incorrect/correct answer after user selects answer? (Currently only works on multiple choice)', 'quiz-master-next'),
314
+ 'type' => 'radio',
315
+ 'options' => array(
316
+ array(
317
+ 'label' => __('Yes', 'quiz-master-next'),
318
+ 'value' => 1
319
+ ),
320
+ array(
321
+ 'label' => __('No', 'quiz-master-next'),
322
+ 'value' => 0
323
+ )
324
+ ),
325
+ 'default' => 0
326
+ );
327
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
328
+
329
+ // Registers user_name setting
330
+ $field_array = array(
331
+ 'id' => 'user_name',
332
+ 'label' => __("Should we ask for the user's name? (Only here for older versions. Use Contact tab for this.)", 'quiz-master-next'),
333
+ 'type' => 'radio',
334
+ 'options' => array(
335
+ array(
336
+ 'label' => __('Yes', 'quiz-master-next'),
337
+ 'value' => 0
338
+ ),
339
+ array(
340
+ 'label' => __('Require', 'quiz-master-next'),
341
+ 'value' => 1
342
+ ),
343
+ array(
344
+ 'label' => __('No', 'quiz-master-next'),
345
+ 'value' => 2
346
+ )
347
+ ),
348
+ 'default' => 2
349
+ );
350
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
351
+
352
+ // Registers user_comp setting
353
+ $field_array = array(
354
+ 'id' => 'user_comp',
355
+ 'label' => __('Should we ask for users business? (Only here for older versions. Use Contact tab for this.)', 'quiz-master-next'),
356
+ 'type' => 'radio',
357
+ 'options' => array(
358
+ array(
359
+ 'label' => __('Yes', 'quiz-master-next'),
360
+ 'value' => 0
361
+ ),
362
+ array(
363
+ 'label' => __('Require', 'quiz-master-next'),
364
+ 'value' => 1
365
+ ),
366
+ array(
367
+ 'label' => __('No', 'quiz-master-next'),
368
+ 'value' => 2
369
+ )
370
+ ),
371
+ 'default' => 2
372
+ );
373
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
374
+
375
+ // Registers user_email setting
376
+ $field_array = array(
377
+ 'id' => 'user_email',
378
+ 'label' => __('Should we ask for users email? (Only here for older versions. Use Contact tab for this.)', 'quiz-master-next'),
379
+ 'type' => 'radio',
380
+ 'options' => array(
381
+ array(
382
+ 'label' => __('Yes', 'quiz-master-next'),
383
+ 'value' => 0
384
+ ),
385
+ array(
386
+ 'label' => __('Require', 'quiz-master-next'),
387
+ 'value' => 1
388
+ ),
389
+ array(
390
+ 'label' => __('No', 'quiz-master-next'),
391
+ 'value' => 2
392
+ )
393
+ ),
394
+ 'default' => 2
395
+ );
396
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
397
+
398
+ // Registers user_phone setting
399
+ $field_array = array(
400
+ 'id' => 'user_phone',
401
+ 'label' => __('Should we ask for users phone number? (Only here for older versions. Use Contact tab for this.)', 'quiz-master-next'),
402
+ 'type' => 'radio',
403
+ 'options' => array(
404
+ array(
405
+ 'label' => __('Yes', 'quiz-master-next'),
406
+ 'value' => 0
407
+ ),
408
+ array(
409
+ 'label' => __('Require', 'quiz-master-next'),
410
+ 'value' => 1
411
+ ),
412
+ array(
413
+ 'label' => __('No', 'quiz-master-next'),
414
+ 'value' => 2
415
+ )
416
+ ),
417
+ 'default' => 2
418
+ );
419
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
420
+
421
+ // Registers message_before setting
422
+ $field_array = array(
423
+ 'id' => 'message_before',
424
+ 'label' => __("Message Displayed Before Quiz", 'quiz-master-next'),
425
+ 'type' => 'editor',
426
+ 'default' => 0,
427
+ 'variables' => array(
428
+ '%QUIZ_NAME%',
429
+ '%CURRENT_DATE%'
430
+ )
431
+ );
432
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
433
+
434
+ // Registers message_comment setting
435
+ $field_array = array(
436
+ 'id' => 'message_comment',
437
+ 'label' => __("Message Displayed Before Comments Box If Enabled", 'quiz-master-next'),
438
+ 'type' => 'editor',
439
+ 'default' => 0,
440
+ 'variables' => array(
441
+ '%QUIZ_NAME%',
442
+ '%CURRENT_DATE%'
443
+ )
444
+ );
445
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
446
+
447
+ // Registers message_end_template setting
448
+ $field_array = array(
449
+ 'id' => 'message_end_template',
450
+ 'label' => __("Message Displayed At End Of Quiz (Leave Blank To Omit Text Section)", 'quiz-master-next'),
451
+ 'type' => 'editor',
452
+ 'default' => 0,
453
+ 'variables' => array(
454
+ '%QUIZ_NAME%',
455
+ '%CURRENT_DATE%'
456
+ )
457
+ );
458
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
459
+
460
+ // Registers total_user_tries_text setting
461
+ $field_array = array(
462
+ 'id' => 'total_user_tries_text',
463
+ 'label' => __("Message Displayed If User Has Tried Quiz Too Many Times", 'quiz-master-next'),
464
+ 'type' => 'editor',
465
+ 'default' => 0,
466
+ 'variables' => array(
467
+ '%QUIZ_NAME%',
468
+ '%CURRENT_DATE%'
469
+ )
470
+ );
471
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
472
+
473
+ // Registers require_log_in_text setting
474
+ $field_array = array(
475
+ 'id' => 'require_log_in_text',
476
+ 'label' => __("Message Displayed If User Is Not Logged In And Quiz Requires Users To Be Logged In", 'quiz-master-next'),
477
+ 'type' => 'editor',
478
+ 'default' => 0,
479
+ 'variables' => array(
480
+ '%QUIZ_NAME%',
481
+ '%CURRENT_DATE%'
482
+ )
483
+ );
484
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
485
+
486
+ // Registers scheduled_timeframe_text setting
487
+ $field_array = array(
488
+ 'id' => 'scheduled_timeframe_text',
489
+ 'label' => __("Message Displayed If Date Is Outside Scheduled Timeframe", 'quiz-master-next'),
490
+ 'type' => 'editor',
491
+ 'default' => 0,
492
+ 'variables' => array(
493
+ '%QUIZ_NAME%',
494
+ '%CURRENT_DATE%'
495
+ )
496
+ );
497
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
498
+
499
+ // Registers limit_total_entries_text setting
500
+ $field_array = array(
501
+ 'id' => 'limit_total_entries_text',
502
+ 'label' => __("Message Displayed If The Limit Of Total Entries Has Been Reached", 'quiz-master-next'),
503
+ 'type' => 'editor',
504
+ 'default' => 0,
505
+ 'variables' => array(
506
+ '%QUIZ_NAME%',
507
+ '%CURRENT_DATE%'
508
+ )
509
+ );
510
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
511
+
512
+ // Registers question_answer_template setting
513
+ $field_array = array(
514
+ 'id' => 'question_answer_template',
515
+ 'label' => __("%QUESTIONS_ANSWERS% Text", 'quiz-master-next'),
516
+ 'type' => 'editor',
517
+ 'default' => 0,
518
+ 'variables' => array(
519
+ '%QUESTION%',
520
+ '%USER_ANSWER%',
521
+ '%CORRECT_ANSWER%',
522
+ '%USER_COMMENTS%',
523
+ '%CORRECT_ANSWER_INFO%'
524
+ )
525
+ );
526
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
527
+
528
+ // Registers twitter_sharing_text setting
529
+ $field_array = array(
530
+ 'id' => 'twitter_sharing_text',
531
+ 'label' => __("Twitter Sharing Text", 'quiz-master-next'),
532
+ 'type' => 'editor',
533
+ 'default' => 0,
534
+ 'variables' => array(
535
+ '%POINT_SCORE%',
536
+ '%AVERAGE_POINT%',
537
+ '%AMOUNT_CORRECT%',
538
+ '%TOTAL_QUESTIONS%',
539
+ '%CORRECT_SCORE%',
540
+ '%QUIZ_NAME%',
541
+ '%TIMER%',
542
+ '%CURRENT_DATE%'
543
+ )
544
+ );
545
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
546
+
547
+ // Registers facebook_sharing_text setting
548
+ $field_array = array(
549
+ 'id' => 'facebook_sharing_text',
550
+ 'label' => __("Facebook Sharing Text", 'quiz-master-next'),
551
+ 'type' => 'editor',
552
+ 'default' => 0,
553
+ 'variables' => array(
554
+ '%POINT_SCORE%',
555
+ '%AVERAGE_POINT%',
556
+ '%AMOUNT_CORRECT%',
557
+ '%TOTAL_QUESTIONS%',
558
+ '%CORRECT_SCORE%',
559
+ '%QUIZ_NAME%',
560
+ '%TIMER%',
561
+ '%CURRENT_DATE%'
562
+ )
563
+ );
564
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
565
+
566
+ // Registers submit_button_text setting
567
+ $field_array = array(
568
+ 'id' => 'submit_button_text',
569
+ 'label' => __('Text for submit button', 'quiz-master-next'),
570
+ 'type' => 'text',
571
+ 'default' => 0
572
+ );
573
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
574
+
575
+ // Registers name_field_text setting
576
+ $field_array = array(
577
+ 'id' => 'name_field_text',
578
+ 'label' => __('Text for name field', 'quiz-master-next'),
579
+ 'type' => 'text',
580
+ 'default' => 0
581
+ );
582
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
583
+
584
+ // Registers business_field_text setting
585
+ $field_array = array(
586
+ 'id' => 'business_field_text',
587
+ 'label' => __('Text for business field', 'quiz-master-next'),
588
+ 'type' => 'text',
589
+ 'default' => 0
590
+ );
591
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
592
+
593
+ // Registers email_field_text setting
594
+ $field_array = array(
595
+ 'id' => 'email_field_text',
596
+ 'label' => __('Text for email field', 'quiz-master-next'),
597
+ 'type' => 'text',
598
+ 'default' => 0
599
+ );
600
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
601
+
602
+ // Registers phone_field_text setting
603
+ $field_array = array(
604
+ 'id' => 'phone_field_text',
605
+ 'label' => __('Text for phone number field', 'quiz-master-next'),
606
+ 'type' => 'text',
607
+ 'default' => 0
608
+ );
609
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
610
+
611
+ // Registers comment_field_text setting
612
+ $field_array = array(
613
+ 'id' => 'comment_field_text',
614
+ 'label' => __('Text for comments field', 'quiz-master-next'),
615
+ 'type' => 'text',
616
+ 'default' => 0
617
+ );
618
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
619
+
620
+ // Registers previous_button_text setting
621
+ $field_array = array(
622
+ 'id' => 'previous_button_text',
623
+ 'label' => __('Text for previous button', 'quiz-master-next'),
624
+ 'type' => 'text',
625
+ 'default' => 0
626
+ );
627
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
628
+
629
+ // Registers next_button_text setting
630
+ $field_array = array(
631
+ 'id' => 'next_button_text',
632
+ 'label' => __('Text for next button', 'quiz-master-next'),
633
+ 'type' => 'text',
634
+ 'default' => 0
635
+ );
636
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
637
+
638
+ // Registers hint_text setting
639
+ $field_array = array(
640
+ 'id' => 'hint_text',
641
+ 'label' => __('Text for hint', 'quiz-master-next'),
642
+ 'type' => 'text',
643
+ 'default' => 'Hint'
644
+ );
645
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
646
+
647
+ // Registers empty_error_text setting
648
+ $field_array = array(
649
+ 'id' => 'empty_error_text',
650
+ 'label' => __('Text for when user has not filled in all required fields', 'quiz-master-next'),
651
+ 'type' => 'text',
652
+ 'default' => 'Please complete all required fields!'
653
+ );
654
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
655
+
656
+ // Registers email_error_text setting
657
+ $field_array = array(
658
+ 'id' => 'email_error_text',
659
+ 'label' => __('Text for when user filled in email field with invalid email', 'quiz-master-next'),
660
+ 'type' => 'text',
661
+ 'default' => 'Not a valid e-mail address!'
662
+ );
663
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
664
+
665
+ // Registers number_error_text setting
666
+ $field_array = array(
667
+ 'id' => 'number_error_text',
668
+ 'label' => __('Text for when user has filled in number field with invalid number', 'quiz-master-next'),
669
+ 'type' => 'text',
670
+ 'default' => 'This field must be a number!'
671
+ );
672
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
673
+
674
+ // Registers incorrect_error_text setting
675
+ $field_array = array(
676
+ 'id' => 'incorrect_error_text',
677
+ 'label' => __('Text for when user has not filled in captcha correctly', 'quiz-master-next'),
678
+ 'type' => 'text',
679
+ 'default' => 'The entered text is not correct!'
680
+ );
681
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
682
+
683
+ // Registers template setting
684
+ $field_array = array(
685
+ 'id' => 'template',
686
+ 'label' => __('Leaderboard Template', 'quiz-master-next'),
687
+ 'type' => 'editor',
688
+ 'variables' => array(
689
+ '%QUIZ_NAME%',
690
+ '%FIRST_PLACE_NAME%',
691
+ '%FIRST_PLACE_SCORE%',
692
+ '%SECOND_PLACE_NAME%',
693
+ '%SECOND_PLACE_SCORE%',
694
+ '%THIRD_PLACE_NAME%',
695
+ '%THIRD_PLACE_SCORE%',
696
+ '%FOURTH_PLACE_NAME%',
697
+ '%FOURTH_PLACE_SCORE%',
698
+ '%FIFTH_PLACE_NAME%',
699
+ '%FIFTH_PLACE_SCORE%'
700
+ ),
701
+ 'default' => 0
702
+ );
703
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_leaderboards' );
704
  }
705
 
706
  /**
1265
  $results = $wpdb->query( $update_sql );
1266
  }
1267
 
1268
+ // Update 4.7.0
1269
  if( $wpdb->get_var( "SHOW COLUMNS FROM $table_name LIKE 'user_ip'" ) != "user_ip" ) {
1270
  $sql = "ALTER TABLE $table_name ADD user_ip TEXT NOT NULL AFTER user";
1271
  $results = $wpdb->query( $sql );
1273
  $results = $wpdb->query( $update_sql );
1274
  }
1275
 
1276
+ // Update 5.0.0
1277
+ $settings = (array) get_option( 'qmn-settings', array() );
1278
+ if ( isset( $settings['results_details_template'] ) ) {
1279
+ $settings['results_details_template'] .= "<p>%CONTACT_ALL%</p>";
1280
+ } else {
1281
+ $settings['results_details_template'] = "<h2>Quiz Results for %QUIZ_NAME%</h2>
1282
+ <p>%CONTACT_ALL%</p>
1283
+ <p>Name Provided: %USER_NAME%</p>
1284
+ <p>Business Provided: %USER_BUSINESS%</p>
1285
+ <p>Phone Provided: %USER_PHONE%</p>
1286
+ <p>Email Provided: %USER_EMAIL%</p>
1287
+ <p>Score Received: %AMOUNT_CORRECT%/%TOTAL_QUESTIONS% or %CORRECT_SCORE%% or %POINT_SCORE% points</p>
1288
+ <h2>Answers Provided:</h2>
1289
+ <p>The user took %TIMER% to complete quiz.</p>
1290
+ <p>Comments entered were: %COMMENT_SECTION%</p>
1291
+ <p>The answers were as follows:</p>
1292
+ %QUESTIONS_ANSWERS%";
1293
+ }
1294
+ update_option( 'qmn-settings' , $settings );
1295
+
1296
 
1297
  update_option('mlw_quiz_master_version' , $data);
1298
  if( ! isset( $_GET['activate-multi'] ) ) {
php/class-qsm-settings.php ADDED
@@ -0,0 +1,416 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ /**
6
+ * This handles all of the settings data for each individual quiz.
7
+ *
8
+ * @since 5.0.0
9
+ */
10
+ class QSM_Quiz_Settings {
11
+
12
+ /**
13
+ * ID of the quiz
14
+ *
15
+ * @var int
16
+ * @since 5.0.0
17
+ */
18
+ private $quiz_id;
19
+
20
+ /**
21
+ * The settings for the quiz
22
+ *
23
+ * @var array
24
+ * @since 5.0.0
25
+ */
26
+ private $settings;
27
+
28
+ /**
29
+ * The fields that have been registered
30
+ *
31
+ * @var array
32
+ * @since 5.0.0
33
+ */
34
+ private $registered_fields;
35
+
36
+ /**
37
+ * Prepares the settings for the supplied quiz
38
+ *
39
+ * @since 5.0.0
40
+ * @param int $quiz_id the ID of the quiz that we are handling the settings data for
41
+ */
42
+ public function prepare_quiz( $quiz_id ) {
43
+ $this->quiz_id = intval( $quiz_id );
44
+ $this->load_settings();
45
+ }
46
+
47
+
48
+ /**
49
+ * Registers a setting be shown on the Options or Text tab
50
+ *
51
+ * @since 5.0.0
52
+ * @param array $field_array An array of the components for the settings field
53
+ */
54
+ public function register_setting( $field_array, $section = 'quiz_options' ) {
55
+
56
+ /*
57
+ Example field array
58
+ $field_array = array(
59
+ 'id' => 'system',
60
+ 'label' => 'Which system is this quiz graded on?',
61
+ 'type' => 'text',
62
+ 'options' => array(
63
+ array(
64
+ 'label' => '',
65
+ 'value' => ''
66
+ )
67
+ ),
68
+ 'variables' => array(
69
+ ''
70
+ ),
71
+ 'default' => ''
72
+ );
73
+ */
74
+
75
+ // Adds field to registered fields
76
+ $this->registered_fields[ $section ][] = $field_array;
77
+
78
+ }
79
+
80
+ /**
81
+ * Retrieves the registered setting fields
82
+ *
83
+ * @since 5.0.0
84
+ * @param string $section The section whose fields that are being retrieved
85
+ * @return array All the fields registered the the section provided
86
+ */
87
+ public function load_setting_fields( $section = 'quiz_options' ) {
88
+
89
+ // Checks if section exists in registered fields and returns it if it does
90
+ if ( isset( $this->registered_fields[ $section ] ) ) {
91
+ return $this->registered_fields[ $section ];
92
+ } else {
93
+ return false;
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Retrieves a setting value from a section based on name of section and setting
99
+ *
100
+ * @since 5.0.0
101
+ * @param string $section The name of the section the setting is registered in
102
+ * @param string $setting The name of the setting whose value we need to retrieve
103
+ * @param mixed $default What we need to return if no setting exists with given $setting
104
+ * @return $mixed Value set for $setting or $default if setting does not exist
105
+ */
106
+ public function get_section_setting( $section, $setting, $default = false ) {
107
+
108
+ // Return if section or setting is empty
109
+ if ( empty( $section ) || empty( $setting ) ) {
110
+ return $default;
111
+ }
112
+
113
+ // Get settings in section
114
+ $section_settings = $this->get_setting( $section );
115
+
116
+ // Return default if section not found
117
+ if ( ! $section_settings ) {
118
+ return $default;
119
+ }
120
+
121
+ // Maybe unserailize
122
+ $section_settings = maybe_unserialize( $section_settings );
123
+
124
+ // Check if setting exists
125
+ if ( isset( $section_settings[ $setting ] ) ) {
126
+
127
+ // Try to unserialize it and then return it
128
+ return maybe_unserialize( $section_settings[ $setting ] );
129
+ } else {
130
+
131
+ // Return the default if no setting exists
132
+ return $default;
133
+ }
134
+ }
135
+
136
+ /**
137
+ * Retrieves setting value based on name of setting
138
+ *
139
+ * @since 5.0.0
140
+ * @param string $setting The name of the setting whose value we need to retrieve
141
+ * @param mixed $default What we need to return if no setting exists with given $setting
142
+ * @return $mixed Value set for $setting or $default if setting does not exist
143
+ */
144
+ public function get_setting( $setting, $default = false ) {
145
+
146
+ global $mlwQuizMasterNext;
147
+
148
+ // Return if empty
149
+ if ( empty( $setting ) ) {
150
+ return false;
151
+ }
152
+
153
+ // Check if ID is not set, for backwards compatibility
154
+ if ( ! $this->quiz_id ) {
155
+ $quiz_id = $mlwQuizMasterNext->quizCreator->get_id();
156
+
157
+ // If get_id doesn't work, return false
158
+ if ( ! $quiz_id ) {
159
+ return false;
160
+ } else {
161
+ $this->prepare_quiz( $quiz_id );
162
+ }
163
+ }
164
+
165
+ // Check if setting exists
166
+ if ( isset( $this->settings[ $setting ] ) ) {
167
+
168
+ // Try to unserialize it and then return it
169
+ return maybe_unserialize( $this->settings[ $setting ] );
170
+ } else {
171
+
172
+ // Return the default if no setting exists
173
+ return $default;
174
+ }
175
+ }
176
+
177
+ /**
178
+ * Updates a settings value, adding it if it didn't already exist
179
+ *
180
+ * @since 5.0.0
181
+ * @param string $setting The name of the setting whose value we need to retrieve
182
+ * @param mixed $value The value that needs to be stored for the setting
183
+ * @return bool True if successful or false if fails
184
+ */
185
+ public function update_setting( $setting, $value ) {
186
+
187
+ global $mlwQuizMasterNext;
188
+
189
+ // Return if empty
190
+ if ( empty( $setting ) ) {
191
+ return false;
192
+ }
193
+
194
+ // Check if ID is not set, for backwards compatibility
195
+ if ( ! $this->quiz_id ) {
196
+ $quiz_id = $mlwQuizMasterNext->quizCreator->get_id();
197
+
198
+ // If get_id doesn't work, return false
199
+ if ( ! $quiz_id ) {
200
+ return false;
201
+ } else {
202
+ $this->prepare_quiz( $quiz_id );
203
+ }
204
+ }
205
+
206
+ $old_value = $this->get_setting( $setting );
207
+
208
+ // If the old value and new value are the same, return false
209
+ if ( $value === $old_value ) {
210
+ return false;
211
+ }
212
+
213
+ // Try to serialize the value
214
+ $serialized_value = maybe_serialize( $value );
215
+
216
+ // Set the new value
217
+ $this->settings[ $setting ] = $serialized_value;
218
+
219
+ // Update the database
220
+ global $wpdb;
221
+ $serialized_settings = serialize( $this->settings );
222
+ $results = $wpdb->update(
223
+ $wpdb->prefix . "mlw_quizzes",
224
+ array( 'quiz_settings' => $serialized_settings ),
225
+ array( 'quiz_id' => $this->quiz_id ),
226
+ array( '%s' ),
227
+ array( '%d' )
228
+ );
229
+
230
+ if ( ! $results ) {
231
+ return false;
232
+ } else {
233
+ return true;
234
+ }
235
+ }
236
+
237
+ /**
238
+ * Loads the settings for the quiz
239
+ *
240
+ * @since 5.0.0
241
+ */
242
+ private function load_settings() {
243
+
244
+ global $wpdb;
245
+ $settings_array = array();
246
+
247
+ // Loads the settings from the database
248
+ $settings = $wpdb->get_var( $wpdb->prepare( "SELECT quiz_settings FROM {$wpdb->prefix}mlw_quizzes WHERE quiz_id=%d", $this->quiz_id ) );
249
+
250
+ // Unserializes array
251
+ if ( is_serialized( $settings ) && is_array( @unserialize( $settings ) ) ) {
252
+ $settings_array = @unserialize( $settings );
253
+ }
254
+
255
+ // If the value is not an array, create an empty array
256
+ if ( ! is_array( $settings_array ) ) {
257
+ $settings_array = array();
258
+ }
259
+
260
+ // If some options are missing
261
+ if ( ! isset( $settings_array['quiz_options'] ) || ! isset( $settings_array["quiz_text"] ) || ! isset( $settings_array["quiz_leaderboards"] ) ) {
262
+
263
+ // Load the old options system
264
+ $quiz_options = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}mlw_quizzes WHERE quiz_id=%d LIMIT 1", $this->quiz_id ) );
265
+
266
+ // If no leadboard is present
267
+ if ( ! isset( $settings_array["quiz_leaderboards"] ) ) {
268
+
269
+ $settings_array["quiz_leaderboards"] = serialize( array(
270
+ 'template' => $quiz_options->leaderboard_template
271
+ ) );
272
+ }
273
+
274
+ // If no options are present
275
+ if ( ! isset( $settings_array['quiz_options'] ) ) {
276
+
277
+ // Sets up older scheduled timeframe settings
278
+ if ( is_serialized( $quiz_options->scheduled_timeframe) && is_array( @unserialize( $quiz_options->scheduled_timeframe ) ) ) {
279
+ $scheduled_timeframe = @unserialize( $quiz_options->scheduled_timeframe );
280
+ } else {
281
+ $scheduled_timeframe = array(
282
+ 'start' => '',
283
+ 'end' => ''
284
+ );
285
+ }
286
+
287
+ // Prepares new quiz_options section's settings
288
+ $settings_array['quiz_options'] = serialize( array(
289
+ 'system' => $quiz_options->system,
290
+ 'loggedin_user_contact' => $quiz_options->loggedin_user_contact,
291
+ 'contact_info_location' => $quiz_options->contact_info_location,
292
+ 'user_name' => $quiz_options->user_name,
293
+ 'user_comp' => $quiz_options->user_comp,
294
+ 'user_email' => $quiz_options->user_email,
295
+ 'user_phone' => $quiz_options->user_phone,
296
+ 'comment_section' => $quiz_options->comment_section,
297
+ 'randomness_order' => $quiz_options->randomness_order,
298
+ 'question_from_total' => $quiz_options->question_from_total,
299
+ 'total_user_tries' => $quiz_options->total_user_tries,
300
+ 'social_media' => $quiz_options->social_media,
301
+ 'pagination' => $quiz_options->pagination,
302
+ 'timer_limit' => $quiz_options->timer_limit,
303
+ 'question_numbering' => $quiz_options->question_numbering,
304
+ 'require_log_in' => $quiz_options->require_log_in,
305
+ 'limit_total_entries' => $quiz_options->limit_total_entries,
306
+ 'scheduled_time_start'=> $scheduled_timeframe["start"],
307
+ 'scheduled_time_end' => $scheduled_timeframe["end"],
308
+ 'disable_answer_onselect' => $quiz_options->disable_answer_onselect,
309
+ 'ajax_show_correct' => $quiz_options->ajax_show_correct
310
+ ) );
311
+ }
312
+
313
+ // If no text is present
314
+ if ( ! isset( $settings_array["quiz_text"] ) ) {
315
+
316
+ // Sets up older pagination text
317
+ if ( is_serialized( $quiz_options->pagination_text) && is_array( @unserialize( $quiz_options->pagination_text ) ) ) {
318
+ $pagination_text = @unserialize( $quiz_options->pagination_text );
319
+ } else {
320
+ $pagination_text = array(
321
+ __( 'Previous', 'quiz-master-next' ),
322
+ __( 'Next', 'quiz-master-next' )
323
+ );
324
+ }
325
+
326
+ // Sets up older social sharing text
327
+ if ( is_serialized( $quiz_options->social_media_text) && is_array( @unserialize( $quiz_options->social_media_text ) ) ) {
328
+ $social_media_text = @unserialize( $quiz_options->social_media_text );
329
+ } else {
330
+ $social_media_text = array(
331
+ 'twitter' => $quiz_options->social_media_text,
332
+ 'facebook' => $quiz_options->social_media_text
333
+
334
+ );
335
+ }
336
+
337
+ // Prepares new quiz_text section's settings
338
+ $settings_array["quiz_text"] = serialize( array(
339
+ 'message_before' => $quiz_options->message_before,
340
+ 'message_comment' => $quiz_options->message_comment,
341
+ 'message_end_template' => $quiz_options->message_end_template,
342
+ 'comment_field_text' => $quiz_options->comment_field_text,
343
+ 'question_answer_template' => $quiz_options->question_answer_template,
344
+ 'submit_button_text' => $quiz_options->submit_button_text,
345
+ 'name_field_text' => $quiz_options->name_field_text,
346
+ 'business_field_text' => $quiz_options->business_field_text,
347
+ 'email_field_text' => $quiz_options->email_field_text,
348
+ 'phone_field_text' => $quiz_options->phone_field_text,
349
+ 'total_user_tries_text' => $quiz_options->total_user_tries_text,
350
+ 'twitter_sharing_text' => $social_media_text["twitter"],
351
+ 'facebook_sharing_text' => $social_media_text["facebook"],
352
+ 'previous_button_text' => $pagination_text[0],
353
+ 'next_button_text' => $pagination_text[1],
354
+ 'require_log_in_text' => $quiz_options->require_log_in_text,
355
+ 'limit_total_entries_text' => $quiz_options->limit_total_entries_text,
356
+ 'scheduled_timeframe_text' => $quiz_options->scheduled_timeframe_text
357
+ ) );
358
+ }
359
+
360
+ // Update new settings system
361
+ $serialized_array = serialize( $settings_array );
362
+ $results = $wpdb->update(
363
+ $wpdb->prefix . "mlw_quizzes",
364
+ array( 'quiz_settings' => $serialized_array ),
365
+ array( 'quiz_id' => $this->quiz_id ),
366
+ array( '%s' ),
367
+ array( '%d' )
368
+ );
369
+ }
370
+
371
+ // Cycle through registered settings
372
+ $registered_fields = $this->registered_fields;
373
+ foreach ( $registered_fields as $section => $fields ) {
374
+
375
+ // Check if section exists in settings and, if not, set it to empty array
376
+ if ( ! isset( $settings_array[ $section ] ) ) {
377
+ $settings_array[ $section ] = array();
378
+ }
379
+
380
+ $unserialized_section = unserialize( $settings_array[ $section ] );
381
+
382
+ // Cycle through each setting in section
383
+ foreach ( $fields as $field ) {
384
+
385
+ // Check if setting exists in section settings and, if not, set it to the default
386
+ if ( ! isset( $unserialized_section[ $field["id"] ] ) ) {
387
+ $unserialized_section[ $field["id"] ] = $field["default"];
388
+ }
389
+ }
390
+
391
+ $settings_array[ $section ] = serialize( $unserialized_section );
392
+ }
393
+
394
+ $this->settings = $settings_array;
395
+ }
396
+
397
+ /**
398
+ * Loads the old object model of options for backwards compatibility
399
+ *
400
+ * @since 5.0.0
401
+ */
402
+ public function get_quiz_options() {
403
+ global $wpdb;
404
+
405
+ // Load the old options system
406
+ $quiz_options = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}mlw_quizzes WHERE quiz_id=%d LIMIT 1", $this->quiz_id ) );
407
+
408
+ // Merge all settings into old object
409
+ $quiz_override = array_merge( (array) $quiz_options, $this->get_setting( 'quiz_leaderboards' ), $this->get_setting( 'quiz_options' ), $this->get_setting( 'quiz_text' ) );
410
+
411
+ // Return as old object model
412
+ return (object) $quiz_override;
413
+ }
414
+ }
415
+
416
+ ?>
php/help-page.php CHANGED
@@ -14,7 +14,7 @@ function mlw_generate_help_page()
14
  return;
15
  }
16
 
17
- wp_enqueue_style( 'qmn_admin_style', plugins_url( '../css/qmn_admin.css' , __FILE__ ) );
18
 
19
  ///Creates the widgets
20
  add_meta_box("wpss_mrts", __('Need Help?', 'quiz-master-next'), "qmn_documentation_meta_box_content", "meta_box_help");
14
  return;
15
  }
16
 
17
+ wp_enqueue_style( 'qmn_admin_style', plugins_url( '../css/qsm-admin.css' , __FILE__ ) );
18
 
19
  ///Creates the widgets
20
  add_meta_box("wpss_mrts", __('Need Help?', 'quiz-master-next'), "qmn_documentation_meta_box_content", "meta_box_help");
php/leaderboard-shortcode.php CHANGED
@@ -10,8 +10,8 @@ if ( ! defined( 'ABSPATH' ) ) exit;
10
  * @return type $mlw_quiz_leaderboard_display This variable contains all the contents of the leaderboard.
11
  * @since 4.4.0
12
  */
13
- function mlw_quiz_leaderboard_shortcode($atts)
14
- {
15
  extract(shortcode_atts(array(
16
  'mlw_quiz' => 0
17
  ), $atts));
10
  * @return type $mlw_quiz_leaderboard_display This variable contains all the contents of the leaderboard.
11
  * @since 4.4.0
12
  */
13
+ function mlw_quiz_leaderboard_shortcode( $atts ) {
14
+
15
  extract(shortcode_atts(array(
16
  'mlw_quiz' => 0
17
  ), $atts));
php/options-page-certificate-tab.php DELETED
@@ -1,155 +0,0 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit;
3
-
4
- /**
5
- * This function adds the certificate tab using our API.
6
- *
7
- * @return type description
8
- * @since 4.4.0
9
- */
10
- function qmn_settings_certificate_tab()
11
- {
12
- global $mlwQuizMasterNext;
13
- $mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs(__("Certificate (Beta)", 'quiz-master-next'), 'mlw_options_certificate_tab_content');
14
- }
15
- add_action("plugins_loaded", 'qmn_settings_certificate_tab', 5);
16
-
17
- /**
18
- * Creates the content that is in the certificate tab.
19
- *
20
- * @return void
21
- * @since 4.4.0
22
- */
23
- function mlw_options_certificate_tab_content()
24
- {
25
- global $wpdb;
26
- global $mlwQuizMasterNext;
27
- $quiz_id = $_GET["quiz_id"];
28
- //Saved Certificate Options
29
- if (isset($_POST["save_certificate_options"]) && $_POST["save_certificate_options"] == "confirmation")
30
- {
31
- $mlw_certificate_id = intval($_POST["certificate_quiz_id"]);
32
- $mlw_certificate_title = sanitize_text_field( stripslashes( $_POST["certificate_title"] ) );
33
- $mlw_certificate_text = wp_kses_post( stripslashes( $_POST["certificate_template"] ) );
34
- $mlw_certificate_logo = esc_url_raw( $_POST["certificate_logo"] );
35
- $mlw_certificate_background = esc_url_raw( $_POST["certificate_background"] );
36
- $mlw_enable_certificates = intval($_POST["enableCertificates"]);
37
- $mlw_certificate = array(
38
- $mlw_certificate_title,
39
- $mlw_certificate_text,
40
- $mlw_certificate_logo,
41
- $mlw_certificate_background,
42
- $mlw_enable_certificates
43
- );
44
- $mlw_certificate_serialized = serialize($mlw_certificate);
45
-
46
- $update_results = $wpdb->update(
47
- $wpdb->prefix . "mlw_quizzes",
48
- array(
49
- 'certificate_template' => $mlw_certificate_serialized,
50
- 'last_activity' => date("Y-m-d H:i:s")
51
- ),
52
- array( 'quiz_id' => $mlw_certificate_id ),
53
- array(
54
- '%s',
55
- '%s'
56
- ),
57
- array( '%d' )
58
- );
59
-
60
- if ( $update_results ) {
61
-
62
- $mlwQuizMasterNext->alertManager->newAlert(__('The certificate has been updated successfully.', 'quiz-master-next'), 'success');
63
- $mlwQuizMasterNext->audit_manager->new_audit( "Certificate Options Have Been Edited For Quiz Number $mlw_certificate_id" );
64
- } else {
65
- $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0012'), 'error');
66
- $mlwQuizMasterNext->log_manager->add("Error 0012", $wpdb->last_error.' from '.$wpdb->last_query, 0, 'error');
67
- }
68
- }
69
- if (isset($_GET["quiz_id"]))
70
- {
71
- $table_name = $wpdb->prefix . "mlw_quizzes";
72
- $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
73
- }
74
-
75
- //Load Certificate Options Variables
76
- if (is_serialized($mlw_quiz_options->certificate_template) && is_array(@unserialize($mlw_quiz_options->certificate_template)))
77
- {
78
- $mlw_certificate_options = @unserialize($mlw_quiz_options->certificate_template);
79
- }
80
- else
81
- {
82
- $mlw_certificate_options = array(__('Enter title here', 'quiz-master-next'), __('Enter text here', 'quiz-master-next'), '', '', 1);
83
- }
84
-
85
- ?>
86
- <div id="tabs-5" class="mlw_tab_content">
87
- <h3><?php _e('Quiz Certificate (Beta)', 'quiz-master-next'); ?></h3>
88
- <div style="background:#fff;border-left: 4px solid #fff;padding: 1px 12px;margin: 5px 0 15px;border-left-color: #dc3232;">
89
- <p style="font-weight:bold;">Warning: This feature is being removed from the core version. Please use our new free Certificate addon. You can read more about this change in <a href="http://quizandsurveymaster.com/certificate-feature-moved/?utm_source=certificate_removal_notice&utm_medium=plugin&utm_campaign=qsm_plugin" target="_blank">our post about the certificate being moved.</a></p>
90
- </div>
91
- <p><?php _e('Enter in your text here to fill in the certificate for this quiz. Be sure to enter in the link variable into the templates on the Emails and Results Page tabs so the user can access the certificate.', 'quiz-master-next'); ?></p>
92
- <p><?php _e('These fields cannot contain HTML.', 'quiz-master-next'); ?></p>
93
- <button id="save_certificate_button" class="button-primary" onclick="javascript: document.quiz_certificate_options_form.submit();"><?php _e('Save Certificate Options', 'quiz-master-next'); ?></button>
94
- <?php
95
- echo "<form action='' method='post' name='quiz_certificate_options_form'>";
96
- echo "<input type='hidden' name='save_certificate_options' value='confirmation' />";
97
- echo "<input type='hidden' name='certificate_quiz_id' value='".$quiz_id."' />";
98
- ?>
99
- <table class="form-table">
100
- <tr valign="top">
101
- <td><label for="enableCertificates"><?php _e('Enable Certificates For This Quiz?', 'quiz-master-next'); ?></label></td>
102
- <td>
103
- <input type="radio" id="radio30" name="enableCertificates" <?php if ($mlw_certificate_options[4] == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio30"><?php _e('Yes', 'quiz-master-next'); ?></label><br>
104
- <input type="radio" id="radio31" name="enableCertificates" <?php if ($mlw_certificate_options[4] == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio31"><?php _e('No', 'quiz-master-next'); ?></label><br>
105
- </td>
106
- </tr>
107
- <tr>
108
- <td width="30%">
109
- <strong><?php _e('Certificate Title', 'quiz-master-next'); ?></strong>
110
- </td>
111
- <td><textarea cols="80" rows="15" id="certificate_title" name="certificate_title"><?php echo $mlw_certificate_options[0]; ?></textarea>
112
- </td>
113
- </tr>
114
- <tr>
115
- <td width="30%">
116
- <strong><?php _e('Message Displayed On Certificate', 'quiz-master-next'); ?></strong>
117
- <br />
118
- <p><?php _e('Allowed Variables:', 'quiz-master-next'); ?></p>
119
- <p style="margin: 2px 0">- %POINT_SCORE%</p>
120
- <p style="margin: 2px 0">- %AVERAGE_POINT%</p>
121
- <p style="margin: 2px 0">- %AMOUNT_CORRECT%</p>
122
- <p style="margin: 2px 0">- %TOTAL_QUESTIONS%</p>
123
- <p style="margin: 2px 0">- %CORRECT_SCORE%</p>
124
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
125
- <p style="margin: 2px 0">- %USER_NAME%</p>
126
- <p style="margin: 2px 0">- %USER_BUSINESS%</p>
127
- <p style="margin: 2px 0">- %USER_PHONE%</p>
128
- <p style="margin: 2px 0">- %USER_EMAIL%</p>
129
- <p style="margin: 2px 0">- %CURRENT_DATE%</p>
130
- <p style="margin: 2px 0">- %DATE_TAKEN%</p>
131
- </td>
132
- <td><label for="certificate_template">Allowed tags: &lt;b&gt; - bold, &lt;i&gt;-italics, &lt;u&gt;-underline, &lt;br&gt;-New Line or start a new line by pressing enter</label><textarea cols="80" rows="15" id="certificate_template" name="certificate_template"><?php echo $mlw_certificate_options[1]; ?></textarea>
133
- </td>
134
- </tr>
135
- <tr>
136
- <td width="30%">
137
- <strong><?php _e('URL To Logo (Must be JPG, JPEG, PNG or GIF)', 'quiz-master-next'); ?></strong>
138
- </td>
139
- <td><textarea cols="80" rows="15" id="certificate_logo" name="certificate_logo"><?php echo $mlw_certificate_options[2]; ?></textarea>
140
- </td>
141
- </tr>
142
- <tr>
143
- <td width="30%">
144
- <strong><?php _e('URL To Background Img (Must be JPG, JPEG, PNG or GIF)', 'quiz-master-next'); ?></strong>
145
- </td>
146
- <td><textarea cols="80" rows="15" id="certificate_background" name="certificate_background"><?php echo $mlw_certificate_options[3]; ?></textarea>
147
- </td>
148
- </tr>
149
- </table>
150
- <button id="save_certificate_button" class="button-primary" onclick="javascript: document.quiz_certificate_options_form.submit();"><?php _e('Save Certificate Options', 'quiz-master-next'); ?></button>
151
- </form>
152
- </div>
153
- <?php
154
- }
155
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
php/options-page-contact-tab.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Exit if accessed directly
4
+ if ( ! defined( 'ABSPATH' ) ) exit;
5
+
6
+ /**
7
+ * This function adds the contact tab using our API.
8
+ *
9
+ * @return type description
10
+ * @since 4.7.0
11
+ */
12
+ function qsm_settings_contact_tab() {
13
+ global $mlwQuizMasterNext;
14
+ $mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs( __( "Contact", 'quiz-master-next' ), 'qsm_options_contact_tab_content' );
15
+ }
16
+ add_action("plugins_loaded", 'qsm_settings_contact_tab', 5);
17
+
18
+ /**
19
+ * Adds the content for the options for contact tab.
20
+ *
21
+ * @return void
22
+ * @since 4.7.0
23
+ */
24
+ function qsm_options_contact_tab_content() {
25
+ global $wpdb;
26
+ global $mlwQuizMasterNext;
27
+ $quiz_id = intval( $_GET["quiz_id"] );
28
+
29
+ $contact_form = QSM_Contact_Manager::load_fields();
30
+
31
+ wp_enqueue_script( 'qsm_contact_admin_script', plugins_url( '../js/qsm-admin-contact.js' , __FILE__ ), array( 'jquery-ui-sortable' ) );
32
+ wp_localize_script( 'qsm_contact_admin_script', 'qsmContactObject', array( 'contactForm' => $contact_form, 'quizID' => $quiz_id ) );
33
+ wp_enqueue_style( 'qsm_contact_admin_style', plugins_url( '../css/qsm-admin-contact.css' , __FILE__ ) );
34
+
35
+ /**
36
+ * Example contact form array
37
+ * array(
38
+ * array(
39
+ * 'label' => 'Name',
40
+ * 'type' => 'text',
41
+ * 'answers' => array(
42
+ * 'one',
43
+ * 'two'
44
+ * ),
45
+ * 'required' => true
46
+ * )
47
+ * )
48
+ */
49
+
50
+ ?>
51
+ <h2>Contact</h2>
52
+ <div class="contact-message"></div>
53
+ <a class="save-contact button-primary">Save Contact Form</a>
54
+ <div class="contact-form"></div>
55
+ <a class="add-contact-field button-primary">Add New Field</a>
56
+ <?php
57
+ }
58
+
59
+ add_action( 'wp_ajax_qsm_save_contact', 'qsm_contact_form_admin_ajax' );
60
+ add_action( 'wp_ajax_nopriv_qsm_save_contact', 'qsm_contact_form_admin_ajax' );
61
+
62
+ /**
63
+ * Saves the contact form from the quiz settings tab
64
+ *
65
+ * @since 0.1.0
66
+ * @return void
67
+ */
68
+ function qsm_contact_form_admin_ajax() {
69
+ global $wpdb;
70
+ global $mlwQuizMasterNext;
71
+ $results["status"] = QSM_Contact_Manager::save_fields( $_POST["quiz_id"], $_POST["contact_form"] );
72
+ echo json_encode( $results );
73
+ die();
74
+ }
75
+
76
+ ?>
php/options-page-email-tab.php CHANGED
@@ -236,7 +236,7 @@ function mlw_options_emails_tab_content()
236
  "subject" => 'Quiz Results For %QUIZ_NAME%'
237
  ));
238
  }
239
- wp_enqueue_style( 'qmn_admin_style', plugins_url( '../css/qmn_admin.css' , __FILE__ ) );
240
  ?>
241
  <script type="text/javascript">
242
  var $j = jQuery.noConflict();
@@ -271,6 +271,12 @@ function mlw_options_emails_tab_content()
271
  </script>
272
  <h3 style="text-align: center;"><?php _e('Template Variables', 'quiz-master-next'); ?></h3>
273
  <div class="template_list_holder">
 
 
 
 
 
 
274
  <div class="template_variable">
275
  <span class="template_name">%POINT_SCORE%</span> - <?php _e('Score for the quiz when using points', 'quiz-master-next'); ?>
276
  </div>
@@ -313,9 +319,6 @@ function mlw_options_emails_tab_content()
313
  <div class="template_variable">
314
  <span class="template_name">%TIMER_MINUTES%</span> - <?php _e('The amount of time user spent on quiz in minutes', 'quiz-master-next'); ?>
315
  </div>
316
- <div class="template_variable">
317
- <span class="template_name">%CERTIFICATE_LINK%</span> - <?php _e('The link to the certificate after completing the quiz', 'quiz-master-next'); ?>
318
- </div>
319
  <div class="template_variable">
320
  <span class="template_name">%CATEGORY_POINTS%%/CATEGORY_POINTS%</span> - <?php _e('The amount of points a specific category earned.', 'quiz-master-next'); ?>
321
  </div>
236
  "subject" => 'Quiz Results For %QUIZ_NAME%'
237
  ));
238
  }
239
+ wp_enqueue_style( 'qmn_admin_style', plugins_url( '../css/qsm-admin.css' , __FILE__ ) );
240
  ?>
241
  <script type="text/javascript">
242
  var $j = jQuery.noConflict();
271
  </script>
272
  <h3 style="text-align: center;"><?php _e('Template Variables', 'quiz-master-next'); ?></h3>
273
  <div class="template_list_holder">
274
+ <div class="template_variable">
275
+ <span class="template_name">%CONTACT_X%</span> - <?php _e( 'Value user entered into contact field. X is # of contact field. For example, first contact field would be %CONTACT_1%', 'quiz-master-next' ); ?>
276
+ </div>
277
+ <div class="template_variable">
278
+ <span class="template_name">%CONTACT_ALL%</span> - <?php _e( 'List user values for all contact fields', 'quiz-master-next' ); ?>
279
+ </div>
280
  <div class="template_variable">
281
  <span class="template_name">%POINT_SCORE%</span> - <?php _e('Score for the quiz when using points', 'quiz-master-next'); ?>
282
  </div>
319
  <div class="template_variable">
320
  <span class="template_name">%TIMER_MINUTES%</span> - <?php _e('The amount of time user spent on quiz in minutes', 'quiz-master-next'); ?>
321
  </div>
 
 
 
322
  <div class="template_variable">
323
  <span class="template_name">%CATEGORY_POINTS%%/CATEGORY_POINTS%</span> - <?php _e('The amount of points a specific category earned.', 'quiz-master-next'); ?>
324
  </div>
php/options-page-leaderboard-tab.php CHANGED
@@ -7,12 +7,11 @@ if ( ! defined( 'ABSPATH' ) ) exit;
7
  * @return void
8
  * @since 4.4.0
9
  */
10
- function qmn_settings_leaderboard_tab()
11
- {
12
  global $mlwQuizMasterNext;
13
- $mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs(__("Leaderboard", 'quiz-master-next'), 'mlw_options_leaderboard_tab_content');
14
  }
15
- add_action("plugins_loaded", 'qmn_settings_leaderboard_tab', 5);
16
 
17
 
18
  /**
@@ -21,108 +20,42 @@ add_action("plugins_loaded", 'qmn_settings_leaderboard_tab', 5);
21
  * @return void
22
  * @since 4.4.0
23
  */
24
- function mlw_options_leaderboard_tab_content()
25
- {
26
  global $wpdb;
27
  global $mlwQuizMasterNext;
28
- $quiz_id = intval( $_GET["quiz_id"] );
29
- ///Submit saved leaderboard template into database
30
- if ( isset($_POST["save_leaderboard_options"]) && $_POST["save_leaderboard_options"] == "confirmation")
31
- {
32
- ///Variables for save leaderboard options form
33
- $mlw_leaderboard_template = wp_kses_post( $_POST["mlw_quiz_leaderboard_template"] );
34
- $mlw_leaderboard_quiz_id = intval( $_POST["leaderboard_quiz_id"] );
35
- $results = $wpdb->update(
36
- $wpdb->prefix . "mlw_quizzes",
37
- array(
38
- 'leaderboard_template' => $mlw_leaderboard_template,
39
- 'last_activity' => date("Y-m-d H:i:s")
40
- ),
41
- array( 'quiz_id' => $mlw_leaderboard_quiz_id ),
42
- array(
43
- '%s',
44
- '%s'
45
- ),
46
- array( '%d' )
47
- );
48
- if ( $results ) {
49
- $mlwQuizMasterNext->alertManager->newAlert(__('The leaderboards has been updated successfully.', 'quiz-master-next'), 'success');
50
- $mlwQuizMasterNext->audit_manager->new_audit( "Leaderboard Options Have Been Edited For Quiz Number $mlw_leaderboard_quiz_id" );
51
- } else {
52
- $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0009'), 'error');
53
- $mlwQuizMasterNext->log_manager->add("Error 0009", $wpdb->last_error.' from '.$wpdb->last_query, 0, 'error');
54
- }
55
- }
56
-
57
- if (isset($_GET["quiz_id"]))
58
- {
59
- $table_name = $wpdb->prefix . "mlw_quizzes";
60
- $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
61
- }
62
  ?>
63
- <div id="tabs-4" class="mlw_tab_content">
64
- <h3><?php _e('Template Variables', 'quiz-master-next'); ?></h3>
65
- <table class="form-table">
66
- <tr>
67
- <td><strong>%FIRST_PLACE_NAME%</strong> - <?php _e("The name of the user who is in first place", 'quiz-master-next'); ?></td>
68
- <td><strong>%FIRST_PLACE_SCORE%</strong> - <?php _e("The score from the first place's quiz", 'quiz-master-next'); ?></td>
69
- </tr>
70
-
71
- <tr>
72
- <td><strong>%SECOND_PLACE_NAME%</strong> - <?php _e("The name of the user who is in second place", 'quiz-master-next'); ?></td>
73
- <td><strong>%SECOND_PLACE_SCORE%</strong> - <?php _e("The score from the second place's quiz", 'quiz-master-next'); ?></td>
74
- </tr>
75
-
76
- <tr>
77
- <td><strong>%THIRD_PLACE_NAME%</strong> - <?php _e('The name of the user who is in third place', 'quiz-master-next'); ?></td>
78
- <td><strong>%THIRD_PLACE_SCORE%</strong> - <?php _e("The score from the third place's quiz", 'quiz-master-next'); ?></td>
79
- </tr>
80
-
81
- <tr>
82
- <td><strong>%FOURTH_PLACE_NAME%</strong> - <?php _e('The name of the user who is in fourth place', 'quiz-master-next'); ?></td>
83
- <td><strong>%FOURTH_PLACE_SCORE%</strong> - <?php _e("The score from the fourth place's quiz", 'quiz-master-next'); ?></td>
84
- </tr>
85
-
86
- <tr>
87
- <td><strong>%FIFTH_PLACE_NAME%</strong> - <?php _e('The name of the user who is in fifth place', 'quiz-master-next'); ?></td>
88
- <td><strong>%FIFTH_PLACE_SCORE%</strong> - <?php _e("The score from the fifth place's quiz", 'quiz-master-next'); ?></td>
89
- </tr>
90
-
91
- <tr>
92
- <td><strong>%QUIZ_NAME%</strong> - <?php _e("The name of the quiz", 'quiz-master-next'); ?></td>
93
- </tr>
94
- </table>
95
- <button id="save_template_button" class="button-primary" onclick="javascript: document.quiz_leaderboard_options_form.submit();"><?php _e("Save Leaderboard Options", 'quiz-master-next'); ?></button>
96
- <?php
97
- echo "<form action='' method='post' name='quiz_leaderboard_options_form'>";
98
- echo "<input type='hidden' name='save_leaderboard_options' value='confirmation' />";
99
- echo "<input type='hidden' name='leaderboard_quiz_id' value='".$quiz_id."' />";
100
- ?>
101
- <table class="form-table">
102
- <tr>
103
- <td width="30%">
104
- <strong><?php _e("Leaderboard Template", 'quiz-master-next'); ?></strong>
105
- <br />
106
- <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
107
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
108
- <p style="margin: 2px 0">- %FIRST_PLACE_NAME%</p>
109
- <p style="margin: 2px 0">- %FIRST_PLACE_SCORE%</p>
110
- <p style="margin: 2px 0">- %SECOND_PLACE_NAME%</p>
111
- <p style="margin: 2px 0">- %SECOND_PLACE_SCORE%</p>
112
- <p style="margin: 2px 0">- %THIRD_PLACE_NAME%</p>
113
- <p style="margin: 2px 0">- %THIRD_PLACE_SCORE%</p>
114
- <p style="margin: 2px 0">- %FOURTH_PLACE_NAME%</p>
115
- <p style="margin: 2px 0">- %FOURTH_PLACE_SCORE%</p>
116
- <p style="margin: 2px 0">- %FIFTH_PLACE_NAME%</p>
117
- <p style="margin: 2px 0">- %FIFTH_PLACE_SCORE%</p>
118
- </td>
119
- <td><textarea cols="80" rows="15" id="mlw_quiz_leaderboard_template" name="mlw_quiz_leaderboard_template"><?php echo $mlw_quiz_options->leaderboard_template; ?></textarea>
120
- </td>
121
- </tr>
122
- </table>
123
- <button id="save_template_button" class="button-primary" onclick="javascript: document.quiz_leaderboard_options_form.submit();"><?php _e("Save Leaderboard Options", 'quiz-master-next'); ?></button>
124
- </form>
125
- </div>
126
  <?php
 
127
  }
128
  ?>
7
  * @return void
8
  * @since 4.4.0
9
  */
10
+ function qmn_settings_leaderboard_tab() {
 
11
  global $mlwQuizMasterNext;
12
+ $mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs( __( "Leaderboard", 'quiz-master-next' ), 'qsm_options_leaderboard_tab_content' );
13
  }
14
+ add_action( "plugins_loaded", 'qmn_settings_leaderboard_tab', 5 );
15
 
16
 
17
  /**
20
  * @return void
21
  * @since 4.4.0
22
  */
23
+ function qsm_options_leaderboard_tab_content() {
 
24
  global $wpdb;
25
  global $mlwQuizMasterNext;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  ?>
27
+ <h3><?php _e( 'Template Variables', 'quiz-master-next' ); ?></h3>
28
+ <table class="form-table">
29
+ <tr>
30
+ <td><strong>%FIRST_PLACE_NAME%</strong> - <?php _e("The name of the user who is in first place", 'quiz-master-next'); ?></td>
31
+ <td><strong>%FIRST_PLACE_SCORE%</strong> - <?php _e("The score from the first place's quiz", 'quiz-master-next'); ?></td>
32
+ </tr>
33
+
34
+ <tr>
35
+ <td><strong>%SECOND_PLACE_NAME%</strong> - <?php _e("The name of the user who is in second place", 'quiz-master-next'); ?></td>
36
+ <td><strong>%SECOND_PLACE_SCORE%</strong> - <?php _e("The score from the second place's quiz", 'quiz-master-next'); ?></td>
37
+ </tr>
38
+
39
+ <tr>
40
+ <td><strong>%THIRD_PLACE_NAME%</strong> - <?php _e('The name of the user who is in third place', 'quiz-master-next'); ?></td>
41
+ <td><strong>%THIRD_PLACE_SCORE%</strong> - <?php _e("The score from the third place's quiz", 'quiz-master-next'); ?></td>
42
+ </tr>
43
+
44
+ <tr>
45
+ <td><strong>%FOURTH_PLACE_NAME%</strong> - <?php _e('The name of the user who is in fourth place', 'quiz-master-next'); ?></td>
46
+ <td><strong>%FOURTH_PLACE_SCORE%</strong> - <?php _e("The score from the fourth place's quiz", 'quiz-master-next'); ?></td>
47
+ </tr>
48
+
49
+ <tr>
50
+ <td><strong>%FIFTH_PLACE_NAME%</strong> - <?php _e('The name of the user who is in fifth place', 'quiz-master-next'); ?></td>
51
+ <td><strong>%FIFTH_PLACE_SCORE%</strong> - <?php _e("The score from the fifth place's quiz", 'quiz-master-next'); ?></td>
52
+ </tr>
53
+
54
+ <tr>
55
+ <td><strong>%QUIZ_NAME%</strong> - <?php _e("The name of the quiz", 'quiz-master-next'); ?></td>
56
+ </tr>
57
+ </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  <?php
59
+ $mlwQuizMasterNext->pluginHelper->generate_settings_section( 'quiz_leaderboards' );
60
  }
61
  ?>
php/options-page-option-tab.php CHANGED
@@ -7,12 +7,11 @@ if ( ! defined( 'ABSPATH' ) ) exit;
7
  * @return void
8
  * @since 4.4.0
9
  */
10
- function qmn_settings_options_tab()
11
- {
12
  global $mlwQuizMasterNext;
13
- $mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs(__("Options", 'quiz-master-next'), 'mlw_options_option_tab_content');
14
  }
15
- add_action("plugins_loaded", 'qmn_settings_options_tab', 5);
16
 
17
  /**
18
  * Adds the options content to the Quiz Settings page.
@@ -20,279 +19,10 @@ add_action("plugins_loaded", 'qmn_settings_options_tab', 5);
20
  * @return void
21
  * @since 4.4.0
22
  */
23
- function mlw_options_option_tab_content()
24
- {
25
  global $wpdb;
26
  global $mlwQuizMasterNext;
27
- $quiz_id = $_GET["quiz_id"];
28
- //Submit saved options into database
29
- if ( isset($_POST["save_options"]) && $_POST["save_options"] == "confirmation")
30
- {
31
- //Variables for save options form
32
- $mlw_system = intval($_POST["system"]);
33
- $mlw_qmn_pagination = intval($_POST["pagination"]);
34
- $mlw_qmn_social_media = intval($_POST["social_media"]);
35
- $mlw_qmn_question_numbering = intval($_POST["question_numbering"]);
36
- $mlw_qmn_timer = intval($_POST["timer_limit"]);
37
- $mlw_qmn_questions_from_total = intval($_POST["question_from_total"]);
38
- $mlw_randomness_order = intval($_POST["randomness_order"]);
39
- $mlw_total_user_tries = intval($_POST["total_user_tries"]);
40
- $mlw_require_log_in = intval($_POST["require_log_in"]);
41
- $mlw_limit_total_entries = intval($_POST["limit_total_entries"]);
42
- $mlw_contact_location = intval($_POST["contact_info_location"]);
43
- $mlw_user_name = intval($_POST["userName"]);
44
- $mlw_user_comp = intval($_POST["userComp"]);
45
- $mlw_user_email = intval($_POST["userEmail"]);
46
- $mlw_user_phone = intval($_POST["userPhone"]);
47
- $disable_answer_onselect = intval($_POST["disable_answer_onselect"]);
48
- $ajax_show_correct = intval($_POST["ajax_show_correct"]);
49
- $mlw_comment_section = intval($_POST["commentSection"]);
50
- $mlw_qmn_loggedin_contact = intval($_POST["loggedin_user_contact"]);
51
- $qmn_scheduled_timeframe = serialize( array(
52
- 'start' => sanitize_text_field( $_POST["scheduled_time_start"] ),
53
- 'end' => sanitize_text_field( $_POST["scheduled_time_end"] )
54
- ));
55
- $quiz_id = intval( $_POST["quiz_id"] );
56
-
57
- $results = $wpdb->update(
58
- $wpdb->prefix . "mlw_quizzes",
59
- array(
60
- 'system' => $mlw_system,
61
- 'loggedin_user_contact' => $mlw_qmn_loggedin_contact,
62
- 'contact_info_location' => $mlw_contact_location,
63
- 'user_name' => $mlw_user_name,
64
- 'user_comp' => $mlw_user_comp,
65
- 'user_email' => $mlw_user_email,
66
- 'user_phone' => $mlw_user_phone,
67
- 'comment_section' => $mlw_comment_section,
68
- 'randomness_order' => $mlw_randomness_order,
69
- 'question_from_total' => $mlw_qmn_questions_from_total,
70
- 'total_user_tries' => $mlw_total_user_tries,
71
- 'social_media' => $mlw_qmn_social_media,
72
- 'pagination' => $mlw_qmn_pagination,
73
- 'timer_limit' => $mlw_qmn_timer,
74
- 'question_numbering' => $mlw_qmn_question_numbering,
75
- 'require_log_in' => $mlw_require_log_in,
76
- 'limit_total_entries' => $mlw_limit_total_entries,
77
- 'last_activity' => date("Y-m-d H:i:s"),
78
- 'scheduled_timeframe' => $qmn_scheduled_timeframe,
79
- 'disable_answer_onselect' => $disable_answer_onselect,
80
- 'ajax_show_correct' => $ajax_show_correct
81
- ),
82
- array( 'quiz_id' => $quiz_id ),
83
- array(
84
- '%d',
85
- '%d',
86
- '%d',
87
- '%d',
88
- '%d',
89
- '%d',
90
- '%d',
91
- '%d',
92
- '%d',
93
- '%d',
94
- '%d',
95
- '%d',
96
- '%d',
97
- '%d',
98
- '%d',
99
- '%d',
100
- '%d',
101
- '%s',
102
- '%s',
103
- '%d',
104
- '%d'
105
- ),
106
- array( '%d' )
107
- );
108
- if ( false != $results ) {
109
- $mlwQuizMasterNext->alertManager->newAlert(__('The options has been updated successfully.', 'quiz-master-next'), 'success');
110
- $mlwQuizMasterNext->audit_manager->new_audit( "Options Have Been Edited For Quiz Number $quiz_id" );
111
- } else {
112
- $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0008'), 'error');
113
- $mlwQuizMasterNext->log_manager->add("Error 0008", $wpdb->last_error.' from '.$wpdb->last_query, 0, 'error');
114
- }
115
- }
116
-
117
- if (isset($_GET["quiz_id"]))
118
- {
119
- $table_name = $wpdb->prefix . "mlw_quizzes";
120
- $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
121
- }
122
-
123
- //Load Scheduled Timeframe
124
- $qmn_scheduled_timeframe = "";
125
- if (is_serialized($mlw_quiz_options->scheduled_timeframe) && is_array(@unserialize($mlw_quiz_options->scheduled_timeframe)))
126
- {
127
- $qmn_scheduled_timeframe = @unserialize($mlw_quiz_options->scheduled_timeframe);
128
- }
129
- else
130
- {
131
- $qmn_scheduled_timeframe = array("start" => '', "end" => '');
132
- }
133
- ?>
134
- <div id="tabs-3" class="mlw_tab_content">
135
- <script>
136
- jQuery(function() {
137
- //jQuery( "#system, #require_log_in, #randomness_order, #loggedin_user_contact, #sendUserEmail, #sendAdminEmail, #contact_info_location, #userName, #userComp, #userEmail, #userPhone, #pagination, #commentSection, #social_media, #question_numbering, #comments" ).buttonset();
138
- jQuery( "#scheduled_time_start, #scheduled_time_end" ).datepicker();
139
- });
140
- </script>
141
- <button id="save_options_button" class="button-primary" onclick="javascript: document.quiz_options_form.submit();"><?php _e('Save Options', 'quiz-master-next'); ?></button>
142
- <?php
143
- echo "<form action='' method='post' name='quiz_options_form'>";
144
- echo "<input type='hidden' name='save_options' value='confirmation' />";
145
- echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
146
- ?>
147
- <table class="form-table" style="width: 100%;">
148
- <tr valign="top">
149
- <th scope="row"><label for="system"><?php _e('Which system is this quiz graded on?', 'quiz-master-next'); ?></label></th>
150
- <td>
151
- <input type="radio" id="radio1" name="system" <?php if ($mlw_quiz_options->system == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio1"><?php _e('Correct/Incorrect', 'quiz-master-next'); ?></label><br>
152
- <input type="radio" id="radio2" name="system" <?php if ($mlw_quiz_options->system == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio2"><?php _e('Points', 'quiz-master-next'); ?></label><br>
153
- <input type="radio" id="radio3" name="system" <?php if ($mlw_quiz_options->system == 2) {echo 'checked="checked"';} ?> value='2' /><label for="radio3"><?php _e('Not Graded', 'quiz-master-next'); ?></label><br>
154
- </td>
155
- </tr>
156
- <tr valign="top">
157
- <th scope="row"><label for="require_log_in"><?php _e('Should the user be required to be logged in to take this quiz?', 'quiz-master-next'); ?></label></th>
158
- <td>
159
- <input type="radio" id="radio_login_1" name="require_log_in" <?php if ($mlw_quiz_options->require_log_in == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio_login_1"><?php _e('Yes', 'quiz-master-next'); ?></label><br>
160
- <input type="radio" id="radio_login_2" name="require_log_in" <?php if ($mlw_quiz_options->require_log_in == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio_login_2"><?php _e('No', 'quiz-master-next'); ?></label><br>
161
- </td>
162
- </tr>
163
- <tr valign="top">
164
- <th scope="row"><label for="pagination"><?php _e('How many questions per page would you like? (Leave 0 for all questions on one page)', 'quiz-master-next'); ?></label></th>
165
- <td>
166
- <input type="number" step="1" min="0" max="1000" name="pagination" value="<?php echo $mlw_quiz_options->pagination; ?>" class="regular-text" />
167
- </td>
168
- </tr>
169
- <tr valign="top">
170
- <th scope="row"><label for="timer_limit"><?php _e('How many minutes does the user have to finish the quiz? (Leave 0 for no time limit)', 'quiz-master-next'); ?></label></th>
171
- <td>
172
- <input name="timer_limit" type="number" step="1" min="0" id="timer_limit" value="<?php echo $mlw_quiz_options->timer_limit; ?>" class="regular-text" />
173
- </td>
174
- </tr>
175
- <tr valign="top">
176
- <th scope="row"><label for="total_user_tries"><?php _e('How many times can a user take this quiz? (Leave 0 for as many times as the user wants to. Currently only works for registered users)', 'quiz-master-next'); ?></label></th>
177
- <td>
178
- <input name="total_user_tries" type="number" step="1" min="0" id="total_user_tries" value="<?php echo $mlw_quiz_options->total_user_tries; ?>" class="regular-text" />
179
- </td>
180
- </tr>
181
- <tr valign="top">
182
- <th scope="row"><label for="limit_total_entries"><?php _e('How many total entries can this quiz have? (Leave 0 for unlimited entries', 'quiz-master-next'); ?>)</label></th>
183
- <td>
184
- <input name="limit_total_entries" type="number" step="1" min="0" id="limit_total_entries" value="<?php echo $mlw_quiz_options->limit_total_entries; ?>" class="regular-text" />
185
- </td>
186
- </tr>
187
- <tr valign="top">
188
- <th scope="row"><label for="question_from_total"><?php _e('How many questions should be loaded for quiz? (Leave 0 to load all questions)', 'quiz-master-next'); ?></label></th>
189
- <td>
190
- <input name="question_from_total" type="number" step="1" min="0" id="question_from_total" value="<?php echo $mlw_quiz_options->question_from_total; ?>" class="regular-text" />
191
- </td>
192
- </tr>
193
- <tr valign="top">
194
- <th scope="row"><label for="scheduled_time_start"><?php _e('What time-frame should the user be able to access the quiz? (Leave blank if the user can access anytime)', 'quiz-master-next'); ?></label></th>
195
- <td>
196
- <input name="scheduled_time_start" placeholder="<?php _e('start date', 'quiz-master-next'); ?>" type="text" id="scheduled_time_start" value="<?php echo $qmn_scheduled_timeframe["start"] ?>" class="regular-text" />
197
- </td>
198
- <td>
199
- <input name="scheduled_time_end" type="text" placeholder="<?php _e('end date', 'quiz-master-next'); ?>" id="scheduled_time_end" value="<?php echo $qmn_scheduled_timeframe["end"] ?>" class="regular-text" />
200
- </td>
201
- </tr>
202
- <tr valign="top">
203
- <th scope="row"><label for="randomness_order"><?php _e('Are the questions random? (Question Order will not apply if this is yes)', 'quiz-master-next'); ?></label></th>
204
- <td>
205
- <input type="radio" id="radio24" name="randomness_order" <?php if ($mlw_quiz_options->randomness_order == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio24"><?php _e('Random Questions', 'quiz-master-next'); ?></label><br>
206
- <input type="radio" id="randomness2" name="randomness_order" <?php if ($mlw_quiz_options->randomness_order == 2) {echo 'checked="checked"';} ?> value='2' /><label for="randomness2"><?php _e('Random Questions And Answers', 'quiz-master-next'); ?></label><br>
207
- <input type="radio" id="randomness3" name="randomness_order" <?php checked( $mlw_quiz_options->randomness_order, 3 ); ?>value='3'><label for="randomness3"><?php _e('Random Answers', 'quiz-master-next'); ?></label><br>
208
- <input type="radio" id="radio23" name="randomness_order" <?php if ($mlw_quiz_options->randomness_order == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio23"><?php _e('No', 'quiz-master-next'); ?></label><br>
209
- </td>
210
- </tr>
211
- <tr valign="top">
212
- <th scope="row"><label for="contact_info_location"><?php _e('Would you like to ask for the contact information at the beginning or at the end of the quiz?', 'quiz-master-next'); ?></label></th>
213
- <td>
214
- <input type="radio" id="radio25" name="contact_info_location" <?php if ($mlw_quiz_options->contact_info_location == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio25"><?php _e('Beginning', 'quiz-master-next'); ?></label><br>
215
- <input type="radio" id="radio26" name="contact_info_location" <?php if ($mlw_quiz_options->contact_info_location == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio26"><?php _e('End', 'quiz-master-next'); ?></label><br>
216
- </td>
217
- </tr>
218
- <tr valign="top">
219
- <th scope="row"><label for="loggedin_user_contact"><?php _e('If a logged-in user takes the quiz, would you like them to be able to edit contact information? If set to no, the fields will not show up for logged in users; however, the users information will be saved for the fields.', 'quiz-master-next'); ?></label></th>
220
- <td>
221
- <input type="radio" id="radio27" name="loggedin_user_contact" <?php if ($mlw_quiz_options->loggedin_user_contact == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio27"><?php _e('Yes', 'quiz-master-next'); ?></label><br>
222
- <input type="radio" id="radio28" name="loggedin_user_contact" <?php if ($mlw_quiz_options->loggedin_user_contact == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio28"><?php _e('No', 'quiz-master-next'); ?></label><br>
223
- </td>
224
- </tr>
225
- <tr valign="top">
226
- <th scope="row"><label for="userName"><?php _e('Should we ask for users name?', 'quiz-master-next'); ?></label></th>
227
- <td>
228
- <input type="radio" id="radio7" name="userName" <?php if ($mlw_quiz_options->user_name == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio7"><?php _e('Yes', 'quiz-master-next'); ?></label><br>
229
- <input type="radio" id="radio8" name="userName" <?php if ($mlw_quiz_options->user_name == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio8"><?php _e('Require', 'quiz-master-next'); ?></label><br>
230
- <input type="radio" id="radio9" name="userName" <?php if ($mlw_quiz_options->user_name == 2) {echo 'checked="checked"';} ?> value='2' /><label for="radio9"><?php _e('No', 'quiz-master-next'); ?></label><br>
231
- </td>
232
- </tr>
233
- <tr valign="top">
234
- <th scope="row"><label for="userComp"><?php _e('Should we ask for users business?', 'quiz-master-next'); ?></label></th>
235
- <td>
236
- <input type="radio" id="radio10" name="userComp" <?php if ($mlw_quiz_options->user_comp == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio10"><?php _e('Yes', 'quiz-master-next'); ?></label><br>
237
- <input type="radio" id="radio11" name="userComp" <?php if ($mlw_quiz_options->user_comp == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio11"><?php _e('Require', 'quiz-master-next'); ?></label><br>
238
- <input type="radio" id="radio12" name="userComp" <?php if ($mlw_quiz_options->user_comp == 2) {echo 'checked="checked"';} ?> value='2' /><label for="radio12"><?php _e('No', 'quiz-master-next'); ?></label><br>
239
- </td>
240
- </tr>
241
- <tr valign="top">
242
- <th scope="row"><label for="userEmail"><?php _e('Should we ask for users email?', 'quiz-master-next'); ?></label></th>
243
- <td>
244
- <input type="radio" id="radio13" name="userEmail" <?php if ($mlw_quiz_options->user_email == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio13"><?php _e('Yes', 'quiz-master-next'); ?></label><br>
245
- <input type="radio" id="radio14" name="userEmail" <?php if ($mlw_quiz_options->user_email == 1) {echo 'checked="checked"';} ?> value='1'/><label for="radio14"><?php _e('Require', 'quiz-master-next'); ?></label><br>
246
- <input type="radio" id="radio15" name="userEmail" <?php if ($mlw_quiz_options->user_email == 2) {echo 'checked="checked"';} ?> value='2' /><label for="radio15"><?php _e('No', 'quiz-master-next'); ?></label><br>
247
- </td>
248
- </tr>
249
- <tr valign="top">
250
- <th scope="row"><label for="userPhone"><?php _e('Should we ask for users phone number?', 'quiz-master-next'); ?></label></th>
251
- <td>
252
- <input type="radio" id="radio16" name="userPhone" <?php if ($mlw_quiz_options->user_phone == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio16"><?php _e('Yes', 'quiz-master-next'); ?></label><br>
253
- <input type="radio" id="radio17" name="userPhone" <?php if ($mlw_quiz_options->user_phone == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio17"><?php _e('Require', 'quiz-master-next'); ?></label><br>
254
- <input type="radio" id="radio18" name="userPhone" <?php if ($mlw_quiz_options->user_phone == 2) {echo 'checked="checked"';} ?> value='2' /><label for="radio18"><?php _e('No', 'quiz-master-next'); ?></label><br>
255
- </td>
256
- </tr>
257
- <tr valign="top">
258
- <th scope="row"><label for="commentSection"><?php _e('Would you like a place for the user to enter comments?', 'quiz-master-next'); ?></label></th>
259
- <td>
260
- <input type="radio" id="radio21" name="commentSection" <?php if ($mlw_quiz_options->comment_section == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio21"><?php _e('Yes', 'quiz-master-next'); ?></label><br>
261
- <input type="radio" id="radio22" name="commentSection" <?php if ($mlw_quiz_options->comment_section == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio22"><?php _e('No', 'quiz-master-next'); ?></label><br>
262
- </td>
263
- </tr>
264
- <tr valign="top">
265
- <th scope="row"><label for="question_numbering"><?php _e('Show question number on quiz?', 'quiz-master-next'); ?></label></th>
266
- <td>
267
- <input type="radio" id="question_numbering_radio2" name="question_numbering" <?php if ($mlw_quiz_options->question_numbering == 1) {echo 'checked="checked"';} ?> value='1' /><label for="question_numbering_radio2"><?php _e('Yes', 'quiz-master-next'); ?></label><br>
268
- <input type="radio" id="question_numbering_radio" name="question_numbering" <?php if ($mlw_quiz_options->question_numbering == 0) {echo 'checked="checked"';} ?> value='0' /><label for="question_numbering_radio"><?php _e('No', 'quiz-master-next'); ?></label><br>
269
- </td>
270
- </tr>
271
- <tr valign="top">
272
- <th scope="row"><label for="social_media"><?php _e('Show social media sharing buttons? (Twitter & Facebook)', 'quiz-master-next'); _e('This option is for here only for users of older versions. Please use the new template variables %FACEBOOK_SHARE% %TWITTER_SHARE% on your results pages instead of using this option!', 'quiz-master-next'); ?></label></th>
273
- <td>
274
- <input type="radio" id="social_media_radio2" name="social_media" <?php if ($mlw_quiz_options->social_media == 1) {echo 'checked="checked"';} ?> value='1' /><label for="social_media_radio2"><?php _e('Yes', 'quiz-master-next'); ?></label><br>
275
- <input type="radio" id="social_media_radio" name="social_media" <?php if ($mlw_quiz_options->social_media == 0) {echo 'checked="checked"';} ?> value='0' /><label for="social_media_radio"><?php _e('No', 'quiz-master-next'); ?></label><br>
276
- </td>
277
- </tr>
278
- <tr valign="top">
279
- <th scope="row"><label for="disable_answer_onselect"><?php _e('Disable question once user selects answer? (Currently only work on multiple choice)', 'quiz-master-next'); ?></label></th>
280
- <td>
281
- <input type="radio" id="disable_answer_radio2" name="disable_answer_onselect" <?php if ($mlw_quiz_options->disable_answer_onselect == 1) {echo 'checked="checked"';} ?> value='1' /><label for="disable_answer_radio2"><?php _e('Yes', 'quiz-master-next'); ?></label><br>
282
- <input type="radio" id="disable_answer_radio" name="disable_answer_onselect" <?php if ($mlw_quiz_options->disable_answer_onselect == 0) {echo 'checked="checked"';} ?> value='0' /><label for="disable_answer_radio"><?php _e('No', 'quiz-master-next'); ?></label><br>
283
- </td>
284
- </tr>
285
- <tr valign="top">
286
- <th scope="row"><label for="ajax_show_correct"><?php _e('Dynamically add class for incorrect/correct answer after user selects answer? (Currently only works on multiple choice)', 'quiz-master-next'); ?></label></th>
287
- <td>
288
- <input type="radio" id="ajax_show_correct_radio2" name="ajax_show_correct" <?php if ($mlw_quiz_options->ajax_show_correct == 1) {echo 'checked="checked"';} ?> value='1' /><label for="ajax_show_correct_radio2"><?php _e('Yes', 'quiz-master-next'); ?></label><br>
289
- <input type="radio" id="ajax_show_correct_radio" name="ajax_show_correct" <?php if ($mlw_quiz_options->ajax_show_correct == 0) {echo 'checked="checked"';} ?> value='0' /><label for="ajax_show_correct_radio"><?php _e('No', 'quiz-master-next'); ?></label><br>
290
- </td>
291
- </tr>
292
- </table>
293
- <button id="save_options_button" class="button-primary" onclick="javascript: document.quiz_options_form.submit();"><?php _e('Save Options', 'quiz-master-next'); ?></button>
294
- </form>
295
- </div>
296
- <?php
297
  }
298
  ?>
7
  * @return void
8
  * @since 4.4.0
9
  */
10
+ function qmn_settings_options_tab() {
 
11
  global $mlwQuizMasterNext;
12
+ $mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs( __( "Options", 'quiz-master-next' ), 'mlw_options_option_tab_content' );
13
  }
14
+ add_action( "plugins_loaded", 'qmn_settings_options_tab', 5 );
15
 
16
  /**
17
  * Adds the options content to the Quiz Settings page.
19
  * @return void
20
  * @since 4.4.0
21
  */
22
+ function mlw_options_option_tab_content() {
23
+
24
  global $wpdb;
25
  global $mlwQuizMasterNext;
26
+ $mlwQuizMasterNext->pluginHelper->generate_settings_section( 'quiz_options' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  }
28
  ?>
php/options-page-results-page-tab.php CHANGED
@@ -104,7 +104,7 @@ function mlw_options_results_tab_content()
104
  {
105
  $mlw_message_after_array = array(array(0, 0, $mlw_quiz_options->message_after, "redirect_url" => ''));
106
  }
107
- wp_enqueue_style( 'qmn_admin_style', plugins_url( '../css/qmn_admin.css' , __FILE__ ) );
108
  ?>
109
  <div id="tabs-6" class="mlw_tab_content">
110
  <script>
@@ -127,6 +127,12 @@ function mlw_options_results_tab_content()
127
  </script>
128
  <h3 style="text-align: center;"><?php _e("Template Variables", 'quiz-master-next'); ?></h3>
129
  <div class="template_list_holder">
 
 
 
 
 
 
130
  <div class="template_variable">
131
  <span class="template_name">%POINT_SCORE%</span> - <?php _e('Score for the quiz when using points', 'quiz-master-next'); ?>
132
  </div>
@@ -169,9 +175,6 @@ function mlw_options_results_tab_content()
169
  <div class="template_variable">
170
  <span class="template_name">%TIMER%</span> - <?php _e('The amount of time user spent taking quiz in seconds', 'quiz-master-next'); ?>
171
  </div>
172
- <div class="template_variable">
173
- <span class="template_name">%CERTIFICATE_LINK%</span> - <?php _e('The link to the certificate after completing the quiz', 'quiz-master-next'); ?>
174
- </div>
175
  <div class="template_variable">
176
  <span class="template_name">%CATEGORY_POINTS%%/CATEGORY_POINTS%</span> - <?php _e('The amount of points a specific category earned.', 'quiz-master-next'); ?>
177
  </div>
104
  {
105
  $mlw_message_after_array = array(array(0, 0, $mlw_quiz_options->message_after, "redirect_url" => ''));
106
  }
107
+ wp_enqueue_style( 'qmn_admin_style', plugins_url( '../css/qsm-admin.css' , __FILE__ ) );
108
  ?>
109
  <div id="tabs-6" class="mlw_tab_content">
110
  <script>
127
  </script>
128
  <h3 style="text-align: center;"><?php _e("Template Variables", 'quiz-master-next'); ?></h3>
129
  <div class="template_list_holder">
130
+ <div class="template_variable">
131
+ <span class="template_name">%CONTACT_X%</span> - <?php _e( 'Value user entered into contact field. X is # of contact field. For example, first contact field would be %CONTACT_1%', 'quiz-master-next' ); ?>
132
+ </div>
133
+ <div class="template_variable">
134
+ <span class="template_name">%CONTACT_ALL%</span> - <?php _e( 'List user values for all contact fields', 'quiz-master-next' ); ?>
135
+ </div>
136
  <div class="template_variable">
137
  <span class="template_name">%POINT_SCORE%</span> - <?php _e('Score for the quiz when using points', 'quiz-master-next'); ?>
138
  </div>
175
  <div class="template_variable">
176
  <span class="template_name">%TIMER%</span> - <?php _e('The amount of time user spent taking quiz in seconds', 'quiz-master-next'); ?>
177
  </div>
 
 
 
178
  <div class="template_variable">
179
  <span class="template_name">%CATEGORY_POINTS%%/CATEGORY_POINTS%</span> - <?php _e('The amount of points a specific category earned.', 'quiz-master-next'); ?>
180
  </div>
php/options-page-text-tab.php CHANGED
@@ -7,12 +7,11 @@ if ( ! defined( 'ABSPATH' ) ) exit;
7
  * @return void
8
  * @since 4.4.0
9
  */
10
- function qmn_settings_text_tab()
11
- {
12
  global $mlwQuizMasterNext;
13
- $mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs(__("Text", 'quiz-master-next'), 'mlw_options_text_tab_content');
14
  }
15
- add_action("plugins_loaded", 'qmn_settings_text_tab', 5);
16
 
17
  /**
18
  * Adds the Text tab content to the tab.
@@ -20,369 +19,88 @@ add_action("plugins_loaded", 'qmn_settings_text_tab', 5);
20
  * @return void
21
  * @since 4.4.0
22
  */
23
- function mlw_options_text_tab_content()
24
- {
25
  global $wpdb;
26
  global $mlwQuizMasterNext;
27
- $quiz_id = intval($_GET["quiz_id"]);
28
- //Submit saved templates into database
29
- if ( isset($_POST["save_templates"]) && $_POST["save_templates"] == "confirmation")
30
- {
31
- //Variables for save templates form
32
- $mlw_before_message = htmlspecialchars( stripslashes( $_POST["mlw_quiz_before_message"] ), ENT_QUOTES);
33
- $mlw_qmn_message_end = htmlspecialchars( stripslashes( $_POST["message_end_template"] ), ENT_QUOTES);
34
- $mlw_user_tries_text = htmlspecialchars( stripslashes( $_POST["mlw_quiz_total_user_tries_text"] ), ENT_QUOTES);
35
- $mlw_submit_button_text = sanitize_text_field( stripslashes( $_POST["mlw_submitText"] ) );
36
- $mlw_name_field_text = sanitize_text_field( stripslashes( $_POST["mlw_nameText"] ) );
37
- $mlw_business_field_text = sanitize_text_field( stripslashes( $_POST["mlw_businessText"] ) );
38
- $mlw_email_field_text = sanitize_text_field( stripslashes( $_POST["mlw_emailText"] ) );
39
- $mlw_phone_field_text = sanitize_text_field( stripslashes( $_POST["mlw_phoneText"] ) );
40
- $mlw_before_comments = htmlspecialchars(stripslashes( $_POST["mlw_quiz_before_comments"] ), ENT_QUOTES);
41
- $mlw_comment_field_text = htmlspecialchars(stripslashes( $_POST["mlw_commentText"] ), ENT_QUOTES);
42
- $mlw_require_log_in_text = htmlspecialchars(stripslashes( $_POST["mlw_require_log_in_text"] ), ENT_QUOTES);
43
- $mlw_scheduled_timeframe_text = htmlspecialchars(stripslashes( $_POST["mlw_scheduled_timeframe_text"] ), ENT_QUOTES);
44
- $mlw_limit_total_entries_text = htmlspecialchars(stripslashes( $_POST["mlw_limit_total_entries_text"] ), ENT_QUOTES);
45
- $mlw_qmn_pagination_field = serialize( array(
46
- sanitize_text_field( stripslashes( $_POST["pagination_prev_text"] ) ),
47
- sanitize_text_field( stripslashes( $_POST["pagination_next_text"] ) )
48
- ));
49
- $qmn_social_media_text = serialize( array(
50
- 'twitter' => wp_kses_post( stripslashes( $_POST["mlw_quiz_twitter_text_template"] ) ),
51
- 'facebook' => wp_kses_post( stripslashes( $_POST["mlw_quiz_facebook_text_template"] ) )
52
- ));
53
-
54
- $mlw_question_answer_template = htmlspecialchars(stripslashes( $_POST["mlw_quiz_question_answer_template"] ), ENT_QUOTES);
55
- $quiz_id = intval($_POST["quiz_id"]);
56
-
57
- $results = $wpdb->update(
58
- $wpdb->prefix . "mlw_quizzes",
59
- array(
60
- 'message_before' => $mlw_before_message,
61
- 'message_comment' => $mlw_before_comments,
62
- 'message_end_template' => $mlw_qmn_message_end,
63
- 'comment_field_text' => $mlw_comment_field_text,
64
- 'question_answer_template' => $mlw_question_answer_template,
65
- 'submit_button_text' => $mlw_submit_button_text,
66
- 'name_field_text' => $mlw_name_field_text,
67
- 'business_field_text' => $mlw_business_field_text,
68
- 'email_field_text' => $mlw_email_field_text,
69
- 'phone_field_text' => $mlw_phone_field_text,
70
- 'total_user_tries_text' => $mlw_user_tries_text,
71
- 'social_media_text' => $qmn_social_media_text,
72
- 'pagination_text' => $mlw_qmn_pagination_field,
73
- 'require_log_in_text' => $mlw_require_log_in_text,
74
- 'limit_total_entries_text' => $mlw_limit_total_entries_text,
75
- 'last_activity' => date("Y-m-d H:i:s"),
76
- 'scheduled_timeframe_text' => $mlw_scheduled_timeframe_text
77
- ),
78
- array( 'quiz_id' => $quiz_id ),
79
- array(
80
- '%s',
81
- '%s',
82
- '%s',
83
- '%s',
84
- '%s',
85
- '%s',
86
- '%s',
87
- '%s',
88
- '%s',
89
- '%s',
90
- '%s',
91
- '%s',
92
- '%s',
93
- '%s',
94
- '%s',
95
- '%s',
96
- '%s'
97
- ),
98
- array( '%d' )
99
- );
100
- if ( false != $results ) {
101
- $mlwQuizMasterNext->alertManager->newAlert(__('The templates has been updated successfully.', 'quiz-master-next'), 'success');
102
- $mlwQuizMasterNext->audit_manager->new_audit( "Templates Have Been Edited For Quiz Number $quiz_id" );
103
- } else {
104
- $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0007'), 'error');
105
- $mlwQuizMasterNext->log_manager->add("Error 0007", $wpdb->last_error.' from '.$wpdb->last_query, 0, 'error');
106
- }
107
- }
108
-
109
- if (isset($_GET["quiz_id"]))
110
- {
111
- $table_name = $wpdb->prefix . "mlw_quizzes";
112
- $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $quiz_id));
113
- }
114
-
115
- //Load Pagination Text
116
- $mlw_qmn_pagination_text = "";
117
- if (is_serialized($mlw_quiz_options->pagination_text) && is_array(@unserialize($mlw_quiz_options->pagination_text)))
118
- {
119
- $mlw_qmn_pagination_text = @unserialize($mlw_quiz_options->pagination_text);
120
- }
121
- else
122
- {
123
- $mlw_qmn_pagination_text = array(__('Previous', 'quiz-master-next'), $mlw_quiz_options->pagination_text);
124
- }
125
-
126
- //Load Social Media Text
127
- $qmn_social_media_text = "";
128
- if (is_serialized($mlw_quiz_options->social_media_text) && is_array(@unserialize($mlw_quiz_options->social_media_text)))
129
- {
130
- $qmn_social_media_text = @unserialize($mlw_quiz_options->social_media_text);
131
- }
132
- else
133
- {
134
- $qmn_social_media_text = array(
135
- 'twitter' => $mlw_quiz_options->social_media_text,
136
- 'facebook' => $mlw_quiz_options->social_media_text
137
- );
138
- }
139
- wp_enqueue_style( 'qmn_admin_style', plugins_url( '../css/qmn_admin.css' , __FILE__ ) );
140
  ?>
141
- <div id="tabs-2" class="mlw_tab_content">
142
- <h3 style="text-align: center;"><?php _e("Template Variables", 'quiz-master-next'); ?></h3>
143
- <div class="template_list_holder">
144
- <div class="template_variable">
145
- <span class="template_name">%POINT_SCORE%</span> - <?php _e('Score for the quiz when using points', 'quiz-master-next'); ?>
146
- </div>
147
- <div class="template_variable">
148
- <span class="template_name">%AVERAGE_POINT%</span> - <?php _e('The average amount of points user had per question', 'quiz-master-next'); ?>
149
- </div>
150
- <div class="template_variable">
151
- <span class="template_name">%AMOUNT_CORRECT%</span> - <?php _e('The number of correct answers the user had', 'quiz-master-next'); ?>
152
- </div>
153
- <div class="template_variable">
154
- <span class="template_name">%TOTAL_QUESTIONS%</span> - <?php _e('The total number of questions in the quiz', 'quiz-master-next'); ?>
155
- </div>
156
- <div class="template_variable">
157
- <span class="template_name">%CORRECT_SCORE%</span> - <?php _e('Score for the quiz when using correct answers', 'quiz-master-next'); ?>
158
- </div>
159
- <div class="template_variable">
160
- <span class="template_name">%USER_NAME%</span> - <?php _e('The name the user entered before the quiz', 'quiz-master-next'); ?>
161
- </div>
162
- <div class="template_variable">
163
- <span class="template_name">%USER_BUSINESS%</span> - <?php _e('The business the user entered before the quiz', 'quiz-master-next'); ?>
164
- </div>
165
- <div class="template_variable">
166
- <span class="template_name">%USER_PHONE%</span> - <?php _e('The phone number the user entered before the quiz', 'quiz-master-next'); ?>
167
- </div>
168
- <div class="template_variable">
169
- <span class="template_name">%USER_EMAIL%</span> - <?php _e('The email the user entered before the quiz', 'quiz-master-next'); ?>
170
- </div>
171
- <div class="template_variable">
172
- <span class="template_name">%QUIZ_NAME%</span> - <?php _e('The name of the quiz', 'quiz-master-next'); ?>
173
- </div>
174
- <div class="template_variable">
175
- <span class="template_name">%QUESTIONS_ANSWERS%</span> - <?php _e('Shows the question, the answer the user provided, and the correct answer', 'quiz-master-next'); ?>
176
- </div>
177
- <div class="template_variable">
178
- <span class="template_name">%COMMENT_SECTION%</span> - <?php _e('The comments the user entered into comment box if enabled', 'quiz-master-next'); ?>
179
- </div>
180
- <div class="template_variable">
181
- <span class="template_name">%TIMER%</span> - <?php _e('The amount of time user spent on quiz in seconds', 'quiz-master-next'); ?>
182
- </div>
183
- <div class="template_variable">
184
- <span class="template_name">%TIMER_MINUTES%</span> - <?php _e('The amount of time user spent on quiz in minutes', 'quiz-master-next'); ?>
185
- </div>
186
- <div class="template_variable">
187
- <span class="template_name">%CERTIFICATE_LINK%</span> - <?php _e('The link to the certificate after completing the quiz', 'quiz-master-next'); ?>
188
- </div>
189
- <div class="template_variable">
190
- <span class="template_name">%CATEGORY_POINTS%%/CATEGORY_POINTS%</span> - <?php _e('The amount of points a specific category earned.', 'quiz-master-next'); ?>
191
- </div>
192
- <div class="template_variable">
193
- <span class="template_name">%CATEGORY_SCORE%%/CATEGORY_SCORE%</span> - <?php _e('The score a specific category earned.', 'quiz-master-next'); ?>
194
- </div>
195
- <div class="template_variable">
196
- <span class="template_name">%CATEGORY_AVERAGE_POINTS%</span> - <?php _e('The average points from all categories.', 'quiz-master-next'); ?>
197
- </div>
198
- <div class="template_variable">
199
- <span class="template_name">%CATEGORY_AVERAGE_SCORE%</span> - <?php _e('The average score from all categories.', 'quiz-master-next'); ?>
200
- </div>
201
- <div class="template_variable">
202
- <span class="template_name">%QUESTION%</span> - <?php _e('The question that the user answered', 'quiz-master-next'); ?>
203
- </div>
204
- <div class="template_variable">
205
- <span class="template_name">%USER_ANSWER%</span> - <?php _e('The answer the user gave for the question', 'quiz-master-next'); ?>
206
- </div>
207
- <div class="template_variable">
208
- <span class="template_name">%CORRECT_ANSWER%</span> - <?php _e('The correct answer for the question', 'quiz-master-next'); ?>
209
- </div>
210
- <div class="template_variable">
211
- <span class="template_name">%USER_COMMENTS%</span> - <?php _e('The comments the user provided in the comment field for the question', 'quiz-master-next'); ?>
212
- </div>
213
- <div class="template_variable">
214
- <span class="template_name">%CORRECT_ANSWER_INFO%</span> - <?php _e('Reason why the correct answer is the correct answer', 'quiz-master-next'); ?>
215
- </div>
216
- <div class="template_variable">
217
- <span class="template_name">%CURRENT_DATE%</span> - <?php _e('The Current Date', 'quiz-master-next'); ?>
218
- </div>
219
- <?php do_action('qmn_template_variable_list'); ?>
220
- </div>
221
- <div style="clear:both;"></div>
222
- <br>
223
- <button id="save_template_button" class="button-primary" onclick="javascript: document.quiz_template_form.submit();"><?php _e("Save Templates", 'quiz-master-next'); ?></button>
224
- <?php
225
- echo "<form action='' method='post' name='quiz_template_form'>";
226
- echo "<input type='hidden' name='save_templates' value='confirmation' />";
227
- echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
228
- ?>
229
- <h3 style="text-align: center;"><?php _e("Message Templates", 'quiz-master-next'); ?></h3>
230
- <table class="form-table">
231
- <tr>
232
- <td width="30%">
233
- <strong><?php _e("Message Displayed Before Quiz", 'quiz-master-next'); ?></strong>
234
- <br />
235
- <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
236
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
237
- <p style="margin: 2px 0">- %CURRENT_DATE%</p>
238
- </td>
239
- <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->message_before, ENT_QUOTES), 'mlw_quiz_before_message' ); ?></td>
240
- </tr>
241
- <tr>
242
- <td width="30%">
243
- <strong><?php _e("Message Displayed Before Comments Box If Enabled", 'quiz-master-next'); ?></strong>
244
- <br />
245
- <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
246
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
247
- <p style="margin: 2px 0">- %CURRENT_DATE%</p>
248
- </td>
249
- <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->message_comment, ENT_QUOTES), 'mlw_quiz_before_comments' ); ?></td>
250
- </tr>
251
- <tr>
252
- <td width="30%">
253
- <strong><?php _e("Message Displayed At End Of Quiz (Leave Blank To Omit Text Section)", 'quiz-master-next'); ?></strong>
254
- <br />
255
- <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
256
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
257
- <p style="margin: 2px 0">- %CURRENT_DATE%</p>
258
- </td>
259
- <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->message_end_template, ENT_QUOTES), 'message_end_template' ); ?></td>
260
- </tr>
261
- <tr>
262
- <td width="30%">
263
- <strong><?php _e("Message Displayed If User Has Tried Quiz Too Many Times", 'quiz-master-next'); ?></strong>
264
- <br />
265
- <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
266
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
267
- <p style="margin: 2px 0">- %CURRENT_DATE%</p>
268
- </td>
269
- <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->total_user_tries_text, ENT_QUOTES), 'mlw_quiz_total_user_tries_text' ); ?></td>
270
- </tr>
271
- <tr>
272
- <td width="30%">
273
- <strong><?php _e("Message Displayed If User Is Not Logged In And Quiz Requires Users To Be Logged In", 'quiz-master-next'); ?></strong>
274
- <br />
275
- <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
276
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
277
- <p style="margin: 2px 0">- %CURRENT_DATE%</p>
278
- </td>
279
- <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->require_log_in_text, ENT_QUOTES), 'mlw_require_log_in_text' ); ?></td>
280
- </tr>
281
- <tr>
282
- <td width="30%">
283
- <strong><?php _e("Message Displayed If Date Is Outside Scheduled Timeframe", 'quiz-master-next'); ?></strong>
284
- <br />
285
- <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
286
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
287
- <p style="margin: 2px 0">- %CURRENT_DATE%</p>
288
- </td>
289
- <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->scheduled_timeframe_text, ENT_QUOTES), 'mlw_scheduled_timeframe_text' ); ?></td>
290
- </tr>
291
- <tr>
292
- <td width="30%">
293
- <strong><?php _e("Message Displayed If The Limit Of Total Entries Has Been Reached", 'quiz-master-next'); ?></strong>
294
- <br />
295
- <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
296
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
297
- <p style="margin: 2px 0">- %CURRENT_DATE%</p>
298
- </td>
299
- <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->limit_total_entries_text, ENT_QUOTES), 'mlw_limit_total_entries_text' ); ?></td>
300
- </tr>
301
- <tr>
302
- <td width="30%">
303
- <strong><?php _e("%QUESTIONS_ANSWERS% Text", 'quiz-master-next'); ?></strong>
304
- <br />
305
- <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
306
- <p style="margin: 2px 0">- %QUESTION%</p>
307
- <p style="margin: 2px 0">- %USER_ANSWER%</p>
308
- <p style="margin: 2px 0">- %CORRECT_ANSWER%</p>
309
- <p style="margin: 2px 0">- %USER_COMMENTS%</p>
310
- <p style="margin: 2px 0">- %CORRECT_ANSWER_INFO%</p>
311
- </td>
312
- <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->question_answer_template, ENT_QUOTES), 'mlw_quiz_question_answer_template' ); ?></td>
313
- </tr>
314
- <tr>
315
- <td width="30%">
316
- <strong><?php _e("Twitter Sharing Text", 'quiz-master-next'); ?></strong>
317
- <br />
318
- <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
319
- <p style="margin: 2px 0">- %POINT_SCORE%</p>
320
- <p style="margin: 2px 0">- %AVERAGE_POINT%</p>
321
- <p style="margin: 2px 0">- %AMOUNT_CORRECT%</p>
322
- <p style="margin: 2px 0">- %TOTAL_QUESTIONS%</p>
323
- <p style="margin: 2px 0">- %CORRECT_SCORE%</p>
324
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
325
- <p style="margin: 2px 0">- %TIMER%</p>
326
- <p style="margin: 2px 0">- %CURRENT_DATE%</p>
327
- </td>
328
- <td><?php wp_editor( htmlspecialchars_decode($qmn_social_media_text["twitter"], ENT_QUOTES), 'mlw_quiz_twitter_text_template' ); ?></td>
329
- </td>
330
- </tr>
331
- <tr>
332
- <td width="30%">
333
- <strong><?php _e("Facebook Sharing Text", 'quiz-master-next'); ?></strong>
334
- <br />
335
- <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
336
- <p style="margin: 2px 0">- %POINT_SCORE%</p>
337
- <p style="margin: 2px 0">- %AVERAGE_POINT%</p>
338
- <p style="margin: 2px 0">- %AMOUNT_CORRECT%</p>
339
- <p style="margin: 2px 0">- %TOTAL_QUESTIONS%</p>
340
- <p style="margin: 2px 0">- %CORRECT_SCORE%</p>
341
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
342
- <p style="margin: 2px 0">- %TIMER%</p>
343
- <p style="margin: 2px 0">- %CURRENT_DATE%</p>
344
- </td>
345
- <td><?php wp_editor( htmlspecialchars_decode($qmn_social_media_text["facebook"], ENT_QUOTES), 'mlw_quiz_facebook_text_template' ); ?></td>
346
- </tr>
347
- </table>
348
- <h3 style="text-align: center;"><?php _e("Other Templates", 'quiz-master-next'); ?></h3>
349
- <table class="form-table">
350
- <tr valign="top">
351
- <th scope="row"><label for="mlw_submitText"><?php _e("Text for submit button", 'quiz-master-next'); ?></label></th>
352
- <td><input name="mlw_submitText" type="text" id="mlw_submitText" value="<?php echo $mlw_quiz_options->submit_button_text; ?>" class="regular-text" /></td>
353
- </tr>
354
- <tr valign="top">
355
- <th scope="row"><label for="mlw_nameText"><?php _e("Text for name field", 'quiz-master-next'); ?></label></th>
356
- <td><input name="mlw_nameText" type="text" id="mlw_nameText" value="<?php echo $mlw_quiz_options->name_field_text; ?>" class="regular-text" /></td>
357
- </tr>
358
- <tr valign="top">
359
- <th scope="row"><label for="mlw_businessText"><?php _e("Text for business field", 'quiz-master-next'); ?></label></th>
360
- <td><input name="mlw_businessText" type="text" id="mlw_businessText" value="<?php echo $mlw_quiz_options->business_field_text; ?>" class="regular-text" /></td>
361
- </tr>
362
- <tr valign="top">
363
- <th scope="row"><label for="mlw_emailText"><?php _e("Text for email field", 'quiz-master-next'); ?></label></th>
364
- <td><input name="mlw_emailText" type="text" id="mlw_emailText" value="<?php echo $mlw_quiz_options->email_field_text; ?>" class="regular-text" /></td>
365
- </tr>
366
- <tr valign="top">
367
- <th scope="row"><label for="mlw_phoneText"><?php _e("Text for phone number field", 'quiz-master-next'); ?></label></th>
368
- <td><input name="mlw_phoneText" type="text" id="mlw_phoneText" value="<?php echo $mlw_quiz_options->phone_field_text; ?>" class="regular-text" /></td>
369
- </tr>
370
- <tr valign="top">
371
- <th scope="row"><label for="mlw_commentText"><?php _e("Text for comments field", 'quiz-master-next'); ?></label></th>
372
- <td><input name="mlw_commentText" type="text" id="mlw_commentText" value="<?php echo $mlw_quiz_options->comment_field_text; ?>" class="regular-text" /></td>
373
- </tr>
374
- <tr valign="top">
375
- <th scope="row"><label for="pagination_prev_text"><?php _e("Text for previous button", 'quiz-master-next'); ?></label></th>
376
- <td><input name="pagination_prev_text" type="text" id="pagination_prev_text" value="<?php echo $mlw_qmn_pagination_text[0]; ?>" class="regular-text" /></td>
377
- </tr>
378
- <tr valign="top">
379
- <th scope="row"><label for="pagination_next_text"><?php _e("Text for next button", 'quiz-master-next'); ?></label></th>
380
- <td><input name="pagination_next_text" type="text" id="pagination_next_text" value="<?php echo $mlw_qmn_pagination_text[1]; ?>" class="regular-text" /></td>
381
- </tr>
382
- </table>
383
- <button id="save_template_button" class="button-primary" onclick="javascript: document.quiz_template_form.submit();"><?php _e("Save Templates", 'quiz-master-next'); ?></button>
384
- <?php echo "</form>"; ?>
385
- </div>
386
  <?php
 
387
  }
388
  ?>
7
  * @return void
8
  * @since 4.4.0
9
  */
10
+ function qmn_settings_text_tab() {
 
11
  global $mlwQuizMasterNext;
12
+ $mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs( __( 'Text', 'quiz-master-next' ), 'mlw_options_text_tab_content' );
13
  }
14
+ add_action( "plugins_loaded", 'qmn_settings_text_tab', 5 );
15
 
16
  /**
17
  * Adds the Text tab content to the tab.
19
  * @return void
20
  * @since 4.4.0
21
  */
22
+ function mlw_options_text_tab_content() {
 
23
  global $wpdb;
24
  global $mlwQuizMasterNext;
25
+ wp_enqueue_style( 'qmn_admin_style', plugins_url( '../css/qsm-admin.css' , __FILE__ ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  ?>
27
+ <h3 style="text-align: center;"><?php _e("Template Variables", 'quiz-master-next'); ?></h3>
28
+ <div class="template_list_holder">
29
+ <div class="template_variable">
30
+ <span class="template_name">%POINT_SCORE%</span> - <?php _e('Score for the quiz when using points', 'quiz-master-next'); ?>
31
+ </div>
32
+ <div class="template_variable">
33
+ <span class="template_name">%AVERAGE_POINT%</span> - <?php _e('The average amount of points user had per question', 'quiz-master-next'); ?>
34
+ </div>
35
+ <div class="template_variable">
36
+ <span class="template_name">%AMOUNT_CORRECT%</span> - <?php _e('The number of correct answers the user had', 'quiz-master-next'); ?>
37
+ </div>
38
+ <div class="template_variable">
39
+ <span class="template_name">%TOTAL_QUESTIONS%</span> - <?php _e('The total number of questions in the quiz', 'quiz-master-next'); ?>
40
+ </div>
41
+ <div class="template_variable">
42
+ <span class="template_name">%CORRECT_SCORE%</span> - <?php _e('Score for the quiz when using correct answers', 'quiz-master-next'); ?>
43
+ </div>
44
+ <div class="template_variable">
45
+ <span class="template_name">%USER_NAME%</span> - <?php _e('The name the user entered before the quiz', 'quiz-master-next'); ?>
46
+ </div>
47
+ <div class="template_variable">
48
+ <span class="template_name">%USER_BUSINESS%</span> - <?php _e('The business the user entered before the quiz', 'quiz-master-next'); ?>
49
+ </div>
50
+ <div class="template_variable">
51
+ <span class="template_name">%USER_PHONE%</span> - <?php _e('The phone number the user entered before the quiz', 'quiz-master-next'); ?>
52
+ </div>
53
+ <div class="template_variable">
54
+ <span class="template_name">%USER_EMAIL%</span> - <?php _e('The email the user entered before the quiz', 'quiz-master-next'); ?>
55
+ </div>
56
+ <div class="template_variable">
57
+ <span class="template_name">%QUIZ_NAME%</span> - <?php _e('The name of the quiz', 'quiz-master-next'); ?>
58
+ </div>
59
+ <div class="template_variable">
60
+ <span class="template_name">%QUESTIONS_ANSWERS%</span> - <?php _e('Shows the question, the answer the user provided, and the correct answer', 'quiz-master-next'); ?>
61
+ </div>
62
+ <div class="template_variable">
63
+ <span class="template_name">%COMMENT_SECTION%</span> - <?php _e('The comments the user entered into comment box if enabled', 'quiz-master-next'); ?>
64
+ </div>
65
+ <div class="template_variable">
66
+ <span class="template_name">%TIMER%</span> - <?php _e('The amount of time user spent on quiz in seconds', 'quiz-master-next'); ?>
67
+ </div>
68
+ <div class="template_variable">
69
+ <span class="template_name">%TIMER_MINUTES%</span> - <?php _e('The amount of time user spent on quiz in minutes', 'quiz-master-next'); ?>
70
+ </div>
71
+ <div class="template_variable">
72
+ <span class="template_name">%CATEGORY_POINTS%%/CATEGORY_POINTS%</span> - <?php _e('The amount of points a specific category earned.', 'quiz-master-next'); ?>
73
+ </div>
74
+ <div class="template_variable">
75
+ <span class="template_name">%CATEGORY_SCORE%%/CATEGORY_SCORE%</span> - <?php _e('The score a specific category earned.', 'quiz-master-next'); ?>
76
+ </div>
77
+ <div class="template_variable">
78
+ <span class="template_name">%CATEGORY_AVERAGE_POINTS%</span> - <?php _e('The average points from all categories.', 'quiz-master-next'); ?>
79
+ </div>
80
+ <div class="template_variable">
81
+ <span class="template_name">%CATEGORY_AVERAGE_SCORE%</span> - <?php _e('The average score from all categories.', 'quiz-master-next'); ?>
82
+ </div>
83
+ <div class="template_variable">
84
+ <span class="template_name">%QUESTION%</span> - <?php _e('The question that the user answered', 'quiz-master-next'); ?>
85
+ </div>
86
+ <div class="template_variable">
87
+ <span class="template_name">%USER_ANSWER%</span> - <?php _e('The answer the user gave for the question', 'quiz-master-next'); ?>
88
+ </div>
89
+ <div class="template_variable">
90
+ <span class="template_name">%CORRECT_ANSWER%</span> - <?php _e('The correct answer for the question', 'quiz-master-next'); ?>
91
+ </div>
92
+ <div class="template_variable">
93
+ <span class="template_name">%USER_COMMENTS%</span> - <?php _e('The comments the user provided in the comment field for the question', 'quiz-master-next'); ?>
94
+ </div>
95
+ <div class="template_variable">
96
+ <span class="template_name">%CORRECT_ANSWER_INFO%</span> - <?php _e('Reason why the correct answer is the correct answer', 'quiz-master-next'); ?>
97
+ </div>
98
+ <div class="template_variable">
99
+ <span class="template_name">%CURRENT_DATE%</span> - <?php _e('The Current Date', 'quiz-master-next'); ?>
100
+ </div>
101
+ <?php do_action('qmn_template_variable_list'); ?>
102
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  <?php
104
+ $mlwQuizMasterNext->pluginHelper->generate_settings_section( 'quiz_text' );
105
  }
106
  ?>
php/quiz-options-page.php CHANGED
@@ -1,5 +1,6 @@
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) ) exit;
 
3
  /**
4
  * This function allows for the editing of quiz options.
5
  *
@@ -7,21 +8,26 @@ if ( ! defined( 'ABSPATH' ) ) exit;
7
  * @return void
8
  * @since 4.4.0
9
  */
10
- function mlw_generate_quiz_options()
11
- {
12
- if ( !current_user_can('moderate_comments') )
13
- {
14
  return;
15
  }
 
16
  global $wpdb;
17
  global $mlwQuizMasterNext;
 
 
18
  $tab_array = $mlwQuizMasterNext->pluginHelper->get_settings_tabs();
19
  $active_tab = isset( $_GET[ 'tab' ] ) ? stripslashes( $_GET[ 'tab' ] ) : 'questions';
 
 
20
  $quiz_id = intval($_GET["quiz_id"]);
21
- if (isset($_GET["quiz_id"]))
22
- {
23
  $table_name = $wpdb->prefix . "mlw_quizzes";
24
  $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
 
25
  }
26
 
27
  ?>
@@ -54,17 +60,18 @@ function mlw_generate_quiz_options()
54
  echo sprintf(__('Quiz Settings For %s', 'quiz-master-next'), $mlw_quiz_options->quiz_name);
55
  ?></h1>
56
  <?php
 
57
  ob_start();
58
- if ($quiz_id != "")
59
- {
 
60
  ?>
61
  <h2 class="nav-tab-wrapper">
62
  <?php
63
- foreach($tab_array as $tab)
64
- {
65
  $active_class = '';
66
- if ($active_tab == $tab['slug'])
67
- {
68
  $active_class = 'nav-tab-active';
69
  }
70
  echo "<a href=\"?page=mlw_quiz_options&quiz_id=$quiz_id&tab=".$tab['slug']."\" class=\"nav-tab $active_class\">".$tab['title']."</a>";
@@ -73,19 +80,16 @@ function mlw_generate_quiz_options()
73
  </h2>
74
  <div class="mlw_tab_content">
75
  <?php
76
- foreach($tab_array as $tab)
77
- {
78
- if ($active_tab == $tab['slug'])
79
- {
80
- call_user_func($tab['function']);
81
  }
82
  }
83
  ?>
84
  </div>
85
  <?php
86
- }
87
- else
88
- {
89
  ?>
90
  <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
91
  <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
@@ -95,6 +99,8 @@ function mlw_generate_quiz_options()
95
  }
96
  $mlw_output = ob_get_contents();
97
  ob_end_clean();
 
 
98
  $mlwQuizMasterNext->alertManager->showAlerts();
99
  echo mlw_qmn_show_adverts();
100
  echo $mlw_output;
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) ) exit;
3
+
4
  /**
5
  * This function allows for the editing of quiz options.
6
  *
8
  * @return void
9
  * @since 4.4.0
10
  */
11
+ function mlw_generate_quiz_options() {
12
+
13
+ // Check if current user can
14
+ if ( ! current_user_can('moderate_comments') ) {
15
  return;
16
  }
17
+
18
  global $wpdb;
19
  global $mlwQuizMasterNext;
20
+
21
+ // Get registered tabs for the options page and set current tab
22
  $tab_array = $mlwQuizMasterNext->pluginHelper->get_settings_tabs();
23
  $active_tab = isset( $_GET[ 'tab' ] ) ? stripslashes( $_GET[ 'tab' ] ) : 'questions';
24
+
25
+ // Prepare quiz
26
  $quiz_id = intval($_GET["quiz_id"]);
27
+ if ( isset( $_GET["quiz_id"] ) ) {
 
28
  $table_name = $wpdb->prefix . "mlw_quizzes";
29
  $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
30
+ $mlwQuizMasterNext->quiz_settings->prepare_quiz( $_GET["quiz_id"] );
31
  }
32
 
33
  ?>
60
  echo sprintf(__('Quiz Settings For %s', 'quiz-master-next'), $mlw_quiz_options->quiz_name);
61
  ?></h1>
62
  <?php
63
+ // Put all output from tab into ob_get_contents below.
64
  ob_start();
65
+
66
+ // If the quiz is set and not empty
67
+ if ( ! empty( $quiz_id ) ) {
68
  ?>
69
  <h2 class="nav-tab-wrapper">
70
  <?php
71
+ // Cycle through registered tabs to create navigation
72
+ foreach( $tab_array as $tab ) {
73
  $active_class = '';
74
+ if ( $active_tab == $tab['slug'] ) {
 
75
  $active_class = 'nav-tab-active';
76
  }
77
  echo "<a href=\"?page=mlw_quiz_options&quiz_id=$quiz_id&tab=".$tab['slug']."\" class=\"nav-tab $active_class\">".$tab['title']."</a>";
80
  </h2>
81
  <div class="mlw_tab_content">
82
  <?php
83
+ // Cycle through tabs looking for current tab to create tab's content
84
+ foreach( $tab_array as $tab ) {
85
+ if ( $active_tab == $tab['slug'] ) {
86
+ call_user_func( $tab['function'] );
 
87
  }
88
  }
89
  ?>
90
  </div>
91
  <?php
92
+ } else {
 
 
93
  ?>
94
  <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
95
  <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
99
  }
100
  $mlw_output = ob_get_contents();
101
  ob_end_clean();
102
+
103
+ // Shows alerts, ads, then tab content
104
  $mlwQuizMasterNext->alertManager->showAlerts();
105
  echo mlw_qmn_show_adverts();
106
  echo $mlw_output;
php/quizzes-page.php CHANGED
@@ -2,285 +2,148 @@
2
  if ( ! defined( 'ABSPATH' ) ) exit;
3
 
4
  /**
5
- * Generates the quizzes page where the quizzes are displayed.
6
- *
7
- * @return void
8
- * @since 4.4.0
9
- */
10
- function mlw_generate_quiz_admin()
11
- {
12
- if ( !current_user_can('moderate_comments') )
13
- {
14
  return;
15
  }
 
 
16
  global $wpdb;
17
  global $mlwQuizMasterNext;
18
- $table_name = $wpdb->prefix . "mlw_quizzes";
19
 
20
- //Create new quiz
21
- if ( isset( $_POST["create_quiz"] ) && $_POST["create_quiz"] == "confirmation" )
22
- {
23
- $quiz_name = htmlspecialchars(stripslashes( $_POST["quiz_name"] ), ENT_QUOTES);
24
- $mlwQuizMasterNext->quizCreator->create_quiz($quiz_name);
 
 
 
 
25
  }
26
 
27
- //Delete quiz
28
- if (isset( $_POST["delete_quiz"] ) && $_POST["delete_quiz"] == "confirmation")
29
- {
30
- $mlw_quiz_id = intval($_POST["quiz_id"]);
31
  $quiz_name = sanitize_text_field( $_POST["delete_quiz_name"] );
32
- $mlwQuizMasterNext->quizCreator->delete_quiz($mlw_quiz_id, $quiz_name);
33
  }
34
 
35
- //Edit Quiz Name
36
- if (isset($_POST["quiz_name_editted"]) && $_POST["quiz_name_editted"] == "confirmation")
37
- {
38
- $mlw_edit_quiz_id = intval($_POST["edit_quiz_id"]);
39
- $mlw_edit_quiz_name = htmlspecialchars( stripslashes( $_POST["edit_quiz_name"] ), ENT_QUOTES);
40
- $mlwQuizMasterNext->quizCreator->edit_quiz_name($mlw_edit_quiz_id, $mlw_edit_quiz_name);
41
  }
42
 
43
- //Duplicate Quiz
44
- if (isset($_POST["duplicate_quiz"]) && $_POST["duplicate_quiz"] == "confirmation")
45
- {
46
- $mlw_duplicate_quiz_id = intval($_POST["duplicate_quiz_id"]);
47
- $mlw_duplicate_quiz_name = htmlspecialchars($_POST["duplicate_new_quiz_name"], ENT_QUOTES);
48
- $mlwQuizMasterNext->quizCreator->duplicate_quiz($mlw_duplicate_quiz_id, $mlw_duplicate_quiz_name, isset($_POST["duplicate_questions"]));
49
  }
50
 
51
- //Retrieve list of quizzes
52
- global $wpdb;
53
- $mlw_qmn_table_limit = 25;
54
- $mlw_qmn_quiz_count = $wpdb->get_var( "SELECT COUNT(quiz_id) FROM " . $wpdb->prefix . "mlw_quizzes WHERE deleted='0'" );
55
-
56
- if( isset($_GET{'mlw_quiz_page'} ) )
57
- {
58
- $mlw_qmn_quiz_page = $_GET{'mlw_quiz_page'} + 1;
59
- $mlw_qmn_quiz_begin = $mlw_qmn_table_limit * $mlw_qmn_quiz_page ;
60
- }
61
- else
62
- {
63
- $mlw_qmn_quiz_page = 0;
64
- $mlw_qmn_quiz_begin = 0;
65
- }
66
- $mlw_qmn_quiz_left = $mlw_qmn_quiz_count - ($mlw_qmn_quiz_page * $mlw_qmn_table_limit);
67
- $mlw_quiz_data = $wpdb->get_results( $wpdb->prepare( "SELECT quiz_id, quiz_name, quiz_views, quiz_taken, last_activity
68
- FROM " . $wpdb->prefix . "mlw_quizzes WHERE deleted='0'
69
- ORDER BY quiz_id DESC LIMIT %d, %d", $mlw_qmn_quiz_begin, $mlw_qmn_table_limit ) );
70
 
 
71
  $post_to_quiz_array = array();
72
- $my_query = new WP_Query( array('post_type' => 'quiz') );
73
- if( $my_query->have_posts() )
74
- {
75
- while( $my_query->have_posts() )
76
- {
77
  $my_query->the_post();
78
- $post_to_quiz_array[get_post_meta( get_the_ID(), 'quiz_id', true )] = array(
79
  'link' => get_permalink(),
80
  'id' => get_the_ID()
81
  );
82
  }
83
  }
84
  wp_reset_postdata();
85
- wp_enqueue_style( 'qmn_admin_style', plugins_url( '../css/qmn_admin.css' , __FILE__ ) );
86
- wp_enqueue_script( 'jquery' );
87
- wp_enqueue_script( 'jquery-ui-core' );
88
- wp_enqueue_script( 'jquery-ui-dialog' );
89
- wp_enqueue_script( 'jquery-ui-button' );
90
- wp_enqueue_script( 'jquery-effects-blind' );
91
- wp_enqueue_script( 'jquery-effects-explode' );
92
- wp_enqueue_style( 'qmn_jquery_redmond_theme', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css' );
93
- ?>
94
- <script type="text/javascript"
95
- src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
96
- </script>
97
- <script type="text/javascript">
98
- var $j = jQuery.noConflict();
99
- // increase the default animation speed to exaggerate the effect
100
- $j.fx.speeds._default = 1000;
101
- $j(function() {
102
- $j('#new_quiz_dialog').dialog({
103
- autoOpen: false,
104
- show: 'blind',
105
- hide: 'explode',
106
- buttons: {
107
- Cancel: function() {
108
- $j(this).dialog('close');
109
- }
110
- }
111
- });
112
 
113
- $j('#new_quiz_button').click(function() {
114
- $j('#new_quiz_dialog').dialog('open');
115
- return false;
116
- } );
117
- $j('#new_quiz_button_two').click(function() {
118
- $j('#new_quiz_dialog').dialog('open');
119
- return false;
120
- } );
121
- });
122
- function deleteQuiz(id,quizName){
123
- $j("#delete_dialog").dialog({
124
- autoOpen: false,
125
- show: 'blind',
126
- hide: 'explode',
127
- buttons: {
128
- Cancel: function() {
129
- $j(this).dialog('close');
130
- }
131
- }
132
- });
133
- $j("#delete_dialog").dialog('open');
134
- var idHidden = document.getElementById("quiz_id");
135
- var idHiddenName = document.getElementById("delete_quiz_name");
136
- idHidden.value = id;
137
- idHiddenName.value = quizName;
138
- };
139
- function editQuizName(id, quizName){
140
- $j("#edit_dialog").dialog({
141
- autoOpen: false,
142
- show: 'blind',
143
- hide: 'explode',
144
- buttons: {
145
- Cancel: function() {
146
- $j(this).dialog('close');
147
- }
148
- }
149
- });
150
- $j("#edit_dialog").dialog('open');
151
- document.getElementById("edit_quiz_name").value = quizName;
152
- document.getElementById("edit_quiz_id"). value = id;
153
- }
154
- function duplicateQuiz(id, quizName){
155
- $j("#duplicate_dialog").dialog({
156
- autoOpen: false,
157
- show: 'blind',
158
- hide: 'explode',
159
- buttons: {
160
- Cancel: function() {
161
- $j(this).dialog('close');
162
- }
163
- }
164
- });
165
- $j("#duplicate_dialog").dialog('open');
166
- document.getElementById("duplicate_quiz_id"). value = id;
167
  }
168
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  <div class="wrap qsm-quizes-page">
170
- <h1><?php _e('Quizzes/Surveys', 'quiz-master-next'); ?><a id="new_quiz_button" href="javascript:();" class="add-new-h2"><?php _e('Add New', 'quiz-master-next'); ?></a></h1>
171
  <?php $mlwQuizMasterNext->alertManager->showAlerts(); ?>
172
  <div class="qsm-quizzes-page-content">
173
- <div class="<?php if ( get_option( 'mlw_advert_shows' ) != 'false' ) { echo 'qsm-quiz-page-wrapper-with-ads'; } else { echo 'qsm-quiz-page-wrapper'; } ?>">
 
 
 
 
 
174
  <div class="tablenav top">
175
  <div class="tablenav-pages">
176
- <span class="displaying-num"><?php echo sprintf(_n('One quiz or survey', '%s quizzes or surveys', $mlw_qmn_quiz_count, 'quiz-master-next'), number_format_i18n($mlw_qmn_quiz_count)); ?></span>
177
- <span class="pagination-links">
178
- <?php
179
- $mlw_qmn_previous_page = 0;
180
- $mlw_current_page = $mlw_qmn_quiz_page+1;
181
- $mlw_total_pages = ceil($mlw_qmn_quiz_count/$mlw_qmn_table_limit);
182
- if( $mlw_qmn_quiz_page > 0 )
183
- {
184
- $mlw_qmn_previous_page = $mlw_qmn_quiz_page - 2;
185
- echo "<a class=\"prev-page\" title=\"Go to the previous page\" href=\"?page=quiz-master-next/mlw_quizmaster2.php&&mlw_quiz_page=$mlw_qmn_previous_page\"><</a>";
186
- echo "<span class=\"paging-input\">$mlw_current_page of $mlw_total_pages</span>";
187
- if( $mlw_qmn_quiz_left > $mlw_qmn_table_limit )
188
- {
189
- echo "<a class=\"next-page\" title=\"Go to the next page\" href=\"?page=quiz-master-next/mlw_quizmaster2.php&&mlw_quiz_page=$mlw_qmn_quiz_page\">></a>";
190
- }
191
- else
192
- {
193
- echo "<a class=\"next-page disabled\" title=\"Go to the next page\" href=\"?page=quiz-master-next/mlw_quizmaster2.php&&mlw_quiz_page=$mlw_qmn_quiz_page\">></a>";
194
- }
195
- }
196
- else if( $mlw_qmn_quiz_page == 0 )
197
- {
198
- if( $mlw_qmn_quiz_left > $mlw_qmn_table_limit )
199
- {
200
- echo "<a class=\"prev-page disabled\" title=\"Go to the previous page\" href=\"?page=quiz-master-next/mlw_quizmaster2.php&&mlw_quiz_page=$mlw_qmn_previous_page\"><</a>";
201
- echo "<span class=\"paging-input\">$mlw_current_page of $mlw_total_pages</span>";
202
- echo "<a class=\"next-page\" title=\"Go to the next page\" href=\"?page=quiz-master-next/mlw_quizmaster2.php&&mlw_quiz_page=$mlw_qmn_quiz_page\">></a>";
203
- }
204
- }
205
- else if( $mlw_qmn_quiz_left < $mlw_qmn_table_limit )
206
- {
207
- $mlw_qmn_previous_page = $mlw_qmn_quiz_page - 2;
208
- echo "<a class=\"prev-page\" title=\"Go to the previous page\" href=\"?page=quiz-master-next/mlw_quizmaster2.php&&mlw_quiz_page=$mlw_qmn_previous_page\"><</a>";
209
- echo "<span class=\"paging-input\">$mlw_current_page of $mlw_total_pages</span>";
210
- echo "<a class=\"next-page disabled\" title=\"Go to the next page\" href=\"?page=quiz-master-next/mlw_quizmaster2.php&&mlw_quiz_page=$mlw_qmn_quiz_page\">></a>";
211
- }
212
- ?>
213
- </span>
214
  <br class="clear">
215
  </div>
216
  </div>
217
  <table class="widefat">
218
  <thead>
219
  <tr>
220
- <th>ID</th>
221
- <th><?php _e('Name', 'quiz-master-next'); ?></th>
222
- <th><?php _e('URL', 'quiz-master-next'); ?></th>
223
- <th><?php _e('Shortcode', 'quiz-master-next'); ?></th>
224
- <th><?php _e('Leaderboard Shortcode', 'quiz-master-next'); ?></th>
225
- <th><?php _e('Views', 'quiz-master-next'); ?></th>
226
- <th><?php _e('Taken', 'quiz-master-next'); ?></th>
227
- <th><?php _e('Last Modified', 'quiz-master-next'); ?></th>
228
  </tr>
229
  </thead>
230
  <tbody id="the-list">
231
- <?php
232
- $quotes_list = "";
233
- $display = "";
234
- $alternate = "";
235
- foreach($mlw_quiz_data as $mlw_quiz_info) {
236
- if($alternate) $alternate = "";
237
- else $alternate = " class=\"alternate\"";
238
- $quotes_list .= "<tr{$alternate}>";
239
- $quotes_list .= "<td>" . $mlw_quiz_info->quiz_id . "</td>";
240
- $quotes_list .= "<td class='post-title column-title'>" . esc_html($mlw_quiz_info->quiz_name) ." <a class='qsm-edit-name' onclick=\"editQuizName('".$mlw_quiz_info->quiz_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='javascript:();'>(".__('Edit Name', 'quiz-master-next').")</a>";
241
- $quotes_list .= "<div class=\"row-actions\">
242
- <a class='qsm-action-link' href='admin.php?page=mlw_quiz_options&&quiz_id=".$mlw_quiz_info->quiz_id."'>".__('Edit', 'quiz-master-next')."</a>
243
- | <a class='qsm-action-link' href='admin.php?page=mlw_quiz_results&&quiz_id=".$mlw_quiz_info->quiz_id."'>".__('Results', 'quiz-master-next')."</a>
244
- | <a href='javascript:();' class='qsm-action-link' onclick=\"duplicateQuiz('".$mlw_quiz_info->quiz_id."','".esc_js($mlw_quiz_info->quiz_name)."')\">".__('Duplicate', 'quiz-master-next')."</a>
245
- | <a class='qsm-action-link qsm-action-link-delete' onclick=\"deleteQuiz('".$mlw_quiz_info->quiz_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='javascript:();'>".__('Delete', 'quiz-master-next')."</a>
246
- </div></td>";
247
- if (isset($post_to_quiz_array[$mlw_quiz_info->quiz_id]))
248
- {
249
- $quotes_list .= "<td>
250
- <a href='".$post_to_quiz_array[$mlw_quiz_info->quiz_id]['link']."'>" . __( 'View Quiz/Survey', 'quiz-master-next' ) . "</a>
251
- <div class=\"row-actions\"><a class='linkOptions' href='post.php?post=".$post_to_quiz_array[$mlw_quiz_info->quiz_id]['id']."&action=edit'>Edit Post Settings</a></a>
252
- </td>";
253
- }
254
- else
255
- {
256
- $quotes_list .= "<td></td>";
257
- }
258
- $quotes_list .= "<td>[mlw_quizmaster quiz=".$mlw_quiz_info->quiz_id."]</td>";
259
- $quotes_list .= "<td>[mlw_quizmaster_leaderboard mlw_quiz=".$mlw_quiz_info->quiz_id."]</td>";
260
- $quotes_list .= "<td>" . $mlw_quiz_info->quiz_views . "</td>";
261
- $quotes_list .= "<td>" . $mlw_quiz_info->quiz_taken ."</td>";
262
- $quotes_list .= "<td>" . $mlw_quiz_info->last_activity ."</td>";
263
- $quotes_list .= "</tr>";
264
- }
265
- echo $quotes_list; ?>
266
  </tbody>
267
  <tfoot>
268
  <tr>
269
- <th>ID</th>
270
- <th><?php _e('Name', 'quiz-master-next'); ?></th>
271
- <th><?php _e('URL', 'quiz-master-next'); ?></th>
272
- <th><?php _e('Shortcode', 'quiz-master-next'); ?></th>
273
- <th><?php _e('Leaderboard Shortcode', 'quiz-master-next'); ?></th>
274
- <th><?php _e('Views', 'quiz-master-next'); ?></th>
275
- <th><?php _e('Taken', 'quiz-master-next'); ?></th>
276
- <th><?php _e('Last Modified', 'quiz-master-next'); ?></th>
277
  </tr>
278
  </tfoot>
279
  </table>
280
  </div>
281
  <?php
282
- if ( get_option('mlw_advert_shows') == 'true' )
283
- {
284
  ?>
285
  <div class="qsm-news-ads">
286
  <h3 class="qsm-news-ads-title">QSM News</h3>
@@ -291,10 +154,10 @@ function mlw_generate_quiz_admin()
291
  </div>
292
  <?php
293
  $qmn_rss = array();
294
- $qmn_feed = fetch_feed('http://quizandsurveymaster.com/feed');
295
- if (!is_wp_error($qmn_feed)) {
296
- $qmn_feed_items = $qmn_feed->get_items(0, 5);
297
- foreach ($qmn_feed_items as $feed_item) {
298
  $qmn_rss[] = array(
299
  'link' => $feed_item->get_link(),
300
  'title' => $feed_item->get_title(),
@@ -304,8 +167,7 @@ function mlw_generate_quiz_admin()
304
  );
305
  }
306
  }
307
- foreach($qmn_rss as $item)
308
- {
309
  ?>
310
  <div class="qsm-news-ads-widget">
311
  <h3><?php echo $item['title']; ?></h3>
@@ -323,49 +185,48 @@ function mlw_generate_quiz_admin()
323
  }
324
  ?>
325
  </div>
326
- <!--Dialogs-->
327
 
328
  <!--New Quiz Dialog-->
329
  <div id="new_quiz_dialog" title="Create New Quiz Or Survey" style="display:none;">
330
  <form action="" method="post" class="qsm-dialog-form">
331
- <input type='hidden' name='create_quiz' value='confirmation' />
332
- <h3><?php _e('Create New Quiz Or Survey', 'quiz-master-next'); ?></h3>
333
- <label><?php _e('Name', 'quiz-master-next'); ?></label><input type="text" name="quiz_name" value="" />
334
- <p class='submit'><input type='submit' class='button-primary' value='<?php _e('Create', 'quiz-master-next'); ?>' /></p>
335
  </form>
336
  </div>
337
 
338
  <!--Edit Quiz Name Dialog-->
339
  <div id="edit_dialog" title="Edit Name" style="display:none;">
340
  <form action='' method='post' class="qsm-dialog-form">
341
- <label><?php _e('Name', 'quiz-master-next'); ?></label>
342
  <input type="text" id="edit_quiz_name" name="edit_quiz_name" />
343
  <input type="hidden" id="edit_quiz_id" name="edit_quiz_id" />
344
- <input type='hidden' name='quiz_name_editted' value='confirmation' />
345
- <p class='submit'><input type='submit' class='button-primary' value='<?php _e('Edit', 'quiz-master-next'); ?>' /></p>
346
  </form>
347
  </div>
348
 
349
  <!--Duplicate Quiz Dialog-->
350
  <div id="duplicate_dialog" title="Duplicate Quiz Or Survey" style="display:none;">
351
  <form action='' method='post' class="qsm-dialog-form">
352
- <label for="duplicate_questions"><?php _e('Duplicate questions also?', 'quiz-master-next'); ?></label><input type="checkbox" name="duplicate_questions" id="duplicate_questions"/><br />
353
  <br />
354
- <label for="duplicate_new_quiz_name"><?php _e('Name Of New Quiz Or Survey:', 'quiz-master-next'); ?></label><input type="text" id="duplicate_new_quiz_name" name="duplicate_new_quiz_name" />
355
  <input type="hidden" id="duplicate_quiz_id" name="duplicate_quiz_id" />
356
- <input type='hidden' name='duplicate_quiz' value='confirmation' />
357
- <p class='submit'><input type='submit' class='button-primary' value='<?php _e('Duplicate', 'quiz-master-next'); ?>' /></p>
358
  </form>
359
  </div>
360
 
361
  <!--Delete Quiz Dialog-->
362
  <div id="delete_dialog" title="Delete Quiz Or Survey?" style="display:none;">
363
  <form action='' method='post' class="qsm-dialog-form">
364
- <h3><b><?php _e('Are you sure you want to delete this quiz or survey?', 'quiz-master-next'); ?></b></h3>
365
- <input type='hidden' name='delete_quiz' value='confirmation' />
366
- <input type='hidden' id='quiz_id' name='quiz_id' value='' />
367
  <input type='hidden' id='delete_quiz_name' name='delete_quiz_name' value='' />
368
- <p class='submit'><input type='submit' class='button-primary' value='<?php _e('Delete', 'quiz-master-next'); ?>' /></p>
369
  </form>
370
  </div>
371
  </div>
2
  if ( ! defined( 'ABSPATH' ) ) exit;
3
 
4
  /**
5
+ * Generates the quizzes and surveys page
6
+ *
7
+ * @since 5.0
8
+ */
9
+ function qsm_generate_quizzes_surveys_page() {
10
+
11
+ // Only let admins and editors see this page
12
+ if ( ! current_user_can( 'moderate_comments' ) ) {
 
13
  return;
14
  }
15
+
16
+ // Retrieve our globals
17
  global $wpdb;
18
  global $mlwQuizMasterNext;
 
19
 
20
+ // Enqueue our styles and scripts
21
+ wp_enqueue_style( 'qsm_admin_style', plugins_url( '../css/qsm-admin.css' , __FILE__ ) );
22
+ wp_enqueue_script( 'qsm_admin_script', plugins_url( '../js/qsm-admin.js' , __FILE__ ), array( 'jquery-ui-core', 'jquery-ui-dialog', 'jquery-ui-button' ) );
23
+ wp_enqueue_style( 'qsm_jquery_redmond_theme', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css' );
24
+
25
+ // Create new quiz
26
+ if ( isset( $_POST['qsm_new_quiz_nonce'] ) && wp_verify_nonce( $_POST['qsm_new_quiz_nonce'], 'qsm_new_quiz' ) ) {
27
+ $quiz_name = htmlspecialchars( stripslashes( $_POST["quiz_name"] ), ENT_QUOTES );
28
+ $mlwQuizMasterNext->quizCreator->create_quiz( $quiz_name );
29
  }
30
 
31
+ // Delete quiz
32
+ if ( isset( $_POST['qsm_delete_quiz_nonce'] ) && wp_verify_nonce( $_POST['qsm_delete_quiz_nonce'], 'qsm_delete_quiz' ) ) {
33
+ $quiz_id = intval( $_POST["delete_quiz_id"] );
 
34
  $quiz_name = sanitize_text_field( $_POST["delete_quiz_name"] );
35
+ $mlwQuizMasterNext->quizCreator->delete_quiz( $quiz_id, $quiz_name );
36
  }
37
 
38
+ // Edit Quiz Name
39
+ if ( isset( $_POST['qsm_edit_name_quiz_nonce'] ) && wp_verify_nonce( $_POST['qsm_edit_name_quiz_nonce'], 'qsm_edit_name_quiz' ) ) {
40
+ $quiz_id = intval( $_POST["edit_quiz_id"] );
41
+ $quiz_name = htmlspecialchars( stripslashes( $_POST["edit_quiz_name"] ), ENT_QUOTES );
42
+ $mlwQuizMasterNext->quizCreator->edit_quiz_name( $quiz_id, $quiz_name );
 
43
  }
44
 
45
+ // Duplicate Quiz
46
+ if ( isset( $_POST['qsm_duplicate_quiz_nonce'] ) && wp_verify_nonce( $_POST['qsm_duplicate_quiz_nonce'], 'qsm_duplicate_quiz' ) ) {
47
+ $quiz_id = intval( $_POST["duplicate_quiz_id"] );
48
+ $quiz_name = htmlspecialchars( $_POST["duplicate_new_quiz_name"], ENT_QUOTES );
49
+ $mlwQuizMasterNext->quizCreator->duplicate_quiz( $quiz_id, $quiz_name, isset( $_POST["duplicate_questions"] ) );
 
50
  }
51
 
52
+ // Load our quizzes
53
+ $quizzes = $wpdb->get_results( "SELECT quiz_id, quiz_name, quiz_views, quiz_taken, last_activity FROM {$wpdb->prefix}mlw_quizzes WHERE deleted='0' ORDER BY quiz_id DESC" );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
+ // Load quiz posts
56
  $post_to_quiz_array = array();
57
+ $my_query = new WP_Query( array( 'post_type' => 'quiz', 'posts_per_page' => -1, 'post_status' => 'publish' ) );
58
+ if ( $my_query->have_posts() ) {
59
+ while ( $my_query->have_posts() ) {
 
 
60
  $my_query->the_post();
61
+ $post_to_quiz_array[ get_post_meta( get_the_ID(), 'quiz_id', true ) ] = array(
62
  'link' => get_permalink(),
63
  'id' => get_the_ID()
64
  );
65
  }
66
  }
67
  wp_reset_postdata();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
+ $quiz_json_array = array();
70
+ foreach ( $quizzes as $quiz ) {
71
+ if ( ! isset( $post_to_quiz_array[ $quiz->quiz_id ] ) ) {
72
+ $current_user = wp_get_current_user();
73
+ $quiz_post = array(
74
+ 'post_title' => $quiz->quiz_name,
75
+ 'post_content' => "[qsm quiz={$quiz->quiz_id}]",
76
+ 'post_status' => 'publish',
77
+ 'post_author' => $current_user->ID,
78
+ 'post_type' => 'quiz'
79
+ );
80
+ $quiz_post_id = wp_insert_post( $quiz_post );
81
+ add_post_meta( $quiz_post_id, 'quiz_id', $quiz->quiz_id );
82
+ $post_to_quiz_array[ $quiz->quiz_id ] = array(
83
+ 'link' => get_permalink( $quiz_post_id ),
84
+ 'id' => $quiz_post_id
85
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  }
87
+
88
+ $quiz_json_array[] = array(
89
+ 'id' => $quiz->quiz_id,
90
+ 'name' => esc_html( $quiz->quiz_name ),
91
+ 'link' => $post_to_quiz_array[ $quiz->quiz_id ]['link'],
92
+ 'postID' => $post_to_quiz_array[ $quiz->quiz_id ]['id'],
93
+ 'views' => $quiz->quiz_views,
94
+ 'taken' => $quiz->quiz_taken,
95
+ 'lastActivity' => $quiz->last_activity
96
+ );
97
+ }
98
+ $total_count = count( $quiz_json_array );
99
+ wp_localize_script( 'qsm_admin_script', 'qsmQuizObject', $quiz_json_array );
100
+ ?>
101
  <div class="wrap qsm-quizes-page">
102
+ <h1><?php _e( 'Quizzes/Surveys', 'quiz-master-next' ); ?><a id="new_quiz_button" href="#" class="add-new-h2"><?php _e( 'Add New', 'quiz-master-next' ); ?></a></h1>
103
  <?php $mlwQuizMasterNext->alertManager->showAlerts(); ?>
104
  <div class="qsm-quizzes-page-content">
105
+ <div class="<?php if ( 'false' != get_option( 'mlw_advert_shows' ) ) { echo 'qsm-quiz-page-wrapper-with-ads'; } else { echo 'qsm-quiz-page-wrapper'; } ?>">
106
+ <p class="search-box">
107
+ <label class="screen-reader-text" for="quiz_search">Search:</label>
108
+ <input type="search" id="quiz_search" name="quiz_search" value="">
109
+ <a href="#" class="button">Search</a>
110
+ </p>
111
  <div class="tablenav top">
112
  <div class="tablenav-pages">
113
+ <span class="displaying-num"><?php echo sprintf( _n( 'One quiz or survey', '%s quizzes or surveys', $total_count, 'quiz-master-next' ), number_format_i18n( $total_count ) ); ?></span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  <br class="clear">
115
  </div>
116
  </div>
117
  <table class="widefat">
118
  <thead>
119
  <tr>
120
+ <th><?php _e( 'Name', 'quiz-master-next' ); ?></th>
121
+ <th><?php _e( 'URL', 'quiz-master-next' ); ?></th>
122
+ <th><?php _e( 'Shortcode', 'quiz-master-next' ); ?></th>
123
+ <th><?php _e( 'Leaderboard Shortcode', 'quiz-master-next' ); ?></th>
124
+ <th><?php _e( 'Views', 'quiz-master-next' ); ?></th>
125
+ <th><?php _e( 'Taken', 'quiz-master-next' ); ?></th>
126
+ <th><?php _e( 'Last Modified', 'quiz-master-next' ); ?></th>
 
127
  </tr>
128
  </thead>
129
  <tbody id="the-list">
130
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  </tbody>
132
  <tfoot>
133
  <tr>
134
+ <th><?php _e( 'Name', 'quiz-master-next' ); ?></th>
135
+ <th><?php _e( 'URL', 'quiz-master-next' ); ?></th>
136
+ <th><?php _e( 'Shortcode', 'quiz-master-next' ); ?></th>
137
+ <th><?php _e( 'Leaderboard Shortcode', 'quiz-master-next' ); ?></th>
138
+ <th><?php _e( 'Views', 'quiz-master-next' ); ?></th>
139
+ <th><?php _e( 'Taken', 'quiz-master-next' ); ?></th>
140
+ <th><?php _e( 'Last Modified', 'quiz-master-next' ); ?></th>
 
141
  </tr>
142
  </tfoot>
143
  </table>
144
  </div>
145
  <?php
146
+ if ( 'true' == get_option( 'mlw_advert_shows' ) ) {
 
147
  ?>
148
  <div class="qsm-news-ads">
149
  <h3 class="qsm-news-ads-title">QSM News</h3>
154
  </div>
155
  <?php
156
  $qmn_rss = array();
157
+ $qmn_feed = fetch_feed( 'http://quizandsurveymaster.com/feed' );
158
+ if ( ! is_wp_error( $qmn_feed ) ) {
159
+ $qmn_feed_items = $qmn_feed->get_items( 0, 5 );
160
+ foreach ( $qmn_feed_items as $feed_item ) {
161
  $qmn_rss[] = array(
162
  'link' => $feed_item->get_link(),
163
  'title' => $feed_item->get_title(),
167
  );
168
  }
169
  }
170
+ foreach( $qmn_rss as $item ) {
 
171
  ?>
172
  <div class="qsm-news-ads-widget">
173
  <h3><?php echo $item['title']; ?></h3>
185
  }
186
  ?>
187
  </div>
 
188
 
189
  <!--New Quiz Dialog-->
190
  <div id="new_quiz_dialog" title="Create New Quiz Or Survey" style="display:none;">
191
  <form action="" method="post" class="qsm-dialog-form">
192
+ <?php wp_nonce_field( 'qsm_new_quiz','qsm_new_quiz_nonce' ); ?>
193
+ <h3><?php _e( 'Create New Quiz Or Survey', 'quiz-master-next' ); ?></h3>
194
+ <label><?php _e( 'Name', 'quiz-master-next' ); ?></label><input type="text" name="quiz_name" value="" />
195
+ <p class='submit'><input type='submit' class='button-primary' value='<?php _e( 'Create', 'quiz-master-next' ); ?>' /></p>
196
  </form>
197
  </div>
198
 
199
  <!--Edit Quiz Name Dialog-->
200
  <div id="edit_dialog" title="Edit Name" style="display:none;">
201
  <form action='' method='post' class="qsm-dialog-form">
202
+ <label><?php _e( 'Name', 'quiz-master-next' ); ?></label>
203
  <input type="text" id="edit_quiz_name" name="edit_quiz_name" />
204
  <input type="hidden" id="edit_quiz_id" name="edit_quiz_id" />
205
+ <?php wp_nonce_field( 'qsm_edit_name_quiz','qsm_edit_name_quiz_nonce' ); ?>
206
+ <p class='submit'><input type='submit' class='button-primary' value='<?php _e( 'Edit', 'quiz-master-next' ); ?>' /></p>
207
  </form>
208
  </div>
209
 
210
  <!--Duplicate Quiz Dialog-->
211
  <div id="duplicate_dialog" title="Duplicate Quiz Or Survey" style="display:none;">
212
  <form action='' method='post' class="qsm-dialog-form">
213
+ <label for="duplicate_questions"><?php _e( 'Duplicate questions also?', 'quiz-master-next' ); ?></label><input type="checkbox" name="duplicate_questions" id="duplicate_questions"/><br />
214
  <br />
215
+ <label for="duplicate_new_quiz_name"><?php _e( 'Name Of New Quiz Or Survey:', 'quiz-master-next' ); ?></label><input type="text" id="duplicate_new_quiz_name" name="duplicate_new_quiz_name" />
216
  <input type="hidden" id="duplicate_quiz_id" name="duplicate_quiz_id" />
217
+ <?php wp_nonce_field( 'qsm_duplicate_quiz','qsm_duplicate_quiz_nonce' ); ?>
218
+ <p class='submit'><input type='submit' class='button-primary' value='<?php _e( 'Duplicate', 'quiz-master-next' ); ?>' /></p>
219
  </form>
220
  </div>
221
 
222
  <!--Delete Quiz Dialog-->
223
  <div id="delete_dialog" title="Delete Quiz Or Survey?" style="display:none;">
224
  <form action='' method='post' class="qsm-dialog-form">
225
+ <h3><b><?php _e( 'Are you sure you want to delete this quiz or survey?', 'quiz-master-next' ); ?></b></h3>
226
+ <?php wp_nonce_field( 'qsm_delete_quiz','qsm_delete_quiz_nonce' ); ?>
227
+ <input type='hidden' id='delete_quiz_id' name='delete_quiz_id' value='' />
228
  <input type='hidden' id='delete_quiz_name' name='delete_quiz_name' value='' />
229
+ <p class='submit'><input type='submit' class='button-primary' value='<?php _e( 'Delete', 'quiz-master-next' ); ?>' /></p>
230
  </form>
231
  </div>
232
  </div>
php/settings-page.php CHANGED
@@ -159,6 +159,7 @@ class QMNGlobalSettingsPage {
159
  else
160
  {
161
  $template = "<h2>Quiz Results for %QUIZ_NAME%</h2>
 
162
  <p>Name Provided: %USER_NAME%</p>
163
  <p>Business Provided: %USER_BUSINESS%</p>
164
  <p>Phone Provided: %USER_PHONE%</p>
159
  else
160
  {
161
  $template = "<h2>Quiz Results for %QUIZ_NAME%</h2>
162
+ <p>%CONTACT_ALL%</p>
163
  <p>Name Provided: %USER_NAME%</p>
164
  <p>Business Provided: %USER_BUSINESS%</p>
165
  <p>Phone Provided: %USER_PHONE%</p>
php/template-variables.php CHANGED
@@ -28,11 +28,12 @@ $mlw_qmn_result_array = array(
28
  'question_answers_display' => $mlw_question_answers,
29
  'question_answers_array' => $mlw_qmn_answer_array,
30
  'timer' => $mlw_qmn_timer,
31
- 'comments' => $mlw_qm_quiz_comments,
32
- 'certificate_link' => CERTIFICATE LINK
33
  );
34
 
35
  */
 
 
36
  add_filter('mlw_qmn_template_variable_results_page', 'qmn_variable_category_points',10,2);
37
  add_filter('mlw_qmn_template_variable_results_page', 'qmn_variable_average_category_points',10,2);
38
  add_filter('mlw_qmn_template_variable_results_page', 'qmn_variable_category_score',10,2);
@@ -54,7 +55,6 @@ add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_timer',10
54
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_timer_minutes',10,2);
55
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_date',10,2);
56
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_date_taken',10,2);
57
- add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_certificate_link',10,2);
58
  add_filter('mlw_qmn_template_variable_results_page', 'qmn_variable_facebook_share',10,2);
59
  add_filter('mlw_qmn_template_variable_results_page', 'qmn_variable_twitter_share',10,2);
60
 
@@ -191,13 +191,44 @@ function mlw_qmn_variable_user_email($content, $mlw_quiz_array)
191
  $content = str_replace( "%USER_EMAIL%" , $mlw_quiz_array["user_email"], $content);
192
  return $content;
193
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  function mlw_qmn_variable_question_answers($content, $mlw_quiz_array)
195
  {
196
  while (strpos($content, '%QUESTIONS_ANSWERS%') !== false)
197
  {
 
198
  global $wpdb;
199
  $display = '';
200
- $qmn_question_answer_template = $wpdb->get_var( $wpdb->prepare( "SELECT question_answer_template FROM " . $wpdb->prefix . "mlw_quizzes WHERE quiz_id=%d", $mlw_quiz_array['quiz_id'] ) );
201
  $qmn_questions_sql = $wpdb->get_results( $wpdb->prepare( "SELECT question_id, question_answer_info FROM " . $wpdb->prefix . "mlw_questions WHERE quiz_id=%d", $mlw_quiz_array['quiz_id'] ) );
202
  $qmn_questions = array();
203
  foreach($qmn_questions_sql as $question)
@@ -252,15 +283,6 @@ function mlw_qmn_variable_date_taken( $content, $mlw_quiz_array ) {
252
  return $content;
253
  }
254
 
255
- function mlw_qmn_variable_certificate_link($content, $mlw_quiz_array)
256
- {
257
- while (strpos($content, '%CERTIFICATE_LINK%') != false)
258
- {
259
- $content = str_replace( "%CERTIFICATE_LINK%" , $mlw_quiz_array["certificate_link"], $content);
260
- }
261
- return $content;
262
- }
263
-
264
  /*
265
  * Replaces variable %CATEGORY_POINTS% with the points for that category
266
  *
28
  'question_answers_display' => $mlw_question_answers,
29
  'question_answers_array' => $mlw_qmn_answer_array,
30
  'timer' => $mlw_qmn_timer,
31
+ 'comments' => $mlw_qm_quiz_comments
 
32
  );
33
 
34
  */
35
+ add_filter( 'mlw_qmn_template_variable_results_page', 'qsm_all_contact_fields_variable', 10, 2 );
36
+ add_filter( 'mlw_qmn_template_variable_results_page', 'qsm_contact_field_variable', 10, 2 );
37
  add_filter('mlw_qmn_template_variable_results_page', 'qmn_variable_category_points',10,2);
38
  add_filter('mlw_qmn_template_variable_results_page', 'qmn_variable_average_category_points',10,2);
39
  add_filter('mlw_qmn_template_variable_results_page', 'qmn_variable_category_score',10,2);
55
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_timer_minutes',10,2);
56
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_date',10,2);
57
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_date_taken',10,2);
 
58
  add_filter('mlw_qmn_template_variable_results_page', 'qmn_variable_facebook_share',10,2);
59
  add_filter('mlw_qmn_template_variable_results_page', 'qmn_variable_twitter_share',10,2);
60
 
191
  $content = str_replace( "%USER_EMAIL%" , $mlw_quiz_array["user_email"], $content);
192
  return $content;
193
  }
194
+
195
+ /**
196
+ * Returns user value for supplied contact field
197
+ *
198
+ * @since 5.0.0
199
+ * @return string The HTML for the content
200
+ */
201
+ function qsm_contact_field_variable( $content, $results_array ) {
202
+ preg_match_all( "~%CONTACT_(.*?)%~i", $content, $matches );
203
+ for ( $i = 0; $i < count( $matches[0] ); $i++ ) {
204
+ $content = str_replace( "%CONTACT_" . $matches[1][ $i ] . "%" , $results_array["contact"][ $matches[1][ $i ] - 1 ]["value"], $content);
205
+ }
206
+ return $content;
207
+ }
208
+
209
+ /**
210
+ * Returns user values for all contact fields
211
+ *
212
+ * @since 5.0.0
213
+ * @return string The HTML for the content
214
+ */
215
+ function qsm_all_contact_fields_variable( $content, $results ) {
216
+ $return = '';
217
+ for ( $i = 0; $i < count( $results["contact"] ); $i++ ) {
218
+ $return .= $results["contact"][ $i ]["label"] . ": " . $results["contact"][ $i ]["value"] . "<br>";
219
+ }
220
+ $content = str_replace( "%CONTACT_ALL%" , $return, $content );
221
+ return $content;
222
+ }
223
+
224
  function mlw_qmn_variable_question_answers($content, $mlw_quiz_array)
225
  {
226
  while (strpos($content, '%QUESTIONS_ANSWERS%') !== false)
227
  {
228
+ global $mlwQuizMasterNext;
229
  global $wpdb;
230
  $display = '';
231
+ $qmn_question_answer_template = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_template', '%QUESTION%<br>%USER_ANSWER%' );
232
  $qmn_questions_sql = $wpdb->get_results( $wpdb->prepare( "SELECT question_id, question_answer_info FROM " . $wpdb->prefix . "mlw_questions WHERE quiz_id=%d", $mlw_quiz_array['quiz_id'] ) );
233
  $qmn_questions = array();
234
  foreach($qmn_questions_sql as $question)
283
  return $content;
284
  }
285
 
 
 
 
 
 
 
 
 
 
286
  /*
287
  * Replaces variable %CATEGORY_POINTS% with the points for that category
288
  *
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Quiz And Survey Master (Formerly Quiz Master Next) ===
2
- Contributors: mylocalwebstop, fpcorso, elrath, dukeran
3
  Donate link: http://mylocalwebstop.com/downloads/donation-service-payment/
4
  Tags: quiz, survey, test, score, exam, questionnaire, email, answer, question, certificate, points, results
5
- Requires at least: 4.4
6
  Tested up to: 4.7
7
- Stable tag: 4.7.10
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -25,7 +25,7 @@ You can easily create surveys for your users. Everything from customer satisfact
25
  = Different Types Of Questions =
26
  You can have **multiple choice** (radio buttons), **true and false**, **open answer** question, **drop down**, **multiple response** (checkboxes), **fill in the blank**, **number**, **captcha**, and **accept**. More types are being supported in future updates!
27
 
28
- = Multiple Landing Pages For Each Quiz =
29
  Each quiz or survey can have **unlimited** results pages that can be customized with your text. Show different results pages based on the users score!
30
 
31
  = Emails After Completion Of Quiz And Survey =
@@ -109,23 +109,31 @@ This is usually a theme conflict. You can [checkout out our common conflict solu
109
 
110
  == Changelog ==
111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  = 4.7.10 (January 1, 2017) =
113
  * Closed Bug: Edit question not working when visual editor is off - Issue #497
114
  * Closed Bug: Localization incomplete on Global Settings page - Issue #478
115
 
116
- = 4.7.9 (December 13, 2016) =
117
- * Closed Security: CSRF vulnerability on Questions tab
118
-
119
- = 4.7.8 (November 2, 2016) =
120
- * Closed Bug: Apostrophe in translation for tab name text causing errors - Issue #490
121
- * Closed Bug: Timer resets if user copies link, opens new tab, and pastes link - Issue #489
122
- * Closed Enhancement: Add Business, Email, And Phone To Quiz Results Search - Issue #485
123
- * Closed Bug: "You Deserve It" button in review message leads to 404 - Issue #476
124
- * Closed Bug: In the Hint dropdown text, the 'apostrophe' does not display properly - Issue #453
125
-
126
  ([Read Full Changelog](https://github.com/fpcorso/quiz_master_next/blob/master/CHANGELOG.md))
127
 
128
  == Upgrade Notice ==
129
 
130
- = 4.7.10 =
131
- Upgrade to fix visual editor bug preventing some users from being able to edit their questions
1
  === Quiz And Survey Master (Formerly Quiz Master Next) ===
2
+ Contributors: fpcorso
3
  Donate link: http://mylocalwebstop.com/downloads/donation-service-payment/
4
  Tags: quiz, survey, test, score, exam, questionnaire, email, answer, question, certificate, points, results
5
+ Requires at least: 4.6
6
  Tested up to: 4.7
7
+ Stable tag: 5.0.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
25
  = Different Types Of Questions =
26
  You can have **multiple choice** (radio buttons), **true and false**, **open answer** question, **drop down**, **multiple response** (checkboxes), **fill in the blank**, **number**, **captcha**, and **accept**. More types are being supported in future updates!
27
 
28
+ = Multiple Results Pages For Each Quiz =
29
  Each quiz or survey can have **unlimited** results pages that can be customized with your text. Show different results pages based on the users score!
30
 
31
  = Emails After Completion Of Quiz And Survey =
109
 
110
  == Changelog ==
111
 
112
+ = 5.0.0 (March 25, 2017) =
113
+ * Closed: Fix delete custom post types during uninstall bug ([Issue #527](https://github.com/fpcorso/quiz_master_next/issues/527))
114
+ * Closed: Change Shortcode To QSM ([Issue #515](https://github.com/fpcorso/quiz_master_next/issues/515))
115
+ * Closed: Search function for quizzes/surveys ([Issue #492](https://github.com/fpcorso/quiz_master_next/issues/492))
116
+ * Closed: Create new fields class to handle creation/post data of settings fields ([Issue #450](https://github.com/fpcorso/quiz_master_next/issues/450))
117
+ * Closed: Create new settings class to handle the settings data ([Issue #449](https://github.com/fpcorso/quiz_master_next/issues/449))
118
+ * Closed: Rewrite options system to allow for extendibility ([Issue #448](https://github.com/fpcorso/quiz_master_next/issues/448))
119
+ * Closed: Enable tabs for the admin results page ([Issue #408](https://github.com/fpcorso/quiz_master_next/issues/408))
120
+ * Closed: Create onboarding process ([Issue #397](https://github.com/fpcorso/quiz_master_next/issues/397))
121
+ * Closed: Create new contact tab to allow form creation ([Issue #394](https://github.com/fpcorso/quiz_master_next/issues/394))
122
+ * Closed: Move Certificate to free addon ([Issue #381](https://github.com/fpcorso/quiz_master_next/issues/381))
123
+ * Closed: Ability to add check box for privacy statement with the contact fields ([Issue #372](https://github.com/fpcorso/quiz_master_next/issues/372))
124
+ * Closed: Customize the "Please complete all required fields!" text ([Issue #371](https://github.com/fpcorso/quiz_master_next/issues/371))
125
+ * Closed: Allow admins to customize the validation error messages ([Issue #346](https://github.com/fpcorso/quiz_master_next/issues/346))
126
+ * Closed: Hint field cannot be customized ([Issue #262](https://github.com/fpcorso/quiz_master_next/issues/262))
127
+ * Closed: Add custom fields to the contact form ([Issue #211](https://github.com/fpcorso/quiz_master_next/issues/211))
128
+ * Closed: Scrollable List of Quizzes ([Issue #46](https://github.com/fpcorso/quiz_master_next/issues/46))
129
+
130
  = 4.7.10 (January 1, 2017) =
131
  * Closed Bug: Edit question not working when visual editor is off - Issue #497
132
  * Closed Bug: Localization incomplete on Global Settings page - Issue #478
133
 
 
 
 
 
 
 
 
 
 
 
134
  ([Read Full Changelog](https://github.com/fpcorso/quiz_master_next/blob/master/CHANGELOG.md))
135
 
136
  == Upgrade Notice ==
137
 
138
+ = 5.0.0 =
139
+ Upgrade to use a variety of new features including new contact fields system, new options to customize hint and error messages, and more!
templates/qmn_amethyst.css CHANGED
@@ -206,16 +206,19 @@ border: 1px solid #e3e3e3;
206
  .quiz_section.qmn_error input[type="text"],
207
  .quiz_section.qmn_error input[type="number"],
208
  .quiz_section.qmn_error input[type="email"],
 
209
  .quiz_section.qmn_error select:hover,
210
  .quiz_section.qmn_error textarea:hover,
211
  .quiz_section.qmn_error input[type="text"]:hover,
212
  .quiz_section.qmn_error input[type="number"]:hover,
213
  .quiz_section.qmn_error input[type="email"]:hover,
 
214
  .quiz_section.qmn_error select:focus,
215
  .quiz_section.qmn_error textarea:focus,
216
  .quiz_section.qmn_error input[type="text"]:focus,
217
  .quiz_section.qmn_error input[type="number"]:focus,
218
- .quiz_section.qmn_error input[type="email"]:focus {
 
219
  position: relative;
220
  border: 1px solid #da4f49;
221
  background: #F2DEDE;
@@ -361,6 +364,11 @@ border: 1px solid #e3e3e3;
361
 
362
  .qmn_quiz_container .qmn_btn:hover, .qmn_quiz_container .btn:hover { background: #8e44ad !important; }
363
 
 
 
 
 
 
364
  /* Helper classes */
365
 
366
  .border-none { border: 0; }
206
  .quiz_section.qmn_error input[type="text"],
207
  .quiz_section.qmn_error input[type="number"],
208
  .quiz_section.qmn_error input[type="email"],
209
+ .quiz_section.qmn_error input[type="checkbox"],
210
  .quiz_section.qmn_error select:hover,
211
  .quiz_section.qmn_error textarea:hover,
212
  .quiz_section.qmn_error input[type="text"]:hover,
213
  .quiz_section.qmn_error input[type="number"]:hover,
214
  .quiz_section.qmn_error input[type="email"]:hover,
215
+ .quiz_section.qmn_error input[type="checkbox"]:hover,
216
  .quiz_section.qmn_error select:focus,
217
  .quiz_section.qmn_error textarea:focus,
218
  .quiz_section.qmn_error input[type="text"]:focus,
219
  .quiz_section.qmn_error input[type="number"]:focus,
220
+ .quiz_section.qmn_error input[type="email"]:focus,
221
+ .quiz_section.qmn_error input[type="checkbox"]:focus {
222
  position: relative;
223
  border: 1px solid #da4f49;
224
  background: #F2DEDE;
364
 
365
  .qmn_quiz_container .qmn_btn:hover, .qmn_quiz_container .btn:hover { background: #8e44ad !important; }
366
 
367
+ .quiz_section.quiz_end .qsm-submit-btn {
368
+ display: block;
369
+ margin: 10px 0;
370
+ }
371
+
372
  /* Helper classes */
373
 
374
  .border-none { border: 0; }
templates/qmn_base.css CHANGED
@@ -205,16 +205,19 @@ border: 1px solid #e3e3e3;
205
  .quiz_section.qmn_error input[type="text"],
206
  .quiz_section.qmn_error input[type="number"],
207
  .quiz_section.qmn_error input[type="email"],
 
208
  .quiz_section.qmn_error select:hover,
209
  .quiz_section.qmn_error textarea:hover,
210
  .quiz_section.qmn_error input[type="text"]:hover,
211
  .quiz_section.qmn_error input[type="number"]:hover,
212
  .quiz_section.qmn_error input[type="email"]:hover,
 
213
  .quiz_section.qmn_error select:focus,
214
  .quiz_section.qmn_error textarea:focus,
215
  .quiz_section.qmn_error input[type="text"]:focus,
216
  .quiz_section.qmn_error input[type="number"]:focus,
217
- .quiz_section.qmn_error input[type="email"]:focus {
 
218
  position: relative;
219
  border: 1px solid #da4f49;
220
  background: #F2DEDE;
@@ -508,6 +511,11 @@ border: 1px solid #e3e3e3;
508
 
509
  .blue .btn:hover { background: #2980b9; }
510
 
 
 
 
 
 
511
  /* Helper classes */
512
 
513
  .border-none { border: 0; }
205
  .quiz_section.qmn_error input[type="text"],
206
  .quiz_section.qmn_error input[type="number"],
207
  .quiz_section.qmn_error input[type="email"],
208
+ .quiz_section.qmn_error input[type="checkbox"],
209
  .quiz_section.qmn_error select:hover,
210
  .quiz_section.qmn_error textarea:hover,
211
  .quiz_section.qmn_error input[type="text"]:hover,
212
  .quiz_section.qmn_error input[type="number"]:hover,
213
  .quiz_section.qmn_error input[type="email"]:hover,
214
+ .quiz_section.qmn_error input[type="checkbox"]:hover,
215
  .quiz_section.qmn_error select:focus,
216
  .quiz_section.qmn_error textarea:focus,
217
  .quiz_section.qmn_error input[type="text"]:focus,
218
  .quiz_section.qmn_error input[type="number"]:focus,
219
+ .quiz_section.qmn_error input[type="email"]:focus,
220
+ .quiz_section.qmn_error input[type="checkbox"]:focus {
221
  position: relative;
222
  border: 1px solid #da4f49;
223
  background: #F2DEDE;
511
 
512
  .blue .btn:hover { background: #2980b9; }
513
 
514
+ .quiz_section.quiz_end .qsm-submit-btn {
515
+ display: block;
516
+ margin: 10px 0;
517
+ }
518
+
519
  /* Helper classes */
520
 
521
  .border-none { border: 0; }
templates/qmn_emerald.css CHANGED
@@ -205,16 +205,19 @@ border: 1px solid #e3e3e3;
205
  .quiz_section.qmn_error input[type="text"],
206
  .quiz_section.qmn_error input[type="number"],
207
  .quiz_section.qmn_error input[type="email"],
 
208
  .quiz_section.qmn_error select:hover,
209
  .quiz_section.qmn_error textarea:hover,
210
  .quiz_section.qmn_error input[type="text"]:hover,
211
  .quiz_section.qmn_error input[type="number"]:hover,
212
  .quiz_section.qmn_error input[type="email"]:hover,
 
213
  .quiz_section.qmn_error select:focus,
214
  .quiz_section.qmn_error textarea:focus,
215
  .quiz_section.qmn_error input[type="text"]:focus,
216
  .quiz_section.qmn_error input[type="number"]:focus,
217
- .quiz_section.qmn_error input[type="email"]:focus {
 
218
  position: relative;
219
  border: 1px solid #da4f49;
220
  background: #F2DEDE;
@@ -360,6 +363,11 @@ border: 1px solid #e3e3e3;
360
 
361
  .qmn_quiz_container .qmn_btn:hover, .qmn_quiz_container .btn:hover { background: #27ae60 !important; }
362
 
 
 
 
 
 
363
  /* Helper classes */
364
 
365
  .border-none { border: 0; }
205
  .quiz_section.qmn_error input[type="text"],
206
  .quiz_section.qmn_error input[type="number"],
207
  .quiz_section.qmn_error input[type="email"],
208
+ .quiz_section.qmn_error input[type="checkbox"],
209
  .quiz_section.qmn_error select:hover,
210
  .quiz_section.qmn_error textarea:hover,
211
  .quiz_section.qmn_error input[type="text"]:hover,
212
  .quiz_section.qmn_error input[type="number"]:hover,
213
  .quiz_section.qmn_error input[type="email"]:hover,
214
+ .quiz_section.qmn_error input[type="checkbox"]:hover,
215
  .quiz_section.qmn_error select:focus,
216
  .quiz_section.qmn_error textarea:focus,
217
  .quiz_section.qmn_error input[type="text"]:focus,
218
  .quiz_section.qmn_error input[type="number"]:focus,
219
+ .quiz_section.qmn_error input[type="email"]:focus,
220
+ .quiz_section.qmn_error input[type="checkbox"]:focus {
221
  position: relative;
222
  border: 1px solid #da4f49;
223
  background: #F2DEDE;
363
 
364
  .qmn_quiz_container .qmn_btn:hover, .qmn_quiz_container .btn:hover { background: #27ae60 !important; }
365
 
366
+ .quiz_section.quiz_end .qsm-submit-btn {
367
+ display: block;
368
+ margin: 10px 0;
369
+ }
370
+
371
  /* Helper classes */
372
 
373
  .border-none { border: 0; }
templates/qmn_gray.css CHANGED
@@ -206,16 +206,19 @@ border: 1px solid #e3e3e3;
206
  .quiz_section.qmn_error input[type="text"],
207
  .quiz_section.qmn_error input[type="number"],
208
  .quiz_section.qmn_error input[type="email"],
 
209
  .quiz_section.qmn_error select:hover,
210
  .quiz_section.qmn_error textarea:hover,
211
  .quiz_section.qmn_error input[type="text"]:hover,
212
  .quiz_section.qmn_error input[type="number"]:hover,
213
  .quiz_section.qmn_error input[type="email"]:hover,
 
214
  .quiz_section.qmn_error select:focus,
215
  .quiz_section.qmn_error textarea:focus,
216
  .quiz_section.qmn_error input[type="text"]:focus,
217
  .quiz_section.qmn_error input[type="number"]:focus,
218
- .quiz_section.qmn_error input[type="email"]:focus {
 
219
  position: relative;
220
  border: 1px solid #da4f49;
221
  background: #F2DEDE;
@@ -327,6 +330,11 @@ border: 1px solid #e3e3e3;
327
  box-shadow: 0 4px 8px rgba(0,0,0,.10);
328
  }
329
 
 
 
 
 
 
330
  /* Helper classes */
331
 
332
  .border-none { border: 0; }
206
  .quiz_section.qmn_error input[type="text"],
207
  .quiz_section.qmn_error input[type="number"],
208
  .quiz_section.qmn_error input[type="email"],
209
+ .quiz_section.qmn_error input[type="checkbox"],
210
  .quiz_section.qmn_error select:hover,
211
  .quiz_section.qmn_error textarea:hover,
212
  .quiz_section.qmn_error input[type="text"]:hover,
213
  .quiz_section.qmn_error input[type="number"]:hover,
214
  .quiz_section.qmn_error input[type="email"]:hover,
215
+ .quiz_section.qmn_error input[type="checkbox"]:hover,
216
  .quiz_section.qmn_error select:focus,
217
  .quiz_section.qmn_error textarea:focus,
218
  .quiz_section.qmn_error input[type="text"]:focus,
219
  .quiz_section.qmn_error input[type="number"]:focus,
220
+ .quiz_section.qmn_error input[type="email"]:focus,
221
+ .quiz_section.qmn_error input[type="checkbox"]:focus {
222
  position: relative;
223
  border: 1px solid #da4f49;
224
  background: #F2DEDE;
330
  box-shadow: 0 4px 8px rgba(0,0,0,.10);
331
  }
332
 
333
+ .quiz_section.quiz_end .qsm-submit-btn {
334
+ display: block;
335
+ margin: 10px 0;
336
+ }
337
+
338
  /* Helper classes */
339
 
340
  .border-none { border: 0; }
templates/qmn_primary.css CHANGED
@@ -206,16 +206,19 @@ border: 1px solid #e3e3e3;
206
  .quiz_section.qmn_error input[type="text"],
207
  .quiz_section.qmn_error input[type="number"],
208
  .quiz_section.qmn_error input[type="email"],
 
209
  .quiz_section.qmn_error select:hover,
210
  .quiz_section.qmn_error textarea:hover,
211
  .quiz_section.qmn_error input[type="text"]:hover,
212
  .quiz_section.qmn_error input[type="number"]:hover,
213
  .quiz_section.qmn_error input[type="email"]:hover,
 
214
  .quiz_section.qmn_error select:focus,
215
  .quiz_section.qmn_error textarea:focus,
216
  .quiz_section.qmn_error input[type="text"]:focus,
217
  .quiz_section.qmn_error input[type="number"]:focus,
218
- .quiz_section.qmn_error input[type="email"]:focus {
 
219
  position: relative;
220
  border: 1px solid #da4f49;
221
  background: #F2DEDE;
@@ -361,6 +364,11 @@ border: 1px solid #e3e3e3;
361
 
362
  .qmn_quiz_container .qmn_btn:hover, .qmn_quiz_container .btn:hover { background: #2980b9 !important; }
363
 
 
 
 
 
 
364
  /* Helper classes */
365
 
366
  .border-none { border: 0; }
206
  .quiz_section.qmn_error input[type="text"],
207
  .quiz_section.qmn_error input[type="number"],
208
  .quiz_section.qmn_error input[type="email"],
209
+ .quiz_section.qmn_error input[type="checkbox"],
210
  .quiz_section.qmn_error select:hover,
211
  .quiz_section.qmn_error textarea:hover,
212
  .quiz_section.qmn_error input[type="text"]:hover,
213
  .quiz_section.qmn_error input[type="number"]:hover,
214
  .quiz_section.qmn_error input[type="email"]:hover,
215
+ .quiz_section.qmn_error input[type="checkbox"]:hover,
216
  .quiz_section.qmn_error select:focus,
217
  .quiz_section.qmn_error textarea:focus,
218
  .quiz_section.qmn_error input[type="text"]:focus,
219
  .quiz_section.qmn_error input[type="number"]:focus,
220
+ .quiz_section.qmn_error input[type="email"]:focus,
221
+ .quiz_section.qmn_error input[type="checkbox"]:focus {
222
  position: relative;
223
  border: 1px solid #da4f49;
224
  background: #F2DEDE;
364
 
365
  .qmn_quiz_container .qmn_btn:hover, .qmn_quiz_container .btn:hover { background: #2980b9 !important; }
366
 
367
+ .quiz_section.quiz_end .qsm-submit-btn {
368
+ display: block;
369
+ margin: 10px 0;
370
+ }
371
+
372
  /* Helper classes */
373
 
374
  .border-none { border: 0; }
templates/qmn_turquoise.css CHANGED
@@ -206,16 +206,19 @@ border: 1px solid #e3e3e3;
206
  .quiz_section.qmn_error input[type="text"],
207
  .quiz_section.qmn_error input[type="number"],
208
  .quiz_section.qmn_error input[type="email"],
 
209
  .quiz_section.qmn_error select:hover,
210
  .quiz_section.qmn_error textarea:hover,
211
  .quiz_section.qmn_error input[type="text"]:hover,
212
  .quiz_section.qmn_error input[type="number"]:hover,
213
  .quiz_section.qmn_error input[type="email"]:hover,
 
214
  .quiz_section.qmn_error select:focus,
215
  .quiz_section.qmn_error textarea:focus,
216
  .quiz_section.qmn_error input[type="text"]:focus,
217
  .quiz_section.qmn_error input[type="number"]:focus,
218
- .quiz_section.qmn_error input[type="email"]:focus {
 
219
  position: relative;
220
  border: 1px solid #da4f49;
221
  background: #F2DEDE;
@@ -361,6 +364,11 @@ border: 1px solid #e3e3e3;
361
 
362
  .qmn_quiz_container .qmn_btn:hover, .qmn_quiz_container .btn:hover { background: #16a085 !important; }
363
 
 
 
 
 
 
364
  /* Helper classes */
365
 
366
  .border-none { border: 0; }
206
  .quiz_section.qmn_error input[type="text"],
207
  .quiz_section.qmn_error input[type="number"],
208
  .quiz_section.qmn_error input[type="email"],
209
+ .quiz_section.qmn_error input[type="checkbox"],
210
  .quiz_section.qmn_error select:hover,
211
  .quiz_section.qmn_error textarea:hover,
212
  .quiz_section.qmn_error input[type="text"]:hover,
213
  .quiz_section.qmn_error input[type="number"]:hover,
214
  .quiz_section.qmn_error input[type="email"]:hover,
215
+ .quiz_section.qmn_error input[type="checkbox"]:hover,
216
  .quiz_section.qmn_error select:focus,
217
  .quiz_section.qmn_error textarea:focus,
218
  .quiz_section.qmn_error input[type="text"]:focus,
219
  .quiz_section.qmn_error input[type="number"]:focus,
220
+ .quiz_section.qmn_error input[type="email"]:focus,
221
+ .quiz_section.qmn_error input[type="checkbox"]:focus {
222
  position: relative;
223
  border: 1px solid #da4f49;
224
  background: #F2DEDE;
364
 
365
  .qmn_quiz_container .qmn_btn:hover, .qmn_quiz_container .btn:hover { background: #16a085 !important; }
366
 
367
+ .quiz_section.quiz_end .qsm-submit-btn {
368
+ display: block;
369
+ margin: 10px 0;
370
+ }
371
+
372
  /* Helper classes */
373
 
374
  .border-none { border: 0; }
uninstall.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- //if uninstall not called from WordPress, then exit
3
  if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
4
  exit();
5
  }
@@ -17,6 +17,19 @@ $results = $wpdb->query( "DROP TABLE IF EXISTS $table_name" );
17
  $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
18
  $results = $wpdb->query( "DROP TABLE IF EXISTS $table_name" );
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  delete_option( 'mlw_quiz_master_version' );
21
  delete_option( 'mlw_qmn_review_notice' );
22
  delete_option( 'mlw_advert_shows' );
1
  <?php
2
+ // If uninstall not called from WordPress, then exit
3
  if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
4
  exit();
5
  }
17
  $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
18
  $results = $wpdb->query( "DROP TABLE IF EXISTS $table_name" );
19
 
20
+ // Taken from Easy Digital Downloads. Much better way of doing it than I was doing :)
21
+ // Cycle through custom post type array, retreive all posts, delete each one
22
+ $qsm_post_types = array( 'quiz', 'qmn_log' );
23
+ foreach ( $qsm_post_types as $post_type ) {
24
+ $items = get_posts( array( 'post_type' => $post_type, 'post_status' => 'any', 'numberposts' => -1, 'fields' => 'ids' ) );
25
+ if ( $items ) {
26
+ foreach ( $items as $item ) {
27
+ wp_delete_post( $item, true);
28
+ }
29
+ }
30
+ }
31
+
32
+
33
  delete_option( 'mlw_quiz_master_version' );
34
  delete_option( 'mlw_qmn_review_notice' );
35
  delete_option( 'mlw_advert_shows' );