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

Version Description

(October 1, 2021) = * Bug: Fixed the issue where %AVERAGE_CATEGORY_POINTS_X% was calculating total instead of average. * Bug: Fixed the issue where no category found for questions imported from question bank. * Bug: Fixed the issue where the limit number of questions per category was not working. * Bug: Fixed the issue with "Limit question per category" setting when "Random" option is enabled * Bug: Fixed the issue where timer was not showing on single page quiz. * Bug: Fixed the issue when recaptcha button not showing when question per page quiz options is enabled. * Bug: Fixed the issues while duplicating a quiz. * Bug: Fixed the issue where date question type shows date in reverse order on the results page and in emails. * Feature: Added date field in quiz contact tab. * Enhancement: Added Correct/Incorrect answers in different color in email.

Download this release

Release Info

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

Code changes from version 7.3.2 to 7.3.3

css/admin-dashboard-rtl.css CHANGED
@@ -4,7 +4,7 @@
4
  font-size: 23px;
5
  margin-left: 5px;
6
  position: relative;
7
- top: -3px;
8
  }
9
 
10
  .welcome-panel .qsm-welcome-panel-close {
@@ -68,6 +68,20 @@
68
  top: -30px;
69
  }
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  .popuar-addon-ul {
72
  columns: 2;
73
  -webkit-columns: 2;
4
  font-size: 23px;
5
  margin-left: 5px;
6
  position: relative;
7
+ top: unset!important;
8
  }
9
 
10
  .welcome-panel .qsm-welcome-panel-close {
68
  top: -30px;
69
  }
70
 
71
+ .welcome-panel .welcome-icon {
72
+ display: flex;
73
+ align-items: center;
74
+ }
75
+
76
+ .popover-count {
77
+ top: -2px !important;
78
+ right: unset!important;
79
+ left: 9px!important;
80
+ height: 13px!important;
81
+ width: 13px!important;
82
+ font-size: 8px!important;
83
+ }
84
+
85
  .popuar-addon-ul {
86
  columns: 2;
87
  -webkit-columns: 2;
css/admin-dashboard.css CHANGED
@@ -4,7 +4,7 @@
4
  font-size: 23px;
5
  margin-right: 5px;
6
  position: relative;
7
- top: -3px;
8
  }
9
 
10
  .welcome-panel .qsm-welcome-panel-close {
@@ -68,6 +68,20 @@
68
  top: -30px;
69
  }
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  .popuar-addon-ul {
72
  columns: 2;
73
  -webkit-columns: 2;
4
  font-size: 23px;
5
  margin-right: 5px;
6
  position: relative;
7
+ top: unset!important;
8
  }
9
 
10
  .welcome-panel .qsm-welcome-panel-close {
68
  top: -30px;
69
  }
70
 
71
+ .welcome-panel .welcome-icon {
72
+ display: flex;
73
+ align-items: center;
74
+ }
75
+
76
+ .popover-count {
77
+ top: -2px !important;
78
+ right: unset!important;
79
+ left: 9px!important;
80
+ height: 13px!important;
81
+ width: 13px!important;
82
+ font-size: 8px!important;
83
+ }
84
+
85
  .popuar-addon-ul {
86
  columns: 2;
87
  -webkit-columns: 2;
js/qsm-admin-contact.js CHANGED
@@ -22,6 +22,7 @@ var QSMContact;
22
  '<option value="text">Small Open Answer</option>' +
23
  '<option value="email">Email</option>' +
24
  '<option value="checkbox">Checkbox</option>' +
 
25
  '</select>' +
26
  '</div>' +
27
  '<div class="contact-form-group">' +
@@ -61,6 +62,9 @@ var QSMContact;
61
  case 'checkbox':
62
  contactField.find( '.type-control option[value="checkbox"]').prop( 'selected', true );
63
  break;
 
 
 
64
  default:
65
 
66
  }
22
  '<option value="text">Small Open Answer</option>' +
23
  '<option value="email">Email</option>' +
24
  '<option value="checkbox">Checkbox</option>' +
25
+ '<option value="date">Date</option>' +
26
  '</select>' +
27
  '</div>' +
28
  '<div class="contact-form-group">' +
62
  case 'checkbox':
63
  contactField.find( '.type-control option[value="checkbox"]').prop( 'selected', true );
64
  break;
65
+ case 'date':
66
+ contactField.find( '.type-control option[value="date"]').prop( 'selected', true );
67
+ break;
68
  default:
69
 
70
  }
js/qsm-productstash-config.js ADDED
@@ -0,0 +1 @@
 
1
+ var ps_popover = { workspace_id : "d24ad9de-78c7-4835-a2a8-3f5ee0317f31", selector: "#whatsnew" };
js/qsm-quiz.js CHANGED
@@ -66,7 +66,7 @@ var QSMPageTimer;
66
  // If we are using the newer pagination system...
67
  if (0 < $quizForm.children('.qsm-page').length) {
68
  // If there is a first page...
69
- if (!qmn_quiz_data[quizID].hasOwnProperty('first_page') && qmn_quiz_data[quizID].first_page) {
70
  QSM.activateTimer(quizID);
71
  $('#quizForm' + quizID).closest('.qmn_quiz_container').find('.stoptimer-p').show();
72
  }
@@ -429,10 +429,10 @@ var QSMPageTimer;
429
  */
430
  changePage: function (quizID, difference) {
431
  var page = QSM.getPage(quizID);
432
- if(page=="1" && qmn_quiz_data[quizID].hasOwnProperty('first_page') && qmn_quiz_data[quizID].first_page){
433
  if (qmn_quiz_data[quizID].hasOwnProperty('advanced_timer')) {
434
  var start_timer = parseInt(qmn_quiz_data[quizID].advanced_timer.start_timer_page);
435
- if ($('#quizForm' + quizID).closest('.qmn_quiz_container').find('.qmn_pagination > .current_page_hidden').val() == start_timer) {
436
  QSM.activateTimer(quizID);
437
  $('#quizForm' + quizID).closest('.qmn_quiz_container').find('.stoptimer-p').show();
438
  }
@@ -1000,6 +1000,7 @@ function qmnNextSlide(pagination, go_to_top, quiz_form_id) {
1000
  submit_button = jQuery(quiz_form_id + " .qsm-auto-page-row.empty_quiz_end").html();
1001
  jQuery(quiz_form_id + " .qsm-auto-page-row.empty_quiz_end").show();
1002
  $container.find(".mlw_next").hide();
 
1003
  }
1004
  }
1005
  $container.find('.qsm-auto-page-row.qsm-apc-' + page_number).show();
@@ -1030,7 +1031,7 @@ function qmnNextSlide(pagination, go_to_top, quiz_form_id) {
1030
  jQuery(quiz_form_id).closest('.qmn_quiz_container').find('.pages_count').hide();
1031
  }
1032
  qmnInitProgressbarOnClick(quiz_id, page_number, total_pages);
1033
- jQuery(document).trigger('qsm_next_button_click_after', [quiz_form_id]);
1034
  }
1035
 
1036
  function qmnPrevSlide(pagination, go_to_top, quiz_form_id) {
66
  // If we are using the newer pagination system...
67
  if (0 < $quizForm.children('.qsm-page').length) {
68
  // If there is a first page...
69
+ if (qmn_quiz_data[quizID].hasOwnProperty('first_page') && !qmn_quiz_data[quizID].first_page) {
70
  QSM.activateTimer(quizID);
71
  $('#quizForm' + quizID).closest('.qmn_quiz_container').find('.stoptimer-p').show();
72
  }
429
  */
430
  changePage: function (quizID, difference) {
431
  var page = QSM.getPage(quizID);
432
+ if(qmn_quiz_data[quizID].hasOwnProperty('first_page') && qmn_quiz_data[quizID].first_page){
433
  if (qmn_quiz_data[quizID].hasOwnProperty('advanced_timer')) {
434
  var start_timer = parseInt(qmn_quiz_data[quizID].advanced_timer.start_timer_page);
435
+ if ( page == start_timer ) { // check current page
436
  QSM.activateTimer(quizID);
437
  $('#quizForm' + quizID).closest('.qmn_quiz_container').find('.stoptimer-p').show();
438
  }
1000
  submit_button = jQuery(quiz_form_id + " .qsm-auto-page-row.empty_quiz_end").html();
1001
  jQuery(quiz_form_id + " .qsm-auto-page-row.empty_quiz_end").show();
1002
  $container.find(".mlw_next").hide();
1003
+ $container.find('.g-recaptcha').show();
1004
  }
1005
  }
1006
  $container.find('.qsm-auto-page-row.qsm-apc-' + page_number).show();
1031
  jQuery(quiz_form_id).closest('.qmn_quiz_container').find('.pages_count').hide();
1032
  }
1033
  qmnInitProgressbarOnClick(quiz_id, page_number, total_pages);
1034
+ jQuery(document).trigger('qsm_auto_next_button_click_after', [quiz_form_id]);
1035
  }
1036
 
1037
  function qmnPrevSlide(pagination, go_to_top, quiz_form_id) {
mlw_quizmaster2.php CHANGED
@@ -2,14 +2,14 @@
2
  /**
3
  * Plugin Name: Quiz And Survey Master
4
  * Description: Easily and quickly add quizzes and surveys to your website.
5
- * Version: 7.3.2
6
  * Author: ExpressTech
7
  * Author URI: https://quizandsurveymaster.com/
8
  * Plugin URI: https://expresstech.io/
9
  * Text Domain: quiz-master-next
10
  *
11
  * @author QSM Team
12
- * @version 7.3.2
13
  * @package QSM
14
  */
15
 
@@ -41,7 +41,7 @@ class MLWQuizMasterNext {
41
  * @var string
42
  * @since 4.0.0
43
  */
44
- public $version = '7.3.2';
45
 
46
  /**
47
  * QSM Alert Manager Object
2
  /**
3
  * Plugin Name: Quiz And Survey Master
4
  * Description: Easily and quickly add quizzes and surveys to your website.
5
+ * Version: 7.3.3
6
  * Author: ExpressTech
7
  * Author URI: https://quizandsurveymaster.com/
8
  * Plugin URI: https://expresstech.io/
9
  * Text Domain: quiz-master-next
10
  *
11
  * @author QSM Team
12
+ * @version 7.3.3
13
  * @package QSM
14
  */
15
 
41
  * @var string
42
  * @since 4.0.0
43
  */
44
+ public $version = '7.3.3';
45
 
46
  /**
47
  * QSM Alert Manager Object
php/admin/admin-dashboard.php CHANGED
@@ -108,12 +108,10 @@ function qsm_generate_dashboard_page() {
108
  wp_enqueue_script( 'jquery-touch-punch' );
109
  }
110
  ?>
111
- <script>
112
- var ps_config = {
113
- workspace_id: "d24ad9de-78c7-4835-a2a8-3f5ee0317f31"
114
- };
115
- </script>
116
- <script type="text/javascript" src="https://cdn.productstash.io/js/widget.min.js?v=0.5" defer="defer"></script>
117
  <div class="wrap">
118
  <h1><?php _e( 'QSM Dashboard', 'quiz-master-next' ); ?></h1>
119
  <div id="welcome_panel" class="postbox welcome-panel <?php qsm_check_close_hidden_box( 'welcome_panel' ); ?>">
108
  wp_enqueue_script( 'jquery-touch-punch' );
109
  }
110
  ?>
111
+ <?php
112
+ wp_enqueue_script ( 'productstash-config', plugins_url( '../../js/qsm-productstash-config.js', __FILE__ ) );
113
+ wp_enqueue_script ( 'productstash-popover', 'https://cdn.productstash.io/js/popover.min.js?v=0.1' );
114
+ ?>
 
 
115
  <div class="wrap">
116
  <h1><?php _e( 'QSM Dashboard', 'quiz-master-next' ); ?></h1>
117
  <div id="welcome_panel" class="postbox welcome-panel <?php qsm_check_close_hidden_box( 'welcome_panel' ); ?>">
php/admin/admin-results-details-page.php CHANGED
@@ -94,221 +94,227 @@ function qsm_generate_results_details_tab() {
94
  $quiz_id = intval( $results_data->quiz_id );
95
  $mlwQuizMasterNext->pluginHelper->prepare_quiz( $quiz_id );
96
 
97
- //Get the data for comments
98
- $quiz_options = $mlwQuizMasterNext->quiz_settings->get_setting( 'quiz_options');
99
- $comments_enabled = $quiz_options['comment_section'];
100
-
101
- $previous_results = $wpdb->get_var( $wpdb->prepare("SELECT result_id FROM {$wpdb->prefix}mlw_results WHERE result_id = (SELECT MAX(result_id) FROM {$wpdb->prefix}mlw_results WHERE deleted = 0 AND result_id < %d)", $result_id));
102
- $next_results = $wpdb->get_var( $wpdb->prepare("SELECT result_id FROM {$wpdb->prefix}mlw_results WHERE result_id = (SELECT MIN(result_id) FROM {$wpdb->prefix}mlw_results WHERE deleted = 0 AND result_id > %d)", $result_id));
103
 
104
  // If there is previous or next results, show buttons.
105
- echo '<div style="text-align:right; margin-top: 20px; margin-bottom: 20px;">';
106
- echo '<h3 class="result-page-title">Quiz Result - '. $results_data->quiz_name .'</h3>';
107
- echo '<a style="margin-right: 15px;" href="?page=mlw_quiz_results" class="button button-primary" title="Return to results">'. __( 'Back to Results', 'quiz-master-next' ) .'</a>';
108
- if ( ! is_null( $previous_results ) && $previous_results ) {
109
- echo "<a class='button button-primary' title='View Previous Result' href=\"?page=qsm_quiz_result_details&&result_id=" . intval( $previous_results ) . "\" ><span class='dashicons dashicons-arrow-left-alt2'></span></a> ";
110
- }else{
111
- echo "<a class='button button-primary' title='View Previous Result' href='#' disbled=disabled><span class='dashicons dashicons-arrow-left-alt2'></span></a> ";
112
- }
113
- if ( ! is_null( $next_results ) && $next_results ) {
114
- echo " <a class='button button-primary' title='View Next Result' href=\"?page=qsm_quiz_result_details&&result_id=" . intval( $next_results ) . "\" ><span class='dashicons dashicons-arrow-right-alt2'></span></a>";
115
- }else{
116
- echo " <a class='button button-primary' title='View Next Result' href='#' disabled=disabled><span class='dashicons dashicons-arrow-right-alt2'></span></a>";
117
- }
118
- echo '</div>';
119
 
120
- // Get template for admin results.
121
- $settings = (array) get_option( 'qmn-settings' );
122
- $new_template_result_detail = '1';
123
- $results["contact"] = array();
124
- if (isset($settings['new_template_result_detail'])){
125
- $new_template_result_detail = esc_attr( $settings['new_template_result_detail'] );
126
- }
127
- if( $new_template_result_detail == 1 ){
128
- $template = '';
129
  if ( is_serialized( $results_data->quiz_results ) && is_array( @unserialize( $results_data->quiz_results ) ) ) {
130
- $results_contact = unserialize($results_data->quiz_results);
131
- $template .= '<div class="overview-main-wrapper">';
132
- //User detail
133
- $template .= '<div class="candidate-detail-wrap overview-inner-wrap">';
134
- $template .= '<div id="submitdiv" class="postbox "><h2 class="hndle ui-sortable-handle"><span>User Detail</span></h2>';
135
- $template .= '<div class="inside">';
136
- if( isset( $results_contact['contact'] ) && is_array( $results_contact['contact'] ) && !empty( $results_contact['contact'] ) ){
137
- for ( $i = 0; $i < count( $results_contact["contact"] ); $i++ ) {
138
- $template .= '<span class="result-candidate-span"><label>'. $results_contact["contact"][ $i ]["label"] .'</label><span>'. $results_contact["contact"][ $i ]["value"] .'</span></span>';
139
- }
140
- }else{
141
- $template .= '<span class="result-candidate-span"><label>'. __( 'Name:', 'quiz-master-next' ) .'</label><span>'. $results_data->name .'</span></span>';
142
- $template .= '<span class="result-candidate-span"><label>'. __( 'Business:', 'quiz-master-next' ) .'</label><span>'. $results_data->business .'</span></span>';
143
- $template .= '<span class="result-candidate-span"><label>'. __( 'Phone:', 'quiz-master-next' ) .'</label><span>'. $results_data->phone .'</span></span>';
144
- $template .= '<span class="result-candidate-span"><label>'. __( 'Email:', 'quiz-master-next' ) .'</label><span>'. $results_data->email .'</span></span>';
145
- }
146
- $template .= '</div>';
147
- $template .= '</div>';
148
- $template .= '</div>';
149
- if( isset( $results_data->form_type ) && $results_data->form_type == 0 ){
150
- //Scoreboard design
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  $template .= '<div class="candidate-detail-wrap overview-inner-wrap">';
152
- $template .= '<div id="submitdiv" class="postbox "><h2 class="hndle ui-sortable-handle"><span>Scorecard</span></h2>';
153
- $template .= '<div class="inside">';
154
- $template .= '<span class="result-candidate-span"><label>'. __( 'Correct Answers:', 'quiz-master-next' ) .'</label><span>%AMOUNT_CORRECT% Out of %TOTAL_QUESTIONS%</span></span>';
155
- $template .= '<span class="result-candidate-span"><label>'. __( 'Points:', 'quiz-master-next' ) .'</label><span>%POINT_SCORE% </span></span>';
156
- $template .= '<span class="result-candidate-span"><label>'. __( 'Percentage:', 'quiz-master-next' ) .'</label><span>%CORRECT_SCORE%%</span></span>';
157
- $template .= '</div>';
 
 
 
 
 
 
158
  $template .= '</div>';
159
  $template .= '</div>';
160
- }
161
- //Timer design
162
- $template .= '<div class="overview-inner-wrap">';
163
- $template .= '<div id="submitdiv" class="postbox "><h2 class="hndle ui-sortable-handle"><span>Time Taken</span></h2>';
164
- $template .= '<div class="inside">';
165
- $template .= '<div class="timer-div-wrapper">';
166
- $mlw_qmn_results_array = @unserialize($results_data->quiz_results);
167
- if ( is_array( $mlw_qmn_results_array ) ) {
168
- $mlw_complete_hours = floor($mlw_qmn_results_array[0] / 3600);
169
- if ( $mlw_complete_hours > 0 ) {
170
- $template .= '<div>';
171
- $template .= '<span class="hours timer-span">' . str_pad($mlw_complete_hours, 2, '0', STR_PAD_LEFT) . '</span>';
172
- $hour_label = $mlw_complete_hours == 1 ? __( 'hour', 'quiz-master-next' ) : __( 'hours', 'quiz-master-next' );
173
- $template .= '<span class="timer-text">'. $hour_label .'</span>';
174
  $template .= '</div>';
175
- }else{
176
- $template .= '<div>';
177
- $template .= '<span class="hours timer-span">00</span>';
178
- $template .= '<span class="timer-text">hours</span>';
179
  $template .= '</div>';
180
  }
181
- $mlw_complete_minutes = floor(($mlw_qmn_results_array[0] % 3600) / 60);
182
- if ( $mlw_complete_minutes > 0 ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  $template .= '<div>';
184
- $template .= '<span class="minutes timer-span">' . str_pad($mlw_complete_minutes, 2, '0', STR_PAD_LEFT) . '</span>';
185
- $min_label = $mlw_complete_minutes == 1 ? __( 'minute', 'quiz-master-next' ) : __( 'minutes', 'quiz-master-next' );
186
- $template .= '<span class="timer-text">' . $min_label . '</span>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
  $template .= '</div>';
188
- } else {
189
- $template .= '<div>';
190
- $template .= '<span class="minutes timer-span">00</span>';
191
- $template .= '<span class="timer-text">minutes</span>';
192
  $template .= '</div>';
193
  }
194
- $mlw_complete_seconds = $mlw_qmn_results_array[0] % 60;
195
- $template .= '<div>';
196
- $template .= '<span class="seconds timer-span">' . str_pad($mlw_complete_seconds, 2, '0', STR_PAD_LEFT) . '</span>';
197
- $sec_label = $mlw_complete_seconds == 1 ? __( 'second', 'quiz-master-next' ) : __( 'seconds', 'quiz-master-next' );
198
- $template .= '<span class="timer-text">' . $sec_label . '</span>';
199
- $template .= '</div>';
200
- }
201
- $template .= '</div>';
202
- $template .= '</div>';
203
- $template .= '</div>';
204
- $template .= '</div>';
205
- $template .= '</div>';
206
- //Comment entered text
207
-
208
- if ( $comments_enabled == "0") {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
 
210
- $template .= '<div class="comment-inner-wrap" style="">';
211
- $template .= '<div id="submitdiv" class="postbox" ><h2 class="hndle ui-sortable-handle"><span>User Comments</span></h2>';
212
- $template .= '<div class="inside">';
213
- $template .= '%COMMENT_SECTION%';
214
- $template .= '</div>';
215
- $template .= '</div>';
216
- $template .= '</div>';
 
 
 
 
 
217
 
218
- }
219
- // //Response div
220
- $template .= '<div class="response-inner-wrap">';
221
- $template .= '<div id="submitdiv" class="postbox "><h2 class="hndle ui-sortable-handle"><span>Responses</span></h2>';
222
- $template .= '<div class="inside">';
223
- $template .= '%QUESTIONS_ANSWERS%';
224
- $template .= '</div>';
225
- $template .= '</div>';
226
- $template .= '</div>';
227
- }else{
228
- $template = 'Data is missing.';
229
- }
230
- }else{
231
- //Old template design
232
- if ( isset( $settings['results_details_template'] ) ) {
233
- $template = htmlspecialchars_decode( $settings['results_details_template'], ENT_QUOTES );
234
  } else {
235
- $template = "<h2>Quiz Results for %QUIZ_NAME%</h2>
236
- <p>%CONTACT_ALL%</p>
237
- <p>Name Provided: %USER_NAME%</p>
238
- <p>Business Provided: %USER_BUSINESS%</p>
239
- <p>Phone Provided: %USER_PHONE%</p>
240
- <p>Email Provided: %USER_EMAIL%</p>
241
- <p>Score Received: %AMOUNT_CORRECT%/%TOTAL_QUESTIONS% or %CORRECT_SCORE%% or %POINT_SCORE% points</p>
242
- <h2>Answers Provided:</h2>
243
- <p>The user took %TIMER% to complete quiz.</p>
244
- <p>Comments entered were: %COMMENT_SECTION%</p>
245
- <p>The answers were as follows:</p>
246
- %QUESTIONS_ANSWERS%";
247
  }
248
- }
249
-
250
- // Prepare responses array.
251
- $total_hidden_questions = 0;
252
- if ( is_serialized( $results_data->quiz_results ) && is_array( @unserialize( $results_data->quiz_results ) ) ) {
253
- $results = unserialize($results_data->quiz_results);
254
- $total_hidden_questions = isset($results['hidden_questions']) ? count($results['hidden_questions']) : 0;
255
- if ( ! isset( $results["contact"] ) ) {
256
- $results["contact"] = array();
257
  }
258
- } else {
259
- $template = str_replace( "%QUESTIONS_ANSWERS%" , $results_data->quiz_results, $template);
260
- $template = str_replace( "%TIMER%" , '', $template);
261
- $template = str_replace( "%COMMENT_SECTION%" , '', $template);
262
- $results = array(
263
- 0,
264
- array(),
265
- '',
266
- 'contact' => array()
267
- );
268
- }
269
-
270
- // Prepare full results array.
271
- $results_array = apply_filters( 'mlw_qmn_template_variable_results_array', array(
272
- 'quiz_id' => $results_data->quiz_id,
273
- 'quiz_name' => $results_data->quiz_name,
274
- 'quiz_system' => $results_data->quiz_system,
275
- 'form_type' => $results_data->form_type,
276
- 'user_name' => $results_data->name,
277
- 'user_business' => $results_data->business,
278
- 'user_email' => $results_data->email,
279
- 'user_phone' => $results_data->phone,
280
- 'user_id' => $results_data->user,
281
- 'timer' => isset($results[0]) ? $results[0] : 0,
282
- 'time_taken' => $results_data->time_taken,
283
- 'total_points' => $results_data->point_score,
284
- 'total_score' => $results_data->correct_score,
285
- 'total_correct' => $results_data->correct,
286
- 'total_questions' => $results_data->total - $total_hidden_questions,
287
- 'comments' => isset( $results[2] ) ? $results[2] : '',
288
- 'question_answers_array' => isset( $results[1] ) ? $results[1] : array(),
289
- 'contact' => $results["contact"],
290
- 'result_id' => $result_id,
291
- 'results' => $results,
292
- ) );
293
-
294
- // Pass through template variable filter
295
- $template = apply_filters( 'mlw_qmn_template_variable_results_page', $template, $results_array );
296
- $template = str_replace( "\n" , "<br>", $template );
297
- if( $new_template_result_detail == 0 ){
298
- echo '<div class="old_template_result_wrap">';
299
- }
300
-
301
- $is_allow_html = apply_filters('qsm_admin_results_details_page_allow_html', false);
302
- if ($is_allow_html) {
303
- echo $template;
304
- } else {
305
- echo wp_kses_post($template);
306
- }
307
- if( $new_template_result_detail == 0 ){
308
- echo '</div>';
309
- }
310
  // Hook for below admin results
311
- do_action( 'qsm_below_admin_results', $results_array );
312
  }
313
 
314
 
94
  $quiz_id = intval( $results_data->quiz_id );
95
  $mlwQuizMasterNext->pluginHelper->prepare_quiz( $quiz_id );
96
 
97
+ //Get the data for comments
98
+ $quiz_options = $mlwQuizMasterNext->quiz_settings->get_setting( 'quiz_options');
99
+ $comments_enabled = $quiz_options['comment_section'];
100
+
101
+ $previous_results = $wpdb->get_var( $wpdb->prepare("SELECT result_id FROM {$wpdb->prefix}mlw_results WHERE result_id = (SELECT MAX(result_id) FROM {$wpdb->prefix}mlw_results WHERE deleted = 0 AND result_id < %d)", $result_id));
102
+ $next_results = $wpdb->get_var( $wpdb->prepare("SELECT result_id FROM {$wpdb->prefix}mlw_results WHERE result_id = (SELECT MIN(result_id) FROM {$wpdb->prefix}mlw_results WHERE deleted = 0 AND result_id > %d)", $result_id));
103
 
104
  // If there is previous or next results, show buttons.
105
+ echo '<div style="text-align:right; margin-top: 20px; margin-bottom: 20px;">';
106
+ echo '<h3 class="result-page-title">Quiz Result - '. $results_data->quiz_name .'</h3>';
107
+ echo '<a style="margin-right: 15px;" href="?page=mlw_quiz_results" class="button button-primary" title="Return to results">'. __( 'Back to Results', 'quiz-master-next' ) .'</a>';
108
+ if ( ! is_null( $previous_results ) && $previous_results ) {
109
+ echo "<a class='button button-primary' title='View Previous Result' href=\"?page=qsm_quiz_result_details&&result_id=" . intval( $previous_results ) . "\" ><span class='dashicons dashicons-arrow-left-alt2'></span></a> ";
110
+ }else{
111
+ echo "<a class='button button-primary' title='View Previous Result' href='#' disbled=disabled><span class='dashicons dashicons-arrow-left-alt2'></span></a> ";
112
+ }
113
+ if ( ! is_null( $next_results ) && $next_results ) {
114
+ echo " <a class='button button-primary' title='View Next Result' href=\"?page=qsm_quiz_result_details&&result_id=" . intval( $next_results ) . "\" ><span class='dashicons dashicons-arrow-right-alt2'></span></a>";
115
+ }else{
116
+ echo " <a class='button button-primary' title='View Next Result' href='#' disabled=disabled><span class='dashicons dashicons-arrow-right-alt2'></span></a>";
117
+ }
118
+ echo '</div>';
119
 
120
+ // Prepare responses array.
121
+ $total_hidden_questions = 0;
 
 
 
 
 
 
 
122
  if ( is_serialized( $results_data->quiz_results ) && is_array( @unserialize( $results_data->quiz_results ) ) ) {
123
+ $results = unserialize($results_data->quiz_results);
124
+ $total_hidden_questions = isset($results['hidden_questions']) ? count($results['hidden_questions']) : 0;
125
+ if ( ! isset( $results["contact"] ) ) {
126
+ $results["contact"] = array();
127
+ }
128
+ } else {
129
+ $results = array(
130
+ 0,
131
+ array(),
132
+ '',
133
+ 'contact' => array()
134
+ );
135
+ }
136
+
137
+ // Prepare full results array.
138
+ $results_array = apply_filters( 'mlw_qmn_template_variable_results_array', array(
139
+ 'quiz_id' => $results_data->quiz_id,
140
+ 'quiz_name' => $results_data->quiz_name,
141
+ 'quiz_system' => $results_data->quiz_system,
142
+ 'form_type' => $results_data->form_type,
143
+ 'user_name' => $results_data->name,
144
+ 'user_business' => $results_data->business,
145
+ 'user_email' => $results_data->email,
146
+ 'user_phone' => $results_data->phone,
147
+ 'user_id' => $results_data->user,
148
+ 'timer' => isset($results[0]) ? $results[0] : 0,
149
+ 'time_taken' => $results_data->time_taken,
150
+ 'total_points' => $results_data->point_score,
151
+ 'total_score' => $results_data->correct_score,
152
+ 'total_correct' => $results_data->correct,
153
+ 'total_questions' => $results_data->total - $total_hidden_questions,
154
+ 'comments' => isset( $results[2] ) ? $results[2] : '',
155
+ 'question_answers_array' => isset( $results[1] ) ? $results[1] : array(),
156
+ 'contact' => $results["contact"],
157
+ 'result_id' => $result_id,
158
+ 'results' => $results,
159
+ ) );
160
+
161
+ //convert to preferred date format
162
+ $results_array = $mlwQuizMasterNext->pluginHelper->convert_to_preferred_date_format($results_array);
163
+
164
+ // Get template for admin results.
165
+ $settings = (array) get_option( 'qmn-settings' );
166
+ $new_template_result_detail = '1';
167
+ if (isset($settings['new_template_result_detail'])){
168
+ $new_template_result_detail = esc_attr( $settings['new_template_result_detail'] );
169
+ }
170
+ if( $new_template_result_detail == 1 ){
171
+ $template = '';
172
+ if ( is_serialized( $results_data->quiz_results ) && is_array( @unserialize( $results_data->quiz_results ) ) ) {
173
+ $span_start = '<span class="result-candidate-span"><label>';
174
+ $span_end = '</label><span>';
175
+ $spanend = '</span></span>';
176
+ $template .= '<div class="overview-main-wrapper">';
177
+ //User detail
178
  $template .= '<div class="candidate-detail-wrap overview-inner-wrap">';
179
+ $template .= '<div id="submitdiv" class="postbox "><h2 class="hndle ui-sortable-handle"><span>User Detail</span></h2>';
180
+ $template .= '<div class="inside">';
181
+ if( isset( $results_array['contact'] ) && is_array( $results_array['contact'] ) && !empty( $results_array['contact'] ) ){
182
+ for ( $i = 0; $i < count( $results_array["contact"] ); $i++ ) {
183
+ $template .= $span_start. $results_array["contact"][ $i ]["label"] .$span_end. $results_array["contact"][ $i ]["value"] .$spanend;
184
+ }
185
+ }else{
186
+ $template .= $span_start. __( 'Name:', 'quiz-master-next' ) .$span_end. $results_data->name .$spanend;
187
+ $template .= $span_start. __( 'Business:', 'quiz-master-next' ) .$span_end. $results_data->business .$spanend;
188
+ $template .= $span_start. __( 'Phone:', 'quiz-master-next' ) .$span_end. $results_data->phone .$spanend;
189
+ $template .= $span_start. __( 'Email:', 'quiz-master-next' ) .$span_end. $results_data->email .$spanend;
190
+ }
191
  $template .= '</div>';
192
  $template .= '</div>';
193
+ $template .= '</div>';
194
+ if( isset( $results_data->form_type ) && $results_data->form_type == 0 ){
195
+ //Scoreboard design
196
+ $template .= '<div class="candidate-detail-wrap overview-inner-wrap">';
197
+ $template .= '<div id="submitdiv" class="postbox "><h2 class="hndle ui-sortable-handle"><span>Scorecard</span></h2>';
198
+ $template .= '<div class="inside">';
199
+ $template .= $span_start. __( 'Correct Answers:', 'quiz-master-next' ) .'</label><span>%AMOUNT_CORRECT% Out of %TOTAL_QUESTIONS%</span></span>';
200
+ $template .= $span_start. __( 'Points:', 'quiz-master-next' ) .'</label><span>%POINT_SCORE% </span></span>';
201
+ $template .= $span_start. __( 'Percentage:', 'quiz-master-next' ) .'</label><span>%CORRECT_SCORE%%</span></span>';
202
+ $template .= '</div>';
 
 
 
 
203
  $template .= '</div>';
 
 
 
 
204
  $template .= '</div>';
205
  }
206
+ //Timer design
207
+ $template .= '<div class="overview-inner-wrap">';
208
+ $template .= '<div id="submitdiv" class="postbox "><h2 class="hndle ui-sortable-handle"><span>Time Taken</span></h2>';
209
+ $template .= '<div class="inside">';
210
+ $template .= '<div class="timer-div-wrapper">';
211
+ $mlw_qmn_results_array = @unserialize($results_data->quiz_results);
212
+ if ( is_array( $mlw_qmn_results_array ) ) {
213
+ $mlw_complete_hours = floor($mlw_qmn_results_array[0] / 3600);
214
+ if ( $mlw_complete_hours > 0 ) {
215
+ $template .= '<div>';
216
+ $template .= '<span class="hours timer-span">' . str_pad($mlw_complete_hours, 2, '0', STR_PAD_LEFT) . '</span>';
217
+ $hour_label = $mlw_complete_hours == 1 ? __( 'hour', 'quiz-master-next' ) : __( 'hours', 'quiz-master-next' );
218
+ $template .= '<span class="timer-text">'. $hour_label .'</span>';
219
+ $template .= '</div>';
220
+ }else{
221
+ $template .= '<div>';
222
+ $template .= '<span class="hours timer-span">00</span>';
223
+ $template .= '<span class="timer-text">hours</span>';
224
+ $template .= '</div>';
225
+ }
226
+ $mlw_complete_minutes = floor(($mlw_qmn_results_array[0] % 3600) / 60);
227
+ if ( $mlw_complete_minutes > 0 ) {
228
+ $template .= '<div>';
229
+ $template .= '<span class="minutes timer-span">' . str_pad($mlw_complete_minutes, 2, '0', STR_PAD_LEFT) . '</span>';
230
+ $min_label = $mlw_complete_minutes == 1 ? __( 'minute', 'quiz-master-next' ) : __( 'minutes', 'quiz-master-next' );
231
+ $template .= '<span class="timer-text">' . $min_label . '</span>';
232
+ $template .= '</div>';
233
+ } else {
234
+ $template .= '<div>';
235
+ $template .= '<span class="minutes timer-span">00</span>';
236
+ $template .= '<span class="timer-text">minutes</span>';
237
+ $template .= '</div>';
238
+ }
239
+ $mlw_complete_seconds = $mlw_qmn_results_array[0] % 60;
240
  $template .= '<div>';
241
+ $template .= '<span class="seconds timer-span">' . str_pad($mlw_complete_seconds, 2, '0', STR_PAD_LEFT) . '</span>';
242
+ $sec_label = $mlw_complete_seconds == 1 ? __( 'second', 'quiz-master-next' ) : __( 'seconds', 'quiz-master-next' );
243
+ $template .= '<span class="timer-text">' . $sec_label . '</span>';
244
+ $template .= '</div>';
245
+ }
246
+ $template .= '</div>';
247
+ $template .= '</div>';
248
+ $template .= '</div>';
249
+ $template .= '</div>';
250
+ $template .= '</div>';
251
+ //Comment entered text
252
+
253
+ if ( $comments_enabled == "0") {
254
+
255
+ $template .= '<div class="comment-inner-wrap" style="">';
256
+ $template .= '<div id="submitdiv" class="postbox" ><h2 class="hndle ui-sortable-handle"><span>User Comments</span></h2>';
257
+ $template .= '<div class="inside">';
258
+ $template .= '%COMMENT_SECTION%';
259
+ $template .= '</div>';
260
  $template .= '</div>';
 
 
 
 
261
  $template .= '</div>';
262
  }
263
+ //Response div
264
+ $template .= '<div class="response-inner-wrap">';
265
+ $template .= '<div id="submitdiv" class="postbox "><h2 class="hndle ui-sortable-handle"><span>Responses</span></h2>';
266
+ $template .= '<div class="inside">';
267
+ $template .= '%QUESTIONS_ANSWERS%';
268
+ $template .= '</div>';
269
+ $template .= '</div>';
270
+ $template .= '</div>';
271
+ }else {
272
+ $template = 'Data is missing.';
273
+ }
274
+ }else{
275
+ //Old template design
276
+ if ( isset( $settings['results_details_template'] ) ) {
277
+ $template = htmlspecialchars_decode( $settings['results_details_template'], ENT_QUOTES );
278
+ } else {
279
+ $template = "<h2>Quiz Results for %QUIZ_NAME%</h2>
280
+ <p>%CONTACT_ALL%</p>
281
+ <p>Name Provided: %USER_NAME%</p>
282
+ <p>Business Provided: %USER_BUSINESS%</p>
283
+ <p>Phone Provided: %USER_PHONE%</p>
284
+ <p>Email Provided: %USER_EMAIL%</p>
285
+ <p>Score Received: %AMOUNT_CORRECT%/%TOTAL_QUESTIONS% or %CORRECT_SCORE%% or %POINT_SCORE% points</p>
286
+ <h2>Answers Provided:</h2>
287
+ <p>The user took %TIMER% to complete quiz.</p>
288
+ <p>Comments entered were: %COMMENT_SECTION%</p>
289
+ <p>The answers were as follows:</p>
290
+ %QUESTIONS_ANSWERS%";
291
+ }
292
+ }
293
 
294
+ if ( !is_serialized( $results_data->quiz_results ) && !is_array( @unserialize( $results_data->quiz_results ) ) ) {
295
+ $template = str_replace( "%QUESTIONS_ANSWERS%" , $results_data->quiz_results, $template);
296
+ $template = str_replace( "%TIMER%" , '', $template);
297
+ $template = str_replace( "%COMMENT_SECTION%" , '', $template);
298
+ }
299
+
300
+ // Pass through template variable filter
301
+ $template = apply_filters( 'mlw_qmn_template_variable_results_page', $template, $results_array );
302
+ $template = str_replace( "\n" , "<br>", $template );
303
+ if( $new_template_result_detail == 0 ){
304
+ echo '<div class="old_template_result_wrap">';
305
+ }
306
 
307
+ $is_allow_html = apply_filters('qsm_admin_results_details_page_allow_html', false);
308
+ if ($is_allow_html) {
309
+ echo $template;
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  } else {
311
+ echo wp_kses_post($template);
 
 
 
 
 
 
 
 
 
 
 
312
  }
313
+ if( $new_template_result_detail == 0 ){
314
+ echo '</div>';
 
 
 
 
 
 
 
315
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  // Hook for below admin results
317
+ do_action( 'qsm_below_admin_results', $results_array );
318
  }
319
 
320
 
php/admin/settings-page.php CHANGED
@@ -111,7 +111,8 @@ class QMNGlobalSettingsPage {
111
  add_settings_field( 'disable-description-on-quiz-result-page', __( 'Disable description on quiz result page?', 'quiz-master-next' ), array( $this, 'qsm_global_disable_description_on_quiz_result_page' ), 'qsm_default_global_option', 'qmn-global-section' );
112
  add_settings_field( 'disable-scroll-on-next-and-previous-button-click', __( 'Disable scroll on next and previous button click?', 'quiz-master-next' ), array( $this, 'qsm_global_disable_scroll_on_next_and_previous_button_click' ), 'qsm_default_global_option', 'qmn-global-section' );
113
  add_settings_field( 'quiz-animation', __( 'Quiz Animation', 'quiz-master-next' ), array( $this, 'qsm_global_quiz_animation' ), 'qsm_default_global_option', 'qmn-global-section' );
114
- add_settings_field( 'logo-url', __( 'Logo URL', 'quiz-master-next' ), array( $this, 'qsm_global_logo_url' ), 'qsm_default_global_option', 'qmn-global-section' );
 
115
  global $globalQuizsetting;
116
  $globalQuizsetting=get_option( 'qsm-quiz-settings' );
117
 
@@ -1108,6 +1109,20 @@ class QMNGlobalSettingsPage {
1108
  <br>
1109
  </fieldset>';
1110
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1111
 
1112
 
1113
  }
111
  add_settings_field( 'disable-description-on-quiz-result-page', __( 'Disable description on quiz result page?', 'quiz-master-next' ), array( $this, 'qsm_global_disable_description_on_quiz_result_page' ), 'qsm_default_global_option', 'qmn-global-section' );
112
  add_settings_field( 'disable-scroll-on-next-and-previous-button-click', __( 'Disable scroll on next and previous button click?', 'quiz-master-next' ), array( $this, 'qsm_global_disable_scroll_on_next_and_previous_button_click' ), 'qsm_default_global_option', 'qmn-global-section' );
113
  add_settings_field( 'quiz-animation', __( 'Quiz Animation', 'quiz-master-next' ), array( $this, 'qsm_global_quiz_animation' ), 'qsm_default_global_option', 'qmn-global-section' );
114
+ add_settings_field( 'logo-url', __( 'Logo URL', 'quiz-master-next' ), array( $this, 'qsm_global_logo_url' ), 'qsm_default_global_option', 'qmn-global-section' );
115
+ add_settings_field( 'preferred_date_format', __( 'Preferred Date Format', 'quiz-master-next' ), array( $this, 'preferred_date_format' ), 'qsm_default_global_option', 'qmn-global-section' );
116
  global $globalQuizsetting;
117
  $globalQuizsetting=get_option( 'qsm-quiz-settings' );
118
 
1109
  <br>
1110
  </fieldset>';
1111
  }
1112
+
1113
+ /**
1114
+ * Generates quiz global field for preferred date format
1115
+ *
1116
+ * @since x.x.x
1117
+ * @return void
1118
+ */
1119
+ public function preferred_date_format() {
1120
+
1121
+ global $globalQuizsetting;
1122
+ $preferred_date_format =(isset($globalQuizsetting['preferred_date_format'])? $globalQuizsetting['preferred_date_format'] : get_option( 'date_format' ));
1123
+ echo '<input type="text" id="preferred_date_format" name="qsm-quiz-settings[preferred_date_format]" value="'.$preferred_date_format.'">';
1124
+ echo '<span class="qsm-opt-desc">Set your preferred date format.</span>';
1125
+ }
1126
 
1127
 
1128
  }
php/classes/class-qmn-plugin-helper.php CHANGED
@@ -408,6 +408,11 @@ class QMNPluginHelper
408
  shuffle($answers);
409
  update_post_meta($question_id,'qsm_random_quetion_answer',$answers);
410
  }
 
 
 
 
 
411
  foreach ($this->question_types as $type) {
412
  if ($type["slug"] == strtolower(str_replace(" ", "-", $slug))) {
413
  if ($type["graded"]) {
@@ -721,4 +726,104 @@ class QMNPluginHelper
721
 
722
  }
723
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
724
  }
408
  shuffle($answers);
409
  update_post_meta($question_id,'qsm_random_quetion_answer',$answers);
410
  }
411
+ /**
412
+ * Filter Answers of specific question before display
413
+ */
414
+ $answers = apply_filters('qsm_single_question_answers', $answers, $question, $quiz_options);
415
+
416
  foreach ($this->question_types as $type) {
417
  if ($type["slug"] == strtolower(str_replace(" ", "-", $slug))) {
418
  if ($type["graded"]) {
726
 
727
  }
728
 
729
+ /**
730
+ * converts dates into preferred date format
731
+ *
732
+ * @since 7.3.3
733
+ * @param array $qsm_qna_array The array of results for the quiz
734
+ * @uses QMNQuizManager:submit_results() submits and displays results
735
+ * @uses qsm_generate_results_details_tab() generates admin results page
736
+ * @return array $qsm_qna_array date formatted array of results for the quiz
737
+ */
738
+
739
+ public function convert_to_preferred_date_format($qsm_qna_array){
740
+ global $mlwQuizMasterNext;
741
+ $quiz_options= $mlwQuizMasterNext->quiz_settings->get_quiz_options();
742
+ $qsm_quiz_settings = unserialize($quiz_options->quiz_settings);
743
+ $qsm_quiz_options=unserialize($qsm_quiz_settings['quiz_options']);
744
+ $qsm_global_settings = get_option( 'qsm-quiz-settings' );
745
+ //check if preferred date format is set at quiz level or plugin level. Default to WP date format otherwise
746
+ if (isset($qsm_quiz_options['preferred_date_format'])){
747
+ $preferred_date_format= $qsm_quiz_options['preferred_date_format'];
748
+ } elseif ( isset($qsm_global_settings['preferred_date_format']) ){
749
+ $preferred_date_format= isset($qsm_global_settings['preferred_date_format']);
750
+ }else{
751
+ $preferred_date_format= get_option( 'date_format');
752
+ }
753
+ //filter date format
754
+ $GLOBALS['qsm_date_format']= apply_filters('qms_preferred_date_format', $preferred_date_format);
755
+
756
+ $qsm_qna_array = $this->convert_contacts_to_preferred_date_format($qsm_qna_array);
757
+ $qsm_qna_array = $this->convert_answers_to_preferred_date_format($qsm_qna_array);
758
+ $this->convert_questions_to_preferred_date_format();
759
+
760
+ return $qsm_qna_array;
761
+ }
762
+
763
+ /**
764
+ * converts contacts into preferred date format
765
+ *
766
+ * @since 7.3.3
767
+ * @param array $qsm_qna_array The array of results for the quiz
768
+ * @uses convert_to_preferred_date_format()
769
+ * @return array $qsm_qna_array date formatted array of results for the quiz
770
+ */
771
+
772
+ public function convert_contacts_to_preferred_date_format($qsm_qna_array){
773
+
774
+ $qsm_contact_array = $qsm_qna_array['contact'];
775
+ foreach ( $qsm_contact_array as $qsm_contact_id => $qsm_contact){
776
+ if ("date" === $qsm_contact['type'] && null!==$GLOBALS['qsm_date_format']){
777
+ $qsm_qna_array['contact'][$qsm_contact_id]['value']=date_i18n( $GLOBALS['qsm_date_format'], strtotime(($qsm_contact['value'])));
778
+ }
779
+ }
780
+ return $qsm_qna_array;
781
+ }
782
+
783
+ /**
784
+ * converts answers into preferred date format
785
+ *
786
+ * @since 7.3.3
787
+ * @param array $qsm_qna_array The array of results for the quiz
788
+ * @uses convert_to_preferred_date_format()
789
+ * @return array $qsm_qna_array date formatted array of results for the quiz
790
+ */
791
+
792
+ public function convert_answers_to_preferred_date_format($qsm_qna_array){
793
+
794
+ $qsm_qna_list = $qsm_qna_array['question_answers_array'];
795
+ foreach ($qsm_qna_list as $qna_id => $qna){
796
+ if ("12"===$qna['question_type'] && null!==$GLOBALS['qsm_date_format']){
797
+ $qsm_qna_array['question_answers_array'][$qna_id]['1']= date_i18n( $GLOBALS['qsm_date_format'], strtotime(($qna['1'])));
798
+ $qsm_qna_array['question_answers_array'][$qna_id]['2']= date_i18n( $GLOBALS['qsm_date_format'], strtotime(($qna['2'])));
799
+ }
800
+ }
801
+ return $qsm_qna_array;
802
+ }
803
+
804
+ /**
805
+ * converts questions into preferred date format
806
+ *
807
+ * @since 7.3.3
808
+ * @param array $qsm_qna_array The array of results for the quiz
809
+ * @uses convert_to_preferred_date_format()
810
+ * @return array $qsm_qna_array date formatted array of results for the quiz
811
+ */
812
+
813
+ public function convert_questions_to_preferred_date_format(){
814
+
815
+ if(!function_exists('qsm_convert_question_array_date_format')){
816
+ function qsm_convert_question_array_date_format($questions){
817
+ foreach ($questions as $question_id => $question_to_convert){
818
+ if("12"=== $question_to_convert['question_type_new']){
819
+ foreach ($question_to_convert['answers'] as $answer_id => $answer_value){
820
+ $questions[$question_id]['answers'][$answer_id][0]= date_i18n( $GLOBALS['qsm_date_format'], strtotime($answer_value[0]));
821
+ }
822
+ }
823
+ }
824
+ return $questions;
825
+ }
826
+ }
827
+ add_filter( 'qsm_load_questions_by_pages','qsm_convert_question_array_date_format');
828
+ }
829
  }
php/classes/class-qmn-quiz-manager.php CHANGED
@@ -92,6 +92,7 @@ class QMNQuizManager {
92
  $mimes[] = $value;
93
  }
94
  }
 
95
  }
96
  $json = array();
97
  $file_name = sanitize_file_name( $_FILES['file']['name'] );
@@ -281,6 +282,10 @@ class QMNQuizManager {
281
 
282
  $return_display = '';
283
  $qmn_quiz_options = $mlwQuizMasterNext->quiz_settings->get_quiz_options();
 
 
 
 
284
 
285
  // If quiz options isn't found, stop function.
286
  if ( is_null( $qmn_quiz_options ) || empty( $qmn_quiz_options->quiz_name ) ) {
@@ -542,7 +547,10 @@ public function load_questions( $quiz_id, $quiz_options, $is_quiz_page, $questio
542
  }
543
  }
544
  foreach ($term_data as $tv) {
545
- $random = array_merge($random, array_slice($tv, 0, $quiz_options->question_per_category));
 
 
 
546
  }
547
  }
548
  $question_ids = array_unique( $random );
@@ -1452,6 +1460,10 @@ public function load_questions( $quiz_id, $quiz_options, $is_quiz_page, $questio
1452
  }
1453
  $qmn_array_for_variables['result_id'] = $results_id;
1454
 
 
 
 
 
1455
  // Determines redirect/results page.
1456
  $results_pages = $this->display_results_text( $qmn_quiz_options, $qmn_array_for_variables );
1457
  $result_display .= $results_pages['display'];
@@ -2225,7 +2237,7 @@ public function load_questions( $quiz_id, $quiz_options, $is_quiz_page, $questio
2225
  public function qsm_convert_editor_text_to_shortcode( $editor_text ) {
2226
  global $wp_embed;
2227
  $editor_text = $wp_embed->run_shortcode( $editor_text );
2228
- $editor_text = preg_replace( '/\s*[a-zA-Z\/\/:\.]*youtube.com\/watch\?v=([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i', '<iframe width="420" height="315" src="//www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>', $editor_text );
2229
  $allowed_html = wp_kses_allowed_html( 'post' );
2230
  return do_shortcode( wp_kses( $editor_text, $allowed_html ) );
2231
  }
92
  $mimes[] = $value;
93
  }
94
  }
95
+ $mimes = apply_filters('qsm_file_upload_mime_type',$mimes);
96
  }
97
  $json = array();
98
  $file_name = sanitize_file_name( $_FILES['file']['name'] );
282
 
283
  $return_display = '';
284
  $qmn_quiz_options = $mlwQuizMasterNext->quiz_settings->get_quiz_options();
285
+ /**
286
+ * Filter Quiz Options before Quiz Display
287
+ */
288
+ $qmn_quiz_options = apply_filters('qsm_shortcode_quiz_options', $qmn_quiz_options);
289
 
290
  // If quiz options isn't found, stop function.
291
  if ( is_null( $qmn_quiz_options ) || empty( $qmn_quiz_options->quiz_name ) ) {
547
  }
548
  }
549
  foreach ($term_data as $tv) {
550
+ if ( 1 == $quiz_options->randomness_order || 2 == $quiz_options->randomness_order ) {
551
+ shuffle($tv);
552
+ }
553
+ $random = array_merge($random, array_slice(array_unique($tv), 0, $quiz_options->question_per_category));
554
  }
555
  }
556
  $question_ids = array_unique( $random );
1460
  }
1461
  $qmn_array_for_variables['result_id'] = $results_id;
1462
 
1463
+ // Converts date to the preferred format
1464
+ global $mlwQuizMasterNext;
1465
+ $qmn_array_for_variables = $mlwQuizMasterNext->pluginHelper->convert_to_preferred_date_format($qmn_array_for_variables);
1466
+
1467
  // Determines redirect/results page.
1468
  $results_pages = $this->display_results_text( $qmn_quiz_options, $qmn_array_for_variables );
1469
  $result_display .= $results_pages['display'];
2237
  public function qsm_convert_editor_text_to_shortcode( $editor_text ) {
2238
  global $wp_embed;
2239
  $editor_text = $wp_embed->run_shortcode( $editor_text );
2240
+ $editor_text = preg_replace( '/\s*[\w\/:\.]*youtube.com\/watch\?v=([\w]+)([\w\*\-\?\&\;\%\=\.]*)/i', '<iframe width="420" height="315" src="//www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>', $editor_text );
2241
  $allowed_html = wp_kses_allowed_html( 'post' );
2242
  return do_shortcode( wp_kses( $editor_text, $allowed_html ) );
2243
  }
php/classes/class-qsm-contact-manager.php CHANGED
@@ -156,6 +156,16 @@ class QSM_Contact_Manager {
156
  <?php
157
  break;
158
 
 
 
 
 
 
 
 
 
 
 
159
  default:
160
  do_action('qsm_extra_contact_filed' ,$fields, $options);
161
  break;
@@ -226,6 +236,9 @@ class QSM_Contact_Manager {
226
  if ( isset( $fields[ $i ]['use'] ) ) {
227
  $field_array['use'] = $fields[ $i ]['use'];
228
  }
 
 
 
229
  $responses[] = $field_array;
230
  }
231
  }
156
  <?php
157
  break;
158
 
159
+ case 'date':
160
+ if ( ( 'true' === $fields[ $i ]["required"] || true === $fields[ $i ]["required"] ) && ! $fields_hidden ) {
161
+ $class = 'mlwRequiredAccept qsm_required_accept';
162
+ }
163
+ ?>
164
+ <span class='mlw_qmn_question qsm_question'><?php echo $fields[ $i ]['label']; ?></span>
165
+ <input type='date' id='contact_field_<?php echo $i; ?>' class='<?php echo esc_attr( $class ); ?>' name='contact_field_<?php echo $i; ?>' value='' />
166
+ <?php
167
+ break;
168
+
169
  default:
170
  do_action('qsm_extra_contact_filed' ,$fields, $options);
171
  break;
236
  if ( isset( $fields[ $i ]['use'] ) ) {
237
  $field_array['use'] = $fields[ $i ]['use'];
238
  }
239
+ if ( isset( $fields[ $i ]['type'] ) ) {
240
+ $field_array['type'] = $fields[ $i ]['type'];
241
+ }
242
  $responses[] = $field_array;
243
  }
244
  }
php/classes/class-qsm-emails.php CHANGED
@@ -171,11 +171,27 @@ class QSM_Emails {
171
  $subject = apply_filters( 'mlw_qmn_template_variable_results_page', $subject, $response_data );
172
 
173
  // Prepares our content.
174
- $content = htmlspecialchars_decode( $content, ENT_QUOTES );
175
- $response_data['email_template_array'] = true;
 
 
 
176
  $content = apply_filters( 'mlw_qmn_template_variable_results_page', $content, $response_data );
177
  $content = str_replace( '<br/>', '<br>', $content );
178
  $content = str_replace( '<br />', '<br>', $content );
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  $content = html_entity_decode( $content );
180
 
181
  // Prepares our from name and email.
171
  $subject = apply_filters( 'mlw_qmn_template_variable_results_page', $subject, $response_data );
172
 
173
  // Prepares our content.
174
+ $incorrect_answer="<span style='color:red;display:block;margin-bottom:5px;'>&#x2715;";
175
+ $correct_answer="<span style='color:green;display:block;margin-bottom:5px;'>&#10003;";
176
+ $simple_answer="<span style='color:#808080;display:block;margin-bottom:5px;'>&#8226;";
177
+ $content = htmlspecialchars_decode( $content, ENT_QUOTES );
178
+ $response_data['email_template_array'] = true;
179
  $content = apply_filters( 'mlw_qmn_template_variable_results_page', $content, $response_data );
180
  $content = str_replace( '<br/>', '<br>', $content );
181
  $content = str_replace( '<br />', '<br>', $content );
182
+ $content = str_replace( "<span class='qmn_user_incorrect_answer'>", "<span style='color:red'>&#x2715; ", $content );
183
+ $content = str_replace( "<span class='qmn_user_correct_answer'>", "<span style='color:green'>&#10003; ", $content );
184
+ $content = str_replace( '<span class="qsm-text-wrong-option qmn_image_option">', "$incorrect_answer ", $content );
185
+ $content = str_replace( '<span class="qsm-text-correct-option qmn_image_option">', "$correct_answer ", $content );
186
+ $content = str_replace( '<span class="qsm-text-correct-option qsm-text-user-correct-answer qmn_image_option">', "$correct_answer ", $content );
187
+ $content = str_replace( '<span class="qsm-text-simple-option qmn_image_option">', "$simple_answer ", $content );
188
+ $content = str_replace( '<span class="qsm-text-correct-option qsm-text-user-correct-answer ">', "$correct_answer ", $content );
189
+ $content = str_replace( '<span class="qsm-text-simple-option ">', "$simple_answer ", $content );
190
+ $content = str_replace( '<span class="qsm-text-wrong-option ">', "$incorrect_answer ", $content );
191
+ $content = str_replace( '<span class="qsm-text-correct-option ">', "$correct_answer ", $content );
192
+ $content = str_replace( '<span class="qmn_user_incorrect_answer">', "$incorrect_answer ", $content );
193
+ $content = str_replace( '<span class="qmn_user_incorrect_answer">', "$correct_answer ", $content );
194
+ $content = str_replace( "class='qmn_question_answer", "style='margin-bottom:30px' class='", $content );
195
  $content = html_entity_decode( $content );
196
 
197
  // Prepares our from name and email.
php/classes/class-qsm-install.php CHANGED
@@ -709,6 +709,16 @@ class QSM_Install {
709
  'help' => __( 'If left blank, this will default to QSM logo', 'quiz-master-next' ),
710
  );
711
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
 
 
 
 
 
 
 
 
 
 
712
  do_action( 'qsm_extra_setting_fields' );
713
  // Setting for animation
714
  $field_array = array(
709
  'help' => __( 'If left blank, this will default to QSM logo', 'quiz-master-next' ),
710
  );
711
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
712
+
713
+ // Registers Preferred date type settings in the quiz options
714
+ $field_array = array(
715
+ 'id' => 'preferred_date_format',
716
+ 'label' => __( 'Preferred Date Format', 'quiz-master-next' ),
717
+ 'type' => 'text',
718
+ 'default' => isset(get_option( 'qsm-quiz-settings' )['preferred_date_format'])? get_option( 'qsm-quiz-settings' )['preferred_date_format'] : get_option( 'date_format'),
719
+ 'help' => __( 'Overrides global settings for preferred date format', 'quiz-master-next' ),
720
+ );
721
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
722
  do_action( 'qsm_extra_setting_fields' );
723
  // Setting for animation
724
  $field_array = array(
php/classes/class-qsm-questions.php CHANGED
@@ -93,7 +93,7 @@ class QSM_Questions {
93
  foreach ( $question_array as $question ) {
94
  $multicategories = self::get_question_categories($question['question_id']);
95
  //get_question_categories
96
-
97
  $question['multicategories'] = isset($multicategories['category_tree']) && !empty($multicategories['category_tree'] ) ? array_keys($multicategories['category_name']) : array();
98
  $question['multicategoriesobject'] = isset($multicategories['category_tree']) && !empty($multicategories['category_tree'] ) ? $multicategories['category_tree'] : array();
99
  // Prepare answers.
@@ -283,9 +283,15 @@ class QSM_Questions {
283
  $answers[ $key ] = $answers_array;
284
  }
285
 
 
 
 
 
 
 
286
  $values = array(
287
  'quiz_id' => intval( $data['quiz_id'] ),
288
- 'question_name' => trim( preg_replace( '/\s+/', ' ', htmlspecialchars( wp_kses_post( $data['name'] ), ENT_QUOTES ) ) ),
289
  'answer_array' => serialize( $answers ),
290
  'question_answer_info' => $data['answer_info'],
291
  'comments' => htmlspecialchars( $data['comments'], ENT_QUOTES ),
@@ -312,7 +318,6 @@ class QSM_Questions {
312
  '%d',
313
  );
314
 
315
- $question_id = intval($data['ID']);
316
  if ( $is_creating ) {
317
  $results = $wpdb->insert(
318
  $wpdb->prefix . 'mlw_questions',
@@ -321,6 +326,7 @@ class QSM_Questions {
321
  );
322
  $question_id = $wpdb->insert_id;
323
  } else {
 
324
  $results = $wpdb->update(
325
  $wpdb->prefix . 'mlw_questions',
326
  $values,
@@ -335,7 +341,7 @@ class QSM_Questions {
335
  $mlwQuizMasterNext->log_manager->add( 'Error when creating/saving question', $msg, 0, 'error' );
336
  throw new Exception( $msg );
337
  }
338
-
339
  /**
340
  * Process Question Categories
341
  */
@@ -367,31 +373,73 @@ class QSM_Questions {
367
  global $wpdb;
368
  $categories = array();
369
  if ( 0 !== $quiz_id ) {
370
- $question_terms = $wpdb->get_results( "SELECT `term_id` FROM `{$wpdb->prefix}mlw_question_terms` WHERE `quiz_id`='{$quiz_id}' AND `taxonomy`='qsm_category'", ARRAY_A );
371
- if ( ! empty( $question_terms ) ) {
372
- $term_ids = array_unique( array_column( $question_terms, 'term_id' ) );
373
- if ( ! empty( $term_ids ) ) {
374
- $categories_names = array();
375
- $categories_tree = array();
376
- $terms = get_terms( array( 'taxonomy' => 'qsm_category', 'include' => array_unique( $term_ids ), 'hide_empty' => false, 'orderby' => '', 'order' => '' ) );
377
- if ( ! empty( $terms ) ) {
378
- foreach ( $terms as $tax ) {
379
- $categories_names[$tax->term_id] = $tax->name;
380
- $taxs[$tax->parent][] = $tax;
381
- }
382
- $categories_tree = self::create_terms_tree( $taxs, $taxs[0] );
383
- }
384
- $categories = array(
385
- 'list' => $categories_names,
386
- 'tree' => $categories_tree,
387
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
388
  }
389
  }
390
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
391
  return $categories;
392
  }
 
393
  /**
394
- * Get categories for a Question
395
  *
396
  * @since 7.2.1
397
  * @param int $quiz_id The ID of the quiz.
@@ -400,21 +448,21 @@ class QSM_Questions {
400
  public static function get_question_categories( $question_id = 0 ) {
401
  global $wpdb;
402
  $categories_tree = array();
403
- $categories_names = array();
404
  if ( 0 !== $question_id ) {
405
  $question_terms = $wpdb->get_results( "SELECT `term_id` FROM `{$wpdb->prefix}mlw_question_terms` WHERE `question_id`='{$question_id}' AND `taxonomy`='qsm_category'", ARRAY_A );
406
  if ( ! empty( $question_terms ) ) {
407
  $term_ids = array_unique( array_column( $question_terms, 'term_id' ) );
408
- if ( ! empty( $term_ids ) ) {
409
  $terms = get_terms( array( 'taxonomy' => 'qsm_category', 'include' => array_unique( $term_ids ), 'hide_empty' => false, 'orderby' => '', 'order' => '' ) );
410
  if ( ! empty( $terms ) ) {
411
  foreach ( $terms as $tax ) {
412
- $categories_names[$tax->term_id] = $tax->name;
413
- $taxs[$tax->parent][] = $tax;
414
  }
415
  $categories_tree = self::create_terms_tree( $taxs, $taxs[0] );
416
-
417
- }
418
  }
419
  }
420
  }
93
  foreach ( $question_array as $question ) {
94
  $multicategories = self::get_question_categories($question['question_id']);
95
  //get_question_categories
96
+
97
  $question['multicategories'] = isset($multicategories['category_tree']) && !empty($multicategories['category_tree'] ) ? array_keys($multicategories['category_name']) : array();
98
  $question['multicategoriesobject'] = isset($multicategories['category_tree']) && !empty($multicategories['category_tree'] ) ? $multicategories['category_tree'] : array();
99
  // Prepare answers.
283
  $answers[ $key ] = $answers_array;
284
  }
285
 
286
+ $question_name = htmlspecialchars( wp_kses_post( $data['name'] ), ENT_QUOTES );
287
+ $trim_question_description = apply_filters( 'qsm_trim_question_description', true );
288
+ if ( $trim_question_description ) {
289
+ $question_name = trim( preg_replace( '/\s+/', ' ', $question_name ) );
290
+ }
291
+
292
  $values = array(
293
  'quiz_id' => intval( $data['quiz_id'] ),
294
+ 'question_name' => $question_name,
295
  'answer_array' => serialize( $answers ),
296
  'question_answer_info' => $data['answer_info'],
297
  'comments' => htmlspecialchars( $data['comments'], ENT_QUOTES ),
318
  '%d',
319
  );
320
 
 
321
  if ( $is_creating ) {
322
  $results = $wpdb->insert(
323
  $wpdb->prefix . 'mlw_questions',
326
  );
327
  $question_id = $wpdb->insert_id;
328
  } else {
329
+ $question_id = intval($data['ID']);
330
  $results = $wpdb->update(
331
  $wpdb->prefix . 'mlw_questions',
332
  $values,
341
  $mlwQuizMasterNext->log_manager->add( 'Error when creating/saving question', $msg, 0, 'error' );
342
  throw new Exception( $msg );
343
  }
344
+
345
  /**
346
  * Process Question Categories
347
  */
373
  global $wpdb;
374
  $categories = array();
375
  if ( 0 !== $quiz_id ) {
376
+ $questions = QSM_Questions::load_questions_by_pages( $quiz_id );
377
+ $question_ids = array_column( $questions, 'question_id' );
378
+ $question_ids = implode( ',', $question_ids );
379
+ $question_terms = $wpdb->get_results( "SELECT `term_id` FROM `{$wpdb->prefix}mlw_question_terms` WHERE `question_id` IN ({$question_ids}) AND `taxonomy`='qsm_category'", ARRAY_A );
380
+ $term_ids = ! empty( $question_terms ) ? array_unique( array_column( $question_terms, 'term_id' ) ) : array();
381
+
382
+ $cat_array = self::get_question_categories_from_quiz_id( $quiz_id );
383
+ $enabled = get_option( 'qsm_multiple_category_enabled' );
384
+ if ( $enabled && $enabled != 'cancelled' && ! empty( $cat_array ) ) {
385
+ $term_ids = array_unique( array_merge( $term_ids, $cat_array ) );
386
+ }
387
+
388
+ $categories = self::get_question_categories_from_term_ids( $term_ids );
389
+ }
390
+ return $categories;
391
+ }
392
+
393
+ /**
394
+ * Get categories from quiz id
395
+ *
396
+ * @since 7.3.3
397
+ * @param int $quiz_id The ID of the quiz.
398
+ * @return array The array of categories.
399
+ */
400
+ public static function get_question_categories_from_quiz_id( $quiz_id ) {
401
+ $cat_array = array();
402
+ $questions = self::load_questions_by_pages( $quiz_id );
403
+ foreach ( $questions as $single_question ) {
404
+ if ( isset( $single_question['multicategories'] ) && is_array( $single_question['multicategories'] ) ) {
405
+ foreach( $single_question['multicategories'] as $cat_id ) {
406
+ $cat_array[] = $cat_id;
407
  }
408
  }
409
  }
410
+ return $cat_array;
411
+ }
412
+
413
+ /**
414
+ * Get categories from term ids
415
+ *
416
+ * @since 7.3.3
417
+ * @param int $term_ids Term IDs of the quiz.
418
+ * @return array The array of categories.
419
+ */
420
+ public static function get_question_categories_from_term_ids( $term_ids ) {
421
+ $categories = array();
422
+ if ( ! empty( $term_ids ) ) {
423
+ $categories_names = array();
424
+ $categories_tree = array();
425
+ $terms = get_terms( array( 'taxonomy' => 'qsm_category', 'include' => $term_ids, 'hide_empty' => false, 'orderby' => '', 'order' => '' ) );
426
+ if ( ! empty( $terms ) ) {
427
+ foreach ( $terms as $tax ) {
428
+ $categories_names[$tax->term_id] = $tax->name;
429
+ $taxs[$tax->parent][] = $tax;
430
+ }
431
+ $categories_tree = self::create_terms_tree( $taxs, $taxs[0] );
432
+ }
433
+ $categories = array(
434
+ 'list' => $categories_names,
435
+ 'tree' => $categories_tree,
436
+ );
437
+ }
438
  return $categories;
439
  }
440
+
441
  /**
442
+ * Get categories for a Question
443
  *
444
  * @since 7.2.1
445
  * @param int $quiz_id The ID of the quiz.
448
  public static function get_question_categories( $question_id = 0 ) {
449
  global $wpdb;
450
  $categories_tree = array();
451
+ $categories_names = array();
452
  if ( 0 !== $question_id ) {
453
  $question_terms = $wpdb->get_results( "SELECT `term_id` FROM `{$wpdb->prefix}mlw_question_terms` WHERE `question_id`='{$question_id}' AND `taxonomy`='qsm_category'", ARRAY_A );
454
  if ( ! empty( $question_terms ) ) {
455
  $term_ids = array_unique( array_column( $question_terms, 'term_id' ) );
456
+ if ( ! empty( $term_ids ) ) {
457
  $terms = get_terms( array( 'taxonomy' => 'qsm_category', 'include' => array_unique( $term_ids ), 'hide_empty' => false, 'orderby' => '', 'order' => '' ) );
458
  if ( ! empty( $terms ) ) {
459
  foreach ( $terms as $tax ) {
460
+ $categories_names[$tax->term_id] = $tax->name;
461
+ $taxs[$tax->parent][] = $tax;
462
  }
463
  $categories_tree = self::create_terms_tree( $taxs, $taxs[0] );
464
+
465
+ }
466
  }
467
  }
468
  }
php/classes/class-qsm-settings.php CHANGED
@@ -213,8 +213,7 @@ class QSM_Quiz_Settings
213
  $old_value = $this->get_setting($setting);
214
  if (isset($_POST['global_setting'])) {
215
  $setDefaultvalue=$old_value;
216
- $getdefaultvalue=get_option('qsm-quiz-settings');
217
-
218
  $setDefaultvalue['form_type']=$getdefaultvalue['form_type'];
219
  $setDefaultvalue['system']=$getdefaultvalue['system'];
220
  $setDefaultvalue['score_roundoff']=$getdefaultvalue['score_roundoff'];
@@ -252,8 +251,8 @@ class QSM_Quiz_Settings
252
  $setDefaultvalue['scheduled_time_start']=$getdefaultvalue['scheduled_time_start'];
253
  $setDefaultvalue['scheduled_time_end']=$getdefaultvalue['scheduled_time_end'];
254
  $setDefaultvalue['not_allow_after_expired_time']=$getdefaultvalue['not_allow_after_expired_time'];
255
- // Try to serialize the value.
256
-
257
  return $this->save_quiz_settings($setting,$setDefaultvalue);
258
  }
259
  // If the old value and new value are the same, return false.
@@ -365,7 +364,8 @@ class QSM_Quiz_Settings
365
  'scheduled_time_start'=> $scheduled_timeframe["start"],
366
  'scheduled_time_end' => $scheduled_timeframe["end"],
367
  'disable_answer_onselect' => $quiz_options->disable_answer_onselect,
368
- 'ajax_show_correct' => $quiz_options->ajax_show_correct
 
369
  ) );
370
  }
371
 
213
  $old_value = $this->get_setting($setting);
214
  if (isset($_POST['global_setting'])) {
215
  $setDefaultvalue=$old_value;
216
+ $getdefaultvalue= (array) get_option('qsm-quiz-settings');
 
217
  $setDefaultvalue['form_type']=$getdefaultvalue['form_type'];
218
  $setDefaultvalue['system']=$getdefaultvalue['system'];
219
  $setDefaultvalue['score_roundoff']=$getdefaultvalue['score_roundoff'];
251
  $setDefaultvalue['scheduled_time_start']=$getdefaultvalue['scheduled_time_start'];
252
  $setDefaultvalue['scheduled_time_end']=$getdefaultvalue['scheduled_time_end'];
253
  $setDefaultvalue['not_allow_after_expired_time']=$getdefaultvalue['not_allow_after_expired_time'];
254
+ $setDefaultvalue['preferred_date_format']=$getdefaultvalue['preferred_date_format'];
255
+ // Try to serialize the value.
256
  return $this->save_quiz_settings($setting,$setDefaultvalue);
257
  }
258
  // If the old value and new value are the same, return false.
364
  'scheduled_time_start'=> $scheduled_timeframe["start"],
365
  'scheduled_time_end' => $scheduled_timeframe["end"],
366
  'disable_answer_onselect' => $quiz_options->disable_answer_onselect,
367
+ 'ajax_show_correct' => $quiz_options->ajax_show_correct ,
368
+ 'preferred_date_format'=>$quiz_options->preferred_date_format
369
  ) );
370
  }
371
 
php/template-variables.php CHANGED
@@ -97,14 +97,14 @@ function qsm_variable_single_question_answer( $content, $mlw_quiz_array ) {
97
  $answer = $question_answers_array[ $key ];
98
  if ( isset( $mlw_quiz_array['email_processed'] ) && $mlw_quiz_array['email_processed'] == 'yes' ) {
99
  if ( isset( $mlw_quiz_array['quiz_settings'] ) && ! empty( $mlw_quiz_array['quiz_settings'] ) ) {
100
- $quiz_text_settings = isset( $mlw_quiz_array['quiz_settings']['quiz_text'] ) ? @unserialize( stripslashes( $mlw_quiz_array['quiz_settings']['quiz_text'] ) ) : array();
101
  $qmn_question_answer_template = isset( $quiz_text_settings['question_answer_email_template'] ) ? apply_filters( 'qsm_section_setting_text', $quiz_text_settings['question_answer_email_template'] ) : $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_email_template', '%QUESTION%<br/>Answer Provided: %USER_ANSWER%<br/>Correct Answer: %CORRECT_ANSWER%<br/>Comments Entered: %USER_COMMENTS%' );
102
  } else {
103
  $qmn_question_answer_template = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_email_template', '%QUESTION%<br/>Answer Provided: %USER_ANSWER%<br/>Correct Answer: %CORRECT_ANSWER%<br/>Comments Entered: %USER_COMMENTS%' );
104
  }
105
  } else {
106
  if ( isset( $mlw_quiz_array['quiz_settings'] ) && ! empty( $mlw_quiz_array['quiz_settings'] ) ) {
107
- $quiz_text_settings = isset( $mlw_quiz_array['quiz_settings']['quiz_text'] ) ? @unserialize( stripslashes( $mlw_quiz_array['quiz_settings']['quiz_text'] ) ) : array();
108
  $qmn_question_answer_template = isset( $quiz_text_settings['question_answer_template'] ) ? apply_filters( 'qsm_section_setting_text', $quiz_text_settings['question_answer_template'] ) : $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_template', '%QUESTION%<br/>%USER_ANSWERS_DEFAULT%' );
109
  } else {
110
  $qmn_question_answer_template = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_template', '%QUESTION%<br/>%USER_ANSWERS_DEFAULT%' );
@@ -174,14 +174,14 @@ function qsm_variable_poll_result( $content, $mlw_quiz_array, $variables = "" )
174
  $total_query = $wpdb->get_row( $wpdb->prepare( "SELECT count(*) AS total_count FROM {$wpdb->prefix}mlw_results WHERE quiz_id = %d", $quiz_id ), ARRAY_A );
175
  $total_result = $total_query['total_count'];
176
  $ser_answer = $wpdb->get_row( $wpdb->prepare( "SELECT answer_array,question_settings FROM {$wpdb->prefix}mlw_questions WHERE question_id = %d", $question_id ), ARRAY_A );
177
- $ser_answer_arry = unserialize( $ser_answer['answer_array'] );
178
- $question_settings = unserialize( $ser_answer['question_settings'] );
179
  $ser_answer_arry_change = array_filter( array_merge( array( 0 ), $ser_answer_arry ) );
180
  $total_quiz_results = $wpdb->get_results( $wpdb->prepare( "SELECT quiz_results FROM {$wpdb->prefix}mlw_results WHERE quiz_id = %d", $quiz_id ), ARRAY_A );
181
  $answer_array = array();
182
  if ( $total_quiz_results ) {
183
  foreach ( $total_quiz_results as $key => $value ) {
184
- $userdb = unserialize( $value['quiz_results'] );
185
  if ( ! empty( $userdb ) ) {
186
  $key = array_search( $question_id, array_column( $userdb[1], 'id' ) );
187
  $answer_array[] = isset( $userdb[1][ $key ] ) ? $userdb[1][ $key ][1] : '';
@@ -192,7 +192,7 @@ function qsm_variable_poll_result( $content, $mlw_quiz_array, $variables = "" )
192
  $str = '';
193
  if ( $vals ) {
194
  $str .= '<h4>' . __( 'Poll Result', 'quiz-master-next' ) . ':</h4>';
195
- foreach ( $vals as $answer_str => $answer_count ) {
196
  if ( $answer_str != '' && qsm_find_key_from_array( $answer_str, $ser_answer_arry_change ) ) {
197
  $percentage = number_format( $answer_count / $total_result * 100, 2 );
198
  $answer_str = qsm_answers_type_evaluated( $answer_str, $question_settings );
@@ -459,7 +459,7 @@ function qsm_all_contact_fields_variable( $content, $results ) {
459
  function mlw_qmn_variable_question_answers( $content, $mlw_quiz_array ) {
460
  global $mlwQuizMasterNext;
461
  $logic_rules = $mlwQuizMasterNext->pluginHelper->get_quiz_setting( 'logic_rules' );
462
- $logic_rules = unserialize( $logic_rules );
463
  $hidden_questions = isset( $mlw_quiz_array['hidden_questions'] ) ? $mlw_quiz_array['hidden_questions'] : array();
464
  if ( empty( $hidden_questions ) ) {
465
  $hidden_questions = isset( $mlw_quiz_array['results']['hidden_questions'] ) ? $mlw_quiz_array['results']['hidden_questions'] : array();
@@ -470,14 +470,14 @@ function mlw_qmn_variable_question_answers( $content, $mlw_quiz_array ) {
470
  $display = '';
471
  if ( strpos( $content, '%QUESTIONS_ANSWERS_EMAIL%' ) !== false ) {
472
  if ( isset( $mlw_quiz_array['quiz_settings'] ) && ! empty( $mlw_quiz_array['quiz_settings'] ) ) {
473
- $quiz_text_settings = isset( $mlw_quiz_array['quiz_settings']['quiz_text'] ) ? @unserialize( stripslashes( $mlw_quiz_array['quiz_settings']['quiz_text'] ) ) : array();
474
  $qmn_question_answer_template = isset( $quiz_text_settings['question_answer_email_template'] ) ? apply_filters( 'qsm_section_setting_text', $quiz_text_settings['question_answer_email_template'] ) : $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_email_template', '%QUESTION%<br/>Answer Provided: %USER_ANSWER%<br/>Correct Answer: %CORRECT_ANSWER%<br/>Comments Entered: %USER_COMMENTS%' );
475
  } else {
476
  $qmn_question_answer_template = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_email_template', '%QUESTION%<br/>Answer Provided: %USER_ANSWER%<br/>Correct Answer: %CORRECT_ANSWER%<br/>Comments Entered: %USER_COMMENTS%' );
477
  }
478
  } else {
479
  if ( isset( $mlw_quiz_array['quiz_settings'] ) && ! empty( $mlw_quiz_array['quiz_settings'] ) ) {
480
- $quiz_text_settings = isset( $mlw_quiz_array['quiz_settings']['quiz_text'] ) ? @unserialize( stripslashes( $mlw_quiz_array['quiz_settings']['quiz_text'] ) ) : array();
481
  $qmn_question_answer_template = isset( $quiz_text_settings['question_answer_template'] ) ? apply_filters( 'qsm_section_setting_text', $quiz_text_settings['question_answer_template'] ) : $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_template', '%QUESTION%<br/>%USER_ANSWERS_DEFAULT%' );
482
  } else {
483
  $qmn_question_answer_template = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_template', '%QUESTION%<br/>%USER_ANSWERS_DEFAULT%' );
@@ -628,15 +628,13 @@ function qmn_variable_average_category_points( $content, $mlw_quiz_array ) {
628
  } else {
629
  $category_name = $answer_text[1];
630
  }
631
- foreach ( $mlw_quiz_array['question_answers_array'] as $answer ) {
632
  if( is_array( $answer['multicategories'] ) ) {
633
  foreach ( $answer['multicategories'] as $category ) {
634
- $category_name_object = get_term_by( 'ID', $category, 'qsm_category' );
635
  $category_name_of_question= ( !empty( $category_name_object->name ) ? $category_name_object->name : '' );
636
- if ( $category_name_object->name == $category_name ) {
637
- if ( '11' !== $answer['question_type'] ) {
638
- $total_questions = +1;
639
- }
640
  $return_points += $answer['points'];
641
  }
642
  }
@@ -818,7 +816,7 @@ function qsm_end_results_rank( $result_display, $qmn_quiz_options, $qmn_array_fo
818
  if ( ! empty( $mlw_result_data ) ) {
819
  foreach ( $mlw_result_data as $key => $mlw_eaches ) {
820
  $time_taken = 0;
821
- $mlw_qmn_results_array = @unserialize( $mlw_eaches->quiz_results );
822
  if ( is_array( $mlw_qmn_results_array ) ) {
823
  $time_taken = $mlw_qmn_results_array[0];
824
  if ( isset( $mlw_qmn_results_array['timer_ms'] ) && $mlw_qmn_results_array['timer_ms'] > 0 ) {
@@ -919,7 +917,7 @@ function qsm_questions_answers_shortcode_to_text( $mlw_quiz_array, $qmn_question
919
  $question_answer_class = 'qmn_question_answer_incorrect';
920
  }
921
  }
922
-
923
  $mlw_question_answer_display = htmlspecialchars_decode( $qmn_question_answer_template, ENT_QUOTES );
924
  $disable_description_on_result = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_options', 'disable_description_on_result' );
925
  // Get question setting
@@ -955,14 +953,14 @@ function qsm_questions_answers_shortcode_to_text( $mlw_quiz_array, $qmn_question
955
  $quiz_system = isset( $mlw_quiz_array['quiz_system'] ) ? $mlw_quiz_array['quiz_system'] : 0;
956
  if ( isset( $answer['id'] ) && isset( $questions[ $answer['id'] ] ) && ! empty( $questions[ $answer['id'] ] ) ) {
957
  $total_answers = isset( $questions[ $answer['id'] ]['answers'] ) ? $questions[ $answer['id'] ]['answers'] : array();
958
-
959
  $qsm_random_quetion_answer = get_post_meta($answer['id'],'qsm_random_quetion_answer',true);
960
  if(!empty($qsm_random_quetion_answer))
961
  {
962
  $total_answers = $qsm_random_quetion_answer;
963
  // No longer Need This Value
964
  delete_post_meta( $answer['id'], 'qsm_random_quetion_answer');
965
- }
966
 
967
  if ( $total_answers ) {
968
  if ( isset( $answer['question_type'] ) && in_array( $answer['question_type'], $show_two_option_questions ) ) {
@@ -1007,9 +1005,9 @@ function qsm_questions_answers_shortcode_to_text( $mlw_quiz_array, $qmn_question
1007
  } elseif ( isset( $answer['question_type'] ) && $answer['question_type'] == 11 ) {
1008
  $file_extension = substr( $answer[1], -4 );
1009
  if ( $file_extension == '.jpg' || $file_extension == '.jpeg' || $file_extension == '.png' || $file_extension == '.gif' ) {
1010
- $question_with_answer_text .= "<span class='$user_answer_class'><img src='$answer[1]'/></span>";
1011
  } else {
1012
- $question_with_answer_text .= "<span class='$user_answer_class'>" . trim( htmlspecialchars_decode( $answer[1], ENT_QUOTES ) ) . '</span>';
1013
  }
1014
  } elseif ( isset( $answer['question_type'] ) && $answer['question_type'] == 14 ) {
1015
  $match_answer = $mlwQuizMasterNext->pluginHelper->get_question_setting( $answer['id'], 'matchAnswer' );
@@ -1193,9 +1191,9 @@ function qsm_questions_answers_shortcode_to_text( $mlw_quiz_array, $qmn_question
1193
  if ( isset( $answer['question_type'] ) && $answer['question_type'] == 11 ) {
1194
  $file_extension = substr( $answer[1], -4 );
1195
  if ( $file_extension == '.jpg' || $file_extension == '.jpeg' || $file_extension == '.png' || $file_extension == '.gif' ) {
1196
- $question_with_answer_text .= "<span class='$user_answer_class'><img src='$answer[1]'/></span>";
1197
  } else {
1198
- $question_with_answer_text .= "<span class='$user_answer_class'>" . trim( htmlspecialchars_decode( $answer[1], ENT_QUOTES ) ) . '</span>';
1199
  }
1200
  } else {
1201
  $question_with_answer_text .= '<span class="qsm-user-answer-text">' . htmlspecialchars_decode( $answer[1], ENT_QUOTES ) . '</span>';
@@ -1205,12 +1203,13 @@ function qsm_questions_answers_shortcode_to_text( $mlw_quiz_array, $qmn_question
1205
  $mlw_question_answer_display = str_replace( '%USER_ANSWERS_DEFAULT%', do_shortcode( $question_with_answer_text ), $mlw_question_answer_display );
1206
  $mlw_question_answer_display = str_replace( '%USER_ANSWER%', do_shortcode( $question_with_answer_text ), $mlw_question_answer_display );
1207
  }
 
1208
  if ( isset( $answer['question_type'] ) && $answer['question_type'] == 11 ) {
1209
  $file_extension = substr( $answer[1], -4 );
1210
  if ( $file_extension == '.jpg' || $file_extension == '.jpeg' || $file_extension == '.png' || $file_extension == '.gif' ) {
1211
- $mlw_question_answer_display = str_replace( '%USER_ANSWER%', "<span class='$user_answer_class'><img src='$answer[1]'/></span><br/>", $mlw_question_answer_display );
1212
- } else {
1213
- $mlw_question_answer_display = str_replace( '%USER_ANSWER%', "<span class='$user_answer_class'>" . trim( htmlspecialchars_decode( $answer[1], ENT_QUOTES ) ) . '</span><br/>', $mlw_question_answer_display );
1214
  }
1215
  } else {
1216
  $user_answer_new = $answer[1];
@@ -1219,9 +1218,11 @@ function qsm_questions_answers_shortcode_to_text( $mlw_quiz_array, $qmn_question
1219
  }
1220
  if ( isset( $question_settings['answerEditor'] ) && $question_settings['answerEditor'] == 'image' && $user_answer_new != '' ) {
1221
  $image_url = htmlspecialchars_decode( $user_answer_new, ENT_QUOTES );
1222
- $mlw_question_answer_display = str_replace( '%USER_ANSWER%', "<span class='$user_answer_class'><img src='$image_url'/></span><br/>", $mlw_question_answer_display );
1223
- } else {
1224
- $mlw_question_answer_display = str_replace( '%USER_ANSWER%', "<span class='$user_answer_class'>" . htmlspecialchars_decode( $user_answer_new, ENT_QUOTES ) . '</span><br/>', $mlw_question_answer_display );
 
 
1225
  }
1226
  }
1227
  $answer_2 = ! empty( $answer[2] ) ? $answer[2] : 'NA';
@@ -1340,9 +1341,12 @@ function qmn_polar_display_on_resultspage( $id, $question, $answers, $answer ) {
1340
  <?php } ?>
1341
  step: 1,
1342
  range: false,
1343
- value: <?php echo $answer['points']; ?>,
1344
  slide: function slider_slide(event, ui) {
1345
  return false; // this code not allow to dragging
 
 
 
1346
  }
1347
  });
1348
  var maxHeight = Math.max.apply(null, $(".mlw-qmn-question-result-<?php echo $id; ?>> div").map(
@@ -1384,4 +1388,19 @@ function qmn_polar_display_on_resultspage( $id, $question, $answers, $answer ) {
1384
  $question = $input_text;
1385
  $question_display .= "<span class='mlw_qmn_question mlw-qmn-question-result-$id question-type-polar-s'>" . do_shortcode( htmlspecialchars_decode( $question, ENT_QUOTES ) ) . '</span>';
1386
  return apply_filters( 'qmn_polar_display_front', $question_display, $id, $question, $answers );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1387
  }
97
  $answer = $question_answers_array[ $key ];
98
  if ( isset( $mlw_quiz_array['email_processed'] ) && $mlw_quiz_array['email_processed'] == 'yes' ) {
99
  if ( isset( $mlw_quiz_array['quiz_settings'] ) && ! empty( $mlw_quiz_array['quiz_settings'] ) ) {
100
+ $quiz_text_settings = isset( $mlw_quiz_array['quiz_settings']['quiz_text'] ) ? qmn_sanitize_input_data( $mlw_quiz_array['quiz_settings']['quiz_text'], true ) : array();
101
  $qmn_question_answer_template = isset( $quiz_text_settings['question_answer_email_template'] ) ? apply_filters( 'qsm_section_setting_text', $quiz_text_settings['question_answer_email_template'] ) : $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_email_template', '%QUESTION%<br/>Answer Provided: %USER_ANSWER%<br/>Correct Answer: %CORRECT_ANSWER%<br/>Comments Entered: %USER_COMMENTS%' );
102
  } else {
103
  $qmn_question_answer_template = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_email_template', '%QUESTION%<br/>Answer Provided: %USER_ANSWER%<br/>Correct Answer: %CORRECT_ANSWER%<br/>Comments Entered: %USER_COMMENTS%' );
104
  }
105
  } else {
106
  if ( isset( $mlw_quiz_array['quiz_settings'] ) && ! empty( $mlw_quiz_array['quiz_settings'] ) ) {
107
+ $quiz_text_settings = isset( $mlw_quiz_array['quiz_settings']['quiz_text'] ) ? qmn_sanitize_input_data( $mlw_quiz_array['quiz_settings']['quiz_text'], true ) : array();
108
  $qmn_question_answer_template = isset( $quiz_text_settings['question_answer_template'] ) ? apply_filters( 'qsm_section_setting_text', $quiz_text_settings['question_answer_template'] ) : $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_template', '%QUESTION%<br/>%USER_ANSWERS_DEFAULT%' );
109
  } else {
110
  $qmn_question_answer_template = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_template', '%QUESTION%<br/>%USER_ANSWERS_DEFAULT%' );
174
  $total_query = $wpdb->get_row( $wpdb->prepare( "SELECT count(*) AS total_count FROM {$wpdb->prefix}mlw_results WHERE quiz_id = %d", $quiz_id ), ARRAY_A );
175
  $total_result = $total_query['total_count'];
176
  $ser_answer = $wpdb->get_row( $wpdb->prepare( "SELECT answer_array,question_settings FROM {$wpdb->prefix}mlw_questions WHERE question_id = %d", $question_id ), ARRAY_A );
177
+ $ser_answer_arry = qmn_sanitize_input_data( $ser_answer['answer_array'] );
178
+ $question_settings = qmn_sanitize_input_data( $ser_answer['question_settings'] );
179
  $ser_answer_arry_change = array_filter( array_merge( array( 0 ), $ser_answer_arry ) );
180
  $total_quiz_results = $wpdb->get_results( $wpdb->prepare( "SELECT quiz_results FROM {$wpdb->prefix}mlw_results WHERE quiz_id = %d", $quiz_id ), ARRAY_A );
181
  $answer_array = array();
182
  if ( $total_quiz_results ) {
183
  foreach ( $total_quiz_results as $key => $value ) {
184
+ $userdb = qmn_sanitize_input_data( $value['quiz_results'] );
185
  if ( ! empty( $userdb ) ) {
186
  $key = array_search( $question_id, array_column( $userdb[1], 'id' ) );
187
  $answer_array[] = isset( $userdb[1][ $key ] ) ? $userdb[1][ $key ][1] : '';
192
  $str = '';
193
  if ( $vals ) {
194
  $str .= '<h4>' . __( 'Poll Result', 'quiz-master-next' ) . ':</h4>';
195
+ foreach ( $vals as $answer_str => $answer_count ) {
196
  if ( $answer_str != '' && qsm_find_key_from_array( $answer_str, $ser_answer_arry_change ) ) {
197
  $percentage = number_format( $answer_count / $total_result * 100, 2 );
198
  $answer_str = qsm_answers_type_evaluated( $answer_str, $question_settings );
459
  function mlw_qmn_variable_question_answers( $content, $mlw_quiz_array ) {
460
  global $mlwQuizMasterNext;
461
  $logic_rules = $mlwQuizMasterNext->pluginHelper->get_quiz_setting( 'logic_rules' );
462
+ $logic_rules = qmn_sanitize_input_data( $logic_rules );
463
  $hidden_questions = isset( $mlw_quiz_array['hidden_questions'] ) ? $mlw_quiz_array['hidden_questions'] : array();
464
  if ( empty( $hidden_questions ) ) {
465
  $hidden_questions = isset( $mlw_quiz_array['results']['hidden_questions'] ) ? $mlw_quiz_array['results']['hidden_questions'] : array();
470
  $display = '';
471
  if ( strpos( $content, '%QUESTIONS_ANSWERS_EMAIL%' ) !== false ) {
472
  if ( isset( $mlw_quiz_array['quiz_settings'] ) && ! empty( $mlw_quiz_array['quiz_settings'] ) ) {
473
+ $quiz_text_settings = isset( $mlw_quiz_array['quiz_settings']['quiz_text'] ) ? qmn_sanitize_input_data( $mlw_quiz_array['quiz_settings']['quiz_text'], true ) : array();
474
  $qmn_question_answer_template = isset( $quiz_text_settings['question_answer_email_template'] ) ? apply_filters( 'qsm_section_setting_text', $quiz_text_settings['question_answer_email_template'] ) : $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_email_template', '%QUESTION%<br/>Answer Provided: %USER_ANSWER%<br/>Correct Answer: %CORRECT_ANSWER%<br/>Comments Entered: %USER_COMMENTS%' );
475
  } else {
476
  $qmn_question_answer_template = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_email_template', '%QUESTION%<br/>Answer Provided: %USER_ANSWER%<br/>Correct Answer: %CORRECT_ANSWER%<br/>Comments Entered: %USER_COMMENTS%' );
477
  }
478
  } else {
479
  if ( isset( $mlw_quiz_array['quiz_settings'] ) && ! empty( $mlw_quiz_array['quiz_settings'] ) ) {
480
+ $quiz_text_settings = isset( $mlw_quiz_array['quiz_settings']['quiz_text'] ) ? qmn_sanitize_input_data( $mlw_quiz_array['quiz_settings']['quiz_text'], true ) : array();
481
  $qmn_question_answer_template = isset( $quiz_text_settings['question_answer_template'] ) ? apply_filters( 'qsm_section_setting_text', $quiz_text_settings['question_answer_template'] ) : $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_template', '%QUESTION%<br/>%USER_ANSWERS_DEFAULT%' );
482
  } else {
483
  $qmn_question_answer_template = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_template', '%QUESTION%<br/>%USER_ANSWERS_DEFAULT%' );
628
  } else {
629
  $category_name = $answer_text[1];
630
  }
631
+ foreach ( $mlw_quiz_array['question_answers_array'] as $answer ) {
632
  if( is_array( $answer['multicategories'] ) ) {
633
  foreach ( $answer['multicategories'] as $category ) {
634
+ $category_name_object = get_term_by( 'ID', $category, 'qsm_category' );
635
  $category_name_of_question= ( !empty( $category_name_object->name ) ? $category_name_object->name : '' );
636
+ if ( $category_name_object->name == $category_name && '11' !== $answer['question_type'] ) {
637
+ $total_questions += 1;
 
 
638
  $return_points += $answer['points'];
639
  }
640
  }
816
  if ( ! empty( $mlw_result_data ) ) {
817
  foreach ( $mlw_result_data as $key => $mlw_eaches ) {
818
  $time_taken = 0;
819
+ $mlw_qmn_results_array = qmn_sanitize_input_data( $mlw_eaches->quiz_results );
820
  if ( is_array( $mlw_qmn_results_array ) ) {
821
  $time_taken = $mlw_qmn_results_array[0];
822
  if ( isset( $mlw_qmn_results_array['timer_ms'] ) && $mlw_qmn_results_array['timer_ms'] > 0 ) {
917
  $question_answer_class = 'qmn_question_answer_incorrect';
918
  }
919
  }
920
+ $open_span_tag = '<span class="'.$user_answer_class.'">';
921
  $mlw_question_answer_display = htmlspecialchars_decode( $qmn_question_answer_template, ENT_QUOTES );
922
  $disable_description_on_result = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_options', 'disable_description_on_result' );
923
  // Get question setting
953
  $quiz_system = isset( $mlw_quiz_array['quiz_system'] ) ? $mlw_quiz_array['quiz_system'] : 0;
954
  if ( isset( $answer['id'] ) && isset( $questions[ $answer['id'] ] ) && ! empty( $questions[ $answer['id'] ] ) ) {
955
  $total_answers = isset( $questions[ $answer['id'] ]['answers'] ) ? $questions[ $answer['id'] ]['answers'] : array();
956
+
957
  $qsm_random_quetion_answer = get_post_meta($answer['id'],'qsm_random_quetion_answer',true);
958
  if(!empty($qsm_random_quetion_answer))
959
  {
960
  $total_answers = $qsm_random_quetion_answer;
961
  // No longer Need This Value
962
  delete_post_meta( $answer['id'], 'qsm_random_quetion_answer');
963
+ }
964
 
965
  if ( $total_answers ) {
966
  if ( isset( $answer['question_type'] ) && in_array( $answer['question_type'], $show_two_option_questions ) ) {
1005
  } elseif ( isset( $answer['question_type'] ) && $answer['question_type'] == 11 ) {
1006
  $file_extension = substr( $answer[1], -4 );
1007
  if ( $file_extension == '.jpg' || $file_extension == '.jpeg' || $file_extension == '.png' || $file_extension == '.gif' ) {
1008
+ $question_with_answer_text .= "$open_span_tag<img src='$answer[1]'/></span>";
1009
  } else {
1010
+ $question_with_answer_text .= "$open_span_tag" . trim( htmlspecialchars_decode( $answer[1], ENT_QUOTES ) ) . '</span>';
1011
  }
1012
  } elseif ( isset( $answer['question_type'] ) && $answer['question_type'] == 14 ) {
1013
  $match_answer = $mlwQuizMasterNext->pluginHelper->get_question_setting( $answer['id'], 'matchAnswer' );
1191
  if ( isset( $answer['question_type'] ) && $answer['question_type'] == 11 ) {
1192
  $file_extension = substr( $answer[1], -4 );
1193
  if ( $file_extension == '.jpg' || $file_extension == '.jpeg' || $file_extension == '.png' || $file_extension == '.gif' ) {
1194
+ $question_with_answer_text .= "$open_span_tag<img src='$answer[1]'/></span>";
1195
  } else {
1196
+ $question_with_answer_text .= "$open_span_tag" . trim( htmlspecialchars_decode( $answer[1], ENT_QUOTES ) ) . '</span>';
1197
  }
1198
  } else {
1199
  $question_with_answer_text .= '<span class="qsm-user-answer-text">' . htmlspecialchars_decode( $answer[1], ENT_QUOTES ) . '</span>';
1203
  $mlw_question_answer_display = str_replace( '%USER_ANSWERS_DEFAULT%', do_shortcode( $question_with_answer_text ), $mlw_question_answer_display );
1204
  $mlw_question_answer_display = str_replace( '%USER_ANSWER%', do_shortcode( $question_with_answer_text ), $mlw_question_answer_display );
1205
  }
1206
+ $close_span_with_br = '</span><br/>';
1207
  if ( isset( $answer['question_type'] ) && $answer['question_type'] == 11 ) {
1208
  $file_extension = substr( $answer[1], -4 );
1209
  if ( $file_extension == '.jpg' || $file_extension == '.jpeg' || $file_extension == '.png' || $file_extension == '.gif' ) {
1210
+ $mlw_question_answer_display = str_replace( '%USER_ANSWER%', "$open_span_tag<img src='$answer[1]'/>$close_span_with_br", $mlw_question_answer_display );
1211
+ }else {
1212
+ $mlw_question_answer_display = str_replace( '%USER_ANSWER%', "$open_span_tag" . trim( htmlspecialchars_decode( $answer[1], ENT_QUOTES ) ) . $close_span_with_br, $mlw_question_answer_display );
1213
  }
1214
  } else {
1215
  $user_answer_new = $answer[1];
1218
  }
1219
  if ( isset( $question_settings['answerEditor'] ) && $question_settings['answerEditor'] == 'image' && $user_answer_new != '' ) {
1220
  $image_url = htmlspecialchars_decode( $user_answer_new, ENT_QUOTES );
1221
+ $mlw_question_answer_display = str_replace( '%USER_ANSWER%', "$open_span_tag<img src='$image_url'/>$close_span_with_br", $mlw_question_answer_display );
1222
+ }elseif( $answer['question_type'] == 5){
1223
+ $mlw_question_answer_display = str_replace( '%USER_ANSWER%', "$open_span_tag" . nl2br(htmlspecialchars_decode( $user_answer_new, ENT_QUOTES )) . $close_span_with_br, $mlw_question_answer_display );
1224
+ } else {
1225
+ $mlw_question_answer_display = str_replace( '%USER_ANSWER%', "$open_span_tag" . htmlspecialchars_decode( $user_answer_new, ENT_QUOTES ) . $close_span_with_br, $mlw_question_answer_display );
1226
  }
1227
  }
1228
  $answer_2 = ! empty( $answer[2] ) ? $answer[2] : 'NA';
1341
  <?php } ?>
1342
  step: 1,
1343
  range: false,
1344
+ value: <?php echo esc_attr( $answer['points'] ); ?>,
1345
  slide: function slider_slide(event, ui) {
1346
  return false; // this code not allow to dragging
1347
+ },
1348
+ create: function (event, ui){
1349
+ jQuery(document).trigger('qsm_after_display_result',[ this, ui ]); // This code allow to apply js code on polar slider on result page
1350
  }
1351
  });
1352
  var maxHeight = Math.max.apply(null, $(".mlw-qmn-question-result-<?php echo $id; ?>> div").map(
1388
  $question = $input_text;
1389
  $question_display .= "<span class='mlw_qmn_question mlw-qmn-question-result-$id question-type-polar-s'>" . do_shortcode( htmlspecialchars_decode( $question, ENT_QUOTES ) ) . '</span>';
1390
  return apply_filters( 'qmn_polar_display_front', $question_display, $id, $question, $answers );
1391
+ }
1392
+
1393
+ /**
1394
+ * Display Polor Question on Result page
1395
+ *
1396
+ * @params $data Questions Data
1397
+ * @params $strip Can Stripable ot not?
1398
+ * @return $question_display Returns the content of the question
1399
+ * @since 7.3.3
1400
+ */
1401
+ function qmn_sanitize_input_data( $data, $strip = false ) {
1402
+ if ( $strip ) {
1403
+ $data = stripslashes( $data );
1404
+ }
1405
+ return unserialize( $data );
1406
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: quiz, survey, lead, test, score, exam, questionnaire, question,wordpress q
4
  Requires at least: 4.9
5
  Tested up to: 5.8
6
  Requires PHP: 5.4
7
- Stable tag: 7.3.2
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -13,7 +13,7 @@ Easily create exams, generate leads, surveys and any type of quiz with our popul
13
  == Description ==
14
 
15
  = Demoes! =
16
- * [Sample Quiz](https://quizandsurveymaster.com/quiz/sample-quiz/?utm_source=readme&utm_medium=plugin&utm_content=sample-quiz&utm_campaign=qsm_plugin)
17
  * [Sample Survey](https://quizandsurveymaster.com/quiz/sample-survey/?utm_source=readme&utm_medium=plugin&utm_content=sample-survey&utm_campaign=qsm_plugin)
18
  * [Personality Quiz](https://quizandsurveymaster.com/quiz/personality-quiz/?utm_source=readme&utm_medium=plugin&utm_campaign=qsm_plugin)
19
  * [Quiz with Leaderboard](https://demo.quizandsurveymaster.com/advanced-leaderboard-demo/?utm_source=readme&utm_medium=plugin&utm_campaign=qsm_plugin)
@@ -39,7 +39,7 @@ You can customize anything your users will see and engage with. Everything from
39
  You can have **multiple choice** (radio buttons), **true and false**, **open answer** question, **drop down**, **multiple response** (checkboxes), **fill in the blank**, **number**, **captcha**, **polar** (slider) and **accept**. We release more questions types with every major release.
40
 
41
  = Customize Results Based on Score =
42
- Using our quiz builder plugin, you can customize the results page based on the user's score.
43
 
44
  = Emails After Quiz =
45
  After the user takes a quiz or survey, you can have the plugin email you and the user with results. This too can be customized with your own text.
@@ -51,9 +51,9 @@ Your quiz or survey can be graded with an incorrect/correct system or a points-b
51
  You can assign categories to your questions using our quiz maker plugin. You can then show the user their score in a **particular** category or an average score of the categories.
52
 
53
  = Countdown Timer =
54
- Add countdown timer to your quizzes and effectively create skills assessment or online exams on your website.
55
 
56
- = Lead Generation =
57
  You can integrate Mailchimp, Activecampaign, Zapier, Campaign Monitor, Get Response to your quiz or surveys in order to create drip email campaigns and reachout to your audience. Checkout our [integrations](https://quizandsurveymaster.com/downloads/category/integrations/).
58
 
59
  = Other Useful Features =
@@ -151,6 +151,18 @@ This is usually a theme conflict. You can [checkout out our common conflict solu
151
  18. Database
152
 
153
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
154
  = 7.3.2 (September 06, 2021) =
155
  * Bug: Added Translation for Time is up and Cancel button.
156
  * Bug: Fixed the issue of category name not visible.
@@ -234,7 +246,7 @@ This is usually a theme conflict. You can [checkout out our common conflict solu
234
  * Enhancement: UI improvements for Quiz Editor.
235
 
236
  = 7.1.13 (March 9, 2021) =
237
- * Bug: Fixed several security issues.
238
  * Bug: Fixed the issue of audio and video player not showing in question content
239
  * Bug: Fixed the issue of [latex] shortcode not showing Red cross mark for incorrect option.
240
  * Bug: Fixed the issue required field getting surpassed by spaces in contact form.
@@ -457,7 +469,7 @@ This is usually a theme conflict. You can [checkout out our common conflict solu
457
  * Bug: Customized text using the "Text tab" and remove from "Options Tab" for user is not logged in
458
  * Bug: Fixed share Quizz's results on Social Media ( https://wordpress.org/support/topic/sharing-to-social-media/ )
459
  * Bug: For polar question type added the validation while creating option
460
- * Bug: Solved phone number field validation
461
  * Bug: Solved User Dashboard addon issue for first row
462
  * Feature: Special capabilities #810 ( https://github.com/QuizandSurveyMaster/quiz_master_next/issues/810 )
463
  * Feature: Added Show JS Error library to show the JS Error in quiz page
@@ -528,7 +540,7 @@ This is usually a theme conflict. You can [checkout out our common conflict solu
528
  * XSS Vulnerability (https://github.com/QuizandSurveyMaster/quiz_master_next/issues/795)
529
 
530
  = 6.3.4 (Oct 24, 2019) =
531
- * Massive overhaule for being responsive in admin panel.
532
  * Checkbox limit ([Issue #743] https://github.com/QuizandSurveyMaster/quiz_master_next/issues/743)
533
  * Logic addon bug ([Issue #760] https://github.com/QuizandSurveyMaster/quiz_master_next/issues/760)
534
  * Add filter to results array ([Issue #785] https://github.com/QuizandSurveyMaster/quiz_master_next/issues/785)
@@ -540,7 +552,7 @@ This is usually a theme conflict. You can [checkout out our common conflict solu
540
  * Radio buttons hard to select ([WP Issue] (https://wordpress.org/support/topic/radio-buttons-are-hard-to-select-on-mobile-devices/))
541
  * Results page enhancements
542
 
543
- = 6.3.2 (July 06, 2019) =
544
  * UI Changes
545
  * Addons Pricing Page Update
546
  * Free Addon Page Added
@@ -554,8 +566,8 @@ This is usually a theme conflict. You can [checkout out our common conflict solu
554
  = 6.3.1 (May 19, 2019) =
555
  * Closed Bug: Duplicate post issue ([Issue #758](https://github.com/QuizandSurveyMaster/quiz_master_next/issues/758))
556
  * Closed Enhancement: Option to turn off autofill ([WP Issue](https://wordpress.org/support/topic/can-you-add-an-option-to-turn-off-autofill-on-galaxy-phones-and-other-devices/))
557
- * Added Feature: Preview quiz within the quiz edit page.
558
- * Added Feature: Auto save quiz and questions
559
  * Closed Enhancement: Disable autofill for contact fields ([Issue #718](https://github.com/QuizandSurveyMaster/quiz_master_next/issues/718))
560
  * Closed Enhancement: Added %POLL_RESULTS_X% tag for results page to show poll results ([Issue #458](https://github.com/QuizandSurveyMaster/quiz_master_next/issues/458))
561
  * Closed Bug: Facebook Share not working properly ([WP Issue](https://wordpress.org/support/topic/facebook-share-40/))
4
  Requires at least: 4.9
5
  Tested up to: 5.8
6
  Requires PHP: 5.4
7
+ Stable tag: 7.3.3
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
13
  == Description ==
14
 
15
  = Demoes! =
16
+ * [Sample Quiz](https://quizandsurveymaster.com/quiz/sample-quiz/?utm_source=readme&utm_medium=plugin&utm_content=sample-quiz&utm_campaign=qsm_plugin)
17
  * [Sample Survey](https://quizandsurveymaster.com/quiz/sample-survey/?utm_source=readme&utm_medium=plugin&utm_content=sample-survey&utm_campaign=qsm_plugin)
18
  * [Personality Quiz](https://quizandsurveymaster.com/quiz/personality-quiz/?utm_source=readme&utm_medium=plugin&utm_campaign=qsm_plugin)
19
  * [Quiz with Leaderboard](https://demo.quizandsurveymaster.com/advanced-leaderboard-demo/?utm_source=readme&utm_medium=plugin&utm_campaign=qsm_plugin)
39
  You can have **multiple choice** (radio buttons), **true and false**, **open answer** question, **drop down**, **multiple response** (checkboxes), **fill in the blank**, **number**, **captcha**, **polar** (slider) and **accept**. We release more questions types with every major release.
40
 
41
  = Customize Results Based on Score =
42
+ Using our quiz builder plugin, you can customize the results page based on the user's score.
43
 
44
  = Emails After Quiz =
45
  After the user takes a quiz or survey, you can have the plugin email you and the user with results. This too can be customized with your own text.
51
  You can assign categories to your questions using our quiz maker plugin. You can then show the user their score in a **particular** category or an average score of the categories.
52
 
53
  = Countdown Timer =
54
+ Add countdown timer to your quizzes and effectively create skills assessment or online exams on your website.
55
 
56
+ = Lead Generation =
57
  You can integrate Mailchimp, Activecampaign, Zapier, Campaign Monitor, Get Response to your quiz or surveys in order to create drip email campaigns and reachout to your audience. Checkout our [integrations](https://quizandsurveymaster.com/downloads/category/integrations/).
58
 
59
  = Other Useful Features =
151
  18. Database
152
 
153
  == Changelog ==
154
+ = 7.3.3 (October 1, 2021) =
155
+ * Bug: Fixed the issue where %AVERAGE_CATEGORY_POINTS_X% was calculating total instead of average.
156
+ * Bug: Fixed the issue where no category found for questions imported from question bank.
157
+ * Bug: Fixed the issue where the limit number of questions per category was not working.
158
+ * Bug: Fixed the issue with "Limit question per category" setting when "Random" option is enabled
159
+ * Bug: Fixed the issue where timer was not showing on single page quiz.
160
+ * Bug: Fixed the issue when recaptcha button not showing when question per page quiz options is enabled.
161
+ * Bug: Fixed the issues while duplicating a quiz.
162
+ * Bug: Fixed the issue where date question type shows date in reverse order on the results page and in emails.
163
+ * Feature: Added date field in quiz contact tab.
164
+ * Enhancement: Added Correct/Incorrect answers in different color in email.
165
+
166
  = 7.3.2 (September 06, 2021) =
167
  * Bug: Added Translation for Time is up and Cancel button.
168
  * Bug: Fixed the issue of category name not visible.
246
  * Enhancement: UI improvements for Quiz Editor.
247
 
248
  = 7.1.13 (March 9, 2021) =
249
+ * Bug: Fixed several security issues.
250
  * Bug: Fixed the issue of audio and video player not showing in question content
251
  * Bug: Fixed the issue of [latex] shortcode not showing Red cross mark for incorrect option.
252
  * Bug: Fixed the issue required field getting surpassed by spaces in contact form.
469
  * Bug: Customized text using the "Text tab" and remove from "Options Tab" for user is not logged in
470
  * Bug: Fixed share Quizz's results on Social Media ( https://wordpress.org/support/topic/sharing-to-social-media/ )
471
  * Bug: For polar question type added the validation while creating option
472
+ * Bug: Solved phone number field validation
473
  * Bug: Solved User Dashboard addon issue for first row
474
  * Feature: Special capabilities #810 ( https://github.com/QuizandSurveyMaster/quiz_master_next/issues/810 )
475
  * Feature: Added Show JS Error library to show the JS Error in quiz page
540
  * XSS Vulnerability (https://github.com/QuizandSurveyMaster/quiz_master_next/issues/795)
541
 
542
  = 6.3.4 (Oct 24, 2019) =
543
+ * Massive overhaule for being responsive in admin panel.
544
  * Checkbox limit ([Issue #743] https://github.com/QuizandSurveyMaster/quiz_master_next/issues/743)
545
  * Logic addon bug ([Issue #760] https://github.com/QuizandSurveyMaster/quiz_master_next/issues/760)
546
  * Add filter to results array ([Issue #785] https://github.com/QuizandSurveyMaster/quiz_master_next/issues/785)
552
  * Radio buttons hard to select ([WP Issue] (https://wordpress.org/support/topic/radio-buttons-are-hard-to-select-on-mobile-devices/))
553
  * Results page enhancements
554
 
555
+ = 6.3.2 (July 06, 2019) =
556
  * UI Changes
557
  * Addons Pricing Page Update
558
  * Free Addon Page Added
566
  = 6.3.1 (May 19, 2019) =
567
  * Closed Bug: Duplicate post issue ([Issue #758](https://github.com/QuizandSurveyMaster/quiz_master_next/issues/758))
568
  * Closed Enhancement: Option to turn off autofill ([WP Issue](https://wordpress.org/support/topic/can-you-add-an-option-to-turn-off-autofill-on-galaxy-phones-and-other-devices/))
569
+ * Added Feature: Preview quiz within the quiz edit page.
570
+ * Added Feature: Auto save quiz and questions
571
  * Closed Enhancement: Disable autofill for contact fields ([Issue #718](https://github.com/QuizandSurveyMaster/quiz_master_next/issues/718))
572
  * Closed Enhancement: Added %POLL_RESULTS_X% tag for results page to show poll results ([Issue #458](https://github.com/QuizandSurveyMaster/quiz_master_next/issues/458))
573
  * Closed Bug: Facebook Share not working properly ([WP Issue](https://wordpress.org/support/topic/facebook-share-40/))