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

Version Description

(May 31, 2016) = * Closed Enhancement: Create new question section id CSS class for each question - Issue #440 * Closed Bug: Creating/Editing questions throw PHP notice of undefined index - Issue #436

Download this release

Release Info

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

Code changes from version 4.7.2 to 4.7.3

mlw_quizmaster2.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: Quiz And Survey Master
4
  * Description: Easily and quickly add quizzes and surveys to your website.
5
- * Version: 4.7.2
6
  * Author: Frank Corso
7
  * Author URI: http://www.quizandsurveymaster.com/
8
  * Plugin URI: http://www.quizandsurveymaster.com/
@@ -10,7 +10,7 @@
10
  * Domain Path: /languages
11
  *
12
  * @author Frank Corso
13
- * @version 4.7.2
14
  */
15
  if ( ! defined( 'ABSPATH' ) ) exit;
16
 
@@ -30,7 +30,7 @@ class MLWQuizMasterNext
30
  * @var string
31
  * @since 4.0.0
32
  */
33
- public $version = '4.7.2';
34
 
35
  /**
36
  * QMN Alert Manager Object
@@ -246,8 +246,8 @@ class MLWQuizMasterNext
246
  add_submenu_page(__FILE__, __('Help', 'quiz-master-next'), __('Help', 'quiz-master-next'), 'moderate_comments', 'mlw_quiz_help', 'mlw_generate_help_page');
247
 
248
  add_dashboard_page(
249
- __( 'QMN About', 'quiz' ),
250
- __( 'QMN About', 'quiz' ),
251
  'manage_options',
252
  'mlw_qmn_about',
253
  'mlw_generate_about_page'
2
  /**
3
  * Plugin Name: Quiz And Survey Master
4
  * Description: Easily and quickly add quizzes and surveys to your website.
5
+ * Version: 4.7.3
6
  * Author: Frank Corso
7
  * Author URI: http://www.quizandsurveymaster.com/
8
  * Plugin URI: http://www.quizandsurveymaster.com/
10
  * Domain Path: /languages
11
  *
12
  * @author Frank Corso
13
+ * @version 4.7.3
14
  */
15
  if ( ! defined( 'ABSPATH' ) ) exit;
16
 
30
  * @var string
31
  * @since 4.0.0
32
  */
33
+ public $version = '4.7.3';
34
 
35
  /**
36
  * QMN Alert Manager Object
246
  add_submenu_page(__FILE__, __('Help', 'quiz-master-next'), __('Help', 'quiz-master-next'), 'moderate_comments', 'mlw_quiz_help', 'mlw_generate_help_page');
247
 
248
  add_dashboard_page(
249
+ __( 'QSM About', 'quiz' ),
250
+ __( 'QSM About', 'quiz' ),
251
  'manage_options',
252
  'mlw_qmn_about',
253
  'mlw_generate_about_page'
php/about-page.php CHANGED
@@ -59,7 +59,7 @@ function mlw_generate_about_page()
59
  </div>
60
  <div id="mlw_quiz_changelog" class="qmn_tab" style="display: none;">
61
  <h2>Changelog</h2>
62
- <?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 22 ); ?>
63
  </div>
64
  <div id="qmn_contributors" class="qmn_tab" style="display:none;">
65
  <h2>GitHub Contributors</h2>
59
  </div>
60
  <div id="mlw_quiz_changelog" class="qmn_tab" style="display: none;">
61
  <h2>Changelog</h2>
62
+ <?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 23 ); ?>
63
  </div>
64
  <div id="qmn_contributors" class="qmn_tab" style="display:none;">
65
  <h2>GitHub Contributors</h2>
php/class-qmn-quiz-manager.php CHANGED
@@ -390,7 +390,7 @@ class QMNQuizManager
390
  {
391
  $question_id_list .= $mlw_question->question_id."Q";
392
  $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
393
- $question_display .= "<div class='quiz_section slide".$mlw_qmn_section_count."'>";
394
 
395
  $question_display .= $mlwQuizMasterNext->pluginHelper->display_question($mlw_question->question_type_new, $mlw_question->question_id, $qmn_quiz_options);
396
 
@@ -410,7 +410,6 @@ class QMNQuizManager
410
  $question_display .= "<br /><br />";
411
  }
412
  $question_display .= "</div>";
413
- if ( $qmn_quiz_options->pagination == 0) { $question_display .= "<br />"; }
414
  }
415
  $question_display .= "<input type='hidden' name='qmn_question_list' value='$question_id_list' />";
416
  return $question_display;
390
  {
391
  $question_id_list .= $mlw_question->question_id."Q";
392
  $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
393
+ $question_display .= "<div class='quiz_section question-section-id-{$mlw_question->question_id} slide{$mlw_qmn_section_count}'>";
394
 
395
  $question_display .= $mlwQuizMasterNext->pluginHelper->display_question($mlw_question->question_type_new, $mlw_question->question_id, $qmn_quiz_options);
396
 
410
  $question_display .= "<br /><br />";
411
  }
412
  $question_display .= "</div>";
 
413
  }
414
  $question_display .= "<input type='hidden' name='qmn_question_list' value='$question_id_list' />";
415
  return $question_display;
php/options-page-questions-tab.php CHANGED
@@ -69,64 +69,77 @@ function mlw_options_questions_tab_content()
69
 
70
  //Edit question
71
  if ( isset( $_POST["question_submission"] ) && $_POST["question_submission"] == "edit_question" ) {
 
72
  //Variables from edit question form
73
- $edit_question_name = trim(preg_replace('/\s+/',' ', nl2br(htmlspecialchars(stripslashes($_POST["question_name"]), ENT_QUOTES))));
74
- $edit_question_answer_info = htmlspecialchars(stripslashes($_POST["correct_answer_info"]), ENT_QUOTES);
75
- $mlw_edit_question_id = intval($_POST["question_id"]);
76
  $mlw_edit_question_type = sanitize_text_field( $_POST["question_type"] );
77
- $edit_comments = htmlspecialchars($_POST["comments"], ENT_QUOTES);
78
- $edit_hint = htmlspecialchars($_POST["hint"], ENT_QUOTES);
79
- $edit_question_order = intval($_POST["new_question_order"]);
80
- $mlw_edit_answer_total = intval($_POST["new_question_answer_total"]);
81
 
 
82
  if ( isset( $_POST["new_category"] ) ) {
 
83
  $qmn_edit_category = sanitize_text_field( $_POST["new_category"] );
84
- if ( $qmn_edit_category == 'new_category' ) {
 
 
85
  $qmn_edit_category = sanitize_text_field( stripslashes( $_POST["new_new_category"] ) );
86
  }
87
  } else {
88
  $qmn_edit_category = '';
89
  }
 
 
90
  $mlw_row_settings = $wpdb->get_row( $wpdb->prepare( "SELECT question_settings FROM " . $wpdb->prefix . "mlw_questions" . " WHERE question_id=%d", $mlw_edit_question_id ) );
91
- if (is_serialized($mlw_row_settings->question_settings) && is_array(@unserialize($mlw_row_settings->question_settings)))
92
- {
93
- $mlw_settings = @unserialize($mlw_row_settings->question_settings);
94
- }
95
- else
96
- {
97
  $mlw_settings = array();
98
- $mlw_settings['required'] = intval($_POST["required"]);
99
  }
100
- if ( !isset($mlw_settings['required']))
101
- {
102
- $mlw_settings['required'] = intval($_POST["required"]);
103
  }
104
- $mlw_settings['required'] = intval($_POST["required"]);
105
- $mlw_settings = serialize($mlw_settings);
 
 
106
  $i = 1;
107
- $mlw_qmn_new_answer_array = array();
108
- while ($i <= $mlw_edit_answer_total)
109
- {
110
- if ($_POST["answer_".$i] != "")
111
- {
112
- $mlw_qmn_correct = 0;
113
- if (isset($_POST["answer_".$i."_correct"]) && $_POST["answer_".$i."_correct"] == 1)
114
- {
115
- $mlw_qmn_correct = 1;
 
116
  }
117
- $mlw_qmn_answer_each = array(htmlspecialchars(stripslashes($_POST["answer_".$i]), ENT_QUOTES), floatval($_POST["answer_".$i."_points"]), $mlw_qmn_correct);
118
- $mlw_qmn_new_answer_array[] = $mlw_qmn_answer_each;
 
 
 
 
 
119
  }
120
  $i++;
121
  }
122
- $mlw_qmn_new_answer_array = serialize( $mlw_qmn_new_answer_array );
 
123
  $quiz_id = intval( $_POST["quiz_id"] );
124
 
 
125
  $results = $wpdb->update(
126
  $wpdb->prefix . "mlw_questions",
127
  array(
128
  'question_name' => $edit_question_name,
129
- 'answer_array' => $mlw_qmn_new_answer_array,
130
  'question_answer_info' => $edit_question_answer_info,
131
  'comments' => $edit_comments,
132
  'hints' => $edit_hint,
@@ -259,73 +272,93 @@ function mlw_options_questions_tab_content()
259
 
260
  //Submit new question into database
261
  if ( isset( $_POST["question_submission"] ) && $_POST["question_submission"] == "new_question") {
 
262
  //Variables from new question form
263
- $question_name = trim(preg_replace('/\s+/',' ', nl2br(htmlspecialchars(stripslashes($_POST["question_name"]), ENT_QUOTES))));
264
  $question_answer_info = htmlspecialchars( stripslashes( $_POST["correct_answer_info"] ), ENT_QUOTES );
265
  $question_type = sanitize_text_field( $_POST["question_type"] );
266
  $comments = htmlspecialchars( $_POST["comments"], ENT_QUOTES );
267
  $hint = htmlspecialchars( $_POST["hint"], ENT_QUOTES );
268
  $new_question_order = intval( $_POST["new_question_order"] );
269
- $mlw_answer_total = intval( $_POST["new_question_answer_total"] );
270
 
 
271
  if ( isset( $_POST['new_category'] ) ) {
 
272
  $qmn_category = sanitize_text_field( $_POST["new_category"] );
273
- if ($qmn_category == 'new_category') {
 
 
274
  $qmn_category = sanitize_text_field( stripslashes( $_POST["new_new_category"] ) );
275
  }
276
  } else {
277
  $qmn_category = '';
278
  }
 
 
279
  $mlw_settings = array();
280
  $mlw_settings['required'] = intval($_POST["required"]);
281
  $mlw_settings = serialize($mlw_settings);
 
 
282
  $i = 1;
283
- $mlw_qmn_new_answer_array = array();
284
- while ($i <= $mlw_answer_total)
285
- {
286
- if ($_POST["answer_".$i] != "")
287
- {
288
- $mlw_qmn_correct = 0;
289
- if (isset($_POST["answer_".$i."_correct"]) && $_POST["answer_".$i."_correct"] == 1)
290
- {
291
- $mlw_qmn_correct = 1;
 
292
  }
293
- $mlw_qmn_answer_each = array(htmlspecialchars(stripslashes($_POST["answer_".$i]), ENT_QUOTES), floatval($_POST["answer_".$i."_points"]), $mlw_qmn_correct);
294
- $mlw_qmn_new_answer_array[] = $mlw_qmn_answer_each;
 
 
 
 
 
295
  }
296
  $i++;
297
  }
298
- $mlw_qmn_new_answer_array = serialize($mlw_qmn_new_answer_array);
 
299
  $quiz_id = intval( $_POST["quiz_id"] );
 
 
300
  $results = $wpdb->insert(
301
- $wpdb->prefix."mlw_questions",
302
- array(
303
- 'quiz_id' => $quiz_id,
304
- 'question_name' => $question_name,
305
- 'answer_array' => $mlw_qmn_new_answer_array,
306
- 'question_answer_info' => $question_answer_info,
307
- 'comments' => $comments,
308
- 'hints' => $hint,
309
- 'question_order' => $new_question_order,
310
- 'question_type_new' => $question_type,
311
- 'question_settings' => $mlw_settings,
312
- 'category' => $qmn_category,
313
- 'deleted' => 0
314
- ),
315
- array(
316
- '%d',
317
- '%s',
318
- '%s',
319
- '%s',
320
- '%d',
321
- '%s',
322
- '%d',
323
- '%s',
324
- '%s',
325
- '%s',
326
- '%d'
327
- )
328
- );
 
 
329
  if ( false != $results ) {
330
  $mlwQuizMasterNext->alertManager->newAlert(__('The question has been created successfully.', 'quiz-master-next'), 'success');
331
  $mlwQuizMasterNext->audit_manager->new_audit( "Question Has Been Added: $question_name" );
69
 
70
  //Edit question
71
  if ( isset( $_POST["question_submission"] ) && $_POST["question_submission"] == "edit_question" ) {
72
+
73
  //Variables from edit question form
74
+ $edit_question_name = trim( preg_replace( '/\s+/',' ', nl2br( htmlspecialchars( stripslashes( $_POST["question_name"] ), ENT_QUOTES ) ) ) );
75
+ $edit_question_answer_info = htmlspecialchars( stripslashes( $_POST["correct_answer_info"] ), ENT_QUOTES );
76
+ $mlw_edit_question_id = intval( $_POST["question_id"] );
77
  $mlw_edit_question_type = sanitize_text_field( $_POST["question_type"] );
78
+ $edit_comments = htmlspecialchars( $_POST["comments"], ENT_QUOTES );
79
+ $edit_hint = htmlspecialchars( $_POST["hint"], ENT_QUOTES );
80
+ $edit_question_order = intval( $_POST["new_question_order"] );
81
+ $total_answers = intval( $_POST["new_question_answer_total"] );
82
 
83
+ // Checks if a category was selected or entered
84
  if ( isset( $_POST["new_category"] ) ) {
85
+
86
  $qmn_edit_category = sanitize_text_field( $_POST["new_category"] );
87
+
88
+ // Checks if the new category radio was selected
89
+ if ( 'new_category' == $qmn_edit_category ) {
90
  $qmn_edit_category = sanitize_text_field( stripslashes( $_POST["new_new_category"] ) );
91
  }
92
  } else {
93
  $qmn_edit_category = '';
94
  }
95
+
96
+ // Retrieves question settings and sets required field
97
  $mlw_row_settings = $wpdb->get_row( $wpdb->prepare( "SELECT question_settings FROM " . $wpdb->prefix . "mlw_questions" . " WHERE question_id=%d", $mlw_edit_question_id ) );
98
+ if ( is_serialized( $mlw_row_settings->question_settings ) && is_array( @unserialize( $mlw_row_settings->question_settings ) ) ) {
99
+ $mlw_settings = @unserialize( $mlw_row_settings->question_settings );
100
+ } else {
 
 
 
101
  $mlw_settings = array();
102
+ $mlw_settings['required'] = intval( $_POST["required"] );
103
  }
104
+ if ( ! isset( $mlw_settings['required'] ) ) {
105
+ $mlw_settings['required'] = intval( $_POST["required"] );
 
106
  }
107
+ $mlw_settings['required'] = intval( $_POST["required"] );
108
+ $mlw_settings = serialize( $mlw_settings );
109
+
110
+ // Cycles through answers
111
  $i = 1;
112
+ $answer_array = array();
113
+ while ( $i <= $total_answers ) {
114
+
115
+ // Checks if that answer exists and it's not empty
116
+ if ( isset( $_POST["answer_$i"] ) && ! empty( $_POST["answer_$i"] ) ) {
117
+
118
+ // Checks if the answer was marked as correct
119
+ $correct = 0;
120
+ if ( isset( $_POST["answer_$i"."_correct"] ) && 1 == $_POST["answer_$i"."_correct"] ) {
121
+ $correct = 1;
122
  }
123
+
124
+ // Prepares this answer array
125
+ $answer_array[] = array(
126
+ htmlspecialchars( stripslashes( $_POST["answer_$i"] ), ENT_QUOTES ),
127
+ floatval( $_POST["answer_".$i."_points"] ),
128
+ $correct
129
+ );
130
  }
131
  $i++;
132
  }
133
+
134
+ $answer_array = serialize( $answer_array );
135
  $quiz_id = intval( $_POST["quiz_id"] );
136
 
137
+ // Updates question row in table
138
  $results = $wpdb->update(
139
  $wpdb->prefix . "mlw_questions",
140
  array(
141
  'question_name' => $edit_question_name,
142
+ 'answer_array' => $answer_array,
143
  'question_answer_info' => $edit_question_answer_info,
144
  'comments' => $edit_comments,
145
  'hints' => $edit_hint,
272
 
273
  //Submit new question into database
274
  if ( isset( $_POST["question_submission"] ) && $_POST["question_submission"] == "new_question") {
275
+
276
  //Variables from new question form
277
+ $question_name = trim( preg_replace( '/\s+/',' ', nl2br( htmlspecialchars( stripslashes( $_POST["question_name"] ), ENT_QUOTES ) ) ) );
278
  $question_answer_info = htmlspecialchars( stripslashes( $_POST["correct_answer_info"] ), ENT_QUOTES );
279
  $question_type = sanitize_text_field( $_POST["question_type"] );
280
  $comments = htmlspecialchars( $_POST["comments"], ENT_QUOTES );
281
  $hint = htmlspecialchars( $_POST["hint"], ENT_QUOTES );
282
  $new_question_order = intval( $_POST["new_question_order"] );
283
+ $total_answers = intval( $_POST["new_question_answer_total"] );
284
 
285
+ // Checks if a category was selected or entered
286
  if ( isset( $_POST['new_category'] ) ) {
287
+
288
  $qmn_category = sanitize_text_field( $_POST["new_category"] );
289
+
290
+ // Checks if the new category radio was selected
291
+ if ( 'new_category' == $qmn_category ) {
292
  $qmn_category = sanitize_text_field( stripslashes( $_POST["new_new_category"] ) );
293
  }
294
  } else {
295
  $qmn_category = '';
296
  }
297
+
298
+ // Creates question settings array
299
  $mlw_settings = array();
300
  $mlw_settings['required'] = intval($_POST["required"]);
301
  $mlw_settings = serialize($mlw_settings);
302
+
303
+ // Cycles through answers
304
  $i = 1;
305
+ $answer_array = array();
306
+ while ( $i <= $total_answers ) {
307
+
308
+ // Checks if that answer exists and it's not empty
309
+ if ( isset( $_POST["answer_$i"] ) && ! empty( $_POST["answer_$i"] ) ) {
310
+
311
+ // Checks if the answer was marked as correct
312
+ $correct = 0;
313
+ if ( isset( $_POST["answer_".$i."_correct"] ) && 1 == $_POST["answer_".$i."_correct"] ) {
314
+ $correct = 1;
315
  }
316
+
317
+ // Prepares answer array
318
+ $answer_array[] = array(
319
+ htmlspecialchars( stripslashes( $_POST["answer_".$i] ), ENT_QUOTES ),
320
+ floatval( $_POST["answer_".$i."_points"] ),
321
+ $correct
322
+ );
323
  }
324
  $i++;
325
  }
326
+
327
+ $answer_array = serialize( $answer_array );
328
  $quiz_id = intval( $_POST["quiz_id"] );
329
+
330
+ // Inserts new question into table
331
  $results = $wpdb->insert(
332
+ $wpdb->prefix."mlw_questions",
333
+ array(
334
+ 'quiz_id' => $quiz_id,
335
+ 'question_name' => $question_name,
336
+ 'answer_array' => $answer_array,
337
+ 'question_answer_info' => $question_answer_info,
338
+ 'comments' => $comments,
339
+ 'hints' => $hint,
340
+ 'question_order' => $new_question_order,
341
+ 'question_type_new' => $question_type,
342
+ 'question_settings' => $mlw_settings,
343
+ 'category' => $qmn_category,
344
+ 'deleted' => 0
345
+ ),
346
+ array(
347
+ '%d',
348
+ '%s',
349
+ '%s',
350
+ '%s',
351
+ '%d',
352
+ '%s',
353
+ '%d',
354
+ '%s',
355
+ '%s',
356
+ '%s',
357
+ '%d'
358
+ )
359
+ );
360
+
361
+ // Checks if insert was successful or not
362
  if ( false != $results ) {
363
  $mlwQuizMasterNext->alertManager->newAlert(__('The question has been created successfully.', 'quiz-master-next'), 'success');
364
  $mlwQuizMasterNext->audit_manager->new_audit( "Question Has Been Added: $question_name" );
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://mylocalwebstop.com/downloads/donation-service-payment/
4
  Tags: quiz, survey, test, score, exam, questionnaire, email, answer, question, certificate, points, results
5
  Requires at least: 4.1
6
  Tested up to: 4.5.2
7
- Stable tag: 4.7.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -104,6 +104,10 @@ This is usually a theme conflict. You can [checkout out our common conflict solu
104
 
105
  == Changelog ==
106
 
 
 
 
 
107
  = 4.7.2 (May 23, 2016) =
108
  * Closed Bug: Multiple quizzes on page causes plugin to scroll to top quiz when submitting - Issue #428
109
 
@@ -137,5 +141,5 @@ This is usually a theme conflict. You can [checkout out our common conflict solu
137
 
138
  == Upgrade Notice ==
139
 
140
- = 4.7.2 =
141
- Upgrade to fix scrolling bug affecting posts with multiple quizzes
4
  Tags: quiz, survey, test, score, exam, questionnaire, email, answer, question, certificate, points, results
5
  Requires at least: 4.1
6
  Tested up to: 4.5.2
7
+ Stable tag: 4.7.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
104
 
105
  == Changelog ==
106
 
107
+ = 4.7.3 (May 31, 2016) =
108
+ * Closed Enhancement: Create new question section id CSS class for each question - Issue #440
109
+ * Closed Bug: Creating/Editing questions throw PHP notice of undefined index - Issue #436
110
+
111
  = 4.7.2 (May 23, 2016) =
112
  * Closed Bug: Multiple quizzes on page causes plugin to scroll to top quiz when submitting - Issue #428
113
 
141
 
142
  == Upgrade Notice ==
143
 
144
+ = 4.7.3 =
145
+ Upgrade to fix undefined index bug when editing questions