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

Version Description

(February 22, 2020) = * Bug: Fixed prevention of SQL injection while using result shortcode and question bank. * Bug: Fixed the issue of broken [latex] shortcode in result and user dashboard page. * Enhancement: Added option to end the quiz if answer is wrong. * Enhancement: Added option to turn off the HTML auto complete. * Enhancement: Modified background color to fix contrast ratios from SEO perspective.

Download this release

Release Info

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

Code changes from version 7.1.11 to 7.1.12

css/qsm-admin.css CHANGED
@@ -859,7 +859,7 @@ Misc.
859
  }
860
 
861
  #mlw_qmn_theme_block_primary{
862
- background-color: #3498db;
863
  color: #fff;
864
  }
865
 
@@ -869,17 +869,17 @@ Misc.
869
  }
870
 
871
  #mlw_qmn_theme_block_emerald{
872
- background-color: #2ecc71;
873
  color: #fff;
874
  }
875
 
876
  #mlw_qmn_theme_block_turquoise{
877
- background-color: #1abc9c;
878
  color: #fff;
879
  }
880
 
881
  #mlw_qmn_theme_block_gray{
882
- background-color: #ccc;
883
  color: #fff;
884
  }
885
 
859
  }
860
 
861
  #mlw_qmn_theme_block_primary{
862
+ background-color: #005e8e;
863
  color: #fff;
864
  }
865
 
869
  }
870
 
871
  #mlw_qmn_theme_block_emerald{
872
+ background-color: #006732;
873
  color: #fff;
874
  }
875
 
876
  #mlw_qmn_theme_block_turquoise{
877
+ background-color: #006552;
878
  color: #fff;
879
  }
880
 
881
  #mlw_qmn_theme_block_gray{
882
+ background-color: #595959;
883
  color: #fff;
884
  }
885
 
js/qsm-quiz.js CHANGED
@@ -1218,6 +1218,61 @@ jQuery(function() {
1218
  }
1219
  });
1220
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1221
  //Ajax upload file code
1222
  jQuery('.quiz_section .mlw_answer_file_upload').on('change', function(){
1223
  var $this = jQuery(this);
1218
  }
1219
  });
1220
 
1221
+ // Autocomplete off
1222
+
1223
+ var quizID = jQuery('.qsm-quiz-container').find('.qmn_quiz_id').val();
1224
+ var $quizForm = QSM.getQuizForm( quizID );
1225
+ if (qmn_quiz_data[ quizID ].form_disable_autofill == 1) {
1226
+ jQuery('#quizForm'+quizID).attr('autocomplete' , 'off');
1227
+ }
1228
+
1229
+
1230
+
1231
+ // End Quiz If Wrong
1232
+ jQuery(document).on('change ','.qmn_radio_answers input , .qmn_check_answers input , .qsm_select',function(e){
1233
+ var quizID = jQuery(this).parents('.qsm-quiz-container').find('.qmn_quiz_id').val();
1234
+ var $quizForm = QSM.getQuizForm( quizID );
1235
+ if (qmn_quiz_data[ quizID ].end_quiz_if_wrong == 1) {
1236
+ var question_id = jQuery(this).attr('name').split('question')[1],
1237
+ value = jQuery(this).val(),
1238
+ $this = jQuery(this).parents('.quiz_section');
1239
+ jQuery.ajax({
1240
+ type: 'POST',
1241
+ url: qmn_ajax_object.ajaxurl,
1242
+ data: {
1243
+ action: "qsm_get_question_quick_result",
1244
+ question_id: question_id,
1245
+ answer: value,
1246
+ show_correct_info: qmn_quiz_data[ quizID ].enable_quick_correct_answer_info
1247
+ },
1248
+ success: function (response) {
1249
+ var data = jQuery.parseJSON(response);
1250
+ $this.find('.quick-question-res-p').remove();
1251
+ $this.find('.qsm-inline-correct-info').remove();
1252
+ if (data.success == 'correct') {
1253
+
1254
+ } else if (data.success == 'incorrect') {
1255
+
1256
+
1257
+
1258
+ $this.append('<div style="color: red" class="quick-question-res-p">' + qmn_quiz_data[ quizID ].quick_result_wrong_answer_text + '</div>')
1259
+ $this.append('<div class="qsm-inline-correct-info">' + data.message + '</div>');
1260
+
1261
+ setTimeout(function() {
1262
+ $quizForm.closest( '.qmn_quiz_container' ).find('.qsm-submit-btn').trigger('click');
1263
+ }, 1000);
1264
+
1265
+
1266
+ }
1267
+ MathJax.Hub.queue.Push(["Typeset", MathJax.Hub]);
1268
+ },
1269
+ error: function (errorThrown) {
1270
+ alert(errorThrown);
1271
+ }
1272
+ });
1273
+ }
1274
+ });
1275
+
1276
  //Ajax upload file code
1277
  jQuery('.quiz_section .mlw_answer_file_upload').on('change', function(){
1278
  var $this = jQuery(this);
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.11
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.11
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.11';
41
 
42
  /**
43
  * QSM Alert Manager Object
@@ -188,7 +188,7 @@ class MLWQuizMasterNext {
188
  add_action( 'admin_menu', array( $this, 'setup_admin_menu' ) );
189
  add_action( 'admin_head', array( $this, 'admin_head' ), 900 );
190
  add_action( 'init', array( $this, 'register_quiz_post_types' ) );
191
- add_action('plugins_loaded', array(&$this, 'qsm_load_textdomain'));
192
  }
193
 
194
  /**
2
  /**
3
  * Plugin Name: Quiz And Survey Master
4
  * Description: Easily and quickly add quizzes and surveys to your website.
5
+ * Version: 7.1.12
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.12
13
  * @package QSM
14
  */
15
 
37
  * @var string
38
  * @since 4.0.0
39
  */
40
+ public $version = '7.1.12';
41
 
42
  /**
43
  * QSM Alert Manager Object
188
  add_action( 'admin_menu', array( $this, 'setup_admin_menu' ) );
189
  add_action( 'admin_head', array( $this, 'admin_head' ), 900 );
190
  add_action( 'init', array( $this, 'register_quiz_post_types' ) );
191
+ add_action('plugins_loaded', array(&$this, 'qsm_load_textdomain'));
192
  }
193
 
194
  /**
php/admin/options-page-questions-tab.php CHANGED
@@ -509,7 +509,7 @@ function qsm_options_questions_tab_content() {
509
  <a href="#" class="add-question-bank-button button"><span class="dashicons dashicons-plus"></span> <?php _e('Add Question From Question Bank', 'quiz-master-next'); ?></a>
510
  </div>
511
  </div>
512
- </div>
513
  </script>
514
 
515
  <!-- View for Question -->
@@ -519,7 +519,7 @@ function qsm_options_questions_tab_content() {
519
  <div><span class="dashicons dashicons-move"></span></div>
520
  <div><a href="#" title="Edit Question" class="edit-question-button"><span class="dashicons dashicons-edit"></span></a></div>
521
  <div><a href="#" title="Clone Question" class="duplicate-question-button"><span class="dashicons dashicons-admin-page"></span></a></div>
522
- <div><a href="#" title="Delete Question" class="delete-question-button" data-question-iid="{{data.id }}"><span class="dashicons dashicons-trash"></span></a></div>
523
  <div class="question-content-text">{{{data.question}}}</div>
524
  <div class="question-category"><# if ( 0 !== data.category.length ) { #> <?php _e('Category:', 'quiz-master-next'); ?> {{data.category}} <# } #></div>
525
  </div>
@@ -529,11 +529,10 @@ function qsm_options_questions_tab_content() {
529
  <!-- View for question in question bank -->
530
  <script type="text/template" id="tmpl-single-question-bank-question">
531
  <div class="question-bank-question" data-question-id="{{data.id}}" data-category-name="{{data.category}}">
532
- <div class="question-bank-selection">
533
- <input type="checkbox" name="qsm-question-checkbox[]" class="qsm-question-checkbox" />
534
- </div>
535
- <div><p>{{{data.question}}}</p><p style="font-size: 12px;color: gray;font-style: italic;"><b>Quiz Name:</b> {{data.quiz_name}} <# if ( data.category != '' ) { #> <b>Category:</b> {{data.category}} <# } #></p>
536
- </div>
537
  <div><a href="#" class="import-button button"><?php _e('Add Question', 'quiz-master-next'); ?></a></div>
538
  </div>
539
  </script>
@@ -550,20 +549,21 @@ function qsm_options_questions_tab_content() {
550
  <div class="answers-single">
551
  <div><a href="#" class="delete-answer-button"><span class="dashicons dashicons-trash"></span></a></div>
552
  <div class="answer-text-div">
553
- <# if ( 'rich' == data.answerType ) { #>
554
- <textarea id="answer-{{data.question_id}}-{{data.count}}"></textarea>
555
- <# } else { #>
556
- <input type="text" class="answer-text" value="{{data.answer}}" placeholder="Your answer"/>
557
- <# } #>
558
- </div>
559
- <# if ( 0 == data.form_type ) { #>
560
- <# if ( 1 == data.quiz_system || 3 == data.quiz_system ) { #>
561
- <div><input type="text" class="answer-points" value="{{data.points}}" placeholder="Points"/></div>
562
- <# } #>
563
- <# if ( 0 == data.quiz_system || 3 == data.quiz_system ) { #>
564
- <div><label class="correct-answer"><input type="checkbox" class="answer-correct" value="1" <# if ( 1 == data.correct ) { #> checked="checked" <# } #>/> <?php _e('Correct', 'quiz-master-next'); ?></label></div>
565
- <# } #>
566
- <# } #>
 
567
  </div>
568
  </script>
569
  <?php
509
  <a href="#" class="add-question-bank-button button"><span class="dashicons dashicons-plus"></span> <?php _e('Add Question From Question Bank', 'quiz-master-next'); ?></a>
510
  </div>
511
  </div>
512
+ </div>
513
  </script>
514
 
515
  <!-- View for Question -->
519
  <div><span class="dashicons dashicons-move"></span></div>
520
  <div><a href="#" title="Edit Question" class="edit-question-button"><span class="dashicons dashicons-edit"></span></a></div>
521
  <div><a href="#" title="Clone Question" class="duplicate-question-button"><span class="dashicons dashicons-admin-page"></span></a></div>
522
+ <div><a href="#" title="Delete Question" class="delete-question-button" data-question-iid="{{data.id }}"><span class="dashicons dashicons-trash"></span></a></div>
523
  <div class="question-content-text">{{{data.question}}}</div>
524
  <div class="question-category"><# if ( 0 !== data.category.length ) { #> <?php _e('Category:', 'quiz-master-next'); ?> {{data.category}} <# } #></div>
525
  </div>
529
  <!-- View for question in question bank -->
530
  <script type="text/template" id="tmpl-single-question-bank-question">
531
  <div class="question-bank-question" data-question-id="{{data.id}}" data-category-name="{{data.category}}">
532
+ <div class="question-bank-selection">
533
+ <input type="checkbox" name="qsm-question-checkbox[]" class="qsm-question-checkbox" />
534
+ </div>
535
+ <div><p>{{{data.question}}}</p><p style="font-size: 12px;color: gray;font-style: italic;"><b>Quiz Name:</b> {{data.quiz_name}} <# if ( data.category != '' ) { #> <b>Category:</b> {{data.category}} <# } #></p></div>
 
536
  <div><a href="#" class="import-button button"><?php _e('Add Question', 'quiz-master-next'); ?></a></div>
537
  </div>
538
  </script>
549
  <div class="answers-single">
550
  <div><a href="#" class="delete-answer-button"><span class="dashicons dashicons-trash"></span></a></div>
551
  <div class="answer-text-div">
552
+ <# if ( 'rich' == data.answerType ) { #>
553
+ <textarea id="answer-{{data.question_id}}-{{data.count}}"></textarea>
554
+ <# } else { #>
555
+ <input type="text" class="answer-text" value="{{data.answer}}" placeholder="Your answer"/>
556
+ <# } #>
557
+ </div>
558
+ <# if ( 0 == data.form_type ) { #>
559
+ <# if ( 1 == data.quiz_system || 3 == data.quiz_system ) { #>
560
+ <div><input type="text" class="answer-points" value="{{data.points}}" placeholder="Points"/></div>
561
+ <# } #>
562
+ <# if ( 0 == data.quiz_system || 3 == data.quiz_system ) { #>
563
+ <div><label class="correct-answer"><input type="checkbox" class="answer-correct" value="1" <# if ( 1 == data.correct ) { #> checked="checked" <# } #>/> <?php _e('Correct', 'quiz-master-next'); ?></label></div>
564
+ <# } #>
565
+ <# } #>
566
+ <?php do_action('qsm_admin_single_answer_option_fields');?>
567
  </div>
568
  </script>
569
  <?php
php/classes/class-qmn-quiz-creator.php CHANGED
@@ -75,18 +75,18 @@ class QMNQuizCreator {
75
  $wpdb->prefix . 'mlw_quizzes',
76
  array(
77
  'quiz_name' => $quiz_name,
78
- 'message_before' => 'Welcome to your %QUIZ_NAME%',
79
- 'message_after' => 'Thanks for submitting your response! You can edit this message on the "Results Pages" tab. <br>%CONTACT_ALL% <br>%QUESTIONS_ANSWERS%',
80
- 'message_comment' => 'Please fill in the comment box below.',
81
  'message_end_template' => '',
82
  'user_email_template' => '%QUESTIONS_ANSWERS_EMAIL%',
83
  'admin_email_template' => '%QUESTIONS_ANSWERS_EMAIL%',
84
- 'submit_button_text' => 'Submit',
85
- 'name_field_text' => 'Name',
86
- 'business_field_text' => 'Business',
87
- 'email_field_text' => 'Email',
88
- 'phone_field_text' => 'Phone Number',
89
- 'comment_field_text' => 'Comments',
90
  'email_from_text' => 'Wordpress',
91
  'question_answer_template' => '%QUESTION%<br />%USER_ANSWERS_DEFAULT%',
92
  'leaderboard_template' => '',
@@ -105,12 +105,12 @@ class QMNQuizCreator {
105
  'comment_section' => 1,
106
  'question_from_total' => 0,
107
  'total_user_tries' => 0,
108
- 'total_user_tries_text' => 'You have utilized all of your attempts to pass this quiz.',
109
  'certificate_template' => '',
110
  'social_media' => 0,
111
- 'social_media_text' => 'I just scored %CORRECT_SCORE%% on %QUIZ_NAME%!',
112
  'pagination' => 0,
113
- 'pagination_text' => 'Next',
114
  'timer_limit' => 0,
115
  'quiz_stye' => '',
116
  'question_numbering' => 0,
@@ -118,9 +118,9 @@ class QMNQuizCreator {
118
  'theme_selected' => 'primary',
119
  'last_activity' => current_time( 'mysql' ),
120
  'require_log_in' => 0,
121
- 'require_log_in_text' => 'This quiz is for logged in users only.',
122
  'limit_total_entries' => 0,
123
- 'limit_total_entries_text' => 'Unfortunately, this quiz has a limited amount of entries it can recieve and has already reached that limit.',
124
  'scheduled_timeframe' => '',
125
  'scheduled_timeframe_text' => '',
126
  'quiz_views' => 0,
75
  $wpdb->prefix . 'mlw_quizzes',
76
  array(
77
  'quiz_name' => $quiz_name,
78
+ 'message_before' => __('Welcome to your %QUIZ_NAME%', 'quiz-master-next'),
79
+ 'message_after' => __('Thanks for submitting your response! You can edit this message on the "Results Pages" tab. <br>%CONTACT_ALL% <br>%QUESTIONS_ANSWERS%', 'quiz-master-next'),
80
+ 'message_comment' => __('Please fill in the comment box below.', 'quiz-master-next'),
81
  'message_end_template' => '',
82
  'user_email_template' => '%QUESTIONS_ANSWERS_EMAIL%',
83
  'admin_email_template' => '%QUESTIONS_ANSWERS_EMAIL%',
84
+ 'submit_button_text' => __('Submit', 'quiz-master-next'),
85
+ 'name_field_text' => __('Name', 'quiz-master-next'),
86
+ 'business_field_text' => __('Business', 'quiz-master-next'),
87
+ 'email_field_text' => __('Email', 'quiz-master-next'),
88
+ 'phone_field_text' => __('Phone Number', 'quiz-master-next'),
89
+ 'comment_field_text' => __('Comments', 'quiz-master-next'),
90
  'email_from_text' => 'Wordpress',
91
  'question_answer_template' => '%QUESTION%<br />%USER_ANSWERS_DEFAULT%',
92
  'leaderboard_template' => '',
105
  'comment_section' => 1,
106
  'question_from_total' => 0,
107
  'total_user_tries' => 0,
108
+ 'total_user_tries_text' => __('You have utilized all of your attempts to pass this quiz.', 'quiz-master-next'),
109
  'certificate_template' => '',
110
  'social_media' => 0,
111
+ 'social_media_text' => __('I just scored %CORRECT_SCORE%% on %QUIZ_NAME%!', 'quiz-master-next'),
112
  'pagination' => 0,
113
+ 'pagination_text' => __('Next', 'quiz-master-next'),
114
  'timer_limit' => 0,
115
  'quiz_stye' => '',
116
  'question_numbering' => 0,
118
  'theme_selected' => 'primary',
119
  'last_activity' => current_time( 'mysql' ),
120
  'require_log_in' => 0,
121
+ 'require_log_in_text' => __('This quiz is for logged in users only.', 'quiz-master-next'),
122
  'limit_total_entries' => 0,
123
+ 'limit_total_entries_text' => __('Unfortunately, this quiz has a limited amount of entries it can recieve and has already reached that limit.', 'quiz-master-next'),
124
  'scheduled_timeframe' => '',
125
  'scheduled_timeframe_text' => '',
126
  'quiz_views' => 0,
php/classes/class-qmn-quiz-manager.php CHANGED
@@ -328,6 +328,8 @@ class QMNQuizManager {
328
  'disable_scroll_next_previous_click' => $qmn_quiz_options->disable_scroll_next_previous_click,
329
  'enable_result_after_timer_end' => isset($qmn_quiz_options->enable_result_after_timer_end) ? $qmn_quiz_options->enable_result_after_timer_end : '',
330
  'enable_quick_result_mc' => isset($qmn_quiz_options->enable_quick_result_mc) ? $qmn_quiz_options->enable_quick_result_mc : '',
 
 
331
  'enable_quick_correct_answer_info' => isset($qmn_quiz_options->enable_quick_correct_answer_info) ? $qmn_quiz_options->enable_quick_correct_answer_info : 0,
332
  'quick_result_correct_answer_text' => $qmn_quiz_options->quick_result_correct_answer_text,
333
  'quick_result_wrong_answer_text' => $qmn_quiz_options->quick_result_wrong_answer_text,
@@ -360,34 +362,42 @@ class QMNQuizManager {
360
  ), $atts));
361
  ob_start();
362
  if($id == 0){
363
- $id = isset($_GET['result_id']) ? $_GET['result_id'] : 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
364
  }
365
- global $wpdb;
366
- $result_data = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}mlw_results WHERE result_id = {$id}", ARRAY_A);
367
- $quiz_result = unserialize($result_data['quiz_results']);
368
- $response_data = array(
369
- 'quiz_id' => $result_data['quiz_id'],
370
- 'quiz_name' => $result_data['quiz_name'],
371
- 'quiz_system' => $result_data['quiz_system'],
372
- 'quiz_payment_id' => '',
373
- 'user_ip' => $result_data['user_ip'],
374
- 'user_name' => $result_data['name'],
375
- 'user_business' => $result_data['business'],
376
- 'user_email' => $result_data['email'],
377
- 'user_phone' => $result_data['phone'],
378
- 'user_id' => $result_data['user'],
379
- 'timer' => 0,
380
- 'time_taken' => $result_data['time_taken'],
381
- 'contact' => $quiz_result['contact'],
382
- 'total_points' => $result_data['point_score'],
383
- 'total_score' => $result_data['correct_score'],
384
- 'total_correct' => $result_data['correct'],
385
- 'total_questions' => $result_data['total'],
386
- 'question_answers_array' => $quiz_result[1],
387
- 'comments' => ''
388
- );
389
- $data = QSM_Results_Pages::generate_pages($response_data);
390
- echo htmlspecialchars_decode($data['display']);
391
  $content = ob_get_clean();
392
  return $content;
393
  }
328
  'disable_scroll_next_previous_click' => $qmn_quiz_options->disable_scroll_next_previous_click,
329
  'enable_result_after_timer_end' => isset($qmn_quiz_options->enable_result_after_timer_end) ? $qmn_quiz_options->enable_result_after_timer_end : '',
330
  'enable_quick_result_mc' => isset($qmn_quiz_options->enable_quick_result_mc) ? $qmn_quiz_options->enable_quick_result_mc : '',
331
+ 'end_quiz_if_wrong' => isset($qmn_quiz_options->end_quiz_if_wrong) ? $qmn_quiz_options->end_quiz_if_wrong : '',
332
+ 'form_disable_autofill' => isset($qmn_quiz_options->form_disable_autofill) ? $qmn_quiz_options->form_disable_autofill : '',
333
  'enable_quick_correct_answer_info' => isset($qmn_quiz_options->enable_quick_correct_answer_info) ? $qmn_quiz_options->enable_quick_correct_answer_info : 0,
334
  'quick_result_correct_answer_text' => $qmn_quiz_options->quick_result_correct_answer_text,
335
  'quick_result_wrong_answer_text' => $qmn_quiz_options->quick_result_wrong_answer_text,
362
  ), $atts));
363
  ob_start();
364
  if($id == 0){
365
+ $id = (int) isset($_GET['result_id']) ? sanitize_text_field( $_GET['result_id'] ) : 0;
366
+ }
367
+ if( $id && is_numeric($id) ){
368
+ global $wpdb;
369
+ $result_data = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}mlw_results WHERE result_id = {$id}", ARRAY_A);
370
+ if( $result_data ){
371
+ $quiz_result = unserialize($result_data['quiz_results']);
372
+ $response_data = array(
373
+ 'quiz_id' => $result_data['quiz_id'],
374
+ 'quiz_name' => $result_data['quiz_name'],
375
+ 'quiz_system' => $result_data['quiz_system'],
376
+ 'quiz_payment_id' => '',
377
+ 'user_ip' => $result_data['user_ip'],
378
+ 'user_name' => $result_data['name'],
379
+ 'user_business' => $result_data['business'],
380
+ 'user_email' => $result_data['email'],
381
+ 'user_phone' => $result_data['phone'],
382
+ 'user_id' => $result_data['user'],
383
+ 'timer' => 0,
384
+ 'time_taken' => $result_data['time_taken'],
385
+ 'contact' => $quiz_result['contact'],
386
+ 'total_points' => $result_data['point_score'],
387
+ 'total_score' => $result_data['correct_score'],
388
+ 'total_correct' => $result_data['correct'],
389
+ 'total_questions' => $result_data['total'],
390
+ 'question_answers_array' => $quiz_result[1],
391
+ 'comments' => ''
392
+ );
393
+ $data = QSM_Results_Pages::generate_pages($response_data);
394
+ echo htmlspecialchars_decode($data['display']);
395
+ } else {
396
+ echo _e('Invalid result id!', 'quiz-master-next');
397
+ }
398
+ }else{
399
+ echo _e('Invalid result id!', 'quiz-master-next');
400
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
401
  $content = ob_get_clean();
402
  return $content;
403
  }
php/classes/class-qsm-install.php CHANGED
@@ -477,6 +477,24 @@ class QSM_Install {
477
  ),
478
  'default' => 0
479
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
480
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
481
 
482
  // Registers show category on front setting
@@ -517,6 +535,25 @@ class QSM_Install {
517
  'help' => __('Instantly displays the result for each question','quiz-master-next')
518
  );
519
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
520
 
521
  // Settings for quick result
522
  $field_array = array(
@@ -1055,7 +1092,7 @@ class QSM_Install {
1055
  'id' => 'empty_error_text',
1056
  'label' => __('All required fields', 'quiz-master-next'),
1057
  'type' => 'text',
1058
- 'default' => 'Please complete all required fields!'
1059
  );
1060
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1061
 
@@ -1064,7 +1101,7 @@ class QSM_Install {
1064
  'id' => 'email_error_text',
1065
  'label' => __('Invalid email', 'quiz-master-next'),
1066
  'type' => 'text',
1067
- 'default' => 'Not a valid e-mail address!'
1068
  );
1069
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1070
 
@@ -1073,7 +1110,7 @@ class QSM_Install {
1073
  'id' => 'number_error_text',
1074
  'label' => __('Invalid number', 'quiz-master-next'),
1075
  'type' => 'text',
1076
- 'default' => 'This field must be a number!'
1077
  );
1078
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1079
 
@@ -1082,7 +1119,7 @@ class QSM_Install {
1082
  'id' => 'incorrect_error_text',
1083
  'label' => __('Invalid Captcha', 'quiz-master-next'),
1084
  'type' => 'text',
1085
- 'default' => 'The entered text is not correct!'
1086
  );
1087
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1088
 
@@ -1109,7 +1146,7 @@ class QSM_Install {
1109
  'id' => 'hint_text',
1110
  'label' => __('Hint Text', 'quiz-master-next'),
1111
  'type' => 'text',
1112
- 'default' => 'Hint'
1113
  );
1114
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1115
 
@@ -1118,7 +1155,7 @@ class QSM_Install {
1118
  'id' => 'quick_result_correct_answer_text',
1119
  'label' => __('Correct answer message', 'quiz-master-next'),
1120
  'type' => 'text',
1121
- 'default' => 'Correct! You have selected correct answer.',
1122
  'tooltip' => __('Text to show when the selected option is correct answer.', 'quiz-master-next')
1123
  );
1124
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
@@ -1128,7 +1165,7 @@ class QSM_Install {
1128
  'id' => 'quick_result_wrong_answer_text',
1129
  'label' => __('Incorrect answer message', 'quiz-master-next'),
1130
  'type' => 'text',
1131
- 'default' => 'Wrong! You have selected wrong answer.',
1132
  'tooltip' => __('Text to show when the selected option is wrong answer.', 'quiz-master-next')
1133
  );
1134
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
477
  ),
478
  'default' => 0
479
  );
480
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
481
+
482
+ $field_array = array(
483
+ 'id' => 'form_disable_autofill',
484
+ 'label' => __('Disable auto fill for Quiz input', 'quiz-master-next'),
485
+ 'type' => 'radio',
486
+ 'options' => array(
487
+ array(
488
+ 'label' => __('Yes', 'quiz-master-next'),
489
+ 'value' => 1
490
+ ),
491
+ array(
492
+ 'label' => __('No', 'quiz-master-next'),
493
+ 'value' => 0
494
+ ),
495
+ ),
496
+ 'default' => 0
497
+ );
498
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
499
 
500
  // Registers show category on front setting
535
  'help' => __('Instantly displays the result for each question','quiz-master-next')
536
  );
537
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
538
+
539
+ $field_array = array(
540
+ 'id' => 'end_quiz_if_wrong',
541
+ 'label' => __( 'End quiz if there is wrong answer', 'quiz-master-next' ),
542
+ 'type' => 'radio',
543
+ 'options' => array(
544
+ array(
545
+ 'label' => __( 'Yes', 'quiz-master-next' ),
546
+ 'value' => 1
547
+ ),
548
+ array(
549
+ 'label' => __( 'No', 'quiz-master-next' ),
550
+ 'value' => 0
551
+ )
552
+ ),
553
+ 'default' => 0,
554
+ 'help' => __('This option works with vertical Multiple Choice , horizontal Multiple Choice , drop down , multiple response and horizontal multiple response question types','quiz-master-next')
555
+ );
556
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
557
 
558
  // Settings for quick result
559
  $field_array = array(
1092
  'id' => 'empty_error_text',
1093
  'label' => __('All required fields', 'quiz-master-next'),
1094
  'type' => 'text',
1095
+ 'default' => __('Please complete all required fields!', 'quiz-master-next')
1096
  );
1097
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1098
 
1101
  'id' => 'email_error_text',
1102
  'label' => __('Invalid email', 'quiz-master-next'),
1103
  'type' => 'text',
1104
+ 'default' => __('Not a valid e-mail address!', 'quiz-master-next')
1105
  );
1106
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1107
 
1110
  'id' => 'number_error_text',
1111
  'label' => __('Invalid number', 'quiz-master-next'),
1112
  'type' => 'text',
1113
+ 'default' => __('This field must be a number!', 'quiz-master-next')
1114
  );
1115
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1116
 
1119
  'id' => 'incorrect_error_text',
1120
  'label' => __('Invalid Captcha', 'quiz-master-next'),
1121
  'type' => 'text',
1122
+ 'default' => __('The entered text is not correct!', 'quiz-master-next')
1123
  );
1124
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1125
 
1146
  'id' => 'hint_text',
1147
  'label' => __('Hint Text', 'quiz-master-next'),
1148
  'type' => 'text',
1149
+ 'default' => __('Hint', 'quiz-master-next')
1150
  );
1151
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1152
 
1155
  'id' => 'quick_result_correct_answer_text',
1156
  'label' => __('Correct answer message', 'quiz-master-next'),
1157
  'type' => 'text',
1158
+ 'default' => __('Correct! You have selected correct answer.', 'quiz-master-next'),
1159
  'tooltip' => __('Text to show when the selected option is correct answer.', 'quiz-master-next')
1160
  );
1161
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1165
  'id' => 'quick_result_wrong_answer_text',
1166
  'label' => __('Incorrect answer message', 'quiz-master-next'),
1167
  'type' => 'text',
1168
+ 'default' => __('Wrong! You have selected wrong answer.', 'quiz-master-next'),
1169
  'tooltip' => __('Text to show when the selected option is wrong answer.', 'quiz-master-next')
1170
  );
1171
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
php/question-types.php CHANGED
@@ -1,957 +1,939 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit;
3
- add_action("plugins_loaded", 'qmn_question_type_multiple_choice');
 
 
4
 
5
  /**
6
- * Registers the multiple choice type
7
- *
8
- * @return void
9
- * @since 4.4.0
10
- */
11
- function qmn_question_type_multiple_choice()
12
- {
13
  global $mlwQuizMasterNext;
14
- $mlwQuizMasterNext->pluginHelper->register_question_type(__("Vertical Multiple Choice", 'quiz-master-next'), 'qmn_multiple_choice_display', true, 'qmn_multiple_choice_review', null, null, 0);
15
  }
16
 
17
- add_action("plugins_loaded", 'qmn_question_type_file_upload');
18
  /**
19
- * Registers the file upload type
20
- *
21
- * @return void
22
- * @since 6.3.7
23
- */
24
- function qmn_question_type_file_upload(){
25
- global $mlwQuizMasterNext;
26
- $mlwQuizMasterNext->pluginHelper->register_question_type(__("File Upload", 'quiz-master-next'), 'qmn_file_upload_display', true, 'qmn_file_upload_review', null, null, 11);
27
  }
28
 
29
  /**
30
- * This function shows the content of the file upload
31
- *
32
- * @params $id The ID of the multiple choice question
33
- * @params $question The question that is being edited.
34
- * @params @answers The array that contains the answers to the question.
35
- * @return $question_display Contains all the content of the question
36
- * @since 6.3.7
37
- */
38
- function qmn_file_upload_display($id, $question, $answers)
39
- {
40
- $question_display = '';
41
- global $mlwQuizMasterNext;
42
- $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
43
- if ($required == 0) {$mlw_requireClass = "mlwRequiredFileUpload";} else {$mlw_requireClass = "";}
44
- //$question_title = apply_filters('the_content', $question);
45
- $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
46
- $question_display .= qsm_question_title_func($question,'',$new_question_title);
47
- $question_display .= "<div style=''></div><input type='file' class='mlw_answer_file_upload $mlw_requireClass'/>";
48
- $question_display .= "<div style='display: none;' class='loading-uploaded-file'><img src='".get_site_url()."/wp-includes/images/spinner-2x.gif'></div>";
49
- $question_display .= "<div style='display: none;' class='remove-uploaded-file'><span class='dashicons dashicons-trash'></span></div>";
50
- $question_display .= "<input class='mlw_file_upload_hidden_value' type='hidden' name='question".$id."' value='' />";
51
- $question_display .= "<span style='display: none;' class='mlw-file-upload-error-msg'></span>";
52
- $question_display .= "<input class='mlw_file_upload_hidden_path' type='hidden' value='' />";
53
- return apply_filters('qmn_file_upload_display_front',$question_display,$id, $question, $answers);
 
 
54
  }
55
 
56
  /**
57
- * This function determines how the file upload will work.
58
- *
59
- * @params $id The ID of the multiple choice question
60
- * @params $question The question that is being edited.
61
- * @params @answers The array that contains the answers to the question.
62
- * @return $return_array Returns the graded question to the results page
63
- * @since 5.3.7
64
- */
65
- function qmn_file_upload_review($id, $question, $answers){
66
- $return_array = array(
67
- 'points' => 0,
68
- 'correct' => 'incorrect',
69
- 'user_text' => '',
70
- 'correct_text' => '',
71
- 'question_type' => 'file_upload'
72
- );
73
- if ( isset( $_POST["question".$id] ) ) {
74
- $decode_user_answer = sanitize_text_field( $_POST["question".$id] );
75
- $mlw_user_answer = trim( $decode_user_answer );
76
- } else {
77
- $mlw_user_answer = " ";
78
- }
79
- $return_array['user_text'] = $mlw_user_answer;
80
- foreach($answers as $answer)
81
- {
82
- $decode_correct_text = strval(htmlspecialchars_decode($answer[0], ENT_QUOTES));
83
- $return_array['correct_text'] = trim( preg_replace( '/\s\s+/', ' ', str_replace( "\n", " ", $decode_correct_text ) ) );
84
- if (mb_strtoupper($return_array['user_text']) == mb_strtoupper($return_array['correct_text']))
85
- {
86
- $return_array['correct'] = "correct";
87
- $return_array['points'] = $answer[1];
88
- break;
89
- }
90
- }
91
- return $return_array;
92
  }
93
 
94
  /**
95
- * This function shows the content of the multiple choice question.
96
- *
97
- * @params $id The ID of the multiple choice question
98
- * @params $question The question that is being edited.
99
- * @params @answers The array that contains the answers to the question.
100
- * @return $question_display Contains all the content of the question
101
- * @since 4.4.0
102
- */
103
- function qmn_multiple_choice_display($id, $question, $answers)
104
- {
105
- $question_display = '';
106
- global $mlwQuizMasterNext;
107
- $answerEditor = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'answerEditor');
108
- $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
109
- $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
110
- if ($required == 0) {$mlw_requireClass = "mlwRequiredRadio";} else {$mlw_requireClass = "";}
111
- //$question_title = apply_filters('the_content', $question);
112
- $question_display .= qsm_question_title_func($question,'multiple_choice',$new_question_title);
113
- $question_display .= "<div class='qmn_radio_answers $mlw_requireClass'>";
114
- if (is_array($answers))
115
- {
116
- $mlw_answer_total = 0;
117
- foreach($answers as $answer)
118
- {
119
- $mlw_answer_total++;
120
- if ($answer[0] != "")
121
- {
122
- if($answerEditor === 'rich'){
123
- $question_display .= "<div class='qmn_mc_answer_wrap' id='question$id-$mlw_answer_total'>";
124
- }else{
125
- $question_display .= "<div class='qmn_mc_answer_wrap' id='question".$id."-".str_replace(" ","-",esc_attr($answer[0]))."'>";
126
- }
127
- $question_display .= "<input type='radio' class='qmn_quiz_radio' name='question".$id."' id='question".$id."_".$mlw_answer_total."' value='". $answer[0] ."' />";
128
- $question_display .= "<label for='question".$id."_".$mlw_answer_total."'>". trim(do_shortcode(htmlspecialchars_decode($answer[0], ENT_QUOTES)) ) ."</label>";
129
- $question_display .= "</div>";
130
- }
131
- }
132
- $question_display .= "<input type='radio' style='display: none;' name='question".$id."' id='question".$id."_none' checked='checked' value='' />";
133
- }
134
- $question_display .= "</div>";
135
- return apply_filters('qmn_multiple_choice_display_front',$question_display,$id, $question, $answers);
136
  }
137
 
138
  /**
139
- * This function determines how the multiple choice question is graded.
140
- *
141
- * @params $id The ID of the multiple choice question
142
- * @params $question The question that is being edited.
143
- * @params @answers The array that contains the answers to the question.
144
- * @return $return_array Returns the graded question to the results page
145
- * @since 4.4.0
146
- */
147
- function qmn_multiple_choice_review($id, $question, $answers) {
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
- $correct_text = array();
165
- foreach ($answers as $answer) {
166
- if ($answerEditor === 'rich') {
167
- $answer_option = stripslashes(htmlspecialchars_decode($answer[0], ENT_QUOTES));
168
- $sinel_answer_cmp = preg_replace("/\s+|\n+|\r/", ' ', htmlentities($answer_option));
169
- if ($rich_text_comapre == $sinel_answer_cmp) {
170
- $return_array["points"] = $answer[1];
171
- $return_array["user_text"] = $answer[0];
172
- if ($answer[2] == 1) {
173
- $return_array["correct"] = "correct";
174
  }
175
  }
176
- if ($answer[2] == 1) {
177
- $correct_text[] = stripslashes(htmlspecialchars_decode($answer[0], ENT_QUOTES));
178
  }
179
  } else {
180
  $mlw_user_answer = '';
181
- if (isset($_POST["question" . $id])) {
182
- $mlw_user_answer = $_POST["question" . $id];
183
- $mlw_user_answer = trim(htmlspecialchars_decode($mlw_user_answer, ENT_QUOTES));
184
- $mlw_user_answer = str_replace('\\', "", $mlw_user_answer);
185
  }
186
- $single_answer = trim(htmlspecialchars_decode($answer[0], ENT_QUOTES));
187
- $single_answer = str_replace('\\', "", $single_answer);
188
- if ($mlw_user_answer == $single_answer) {
189
- $return_array["points"] = $answer[1];
190
- $return_array["user_text"] = $answer[0];
191
- if ($answer[2] == 1) {
192
- $return_array["correct"] = "correct";
193
  }
194
  }
195
- if ($answer[2] == 1) {
196
- $correct_text[] = stripslashes(htmlspecialchars_decode($answer[0], ENT_QUOTES));
197
  }
198
  }
199
  }
200
- $return_array["correct_text"] = implode('.', $correct_text);
201
  return $return_array;
202
  }
203
 
204
- add_action("plugins_loaded", 'qmn_question_type_date');
205
  /**
206
- * Registers the date type
207
- *
208
- * @return void
209
- * @since 6.3.7
210
- */
211
- function qmn_question_type_date(){
212
- global $mlwQuizMasterNext;
213
- $mlwQuizMasterNext->pluginHelper->register_question_type(__("Date", 'quiz-master-next'), 'qmn_date_display', true, 'qmn_date_review', null, null, 12);
214
  }
215
 
216
  /**
217
- * This function shows the content of the date field
218
- *
219
- * @params $id The ID of the multiple choice question
220
- * @params $question The question that is being edited.
221
- * @params @answers The array that contains the answers to the question.
222
- * @return $question_display Contains all the content of the question
223
- * @since 6.3.7
224
- */
225
- function qmn_date_display($id, $question, $answers)
226
- {
227
- $question_display = '';
228
- global $mlwQuizMasterNext;
229
- $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
230
- if ($required == 0) {$mlw_requireClass = "mlwRequiredDate";} else {$mlw_requireClass = "";}
231
- //$question_title = apply_filters('the_content', $question);
232
- $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
233
- $question_display .= qsm_question_title_func($question,'',$new_question_title);
234
- $question_display .= "<input type='date' class='mlw_answer_date $mlw_requireClass' name='question".$id."' id='question".$id."' value=''/>";
235
- //$question_display .= "<script>jQuery(document).ready(function () { jQuery('#question".$id."').datepicker(); });</script>";
236
- return apply_filters('qmn_date_display_front',$question_display,$id, $question, $answers);
 
 
237
  }
238
 
239
  /**
240
- * This function reviews the date type.
241
- *
242
- * @params $id The ID of the multiple choice question
243
- * @params $question The question that is being edited.
244
- * @params @answers The array that contains the answers to the question.
245
- * @return $return_array Returns the graded question to the results page
246
- * @since 6.3.7
247
- */
248
- function qmn_date_review($id, $question, $answers) {
249
- $return_array = array(
250
- 'points' => 0,
251
- 'correct' => 'incorrect',
252
- 'user_text' => '',
253
- 'correct_text' => ''
254
- );
255
- if (isset($_POST["question" . $id])) {
256
- $decode_user_answer = sanitize_textarea_field(strval(stripslashes(htmlspecialchars_decode($_POST["question" . $id], ENT_QUOTES))));
257
- $mlw_user_answer = trim(preg_replace('/\s\s+/', ' ', str_replace("\n", " ", $decode_user_answer)));
258
- } else {
259
- $mlw_user_answer = " ";
260
- }
261
- $return_array['user_text'] = $mlw_user_answer;
262
- foreach ($answers as $answer) {
263
- $decode_correct_text = strval(htmlspecialchars_decode($answer[0], ENT_QUOTES));
264
- $return_array['correct_text'] = trim(preg_replace('/\s\s+/', ' ', str_replace("\n", " ", $decode_correct_text)));
265
- if (mb_strtoupper($return_array['user_text']) == mb_strtoupper($return_array['correct_text'])) {
266
- $return_array['correct'] = "correct";
267
- $return_array['points'] = $answer[1];
268
- break;
269
- }
270
- }
271
- return $return_array;
272
  }
273
 
274
- add_action("plugins_loaded", 'qmn_question_type_horizontal_multiple_choice');
275
 
276
  /**
277
- * This function registers the horizontal multiple choice type.
278
- *
279
- * @return void
280
- * @since 4.4.0
281
- */
282
- function qmn_question_type_horizontal_multiple_choice()
283
- {
284
  global $mlwQuizMasterNext;
285
- $mlwQuizMasterNext->pluginHelper->register_question_type(__("Horizontal Multiple Choice", 'quiz-master-next'), 'qmn_horizontal_multiple_choice_display', true, 'qmn_horizontal_multiple_choice_review', null, null, 1);
286
  }
287
 
288
  /**
289
- * This function shows the content of the horizontal multiple choice question.
290
- *
291
- * @params $id The ID of the multiple choice question
292
- * @params $question The question that is being edited.
293
- * @params @answers The array that contains the answers to the question.
294
- * @return $question_display Contains all the content of the question
295
- * @since 4.4.0
296
- */
297
- function qmn_horizontal_multiple_choice_display($id, $question, $answers)
298
- {
299
- $question_display = '';
300
- global $mlwQuizMasterNext;
301
- $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
302
- if ($required == 0) {$mlw_requireClass = "mlwRequiredRadio";} else {$mlw_requireClass = "";}
303
- //$question_title = apply_filters('the_content', $question);
304
- $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
305
- $question_display .= qsm_question_title_func($question,'horizontal_multiple_choice',$new_question_title);
306
- $question_display .= "<div class='qmn_radio_answers $mlw_requireClass'>";
307
- if (is_array($answers))
308
- {
309
- $mlw_answer_total = 0;
310
- foreach($answers as $answer)
311
- {
312
- $mlw_answer_total++;
313
- if ($answer[0] != "")
314
- {
315
- $question_display .= "<span class='mlw_horizontal_choice'><input type='radio' class='qmn_quiz_radio' name='question".$id."' id='question".$id."_".$mlw_answer_total."' value='". $answer[0] ."' /><label for='question".$id."_".$mlw_answer_total."'>".trim(do_shortcode(htmlspecialchars_decode($answer[0], ENT_QUOTES)) )."</label></span>";
316
- }
317
- }
318
- $question_display .= "<input type='radio' style='display: none;' name='question".$id."' id='question".$id."_none' checked='checked' value='' />";
319
- }
320
- $question_display .= "</div>";
321
-
322
- return apply_filters('qmn_horizontal_multiple_choice_display_front',$question_display,$id, $question, $answers);
323
  }
324
 
325
  /**
326
- * This function determines how the question is graded.
327
- *
328
- * @params $id The ID of the multiple choice question
329
- * @params $question The question that is being edited.
330
- * @params @answers The array that contains the answers to the question.
331
- * @return $return_array Returns the graded question to the results page
332
- * @since 4.4.0
333
- */
334
- function qmn_horizontal_multiple_choice_review($id, $question, $answers) {
335
  global $mlwQuizMasterNext;
336
- $answerEditor = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'answerEditor');
337
  $return_array = array(
338
- 'points' => 0,
339
- 'correct' => 'incorrect',
340
- 'user_text' => '',
341
- 'correct_text' => ''
342
  );
343
- if (isset($_POST["question" . $id])) {
344
- $mlw_user_answer = $_POST["question" . $id];
345
- $mlw_user_answer = trim(stripslashes(htmlspecialchars_decode($mlw_user_answer, ENT_QUOTES)));
346
  } else {
347
- $mlw_user_answer = " ";
348
  }
349
- $rich_text_comapre = preg_replace("/\s+|\n+|\r/", ' ', htmlentities($mlw_user_answer));
350
- $correct_text = array();
351
- foreach ($answers as $answer) {
352
- if ($answerEditor === 'rich') {
353
- $answer_option = stripslashes(htmlspecialchars_decode($answer[0], ENT_QUOTES));
354
- $sinel_answer_cmp = preg_replace("/\s+|\n+|\r/", ' ', htmlentities($answer_option));
355
- if ($rich_text_comapre == $sinel_answer_cmp) {
356
- $return_array["points"] = $answer[1];
357
- $return_array["user_text"] = $answer[0];
358
- if ($answer[2] == 1) {
359
- $return_array["correct"] = "correct";
360
  }
361
  }
362
- if ($answer[2] == 1) {
363
- $correct_text[] = stripslashes(htmlspecialchars_decode($answer[0], ENT_QUOTES));
364
  }
365
  } else {
366
  $mlw_user_answer = '';
367
- if (isset($_POST["question" . $id])) {
368
- $mlw_user_answer = $_POST["question" . $id];
369
- $mlw_user_answer = trim(htmlspecialchars_decode($mlw_user_answer, ENT_QUOTES));
370
- $mlw_user_answer = str_replace('\\', "", $mlw_user_answer);
371
  }
372
- $single_answer = trim(htmlspecialchars_decode($answer[0], ENT_QUOTES));
373
- $single_answer = str_replace('\\', "", $single_answer);
374
- if ($mlw_user_answer == $single_answer) {
375
- $return_array["points"] = $answer[1];
376
- $return_array["user_text"] = $answer[0];
377
- if ($answer[2] == 1) {
378
- $return_array["correct"] = "correct";
379
  }
380
  }
381
- if ($answer[2] == 1) {
382
- $correct_text[] = stripslashes(htmlspecialchars_decode($answer[0], ENT_QUOTES));
383
  }
384
  }
385
  }
386
- $return_array["correct_text"] = implode('.', $correct_text);
387
  return $return_array;
388
  }
389
 
390
- add_action("plugins_loaded", 'qmn_question_type_drop_down');
391
 
392
  /**
393
- * This function registers the drop down question type
394
- *
395
- * @return void
396
- * @since 4.4.0
397
- */
398
- function qmn_question_type_drop_down()
399
- {
400
  global $mlwQuizMasterNext;
401
- $mlwQuizMasterNext->pluginHelper->register_question_type(__("Drop Down", 'quiz-master-next'), 'qmn_drop_down_display', true, 'qmn_drop_down_review', null, null, 2);
402
  }
403
 
404
  /**
405
- * This function shows the content of the multiple choice question.
406
- *
407
- * @params $id The ID of the multiple choice question
408
- * @params $question The question that is being edited.
409
- * @params @answers The array that contains the answers to the question.
410
- * @return $question_display Contains all the content of the question
411
- * @since 4.4.0
412
- */
413
- function qmn_drop_down_display($id, $question, $answers)
414
- {
415
- $question_display = '';
416
- global $mlwQuizMasterNext;
417
- $required = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'required' );
418
- if ( 0 == $required ) {
419
- $require_class = "qsmRequiredSelect";
420
- } else {
421
- $require_class = "";
422
- }
423
- //$question_title = apply_filters('the_content', $question);
424
- $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
425
- $question_display .= qsm_question_title_func($question, '', $new_question_title);
426
- $question_display .= "<select class='qsm_select $require_class' name='question".$id."'>";
427
- $question_display .= "<option value=''>" . __('Please select your answer','quiz-master-next') . "</option>";
428
- if (is_array($answers))
429
- {
430
- $mlw_answer_total = 0;
431
- foreach($answers as $answer)
432
- {
433
- $mlw_answer_total++;
434
- if ($answer[0] != "")
435
- {
436
- $question_display .= "<option value='".esc_attr($answer[0])."'>".htmlspecialchars_decode($answer[0], ENT_QUOTES)."</option>";
437
- }
438
- }
439
- }
440
- $question_display .= "</select>";
441
- return apply_filters('qmn_drop_down_display_front',$question_display,$id, $question, $answers);
442
  }
443
 
444
  /**
445
- * This function determines how the question is graded
446
- *
447
- * @params $id The ID of the multiple choice question
448
- * @params $question The question that is being edited.
449
- * @params @answers The array that contains the answers to the question.
450
- * @return $return_array Returns the graded question to the results page
451
- * @since 4.4.0
452
- */
453
- function qmn_drop_down_review($id, $question, $answers)
454
- {
455
- global $mlwQuizMasterNext;
456
- $answerEditor = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'answerEditor');
457
- $return_array = array(
458
- 'points' => 0,
459
- 'correct' => 'incorrect',
460
- 'user_text' => '',
461
- 'correct_text' => ''
462
- );
463
- if (isset($_POST["question".$id])) {
464
- $mlw_user_answer = $_POST["question".$id];
465
- $mlw_user_answer = trim( stripslashes( htmlspecialchars_decode($mlw_user_answer, ENT_QUOTES) ) );
466
- } else {
467
- $mlw_user_answer = " ";
468
- }
469
- foreach($answers as $answer)
470
- {
471
- $answers_loop = trim( stripslashes( htmlspecialchars_decode($answer[0], ENT_QUOTES) ) );
472
- if ( $mlw_user_answer == $answers_loop )
473
- {
474
- $return_array["points"] = $answer[1];
475
- $return_array["user_text"] = strval(htmlspecialchars_decode($answer[0], ENT_QUOTES));
476
- if ($answer[2] == 1)
477
- {
478
- $return_array["correct"] = "correct";
479
- }
480
- }
481
- if ($answer[2] == 1)
482
- {
483
- $return_array["correct_text"] = htmlspecialchars_decode($answer[0], ENT_QUOTES);
484
- }
485
- }
486
- return $return_array;
487
  }
488
 
489
- add_action("plugins_loaded", 'qmn_question_type_small_open');
490
 
491
  /**
492
- * This function registers the small open question type
493
- *
494
- * @return void
495
- * @since 4.4.0
496
- */
497
- function qmn_question_type_small_open()
498
- {
499
  global $mlwQuizMasterNext;
500
- $mlwQuizMasterNext->pluginHelper->register_question_type(__("Short Answer", 'quiz-master-next'), 'qmn_small_open_display', true, 'qmn_small_open_review', null, null, 3);
501
  }
502
 
503
  /**
504
- * This function shows the content of the small open answer question.
505
- *
506
- * @params $id The ID of the multiple choice question
507
- * @params $question The question that is being edited.
508
- * @params @answers The array that contains the answers to the question.
509
- * @return $question_display Contains all the content of the question
510
- * @since 4.4.0
511
- */
512
- function qmn_small_open_display($id, $question, $answers)
513
- {
514
- $question_display = '';
515
- global $mlwQuizMasterNext;
516
- $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
517
- $autofill = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'autofill');
518
- $limit_text = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'limit_text');
519
- $autofill_att = $autofill ? "autocomplete='off' " : '';
520
- $limit_text_att = $limit_text ? "maxlength='". $limit_text ."' " : '';
521
- if ($required == 0) {$mlw_requireClass = "mlwRequiredText";} else {$mlw_requireClass = "";}
522
- //$question_title = apply_filters('the_content', $question);
523
- $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
524
- $question_display .= qsm_question_title_func($question, '', $new_question_title);
525
- $question_display .= "<input ". $autofill_att . $limit_text_att . " type='text' class='mlw_answer_open_text $mlw_requireClass' name='question".$id."' />";
526
- return apply_filters('qmn_small_open_display_front',$question_display,$id, $question, $answers);
 
 
527
  }
528
 
529
  /**
530
- * This function reviews the small open answer.
531
- *
532
- * @params $id The ID of the multiple choice question
533
- * @params $question The question that is being edited.
534
- * @params @answers The array that contains the answers to the question.
535
- * @return $return_array Returns the graded question to the results page
536
- * @since 4.4.0
537
- */
538
- function qmn_small_open_review($id, $question, $answers)
539
- {
540
- $return_array = array(
541
- 'points' => 0,
542
- 'correct' => 'incorrect',
543
- 'user_text' => '',
544
- 'correct_text' => ''
545
- );
546
- if ( isset( $_POST["question".$id] ) ) {
547
- $decode_user_answer = sanitize_textarea_field( strval( stripslashes( htmlspecialchars_decode( $_POST["question".$id], ENT_QUOTES ) ) ) );
548
- $mlw_user_answer = trim( preg_replace( '/\s\s+/', ' ', str_replace( "\n", " ", $decode_user_answer ) ) );
549
- } else {
550
- $mlw_user_answer = " ";
551
- }
552
- $return_array['user_text'] = $mlw_user_answer;
553
- foreach($answers as $answer)
554
- {
555
- $decode_correct_text = strval(htmlspecialchars_decode($answer[0], ENT_QUOTES));
556
- $return_array['correct_text'] = trim( preg_replace( '/\s\s+/', ' ', str_replace( "\n", " ", $decode_correct_text ) ) );
557
- if (mb_strtoupper($return_array['user_text']) == mb_strtoupper($return_array['correct_text']))
558
- {
559
- $return_array['correct'] = "correct";
560
- $return_array['points'] = $answer[1];
561
- break;
562
- }
563
- }
564
- return $return_array;
565
  }
566
 
567
- add_action("plugins_loaded", 'qmn_question_type_multiple_response');
568
 
569
  /**
570
- * This function registers the multiple response question type
571
- *
572
- * @return void
573
- * @since 4.4.0
574
- */
575
- function qmn_question_type_multiple_response()
576
- {
577
  global $mlwQuizMasterNext;
578
- $mlwQuizMasterNext->pluginHelper->register_question_type(__("Multiple Response", 'quiz-master-next'), 'qmn_multiple_response_display', true, 'qmn_multiple_response_review', null, null, 4);
579
  }
580
 
581
  /**
582
- * This function shows the content of the multiple response question
583
- *
584
- * @params $id The ID of the multiple choice question
585
- * @params $question The question that is being edited.
586
- * @params @answers The array that contains the answers to the question.
587
- * @return $question_display Contains all the content of the question
588
- * @since 4.4.0
589
- */
590
- function qmn_multiple_response_display($id, $question, $answers)
591
- {
592
- $question_display = $limit_mr_text = '';
593
- global $mlwQuizMasterNext;
594
- $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
595
- $limit_multiple_response = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'limit_multiple_response');
596
- if($limit_multiple_response > 0)
597
- $limit_mr_text = 'onchange="qsmCheckMR(this,'. $limit_multiple_response .')"';
598
- if ($required == 0) {$mlw_requireClass = "mlwRequiredCheck";} else {$mlw_requireClass = "";}
599
- //$question_title = apply_filters('the_content', $question);
600
- $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
601
- $question_display .= qsm_question_title_func($question, '', $new_question_title);
602
- $question_display .= "<div class='qmn_check_answers $mlw_requireClass'>";
603
- if (is_array($answers))
604
- {
605
- $mlw_answer_total = 0;
606
- foreach($answers as $answer)
607
- {
608
- $mlw_answer_total++;
609
- if ($answer[0] != "")
610
- {
611
  $question_display .= '<div class="qsm_check_answer">';
612
- $question_display .= "<input type='hidden' name='question".$id."' value='This value does not matter' />";
613
- $question_display .= "<input type='checkbox' " . $limit_mr_text ." name='question".$id."_".$mlw_answer_total."' id='question".$id."_".$mlw_answer_total."' value='".esc_attr($answer[0])."' /> <label for='question".$id."_".$mlw_answer_total."'>".trim(do_shortcode(htmlspecialchars_decode($answer[0], ENT_QUOTES)) )."</label>";
614
  $question_display .= '</div>';
615
- }
616
- }
617
- }
618
- $question_display .= "</div>";
619
- return apply_filters('qmn_multiple_response_display_front',$question_display,$id, $question, $answers);
620
  }
621
 
622
  /**
623
- * This function determines how the multiple response is graded,
624
- *
625
- * @params $id The ID of the multiple choice question
626
- * @params $question The question that is being edited.
627
- * @params @answers The array that contains the answers to the question.
628
- * @return $return_array Returns the graded question to the results page
629
- * @since 4.4.0
630
- */
631
- function qmn_multiple_response_review($id, $question, $answers) {
632
- $return_array = array(
633
- 'points' => 0,
634
- 'correct' => 'incorrect',
635
- 'user_text' => '',
636
- 'correct_text' => '',
637
- 'user_compare_text' => ''
638
  );
639
- $user_correct = 0;
640
  $total_correct = 0;
641
- $total_answers = count($answers);
642
- $correct_text = array();
643
- foreach ($answers as $answer) {
644
- for ($i = 1; $i <= $total_answers; $i++) {
645
- if (isset($_POST["question" . $id . "_" . $i]) && sanitize_textarea_field(htmlspecialchars(stripslashes($_POST["question" . $id . "_" . $i]), ENT_QUOTES)) == esc_attr($answer[0])) {
646
- $return_array["points"] += $answer[1];
647
- $return_array["user_text"] .= htmlspecialchars_decode($answer[0], ENT_QUOTES) . ".";
648
- $return_array["user_compare_text"] .= sanitize_textarea_field(strval(htmlspecialchars_decode($answer[0], ENT_QUOTES))) . "=====";
649
- if ($answer[2] == 1) {
650
  $user_correct += 1;
651
  } else {
652
  $user_correct = -1;
653
  }
654
  }
655
  }
656
- if ($answer[2] == 1) {
657
- $correct_text[] = stripslashes(htmlspecialchars_decode($answer[0], ENT_QUOTES));
658
  $total_correct++;
659
  }
660
  }
661
- if ($user_correct == $total_correct) {
662
- $return_array["correct"] = "correct";
663
  }
664
- $return_array["correct_text"] = implode('.', $correct_text);
665
  return $return_array;
666
  }
667
 
668
- add_action("plugins_loaded", 'qmn_question_type_large_open');
669
 
670
  /**
671
- * This function registers the large open question type.
672
- *
673
- * @since 4.4.0
674
- */
675
- function qmn_question_type_large_open()
676
- {
677
  global $mlwQuizMasterNext;
678
- $mlwQuizMasterNext->pluginHelper->register_question_type(__("Paragraph", 'quiz-master-next'), 'qmn_large_open_display', true, 'qmn_large_open_review', null, null, 5);
679
  }
680
 
681
  /**
682
- * This function displays the content of the large open question.
683
- *
684
- * @params $id The ID of the multiple choice question
685
- * @params $question The question that is being edited.
686
- * @params @answers The array that contains the answers to the question.
687
- * @return $question_display Contains all the content of the question
688
- * @since 4.4.0
689
- */
690
- function qmn_large_open_display($id, $question, $answers)
691
- {
692
- $question_display = '';
693
- global $mlwQuizMasterNext;
694
- $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
695
- $limit_text = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'limit_text');
696
- if ($required == 0) {$mlw_requireClass = "mlwRequiredText";} else {$mlw_requireClass = "";}
697
- $limit_text_att = $limit_text ? "maxlength='". $limit_text ."' " : '';
698
- //$question_title = apply_filters('the_content', $question);
699
- $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
700
- $question_display .= qsm_question_title_func($question, '', $new_question_title);
701
- $question_display .= "<textarea class='mlw_answer_open_text {$mlw_requireClass}' {$limit_text_att} cols='70' rows='5' name='question{$id}' /></textarea>";
702
- return apply_filters('qmn_large_open_display_front',$question_display,$id, $question, $answers);
 
 
703
  }
704
 
705
  /**
706
- * This function determines how the large open question is graded
707
- *
708
- * @params $id The ID of the multiple choice question
709
- * @params $question The question that is being edited.
710
- * @params @answers The array that contains the answers to the question.
711
- * @return $return_array Returns the graded question to the results page
712
- * @since 4.4.0
713
- */
714
- function qmn_large_open_review($id, $question, $answers)
715
- {
716
- $return_array = array(
717
- 'points' => 0,
718
- 'correct' => 'incorrect',
719
- 'user_text' => '',
720
- 'correct_text' => ''
721
- );
722
- if ( isset( $_POST["question".$id] ) ) {
723
- $decode_user_answer = sanitize_textarea_field( strval( stripslashes( htmlspecialchars_decode( $_POST["question".$id], ENT_QUOTES ) ) ) );
724
- $mlw_user_answer = trim( preg_replace( '/\s\s+/', ' ', str_replace( "\n", " ", $decode_user_answer ) ) );
725
- } else {
726
- $mlw_user_answer = " ";
727
- }
728
- $return_array['user_text'] = $mlw_user_answer;
729
- foreach($answers as $answer)
730
- {
731
- $decode_correct_text = strval(htmlspecialchars_decode($answer[0], ENT_QUOTES));
732
- $return_array['correct_text'] = trim( preg_replace( '/\s\s+/', ' ', str_replace( "\n", " ", $decode_correct_text ) ) );
733
- if (mb_strtoupper($return_array['user_text']) == mb_strtoupper($return_array['correct_text']))
734
- {
735
- $return_array['correct'] = "correct";
736
- $return_array['points'] = $answer[1];
737
- break;
738
- }
739
- }
740
- return $return_array;
741
  }
742
 
743
- add_action("plugins_loaded", 'qmn_question_type_text_block');
744
 
745
  /**
746
- * This function registers the text block question type
747
- *
748
- * @return void
749
- * @since 4.4.0
750
- */
751
- function qmn_question_type_text_block()
752
- {
753
  global $mlwQuizMasterNext;
754
  $edit_args = array(
755
- 'inputs' => array(
756
- 'question'
757
  ),
758
- 'information' => '',
759
  'extra_inputs' => array(),
760
- 'function' => ''
761
  );
762
- $mlwQuizMasterNext->pluginHelper->register_question_type(__("Text/HTML Section", 'quiz-master-next'), 'qmn_text_block_display', false, null, $edit_args, null, 6);
763
  }
764
 
765
 
766
  /**
767
- * This function displays the contents of the text block question type.
768
- *
769
- * @params $id The ID of the multiple choice question
770
- * @params $question The question that is being edited.
771
- * @params @answers The array that contains the answers to the question.
772
- * @return $question_display Contains all the content of the question
773
- * @since 4.4.0
774
- */
775
- function qmn_text_block_display($id, $question, $answers)
776
- {
777
- $question_display = '';
778
- $question_display .= do_shortcode(htmlspecialchars_decode($question, ENT_QUOTES));
779
- return $question_display;
780
  }
781
 
782
- add_action("plugins_loaded", 'qmn_question_type_number');
783
 
784
  /**
785
- * This function registers the number question type
786
- *
787
- * @params $id The ID of the multiple choice question
788
- * @params $question The question that is being edited.
789
- * @params @answers The array that contains the answers to the question.
790
- * @return void
791
- * @since 4.4.0
792
- */
793
- function qmn_question_type_number()
794
- {
795
  global $mlwQuizMasterNext;
796
- $mlwQuizMasterNext->pluginHelper->register_question_type(__("Number", 'quiz-master-next'), 'qmn_number_display', true, 'qmn_number_review', null, null, 7);
797
  }
798
 
799
 
800
  /**
801
- * This function shows the content of the multiple choice question.
802
- *
803
- * @params $id The ID of the multiple choice question
804
- * @params $question The question that is being edited.
805
- * @params @answers The array that contains the answers to the question.
806
- * @return $question_display Contains all the content of the question
807
- * @since 4.4.0
808
- */
809
- function qmn_number_display($id, $question, $answers)
810
- {
811
- $question_display = '';
812
- global $mlwQuizMasterNext;
813
- $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
814
- $limit_text = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'limit_text');
815
- $limit_text_att = $limit_text ? "maxlength='". $limit_text ."' oninput='javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);'" : '';
816
- if ($required == 0) {$mlw_requireClass = "mlwRequiredNumber";} else {$mlw_requireClass = "";}
817
- //$question_title = apply_filters('the_content', $question);
818
- $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
819
- $question_display .= qsm_question_title_func($question, '', $new_question_title);
820
- $question_display .= "<input type='number' $limit_text_att class='mlw_answer_number $mlw_requireClass' name='question".$id."' />";
821
- return apply_filters('qmn_number_display_front',$question_display,$id, $question, $answers);
 
 
822
  }
823
 
824
 
825
  /**
826
- * This function determines how the number question type is graded.
827
- *
828
- * @params $id The ID of the multiple choice question
829
- * @params $question The question that is being edited.
830
- * @params @answers The array that contains the answers to the question.
831
- * @return $return_array Returns the graded question to the results page
832
- * @since 4.4.0
833
- */
834
- function qmn_number_review($id, $question, $answers)
835
- {
836
- $return_array = array(
837
- 'points' => 0,
838
- 'correct' => 'incorrect',
839
- 'user_text' => '',
840
- 'correct_text' => ''
841
- );
842
- if ( isset( $_POST["question".$id] ) ) {
843
- $mlw_user_answer = sanitize_textarea_field( strval( stripslashes( htmlspecialchars_decode( $_POST["question".$id], ENT_QUOTES ) ) ) );
844
- } else {
845
- $mlw_user_answer = " ";
846
- }
847
- $return_array['user_text'] = $mlw_user_answer;
848
- foreach($answers as $answer)
849
- {
850
- $return_array['correct_text'] = strval(htmlspecialchars_decode($answer[0], ENT_QUOTES));
851
- if (strtoupper($return_array['user_text']) == strtoupper($return_array['correct_text']))
852
- {
853
- $return_array['correct'] = "correct";
854
- $return_array['points'] = $answer[1];
855
- break;
856
- }
857
- }
858
- return $return_array;
859
  }
860
 
861
- add_action("plugins_loaded", 'qmn_question_type_accept');
862
 
863
  /**
864
- * This function registers the accept question type.
865
- *
866
- * @return void Description
867
- * @since 4.4.0
868
- */
869
- function qmn_question_type_accept()
870
- {
871
  global $mlwQuizMasterNext;
872
  $edit_args = array(
873
- 'inputs' => array(
874
  'question',
875
- 'required'
876
  ),
877
- 'information' => '',
878
  'extra_inputs' => array(),
879
- 'function' => ''
880
  );
881
- $mlwQuizMasterNext->pluginHelper->register_question_type(__("Opt-in", 'quiz-master-next'), 'qmn_accept_display', false, null, $edit_args, null, 8);
882
  }
883
 
884
  /**
885
- * This function displays the accept question
886
- *
887
- * @params $id The ID of the multiple choice question
888
- * @params $question The question that is being edited.
889
- * @params @answers The array that contains the answers to the question.
890
- * @return $question_display Contains all the content of the question
891
- * @since 4.4.0
892
- */
893
- function qmn_accept_display($id, $question, $answers)
894
- {
895
- $question_display = '';
896
- global $mlwQuizMasterNext;
897
- $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
898
- if ($required == 0) {$mlw_requireClass = "mlwRequiredAccept";} else {$mlw_requireClass = "";}
 
 
899
  $question_display .= "<div class='qmn_accept_answers'>";
900
- $question_display .= "<input type='checkbox' id='mlwAcceptance' class='$mlw_requireClass ' />";
901
- $question_display .= "<label for='mlwAcceptance'><span class='qmn_accept_text'>".do_shortcode(htmlspecialchars_decode($question, ENT_QUOTES))."</span></label>";
902
- $question_display .= "</div>";
903
- return apply_filters('qmn_accept_display_front',$question_display,$id, $question, $answers);
904
  }
905
 
906
- add_action("plugins_loaded", 'qmn_question_type_captcha');
907
 
908
  /**
909
- * This function registers the captcha question
910
- *
911
- *
912
- * @since 4.4.0
913
- */
914
- function qmn_question_type_captcha()
915
- {
916
  global $mlwQuizMasterNext;
917
  $edit_args = array(
918
- 'inputs' => array(
919
  'question',
920
- 'required'
921
  ),
922
- 'information' => '',
923
  'extra_inputs' => array(),
924
- 'function' => ''
925
  );
926
- $mlwQuizMasterNext->pluginHelper->register_question_type(__("Captcha", 'quiz-master-next'), 'qmn_captcha_display', false, null, $edit_args, null, 9);
927
  }
928
 
929
 
930
  /**
931
- * This function displays the captcha question
932
- *
933
- * @params $id The ID of the multiple choice question
934
- * @params $question The question that is being edited.
935
- * @params @answers The array that contains the answers to the question.
936
- * @return $question_display Contains all the content of the question
937
- * @since 4.4.0
938
- */
939
- function qmn_captcha_display($id, $question, $answers)
940
- {
941
- $question_display = '';
942
- global $mlwQuizMasterNext;
943
- $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
944
- if ($required == 0) {$mlw_requireClass = "mlwRequiredCaptcha";} else {$mlw_requireClass = "";}
945
- $question_display .= "<div class='mlw_captchaWrap'>";
946
- $question_display .= "<canvas alt='' id='mlw_captcha' class='mlw_captcha' width='100' height='50'></canvas>";
947
- $question_display .= "</div>";
948
- $question_display .= "<span class='mlw_qmn_question'>";
949
- $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
950
- $question_title = qsm_question_title_func($question, '', $new_question_title);
951
- $question_display .= $question_title ."</span>";
952
- $question_display .= "<input type='text' class='mlw_answer_open_text $mlw_requireClass' id='mlw_captcha_text' name='mlw_user_captcha'/>";
953
- $question_display .= "<input type='hidden' name='mlw_code_captcha' id='mlw_code_captcha' value='none' />";
954
- $question_display .= "<script>
 
 
955
  var mlw_code = '';
956
  var mlw_chars = '0123456789ABCDEFGHIJKL!@#$%^&*()MNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
957
  var mlw_code_length = 5;
@@ -967,220 +949,214 @@ function qmn_captcha_display($id, $question, $answers)
967
  mlw_captchaCTX.textBaseline = 'middle';
968
  document.getElementById('mlw_code_captcha').value = mlw_code;
969
  </script>
970
- ";
971
- return apply_filters('qmn_captcha_display_front',$question_display,$id, $question, $answers);
972
  }
973
 
974
- add_action("plugins_loaded", 'qmn_question_type_horizontal_multiple_response');
975
 
976
  /**
977
- * This function registers the horizontal multiple response question
978
- *
979
- * @return void
980
- * @since 4.4.0
981
- */
982
- function qmn_question_type_horizontal_multiple_response()
983
- {
984
- global $mlwQuizMasterNext;
985
- $mlwQuizMasterNext->pluginHelper->register_question_type(__("Horizontal Multiple Response", 'quiz-master-next'), 'qmn_horizontal_multiple_response_display', true, 'qmn_horizontal_multiple_response_review', null, null, 10);
986
  }
987
 
988
 
989
  /**
990
- * This function displays the content of the multiple response question type
991
- *
992
- * @params $id The ID of the multiple choice question
993
- * @params $question The question that is being edited.
994
- * @params @answers The array that contains the answers to the question.
995
- * @return $question_display Contains all the content of the question
996
- * @since 4.4.0
997
- */
998
- function qmn_horizontal_multiple_response_display($id, $question, $answers)
999
- {
1000
- $question_display = '';
1001
- global $mlwQuizMasterNext;
1002
- $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
1003
- if ($required == 0) {$mlw_requireClass = "mlwRequiredCheck";} else {$mlw_requireClass = "";}
1004
- //$question_title = apply_filters('the_content', $question);
1005
- $limit_multiple_response = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'limit_multiple_response');
1006
- $limit_mr_text = '';
1007
- if($limit_multiple_response > 0)
1008
- $limit_mr_text = 'onchange="qsmCheckMR(this,'. $limit_multiple_response .')"';
1009
- $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
1010
- $question_display .= qsm_question_title_func($question, '', $new_question_title);
1011
- $question_display .= "<div class='qmn_check_answers $mlw_requireClass'>";
1012
- if (is_array($answers))
1013
- {
1014
- $mlw_answer_total = 0;
1015
- foreach($answers as $answer)
1016
- {
1017
- $mlw_answer_total++;
1018
- if ($answer[0] != "")
1019
- {
1020
- $question_display .= "<input type='hidden' name='question".$id."' value='This value does not matter' />";
1021
- $question_display .= "<span class='mlw_horizontal_multiple'><input type='checkbox' " . $limit_mr_text ." name='question".$id."_".$mlw_answer_total."' id='question".$id."_".$mlw_answer_total."' value='".esc_attr($answer[0])."' /> <label for='question".$id."_".$mlw_answer_total."'>".trim(do_shortcode(htmlspecialchars_decode($answer[0], ENT_QUOTES)) )."&nbsp;</label></span>";
1022
- }
1023
- }
1024
- }
1025
- $question_display .= "</div>";
1026
- return apply_filters('qmn_horizontal_multiple_response_display_front',$question_display,$id, $question, $answers);
1027
  }
1028
 
1029
 
1030
  /**
1031
- * This function determines how the multiple response is graded.
1032
- *
1033
- * @params $id The ID of the multiple choice question
1034
- * @params $question The question that is being edited.
1035
- * @params @answers The array that contains the answers to the question.
1036
- * @return $return_array Returns the graded question to the Results page
1037
- * @since 4.4.0
1038
- */
1039
- function qmn_horizontal_multiple_response_review($id, $question, $answers) {
1040
- $return_array = array(
1041
- 'points' => 0,
1042
- 'correct' => 'incorrect',
1043
- 'user_text' => '',
1044
- 'correct_text' => '',
1045
- 'user_compare_text' => ''
1046
  );
1047
- $user_correct = 0;
1048
  $total_correct = 0;
1049
- $total_answers = count($answers);
1050
- $correct_text = array();
1051
- foreach ($answers as $answer) {
1052
- for ($i = 1; $i <= $total_answers; $i++) {
1053
- if (isset($_POST["question" . $id . "_" . $i]) && sanitize_textarea_field(htmlspecialchars(stripslashes($_POST["question" . $id . "_" . $i]), ENT_QUOTES)) == esc_attr($answer[0])) {
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
  $user_correct += 1;
1059
  } else {
1060
  $user_correct = -1;
1061
  }
1062
  }
1063
  }
1064
- if ($answer[2] == 1) {
1065
- $correct_text[] = stripslashes(htmlspecialchars_decode($answer[0], ENT_QUOTES));
1066
  $total_correct++;
1067
  }
1068
  }
1069
- if ($user_correct == $total_correct) {
1070
- $return_array["correct"] = "correct";
1071
  }
1072
- $return_array["correct_text"] = implode('.', $correct_text);
1073
  return $return_array;
1074
  }
1075
 
1076
- add_action("plugins_loaded", 'qmn_question_type_fill_blank');
1077
 
1078
  /**
1079
- * This function registers the fill in the blank question type
1080
- *
1081
- * @return void
1082
- * @since 4.4.0
1083
- */
1084
- function qmn_question_type_fill_blank()
1085
- {
1086
  global $mlwQuizMasterNext;
1087
  $edit_args = array(
1088
- 'inputs' => array(
1089
  'question',
1090
  'answer',
1091
  'hint',
1092
  'correct_info',
1093
  'comments',
1094
  'category',
1095
- 'required'
1096
  ),
1097
- 'information' => __('For fill in the blank types, use %BLANK% to represent where to put the text box in your text.', 'quiz-master-next'),
1098
  'extra_inputs' => array(),
1099
- 'function' => ''
1100
  );
1101
 
1102
- $mlwQuizMasterNext->pluginHelper->register_question_type(__("Fill In The Blank", 'quiz-master-next'), 'qmn_fill_blank_display', true, 'qmn_fill_blank_review', $edit_args, null, 14 );
1103
-
1104
 
1105
  }
1106
 
1107
 
1108
  /**
1109
- * This function displays the fill in the blank question
1110
- *
1111
- * @params $id The ID of the multiple choice question
1112
- * @params $question The question that is being edited.
1113
- * @params @answers The array that contains the answers to the question.
1114
- * @return $question_display Returns the content of the question
1115
- * @since 4.4.0
1116
- */
1117
- function qmn_fill_blank_display($id, $question, $answers)
1118
- {
1119
- $question_display = '';
1120
- global $mlwQuizMasterNext;
1121
- $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
1122
- $autofill = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'autofill');
1123
- $limit_text = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'limit_text');
1124
- $autofill_att = $autofill ? "autocomplete='off' " : '';
1125
- $limit_text_att = $limit_text ? "maxlength='". $limit_text ."' " : '';
1126
- if ($required == 0) {$mlw_requireClass = "mlwRequiredText";} else {$mlw_requireClass = "";}
1127
- $input_text = "<input ". $autofill_att . $limit_text_att . " type='text' class='qmn_fill_blank $mlw_requireClass' name='question".$id."' />";
1128
- if (strpos($question, '%BLANK%') !== false)
1129
- {
1130
- $question = str_replace( "%BLANK%", $input_text, do_shortcode(htmlspecialchars_decode($question, ENT_QUOTES)));
 
1131
  }
1132
- //$question_title = apply_filters('the_content', $question);
1133
- $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
1134
- $question_display .= qsm_question_title_func($question, '', $new_question_title);
1135
- return apply_filters('qmn_fill_blank_display_front',$question_display,$id, $question, $answers);
1136
  }
1137
 
1138
 
1139
  /**
1140
- * This function determines how the fill in the blank question is graded.
1141
- *
1142
- * @params $id The ID of the multiple choice question
1143
- * @params $question The question that is being edited.
1144
- * @params @answers The array that contains the answers to the question.
1145
- * @return $return_array Returns the graded question to the results page
1146
- * @since 4.4.0
1147
- */
1148
- function qmn_fill_blank_review($id, $question, $answers)
1149
- {
1150
- $return_array = array(
1151
- 'points' => 0,
1152
- 'correct' => 'incorrect',
1153
- 'user_text' => '',
1154
- 'correct_text' => ''
1155
- );
1156
- if (strpos($question, '%BLANK%') !== false || strpos($question, '%blank%') !== false)
1157
- {
1158
- $return_array['question_text'] = str_replace( array( "%BLANK%", "%blank%" ), array( "__________", "__________" ), do_shortcode(htmlspecialchars_decode($question, ENT_QUOTES)));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1159
  }
1160
- if ( isset( $_POST["question".$id] ) ) {
1161
- $decode_user_answer = sanitize_textarea_field( strval( stripslashes( htmlspecialchars_decode( $_POST["question".$id], ENT_QUOTES ) ) ) );
1162
- $mlw_user_answer = trim( preg_replace( '/\s\s+/', ' ', str_replace( "\n", " ", $decode_user_answer ) ) );
1163
- } else {
1164
- $mlw_user_answer = " ";
1165
- }
1166
- $return_array['user_text'] = $mlw_user_answer;
1167
- foreach($answers as $answer)
1168
- {
1169
- $decode_correct_text = strval(htmlspecialchars_decode($answer[0], ENT_QUOTES));
1170
- $return_array['correct_text'] = trim( preg_replace( '/\s\s+/', ' ', str_replace( "\n", " ", $decode_correct_text ) ) );
1171
- if (mb_strtoupper($return_array['user_text']) == mb_strtoupper($return_array['correct_text']))
1172
- {
1173
- $return_array['correct'] = "correct";
1174
- $return_array['points'] = $answer[1];
1175
- break;
1176
- }
1177
- }
1178
- return $return_array;
1179
  }
1180
 
1181
 
1182
- //Start polar question
1183
- add_action("plugins_loaded", 'qmn_question_type_polar');
1184
 
1185
  /**
1186
  * This function registers the fill in the blank question type
@@ -1189,8 +1165,8 @@ add_action("plugins_loaded", 'qmn_question_type_polar');
1189
  * @since 6.4.1
1190
  */
1191
  function qmn_question_type_polar() {
1192
- global $mlwQuizMasterNext;
1193
- $mlwQuizMasterNext->pluginHelper->register_question_type(__("Polar", 'quiz-master-next'), 'qmn_polar_display', true, 'qmn_polar_review', null, null, 13);
1194
  }
1195
 
1196
  /**
@@ -1202,95 +1178,97 @@ function qmn_question_type_polar() {
1202
  * @return $question_display Returns the content of the question
1203
  * @since 6.4.1
1204
  */
1205
- function qmn_polar_display($id, $question, $answers) {
1206
- $question_display = '';
1207
- global $mlwQuizMasterNext;
1208
- $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
1209
- $autofill = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'autofill');
1210
- $limit_text = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'limit_text');
1211
- $autofill_att = $autofill ? "autocomplete='off' " : '';
1212
- $limit_text_att = $limit_text ? "maxlength='" . $limit_text . "' " : '';
1213
- $input_text = '';
1214
- $first_point = isset($answers[0][1]) ? $answers[0][1] : 0;
1215
- $second_point = isset($answers[1][1]) ? $answers[1][1] : 0;
1216
- $is_reverse = false;
1217
- $check_point = $second_point;
1218
- $font_weight_lc = 'right-polar-title';
1219
- $font_weight_rc = 'left-polar-title';
1220
- if($first_point > $second_point){
1221
- $is_reverse = true;
1222
- $check_point = $first_point;
1223
- $font_weight_lc = 'left-polar-title';
1224
- $font_weight_rc = 'right-polar-title';
1225
- }
1226
- $total_answer = count($answers);
1227
- ?>
1228
- <script type="text/javascript">
1229
- (function($) {
1230
- $(document).ready(function() {
1231
- $('#slider-' + '<?php echo $id; ?>').slider({
1232
- <?php if ($total_answer == 2 && $is_reverse) { ?>
1233
- max: <?php echo $answers[0][1]; ?>,
1234
- min: <?php echo $answers[1][1]; ?>,
1235
- isRTL: true,
1236
- <?php }else{ ?>
1237
- min: <?php echo $answers[0][1]; ?>,
1238
- max: <?php echo $answers[1][1]; ?>,
1239
- <?php } ?>
1240
- step: 1,
1241
- value: <?php echo $check_point/2; ?>,
1242
- change: function( event, ui ) {
1243
- $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.qmn_polar').val(ui.value);
1244
- if(ui.value == <?php echo $answers[0][1]; ?>){
1245
- $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.left-polar-title').css('font-weight','900');
1246
- $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.right-polar-title').css('font-weight','100');
1247
- } else if(ui.value == <?php echo $answers[1][1]; ?>){
1248
- $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.left-polar-title').css('font-weight','100');
1249
- $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.right-polar-title').css('font-weight','900');
1250
- } else if(ui.value == <?php echo $check_point / 2; ?>){
1251
- $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.left-polar-title').css('font-weight','400');
1252
- $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.right-polar-title').css('font-weight','400');
1253
- } else if(ui.value > <?php echo $check_point / 2; ?>){
1254
- $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.<?php echo $font_weight_rc; ?>').css('font-weight','400');
1255
- $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.<?php echo $font_weight_lc; ?>').css('font-weight','600');
1256
- } else if(ui.value < <?php echo $check_point / 2; ?>){
1257
- $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.<?php echo $font_weight_rc; ?>').css('font-weight','600');
1258
- $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.<?php echo $font_weight_lc; ?>').css('font-weight','400');
1259
- }
1260
- },
1261
- create: function( event, ui ) {
1262
- $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.left-polar-title').css('font-weight','400');
1263
- $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.right-polar-title').css('font-weight','400');
1264
- $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.qmn_polar').val(<?php echo $check_point/2; ?>);
1265
- }
1266
- });
1267
- var maxHeight = Math.max.apply(null, $(".question-section-id-<?php echo $id; ?> .question-type-polar-s > div").map(function (){
1268
- return $(this).height();
1269
- }).get());
1270
- $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').height(maxHeight);
1271
- });
1272
- })(jQuery);
1273
- </script>
1274
- <?php
1275
- if ($required == 0) {
1276
- $mlw_requireClass = "mlwRequiredText";
1277
- } else {
1278
- $mlw_requireClass = "";
1279
- }
1280
- $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
1281
- $question_title = qsm_question_title_func($question, '', $new_question_title);
1282
- //$question_title = "<div class='mlw_qmn_question polar-question-title'>". do_shortcode(htmlspecialchars_decode($question, ENT_QUOTES)) ."</div>";
1283
- $input_text .= "<div class='left-polar-title'>" . $answers[0][0] ."</div>";
1284
- $input_text .= "<div class='slider-main-wrapper'><input type='hidden' class='qmn_polar $mlw_requireClass' id='question" . $id . "' name='question" . $id . "' />";
1285
- $input_text .= '<div id="slider-'. $id .'"></div></div>';
1286
- $input_text .= "<div class='right-polar-title'>" . $answers[1][0] . "</div>";
1287
- /*if (strpos($question, '%POLAR_SLIDER%') !== false) {
1288
- $question = str_replace("%POLAR_SLIDER%", $input_text, do_shortcode(htmlspecialchars_decode($question, ENT_QUOTES)));
1289
- }*/
1290
- $question = $input_text;
1291
- //$question_title = apply_filters('the_content', $question);
1292
- $question_display .= $question_title . "<span class='mlw_qmn_question question-type-polar-s'>" . do_shortcode( htmlspecialchars_decode( $question, ENT_QUOTES ) ) . "</span>";;
1293
- return apply_filters('qmn_polar_display_front', $question_display, $id, $question, $answers);
 
 
1294
  }
1295
 
1296
  /**
@@ -1302,57 +1280,57 @@ function qmn_polar_display($id, $question, $answers) {
1302
  * @return $return_array Returns the graded question to the results page
1303
  * @since 6.4.1
1304
  */
1305
- function qmn_polar_review($id, $question, $answers) {
1306
- $return_array = array(
1307
- 'points' => 0,
1308
- 'correct' => 'incorrect',
1309
- 'user_text' => '',
1310
- 'correct_text' => ''
1311
- );
1312
- if (strpos($question, '%POLAR_SLIDER%') !== false || strpos($question, '%polar_slider%') !== false) {
1313
- $return_array['question_text'] = str_replace( array( "%POLAR_SLIDER%", "%polar_slider%" ), array( "__________", "__________" ), do_shortcode(htmlspecialchars_decode($question, ENT_QUOTES)));
1314
- }
1315
- if (isset($_POST["question" . $id])) {
1316
- $decode_user_answer = sanitize_textarea_field( $_POST["question" . $id] );
1317
- $mlw_user_answer = trim(preg_replace('/\s\s+/', ' ', str_replace("\n", " ", $decode_user_answer)));
1318
- } else {
1319
- $mlw_user_answer = " ";
1320
- }
1321
- $return_array['user_text'] = $mlw_user_answer;
1322
- $return_array['points'] = $mlw_user_answer;
1323
- foreach($answers as $answer) {
1324
- $decode_correct_text = $answer[1];
1325
- $return_array['correct_text'] = trim( preg_replace( '/\s\s+/', ' ', str_replace( "\n", " ", $decode_correct_text ) ) );
1326
- if ( $return_array['user_text'] == trim ($decode_correct_text) && isset($answer[2]) && $answer[2] == 1 ) {
1327
- $return_array['correct'] = "correct";
1328
- break;
1329
- }
1330
- }
1331
- return $return_array;
1332
  }
1333
 
1334
- function qsm_question_title_func($question,$question_type = '',$new_question_title=''){
1335
- //$question_title = apply_filters('the_content', $question);
1336
- $question_title = $question;
1337
- global $wp_embed,$mlwQuizMasterNext;
1338
- $question_title = $wp_embed->run_shortcode($question_title);
1339
- $question_title = 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>",$question_title);
1340
- $polar_extra_class = '';
1341
- $question_display = '';
1342
- if($question_type == 'polar'){
1343
- $polar_extra_class = 'question-type-polar-s';
1344
- }
1345
- $qmn_quiz_options = $mlwQuizMasterNext->quiz_settings->get_quiz_options();
1346
- $deselect_answer = '';
1347
- if( isset($qmn_quiz_options->enable_deselect_option) && $qmn_quiz_options->enable_deselect_option == 1 && ($question_type == 'multiple_choice' || $question_type == 'horizontal_multiple_choice') ){
1348
- $deselect_answer = '<a href="#" class="qsm-deselect-answer">Deselect Answer</a>';
1349
- }
1350
-
1351
- if($new_question_title != ''){
1352
- $question_display .= "<span class='mlw_qmn_new_question'>" . sanitize_text_field( htmlspecialchars_decode( $new_question_title, ENT_QUOTES ) ) . "</span>";
1353
- $polar_extra_class .= ' qsm_remove_bold';
1354
- }
1355
- $question_display .= "<span class='mlw_qmn_question {$polar_extra_class}' >" . do_shortcode( htmlspecialchars_decode( $question_title, ENT_QUOTES ) ) . $deselect_answer . "</span>";
1356
- return $question_display;
1357
  }
1358
  ?>
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+ add_action( 'plugins_loaded', 'qmn_question_type_multiple_choice' );
6
 
7
  /**
8
+ * Registers the multiple choice type
9
+ *
10
+ * @return void
11
+ * @since 4.4.0
12
+ */
13
+ function qmn_question_type_multiple_choice() {
 
14
  global $mlwQuizMasterNext;
15
+ $mlwQuizMasterNext->pluginHelper->register_question_type( __( 'Vertical Multiple Choice', 'quiz-master-next' ), 'qmn_multiple_choice_display', true, 'qmn_multiple_choice_review', null, null, 0 );
16
  }
17
 
18
+ add_action( 'plugins_loaded', 'qmn_question_type_file_upload' );
19
  /**
20
+ * Registers the file upload type
21
+ *
22
+ * @return void
23
+ * @since 6.3.7
24
+ */
25
+ function qmn_question_type_file_upload() {
26
+ global $mlwQuizMasterNext;
27
+ $mlwQuizMasterNext->pluginHelper->register_question_type( __( 'File Upload', 'quiz-master-next' ), 'qmn_file_upload_display', true, 'qmn_file_upload_review', null, null, 11 );
28
  }
29
 
30
  /**
31
+ * This function shows the content of the file upload
32
+ *
33
+ * @param $id The ID of the multiple choice question
34
+ * @param $question The question that is being edited.
35
+ * @param @answers The array that contains the answers to the question.
36
+ * @return $question_display Contains all the content of the question
37
+ * @since 6.3.7
38
+ */
39
+ function qmn_file_upload_display( $id, $question, $answers ) {
40
+ $question_display = '';
41
+ global $mlwQuizMasterNext;
42
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'required' );
43
+ if ( $required == 0 ) {
44
+ $mlw_requireClass = 'mlwRequiredFileUpload';
45
+ } else {
46
+ $mlw_requireClass = '';}
47
+ // $question_title = apply_filters('the_content', $question);
48
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'question_title' );
49
+ $question_display .= qsm_question_title_func( $question, '', $new_question_title );
50
+ $question_display .= "<div style=''></div><input type='file' class='mlw_answer_file_upload $mlw_requireClass'/>";
51
+ $question_display .= "<div style='display: none;' class='loading-uploaded-file'><img src='" . get_site_url() . "/wp-includes/images/spinner-2x.gif'></div>";
52
+ $question_display .= "<div style='display: none;' class='remove-uploaded-file'><span class='dashicons dashicons-trash'></span></div>";
53
+ $question_display .= "<input class='mlw_file_upload_hidden_value' type='hidden' name='question" . $id . "' value='' />";
54
+ $question_display .= "<span style='display: none;' class='mlw-file-upload-error-msg'></span>";
55
+ $question_display .= "<input class='mlw_file_upload_hidden_path' type='hidden' value='' />";
56
+ return apply_filters( 'qmn_file_upload_display_front', $question_display, $id, $question, $answers );
57
  }
58
 
59
  /**
60
+ * This function determines how the file upload will work.
61
+ *
62
+ * @params $id The ID of the multiple choice question
63
+ * @params $question The question that is being edited.
64
+ * @params @answers The array that contains the answers to the question.
65
+ * @return $return_array Returns the graded question to the results page
66
+ * @since 5.3.7
67
+ */
68
+ function qmn_file_upload_review( $id, $question, $answers ) {
69
+ $return_array = array(
70
+ 'points' => 0,
71
+ 'correct' => 'incorrect',
72
+ 'user_text' => '',
73
+ 'correct_text' => '',
74
+ 'question_type' => 'file_upload',
75
+ );
76
+ if ( isset( $_POST[ 'question' . $id ] ) ) {
77
+ $decode_user_answer = sanitize_text_field( $_POST[ 'question' . $id ] );
78
+ $mlw_user_answer = trim( $decode_user_answer );
79
+ } else {
80
+ $mlw_user_answer = ' ';
81
+ }
82
+ $return_array['user_text'] = $mlw_user_answer;
83
+ foreach ( $answers as $answer ) {
84
+ $decode_correct_text = strval( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) );
85
+ $return_array['correct_text'] = trim( preg_replace( '/\s\s+/', ' ', str_replace( "\n", ' ', $decode_correct_text ) ) );
86
+ if ( mb_strtoupper( $return_array['user_text'] ) == mb_strtoupper( $return_array['correct_text'] ) ) {
87
+ $return_array['correct'] = 'correct';
88
+ $return_array['points'] = $answer[1];
89
+ break;
90
+ }
91
+ }
92
+ return $return_array;
 
 
93
  }
94
 
95
  /**
96
+ * This function shows the content of the multiple choice question.
97
+ *
98
+ * @params $id The ID of the multiple choice question
99
+ * @params $question The question that is being edited.
100
+ * @params @answers The array that contains the answers to the question.
101
+ * @return $question_display Contains all the content of the question
102
+ * @since 4.4.0
103
+ */
104
+ function qmn_multiple_choice_display( $id, $question, $answers ) {
105
+ $question_display = '';
106
+ global $mlwQuizMasterNext;
107
+ $answerEditor = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'answerEditor' );
108
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'required' );
109
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'question_title' );
110
+ if ( $required == 0 ) {
111
+ $mlw_requireClass = 'mlwRequiredRadio';
112
+ } else {
113
+ $mlw_requireClass = '';}
114
+ // $question_title = apply_filters('the_content', $question);
115
+ $question_display .= qsm_question_title_func( $question, 'multiple_choice', $new_question_title );
116
+ $question_display .= "<div class='qmn_radio_answers $mlw_requireClass'>";
117
+ if ( is_array( $answers ) ) {
118
+ $mlw_answer_total = 0;
119
+ foreach ( $answers as $answer ) {
120
+ $mlw_answer_total++;
121
+ if ( $answer[0] != '' ) {
122
+ if ( $answerEditor === 'rich' ) {
123
+ $question_display .= "<div class='qmn_mc_answer_wrap' id='question$id-$mlw_answer_total'>";
124
+ } else {
125
+ $question_display .= "<div class='qmn_mc_answer_wrap' id='question" . $id . '-' . str_replace( ' ', '-', esc_attr( $answer[0] ) ) . "'>";
126
+ }
127
+ $question_display .= "<input type='radio' class='qmn_quiz_radio' name='question" . $id . "' id='question" . $id . '_' . $mlw_answer_total . "' value='" . $answer[0] . "' />";
128
+ $question_display .= "<label for='question" . $id . '_' . $mlw_answer_total . "'>" . trim( do_shortcode( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) ) ) . '</label>';
129
+ $question_display .= '</div>';
130
+ }
131
+ }
132
+ $question_display .= "<input type='radio' style='display: none;' name='question" . $id . "' id='question" . $id . "_none' checked='checked' value='' />";
133
+ }
134
+ $question_display .= '</div>';
135
+ return apply_filters( 'qmn_multiple_choice_display_front', $question_display, $id, $question, $answers );
 
136
  }
137
 
138
  /**
139
+ * This function determines how the multiple choice question is graded.
140
+ *
141
+ * @params $id The ID of the multiple choice question
142
+ * @params $question The question that is being edited.
143
+ * @params @answers The array that contains the answers to the question.
144
+ * @return $return_array Returns the graded question to the results page
145
+ * @since 4.4.0
146
+ */
147
+ function qmn_multiple_choice_review( $id, $question, $answers ) {
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
+ $correct_text = array();
165
+ foreach ( $answers as $answer ) {
166
+ if ( $answerEditor === 'rich' ) {
167
+ $answer_option = stripslashes( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) );
168
+ $sinel_answer_cmp = preg_replace( "/\s+|\n+|\r/", ' ', htmlentities( $answer_option ) );
169
+ if ( $rich_text_comapre == $sinel_answer_cmp ) {
170
+ $return_array['points'] = $answer[1];
171
+ $return_array['user_text'] = $answer[0];
172
+ if ( $answer[2] == 1 ) {
173
+ $return_array['correct'] = 'correct';
174
  }
175
  }
176
+ if ( $answer[2] == 1 ) {
177
+ $correct_text[] = stripslashes( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) );
178
  }
179
  } else {
180
  $mlw_user_answer = '';
181
+ if ( isset( $_POST[ 'question' . $id ] ) ) {
182
+ $mlw_user_answer = $_POST[ 'question' . $id ];
183
+ $mlw_user_answer = trim( htmlspecialchars_decode( $mlw_user_answer, ENT_QUOTES ) );
184
+ $mlw_user_answer = str_replace( '\\', '', $mlw_user_answer );
185
  }
186
+ $single_answer = trim( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) );
187
+ $single_answer = str_replace( '\\', '', $single_answer );
188
+ if ( $mlw_user_answer == $single_answer ) {
189
+ $return_array['points'] = $answer[1];
190
+ $return_array['user_text'] = $answer[0];
191
+ if ( $answer[2] == 1 ) {
192
+ $return_array['correct'] = 'correct';
193
  }
194
  }
195
+ if ( $answer[2] == 1 ) {
196
+ $correct_text[] = stripslashes( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) );
197
  }
198
  }
199
  }
200
+ $return_array['correct_text'] = implode( '.', $correct_text );
201
  return $return_array;
202
  }
203
 
204
+ add_action( 'plugins_loaded', 'qmn_question_type_date' );
205
  /**
206
+ * Registers the date type
207
+ *
208
+ * @return void
209
+ * @since 6.3.7
210
+ */
211
+ function qmn_question_type_date() {
212
+ global $mlwQuizMasterNext;
213
+ $mlwQuizMasterNext->pluginHelper->register_question_type( __( 'Date', 'quiz-master-next' ), 'qmn_date_display', true, 'qmn_date_review', null, null, 12 );
214
  }
215
 
216
  /**
217
+ * This function shows the content of the date field
218
+ *
219
+ * @params $id The ID of the multiple choice question
220
+ * @params $question The question that is being edited.
221
+ * @params @answers The array that contains the answers to the question.
222
+ * @return $question_display Contains all the content of the question
223
+ * @since 6.3.7
224
+ */
225
+ function qmn_date_display( $id, $question, $answers ) {
226
+ $question_display = '';
227
+ global $mlwQuizMasterNext;
228
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'required' );
229
+ if ( $required == 0 ) {
230
+ $mlw_requireClass = 'mlwRequiredDate';
231
+ } else {
232
+ $mlw_requireClass = '';}
233
+ // $question_title = apply_filters('the_content', $question);
234
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'question_title' );
235
+ $question_display .= qsm_question_title_func( $question, '', $new_question_title );
236
+ $question_display .= "<input type='date' class='mlw_answer_date $mlw_requireClass' name='question" . $id . "' id='question" . $id . "' value=''/>";
237
+ // $question_display .= "<script>jQuery(document).ready(function () { jQuery('#question".$id."').datepicker(); });</script>";
238
+ return apply_filters( 'qmn_date_display_front', $question_display, $id, $question, $answers );
239
  }
240
 
241
  /**
242
+ * This function reviews the date type.
243
+ *
244
+ * @params $id The ID of the multiple choice question
245
+ * @params $question The question that is being edited.
246
+ * @params @answers The array that contains the answers to the question.
247
+ * @return $return_array Returns the graded question to the results page
248
+ * @since 6.3.7
249
+ */
250
+ function qmn_date_review( $id, $question, $answers ) {
251
+ $return_array = array(
252
+ 'points' => 0,
253
+ 'correct' => 'incorrect',
254
+ 'user_text' => '',
255
+ 'correct_text' => '',
256
+ );
257
+ if ( isset( $_POST[ 'question' . $id ] ) ) {
258
+ $decode_user_answer = sanitize_textarea_field( strval( stripslashes( htmlspecialchars_decode( $_POST[ 'question' . $id ], ENT_QUOTES ) ) ) );
259
+ $mlw_user_answer = trim( preg_replace( '/\s\s+/', ' ', str_replace( "\n", ' ', $decode_user_answer ) ) );
260
+ } else {
261
+ $mlw_user_answer = ' ';
262
+ }
263
+ $return_array['user_text'] = $mlw_user_answer;
264
+ foreach ( $answers as $answer ) {
265
+ $decode_correct_text = strval( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) );
266
+ $return_array['correct_text'] = trim( preg_replace( '/\s\s+/', ' ', str_replace( "\n", ' ', $decode_correct_text ) ) );
267
+ if ( mb_strtoupper( $return_array['user_text'] ) == mb_strtoupper( $return_array['correct_text'] ) ) {
268
+ $return_array['correct'] = 'correct';
269
+ $return_array['points'] = $answer[1];
270
+ break;
271
+ }
272
+ }
273
+ return $return_array;
274
  }
275
 
276
+ add_action( 'plugins_loaded', 'qmn_question_type_horizontal_multiple_choice' );
277
 
278
  /**
279
+ * This function registers the horizontal multiple choice type.
280
+ *
281
+ * @return void
282
+ * @since 4.4.0
283
+ */
284
+ function qmn_question_type_horizontal_multiple_choice() {
 
285
  global $mlwQuizMasterNext;
286
+ $mlwQuizMasterNext->pluginHelper->register_question_type( __( 'Horizontal Multiple Choice', 'quiz-master-next' ), 'qmn_horizontal_multiple_choice_display', true, 'qmn_horizontal_multiple_choice_review', null, null, 1 );
287
  }
288
 
289
  /**
290
+ * This function shows the content of the horizontal multiple choice question.
291
+ *
292
+ * @params $id The ID of the multiple choice question
293
+ * @params $question The question that is being edited.
294
+ * @params @answers The array that contains the answers to the question.
295
+ * @return $question_display Contains all the content of the question
296
+ * @since 4.4.0
297
+ */
298
+ function qmn_horizontal_multiple_choice_display( $id, $question, $answers ) {
299
+ $question_display = '';
300
+ global $mlwQuizMasterNext;
301
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'required' );
302
+ if ( $required == 0 ) {
303
+ $mlw_requireClass = 'mlwRequiredRadio';
304
+ } else {
305
+ $mlw_requireClass = '';}
306
+ // $question_title = apply_filters('the_content', $question);
307
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'question_title' );
308
+ $question_display .= qsm_question_title_func( $question, 'horizontal_multiple_choice', $new_question_title );
309
+ $question_display .= "<div class='qmn_radio_answers $mlw_requireClass'>";
310
+ if ( is_array( $answers ) ) {
311
+ $mlw_answer_total = 0;
312
+ foreach ( $answers as $answer ) {
313
+ $mlw_answer_total++;
314
+ if ( $answer[0] != '' ) {
315
+ $question_display .= "<span class='mlw_horizontal_choice'><input type='radio' class='qmn_quiz_radio' name='question" . $id . "' id='question" . $id . '_' . $mlw_answer_total . "' value='" . $answer[0] . "' /><label for='question" . $id . '_' . $mlw_answer_total . "'>" . trim( do_shortcode( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) ) ) . '</label></span>';
316
+ }
317
+ }
318
+ $question_display .= "<input type='radio' style='display: none;' name='question" . $id . "' id='question" . $id . "_none' checked='checked' value='' />";
319
+ }
320
+ $question_display .= '</div>';
321
+
322
+ return apply_filters( 'qmn_horizontal_multiple_choice_display_front', $question_display, $id, $question, $answers );
 
323
  }
324
 
325
  /**
326
+ * This function determines how the question is graded.
327
+ *
328
+ * @params $id The ID of the multiple choice question
329
+ * @params $question The question that is being edited.
330
+ * @params @answers The array that contains the answers to the question.
331
+ * @return $return_array Returns the graded question to the results page
332
+ * @since 4.4.0
333
+ */
334
+ function qmn_horizontal_multiple_choice_review( $id, $question, $answers ) {
335
  global $mlwQuizMasterNext;
336
+ $answerEditor = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'answerEditor' );
337
  $return_array = array(
338
+ 'points' => 0,
339
+ 'correct' => 'incorrect',
340
+ 'user_text' => '',
341
+ 'correct_text' => '',
342
  );
343
+ if ( isset( $_POST[ 'question' . $id ] ) ) {
344
+ $mlw_user_answer = $_POST[ 'question' . $id ];
345
+ $mlw_user_answer = trim( stripslashes( htmlspecialchars_decode( $mlw_user_answer, ENT_QUOTES ) ) );
346
  } else {
347
+ $mlw_user_answer = ' ';
348
  }
349
+ $rich_text_comapre = preg_replace( "/\s+|\n+|\r/", ' ', htmlentities( $mlw_user_answer ) );
350
+ $correct_text = array();
351
+ foreach ( $answers as $answer ) {
352
+ if ( $answerEditor === 'rich' ) {
353
+ $answer_option = stripslashes( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) );
354
+ $sinel_answer_cmp = preg_replace( "/\s+|\n+|\r/", ' ', htmlentities( $answer_option ) );
355
+ if ( $rich_text_comapre == $sinel_answer_cmp ) {
356
+ $return_array['points'] = $answer[1];
357
+ $return_array['user_text'] = $answer[0];
358
+ if ( $answer[2] == 1 ) {
359
+ $return_array['correct'] = 'correct';
360
  }
361
  }
362
+ if ( $answer[2] == 1 ) {
363
+ $correct_text[] = stripslashes( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) );
364
  }
365
  } else {
366
  $mlw_user_answer = '';
367
+ if ( isset( $_POST[ 'question' . $id ] ) ) {
368
+ $mlw_user_answer = $_POST[ 'question' . $id ];
369
+ $mlw_user_answer = trim( htmlspecialchars_decode( $mlw_user_answer, ENT_QUOTES ) );
370
+ $mlw_user_answer = str_replace( '\\', '', $mlw_user_answer );
371
  }
372
+ $single_answer = trim( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) );
373
+ $single_answer = str_replace( '\\', '', $single_answer );
374
+ if ( $mlw_user_answer == $single_answer ) {
375
+ $return_array['points'] = $answer[1];
376
+ $return_array['user_text'] = $answer[0];
377
+ if ( $answer[2] == 1 ) {
378
+ $return_array['correct'] = 'correct';
379
  }
380
  }
381
+ if ( $answer[2] == 1 ) {
382
+ $correct_text[] = stripslashes( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) );
383
  }
384
  }
385
  }
386
+ $return_array['correct_text'] = implode( '.', $correct_text );
387
  return $return_array;
388
  }
389
 
390
+ add_action( 'plugins_loaded', 'qmn_question_type_drop_down' );
391
 
392
  /**
393
+ * This function registers the drop down question type
394
+ *
395
+ * @return void
396
+ * @since 4.4.0
397
+ */
398
+ function qmn_question_type_drop_down() {
 
399
  global $mlwQuizMasterNext;
400
+ $mlwQuizMasterNext->pluginHelper->register_question_type( __( 'Drop Down', 'quiz-master-next' ), 'qmn_drop_down_display', true, 'qmn_drop_down_review', null, null, 2 );
401
  }
402
 
403
  /**
404
+ * This function shows the content of the multiple choice question.
405
+ *
406
+ * @params $id The ID of the multiple choice question
407
+ * @params $question The question that is being edited.
408
+ * @params @answers The array that contains the answers to the question.
409
+ * @return $question_display Contains all the content of the question
410
+ * @since 4.4.0
411
+ */
412
+ function qmn_drop_down_display( $id, $question, $answers ) {
413
+ $question_display = '';
414
+ global $mlwQuizMasterNext;
415
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'required' );
416
+ if ( 0 == $required ) {
417
+ $require_class = 'qsmRequiredSelect';
418
+ } else {
419
+ $require_class = '';
420
+ }
421
+ // $question_title = apply_filters('the_content', $question);
422
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'question_title' );
423
+ $question_display .= qsm_question_title_func( $question, '', $new_question_title );
424
+ $question_display .= "<select class='qsm_select $require_class' name='question" . $id . "'>";
425
+ $question_display .= "<option value=''>" . __( 'Please select your answer', 'quiz-master-next' ) . '</option>';
426
+ if ( is_array( $answers ) ) {
427
+ $mlw_answer_total = 0;
428
+ foreach ( $answers as $answer ) {
429
+ $mlw_answer_total++;
430
+ if ( $answer[0] != '' ) {
431
+ $question_display .= "<option value='" . esc_attr( $answer[0] ) . "'>" . htmlspecialchars_decode( $answer[0], ENT_QUOTES ) . '</option>';
432
+ }
433
+ }
434
+ }
435
+ $question_display .= '</select>';
436
+ return apply_filters( 'qmn_drop_down_display_front', $question_display, $id, $question, $answers );
 
 
 
 
437
  }
438
 
439
  /**
440
+ * This function determines how the question is graded
441
+ *
442
+ * @params $id The ID of the multiple choice question
443
+ * @params $question The question that is being edited.
444
+ * @params @answers The array that contains the answers to the question.
445
+ * @return $return_array Returns the graded question to the results page
446
+ * @since 4.4.0
447
+ */
448
+ function qmn_drop_down_review( $id, $question, $answers ) {
449
+ global $mlwQuizMasterNext;
450
+ $answerEditor = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'answerEditor' );
451
+ $return_array = array(
452
+ 'points' => 0,
453
+ 'correct' => 'incorrect',
454
+ 'user_text' => '',
455
+ 'correct_text' => '',
456
+ );
457
+ if ( isset( $_POST[ 'question' . $id ] ) ) {
458
+ $mlw_user_answer = $_POST[ 'question' . $id ];
459
+ $mlw_user_answer = trim( stripslashes( htmlspecialchars_decode( $mlw_user_answer, ENT_QUOTES ) ) );
460
+ } else {
461
+ $mlw_user_answer = ' ';
462
+ }
463
+ foreach ( $answers as $answer ) {
464
+ $answers_loop = trim( stripslashes( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) ) );
465
+ if ( $mlw_user_answer == $answers_loop ) {
466
+ $return_array['points'] = $answer[1];
467
+ $return_array['user_text'] = strval( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) );
468
+ if ( $answer[2] == 1 ) {
469
+ $return_array['correct'] = 'correct';
470
+ }
471
+ }
472
+ if ( $answer[2] == 1 ) {
473
+ $return_array['correct_text'] = htmlspecialchars_decode( $answer[0], ENT_QUOTES );
474
+ }
475
+ }
476
+ return $return_array;
 
 
 
 
 
477
  }
478
 
479
+ add_action( 'plugins_loaded', 'qmn_question_type_small_open' );
480
 
481
  /**
482
+ * This function registers the small open question type
483
+ *
484
+ * @return void
485
+ * @since 4.4.0
486
+ */
487
+ function qmn_question_type_small_open() {
 
488
  global $mlwQuizMasterNext;
489
+ $mlwQuizMasterNext->pluginHelper->register_question_type( __( 'Short Answer', 'quiz-master-next' ), 'qmn_small_open_display', true, 'qmn_small_open_review', null, null, 3 );
490
  }
491
 
492
  /**
493
+ * This function shows the content of the small open answer question.
494
+ *
495
+ * @params $id The ID of the multiple choice question
496
+ * @params $question The question that is being edited.
497
+ * @params @answers The array that contains the answers to the question.
498
+ * @return $question_display Contains all the content of the question
499
+ * @since 4.4.0
500
+ */
501
+ function qmn_small_open_display( $id, $question, $answers ) {
502
+ $question_display = '';
503
+ global $mlwQuizMasterNext;
504
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'required' );
505
+ $autofill = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'autofill' );
506
+ $limit_text = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'limit_text' );
507
+ $autofill_att = $autofill ? "autocomplete='off' " : '';
508
+ $limit_text_att = $limit_text ? "maxlength='" . $limit_text . "' " : '';
509
+ if ( $required == 0 ) {
510
+ $mlw_requireClass = 'mlwRequiredText';
511
+ } else {
512
+ $mlw_requireClass = '';}
513
+ // $question_title = apply_filters('the_content', $question);
514
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'question_title' );
515
+ $question_display .= qsm_question_title_func( $question, '', $new_question_title );
516
+ $question_display .= '<input ' . $autofill_att . $limit_text_att . " type='text' class='mlw_answer_open_text $mlw_requireClass' name='question" . $id . "' />";
517
+ return apply_filters( 'qmn_small_open_display_front', $question_display, $id, $question, $answers );
518
  }
519
 
520
  /**
521
+ * This function reviews the small open answer.
522
+ *
523
+ * @params $id The ID of the multiple choice question
524
+ * @params $question The question that is being edited.
525
+ * @params @answers The array that contains the answers to the question.
526
+ * @return $return_array Returns the graded question to the results page
527
+ * @since 4.4.0
528
+ */
529
+ function qmn_small_open_review( $id, $question, $answers ) {
530
+ $return_array = array(
531
+ 'points' => 0,
532
+ 'correct' => 'incorrect',
533
+ 'user_text' => '',
534
+ 'correct_text' => '',
535
+ );
536
+ if ( isset( $_POST[ 'question' . $id ] ) ) {
537
+ $decode_user_answer = sanitize_textarea_field( strval( stripslashes( htmlspecialchars_decode( $_POST[ 'question' . $id ], ENT_QUOTES ) ) ) );
538
+ $mlw_user_answer = trim( preg_replace( '/\s\s+/', ' ', str_replace( "\n", ' ', $decode_user_answer ) ) );
539
+ } else {
540
+ $mlw_user_answer = ' ';
541
+ }
542
+ $return_array['user_text'] = $mlw_user_answer;
543
+ foreach ( $answers as $answer ) {
544
+ $decode_correct_text = strval( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) );
545
+ $return_array['correct_text'] = trim( preg_replace( '/\s\s+/', ' ', str_replace( "\n", ' ', $decode_correct_text ) ) );
546
+ if ( mb_strtoupper( $return_array['user_text'] ) == mb_strtoupper( $return_array['correct_text'] ) ) {
547
+ $return_array['correct'] = 'correct';
548
+ $return_array['points'] = $answer[1];
549
+ break;
550
+ }
551
+ }
552
+ return $return_array;
 
 
 
553
  }
554
 
555
+ add_action( 'plugins_loaded', 'qmn_question_type_multiple_response' );
556
 
557
  /**
558
+ * This function registers the multiple response question type
559
+ *
560
+ * @return void
561
+ * @since 4.4.0
562
+ */
563
+ function qmn_question_type_multiple_response() {
 
564
  global $mlwQuizMasterNext;
565
+ $mlwQuizMasterNext->pluginHelper->register_question_type( __( 'Multiple Response', 'quiz-master-next' ), 'qmn_multiple_response_display', true, 'qmn_multiple_response_review', null, null, 4 );
566
  }
567
 
568
  /**
569
+ * This function shows the content of the multiple response question
570
+ *
571
+ * @params $id The ID of the multiple choice question
572
+ * @params $question The question that is being edited.
573
+ * @params @answers The array that contains the answers to the question.
574
+ * @return $question_display Contains all the content of the question
575
+ * @since 4.4.0
576
+ */
577
+ function qmn_multiple_response_display( $id, $question, $answers ) {
578
+ $question_display = $limit_mr_text = '';
579
+ global $mlwQuizMasterNext;
580
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'required' );
581
+ $limit_multiple_response = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'limit_multiple_response' );
582
+ if ( $limit_multiple_response > 0 ) {
583
+ $limit_mr_text = 'onchange="qsmCheckMR(this,' . $limit_multiple_response . ')"';
584
+ }
585
+ if ( $required == 0 ) {
586
+ $mlw_requireClass = 'mlwRequiredCheck';
587
+ } else {
588
+ $mlw_requireClass = '';}
589
+ // $question_title = apply_filters('the_content', $question);
590
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'question_title' );
591
+ $question_display .= qsm_question_title_func( $question, '', $new_question_title );
592
+ $question_display .= "<div class='qmn_check_answers $mlw_requireClass'>";
593
+ if ( is_array( $answers ) ) {
594
+ $mlw_answer_total = 0;
595
+ foreach ( $answers as $answer ) {
596
+ $mlw_answer_total++;
597
+ if ( $answer[0] != '' ) {
598
  $question_display .= '<div class="qsm_check_answer">';
599
+ $question_display .= "<input type='hidden' name='question" . $id . "' value='This value does not matter' />";
600
+ $question_display .= "<input type='checkbox' " . $limit_mr_text . " name='question" . $id . '_' . $mlw_answer_total . "' id='question" . $id . '_' . $mlw_answer_total . "' value='" . esc_attr( $answer[0] ) . "' /> <label for='question" . $id . '_' . $mlw_answer_total . "'>" . trim( do_shortcode( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) ) ) . '</label>';
601
  $question_display .= '</div>';
602
+ }
603
+ }
604
+ }
605
+ $question_display .= '</div>';
606
+ return apply_filters( 'qmn_multiple_response_display_front', $question_display, $id, $question, $answers );
607
  }
608
 
609
  /**
610
+ * This function determines how the multiple response is graded,
611
+ *
612
+ * @params $id The ID of the multiple choice question
613
+ * @params $question The question that is being edited.
614
+ * @params @answers The array that contains the answers to the question.
615
+ * @return $return_array Returns the graded question to the results page
616
+ * @since 4.4.0
617
+ */
618
+ function qmn_multiple_response_review( $id, $question, $answers ) {
619
+ $return_array = array(
620
+ 'points' => 0,
621
+ 'correct' => 'incorrect',
622
+ 'user_text' => '',
623
+ 'correct_text' => '',
624
+ 'user_compare_text' => '',
625
  );
626
+ $user_correct = 0;
627
  $total_correct = 0;
628
+ $total_answers = count( $answers );
629
+ $correct_text = array();
630
+ foreach ( $answers as $answer ) {
631
+ for ( $i = 1; $i <= $total_answers; $i++ ) {
632
+ if ( isset( $_POST[ 'question' . $id . '_' . $i ] ) && sanitize_textarea_field( htmlspecialchars( stripslashes( $_POST[ 'question' . $id . '_' . $i ] ), ENT_QUOTES ) ) == esc_attr( $answer[0] ) ) {
633
+ $return_array['points'] += $answer[1];
634
+ $return_array['user_text'] .= htmlspecialchars_decode( $answer[0], ENT_QUOTES ) . '.';
635
+ $return_array['user_compare_text'] .= sanitize_textarea_field( strval( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) ) ) . '=====';
636
+ if ( $answer[2] == 1 ) {
637
  $user_correct += 1;
638
  } else {
639
  $user_correct = -1;
640
  }
641
  }
642
  }
643
+ if ( $answer[2] == 1 ) {
644
+ $correct_text[] = stripslashes( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) );
645
  $total_correct++;
646
  }
647
  }
648
+ if ( $user_correct == $total_correct ) {
649
+ $return_array['correct'] = 'correct';
650
  }
651
+ $return_array['correct_text'] = implode( '.', $correct_text );
652
  return $return_array;
653
  }
654
 
655
+ add_action( 'plugins_loaded', 'qmn_question_type_large_open' );
656
 
657
  /**
658
+ * This function registers the large open question type.
659
+ *
660
+ * @since 4.4.0
661
+ */
662
+ function qmn_question_type_large_open() {
 
663
  global $mlwQuizMasterNext;
664
+ $mlwQuizMasterNext->pluginHelper->register_question_type( __( 'Paragraph', 'quiz-master-next' ), 'qmn_large_open_display', true, 'qmn_large_open_review', null, null, 5 );
665
  }
666
 
667
  /**
668
+ * This function displays the content of the large open question.
669
+ *
670
+ * @params $id The ID of the multiple choice question
671
+ * @params $question The question that is being edited.
672
+ * @params @answers The array that contains the answers to the question.
673
+ * @return $question_display Contains all the content of the question
674
+ * @since 4.4.0
675
+ */
676
+ function qmn_large_open_display( $id, $question, $answers ) {
677
+ $question_display = '';
678
+ global $mlwQuizMasterNext;
679
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'required' );
680
+ $limit_text = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'limit_text' );
681
+ if ( $required == 0 ) {
682
+ $mlw_requireClass = 'mlwRequiredText';
683
+ } else {
684
+ $mlw_requireClass = '';}
685
+ $limit_text_att = $limit_text ? "maxlength='" . $limit_text . "' " : '';
686
+ // $question_title = apply_filters('the_content', $question);
687
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'question_title' );
688
+ $question_display .= qsm_question_title_func( $question, '', $new_question_title );
689
+ $question_display .= "<textarea class='mlw_answer_open_text {$mlw_requireClass}' {$limit_text_att} cols='70' rows='5' name='question{$id}' /></textarea>";
690
+ return apply_filters( 'qmn_large_open_display_front', $question_display, $id, $question, $answers );
691
  }
692
 
693
  /**
694
+ * This function determines how the large open question is graded
695
+ *
696
+ * @params $id The ID of the multiple choice question
697
+ * @params $question The question that is being edited.
698
+ * @params @answers The array that contains the answers to the question.
699
+ * @return $return_array Returns the graded question to the results page
700
+ * @since 4.4.0
701
+ */
702
+ function qmn_large_open_review( $id, $question, $answers ) {
703
+ $return_array = array(
704
+ 'points' => 0,
705
+ 'correct' => 'incorrect',
706
+ 'user_text' => '',
707
+ 'correct_text' => '',
708
+ );
709
+ if ( isset( $_POST[ 'question' . $id ] ) ) {
710
+ $decode_user_answer = sanitize_textarea_field( strval( stripslashes( htmlspecialchars_decode( $_POST[ 'question' . $id ], ENT_QUOTES ) ) ) );
711
+ $mlw_user_answer = trim( $decode_user_answer );
712
+ } else {
713
+ $mlw_user_answer = ' ';
714
+ }
715
+ $return_array['user_text'] = $mlw_user_answer;
716
+ foreach ( $answers as $answer ) {
717
+ $decode_correct_text = strval( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) );
718
+ $return_array['correct_text'] = trim( $decode_correct_text );
719
+ if ( mb_strtoupper( $return_array['user_text'] ) == mb_strtoupper( $return_array['correct_text'] ) ) {
720
+ $return_array['correct'] = 'correct';
721
+ $return_array['points'] = $answer[1];
722
+ break;
723
+ }
724
+ }
725
+ return $return_array;
 
 
 
726
  }
727
 
728
+ add_action( 'plugins_loaded', 'qmn_question_type_text_block' );
729
 
730
  /**
731
+ * This function registers the text block question type
732
+ *
733
+ * @return void
734
+ * @since 4.4.0
735
+ */
736
+ function qmn_question_type_text_block() {
 
737
  global $mlwQuizMasterNext;
738
  $edit_args = array(
739
+ 'inputs' => array(
740
+ 'question',
741
  ),
742
+ 'information' => '',
743
  'extra_inputs' => array(),
744
+ 'function' => '',
745
  );
746
+ $mlwQuizMasterNext->pluginHelper->register_question_type( __( 'Text/HTML Section', 'quiz-master-next' ), 'qmn_text_block_display', false, null, $edit_args, null, 6 );
747
  }
748
 
749
 
750
  /**
751
+ * This function displays the contents of the text block question type.
752
+ *
753
+ * @params $id The ID of the multiple choice question
754
+ * @params $question The question that is being edited.
755
+ * @params @answers The array that contains the answers to the question.
756
+ * @return $question_display Contains all the content of the question
757
+ * @since 4.4.0
758
+ */
759
+ function qmn_text_block_display( $id, $question, $answers ) {
760
+ $question_display = '';
761
+ $question_display .= do_shortcode( htmlspecialchars_decode( $question, ENT_QUOTES ) );
762
+ return $question_display;
 
763
  }
764
 
765
+ add_action( 'plugins_loaded', 'qmn_question_type_number' );
766
 
767
  /**
768
+ * This function registers the number question type
769
+ *
770
+ * @params $id The ID of the multiple choice question
771
+ * @params $question The question that is being edited.
772
+ * @params @answers The array that contains the answers to the question.
773
+ * @return void
774
+ * @since 4.4.0
775
+ */
776
+ function qmn_question_type_number() {
 
777
  global $mlwQuizMasterNext;
778
+ $mlwQuizMasterNext->pluginHelper->register_question_type( __( 'Number', 'quiz-master-next' ), 'qmn_number_display', true, 'qmn_number_review', null, null, 7 );
779
  }
780
 
781
 
782
  /**
783
+ * This function shows the content of the multiple choice question.
784
+ *
785
+ * @params $id The ID of the multiple choice question
786
+ * @params $question The question that is being edited.
787
+ * @params @answers The array that contains the answers to the question.
788
+ * @return $question_display Contains all the content of the question
789
+ * @since 4.4.0
790
+ */
791
+ function qmn_number_display( $id, $question, $answers ) {
792
+ $question_display = '';
793
+ global $mlwQuizMasterNext;
794
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'required' );
795
+ $limit_text = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'limit_text' );
796
+ $limit_text_att = $limit_text ? "maxlength='" . $limit_text . "' oninput='javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);'" : '';
797
+ if ( $required == 0 ) {
798
+ $mlw_requireClass = 'mlwRequiredNumber';
799
+ } else {
800
+ $mlw_requireClass = '';}
801
+ // $question_title = apply_filters('the_content', $question);
802
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'question_title' );
803
+ $question_display .= qsm_question_title_func( $question, '', $new_question_title );
804
+ $question_display .= "<input type='number' $limit_text_att class='mlw_answer_number $mlw_requireClass' name='question" . $id . "' />";
805
+ return apply_filters( 'qmn_number_display_front', $question_display, $id, $question, $answers );
806
  }
807
 
808
 
809
  /**
810
+ * This function determines how the number question type is graded.
811
+ *
812
+ * @params $id The ID of the multiple choice question
813
+ * @params $question The question that is being edited.
814
+ * @params @answers The array that contains the answers to the question.
815
+ * @return $return_array Returns the graded question to the results page
816
+ * @since 4.4.0
817
+ */
818
+ function qmn_number_review( $id, $question, $answers ) {
819
+ $return_array = array(
820
+ 'points' => 0,
821
+ 'correct' => 'incorrect',
822
+ 'user_text' => '',
823
+ 'correct_text' => '',
824
+ );
825
+ if ( isset( $_POST[ 'question' . $id ] ) ) {
826
+ $mlw_user_answer = sanitize_textarea_field( strval( stripslashes( htmlspecialchars_decode( $_POST[ 'question' . $id ], ENT_QUOTES ) ) ) );
827
+ } else {
828
+ $mlw_user_answer = ' ';
829
+ }
830
+ $return_array['user_text'] = $mlw_user_answer;
831
+ foreach ( $answers as $answer ) {
832
+ $return_array['correct_text'] = strval( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) );
833
+ if ( strtoupper( $return_array['user_text'] ) == strtoupper( $return_array['correct_text'] ) ) {
834
+ $return_array['correct'] = 'correct';
835
+ $return_array['points'] = $answer[1];
836
+ break;
837
+ }
838
+ }
839
+ return $return_array;
 
 
 
840
  }
841
 
842
+ add_action( 'plugins_loaded', 'qmn_question_type_accept' );
843
 
844
  /**
845
+ * This function registers the accept question type.
846
+ *
847
+ * @return void Description
848
+ * @since 4.4.0
849
+ */
850
+ function qmn_question_type_accept() {
 
851
  global $mlwQuizMasterNext;
852
  $edit_args = array(
853
+ 'inputs' => array(
854
  'question',
855
+ 'required',
856
  ),
857
+ 'information' => '',
858
  'extra_inputs' => array(),
859
+ 'function' => '',
860
  );
861
+ $mlwQuizMasterNext->pluginHelper->register_question_type( __( 'Opt-in', 'quiz-master-next' ), 'qmn_accept_display', false, null, $edit_args, null, 8 );
862
  }
863
 
864
  /**
865
+ * This function displays the accept question
866
+ *
867
+ * @params $id The ID of the multiple choice question
868
+ * @params $question The question that is being edited.
869
+ * @params @answers The array that contains the answers to the question.
870
+ * @return $question_display Contains all the content of the question
871
+ * @since 4.4.0
872
+ */
873
+ function qmn_accept_display( $id, $question, $answers ) {
874
+ $question_display = '';
875
+ global $mlwQuizMasterNext;
876
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'required' );
877
+ if ( $required == 0 ) {
878
+ $mlw_requireClass = 'mlwRequiredAccept';
879
+ } else {
880
+ $mlw_requireClass = '';}
881
  $question_display .= "<div class='qmn_accept_answers'>";
882
+ $question_display .= "<input type='checkbox' id='mlwAcceptance' class='$mlw_requireClass ' />";
883
+ $question_display .= "<label for='mlwAcceptance'><span class='qmn_accept_text'>" . do_shortcode( htmlspecialchars_decode( $question, ENT_QUOTES ) ) . '</span></label>';
884
+ $question_display .= '</div>';
885
+ return apply_filters( 'qmn_accept_display_front', $question_display, $id, $question, $answers );
886
  }
887
 
888
+ add_action( 'plugins_loaded', 'qmn_question_type_captcha' );
889
 
890
  /**
891
+ * This function registers the captcha question
892
+ *
893
+ * @since 4.4.0
894
+ */
895
+ function qmn_question_type_captcha() {
 
 
896
  global $mlwQuizMasterNext;
897
  $edit_args = array(
898
+ 'inputs' => array(
899
  'question',
900
+ 'required',
901
  ),
902
+ 'information' => '',
903
  'extra_inputs' => array(),
904
+ 'function' => '',
905
  );
906
+ $mlwQuizMasterNext->pluginHelper->register_question_type( __( 'Captcha', 'quiz-master-next' ), 'qmn_captcha_display', false, null, $edit_args, null, 9 );
907
  }
908
 
909
 
910
  /**
911
+ * This function displays the captcha question
912
+ *
913
+ * @params $id The ID of the multiple choice question
914
+ * @params $question The question that is being edited.
915
+ * @params @answers The array that contains the answers to the question.
916
+ * @return $question_display Contains all the content of the question
917
+ * @since 4.4.0
918
+ */
919
+ function qmn_captcha_display( $id, $question, $answers ) {
920
+ $question_display = '';
921
+ global $mlwQuizMasterNext;
922
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'required' );
923
+ if ( $required == 0 ) {
924
+ $mlw_requireClass = 'mlwRequiredCaptcha';
925
+ } else {
926
+ $mlw_requireClass = '';}
927
+ $question_display .= "<div class='mlw_captchaWrap'>";
928
+ $question_display .= "<canvas alt='' id='mlw_captcha' class='mlw_captcha' width='100' height='50'></canvas>";
929
+ $question_display .= '</div>';
930
+ $question_display .= "<span class='mlw_qmn_question'>";
931
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'question_title' );
932
+ $question_title = qsm_question_title_func( $question, '', $new_question_title );
933
+ $question_display .= $question_title . '</span>';
934
+ $question_display .= "<input type='text' class='mlw_answer_open_text $mlw_requireClass' id='mlw_captcha_text' name='mlw_user_captcha'/>";
935
+ $question_display .= "<input type='hidden' name='mlw_code_captcha' id='mlw_code_captcha' value='none' />";
936
+ $question_display .= "<script>
937
  var mlw_code = '';
938
  var mlw_chars = '0123456789ABCDEFGHIJKL!@#$%^&*()MNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
939
  var mlw_code_length = 5;
949
  mlw_captchaCTX.textBaseline = 'middle';
950
  document.getElementById('mlw_code_captcha').value = mlw_code;
951
  </script>
952
+ ";
953
+ return apply_filters( 'qmn_captcha_display_front', $question_display, $id, $question, $answers );
954
  }
955
 
956
+ add_action( 'plugins_loaded', 'qmn_question_type_horizontal_multiple_response' );
957
 
958
  /**
959
+ * This function registers the horizontal multiple response question
960
+ *
961
+ * @return void
962
+ * @since 4.4.0
963
+ */
964
+ function qmn_question_type_horizontal_multiple_response() {
965
+ global $mlwQuizMasterNext;
966
+ $mlwQuizMasterNext->pluginHelper->register_question_type( __( 'Horizontal Multiple Response', 'quiz-master-next' ), 'qmn_horizontal_multiple_response_display', true, 'qmn_horizontal_multiple_response_review', null, null, 10 );
 
967
  }
968
 
969
 
970
  /**
971
+ * This function displays the content of the multiple response question type
972
+ *
973
+ * @params $id The ID of the multiple choice question
974
+ * @params $question The question that is being edited.
975
+ * @params @answers The array that contains the answers to the question.
976
+ * @return $question_display Contains all the content of the question
977
+ * @since 4.4.0
978
+ */
979
+ function qmn_horizontal_multiple_response_display( $id, $question, $answers ) {
980
+ $question_display = '';
981
+ global $mlwQuizMasterNext;
982
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'required' );
983
+ if ( $required == 0 ) {
984
+ $mlw_requireClass = 'mlwRequiredCheck';
985
+ } else {
986
+ $mlw_requireClass = '';}
987
+ // $question_title = apply_filters('the_content', $question);
988
+ $limit_multiple_response = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'limit_multiple_response' );
989
+ $limit_mr_text = '';
990
+ if ( $limit_multiple_response > 0 ) {
991
+ $limit_mr_text = 'onchange="qsmCheckMR(this,' . $limit_multiple_response . ')"';
992
+ }
993
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'question_title' );
994
+ $question_display .= qsm_question_title_func( $question, '', $new_question_title );
995
+ $question_display .= "<div class='qmn_check_answers $mlw_requireClass'>";
996
+ if ( is_array( $answers ) ) {
997
+ $mlw_answer_total = 0;
998
+ foreach ( $answers as $answer ) {
999
+ $mlw_answer_total++;
1000
+ if ( $answer[0] != '' ) {
1001
+ $question_display .= "<input type='hidden' name='question" . $id . "' value='This value does not matter' />";
1002
+ $question_display .= "<span class='mlw_horizontal_multiple'><input type='checkbox' " . $limit_mr_text . " name='question" . $id . '_' . $mlw_answer_total . "' id='question" . $id . '_' . $mlw_answer_total . "' value='" . esc_attr( $answer[0] ) . "' /> <label for='question" . $id . '_' . $mlw_answer_total . "'>" . trim( do_shortcode( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) ) ) . '&nbsp;</label></span>';
1003
+ }
1004
+ }
1005
+ }
1006
+ $question_display .= '</div>';
1007
+ return apply_filters( 'qmn_horizontal_multiple_response_display_front', $question_display, $id, $question, $answers );
1008
  }
1009
 
1010
 
1011
  /**
1012
+ * This function determines how the multiple response is graded.
1013
+ *
1014
+ * @params $id The ID of the multiple choice question
1015
+ * @params $question The question that is being edited.
1016
+ * @params @answers The array that contains the answers to the question.
1017
+ * @return $return_array Returns the graded question to the Results page
1018
+ * @since 4.4.0
1019
+ */
1020
+ function qmn_horizontal_multiple_response_review( $id, $question, $answers ) {
1021
+ $return_array = array(
1022
+ 'points' => 0,
1023
+ 'correct' => 'incorrect',
1024
+ 'user_text' => '',
1025
+ 'correct_text' => '',
1026
+ 'user_compare_text' => '',
1027
  );
1028
+ $user_correct = 0;
1029
  $total_correct = 0;
1030
+ $total_answers = count( $answers );
1031
+ $correct_text = array();
1032
+ foreach ( $answers as $answer ) {
1033
+ for ( $i = 1; $i <= $total_answers; $i++ ) {
1034
+ if ( isset( $_POST[ 'question' . $id . '_' . $i ] ) && sanitize_textarea_field( htmlspecialchars( stripslashes( $_POST[ 'question' . $id . '_' . $i ] ), ENT_QUOTES ) ) == esc_attr( $answer[0] ) ) {
1035
+ $return_array['points'] += $answer[1];
1036
+ $return_array['user_text'] .= strval( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) ) . '.';
1037
+ $return_array['user_compare_text'] .= sanitize_textarea_field( strval( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) ) ) . '=====';
1038
+ if ( $answer[2] == 1 ) {
1039
  $user_correct += 1;
1040
  } else {
1041
  $user_correct = -1;
1042
  }
1043
  }
1044
  }
1045
+ if ( $answer[2] == 1 ) {
1046
+ $correct_text[] = stripslashes( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) );
1047
  $total_correct++;
1048
  }
1049
  }
1050
+ if ( $user_correct == $total_correct ) {
1051
+ $return_array['correct'] = 'correct';
1052
  }
1053
+ $return_array['correct_text'] = implode( '.', $correct_text );
1054
  return $return_array;
1055
  }
1056
 
1057
+ add_action( 'plugins_loaded', 'qmn_question_type_fill_blank' );
1058
 
1059
  /**
1060
+ * This function registers the fill in the blank question type
1061
+ *
1062
+ * @return void
1063
+ * @since 4.4.0
1064
+ */
1065
+ function qmn_question_type_fill_blank() {
 
1066
  global $mlwQuizMasterNext;
1067
  $edit_args = array(
1068
+ 'inputs' => array(
1069
  'question',
1070
  'answer',
1071
  'hint',
1072
  'correct_info',
1073
  'comments',
1074
  'category',
1075
+ 'required',
1076
  ),
1077
+ 'information' => __( 'For fill in the blank types, use %BLANK% to represent where to put the text box in your text.', 'quiz-master-next' ),
1078
  'extra_inputs' => array(),
1079
+ 'function' => '',
1080
  );
1081
 
1082
+ $mlwQuizMasterNext->pluginHelper->register_question_type( __( 'Fill In The Blank', 'quiz-master-next' ), 'qmn_fill_blank_display', true, 'qmn_fill_blank_review', $edit_args, null, 14 );
 
1083
 
1084
  }
1085
 
1086
 
1087
  /**
1088
+ * This function displays the fill in the blank question
1089
+ *
1090
+ * @params $id The ID of the multiple choice question
1091
+ * @params $question The question that is being edited.
1092
+ * @params @answers The array that contains the answers to the question.
1093
+ * @return $question_display Returns the content of the question
1094
+ * @since 4.4.0
1095
+ */
1096
+ function qmn_fill_blank_display( $id, $question, $answers ) {
1097
+ $question_display = '';
1098
+ global $mlwQuizMasterNext;
1099
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'required' );
1100
+ $autofill = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'autofill' );
1101
+ $limit_text = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'limit_text' );
1102
+ $autofill_att = $autofill ? "autocomplete='off' " : '';
1103
+ $limit_text_att = $limit_text ? "maxlength='" . $limit_text . "' " : '';
1104
+ if ( $required == 0 ) {
1105
+ $mlw_requireClass = 'mlwRequiredText';
1106
+ } else {
1107
+ $mlw_requireClass = '';}
1108
+ $input_text = '<input ' . $autofill_att . $limit_text_att . " type='text' class='qmn_fill_blank $mlw_requireClass' name='question" . $id . "' />";
1109
+ if ( strpos( $question, '%BLANK%' ) !== false ) {
1110
+ $question = str_replace( '%BLANK%', $input_text, do_shortcode( htmlspecialchars_decode( $question, ENT_QUOTES ) ) );
1111
  }
1112
+ // $question_title = apply_filters('the_content', $question);
1113
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'question_title' );
1114
+ $question_display .= qsm_question_title_func( $question, '', $new_question_title );
1115
+ return apply_filters( 'qmn_fill_blank_display_front', $question_display, $id, $question, $answers );
1116
  }
1117
 
1118
 
1119
  /**
1120
+ * This function determines how the fill in the blank question is graded.
1121
+ *
1122
+ * @params $id The ID of the multiple choice question
1123
+ * @params $question The question that is being edited.
1124
+ * @params @answers The array that contains the answers to the question.
1125
+ * @return $return_array Returns the graded question to the results page
1126
+ * @since 4.4.0
1127
+ */
1128
+ function qmn_fill_blank_review( $id, $question, $answers ) {
1129
+ $return_array = array(
1130
+ 'points' => 0,
1131
+ 'correct' => 'incorrect',
1132
+ 'user_text' => '',
1133
+ 'correct_text' => '',
1134
+ );
1135
+ if ( strpos( $question, '%BLANK%' ) !== false || strpos( $question, '%blank%' ) !== false ) {
1136
+ $return_array['question_text'] = str_replace( array( '%BLANK%', '%blank%' ), array( '__________', '__________' ), do_shortcode( htmlspecialchars_decode( $question, ENT_QUOTES ) ) );
1137
+ }
1138
+ if ( isset( $_POST[ 'question' . $id ] ) ) {
1139
+ $decode_user_answer = sanitize_textarea_field( strval( stripslashes( htmlspecialchars_decode( $_POST[ 'question' . $id ], ENT_QUOTES ) ) ) );
1140
+ $mlw_user_answer = trim( preg_replace( '/\s\s+/', ' ', str_replace( "\n", ' ', $decode_user_answer ) ) );
1141
+ } else {
1142
+ $mlw_user_answer = ' ';
1143
+ }
1144
+ $return_array['user_text'] = $mlw_user_answer;
1145
+ foreach ( $answers as $answer ) {
1146
+ $decode_correct_text = strval( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) );
1147
+ $return_array['correct_text'] = trim( preg_replace( '/\s\s+/', ' ', str_replace( "\n", ' ', $decode_correct_text ) ) );
1148
+ if ( mb_strtoupper( $return_array['user_text'] ) == mb_strtoupper( $return_array['correct_text'] ) ) {
1149
+ $return_array['correct'] = 'correct';
1150
+ $return_array['points'] = $answer[1];
1151
+ break;
1152
+ }
1153
  }
1154
+ return $return_array;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1155
  }
1156
 
1157
 
1158
+ // Start polar question
1159
+ add_action( 'plugins_loaded', 'qmn_question_type_polar' );
1160
 
1161
  /**
1162
  * This function registers the fill in the blank question type
1165
  * @since 6.4.1
1166
  */
1167
  function qmn_question_type_polar() {
1168
+ global $mlwQuizMasterNext;
1169
+ $mlwQuizMasterNext->pluginHelper->register_question_type( __( 'Polar', 'quiz-master-next' ), 'qmn_polar_display', true, 'qmn_polar_review', null, null, 13 );
1170
  }
1171
 
1172
  /**
1178
  * @return $question_display Returns the content of the question
1179
  * @since 6.4.1
1180
  */
1181
+ function qmn_polar_display( $id, $question, $answers ) {
1182
+ $question_display = '';
1183
+ global $mlwQuizMasterNext;
1184
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'required' );
1185
+ $autofill = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'autofill' );
1186
+ $limit_text = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'limit_text' );
1187
+ $autofill_att = $autofill ? "autocomplete='off' " : '';
1188
+ $limit_text_att = $limit_text ? "maxlength='" . $limit_text . "' " : '';
1189
+ $input_text = '';
1190
+ $first_point = isset( $answers[0][1] ) ? $answers[0][1] : 0;
1191
+ $second_point = isset( $answers[1][1] ) ? $answers[1][1] : 0;
1192
+ $is_reverse = false;
1193
+ $check_point = $second_point;
1194
+ $font_weight_lc = 'right-polar-title';
1195
+ $font_weight_rc = 'left-polar-title';
1196
+ if ( $first_point > $second_point ) {
1197
+ $is_reverse = true;
1198
+ $check_point = $first_point;
1199
+ $font_weight_lc = 'left-polar-title';
1200
+ $font_weight_rc = 'right-polar-title';
1201
+ }
1202
+ $total_answer = count( $answers );
1203
+ ?>
1204
+ <script type="text/javascript">
1205
+ (function($) {
1206
+ $(document).ready(function() {
1207
+ $('#slider-' + '<?php echo $id; ?>').slider({
1208
+ <?php if ( $total_answer == 2 && $is_reverse ) { ?>
1209
+ max: <?php echo $answers[0][1]; ?>,
1210
+ min: <?php echo $answers[1][1]; ?>,
1211
+ isRTL: true,
1212
+ <?php } else { ?>
1213
+ min: <?php echo $answers[0][1]; ?>,
1214
+ max: <?php echo $answers[1][1]; ?>,
1215
+ <?php } ?>
1216
+ step: 1,
1217
+ value: <?php echo $check_point / 2; ?>,
1218
+ change: function( event, ui ) {
1219
+ $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.qmn_polar').val(ui.value);
1220
+ if(ui.value == <?php echo $answers[0][1]; ?>){
1221
+ $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.left-polar-title').css('font-weight','900');
1222
+ $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.right-polar-title').css('font-weight','100');
1223
+ } else if(ui.value == <?php echo $answers[1][1]; ?>){
1224
+ $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.left-polar-title').css('font-weight','100');
1225
+ $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.right-polar-title').css('font-weight','900');
1226
+ } else if(ui.value == <?php echo $check_point / 2; ?>){
1227
+ $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.left-polar-title').css('font-weight','400');
1228
+ $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.right-polar-title').css('font-weight','400');
1229
+ } else if(ui.value > <?php echo $check_point / 2; ?>){
1230
+ $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.<?php echo $font_weight_rc; ?>').css('font-weight','400');
1231
+ $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.<?php echo $font_weight_lc; ?>').css('font-weight','600');
1232
+ } else if(ui.value < <?php echo $check_point / 2; ?>){
1233
+ $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.<?php echo $font_weight_rc; ?>').css('font-weight','600');
1234
+ $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.<?php echo $font_weight_lc; ?>').css('font-weight','400');
1235
+ }
1236
+ },
1237
+ create: function( event, ui ) {
1238
+ $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.left-polar-title').css('font-weight','400');
1239
+ $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.right-polar-title').css('font-weight','400');
1240
+ $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').find('.qmn_polar').val(<?php echo $check_point / 2; ?>);
1241
+ }
1242
+ });
1243
+ var maxHeight = Math.max.apply(null, $(".question-section-id-<?php echo $id; ?> .question-type-polar-s > div").map(function (){
1244
+ return $(this).height();
1245
+ }).get());
1246
+ $('.question-section-id-<?php echo $id; ?> .question-type-polar-s').height(maxHeight);
1247
+ });
1248
+ })(jQuery);
1249
+ </script>
1250
+ <?php
1251
+ if ( $required == 0 ) {
1252
+ $mlw_requireClass = 'mlwRequiredText';
1253
+ } else {
1254
+ $mlw_requireClass = '';
1255
+ }
1256
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'question_title' );
1257
+ $question_title = qsm_question_title_func( $question, '', $new_question_title );
1258
+ // $question_title = "<div class='mlw_qmn_question polar-question-title'>". do_shortcode(htmlspecialchars_decode($question, ENT_QUOTES)) ."</div>";
1259
+ $input_text .= "<div class='left-polar-title'>" . $answers[0][0] . '</div>';
1260
+ $input_text .= "<div class='slider-main-wrapper'><input type='hidden' class='qmn_polar $mlw_requireClass' id='question" . $id . "' name='question" . $id . "' />";
1261
+ $input_text .= '<div id="slider-' . $id . '"></div></div>';
1262
+ $input_text .= "<div class='right-polar-title'>" . $answers[1][0] . '</div>';
1263
+ /*
1264
+ if (strpos($question, '%POLAR_SLIDER%') !== false) {
1265
+ $question = str_replace("%POLAR_SLIDER%", $input_text, do_shortcode(htmlspecialchars_decode($question, ENT_QUOTES)));
1266
+ }*/
1267
+ $question = $input_text;
1268
+ // $question_title = apply_filters('the_content', $question);
1269
+ $question_display .= $question_title . "<span class='mlw_qmn_question question-type-polar-s'>" . do_shortcode( htmlspecialchars_decode( $question, ENT_QUOTES ) ) . '</span>';
1270
+
1271
+ return apply_filters( 'qmn_polar_display_front', $question_display, $id, $question, $answers );
1272
  }
1273
 
1274
  /**
1280
  * @return $return_array Returns the graded question to the results page
1281
  * @since 6.4.1
1282
  */
1283
+ function qmn_polar_review( $id, $question, $answers ) {
1284
+ $return_array = array(
1285
+ 'points' => 0,
1286
+ 'correct' => 'incorrect',
1287
+ 'user_text' => '',
1288
+ 'correct_text' => '',
1289
+ );
1290
+ if ( strpos( $question, '%POLAR_SLIDER%' ) !== false || strpos( $question, '%polar_slider%' ) !== false ) {
1291
+ $return_array['question_text'] = str_replace( array( '%POLAR_SLIDER%', '%polar_slider%' ), array( '__________', '__________' ), do_shortcode( htmlspecialchars_decode( $question, ENT_QUOTES ) ) );
1292
+ }
1293
+ if ( isset( $_POST[ 'question' . $id ] ) ) {
1294
+ $decode_user_answer = sanitize_textarea_field( $_POST[ 'question' . $id ] );
1295
+ $mlw_user_answer = trim( preg_replace( '/\s\s+/', ' ', str_replace( "\n", ' ', $decode_user_answer ) ) );
1296
+ } else {
1297
+ $mlw_user_answer = ' ';
1298
+ }
1299
+ $return_array['user_text'] = $mlw_user_answer;
1300
+ $return_array['points'] = $mlw_user_answer;
1301
+ foreach ( $answers as $answer ) {
1302
+ $decode_correct_text = $answer[1];
1303
+ $return_array['correct_text'] = trim( preg_replace( '/\s\s+/', ' ', str_replace( "\n", ' ', $decode_correct_text ) ) );
1304
+ if ( $return_array['user_text'] == trim( $decode_correct_text ) && isset( $answer[2] ) && $answer[2] == 1 ) {
1305
+ $return_array['correct'] = 'correct';
1306
+ break;
1307
+ }
1308
+ }
1309
+ return $return_array;
1310
  }
1311
 
1312
+ function qsm_question_title_func( $question, $question_type = '', $new_question_title = '' ) {
1313
+ // $question_title = apply_filters('the_content', $question);
1314
+ $question_title = $question;
1315
+ global $wp_embed,$mlwQuizMasterNext;
1316
+ $question_title = $wp_embed->run_shortcode( $question_title );
1317
+ $question_title = 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>', $question_title );
1318
+ $polar_extra_class = '';
1319
+ $question_display = '';
1320
+ if ( $question_type == 'polar' ) {
1321
+ $polar_extra_class = 'question-type-polar-s';
1322
+ }
1323
+ $qmn_quiz_options = $mlwQuizMasterNext->quiz_settings->get_quiz_options();
1324
+ $deselect_answer = '';
1325
+ if ( isset( $qmn_quiz_options->enable_deselect_option ) && $qmn_quiz_options->enable_deselect_option == 1 && ( $question_type == 'multiple_choice' || $question_type == 'horizontal_multiple_choice' ) ) {
1326
+ $deselect_answer = '<a href="#" class="qsm-deselect-answer">Deselect Answer</a>';
1327
+ }
1328
+
1329
+ if ( $new_question_title != '' ) {
1330
+ $question_display .= "<span class='mlw_qmn_new_question'>" . sanitize_text_field( htmlspecialchars_decode( $new_question_title, ENT_QUOTES ) ) . '</span>';
1331
+ $polar_extra_class .= ' qsm_remove_bold';
1332
+ }
1333
+ $question_display .= "<span class='mlw_qmn_question {$polar_extra_class}' >" . htmlspecialchars_decode( do_shortcode( $question_title ), ENT_QUOTES ) . $deselect_answer . '</span>';
1334
+ return $question_display;
1335
  }
1336
  ?>
php/rest-api.php CHANGED
@@ -88,7 +88,7 @@ function qsm_register_rest_routes() {
88
  function qsm_rest_get_bank_questions( WP_REST_Request $request ){
89
  if(is_user_logged_in()){
90
  global $wpdb;
91
- $category = isset($_REQUEST['category']) ? $_REQUEST['category'] : '';
92
  $category_query = '';
93
  if($category){
94
  $category_query = ' AND category = "' . $category . '"';
88
  function qsm_rest_get_bank_questions( WP_REST_Request $request ){
89
  if(is_user_logged_in()){
90
  global $wpdb;
91
+ $category = isset($_REQUEST['category']) ? sanitize_text_field( $_REQUEST['category'] ) : '';
92
  $category_query = '';
93
  if($category){
94
  $category_query = ' AND category = "' . $category . '"';
php/template-variables.php CHANGED
@@ -100,7 +100,7 @@ function qsm_variable_single_question_answer( $content, $mlw_quiz_array ){
100
  $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%' );
101
  }else{
102
  $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%' );
103
- }
104
  } else {
105
  if( isset( $mlw_quiz_array['quiz_settings'] ) && !empty($mlw_quiz_array['quiz_settings']) ){
106
  $quiz_text_settings = isset( $mlw_quiz_array['quiz_settings']['quiz_text'] ) ? @unserialize( stripslashes( $mlw_quiz_array['quiz_settings']['quiz_text'] ) ) : array();
@@ -108,13 +108,13 @@ function qsm_variable_single_question_answer( $content, $mlw_quiz_array ){
108
  }else{
109
  $qmn_question_answer_template = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_template', '%QUESTION%<br/>%USER_ANSWERS_DEFAULT%' );
110
  }
111
- }
112
  $mlw_question_answer_display = htmlspecialchars_decode($qmn_question_answer_template, ENT_QUOTES);
113
  $questions = QSM_Questions::load_questions_by_pages( $mlw_quiz_array['quiz_id'] );
114
  $qmn_questions = array();
115
  foreach ( $questions as $question ) {
116
  $qmn_questions[ $question['question_id'] ] = $question['question_answer_info'];
117
- }
118
  $total_question_cnt = 2;
119
  $qsm_question_cnt = 1;
120
  $display = qsm_questions_answers_shortcode_to_text($mlw_quiz_array, $mlw_question_answer_display, $questions, $qmn_questions, $answer, $qsm_question_cnt, $total_question_cnt);
@@ -126,14 +126,14 @@ function qsm_variable_single_question_answer( $content, $mlw_quiz_array ){
126
 
127
  /**
128
  * Replace total_possible_points variable with actual points
129
- *
130
  * @since 7.0.2
131
- *
132
  * @param string $content
133
  * @param array $mlw_quiz_array
134
  * @return string $content
135
  */
136
- function qsm_variable_total_possible_points( $content, $mlw_quiz_array ){
137
  if( isset( $mlw_quiz_array["total_possible_points"] ) ){
138
  $content = str_replace( "%MAXIMUM_POINTS%" , $mlw_quiz_array["total_possible_points"], $content);
139
  }
@@ -142,16 +142,16 @@ function qsm_variable_total_possible_points( $content, $mlw_quiz_array ){
142
 
143
  /**
144
  * Replace total_possible_points variable with actual points
145
- *
146
  * @since 7.0.2
147
- *
148
  * @param string $content
149
  * @param array $mlw_quiz_array
150
  * @return string $content
151
  */
152
- function qsm_variable_total_attempted_questions( $content, $mlw_quiz_array ){
153
  $total_attempted_questions = isset( $mlw_quiz_array["total_attempted_questions"] ) ? $mlw_quiz_array["total_attempted_questions"] : 0;
154
- $content = str_replace( "%AMOUNT_ATTEMPTED%" , $total_attempted_questions, $content);
155
  return $content;
156
  }
157
 
@@ -214,14 +214,14 @@ function mlw_qmn_get_string_between($string, $start, $end){
214
  }
215
 
216
  function qsm_find_key_from_array($search_value,$array){
217
- if($array){
218
  $search_value = htmlspecialchars_decode( $search_value, ENT_QUOTES );
219
- foreach ($array as $key => $value) {
220
  $value_val = $value[0];
221
  if( $value_val == $search_value ){
222
  return true;
223
  }
224
- }
225
  }
226
  return false;
227
  }
@@ -278,12 +278,12 @@ function mlw_qmn_variable_point_score($content, $mlw_quiz_array)
278
  return $content;
279
  }
280
  function mlw_qmn_variable_average_point($content, $mlw_quiz_array){
281
- $question_total = 0;
282
  if( isset( $mlw_quiz_array['question_answers_array'] ) ){
283
  foreach( $mlw_quiz_array['question_answers_array'] as $single_question ){
284
- if( $single_question['question_type'] !== '11' ){
285
  $question_total++;
286
- }
287
  }
288
  }
289
  if (isset($mlw_quiz_array['total_questions']) && $mlw_quiz_array["total_questions"] != 0 && $question_total != 0){
@@ -307,7 +307,7 @@ function mlw_qmn_variable_amount_correct($content, $mlw_quiz_array) {
307
 
308
  /**
309
  * Return total incorrect amount
310
- *
311
  * @since 7.0.3
312
  * @param string $content
313
  * @param array $mlw_quiz_array
@@ -374,8 +374,8 @@ function mlw_qmn_variable_current_user($content, $mlw_quiz_array) {
374
  * @return string
375
  */
376
  function mlw_qmn_variable_user_full_name($content, $mlw_quiz_array) {
377
- if (false !== strpos($content, '%FULL_NAME%')) {
378
- $current_user = wp_get_current_user();
379
  $firstname = get_user_meta( $current_user->ID, 'first_name', true );
380
  $lastname = get_user_meta( $current_user->ID, 'last_name', true );
381
  if(!empty($firstname) && !empty($lastname))
@@ -596,7 +596,7 @@ function qmn_variable_average_category_points( $content, $mlw_quiz_array ) {
596
  }
597
  foreach ( $mlw_quiz_array['question_answers_array'] as $answer ) {
598
  if ( $answer["category"] == $category_name ) {
599
- if( $answer['question_type'] !== '11' ){
600
  $total_questions += 1;
601
  }
602
  $return_points += $answer["points"];
@@ -773,7 +773,7 @@ function qmn_variable_category_average_points($content, $mlw_quiz_array)
773
 
774
  add_filter('qmn_end_results', 'qsm_end_results_rank', 9999, 3);
775
  function qsm_end_results_rank($result_display, $qmn_quiz_options, $qmn_array_for_variables)
776
- {
777
  while (strpos($result_display, '%RANK%') !== false){
778
  global $wpdb;
779
  $mlw_quiz_id = $qmn_array_for_variables['quiz_id'];
@@ -848,9 +848,9 @@ add_filter( 'wp_kses_allowed_html', 'qsm_custom_wpkses_post_tags', 10, 2 );
848
 
849
  /**
850
  * Function will convert all the QUESIONS_ANSWERS variable into appropriate data
851
- *
852
  * @since 7.1.3
853
- *
854
  * @param arr $mlw_quiz_array
855
  * @param str $qmn_question_answer_template
856
  * @param str $answer
@@ -858,7 +858,7 @@ add_filter( 'wp_kses_allowed_html', 'qsm_custom_wpkses_post_tags', 10, 2 );
858
  * @param int $total_question_cnt
859
  * @return string
860
  */
861
- function qsm_questions_answers_shortcode_to_text($mlw_quiz_array, $qmn_question_answer_template, $questions, $qmn_questions, $answer, $qsm_question_cnt, $total_question_cnt) {
862
  global $mlwQuizMasterNext;
863
  if (is_admin() && isset($_GET['page']) && $_GET['page'] == 'qsm_quiz_result_details') {
864
  $user_answer_class = "";
@@ -883,11 +883,12 @@ function qsm_questions_answers_shortcode_to_text($mlw_quiz_array, $qmn_question_
883
  $question_answer_class = "qmn_question_answer_incorrect";
884
  }
885
  }
886
-
887
  $mlw_question_answer_display = htmlspecialchars_decode($qmn_question_answer_template, ENT_QUOTES);
888
  $disable_description_on_result = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_options', 'disable_description_on_result');
889
-
890
- if (isset($answer['question_title']) && $answer['question_title'] != '') {
 
891
  $add_br = '';
892
  if ($answer[0] != '') {
893
  $add_br = '<br/>';
@@ -896,11 +897,11 @@ function qsm_questions_answers_shortcode_to_text($mlw_quiz_array, $qmn_question_
896
  $mlw_question_answer_display = str_replace("%QUESTION%", '<b>' . htmlspecialchars_decode($answer['question_title'], ENT_QUOTES) . '</b>', $mlw_question_answer_display);
897
  } else {
898
  $mlw_question_answer_display = str_replace("%QUESTION%", '<b>' . htmlspecialchars_decode($answer['question_title'], ENT_QUOTES) . '</b>' . $add_br . htmlspecialchars_decode($answer[0], ENT_QUOTES), $mlw_question_answer_display);
899
- }
900
- } else {
901
  $mlw_question_answer_display = str_replace("%QUESTION%", '<b>' . htmlspecialchars_decode($answer[0], ENT_QUOTES) . '</b>', $mlw_question_answer_display);
902
- }
903
- $mlw_question_answer_display = qsm_question_title_func($mlw_question_answer_display);
904
  $extra_border_bottom_class = '';
905
  $remove_border = true;
906
  if (strpos($mlw_question_answer_display, '%USER_ANSWERS_DEFAULT%') !== false) {
@@ -911,11 +912,11 @@ function qsm_questions_answers_shortcode_to_text($mlw_quiz_array, $qmn_question_
911
  3, 12, 5, 7, 14
912
  );
913
  $form_type = isset($mlw_quiz_array['form_type']) ? $mlw_quiz_array['form_type'] : 0;
914
- $quiz_system = isset($mlw_quiz_array['quiz_system']) ? $mlw_quiz_array['quiz_system'] : 0;
915
- if (isset($answer['id']) && isset($questions[$answer['id']]) && !empty($questions[$answer['id']])) {
916
- $total_answers = isset($questions[$answer['id']]['answers']) ? $questions[$answer['id']]['answers'] : array();
917
  if ($total_answers) {
918
- if (isset($answer['question_type']) && in_array($answer['question_type'], $show_two_option_questions)) {
919
  $do_show_wrong = true;
920
  foreach ($total_answers as $single_answer) {
921
  $current_answer_zero = trim( htmlspecialchars_decode($single_answer[0], ENT_QUOTES) );
@@ -955,7 +956,7 @@ function qsm_questions_answers_shortcode_to_text($mlw_quiz_array, $qmn_question_
955
  }
956
  } else {
957
  if ($form_type == 0 && ( $quiz_system == 0 || $quiz_system == 3 )) {
958
- if (isset($answer['question_type']) && ( $answer['question_type'] == 4 || $answer['question_type'] == 10 )) {
959
  $user_selected_answer = htmlspecialchars_decode($answer[1], ENT_QUOTES);
960
  $new_array_user_answer = isset( $answer['user_compare_text'] ) ? explode('=====', $answer['user_compare_text']) : array();
961
  foreach ($total_answers as $single_answer) {
@@ -967,7 +968,7 @@ function qsm_questions_answers_shortcode_to_text($mlw_quiz_array, $qmn_question_
967
  if( $current_answer_text == $new_array_value ){
968
  $is_answer_correct = true;
969
  break;
970
- }
971
  }
972
  }
973
  if (isset($single_answer[2]) && $single_answer[2] == 1 && $is_answer_correct ) {
@@ -982,15 +983,28 @@ function qsm_questions_answers_shortcode_to_text($mlw_quiz_array, $qmn_question_
982
  }
983
  } else {
984
  if($answer['question_type'] == 13)
985
- {
986
  $questionid = $questions[$answer['id']]['question_id'];
987
- $question_with_answer_text .= qmn_polar_display_on_resultspage($questionid, $questions, $total_answers,$answer);
988
  }
989
- else
990
- {
991
- foreach ($total_answers as $single_answer) {
992
  $single_answer_option = $single_answer[0];
993
- if (isset($single_answer[2]) && $single_answer[2] == 1 && htmlspecialchars_decode($answer[1], ENT_QUOTES) == $single_answer_option ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
994
  $question_with_answer_text .= '<span class="qsm-text-correct-option qsm-text-user-correct-answer">' . htmlspecialchars_decode($single_answer[0], ENT_QUOTES) . '</span>';
995
  } else if (isset($single_answer[2]) && $single_answer[2] == 1) {
996
  $question_with_answer_text .= '<span class="qsm-text-correct-option">' . htmlspecialchars_decode($single_answer[0], ENT_QUOTES) . '</span>';
@@ -1001,7 +1015,7 @@ function qsm_questions_answers_shortcode_to_text($mlw_quiz_array, $qmn_question_
1001
  }
1002
  }
1003
  }
1004
- }
1005
  } else {
1006
  if (isset($answer['question_type']) && ( $answer['question_type'] == 4 || $answer['question_type'] == 10 )) {
1007
  $user_selected_answer = htmlspecialchars_decode($answer[1], ENT_QUOTES);
@@ -1014,10 +1028,10 @@ function qsm_questions_answers_shortcode_to_text($mlw_quiz_array, $qmn_question_
1014
  }
1015
  } else {
1016
  if($answer['question_type'] == 13)
1017
- {
1018
  $questionid = $questions[$answer['id']]['question_id'];
1019
-
1020
- $question_with_answer_text .= qmn_polar_display_on_resultspage($questionid, $questions, $total_answers,$answer);
1021
  }
1022
  else
1023
  {
@@ -1044,8 +1058,8 @@ function qsm_questions_answers_shortcode_to_text($mlw_quiz_array, $qmn_question_
1044
  $question_with_answer_text .= '<span class="qsm-user-answer-text">' . htmlspecialchars_decode($answer[1], ENT_QUOTES) . '</span>';
1045
  }
1046
  }
1047
- }
1048
- $mlw_question_answer_display = str_replace("%USER_ANSWERS_DEFAULT%", $question_with_answer_text, $mlw_question_answer_display);
1049
  }
1050
  if (isset($answer['question_type']) && $answer['question_type'] == 11) {
1051
  $file_extension = substr($answer[1], -4);
@@ -1070,10 +1084,10 @@ function qsm_questions_answers_shortcode_to_text($mlw_quiz_array, $qmn_question_
1070
  //Point score of the particular question.
1071
  $question_point = isset( $answer['points'] ) ? $answer['points'] : '0';
1072
  $mlw_question_answer_display = str_replace("%QUESTION_POINT_SCORE%", htmlspecialchars_decode($question_point, ENT_QUOTES), $mlw_question_answer_display);
1073
-
1074
  $question_max_point = (isset($questions[$answer['id']]) ? qsm_get_question_maximum_points($questions[$answer['id']]) : 0 );
1075
  $mlw_question_answer_display = str_replace("%QUESTION_MAX_POINTS%", $question_max_point, $mlw_question_answer_display);
1076
-
1077
  $mlw_question_answer_display = wp_kses_post($mlw_question_answer_display);
1078
  if ($total_question_cnt == $qsm_question_cnt && $remove_border == false ) {
1079
  $extra_border_bottom_class = 'qsm-remove-border-bottom';
@@ -1114,9 +1128,9 @@ function qsm_is_allow_score_roundoff()
1114
  $score_roundoff = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_options', 'score_roundoff');
1115
  $form_type = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_options', 'form_type');
1116
  $system = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_options', 'system');
1117
-
1118
  // check if quiz type Quiz and Geading system Correct/Incorrect Or Both Type
1119
- if($score_roundoff && $form_type ==0 && ($system ==0 || $system == 3))
1120
  return 1;
1121
  else
1122
  return 0;
@@ -1131,7 +1145,7 @@ function qsm_is_allow_score_roundoff()
1131
  * @return $question_display Returns the content of the question
1132
  * @since 7.1.10
1133
  */
1134
- function qmn_polar_display_on_resultspage($id, $question, $answers,$answer) {
1135
  $question_display = '';
1136
  global $mlwQuizMasterNext;
1137
  $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
@@ -1157,7 +1171,7 @@ function qmn_polar_display_on_resultspage($id, $question, $answers,$answer) {
1157
  <script type="text/javascript">
1158
  (function($) {
1159
  $(document).ready(function() {
1160
-
1161
  $('#slider-' + '<?php echo $id; ?>').slider({
1162
  <?php if ($total_answer == 2 && $is_reverse) { ?>
1163
  max: <?php echo $answers[0][1]; ?>,
@@ -1172,14 +1186,14 @@ function qmn_polar_display_on_resultspage($id, $question, $answers,$answer) {
1172
  value: <?php echo $answer['points']; ?>,
1173
  slide: function slider_slide(event, ui) {
1174
  return false; // this code not allow to dragging
1175
- }
1176
  });
1177
  var maxHeight = Math.max.apply(null, $(".mlw-qmn-question-result-<?php echo $id; ?>> div").map(function (){
1178
  return $(this).height();
1179
  }).get());
1180
  $('.mlw-qmn-question-result-<?php echo $id; ?>').height(maxHeight);
1181
  });
1182
- })(jQuery);
1183
  </script>
1184
  <?php
1185
  if ($required == 0) {
@@ -1217,7 +1231,7 @@ function qmn_polar_display_on_resultspage($id, $question, $answers,$answer) {
1217
  $left_polar_title_style = "style='font-weight:400;'";
1218
  $right_polar_title_style = "style='font-weight:400;'";
1219
  }
1220
- $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
1221
  $question_title = qsm_question_title_func($question, '', $new_question_title);
1222
  $input_text .= "<div class='left-polar-title' $left_polar_title_style>" . $answers[0][0] ."</div>";
1223
  $input_text .= "<div class='slider-main-wrapper'><input type='hidden' class='qmn_polar $mlw_requireClass' id='question" . $id . "' name='question" . $id . "' />";
100
  $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%' );
101
  }else{
102
  $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%' );
103
+ }
104
  } else {
105
  if( isset( $mlw_quiz_array['quiz_settings'] ) && !empty($mlw_quiz_array['quiz_settings']) ){
106
  $quiz_text_settings = isset( $mlw_quiz_array['quiz_settings']['quiz_text'] ) ? @unserialize( stripslashes( $mlw_quiz_array['quiz_settings']['quiz_text'] ) ) : array();
108
  }else{
109
  $qmn_question_answer_template = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_template', '%QUESTION%<br/>%USER_ANSWERS_DEFAULT%' );
110
  }
111
+ }
112
  $mlw_question_answer_display = htmlspecialchars_decode($qmn_question_answer_template, ENT_QUOTES);
113
  $questions = QSM_Questions::load_questions_by_pages( $mlw_quiz_array['quiz_id'] );
114
  $qmn_questions = array();
115
  foreach ( $questions as $question ) {
116
  $qmn_questions[ $question['question_id'] ] = $question['question_answer_info'];
117
+ }
118
  $total_question_cnt = 2;
119
  $qsm_question_cnt = 1;
120
  $display = qsm_questions_answers_shortcode_to_text($mlw_quiz_array, $mlw_question_answer_display, $questions, $qmn_questions, $answer, $qsm_question_cnt, $total_question_cnt);
126
 
127
  /**
128
  * Replace total_possible_points variable with actual points
129
+ *
130
  * @since 7.0.2
131
+ *
132
  * @param string $content
133
  * @param array $mlw_quiz_array
134
  * @return string $content
135
  */
136
+ function qsm_variable_total_possible_points( $content, $mlw_quiz_array ){
137
  if( isset( $mlw_quiz_array["total_possible_points"] ) ){
138
  $content = str_replace( "%MAXIMUM_POINTS%" , $mlw_quiz_array["total_possible_points"], $content);
139
  }
142
 
143
  /**
144
  * Replace total_possible_points variable with actual points
145
+ *
146
  * @since 7.0.2
147
+ *
148
  * @param string $content
149
  * @param array $mlw_quiz_array
150
  * @return string $content
151
  */
152
+ function qsm_variable_total_attempted_questions( $content, $mlw_quiz_array ){
153
  $total_attempted_questions = isset( $mlw_quiz_array["total_attempted_questions"] ) ? $mlw_quiz_array["total_attempted_questions"] : 0;
154
+ $content = str_replace( "%AMOUNT_ATTEMPTED%" , $total_attempted_questions, $content);
155
  return $content;
156
  }
157
 
214
  }
215
 
216
  function qsm_find_key_from_array($search_value,$array){
217
+ if($array){
218
  $search_value = htmlspecialchars_decode( $search_value, ENT_QUOTES );
219
+ foreach ($array as $key => $value) {
220
  $value_val = $value[0];
221
  if( $value_val == $search_value ){
222
  return true;
223
  }
224
+ }
225
  }
226
  return false;
227
  }
278
  return $content;
279
  }
280
  function mlw_qmn_variable_average_point($content, $mlw_quiz_array){
281
+ $question_total = 0;
282
  if( isset( $mlw_quiz_array['question_answers_array'] ) ){
283
  foreach( $mlw_quiz_array['question_answers_array'] as $single_question ){
284
+ if( $single_question['question_type'] !== '11' ){
285
  $question_total++;
286
+ }
287
  }
288
  }
289
  if (isset($mlw_quiz_array['total_questions']) && $mlw_quiz_array["total_questions"] != 0 && $question_total != 0){
307
 
308
  /**
309
  * Return total incorrect amount
310
+ *
311
  * @since 7.0.3
312
  * @param string $content
313
  * @param array $mlw_quiz_array
374
  * @return string
375
  */
376
  function mlw_qmn_variable_user_full_name($content, $mlw_quiz_array) {
377
+ if (false !== strpos($content, '%FULL_NAME%')) {
378
+ $current_user = wp_get_current_user();
379
  $firstname = get_user_meta( $current_user->ID, 'first_name', true );
380
  $lastname = get_user_meta( $current_user->ID, 'last_name', true );
381
  if(!empty($firstname) && !empty($lastname))
596
  }
597
  foreach ( $mlw_quiz_array['question_answers_array'] as $answer ) {
598
  if ( $answer["category"] == $category_name ) {
599
+ if( $answer['question_type'] !== '11' ){
600
  $total_questions += 1;
601
  }
602
  $return_points += $answer["points"];
773
 
774
  add_filter('qmn_end_results', 'qsm_end_results_rank', 9999, 3);
775
  function qsm_end_results_rank($result_display, $qmn_quiz_options, $qmn_array_for_variables)
776
+ {
777
  while (strpos($result_display, '%RANK%') !== false){
778
  global $wpdb;
779
  $mlw_quiz_id = $qmn_array_for_variables['quiz_id'];
848
 
849
  /**
850
  * Function will convert all the QUESIONS_ANSWERS variable into appropriate data
851
+ *
852
  * @since 7.1.3
853
+ *
854
  * @param arr $mlw_quiz_array
855
  * @param str $qmn_question_answer_template
856
  * @param str $answer
858
  * @param int $total_question_cnt
859
  * @return string
860
  */
861
+ function qsm_questions_answers_shortcode_to_text($mlw_quiz_array, $qmn_question_answer_template, $questions, $qmn_questions, $answer, $qsm_question_cnt, $total_question_cnt) {
862
  global $mlwQuizMasterNext;
863
  if (is_admin() && isset($_GET['page']) && $_GET['page'] == 'qsm_quiz_result_details') {
864
  $user_answer_class = "";
883
  $question_answer_class = "qmn_question_answer_incorrect";
884
  }
885
  }
886
+
887
  $mlw_question_answer_display = htmlspecialchars_decode($qmn_question_answer_template, ENT_QUOTES);
888
  $disable_description_on_result = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_options', 'disable_description_on_result');
889
+ //Get question setting
890
+ $question_settings = isset( $questions[$answer['id']]['settings'] ) ? $questions[$answer['id']]['settings'] : array();
891
+ if (isset($answer['question_title']) && $answer['question_title'] != '') {
892
  $add_br = '';
893
  if ($answer[0] != '') {
894
  $add_br = '<br/>';
897
  $mlw_question_answer_display = str_replace("%QUESTION%", '<b>' . htmlspecialchars_decode($answer['question_title'], ENT_QUOTES) . '</b>', $mlw_question_answer_display);
898
  } else {
899
  $mlw_question_answer_display = str_replace("%QUESTION%", '<b>' . htmlspecialchars_decode($answer['question_title'], ENT_QUOTES) . '</b>' . $add_br . htmlspecialchars_decode($answer[0], ENT_QUOTES), $mlw_question_answer_display);
900
+ }
901
+ } else {
902
  $mlw_question_answer_display = str_replace("%QUESTION%", '<b>' . htmlspecialchars_decode($answer[0], ENT_QUOTES) . '</b>', $mlw_question_answer_display);
903
+ }
904
+ $mlw_question_answer_display = qsm_question_title_func($mlw_question_answer_display);
905
  $extra_border_bottom_class = '';
906
  $remove_border = true;
907
  if (strpos($mlw_question_answer_display, '%USER_ANSWERS_DEFAULT%') !== false) {
912
  3, 12, 5, 7, 14
913
  );
914
  $form_type = isset($mlw_quiz_array['form_type']) ? $mlw_quiz_array['form_type'] : 0;
915
+ $quiz_system = isset($mlw_quiz_array['quiz_system']) ? $mlw_quiz_array['quiz_system'] : 0;
916
+ if (isset($answer['id']) && isset($questions[$answer['id']]) && !empty($questions[$answer['id']])) {
917
+ $total_answers = isset($questions[$answer['id']]['answers']) ? $questions[$answer['id']]['answers'] : array();
918
  if ($total_answers) {
919
+ if (isset($answer['question_type']) && in_array($answer['question_type'], $show_two_option_questions)) {
920
  $do_show_wrong = true;
921
  foreach ($total_answers as $single_answer) {
922
  $current_answer_zero = trim( htmlspecialchars_decode($single_answer[0], ENT_QUOTES) );
956
  }
957
  } else {
958
  if ($form_type == 0 && ( $quiz_system == 0 || $quiz_system == 3 )) {
959
+ if (isset($answer['question_type']) && ( $answer['question_type'] == 4 || $answer['question_type'] == 10 )) {
960
  $user_selected_answer = htmlspecialchars_decode($answer[1], ENT_QUOTES);
961
  $new_array_user_answer = isset( $answer['user_compare_text'] ) ? explode('=====', $answer['user_compare_text']) : array();
962
  foreach ($total_answers as $single_answer) {
968
  if( $current_answer_text == $new_array_value ){
969
  $is_answer_correct = true;
970
  break;
971
+ }
972
  }
973
  }
974
  if (isset($single_answer[2]) && $single_answer[2] == 1 && $is_answer_correct ) {
983
  }
984
  } else {
985
  if($answer['question_type'] == 13)
986
+ {
987
  $questionid = $questions[$answer['id']]['question_id'];
988
+ $question_with_answer_text .= qmn_polar_display_on_resultspage($questionid, $questions, $total_answers,$answer);
989
  }
990
+ else {
991
+ foreach ($total_answers as $single_answer) {
 
992
  $single_answer_option = $single_answer[0];
993
+ if( isset( $question_settings['answerEditor'] ) && $question_settings['answerEditor'] == 'rich' ){
994
+ $single_answer_option = htmlspecialchars_decode( $single_answer[0], ENT_QUOTES );
995
+ $single_answer_option = htmlentities( $single_answer_option );
996
+ if( strpos($single_answer_option, '&lt;') !== false || strpos($single_answer_option, '&quot;') !== false ){
997
+ $single_answer_option = htmlspecialchars( $single_answer_option );
998
+ }
999
+ if( strpos($answer[1], '&lt;') !== false || strpos($answer[1], '&quot;') !== false ){
1000
+ $answer_value = htmlentities( $answer[1] );
1001
+ }else {
1002
+ $answer_value = $answer[1];
1003
+ }
1004
+ } else {
1005
+ $answer_value = htmlspecialchars_decode($answer[1], ENT_QUOTES);
1006
+ }
1007
+ if (isset($single_answer[2]) && $single_answer[2] == 1 && $answer_value == $single_answer_option ) {
1008
  $question_with_answer_text .= '<span class="qsm-text-correct-option qsm-text-user-correct-answer">' . htmlspecialchars_decode($single_answer[0], ENT_QUOTES) . '</span>';
1009
  } else if (isset($single_answer[2]) && $single_answer[2] == 1) {
1010
  $question_with_answer_text .= '<span class="qsm-text-correct-option">' . htmlspecialchars_decode($single_answer[0], ENT_QUOTES) . '</span>';
1015
  }
1016
  }
1017
  }
1018
+ }
1019
  } else {
1020
  if (isset($answer['question_type']) && ( $answer['question_type'] == 4 || $answer['question_type'] == 10 )) {
1021
  $user_selected_answer = htmlspecialchars_decode($answer[1], ENT_QUOTES);
1028
  }
1029
  } else {
1030
  if($answer['question_type'] == 13)
1031
+ {
1032
  $questionid = $questions[$answer['id']]['question_id'];
1033
+
1034
+ $question_with_answer_text .= qmn_polar_display_on_resultspage($questionid, $questions, $total_answers,$answer);
1035
  }
1036
  else
1037
  {
1058
  $question_with_answer_text .= '<span class="qsm-user-answer-text">' . htmlspecialchars_decode($answer[1], ENT_QUOTES) . '</span>';
1059
  }
1060
  }
1061
+ }
1062
+ $mlw_question_answer_display = str_replace("%USER_ANSWERS_DEFAULT%", do_shortcode( $question_with_answer_text ), $mlw_question_answer_display);
1063
  }
1064
  if (isset($answer['question_type']) && $answer['question_type'] == 11) {
1065
  $file_extension = substr($answer[1], -4);
1084
  //Point score of the particular question.
1085
  $question_point = isset( $answer['points'] ) ? $answer['points'] : '0';
1086
  $mlw_question_answer_display = str_replace("%QUESTION_POINT_SCORE%", htmlspecialchars_decode($question_point, ENT_QUOTES), $mlw_question_answer_display);
1087
+
1088
  $question_max_point = (isset($questions[$answer['id']]) ? qsm_get_question_maximum_points($questions[$answer['id']]) : 0 );
1089
  $mlw_question_answer_display = str_replace("%QUESTION_MAX_POINTS%", $question_max_point, $mlw_question_answer_display);
1090
+
1091
  $mlw_question_answer_display = wp_kses_post($mlw_question_answer_display);
1092
  if ($total_question_cnt == $qsm_question_cnt && $remove_border == false ) {
1093
  $extra_border_bottom_class = 'qsm-remove-border-bottom';
1128
  $score_roundoff = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_options', 'score_roundoff');
1129
  $form_type = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_options', 'form_type');
1130
  $system = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_options', 'system');
1131
+
1132
  // check if quiz type Quiz and Geading system Correct/Incorrect Or Both Type
1133
+ if($score_roundoff && $form_type ==0 && ($system ==0 || $system == 3))
1134
  return 1;
1135
  else
1136
  return 0;
1145
  * @return $question_display Returns the content of the question
1146
  * @since 7.1.10
1147
  */
1148
+ function qmn_polar_display_on_resultspage($id, $question, $answers,$answer) {
1149
  $question_display = '';
1150
  global $mlwQuizMasterNext;
1151
  $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
1171
  <script type="text/javascript">
1172
  (function($) {
1173
  $(document).ready(function() {
1174
+
1175
  $('#slider-' + '<?php echo $id; ?>').slider({
1176
  <?php if ($total_answer == 2 && $is_reverse) { ?>
1177
  max: <?php echo $answers[0][1]; ?>,
1186
  value: <?php echo $answer['points']; ?>,
1187
  slide: function slider_slide(event, ui) {
1188
  return false; // this code not allow to dragging
1189
+ }
1190
  });
1191
  var maxHeight = Math.max.apply(null, $(".mlw-qmn-question-result-<?php echo $id; ?>> div").map(function (){
1192
  return $(this).height();
1193
  }).get());
1194
  $('.mlw-qmn-question-result-<?php echo $id; ?>').height(maxHeight);
1195
  });
1196
+ })(jQuery);
1197
  </script>
1198
  <?php
1199
  if ($required == 0) {
1231
  $left_polar_title_style = "style='font-weight:400;'";
1232
  $right_polar_title_style = "style='font-weight:400;'";
1233
  }
1234
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
1235
  $question_title = qsm_question_title_func($question, '', $new_question_title);
1236
  $input_text .= "<div class='left-polar-title' $left_polar_title_style>" . $answers[0][0] ."</div>";
1237
  $input_text .= "<div class='slider-main-wrapper'><input type='hidden' class='qmn_polar $mlw_requireClass' id='question" . $id . "' name='question" . $id . "' />";
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.6
6
  Requires PHP: 5.4
7
- Stable tag: 7.1.11
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -125,16 +125,28 @@ This is usually a theme conflict. You can [checkout out our common conflict solu
125
 
126
  == Screenshots ==
127
 
128
- 1. Quiz/Survey Admin Page (With Advertisement Be Gone Add-On)
129
- 2. Quiz/Survey Settings Page (With Advertisement Be Gone Add-On)
130
- 3. Quiz/Survey Statistics Page (With Advertisement Be Gone Add-On)
131
- 4. Example Quiz
132
- 5. Example Survey
133
- 6. Quiz/Survey Results Page
134
- 8. Example Quiz With Styling
 
 
 
 
 
135
 
136
  == Changelog ==
137
 
 
 
 
 
 
 
 
138
  = 7.1.11 (January 27, 2020) =
139
  * Bug: Fixed jquery issue while editing the result page.
140
  * Bug: Added string translation for %POLL_RESULTS_X% variable.
4
  Requires at least: 4.9
5
  Tested up to: 5.6
6
  Requires PHP: 5.4
7
+ Stable tag: 7.1.12
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
125
 
126
  == Screenshots ==
127
 
128
+ 1. Dashboard
129
+ 2. Create New Quiz or Survey
130
+ 3. Question Type
131
+ 4. Questions
132
+ 5. All Quizzes & Surveys
133
+ 6. Contact Field
134
+ 7. Frontend View
135
+ 8. Frontend View with Answer
136
+ 9. Answer
137
+ 10. Database
138
+ 11. Stats
139
+ 12. Reporting and analysis result
140
 
141
  == Changelog ==
142
 
143
+ = 7.1.12 (February 22, 2020) =
144
+ * Bug: Fixed prevention of SQL injection while using result shortcode and question bank.
145
+ * Bug: Fixed the issue of broken [latex] shortcode in result and user dashboard page.
146
+ * Enhancement: Added option to end the quiz if answer is wrong.
147
+ * Enhancement: Added option to turn off the HTML auto complete.
148
+ * Enhancement: Modified background color to fix contrast ratios from SEO perspective.
149
+
150
  = 7.1.11 (January 27, 2020) =
151
  * Bug: Fixed jquery issue while editing the result page.
152
  * Bug: Added string translation for %POLL_RESULTS_X% variable.