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

Version Description

(December 14, 2020) = * Bug: Fixed the issue where answers with apostrophe's are not being recognized as correct. * Bug: Fixed the issue where inline are shown twice when Random Questions are enabled. * Bug: Fixed the issue with point score and maximum point variable * Bug: Fixed the issue where only last answer display as correct when all the answers were marked correct. * Enhancement: Added Limit Text option for paragraph question type. * Enhancement: Added an option for inserting a link in the Correct info.

Download this release

Release Info

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

Code changes from version 7.1.8 to 7.1.9

css/common.css CHANGED
@@ -31,7 +31,6 @@ body .quiz_section .qsm_contact_div .mlw_qmn_question{
31
  line-height: 20px;
32
  }
33
 
34
-
35
  .question-type-polar-s{
36
  display: inline-block !important;
37
  position: relative;
@@ -255,6 +254,7 @@ footer.qsm-popup__footer button.qsm-popup-secondary-button:hover{
255
  -moz-border-radius: 3px;
256
  border-radius: 3px;
257
  }
 
258
  @media screen and (max-width: 767px){
259
  .question-type-polar-s .left-polar-title,
260
  .question-type-polar-s .slider-main-wrapper,
31
  line-height: 20px;
32
  }
33
 
 
34
  .question-type-polar-s{
35
  display: inline-block !important;
36
  position: relative;
254
  -moz-border-radius: 3px;
255
  border-radius: 3px;
256
  }
257
+ .qsm_social_share_link{display: inline-block;cursor: pointer;}
258
  @media screen and (max-width: 767px){
259
  .question-type-polar-s .left-polar-title,
260
  .question-type-polar-s .slider-main-wrapper,
js/qsm-quiz.js CHANGED
@@ -1325,6 +1325,27 @@ jQuery(function() {
1325
  jQuery(document).on('keyup', '.mlwPhoneNumber', function(e){
1326
  this.value = this.value.replace(/[^- +()0-9\.]/g,'');
1327
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1328
  });
1329
 
1330
  var qsmTimerInterval = setInterval( qmnTimeTakenTimer, 1000 );
1325
  jQuery(document).on('keyup', '.mlwPhoneNumber', function(e){
1326
  this.value = this.value.replace(/[^- +()0-9\.]/g,'');
1327
  });
1328
+
1329
+ jQuery(document).on('click', '.qsm_social_share_link', function (e) {
1330
+ e.preventDefault();
1331
+ var network = jQuery(this).attr('data-network');
1332
+ var share_url = jQuery(this).attr('data-link');
1333
+ var social_text = jQuery(this).attr('data-text');
1334
+ var social_id = jQuery(this).attr('data-id');
1335
+ var url = '';
1336
+ if (network == 'facebook') {
1337
+ url = "https://www.facebook.com/dialog/feed?" + "display=popup&" + "app_id=" + social_id +
1338
+ "&" + "link=" + encodeURIComponent(share_url) + "&" + "name=" + social_text;
1339
+ }
1340
+ if (network == 'twitter') {
1341
+ url = "https://twitter.com/intent/tweet?text=" + social_text;
1342
+ }
1343
+ var sTop = window.screen.height / 2 - (218);
1344
+ var sLeft = window.screen.width / 2 - (313);
1345
+ var sqShareOptions = "height=400,width=580,toolbar=0,status=0,location=0,menubar=0,directories=0,scrollbars=0,top=" + sTop + ",left=" + sLeft;
1346
+ window.open(url, "Share", sqShareOptions);
1347
+ return false;
1348
+ });
1349
  });
1350
 
1351
  var qsmTimerInterval = setInterval( qmnTimeTakenTimer, 1000 );
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.1.8
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.1.8
13
  * @package QSM
14
  */
15
 
@@ -37,7 +37,7 @@ class MLWQuizMasterNext {
37
  * @var string
38
  * @since 4.0.0
39
  */
40
- public $version = '7.1.8';
41
 
42
  /**
43
  * 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.1.9
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.1.9
13
  * @package QSM
14
  */
15
 
37
  * @var string
38
  * @since 4.0.0
39
  */
40
+ public $version = '7.1.9';
41
 
42
  /**
43
  * QSM Alert Manager Object
php/admin/admin-results-page.php CHANGED
@@ -160,9 +160,12 @@ function qsm_results_overview_tab_content() {
160
  $sanitized_search_phrase = sanitize_text_field( $_GET['qsm_search_phrase'] );
161
  $search_phrase_percents = '%' . $wpdb->esc_like( $sanitized_search_phrase ) . '%';
162
  $search_phrase_sql = $wpdb->prepare( ' AND (quiz_name LIKE %s OR name LIKE %s OR business LIKE %s OR email LIKE %s OR phone LIKE %s)', $search_phrase_percents, $search_phrase_percents, $search_phrase_percents, $search_phrase_percents, $search_phrase_percents );
163
- $qsm_results_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(result_id) FROM {$wpdb->prefix}mlw_results WHERE deleted='0' AND (quiz_name LIKE %s OR name LIKE %s OR business LIKE %s OR email LIKE %s OR phone LIKE %s)", $search_phrase_percents, $search_phrase_percents, $search_phrase_percents, $search_phrase_percents, $search_phrase_percents ) );
 
 
 
164
  } else {
165
- $qsm_results_count = $wpdb->get_var( "SELECT COUNT(result_id) FROM {$wpdb->prefix}mlw_results WHERE deleted = '0'" );
166
  }
167
 
168
  // Gets the order by arg. Uses switch to create SQL to prevent SQL injection.
160
  $sanitized_search_phrase = sanitize_text_field( $_GET['qsm_search_phrase'] );
161
  $search_phrase_percents = '%' . $wpdb->esc_like( $sanitized_search_phrase ) . '%';
162
  $search_phrase_sql = $wpdb->prepare( ' AND (quiz_name LIKE %s OR name LIKE %s OR business LIKE %s OR email LIKE %s OR phone LIKE %s)', $search_phrase_percents, $search_phrase_percents, $search_phrase_percents, $search_phrase_percents, $search_phrase_percents );
163
+ }
164
+ if ( isset( $_GET['quiz_id'] ) && ! empty( $_GET['quiz_id'] ) ) {
165
+ $quiz_id = intval( $_GET['quiz_id'] );
166
+ $qsm_results_count = $wpdb->get_var( "SELECT COUNT(result_id) FROM {$wpdb->prefix}mlw_results WHERE `deleted`='0' AND `quiz_id`='{$quiz_id}' {$search_phrase_sql}" );
167
  } else {
168
+ $qsm_results_count = $wpdb->get_var( "SELECT COUNT(result_id) FROM {$wpdb->prefix}mlw_results WHERE `deleted`='0' {$search_phrase_sql}" );
169
  }
170
 
171
  // Gets the order by arg. Uses switch to create SQL to prevent SQL injection.
php/admin/functions.php CHANGED
@@ -576,6 +576,7 @@ function qsm_text_template_variable_list(){
576
  '%USER_PHONE%' => __('The phone number the user entered before the quiz', 'quiz-master-next'),
577
  '%USER_EMAIL%' => __('The email the user entered before the quiz', 'quiz-master-next'),
578
  '%QUIZ_NAME%' => __('The name of the quiz', 'quiz-master-next'),
 
579
  '%QUESTIONS_ANSWERS%' => __('Shows the question, the answer the user provided, and the correct answer', 'quiz-master-next'),
580
  '%COMMENT_SECTION%' => __('The comments the user entered into comment box if enabled', 'quiz-master-next'),
581
  '%TIMER%' => __('The amount of time user spent on quiz in seconds', 'quiz-master-next'),
@@ -592,6 +593,10 @@ function qsm_text_template_variable_list(){
592
  '%CORRECT_ANSWER_INFO%' => __('Reason why the correct answer is the correct answer', 'quiz-master-next'),
593
  '%CURRENT_DATE%' => __('The Current Date', 'quiz-master-next'),
594
  '%QUESTION_POINT_SCORE%' => __('Point Score of the question', 'quiz-master-next'),
 
 
 
 
595
  );
596
  $variable_list = apply_filters('qsm_text_variable_list', $variable_list);
597
  return $variable_list;
576
  '%USER_PHONE%' => __('The phone number the user entered before the quiz', 'quiz-master-next'),
577
  '%USER_EMAIL%' => __('The email the user entered before the quiz', 'quiz-master-next'),
578
  '%QUIZ_NAME%' => __('The name of the quiz', 'quiz-master-next'),
579
+ '%QUIZ_LINK%' => __('The link of the quiz', 'quiz-master-next'),
580
  '%QUESTIONS_ANSWERS%' => __('Shows the question, the answer the user provided, and the correct answer', 'quiz-master-next'),
581
  '%COMMENT_SECTION%' => __('The comments the user entered into comment box if enabled', 'quiz-master-next'),
582
  '%TIMER%' => __('The amount of time user spent on quiz in seconds', 'quiz-master-next'),
593
  '%CORRECT_ANSWER_INFO%' => __('Reason why the correct answer is the correct answer', 'quiz-master-next'),
594
  '%CURRENT_DATE%' => __('The Current Date', 'quiz-master-next'),
595
  '%QUESTION_POINT_SCORE%' => __('Point Score of the question', 'quiz-master-next'),
596
+ '%QUESTION_MAX_POINTS%' => __('Maximum points of the question', 'quiz-master-next'),
597
+ '%FACEBOOK_SHARE%' => __('Displays button to share on Facebook.', 'quiz-master-next'),
598
+ '%TWITTER_SHARE%' => __('Displays button to share on Twitter.', 'quiz-master-next'),
599
+ '%RESULT_LINK%' => __('The link of the result page.', 'quiz-master-next'),
600
  );
601
  $variable_list = apply_filters('qsm_text_variable_list', $variable_list);
602
  return $variable_list;
php/admin/options-page-email-tab.php CHANGED
@@ -146,6 +146,8 @@ function qsm_options_emails_tab_content() {
146
  unset($variable_list['%USER_COMMENTS%']);
147
  unset($variable_list['%CORRECT_ANSWER_INFO%']);
148
  unset($variable_list['%QUESTIONS_ANSWERS%']);
 
 
149
  if( $variable_list ){
150
  foreach ( $variable_list as $key => $s_variable ) { ?>
151
  <div class="popup-template-span-wrap">
146
  unset($variable_list['%USER_COMMENTS%']);
147
  unset($variable_list['%CORRECT_ANSWER_INFO%']);
148
  unset($variable_list['%QUESTIONS_ANSWERS%']);
149
+ unset($variable_list['%FACEBOOK_SHARE%']);
150
+ unset($variable_list['%TWITTER_SHARE%']);
151
  if( $variable_list ){
152
  foreach ( $variable_list as $key => $s_variable ) { ?>
153
  <div class="popup-template-span-wrap">
php/admin/options-page-questions-tab.php CHANGED
@@ -404,7 +404,7 @@ function qsm_options_questions_tab_content() {
404
  'type' => 'text',
405
  'priority' => '7',
406
  'default' => '',
407
- 'show' => '3, 14, 7',
408
  'documentation_link' => 'https://quizandsurveymaster.com/docs/v7/advanced-options/#Limit-Text'
409
  ),
410
  'limit_multiple_response' => array(
404
  'type' => 'text',
405
  'priority' => '7',
406
  'default' => '',
407
+ 'show' => '3, 5, 7, 14',
408
  'documentation_link' => 'https://quizandsurveymaster.com/docs/v7/advanced-options/#Limit-Text'
409
  ),
410
  'limit_multiple_response' => array(
php/admin/options-page-results-page-tab.php CHANGED
@@ -126,8 +126,6 @@ function qsm_options_results_tab_content() {
126
  );
127
  $variable_list = array_merge($email_exta_variable, $variable_list);
128
  $variable_list['%AVERAGE_CATEGORY_POINTS_X%'] = __('X: Category name - The average amount of points a specific category earned.', 'quiz-master-next');
129
- $variable_list['%FACEBOOK_SHARE%'] = __('Displays button to share on Facebook.', 'quiz-master-next');
130
- $variable_list['%TWITTER_SHARE%'] = __('Displays button to share on Twitter.', 'quiz-master-next');
131
  $variable_list['%POLL_RESULTS_X%'] = __('X = Question ID Note: only supported for multiple choice answers', 'quiz-master-next');
132
  $variable_list['%RESULT_ID%'] = __('Show result id', 'quiz-master-next');
133
  $variable_list['%QUESTION_ANSWER_X%'] = __('X = Question ID. It will show result of particular question.', 'quiz-master-next');
126
  );
127
  $variable_list = array_merge($email_exta_variable, $variable_list);
128
  $variable_list['%AVERAGE_CATEGORY_POINTS_X%'] = __('X: Category name - The average amount of points a specific category earned.', 'quiz-master-next');
 
 
129
  $variable_list['%POLL_RESULTS_X%'] = __('X = Question ID Note: only supported for multiple choice answers', 'quiz-master-next');
130
  $variable_list['%RESULT_ID%'] = __('Show result id', 'quiz-master-next');
131
  $variable_list['%QUESTION_ANSWER_X%'] = __('X = Question ID. It will show result of particular question.', 'quiz-master-next');
php/admin/quizzes-page.php CHANGED
@@ -70,8 +70,9 @@ function qsm_generate_quizzes_surveys_page() {
70
 
71
  //Pagination.
72
  $paged = filter_input(INPUT_GET, 'paged') ? absint(filter_input(INPUT_GET, 'paged')) : 1;
 
73
  if (!is_numeric($paged))
74
- $paged = 1;
75
  $limit = 10; // number of rows in page.
76
 
77
  $current_user = get_current_user_id();
@@ -118,9 +119,9 @@ function qsm_generate_quizzes_surveys_page() {
118
  }
119
  }
120
  }
121
-
122
- if (isset($_REQUEST['s']) && $_REQUEST['s'] != '') {
123
- $search = $_REQUEST['s'];
124
  $condition = " WHERE deleted='0' AND quiz_name LIKE '%$search%'";
125
  $qry = "SELECT COUNT('quiz_id') FROM {$wpdb->prefix}mlw_quizzes" . $condition;
126
  $total = $wpdb->get_var($qry);
@@ -134,20 +135,17 @@ function qsm_generate_quizzes_surveys_page() {
134
  //Next and previous page.
135
  $next_page = (int) $paged + 1;
136
 
137
- if ($next_page > $num_of_pages)
138
  $next_page = $num_of_pages;
 
139
 
140
  $prev_page = (int) $paged - 1;
141
 
142
- if ($prev_page < 1)
143
  $prev_page = 1;
 
144
 
145
- //Query for post
146
- $post_arr = array(
147
- 'post_type' => 'qsm_quiz',
148
- 'posts_per_page' => -1,
149
- 'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private')
150
- );
151
  //Check user role and fetch the quiz
152
  $user = wp_get_current_user();
153
  if (in_array('author', (array) $user->roles)) {
@@ -167,9 +165,24 @@ function qsm_generate_quizzes_surveys_page() {
167
  // Load our quizzes.
168
  $quizzes = $mlwQuizMasterNext->pluginHelper->get_quizzes(false, '', '', (array) $user->roles, $user->ID, $limit, $offset, $where);
169
  }
 
 
 
 
 
 
 
 
170
 
171
  // Load quiz posts.
172
  $post_to_quiz_array = array();
 
 
 
 
 
 
 
173
  $my_query = new WP_Query($post_arr);
174
 
175
  if ($my_query->have_posts()) {
@@ -203,21 +216,26 @@ function qsm_generate_quizzes_surveys_page() {
203
  );
204
  }
205
 
 
 
206
  $activity_date = date_i18n(get_option('date_format'), strtotime($quiz->last_activity));
207
  $activity_time = date('h:i:s A', strtotime($quiz->last_activity));
 
208
  $quiz_json_array[] = array(
209
  'id' => $quiz->quiz_id,
210
  'name' => esc_html($quiz->quiz_name),
211
  'link' => $post_to_quiz_array[$quiz->quiz_id]['link'],
212
  'postID' => $post_to_quiz_array[$quiz->quiz_id]['id'],
213
  'views' => $quiz->quiz_views,
214
- 'taken' => $quiz->quiz_taken,
 
215
  'lastActivity' => $activity_date,
216
  'lastActivityDateTime' => $activity_date . ' ' . $activity_time,
217
  'post_status' => $post_to_quiz_array[$quiz->quiz_id]['post_status'],
218
  );
219
  }
220
  $total_count = count($quiz_json_array);
 
221
  wp_localize_script('qsm_admin_script', 'qsmQuizObject', $quiz_json_array);
222
  ?>
223
  <div class="wrap qsm-quizes-page">
@@ -247,7 +265,8 @@ function qsm_generate_quizzes_surveys_page() {
247
  ?>">
248
  <p class="search-box">
249
  <label class="screen-reader-text" for="quiz_search"><?php esc_html_e('Search', 'quiz-master-next'); ?></label>
250
- <input type="search" id="quiz_search" name="s" value="<?php echo isset($_REQUEST['s']) && $_REQUEST['s'] != '' ? $_REQUEST['s'] : ''; ?>">
 
251
  <input id="search-submit" class="button" type="submit" name="btnSearchQuiz" value="Search Quiz">
252
  <?php if (class_exists('QSM_Export_Import')) { ?>
253
  <a class="button button-primary" href="<?php echo admin_url() . 'admin.php?page=qmn_addons&tab=export-and-import'; ?>" target="_blank"><?php _e('Import & Export', 'quiz-master-next'); ?></a>
@@ -386,6 +405,7 @@ function qsm_generate_quizzes_surveys_page() {
386
  </tr>
387
  <?php
388
  }
 
389
  }else{ ?>
390
  <tr>
391
  <td colspan="6" style="text-align: center;">
@@ -542,8 +562,8 @@ function qsm_generate_quizzes_surveys_page() {
542
  <h2 class="qsm-popup__title" id="modal-5-title"><?php _e('Extend QSM', 'quiz-master-next'); ?></h2>
543
  <a class="qsm-popup__close" aria-label="Close modal" data-micromodal-close></a>
544
  </header>
545
- <main class="qsm-popup__content" id="modal-5-content">
546
- <h3><b><?php _e('Export functionality is provided as Premium addon.', 'quiz-master-next'); ?></b></h3>
547
  </main>
548
  <footer class="qsm-popup__footer">
549
  <a style="color: white; text-decoration: none;" href="https://quizandsurveymaster.com/downloads/export-import/" target="_blank" class="qsm-popup__btn qsm-popup__btn-primary"><?php _e('Buy Now', 'quiz-master-next'); ?></a>
70
 
71
  //Pagination.
72
  $paged = filter_input(INPUT_GET, 'paged') ? absint(filter_input(INPUT_GET, 'paged')) : 1;
73
+ /* //Not required already checked above as integer.(AA)
74
  if (!is_numeric($paged))
75
+ $paged = 1;*/
76
  $limit = 10; // number of rows in page.
77
 
78
  $current_user = get_current_user_id();
119
  }
120
  }
121
  }
122
+ /*Set Request To Post as form method is Post.(AA)*/
123
+ if (isset($_POST['btnSearchQuiz']) && $_POST['s'] != '') {
124
+ $search = $_POST['s'];
125
  $condition = " WHERE deleted='0' AND quiz_name LIKE '%$search%'";
126
  $qry = "SELECT COUNT('quiz_id') FROM {$wpdb->prefix}mlw_quizzes" . $condition;
127
  $total = $wpdb->get_var($qry);
135
  //Next and previous page.
136
  $next_page = (int) $paged + 1;
137
 
138
+ if ($next_page > $num_of_pages){
139
  $next_page = $num_of_pages;
140
+ }
141
 
142
  $prev_page = (int) $paged - 1;
143
 
144
+ if ($prev_page < 1){
145
  $prev_page = 1;
146
+ }
147
 
148
+
 
 
 
 
 
149
  //Check user role and fetch the quiz
150
  $user = wp_get_current_user();
151
  if (in_array('author', (array) $user->roles)) {
165
  // Load our quizzes.
166
  $quizzes = $mlwQuizMasterNext->pluginHelper->get_quizzes(false, '', '', (array) $user->roles, $user->ID, $limit, $offset, $where);
167
  }
168
+ /*Written to get results form search.(AA)*/
169
+ if (isset($_POST['btnSearchQuiz']) && $_POST['s'] != '') {
170
+ $search_quiz = $_POST['s'];
171
+ $condition = " WHERE quiz_name LIKE '%$search_quiz%'";
172
+ $qry = "SELECT * FROM {$wpdb->prefix}mlw_quizzes" . $condition;
173
+ $quizzes = $wpdb->get_results($qry );
174
+
175
+ }
176
 
177
  // Load quiz posts.
178
  $post_to_quiz_array = array();
179
+ //Query for post
180
+ $post_arr = array(
181
+ 'post_type' => 'qsm_quiz',
182
+ 'paged' => $paged,
183
+ 'posts_per_page' => -1,
184
+ 'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private')
185
+ );
186
  $my_query = new WP_Query($post_arr);
187
 
188
  if ($my_query->have_posts()) {
216
  );
217
  }
218
 
219
+ $quiz_results_count = $wpdb->get_var( "SELECT COUNT(result_id) FROM {$wpdb->prefix}mlw_results WHERE `deleted`='0' AND `quiz_id`='{$quiz->quiz_id}'" );
220
+
221
  $activity_date = date_i18n(get_option('date_format'), strtotime($quiz->last_activity));
222
  $activity_time = date('h:i:s A', strtotime($quiz->last_activity));
223
+
224
  $quiz_json_array[] = array(
225
  'id' => $quiz->quiz_id,
226
  'name' => esc_html($quiz->quiz_name),
227
  'link' => $post_to_quiz_array[$quiz->quiz_id]['link'],
228
  'postID' => $post_to_quiz_array[$quiz->quiz_id]['id'],
229
  'views' => $quiz->quiz_views,
230
+ /*'taken' => $quiz->quiz_taken,*/
231
+ 'taken' => $quiz_results_count,
232
  'lastActivity' => $activity_date,
233
  'lastActivityDateTime' => $activity_date . ' ' . $activity_time,
234
  'post_status' => $post_to_quiz_array[$quiz->quiz_id]['post_status'],
235
  );
236
  }
237
  $total_count = count($quiz_json_array);
238
+
239
  wp_localize_script('qsm_admin_script', 'qsmQuizObject', $quiz_json_array);
240
  ?>
241
  <div class="wrap qsm-quizes-page">
265
  ?>">
266
  <p class="search-box">
267
  <label class="screen-reader-text" for="quiz_search"><?php esc_html_e('Search', 'quiz-master-next'); ?></label>
268
+ <!-- Changed Request to Post -->
269
+ <input type="search" id="quiz_search" name="s" value="<?php echo isset($_POST['s']) && $_POST['s'] != '' ? $_POST['s'] : ''; ?>">
270
  <input id="search-submit" class="button" type="submit" name="btnSearchQuiz" value="Search Quiz">
271
  <?php if (class_exists('QSM_Export_Import')) { ?>
272
  <a class="button button-primary" href="<?php echo admin_url() . 'admin.php?page=qmn_addons&tab=export-and-import'; ?>" target="_blank"><?php _e('Import & Export', 'quiz-master-next'); ?></a>
405
  </tr>
406
  <?php
407
  }
408
+
409
  }else{ ?>
410
  <tr>
411
  <td colspan="6" style="text-align: center;">
562
  <h2 class="qsm-popup__title" id="modal-5-title"><?php _e('Extend QSM', 'quiz-master-next'); ?></h2>
563
  <a class="qsm-popup__close" aria-label="Close modal" data-micromodal-close></a>
564
  </header>
565
+ <main class="qsm-popup__content" id="modal-5-content">
566
+ <h3><b><?php _e('Export functionality is provided as Premium addon.', 'quiz-master-next'); ?></b></h3>
567
  </main>
568
  <footer class="qsm-popup__footer">
569
  <a style="color: white; text-decoration: none;" href="https://quizandsurveymaster.com/downloads/export-import/" target="_blank" class="qsm-popup__btn qsm-popup__btn-primary"><?php _e('Buy Now', 'quiz-master-next'); ?></a>
php/classes/class-qmn-quiz-manager.php CHANGED
@@ -182,16 +182,16 @@ class QMNQuizManager {
182
  public function qsm_get_question_quick_result(){
183
  global $wpdb;
184
  $question_id = isset($_POST['question_id']) ? intval($_POST['question_id']) : 0;
185
- $answer = isset( $_POST['answer'] ) ? wp_kses_post( $_POST['answer'] ) : '';
186
  $question_array = $wpdb->get_row( "SELECT answer_array, question_answer_info FROM {$wpdb->prefix}mlw_questions WHERE question_id = ($question_id)", 'ARRAY_A' );
187
  $answer_array = unserialize($question_array['answer_array']);
188
- $correct_info_text = isset( $question_array['question_answer_info'] ) ? $question_array['question_answer_info'] : '';
189
  $show_correct_info = isset( $_POST['show_correct_info'] ) ? sanitize_text_field( $_POST['show_correct_info'] ) : 0;
190
  $got_ans = false;
191
  $correct_answer = false;
192
  if($answer_array && $got_ans === false){
193
- foreach ($answer_array as $key => $value) {
194
- if( htmlspecialchars_decode( $value[0], ENT_QUOTES ) == $answer && $value[2] == 1 ){
195
  $got_ans = true;
196
  $correct_answer = true;
197
  break;
@@ -906,9 +906,7 @@ class QMNQuizManager {
906
  $pages_count = 1;
907
  $current_page_number = 1;
908
  foreach ($qmn_quiz_questions as $mlw_question) {
909
- if( $pagination_optoin == 0 ){
910
- $question_display .= "<div class='quiz_section {$animation_effect} question-section-id-{$mlw_question->question_id} slide{$mlw_qmn_section_count}'>";
911
- } else {
912
  if( $pagination_optoin == 1 ){
913
  $question_display .='<div class="qsm-auto-page-row qsm-apc-' . $current_page_number . '" style="display: none;">';
914
  $current_page_number++;
@@ -918,12 +916,9 @@ class QMNQuizManager {
918
  $current_page_number++;
919
  }
920
  }
921
- }
922
  $question_id_list .= $mlw_question->question_id . "Q";
923
- $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
924
-
925
- $question_display .= "<div class='quiz_section {$animation_effect} question-section-id-{$mlw_question->question_id} slide{$mlw_qmn_section_count}'>";
926
-
927
  $question_display .= $mlwQuizMasterNext->pluginHelper->display_question($mlw_question->question_type_new, $mlw_question->question_id, $qmn_quiz_options);
928
 
929
  if (0 == $mlw_question->comments) {
@@ -940,14 +935,15 @@ class QMNQuizManager {
940
  $question_display .= "<div title=\"" . esc_attr(htmlspecialchars_decode($mlw_question->hints, ENT_QUOTES)) . "\" class='qsm_hint mlw_qmn_hint_link'>{$qmn_quiz_options->hint_text}</div>";
941
  $question_display .= "<br /><br />";
942
  }
943
- $question_display .= "</div>";
944
  if( $pagination_optoin == 0 ){
945
- $question_display .= '</div><!-- .quiz_section -->';
946
  } else if( $pagination_optoin == 1 ){
947
  $question_display .= '</div><!-- .qsm-auto-page-row -->';
948
  }else if ($pages_count % $pagination_optoin == 0 || $pages_count == count($qmn_quiz_questions)) { // end of the row or last
949
  $question_display .= '</div><!-- .qsm-auto-page-row -->';
950
  }
 
951
  $pages_count++;
952
  }
953
  if($enable_pagination_quiz){
182
  public function qsm_get_question_quick_result(){
183
  global $wpdb;
184
  $question_id = isset($_POST['question_id']) ? intval($_POST['question_id']) : 0;
185
+ $answer = isset( $_POST['answer'] ) ? stripslashes_deep( $_POST['answer'] ) : '';
186
  $question_array = $wpdb->get_row( "SELECT answer_array, question_answer_info FROM {$wpdb->prefix}mlw_questions WHERE question_id = ($question_id)", 'ARRAY_A' );
187
  $answer_array = unserialize($question_array['answer_array']);
188
+ $correct_info_text = isset( $question_array['question_answer_info'] ) ? html_entity_decode( $question_array['question_answer_info'] ) : '';
189
  $show_correct_info = isset( $_POST['show_correct_info'] ) ? sanitize_text_field( $_POST['show_correct_info'] ) : 0;
190
  $got_ans = false;
191
  $correct_answer = false;
192
  if($answer_array && $got_ans === false){
193
+ foreach ($answer_array as $key => $value) {
194
+ if( esc_html( $value[0]) == esc_html($answer) && $value[2] == 1 ){
195
  $got_ans = true;
196
  $correct_answer = true;
197
  break;
906
  $pages_count = 1;
907
  $current_page_number = 1;
908
  foreach ($qmn_quiz_questions as $mlw_question) {
909
+ if( $pagination_optoin != 0 ){
 
 
910
  if( $pagination_optoin == 1 ){
911
  $question_display .='<div class="qsm-auto-page-row qsm-apc-' . $current_page_number . '" style="display: none;">';
912
  $current_page_number++;
916
  $current_page_number++;
917
  }
918
  }
919
+ }
920
  $question_id_list .= $mlw_question->question_id . "Q";
921
+ $question_display .= "<div class='quiz_section {$animation_effect} question-section-id-{$mlw_question->question_id} slide{$mlw_qmn_section_count}'>";
 
 
 
922
  $question_display .= $mlwQuizMasterNext->pluginHelper->display_question($mlw_question->question_type_new, $mlw_question->question_id, $qmn_quiz_options);
923
 
924
  if (0 == $mlw_question->comments) {
935
  $question_display .= "<div title=\"" . esc_attr(htmlspecialchars_decode($mlw_question->hints, ENT_QUOTES)) . "\" class='qsm_hint mlw_qmn_hint_link'>{$qmn_quiz_options->hint_text}</div>";
936
  $question_display .= "<br /><br />";
937
  }
938
+ $question_display .= '</div><!-- .quiz_section -->';
939
  if( $pagination_optoin == 0 ){
940
+
941
  } else if( $pagination_optoin == 1 ){
942
  $question_display .= '</div><!-- .qsm-auto-page-row -->';
943
  }else if ($pages_count % $pagination_optoin == 0 || $pages_count == count($qmn_quiz_questions)) { // end of the row or last
944
  $question_display .= '</div><!-- .qsm-auto-page-row -->';
945
  }
946
+ $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
947
  $pages_count++;
948
  }
949
  if($enable_pagination_quiz){
php/classes/class-qsm-install.php CHANGED
@@ -822,7 +822,10 @@ class QSM_Install {
822
  'default' => 0,
823
  'variables' => array(
824
  '%QUIZ_NAME%',
825
- '%CURRENT_DATE%'
 
 
 
826
  )
827
  );
828
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
@@ -835,7 +838,10 @@ class QSM_Install {
835
  'default' => 0,
836
  'variables' => array(
837
  '%QUIZ_NAME%',
838
- '%CURRENT_DATE%'
 
 
 
839
  )
840
  );
841
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
@@ -848,7 +854,10 @@ class QSM_Install {
848
  'default' => 0,
849
  'variables' => array(
850
  '%QUIZ_NAME%',
851
- '%CURRENT_DATE%'
 
 
 
852
  )
853
  );
854
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
@@ -861,6 +870,7 @@ class QSM_Install {
861
  'default' => 0,
862
  'variables' => array(
863
  '%QUIZ_NAME%',
 
864
  '%CURRENT_DATE%'
865
  )
866
  );
@@ -874,7 +884,10 @@ class QSM_Install {
874
  'default' => 0,
875
  'variables' => array(
876
  '%QUIZ_NAME%',
877
- '%CURRENT_DATE%'
 
 
 
878
  )
879
  );
880
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
@@ -887,7 +900,10 @@ class QSM_Install {
887
  'default' => 0,
888
  'variables' => array(
889
  '%QUIZ_NAME%',
890
- '%CURRENT_DATE%'
 
 
 
891
  )
892
  );
893
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
@@ -900,6 +916,7 @@ class QSM_Install {
900
  'default' => 0,
901
  'variables' => array(
902
  '%QUIZ_NAME%',
 
903
  '%CURRENT_DATE%'
904
  )
905
  );
@@ -918,7 +935,8 @@ class QSM_Install {
918
  '%CORRECT_ANSWER%',
919
  '%USER_COMMENTS%',
920
  '%CORRECT_ANSWER_INFO%',
921
- '%QUESTION_POINT_SCORE%'
 
922
  )
923
  );
924
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
@@ -934,7 +952,9 @@ class QSM_Install {
934
  '%USER_ANSWER%',
935
  '%CORRECT_ANSWER%',
936
  '%USER_COMMENTS%',
937
- '%CORRECT_ANSWER_INFO%'
 
 
938
  )
939
  );
940
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
@@ -952,6 +972,8 @@ class QSM_Install {
952
  '%TOTAL_QUESTIONS%',
953
  '%CORRECT_SCORE%',
954
  '%QUIZ_NAME%',
 
 
955
  '%TIMER%',
956
  '%CURRENT_DATE%'
957
  )
@@ -971,6 +993,8 @@ class QSM_Install {
971
  '%TOTAL_QUESTIONS%',
972
  '%CORRECT_SCORE%',
973
  '%QUIZ_NAME%',
 
 
974
  '%TIMER%',
975
  '%CURRENT_DATE%'
976
  )
822
  'default' => 0,
823
  'variables' => array(
824
  '%QUIZ_NAME%',
825
+ '%QUIZ_LINK%',
826
+ '%CURRENT_DATE%',
827
+ '%FACEBOOK_SHARE%',
828
+ '%TWITTER_SHARE%'
829
  )
830
  );
831
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
838
  'default' => 0,
839
  'variables' => array(
840
  '%QUIZ_NAME%',
841
+ '%QUIZ_LINK%',
842
+ '%CURRENT_DATE%',
843
+ '%FACEBOOK_SHARE%',
844
+ '%TWITTER_SHARE%'
845
  )
846
  );
847
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
854
  'default' => 0,
855
  'variables' => array(
856
  '%QUIZ_NAME%',
857
+ '%QUIZ_LINK%',
858
+ '%CURRENT_DATE%',
859
+ '%FACEBOOK_SHARE%',
860
+ '%TWITTER_SHARE%'
861
  )
862
  );
863
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
870
  'default' => 0,
871
  'variables' => array(
872
  '%QUIZ_NAME%',
873
+ '%QUIZ_LINK%',
874
  '%CURRENT_DATE%'
875
  )
876
  );
884
  'default' => 0,
885
  'variables' => array(
886
  '%QUIZ_NAME%',
887
+ '%QUIZ_LINK%',
888
+ '%CURRENT_DATE%',
889
+ '%FACEBOOK_SHARE%',
890
+ '%TWITTER_SHARE%'
891
  )
892
  );
893
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
900
  'default' => 0,
901
  'variables' => array(
902
  '%QUIZ_NAME%',
903
+ '%QUIZ_LINK%',
904
+ '%CURRENT_DATE%',
905
+ '%FACEBOOK_SHARE%',
906
+ '%TWITTER_SHARE%'
907
  )
908
  );
909
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
916
  'default' => 0,
917
  'variables' => array(
918
  '%QUIZ_NAME%',
919
+ '%QUIZ_LINK%',
920
  '%CURRENT_DATE%'
921
  )
922
  );
935
  '%CORRECT_ANSWER%',
936
  '%USER_COMMENTS%',
937
  '%CORRECT_ANSWER_INFO%',
938
+ '%QUESTION_POINT_SCORE%',
939
+ '%QUESTION_MAX_POINTS%'
940
  )
941
  );
942
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
952
  '%USER_ANSWER%',
953
  '%CORRECT_ANSWER%',
954
  '%USER_COMMENTS%',
955
+ '%CORRECT_ANSWER_INFO%',
956
+ '%QUESTION_POINT_SCORE%',
957
+ '%QUESTION_MAX_POINTS%'
958
  )
959
  );
960
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
972
  '%TOTAL_QUESTIONS%',
973
  '%CORRECT_SCORE%',
974
  '%QUIZ_NAME%',
975
+ '%QUIZ_LINK%',
976
+ '%RESULT_LINK%',
977
  '%TIMER%',
978
  '%CURRENT_DATE%'
979
  )
993
  '%TOTAL_QUESTIONS%',
994
  '%CORRECT_SCORE%',
995
  '%QUIZ_NAME%',
996
+ '%QUIZ_LINK%',
997
+ '%RESULT_LINK%',
998
  '%TIMER%',
999
  '%CURRENT_DATE%'
1000
  )
php/classes/class-qsm-questions.php CHANGED
@@ -263,7 +263,7 @@ class QSM_Questions {
263
  'quiz_id' => intval( $data['quiz_id'] ),
264
  'question_name' => trim( preg_replace( '/\s+/', ' ', htmlspecialchars( wp_kses_post( $data['name'] ), ENT_QUOTES ) ) ),
265
  'answer_array' => serialize( $answers ),
266
- 'question_answer_info' => htmlspecialchars( $data['answer_info'], ENT_QUOTES ),
267
  'comments' => htmlspecialchars( $data['comments'], ENT_QUOTES ),
268
  'hints' => htmlspecialchars( $data['hint'], ENT_QUOTES ),
269
  'question_order' => intval( $data['order'] ),
263
  'quiz_id' => intval( $data['quiz_id'] ),
264
  'question_name' => trim( preg_replace( '/\s+/', ' ', htmlspecialchars( wp_kses_post( $data['name'] ), ENT_QUOTES ) ) ),
265
  'answer_array' => serialize( $answers ),
266
+ 'question_answer_info' => htmlentities( $data['answer_info'], ENT_QUOTES ),
267
  'comments' => htmlspecialchars( $data['comments'], ENT_QUOTES ),
268
  'hints' => htmlspecialchars( $data['hint'], ENT_QUOTES ),
269
  'question_order' => intval( $data['order'] ),
php/question-types.php CHANGED
@@ -143,60 +143,61 @@ function qmn_multiple_choice_display($id, $question, $answers)
143
  * @return $return_array Returns the graded question to the results page
144
  * @since 4.4.0
145
  */
146
- function qmn_multiple_choice_review($id, $question, $answers)
147
- {
148
  global $mlwQuizMasterNext;
149
- $return_array = array(
150
- 'points' => 0,
151
- 'correct' => 'incorrect',
152
- 'user_text' => '',
153
- 'correct_text' => ''
154
- );
155
  $answerEditor = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'answerEditor');
156
- if ( isset( $_POST["question".$id] ) ) {
157
- $mlw_user_answer = $_POST["question".$id];
158
- $mlw_user_answer = trim( stripslashes( htmlspecialchars_decode($mlw_user_answer, ENT_QUOTES) ) );
159
- } else {
160
- $mlw_user_answer = " ";
161
- }
162
- $return_array['user_text'] = stripslashes( htmlspecialchars_decode($mlw_user_answer, ENT_QUOTES) );
163
- $rich_text_comapre = preg_replace("/\s+|\n+|\r/", ' ', htmlentities( $mlw_user_answer ));
164
- foreach($answers as $answer){
165
- if($answerEditor === 'rich'){
166
- $answer_option = stripslashes( htmlspecialchars_decode($answer[0], ENT_QUOTES) );
167
- $sinel_answer_cmp = preg_replace("/\s+|\n+|\r/", ' ', htmlentities( $answer_option ));
168
- if ( $rich_text_comapre == $sinel_answer_cmp ){
169
- $return_array["points"] = $answer[1];
170
- $return_array["user_text"] = $answer[0];
171
- if ($answer[2] == 1){
172
- $return_array["correct"] = "correct";
173
- }
174
- }
175
- if ($answer[2] == 1){
176
- $return_array["correct_text"] = stripslashes( htmlspecialchars_decode($answer[0], ENT_QUOTES) );
177
- }
178
- } else {
179
- $mlw_user_answer = '';
180
- if ( isset( $_POST["question".$id] ) ) {
181
- $mlw_user_answer = $_POST["question".$id];
182
- $mlw_user_answer = trim( htmlspecialchars_decode($mlw_user_answer, ENT_QUOTES) );
183
- $mlw_user_answer = str_replace('\\', "", $mlw_user_answer);
184
- }
185
- $single_answer = trim( htmlspecialchars_decode($answer[0], ENT_QUOTES) );
186
- $single_answer = str_replace('\\', "", $single_answer);
187
- if ( $mlw_user_answer == $single_answer ){
188
- $return_array["points"] = $answer[1];
189
- $return_array["user_text"] = $answer[0];
190
- if ($answer[2] == 1){
191
- $return_array["correct"] = "correct";
192
- }
193
- }
194
- if ($answer[2] == 1){
195
- $return_array["correct_text"] = htmlspecialchars_decode($answer[0], ENT_QUOTES);
196
- }
197
- }
198
- }
199
- return $return_array;
 
 
200
  }
201
 
202
  add_action("plugins_loaded", 'qmn_question_type_date');
@@ -329,54 +330,52 @@ function qmn_horizontal_multiple_choice_display($id, $question, $answers)
329
  * @return $return_array Returns the graded question to the results page
330
  * @since 4.4.0
331
  */
332
- function qmn_horizontal_multiple_choice_review($id, $question, $answers)
333
- {
334
  global $mlwQuizMasterNext;
335
  $answerEditor = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'answerEditor');
336
- $return_array = array(
337
- 'points' => 0,
338
- 'correct' => 'incorrect',
339
- 'user_text' => '',
340
- 'correct_text' => ''
341
- );
342
- if ( isset( $_POST["question".$id] ) ) {
343
- $mlw_user_answer = $_POST["question".$id];
344
- $mlw_user_answer = trim( stripslashes( htmlspecialchars_decode($mlw_user_answer, ENT_QUOTES) ) );
345
- } else {
346
- $mlw_user_answer = " ";
347
- }
348
- $rich_text_comapre = preg_replace("/\s+|\n+|\r/", ' ', htmlentities( $mlw_user_answer ));
349
- foreach($answers as $answer){
350
- if($answerEditor === 'rich'){
351
- $answer_option = stripslashes( htmlspecialchars_decode($answer[0], ENT_QUOTES) );
352
- $sinel_answer_cmp = preg_replace("/\s+|\n+|\r/", ' ', htmlentities( $answer_option ));
353
- if ( $rich_text_comapre == $sinel_answer_cmp ){
354
- $return_array["points"] = $answer[1];
355
- $return_array["user_text"] = $answer[0];
356
- if ($answer[2] == 1){
357
- $return_array["correct"] = "correct";
358
- }
359
- }
360
- if ($answer[2] == 1){
361
- $return_array["correct_text"] = htmlspecialchars_decode($answer[0], ENT_QUOTES);
362
- }
363
- } else{
364
- if ( $mlw_user_answer == trim( stripslashes( htmlspecialchars_decode($answer[0], ENT_QUOTES) ) ) ){
365
- $return_array["points"] = $answer[1];
366
- $return_array["user_text"] = $answer[0];
367
- if ($answer[2] == 1)
368
- {
369
- $return_array["correct"] = "correct";
370
- }
371
- }
372
- if ($answer[2] == 1)
373
- {
374
- $return_array["correct_text"] = htmlspecialchars_decode($answer[0], ENT_QUOTES);
375
- }
376
- }
377
-
378
- }
379
- return $return_array;
380
  }
381
 
382
  add_action("plugins_loaded", 'qmn_question_type_drop_down');
@@ -620,48 +619,41 @@ function qmn_multiple_response_display($id, $question, $answers)
620
  * @return $return_array Returns the graded question to the results page
621
  * @since 4.4.0
622
  */
623
- function qmn_multiple_response_review($id, $question, $answers)
624
- {
625
- $return_array = array(
626
- 'points' => 0,
627
- 'correct' => 'incorrect',
628
- 'user_text' => '',
629
- 'correct_text' => '',
630
- 'user_compare_text' => ''
631
- );
632
- $user_correct = 0;
633
- $total_correct = 0;
634
- $total_answers = count($answers);
635
- foreach($answers as $answer)
636
- {
637
- for ($i = 1; $i <= $total_answers; $i++)
638
- {
639
- if (isset($_POST["question".$id."_".$i]) && sanitize_textarea_field( htmlspecialchars(stripslashes($_POST["question".$id."_".$i]), ENT_QUOTES) ) == esc_attr($answer[0]))
640
- {
641
- $return_array["points"] += $answer[1];
642
- $return_array["user_text"] .= sanitize_textarea_field( strval(htmlspecialchars_decode($answer[0], ENT_QUOTES)) ) .".";
643
- $return_array["user_compare_text"] .= sanitize_textarea_field( strval(htmlspecialchars_decode($answer[0], ENT_QUOTES)) ) ."=====";
644
- if ($answer[2] == 1)
645
- {
646
- $user_correct += 1;
647
- }
648
- else
649
- {
650
- $user_correct = -1;
651
- }
652
- }
653
- }
654
- if ($answer[2] == 1)
655
- {
656
- $return_array["correct_text"] .= htmlspecialchars_decode($answer[0], ENT_QUOTES).".";
657
- $total_correct++;
658
- }
659
- }
660
- if ($user_correct == $total_correct)
661
- {
662
- $return_array["correct"] = "correct";
663
- }
664
- return $return_array;
665
  }
666
 
667
  add_action("plugins_loaded", 'qmn_question_type_large_open');
@@ -691,11 +683,13 @@ function qmn_large_open_display($id, $question, $answers)
691
  $question_display = '';
692
  global $mlwQuizMasterNext;
693
  $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
 
694
  if ($required == 0) {$mlw_requireClass = "mlwRequiredText";} else {$mlw_requireClass = "";}
 
695
  //$question_title = apply_filters('the_content', $question);
696
  $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
697
  $question_display .= qsm_question_title_func($question, '', $new_question_title);
698
- $question_display .= "<textarea class='mlw_answer_open_text $mlw_requireClass' cols='70' rows='5' name='question".$id."' /></textarea>";
699
  return apply_filters('qmn_large_open_display_front',$question_display,$id, $question, $answers);
700
  }
701
 
@@ -1033,48 +1027,41 @@ function qmn_horizontal_multiple_response_display($id, $question, $answers)
1033
  * @return $return_array Returns the graded question to the Results page
1034
  * @since 4.4.0
1035
  */
1036
- function qmn_horizontal_multiple_response_review($id, $question, $answers)
1037
- {
1038
- $return_array = array(
1039
- 'points' => 0,
1040
- 'correct' => 'incorrect',
1041
- 'user_text' => '',
1042
- 'correct_text' => '',
1043
- 'user_compare_text' => ''
1044
- );
1045
- $user_correct = 0;
1046
- $total_correct = 0;
1047
- $total_answers = count($answers);
1048
- foreach($answers as $answer)
1049
- {
1050
- for ($i = 1; $i <= $total_answers; $i++)
1051
- {
1052
- if (isset($_POST["question".$id."_".$i]) && sanitize_textarea_field( htmlspecialchars(stripslashes($_POST["question".$id."_".$i]), ENT_QUOTES) ) == esc_attr($answer[0]))
1053
- {
1054
- $return_array["points"] += $answer[1];
1055
- $return_array["user_text"] .= strval(htmlspecialchars_decode($answer[0], ENT_QUOTES)).".";
1056
- $return_array["user_compare_text"] .= sanitize_textarea_field( strval(htmlspecialchars_decode($answer[0], ENT_QUOTES)) ) ."=====";
1057
- if ($answer[2] == 1)
1058
- {
1059
- $user_correct += 1;
1060
- }
1061
- else
1062
- {
1063
- $user_correct = -1;
1064
- }
1065
- }
1066
- }
1067
- if ($answer[2] == 1)
1068
- {
1069
- $return_array["correct_text"] .= htmlspecialchars_decode($answer[0], ENT_QUOTES).".";
1070
- $total_correct++;
1071
- }
1072
- }
1073
- if ($user_correct == $total_correct)
1074
- {
1075
- $return_array["correct"] = "correct";
1076
- }
1077
- return $return_array;
1078
  }
1079
 
1080
  add_action("plugins_loaded", 'qmn_question_type_fill_blank');
143
  * @return $return_array Returns the graded question to the results page
144
  * @since 4.4.0
145
  */
146
+ function qmn_multiple_choice_review($id, $question, $answers) {
 
147
  global $mlwQuizMasterNext;
148
+ $return_array = array(
149
+ 'points' => 0,
150
+ 'correct' => 'incorrect',
151
+ 'user_text' => '',
152
+ 'correct_text' => ''
153
+ );
154
  $answerEditor = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'answerEditor');
155
+ if (isset($_POST["question" . $id])) {
156
+ $mlw_user_answer = $_POST["question" . $id];
157
+ $mlw_user_answer = trim(stripslashes(htmlspecialchars_decode($mlw_user_answer, ENT_QUOTES)));
158
+ } else {
159
+ $mlw_user_answer = " ";
160
+ }
161
+ $return_array['user_text'] = stripslashes(htmlspecialchars_decode($mlw_user_answer, ENT_QUOTES));
162
+ $rich_text_comapre = preg_replace("/\s+|\n+|\r/", ' ', htmlentities($mlw_user_answer));
163
+ $correct_text = array();
164
+ foreach ($answers as $answer) {
165
+ if ($answerEditor === 'rich') {
166
+ $answer_option = stripslashes(htmlspecialchars_decode($answer[0], ENT_QUOTES));
167
+ $sinel_answer_cmp = preg_replace("/\s+|\n+|\r/", ' ', htmlentities($answer_option));
168
+ if ($rich_text_comapre == $sinel_answer_cmp) {
169
+ $return_array["points"] = $answer[1];
170
+ $return_array["user_text"] = $answer[0];
171
+ if ($answer[2] == 1) {
172
+ $return_array["correct"] = "correct";
173
+ }
174
+ }
175
+ if ($answer[2] == 1) {
176
+ $correct_text[] = stripslashes(htmlspecialchars_decode($answer[0], ENT_QUOTES));
177
+ }
178
+ } else {
179
+ $mlw_user_answer = '';
180
+ if (isset($_POST["question" . $id])) {
181
+ $mlw_user_answer = $_POST["question" . $id];
182
+ $mlw_user_answer = trim(htmlspecialchars_decode($mlw_user_answer, ENT_QUOTES));
183
+ $mlw_user_answer = str_replace('\\', "", $mlw_user_answer);
184
+ }
185
+ $single_answer = trim(htmlspecialchars_decode($answer[0], ENT_QUOTES));
186
+ $single_answer = str_replace('\\', "", $single_answer);
187
+ if ($mlw_user_answer == $single_answer) {
188
+ $return_array["points"] = $answer[1];
189
+ $return_array["user_text"] = $answer[0];
190
+ if ($answer[2] == 1) {
191
+ $return_array["correct"] = "correct";
192
+ }
193
+ }
194
+ if ($answer[2] == 1) {
195
+ $correct_text[] = stripslashes(htmlspecialchars_decode($answer[0], ENT_QUOTES));
196
+ }
197
+ }
198
+ }
199
+ $return_array["correct_text"] = implode('.', $correct_text);
200
+ return $return_array;
201
  }
202
 
203
  add_action("plugins_loaded", 'qmn_question_type_date');
330
  * @return $return_array Returns the graded question to the results page
331
  * @since 4.4.0
332
  */
333
+ function qmn_horizontal_multiple_choice_review($id, $question, $answers) {
 
334
  global $mlwQuizMasterNext;
335
  $answerEditor = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'answerEditor');
336
+ $return_array = array(
337
+ 'points' => 0,
338
+ 'correct' => 'incorrect',
339
+ 'user_text' => '',
340
+ 'correct_text' => ''
341
+ );
342
+ if (isset($_POST["question" . $id])) {
343
+ $mlw_user_answer = $_POST["question" . $id];
344
+ $mlw_user_answer = trim(stripslashes(htmlspecialchars_decode($mlw_user_answer, ENT_QUOTES)));
345
+ } else {
346
+ $mlw_user_answer = " ";
347
+ }
348
+ $rich_text_comapre = preg_replace("/\s+|\n+|\r/", ' ', htmlentities($mlw_user_answer));
349
+ $correct_text = array();
350
+ foreach ($answers as $answer) {
351
+ if ($answerEditor === 'rich') {
352
+ $answer_option = stripslashes(htmlspecialchars_decode($answer[0], ENT_QUOTES));
353
+ $sinel_answer_cmp = preg_replace("/\s+|\n+|\r/", ' ', htmlentities($answer_option));
354
+ if ($rich_text_comapre == $sinel_answer_cmp) {
355
+ $return_array["points"] = $answer[1];
356
+ $return_array["user_text"] = $answer[0];
357
+ if ($answer[2] == 1) {
358
+ $return_array["correct"] = "correct";
359
+ }
360
+ }
361
+ if ($answer[2] == 1) {
362
+ $correct_text[] = stripslashes(htmlspecialchars_decode($answer[0], ENT_QUOTES));
363
+ }
364
+ } else {
365
+ if ($mlw_user_answer == trim(stripslashes(htmlspecialchars_decode($answer[0], ENT_QUOTES)))) {
366
+ $return_array["points"] = $answer[1];
367
+ $return_array["user_text"] = $answer[0];
368
+ if ($answer[2] == 1) {
369
+ $return_array["correct"] = "correct";
370
+ }
371
+ }
372
+ if ($answer[2] == 1) {
373
+ $correct_text[] = stripslashes(htmlspecialchars_decode($answer[0], ENT_QUOTES));
374
+ }
375
+ }
376
+ }
377
+ $return_array["correct_text"] = implode('.', $correct_text);
378
+ return $return_array;
 
379
  }
380
 
381
  add_action("plugins_loaded", 'qmn_question_type_drop_down');
619
  * @return $return_array Returns the graded question to the results page
620
  * @since 4.4.0
621
  */
622
+ function qmn_multiple_response_review($id, $question, $answers) {
623
+ $return_array = array(
624
+ 'points' => 0,
625
+ 'correct' => 'incorrect',
626
+ 'user_text' => '',
627
+ 'correct_text' => '',
628
+ 'user_compare_text' => ''
629
+ );
630
+ $user_correct = 0;
631
+ $total_correct = 0;
632
+ $total_answers = count($answers);
633
+ $correct_text = array();
634
+ foreach ($answers as $answer) {
635
+ for ($i = 1; $i <= $total_answers; $i++) {
636
+ if (isset($_POST["question" . $id . "_" . $i]) && sanitize_textarea_field(htmlspecialchars(stripslashes($_POST["question" . $id . "_" . $i]), ENT_QUOTES)) == esc_attr($answer[0])) {
637
+ $return_array["points"] += $answer[1];
638
+ $return_array["user_text"] .= sanitize_textarea_field(strval(htmlspecialchars_decode($answer[0], ENT_QUOTES))) . ".";
639
+ $return_array["user_compare_text"] .= sanitize_textarea_field(strval(htmlspecialchars_decode($answer[0], ENT_QUOTES))) . "=====";
640
+ if ($answer[2] == 1) {
641
+ $user_correct += 1;
642
+ } else {
643
+ $user_correct = -1;
644
+ }
645
+ }
646
+ }
647
+ if ($answer[2] == 1) {
648
+ $correct_text[] = stripslashes(htmlspecialchars_decode($answer[0], ENT_QUOTES));
649
+ $total_correct++;
650
+ }
651
+ }
652
+ if ($user_correct == $total_correct) {
653
+ $return_array["correct"] = "correct";
654
+ }
655
+ $return_array["correct_text"] = implode('.', $correct_text);
656
+ return $return_array;
 
 
 
 
 
 
 
657
  }
658
 
659
  add_action("plugins_loaded", 'qmn_question_type_large_open');
683
  $question_display = '';
684
  global $mlwQuizMasterNext;
685
  $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
686
+ $limit_text = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'limit_text');
687
  if ($required == 0) {$mlw_requireClass = "mlwRequiredText";} else {$mlw_requireClass = "";}
688
+ $limit_text_att = $limit_text ? "maxlength='". $limit_text ."' " : '';
689
  //$question_title = apply_filters('the_content', $question);
690
  $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
691
  $question_display .= qsm_question_title_func($question, '', $new_question_title);
692
+ $question_display .= "<textarea class='mlw_answer_open_text {$mlw_requireClass}' {$limit_text_att} cols='70' rows='5' name='question{$id}' /></textarea>";
693
  return apply_filters('qmn_large_open_display_front',$question_display,$id, $question, $answers);
694
  }
695
 
1027
  * @return $return_array Returns the graded question to the Results page
1028
  * @since 4.4.0
1029
  */
1030
+ function qmn_horizontal_multiple_response_review($id, $question, $answers) {
1031
+ $return_array = array(
1032
+ 'points' => 0,
1033
+ 'correct' => 'incorrect',
1034
+ 'user_text' => '',
1035
+ 'correct_text' => '',
1036
+ 'user_compare_text' => ''
1037
+ );
1038
+ $user_correct = 0;
1039
+ $total_correct = 0;
1040
+ $total_answers = count($answers);
1041
+ $correct_text = array();
1042
+ foreach ($answers as $answer) {
1043
+ for ($i = 1; $i <= $total_answers; $i++) {
1044
+ if (isset($_POST["question" . $id . "_" . $i]) && sanitize_textarea_field(htmlspecialchars(stripslashes($_POST["question" . $id . "_" . $i]), ENT_QUOTES)) == esc_attr($answer[0])) {
1045
+ $return_array["points"] += $answer[1];
1046
+ $return_array["user_text"] .= strval(htmlspecialchars_decode($answer[0], ENT_QUOTES)) . ".";
1047
+ $return_array["user_compare_text"] .= sanitize_textarea_field(strval(htmlspecialchars_decode($answer[0], ENT_QUOTES))) . "=====";
1048
+ if ($answer[2] == 1) {
1049
+ $user_correct += 1;
1050
+ } else {
1051
+ $user_correct = -1;
1052
+ }
1053
+ }
1054
+ }
1055
+ if ($answer[2] == 1) {
1056
+ $correct_text[] = stripslashes(htmlspecialchars_decode($answer[0], ENT_QUOTES));
1057
+ $total_correct++;
1058
+ }
1059
+ }
1060
+ if ($user_correct == $total_correct) {
1061
+ $return_array["correct"] = "correct";
1062
+ }
1063
+ $return_array["correct_text"] = implode('.', $correct_text);
1064
+ return $return_array;
 
 
 
 
 
 
 
1065
  }
1066
 
1067
  add_action("plugins_loaded", 'qmn_question_type_fill_blank');
php/template-variables.php CHANGED
@@ -46,6 +46,7 @@ add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_amount_in
46
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_total_questions',10,2);
47
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_correct_score',10,2);
48
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_quiz_name',10,2);
 
49
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_user_name',10,2);
50
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_user_business',10,2);
51
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_user_phone',10,2);
@@ -56,8 +57,7 @@ add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_timer',10
56
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_timer_minutes',10,2);
57
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_date',10,2);
58
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_date_taken',10,2);
59
- add_filter('mlw_qmn_template_variable_results_page', 'qsm_variable_facebook_share',10,2);
60
- add_filter('mlw_qmn_template_variable_results_page', 'qsm_variable_twitter_share',10,2);
61
  add_filter('mlw_qmn_template_variable_results_page', 'qsm_variable_result_id',10,2);
62
  add_filter('mlw_qmn_template_variable_results_page', 'qsm_variable_single_question_answer',20,2);
63
  add_filter('mlw_qmn_template_variable_results_page', 'qsm_variable_total_possible_points',10,2);
@@ -65,8 +65,10 @@ add_filter('mlw_qmn_template_variable_results_page', 'qsm_variable_total_attempt
65
  add_filter('qmn_end_results', 'qsm_variable_poll_result',10,3);
66
 
67
  add_filter('mlw_qmn_template_variable_quiz_page', 'mlw_qmn_variable_quiz_name',10,2);
 
68
  add_filter('mlw_qmn_template_variable_quiz_page', 'mlw_qmn_variable_date',10,2);
69
  add_filter('mlw_qmn_template_variable_quiz_page', 'mlw_qmn_variable_current_user',10,2);
 
70
 
71
  /**
72
  * @since 6.4.11
@@ -223,42 +225,43 @@ function qsm_find_key_from_array($search_value,$array){
223
  }
224
 
225
  /**
226
- * Adds Facebook sharing link using the %FACEBOOK_SHARE% variable
227
  */
228
- function qsm_variable_facebook_share( $content, $mlw_quiz_array ) {
229
- if ( false !== strpos($content, '%FACEBOOK_SHARE%') ) {
230
- wp_enqueue_script( 'qmn_quiz_social_share', plugins_url( '../../js/qmn_social_share.js' , __FILE__ ) );
231
- $settings = (array) get_option( 'qmn-settings' );
 
232
  $facebook_app_id = '483815031724529';
233
- if ( isset( $settings['facebook_app_id'] ) ) {
234
- $facebook_app_id = esc_js( $settings['facebook_app_id'] );
235
  }
236
-
237
- global $mlwQuizMasterNext;
238
- $sharing = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'facebook_sharing_text', '' );
239
- $url = qsm_get_post_id_from_quiz_id($mlw_quiz_array['quiz_id']);
240
- $page_link = $url . '?result_id=' . '%FB_RESULT_ID%';
241
- $sharing = apply_filters( 'mlw_qmn_template_variable_results_page', $sharing, $mlw_quiz_array);
242
- $fb_image = plugins_url('', dirname(__FILE__) ) . '/assets/facebook.png';
243
- $social_display = "<a class=\"mlw_qmn_quiz_link\" onclick=\"qmnSocialShare('facebook', '".esc_js( $sharing )."', '".esc_js($mlw_quiz_array["quiz_name"])."', '$facebook_app_id', '$page_link');\"><img src='". $fb_image ."' alt='Facebbok Share' /></a>";
244
- $content = str_replace( "%FACEBOOK_SHARE%" , $social_display, $content);
 
 
 
245
  }
246
- return $content;
247
- }
248
-
249
- /**
250
- * Adds Twitter sharing link using the %TWITTER_SHARE% variable
251
- */
252
- function qsm_variable_twitter_share( $content, $mlw_quiz_array ) {
253
- while ( false !== strpos($content, '%TWITTER_SHARE%') ) {
254
- wp_enqueue_script( 'qmn_quiz_social_share', plugins_url( '../../js/qmn_social_share.js' , __FILE__ ) );
255
-
256
- global $mlwQuizMasterNext;
257
- $sharing = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'twitter_sharing_text', '' );
258
- $sharing = apply_filters( 'mlw_qmn_template_variable_results_page', $sharing, $mlw_quiz_array);
259
- $tw_image = plugins_url('', dirname(__FILE__) ) . '/assets/twitter.png';
260
- $social_display = "<a class=\"mlw_qmn_quiz_link\" onclick=\"qmnSocialShare('twitter', '".esc_js( $sharing )."', '".esc_js($mlw_quiz_array["quiz_name"])."');\"><img src='". $tw_image ."' alt='Twitter Share' /></a>";
261
- $content = str_replace( "%TWITTER_SHARE%" , $social_display, $content);
262
  }
263
  return $content;
264
  }
@@ -278,7 +281,7 @@ function qsm_variable_result_id( $content, $mlw_quiz_array ) {
278
 
279
  function mlw_qmn_variable_point_score($content, $mlw_quiz_array)
280
  {
281
- $content = str_replace( "%POINT_SCORE%" , $mlw_quiz_array["total_points"], $content);
282
  return $content;
283
  }
284
  function mlw_qmn_variable_average_point($content, $mlw_quiz_array){
@@ -290,7 +293,7 @@ function mlw_qmn_variable_average_point($content, $mlw_quiz_array){
290
  }
291
  }
292
  }
293
- if ($mlw_quiz_array["total_questions"] != 0 && $question_total != 0){
294
  $mlw_average_points = round($mlw_quiz_array["total_points"]/$question_total, 2);
295
  }
296
  else
@@ -300,9 +303,9 @@ function mlw_qmn_variable_average_point($content, $mlw_quiz_array){
300
  $content = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $content);
301
  return $content;
302
  }
303
- function mlw_qmn_variable_amount_correct($content, $mlw_quiz_array)
304
- {
305
- $content = str_replace( "%AMOUNT_CORRECT%" , $mlw_quiz_array["total_correct"], $content);
306
  return $content;
307
  }
308
 
@@ -314,54 +317,71 @@ function mlw_qmn_variable_amount_correct($content, $mlw_quiz_array)
314
  * @param array $mlw_quiz_array
315
  * @return string
316
  */
317
- function mlw_qmn_variable_amount_incorrect($content, $mlw_quiz_array){
318
- if( false !== strpos($content, '%AMOUNT_INCORRECT%') ){
319
- $total_question = $mlw_quiz_array["total_questions"];
320
- $total_correct = $mlw_quiz_array["total_correct"];
321
- $total_incorrect = $total_question - $total_correct;
322
- $content = str_replace( "%AMOUNT_INCORRECT%" , max($total_incorrect, 0), $content);
323
- }
324
  return $content;
325
  }
326
- function mlw_qmn_variable_total_questions($content, $mlw_quiz_array)
327
- {
328
- $content = str_replace( "%TOTAL_QUESTIONS%" , $mlw_quiz_array["total_questions"], $content);
329
  return $content;
330
  }
331
- function mlw_qmn_variable_correct_score($content, $mlw_quiz_array)
332
- {
333
- $content = str_replace( "%CORRECT_SCORE%" , round( $mlw_quiz_array["total_score"] ), $content);
334
  return $content;
335
  }
336
- function mlw_qmn_variable_quiz_name($content, $mlw_quiz_array)
337
- {
338
- $content = str_replace( "%QUIZ_NAME%" , $mlw_quiz_array["quiz_name"], $content);
339
  return $content;
340
  }
341
- function mlw_qmn_variable_user_name($content, $mlw_quiz_array)
342
- {
343
- $content = str_replace( "%USER_NAME%" , $mlw_quiz_array["user_name"], $content);
 
 
 
 
 
 
 
 
 
 
 
 
344
  return $content;
345
  }
346
- function mlw_qmn_variable_current_user($content, $mlw_quiz_array)
347
- {
 
 
 
 
 
348
  $current_user = wp_get_current_user();
349
- $content = str_replace( "%USER_NAME%" , $current_user->display_name, $content);
350
  return $content;
351
  }
352
- function mlw_qmn_variable_user_business($content, $mlw_quiz_array)
353
- {
354
- $content = str_replace( "%USER_BUSINESS%" , $mlw_quiz_array["user_business"], $content);
355
  return $content;
356
  }
357
- function mlw_qmn_variable_user_phone($content, $mlw_quiz_array)
358
- {
359
- $content = str_replace( "%USER_PHONE%" , $mlw_quiz_array["user_phone"], $content);
360
  return $content;
361
  }
362
- function mlw_qmn_variable_user_email($content, $mlw_quiz_array)
363
- {
364
- $content = str_replace( "%USER_EMAIL%" , $mlw_quiz_array["user_email"], $content);
365
  return $content;
366
  }
367
 
@@ -371,10 +391,10 @@ function mlw_qmn_variable_user_email($content, $mlw_quiz_array)
371
  * @since 5.0.0
372
  * @return string The HTML for the content
373
  */
374
- function qsm_contact_field_variable( $content, $results_array ) {
375
- preg_match_all( "~%CONTACT_(.*?)%~i", $content, $matches );
376
- for ( $i = 0; $i < count( $matches[0] ); $i++ ) {
377
- $content = str_replace( "%CONTACT_" . $matches[1][ $i ] . "%" , $results_array["contact"][ $matches[1][ $i ] - 1 ]["value"], $content);
378
  }
379
  return $content;
380
  }
@@ -385,90 +405,86 @@ function qsm_contact_field_variable( $content, $results_array ) {
385
  * @since 5.0.0
386
  * @return string The HTML for the content
387
  */
388
- function qsm_all_contact_fields_variable( $content, $results ) {
389
  $return = '';
390
- if( isset( $results["contact"] ) && ( is_array($results["contact"]) || is_object( $results["contact"] ) ) ){
391
- for ( $i = 0; $i < count( $results["contact"] ); $i++ ) {
392
- $return .= $results["contact"][ $i ]["label"] . ": " . $results["contact"][ $i ]["value"] . "<br>";
393
- }
394
- }
395
- $content = str_replace( "%CONTACT_ALL%" , $return, $content );
396
  return $content;
397
  }
398
 
399
-
400
  /**
401
  * Converts the %QUESTIONS_ANSWERS% into the template
402
  *
403
  * @param string $content The content to be checked for the template
404
  * @param array $mlw_quiz_array The array for the response data
405
  */
406
- function mlw_qmn_variable_question_answers( $content, $mlw_quiz_array ) {
407
- global $mlwQuizMasterNext;
408
- $logic_rules = $mlwQuizMasterNext->pluginHelper->get_quiz_setting( 'logic_rules' );
409
- $logic_rules = unserialize( $logic_rules );
410
- $hidden_questions = isset($mlw_quiz_array['hidden_questions']) ? $mlw_quiz_array['hidden_questions'] : array();
411
- if(empty($hidden_questions)) {
412
- $hidden_questions = isset($mlw_quiz_array['results']['hidden_questions']) ? $mlw_quiz_array['results']['hidden_questions'] : array();
413
- }
414
-
415
  // Checks if the variable is present in the content.
416
- while ( strpos( $content, '%QUESTIONS_ANSWERS%' ) !== false || strpos( $content, '%QUESTIONS_ANSWERS_EMAIL%' ) !== false ) {
417
  global $wpdb;
418
  $display = '';
419
- if( strpos( $content, '%QUESTIONS_ANSWERS_EMAIL%' ) !== false ){
420
- if( isset( $mlw_quiz_array['quiz_settings'] ) && !empty($mlw_quiz_array['quiz_settings']) ){
421
- $quiz_text_settings = isset( $mlw_quiz_array['quiz_settings']['quiz_text'] ) ? @unserialize( stripslashes( $mlw_quiz_array['quiz_settings']['quiz_text'] ) ) : array();
422
- $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%' );
423
- }else{
424
- $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%' );
425
- }
426
- }else{
427
- if( isset( $mlw_quiz_array['quiz_settings'] ) && !empty($mlw_quiz_array['quiz_settings']) ){
428
- $quiz_text_settings = isset( $mlw_quiz_array['quiz_settings']['quiz_text'] ) ? @unserialize( stripslashes( $mlw_quiz_array['quiz_settings']['quiz_text'] ) ) : array();
429
- $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%' );
430
- }else{
431
- $qmn_question_answer_template = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_template', '%QUESTION%<br/>%USER_ANSWERS_DEFAULT%' );
432
- }
433
- }
434
- $questions = QSM_Questions::load_questions_by_pages( $mlw_quiz_array['quiz_id'] );
435
  $qmn_questions = array();
436
- foreach ( $questions as $question ) {
437
- $qmn_questions[ $question['question_id'] ] = $question['question_answer_info'];
438
  }
439
-
440
  // Cycles through each answer in the responses.
441
- $total_question_cnt = count( $mlw_quiz_array['question_answers_array'] );
442
- $qsm_question_cnt = 1;
443
- foreach ( $mlw_quiz_array['question_answers_array'] as $answer ) {
444
- if(in_array($answer['id'],$hidden_questions)) {
445
- continue;
446
- }
447
- $display .= qsm_questions_answers_shortcode_to_text($mlw_quiz_array, $qmn_question_answer_template, $questions, $qmn_questions, $answer, $qsm_question_cnt, $total_question_cnt);
448
- $qsm_question_cnt++;
449
  }
450
  $display = "<div class='qsm_questions_answers_section'>{$display}</div>";
451
- $content = str_replace( "%QUESTIONS_ANSWERS%" , $display, $content);
452
- $content = str_replace( "%QUESTIONS_ANSWERS_EMAIL%" , $display, $content);
453
  }
454
-
455
  return $content;
456
  }
457
 
458
- function mlw_qmn_variable_comments($content, $mlw_quiz_array)
459
- {
460
- $content = str_replace( "%COMMENT_SECTION%" , $mlw_quiz_array["comments"], $content);
461
  return $content;
462
  }
463
- function mlw_qmn_variable_timer($content, $mlw_quiz_array)
464
- {
465
- $content = str_replace( "%TIMER%" , $mlw_quiz_array["timer"], $content);
466
  return $content;
467
  }
468
- function mlw_qmn_variable_timer_minutes($content, $mlw_quiz_array)
469
- {
470
- $mlw_minutes = round($mlw_quiz_array["timer"]/60,2);
471
- $content = str_replace( "%TIMER_MINUTES%" , $mlw_minutes, $content);
472
  return $content;
473
  }
474
 
@@ -479,9 +495,9 @@ function mlw_qmn_variable_timer_minutes($content, $mlw_quiz_array)
479
  * @param array $results The array of all the results from user taking the quiz
480
  * @return string Returns the contents for the results page
481
  */
482
- function mlw_qmn_variable_date( $content, $results ) {
483
- $date = date_i18n( get_option( 'date_format' ), time() );
484
- $content = str_replace( "%CURRENT_DATE%" , $date, $content);
485
  return $content;
486
  }
487
 
@@ -492,9 +508,12 @@ function mlw_qmn_variable_date( $content, $results ) {
492
  * @param array $results The array of all the results from user taking the quiz
493
  * @return string Returns the contents for the results page
494
  */
495
- function mlw_qmn_variable_date_taken( $content, $results ) {
496
- $date = date_i18n( get_option( 'date_format' ), strtotime( $results["time_taken"] ) );
497
- $content = str_replace( "%DATE_TAKEN%" , $date, $content);
 
 
 
498
  return $content;
499
  }
500
 
@@ -903,7 +922,7 @@ function qsm_questions_answers_shortcode_to_text($mlw_quiz_array, $qmn_question_
903
  }
904
  } else if (isset($answer['question_type']) && $answer['question_type'] == 11) {
905
  $file_extension = substr($answer[1], -4);
906
- if ($file_extension == '.jpg' || $file_extension == 'jepg' || $file_extension == '.png' || $file_extension == '.gif') {
907
  $question_with_answer_text .= "<span class='$user_answer_class'><img src='$answer[1]'/></span>";
908
  } else {
909
  $question_with_answer_text .= "<span class='$user_answer_class'>" . trim(htmlspecialchars_decode($answer[1], ENT_QUOTES)) . '</span>';
@@ -973,7 +992,7 @@ function qsm_questions_answers_shortcode_to_text($mlw_quiz_array, $qmn_question_
973
  } else {
974
  if (isset($answer['question_type']) && $answer['question_type'] == 11) {
975
  $file_extension = substr($answer[1], -4);
976
- if ($file_extension == '.jpg' || $file_extension == 'jepg' || $file_extension == '.png' || $file_extension == '.gif') {
977
  $question_with_answer_text .= "<span class='$user_answer_class'><img src='$answer[1]'/></span>";
978
  } else {
979
  $question_with_answer_text .= "<span class='$user_answer_class'>" . trim(htmlspecialchars_decode($answer[1], ENT_QUOTES)) . '</span>';
@@ -987,7 +1006,7 @@ function qsm_questions_answers_shortcode_to_text($mlw_quiz_array, $qmn_question_
987
  }
988
  if (isset($answer['question_type']) && $answer['question_type'] == 11) {
989
  $file_extension = substr($answer[1], -4);
990
- if ($file_extension == '.jpg' || $file_extension == 'jepg' || $file_extension == '.png' || $file_extension == '.gif') {
991
  $mlw_question_answer_display = str_replace("%USER_ANSWER%", "<span class='$user_answer_class'><img src='$answer[1]'/></span>", $mlw_question_answer_display);
992
  } else {
993
  $mlw_question_answer_display = str_replace("%USER_ANSWER%", "<span class='$user_answer_class'>" . trim(htmlspecialchars_decode($answer[1], ENT_QUOTES)) . '</span>', $mlw_question_answer_display);
@@ -1008,6 +1027,10 @@ function qsm_questions_answers_shortcode_to_text($mlw_quiz_array, $qmn_question_
1008
  //Point score of the particular question.
1009
  $question_point = isset( $answer['points'] ) ? $answer['points'] : '0';
1010
  $mlw_question_answer_display = str_replace("%QUESTION_POINT_SCORE%", htmlspecialchars_decode($question_point, ENT_QUOTES), $mlw_question_answer_display);
 
 
 
 
1011
  $mlw_question_answer_display = wp_kses_post($mlw_question_answer_display);
1012
  if ($total_question_cnt == $qsm_question_cnt && $remove_border == false ) {
1013
  $extra_border_bottom_class = 'qsm-remove-border-bottom';
@@ -1016,3 +1039,24 @@ function qsm_questions_answers_shortcode_to_text($mlw_quiz_array, $qmn_question_
1016
  $display = "<div class='qmn_question_answer $extra_border_bottom_class $question_answer_class'>" . apply_filters('qmn_variable_question_answers', $mlw_question_answer_display, $mlw_quiz_array) . '</div>';
1017
  return $display;
1018
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_total_questions',10,2);
47
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_correct_score',10,2);
48
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_quiz_name',10,2);
49
+ add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_quiz_links',10,2);
50
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_user_name',10,2);
51
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_user_business',10,2);
52
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_user_phone',10,2);
57
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_timer_minutes',10,2);
58
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_date',10,2);
59
  add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_date_taken',10,2);
60
+ add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_social_share',10,2);
 
61
  add_filter('mlw_qmn_template_variable_results_page', 'qsm_variable_result_id',10,2);
62
  add_filter('mlw_qmn_template_variable_results_page', 'qsm_variable_single_question_answer',20,2);
63
  add_filter('mlw_qmn_template_variable_results_page', 'qsm_variable_total_possible_points',10,2);
65
  add_filter('qmn_end_results', 'qsm_variable_poll_result',10,3);
66
 
67
  add_filter('mlw_qmn_template_variable_quiz_page', 'mlw_qmn_variable_quiz_name',10,2);
68
+ add_filter('mlw_qmn_template_variable_quiz_page', 'mlw_qmn_variable_quiz_links',10,2);
69
  add_filter('mlw_qmn_template_variable_quiz_page', 'mlw_qmn_variable_date',10,2);
70
  add_filter('mlw_qmn_template_variable_quiz_page', 'mlw_qmn_variable_current_user',10,2);
71
+ add_filter('mlw_qmn_template_variable_quiz_page', 'mlw_qmn_variable_social_share',10,2);
72
 
73
  /**
74
  * @since 6.4.11
225
  }
226
 
227
  /**
228
+ * Adds Social sharing links
229
  */
230
+ function mlw_qmn_variable_social_share($content, $mlw_quiz_array) {
231
+ global $wpdb, $mlwQuizMasterNext;
232
+ $page_link = qsm_get_post_id_from_quiz_id($mlw_quiz_array['quiz_id']);
233
+ if (false !== strpos($content, '%FACEBOOK_SHARE%')) {
234
+ $settings = (array) get_option('qmn-settings');
235
  $facebook_app_id = '483815031724529';
236
+ if (isset($settings['facebook_app_id'])) {
237
+ $facebook_app_id = esc_js($settings['facebook_app_id']);
238
  }
239
+ $fb_image = plugins_url('', dirname(__FILE__)) . '/assets/facebook.png';
240
+ $sharing = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_text', 'facebook_sharing_text', '%QUIZ_NAME%');
241
+ if (false !== strpos($sharing, '%RESULT_LINK%')) {
242
+ if (isset($mlw_quiz_array['result_id'])) {
243
+ $unique_id = $wpdb->get_var("SELECT `unique_id` FROM `{$wpdb->prefix}mlw_results` WHERE `quiz_id`='{$mlw_quiz_array['quiz_id']}' AND `result_id`='{$mlw_quiz_array['result_id']}'");
244
+ $page_link = add_query_arg('result_id', $unique_id, $page_link);
245
+ }
246
+ $sharing = str_replace("%RESULT_LINK%", $page_link, $sharing);
247
+ }
248
+ $sharing = apply_filters('mlw_qmn_template_variable_results_page', $sharing, $mlw_quiz_array);
249
+ $social_display = "<a class='qsm_social_share_link' data-network='facebook' data-text='" . urlencode($sharing) . "' data-link='{$page_link}' data-id='{$facebook_app_id}'><img src='{$fb_image}' alt='" . __('Facebbok Share', 'quiz-master-next') . "' /></a>";
250
+ $content = str_replace("%FACEBOOK_SHARE%", $social_display, $content);
251
  }
252
+ if (false !== strpos($content, '%TWITTER_SHARE%')) {
253
+ $tw_image = plugins_url('', dirname(__FILE__) ) . '/assets/twitter.png';
254
+ $sharing = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_text', 'twitter_sharing_text', '%QUIZ_NAME%');
255
+ if (false !== strpos($sharing, '%RESULT_LINK%')) {
256
+ if (isset($mlw_quiz_array['result_id'])) {
257
+ $unique_id = $wpdb->get_var("SELECT `unique_id` FROM `{$wpdb->prefix}mlw_results` WHERE `quiz_id`='{$mlw_quiz_array['quiz_id']}' AND `result_id`='{$mlw_quiz_array['result_id']}'");
258
+ $page_link = add_query_arg('result_id', $unique_id, $page_link);
259
+ }
260
+ $sharing = str_replace("%RESULT_LINK%", $page_link, $sharing);
261
+ }
262
+ $sharing = apply_filters('mlw_qmn_template_variable_results_page', $sharing, $mlw_quiz_array);
263
+ $social_display = "<a class='qsm_social_share_link' data-network='twitter' data-text='" . urlencode($sharing) . "' data-link='{$page_link}'><img src='{$tw_image}' alt='" . __('Twitter Share', 'quiz-master-next') . "' /></a>";
264
+ $content = str_replace("%TWITTER_SHARE%", $social_display, $content);
 
 
 
265
  }
266
  return $content;
267
  }
281
 
282
  function mlw_qmn_variable_point_score($content, $mlw_quiz_array)
283
  {
284
+ $content = str_replace( "%POINT_SCORE%" , (isset($mlw_quiz_array["total_points"]) ? $mlw_quiz_array["total_points"] : ''), $content);
285
  return $content;
286
  }
287
  function mlw_qmn_variable_average_point($content, $mlw_quiz_array){
293
  }
294
  }
295
  }
296
+ if (isset($mlw_quiz_array['total_questions']) && $mlw_quiz_array["total_questions"] != 0 && $question_total != 0){
297
  $mlw_average_points = round($mlw_quiz_array["total_points"]/$question_total, 2);
298
  }
299
  else
303
  $content = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $content);
304
  return $content;
305
  }
306
+
307
+ function mlw_qmn_variable_amount_correct($content, $mlw_quiz_array) {
308
+ $content = str_replace("%AMOUNT_CORRECT%", (isset($mlw_quiz_array["total_correct"]) ? $mlw_quiz_array["total_correct"] : ''), $content);
309
  return $content;
310
  }
311
 
317
  * @param array $mlw_quiz_array
318
  * @return string
319
  */
320
+ function mlw_qmn_variable_amount_incorrect($content, $mlw_quiz_array) {
321
+ if (false !== strpos($content, '%AMOUNT_INCORRECT%')) {
322
+ $total_question = $mlw_quiz_array["total_questions"];
323
+ $total_correct = $mlw_quiz_array["total_correct"];
324
+ $total_incorrect = $total_question - $total_correct;
325
+ $content = str_replace("%AMOUNT_INCORRECT%", max($total_incorrect, 0), $content);
326
+ }
327
  return $content;
328
  }
329
+
330
+ function mlw_qmn_variable_total_questions($content, $mlw_quiz_array) {
331
+ $content = str_replace("%TOTAL_QUESTIONS%", (isset($mlw_quiz_array["total_questions"]) ? $mlw_quiz_array["total_questions"] : ''), $content);
332
  return $content;
333
  }
334
+
335
+ function mlw_qmn_variable_correct_score($content, $mlw_quiz_array) {
336
+ $content = str_replace("%CORRECT_SCORE%", (isset($mlw_quiz_array["total_score"]) ? round($mlw_quiz_array["total_score"]) : ''), $content);
337
  return $content;
338
  }
339
+
340
+ function mlw_qmn_variable_quiz_name($content, $mlw_quiz_array) {
341
+ $content = str_replace("%QUIZ_NAME%", (isset($mlw_quiz_array["quiz_name"]) ? $mlw_quiz_array["quiz_name"] : ''), $content);
342
  return $content;
343
  }
344
+
345
+ function mlw_qmn_variable_quiz_links($content, $mlw_quiz_array) {
346
+ global $wpdb;
347
+ $quiz_link = qsm_get_post_id_from_quiz_id($mlw_quiz_array['quiz_id']);
348
+ if (false !== strpos($content, '%QUIZ_LINK%')) {
349
+ $content = str_replace("%QUIZ_LINK%", $quiz_link, $content);
350
+ }
351
+ if (false !== strpos($content, '%RESULT_LINK%')) {
352
+ $result_link = $quiz_link;
353
+ if (isset($mlw_quiz_array['result_id'])) {
354
+ $unique_id = $wpdb->get_var("SELECT `unique_id` FROM `{$wpdb->prefix}mlw_results` WHERE `quiz_id`='{$mlw_quiz_array['quiz_id']}' AND `result_id`='{$mlw_quiz_array['result_id']}'");
355
+ $result_link = add_query_arg('result_id', $unique_id, $quiz_link);
356
+ }
357
+ $content = str_replace("%RESULT_LINK%", $result_link, $content);
358
+ }
359
  return $content;
360
  }
361
+
362
+ function mlw_qmn_variable_user_name($content, $mlw_quiz_array) {
363
+ $content = str_replace("%USER_NAME%", (isset($mlw_quiz_array["user_name"]) ? $mlw_quiz_array["user_name"] : ''), $content);
364
+ return $content;
365
+ }
366
+
367
+ function mlw_qmn_variable_current_user($content, $mlw_quiz_array) {
368
  $current_user = wp_get_current_user();
369
+ $content = str_replace("%USER_NAME%", $current_user->display_name, $content);
370
  return $content;
371
  }
372
+
373
+ function mlw_qmn_variable_user_business($content, $mlw_quiz_array) {
374
+ $content = str_replace("%USER_BUSINESS%", (isset($mlw_quiz_array["user_business"]) ? $mlw_quiz_array["user_business"] : ''), $content);
375
  return $content;
376
  }
377
+
378
+ function mlw_qmn_variable_user_phone($content, $mlw_quiz_array) {
379
+ $content = str_replace("%USER_PHONE%", (isset($mlw_quiz_array["user_phone"]) ? $mlw_quiz_array["user_phone"] : ''), $content);
380
  return $content;
381
  }
382
+
383
+ function mlw_qmn_variable_user_email($content, $mlw_quiz_array) {
384
+ $content = str_replace("%USER_EMAIL%", (isset($mlw_quiz_array["user_email"]) ? $mlw_quiz_array["user_email"] : ''), $content);
385
  return $content;
386
  }
387
 
391
  * @since 5.0.0
392
  * @return string The HTML for the content
393
  */
394
+ function qsm_contact_field_variable($content, $results_array) {
395
+ preg_match_all("~%CONTACT_(.*?)%~i", $content, $matches);
396
+ for ($i = 0; $i < count($matches[0]); $i++) {
397
+ $content = str_replace("%CONTACT_" . $matches[1][$i] . "%", $results_array["contact"][$matches[1][$i] - 1]["value"], $content);
398
  }
399
  return $content;
400
  }
405
  * @since 5.0.0
406
  * @return string The HTML for the content
407
  */
408
+ function qsm_all_contact_fields_variable($content, $results) {
409
  $return = '';
410
+ if (isset($results["contact"]) && ( is_array($results["contact"]) || is_object($results["contact"]) )) {
411
+ for ($i = 0; $i < count($results["contact"]); $i++) {
412
+ $return .= $results["contact"][$i]["label"] . ": " . $results["contact"][$i]["value"] . "<br>";
413
+ }
414
+ }
415
+ $content = str_replace("%CONTACT_ALL%", $return, $content);
416
  return $content;
417
  }
418
 
 
419
  /**
420
  * Converts the %QUESTIONS_ANSWERS% into the template
421
  *
422
  * @param string $content The content to be checked for the template
423
  * @param array $mlw_quiz_array The array for the response data
424
  */
425
+ function mlw_qmn_variable_question_answers($content, $mlw_quiz_array) {
426
+ global $mlwQuizMasterNext;
427
+ $logic_rules = $mlwQuizMasterNext->pluginHelper->get_quiz_setting('logic_rules');
428
+ $logic_rules = unserialize($logic_rules);
429
+ $hidden_questions = isset($mlw_quiz_array['hidden_questions']) ? $mlw_quiz_array['hidden_questions'] : array();
430
+ if (empty($hidden_questions)) {
431
+ $hidden_questions = isset($mlw_quiz_array['results']['hidden_questions']) ? $mlw_quiz_array['results']['hidden_questions'] : array();
432
+ }
 
433
  // Checks if the variable is present in the content.
434
+ while (strpos($content, '%QUESTIONS_ANSWERS%') !== false || strpos($content, '%QUESTIONS_ANSWERS_EMAIL%') !== false) {
435
  global $wpdb;
436
  $display = '';
437
+ if (strpos($content, '%QUESTIONS_ANSWERS_EMAIL%') !== false) {
438
+ if (isset($mlw_quiz_array['quiz_settings']) && !empty($mlw_quiz_array['quiz_settings'])) {
439
+ $quiz_text_settings = isset($mlw_quiz_array['quiz_settings']['quiz_text']) ? @unserialize(stripslashes($mlw_quiz_array['quiz_settings']['quiz_text'])) : array();
440
+ $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%');
441
+ } else {
442
+ $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%');
443
+ }
444
+ } else {
445
+ if (isset($mlw_quiz_array['quiz_settings']) && !empty($mlw_quiz_array['quiz_settings'])) {
446
+ $quiz_text_settings = isset($mlw_quiz_array['quiz_settings']['quiz_text']) ? @unserialize(stripslashes($mlw_quiz_array['quiz_settings']['quiz_text'])) : array();
447
+ $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%');
448
+ } else {
449
+ $qmn_question_answer_template = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_text', 'question_answer_template', '%QUESTION%<br/>%USER_ANSWERS_DEFAULT%');
450
+ }
451
+ }
452
+ $questions = QSM_Questions::load_questions_by_pages($mlw_quiz_array['quiz_id']);
453
  $qmn_questions = array();
454
+ foreach ($questions as $question) {
455
+ $qmn_questions[$question['question_id']] = $question['question_answer_info'];
456
  }
457
+
458
  // Cycles through each answer in the responses.
459
+ $total_question_cnt = count($mlw_quiz_array['question_answers_array']);
460
+ $qsm_question_cnt = 1;
461
+ foreach ($mlw_quiz_array['question_answers_array'] as $answer) {
462
+ if (in_array($answer['id'], $hidden_questions)) {
463
+ continue;
464
+ }
465
+ $display .= qsm_questions_answers_shortcode_to_text($mlw_quiz_array, $qmn_question_answer_template, $questions, $qmn_questions, $answer, $qsm_question_cnt, $total_question_cnt);
466
+ $qsm_question_cnt++;
467
  }
468
  $display = "<div class='qsm_questions_answers_section'>{$display}</div>";
469
+ $content = str_replace("%QUESTIONS_ANSWERS%", $display, $content);
470
+ $content = str_replace("%QUESTIONS_ANSWERS_EMAIL%", $display, $content);
471
  }
 
472
  return $content;
473
  }
474
 
475
+ function mlw_qmn_variable_comments($content, $mlw_quiz_array) {
476
+ $content = str_replace("%COMMENT_SECTION%", (isset($mlw_quiz_array["comments"]) ? $mlw_quiz_array["comments"] : ''), $content);
 
477
  return $content;
478
  }
479
+
480
+ function mlw_qmn_variable_timer($content, $mlw_quiz_array) {
481
+ $content = str_replace("%TIMER%", (isset($mlw_quiz_array["timer"]) ? $mlw_quiz_array["timer"] : ''), $content);
482
  return $content;
483
  }
484
+
485
+ function mlw_qmn_variable_timer_minutes($content, $mlw_quiz_array) {
486
+ $mlw_minutes = (isset($mlw_quiz_array["timer"]) ? round($mlw_quiz_array["timer"] / 60, 2) : '');
487
+ $content = str_replace("%TIMER_MINUTES%", $mlw_minutes, $content);
488
  return $content;
489
  }
490
 
495
  * @param array $results The array of all the results from user taking the quiz
496
  * @return string Returns the contents for the results page
497
  */
498
+ function mlw_qmn_variable_date($content, $results) {
499
+ $date = date_i18n(get_option('date_format'), time());
500
+ $content = str_replace("%CURRENT_DATE%", $date, $content);
501
  return $content;
502
  }
503
 
508
  * @param array $results The array of all the results from user taking the quiz
509
  * @return string Returns the contents for the results page
510
  */
511
+ function mlw_qmn_variable_date_taken($content, $results) {
512
+ $date = '';
513
+ if (isset($mlw_quiz_array["time_taken"])) {
514
+ $date = date_i18n(get_option('date_format'), strtotime($results["time_taken"]));
515
+ }
516
+ $content = str_replace("%DATE_TAKEN%", $date, $content);
517
  return $content;
518
  }
519
 
922
  }
923
  } else if (isset($answer['question_type']) && $answer['question_type'] == 11) {
924
  $file_extension = substr($answer[1], -4);
925
+ if ($file_extension == '.jpg' || $file_extension == '.jpeg' || $file_extension == '.png' || $file_extension == '.gif') {
926
  $question_with_answer_text .= "<span class='$user_answer_class'><img src='$answer[1]'/></span>";
927
  } else {
928
  $question_with_answer_text .= "<span class='$user_answer_class'>" . trim(htmlspecialchars_decode($answer[1], ENT_QUOTES)) . '</span>';
992
  } else {
993
  if (isset($answer['question_type']) && $answer['question_type'] == 11) {
994
  $file_extension = substr($answer[1], -4);
995
+ if ($file_extension == '.jpg' || $file_extension == '.jpeg' || $file_extension == '.png' || $file_extension == '.gif') {
996
  $question_with_answer_text .= "<span class='$user_answer_class'><img src='$answer[1]'/></span>";
997
  } else {
998
  $question_with_answer_text .= "<span class='$user_answer_class'>" . trim(htmlspecialchars_decode($answer[1], ENT_QUOTES)) . '</span>';
1006
  }
1007
  if (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
  $mlw_question_answer_display = str_replace("%USER_ANSWER%", "<span class='$user_answer_class'><img src='$answer[1]'/></span>", $mlw_question_answer_display);
1011
  } else {
1012
  $mlw_question_answer_display = str_replace("%USER_ANSWER%", "<span class='$user_answer_class'>" . trim(htmlspecialchars_decode($answer[1], ENT_QUOTES)) . '</span>', $mlw_question_answer_display);
1027
  //Point score of the particular question.
1028
  $question_point = isset( $answer['points'] ) ? $answer['points'] : '0';
1029
  $mlw_question_answer_display = str_replace("%QUESTION_POINT_SCORE%", htmlspecialchars_decode($question_point, ENT_QUOTES), $mlw_question_answer_display);
1030
+
1031
+ $question_max_point = (isset($questions[$answer['id']]) ? qsm_get_question_maximum_points($questions[$answer['id']]) : 0 );
1032
+ $mlw_question_answer_display = str_replace("%QUESTION_MAX_POINTS%", $question_max_point, $mlw_question_answer_display);
1033
+
1034
  $mlw_question_answer_display = wp_kses_post($mlw_question_answer_display);
1035
  if ($total_question_cnt == $qsm_question_cnt && $remove_border == false ) {
1036
  $extra_border_bottom_class = 'qsm-remove-border-bottom';
1039
  $display = "<div class='qmn_question_answer $extra_border_bottom_class $question_answer_class'>" . apply_filters('qmn_variable_question_answers', $mlw_question_answer_display, $mlw_quiz_array) . '</div>';
1040
  return $display;
1041
  }
1042
+ function qsm_get_question_maximum_points($question = array()) {
1043
+ $question_max_point = 0;
1044
+ if (!empty($question) && isset($question['answers'])) {
1045
+ $answer_points = array(0);
1046
+ foreach ($question['answers'] as $ans) {
1047
+ if (isset($ans[1])) {
1048
+ $answer_points[] = intval($ans[1]);
1049
+ }
1050
+ }
1051
+ $question_max_point = max($answer_points);
1052
+ if ($question['question_type_new'] == 4 || $question['question_type_new'] == 10) {
1053
+ $limit_multiple_response = (isset($question['settings']['limit_multiple_response'])) ? intval($question['settings']['limit_multiple_response']) : 0;
1054
+ if ($limit_multiple_response > 0 && count($answer_points) > $limit_multiple_response) {
1055
+ rsort($answer_points);
1056
+ $answer_points = array_slice($answer_points, 0, $limit_multiple_response, true);
1057
+ }
1058
+ $question_max_point = array_sum($answer_points);
1059
+ }
1060
+ }
1061
+ return $question_max_point;
1062
+ }
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.5.3
6
  Requires PHP: 5.4
7
- Stable tag: 7.1.8
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -135,6 +135,14 @@ This is usually a theme conflict. You can [checkout out our common conflict solu
135
 
136
  == Changelog ==
137
 
 
 
 
 
 
 
 
 
138
  = 7.1.8 (November 18, 2020) =
139
  * Bug: Fixed required field not working while using Date question type.
140
  * Bug: Fixed the issue of right answers containing apostrophes marked as incorrect in Multiple Response/ Multiple Choice questions
4
  Requires at least: 4.9
5
  Tested up to: 5.5.3
6
  Requires PHP: 5.4
7
+ Stable tag: 7.1.9
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
135
 
136
  == Changelog ==
137
 
138
+ = 7.1.9 (December 14, 2020) =
139
+ * Bug: Fixed the issue where answers with apostrophe's are not being recognized as correct.
140
+ * Bug: Fixed the issue where inline are shown twice when Random Questions are enabled.
141
+ * Bug: Fixed the issue with point score and maximum point variable
142
+ * Bug: Fixed the issue where only last answer display as correct when all the answers were marked correct.
143
+ * Enhancement: Added Limit Text option for paragraph question type.
144
+ * Enhancement: Added an option for inserting a link in the Correct info.
145
+
146
  = 7.1.8 (November 18, 2020) =
147
  * Bug: Fixed required field not working while using Date question type.
148
  * Bug: Fixed the issue of right answers containing apostrophes marked as incorrect in Multiple Response/ Multiple Choice questions