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

Version Description

This update adds pagination to the quizzes, audit trail, and question tables to make using the admin side easier. It also adds the ability to duplicate a quiz. Fixes various minor bugs.

Download this release

Release Info

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

Code changes from version 1.1.1 to 1.2.1

includes/mlw_quiz_admin.php CHANGED
@@ -14,6 +14,8 @@ function mlw_generate_quiz_admin()
14
  $quiz_name = $_POST["quiz_name"];
15
  $hasCreatedQuiz = false;
16
  $hasDeletedQuiz = false;
 
 
17
  $mlw_qmn_isQueryError = false;
18
  $mlw_qmn_error_code = '0';
19
 
@@ -64,47 +66,102 @@ function mlw_generate_quiz_admin()
64
  $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET deleted=1 WHERE quiz_id=".$mlw_quiz_id;
65
  $results = $wpdb->query( $update );
66
  $update = "UPDATE " . $wpdb->prefix . "mlw_questions" . " SET deleted=1 WHERE quiz_id=".$mlw_quiz_id;
67
- $results = $wpdb->query( $update );
68
- $hasDeletedQuiz = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
- //Insert Action Into Audit Trail
71
- global $current_user;
72
- get_currentuserinfo();
73
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
74
- $insert = "INSERT INTO " . $table_name .
75
- "(trail_id, action_user, action, time) " .
76
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Quiz Has Been Deleted: ".$quiz_name."' , '" . date("h:i:s A m/d/Y") . "')";
77
- $results = $wpdb->query( $insert );
78
  }
79
 
80
  //Edit Quiz Name
81
- if ($_POST["quiz_name_editted"] == "confirmation")
82
  {
83
  $mlw_edit_quiz_id = $_POST["edit_quiz_id"];
84
  $mlw_edit_quiz_name = $_POST["edit_quiz_name"];
85
  $mlw_update_quiz_table = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET quiz_name='".$mlw_edit_quiz_name."' WHERE quiz_id=".$mlw_edit_quiz_id;
86
  $results = $wpdb->query( $mlw_update_quiz_table );
87
- $hasUpdatedQuizName = true;
88
-
89
- //Insert Action Into Audit Trail
90
- global $current_user;
91
- get_currentuserinfo();
92
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
93
- $insert = "INSERT INTO " . $table_name .
94
- "(trail_id, action_user, action, time) " .
95
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Quiz Name Has Been Edited: ".$mlw_edit_quiz_name."' , '" . date("h:i:s A m/d/Y") . "')";
96
- $results = $wpdb->query( $insert );
97
-
98
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  }
100
 
101
  //Retrieve list of quizzes
102
  global $wpdb;
103
- $sql = "SELECT quiz_id, quiz_name, quiz_views, quiz_taken
104
- FROM " . $wpdb->prefix . "mlw_quizzes WHERE deleted='0'";
105
- $sql .= "ORDER BY quiz_id DESC";
106
-
107
- $mlw_quiz_data = $wpdb->get_results($sql);
 
 
 
 
 
 
 
 
 
 
 
 
108
  ?>
109
  <!-- css -->
110
  <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
@@ -136,7 +193,7 @@ function mlw_generate_quiz_admin()
136
  $j( document ).tooltip();
137
  });
138
  $j(function() {
139
- $j("button").button();
140
 
141
  });
142
  $j(function() {
@@ -195,6 +252,21 @@ function mlw_generate_quiz_admin()
195
  document.getElementById("edit_quiz_name").value = quizName;
196
  document.getElementById("edit_quiz_id"). value = id;
197
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  </script>
199
  <style>
200
  label {
@@ -219,6 +291,15 @@ function mlw_generate_quiz_admin()
219
  <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
220
  <strong>Hey!</strong> Your new quiz has been created successfully. To begin editing options and adding questions to your quiz, click on the edit link for that quiz.</p>
221
  </div>
 
 
 
 
 
 
 
 
 
222
  <?php
223
  }
224
  ?>
@@ -252,6 +333,7 @@ function mlw_generate_quiz_admin()
252
  }
253
  ?>
254
  <button id="new_quiz_button_two">Create New Quiz</button>
 
255
  <?php
256
  $quotes_list = "";
257
  $display = "";
@@ -260,13 +342,35 @@ function mlw_generate_quiz_admin()
260
  else $alternate = " class=\"alternate\"";
261
  $quotes_list .= "<tr{$alternate}>";
262
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_id . "</span></td>";
263
- $quotes_list .= "<td class='post-title column-title'><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_name ." </span><span style='color:green;font-size:12px;'><a onclick=\"editQuizName('".$mlw_quiz_info->quiz_id."','".str_replace("'", "\'", htmlspecialchars_decode($mlw_quiz_info->quiz_name, ENT_QUOTES))."')\" href='#'>(Edit Name)</a></span><div><span style='color:green;font-size:12px;'><a href='admin.php?page=mlw_quiz_options&&quiz_id=".$mlw_quiz_info->quiz_id."'>Edit</a> | <a onclick=\"deleteQuiz('".$mlw_quiz_info->quiz_id."','".$mlw_quiz_info->quiz_name."')\" href='#'>Delete</a> | <a href='admin.php?page=mlw_quiz_results&&quiz_id=".$mlw_quiz_info->quiz_id."'>Results</a></span></div></td>";
264
  $quotes_list .= "<td><span style='font-size:16px;'>[mlw_quizmaster quiz=".$mlw_quiz_info->quiz_id."]</span></td>";
265
  $quotes_list .= "<td><span style='font-size:16px;'>[mlw_quizmaster_leaderboard mlw_quiz=".$mlw_quiz_info->quiz_id."]</span></td>";
266
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_views . "</span></td>";
267
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_taken ."</span></td>";
268
  $quotes_list .= "</tr>";
269
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
 
271
  $display .= "<table class=\"widefat\">";
272
  $display .= "<thead><tr>
@@ -328,6 +432,19 @@ function mlw_generate_quiz_admin()
328
  <input type="submit" class="button-primary" value="Edit" />
329
  </form>
330
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  <div id="delete_dialog" title="Delete Quiz?" style="display:none;">
332
  <h3><b>Are you sure you want to delete Quiz <span id="delete_quiz_id"></span>?</b></h3>
333
  <?php
14
  $quiz_name = $_POST["quiz_name"];
15
  $hasCreatedQuiz = false;
16
  $hasDeletedQuiz = false;
17
+ $hasUpdatedQuizName = false;
18
+ $hasDuplicatedQuiz = false;
19
  $mlw_qmn_isQueryError = false;
20
  $mlw_qmn_error_code = '0';
21
 
66
  $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET deleted=1 WHERE quiz_id=".$mlw_quiz_id;
67
  $results = $wpdb->query( $update );
68
  $update = "UPDATE " . $wpdb->prefix . "mlw_questions" . " SET deleted=1 WHERE quiz_id=".$mlw_quiz_id;
69
+ $delete_question_results = $wpdb->query( $update );
70
+ if ($results != false)
71
+ {
72
+ $hasDeletedQuiz = true;
73
+
74
+ //Insert Action Into Audit Trail
75
+ global $current_user;
76
+ get_currentuserinfo();
77
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
78
+ $insert = "INSERT INTO " . $table_name .
79
+ "(trail_id, action_user, action, time) " .
80
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Quiz Has Been Deleted: ".$quiz_name."' , '" . date("h:i:s A m/d/Y") . "')";
81
+ $results = $wpdb->query( $insert );
82
+ }
83
+ else
84
+ {
85
+ $mlw_qmn_error_code = '0002';
86
+ $mlw_qmn_isQueryError = true;
87
+ }
88
 
 
 
 
 
 
 
 
 
89
  }
90
 
91
  //Edit Quiz Name
92
+ if (isset($_POST["quiz_name_editted"]) && $_POST["quiz_name_editted"] == "confirmation")
93
  {
94
  $mlw_edit_quiz_id = $_POST["edit_quiz_id"];
95
  $mlw_edit_quiz_name = $_POST["edit_quiz_name"];
96
  $mlw_update_quiz_table = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET quiz_name='".$mlw_edit_quiz_name."' WHERE quiz_id=".$mlw_edit_quiz_id;
97
  $results = $wpdb->query( $mlw_update_quiz_table );
98
+ if ($results != false)
99
+ {
100
+ $hasUpdatedQuizName = true;
101
+
102
+ //Insert Action Into Audit Trail
103
+ global $current_user;
104
+ get_currentuserinfo();
105
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
106
+ $insert = "INSERT INTO " . $table_name .
107
+ "(trail_id, action_user, action, time) " .
108
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Quiz Name Has Been Edited: ".$mlw_edit_quiz_name."' , '" . date("h:i:s A m/d/Y") . "')";
109
+ $results = $wpdb->query( $insert );
110
+ }
111
+ else
112
+ {
113
+ $mlw_qmn_error_code = '0003';
114
+ $mlw_qmn_isQueryError = true;
115
+ }
116
+ }
117
+
118
+ //Duplicate Quiz
119
+ if (isset($_POST["duplicate_quiz"]) && $_POST["duplicate_quiz"] == "confirmation")
120
+ {
121
+ $table_name = $wpdb->prefix . "mlw_quizzes";
122
+ $mlw_duplicate_quiz_id = $_POST["duplicate_quiz_id"];
123
+ $mlw_duplicate_quiz_name = $_POST["duplicate_new_quiz_name"];
124
+ $mlw_qmn_duplicate_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "mlw_quizzes WHERE quiz_id=%d", $mlw_duplicate_quiz_id ) );
125
+ $results = $wpdb->query( "INSERT INTO ".$table_name." (quiz_id, quiz_name, message_before, message_after, message_comment, user_email_template, admin_email_template, submit_button_text, name_field_text, business_field_text, email_field_text, phone_field_text, comment_field_text, email_from_text, question_answer_template, leaderboard_template, system, randomness_order, show_score, send_user_email, send_admin_email, contact_info_location, user_name, user_comp, user_email, user_phone, admin_email, comment_section, quiz_views, quiz_taken, deleted) VALUES (NULL , '".$mlw_duplicate_quiz_name."' , '".$mlw_qmn_duplicate_data->message_before."', '".$mlw_qmn_duplicate_data->message_after."', '".$mlw_qmn_duplicate_data->message_comment."', '".$mlw_qmn_duplicate_data->user_email_template."', '".$mlw_qmn_duplicate_data->admin_email_template."', '".$mlw_qmn_duplicate_data->submit_button_text."', '".$mlw_qmn_duplicate_data->name_field_text."', '".$mlw_qmn_duplicate_data->business_field_text."', '".$mlw_qmn_duplicate_data->email_field_text."', '".$mlw_qmn_duplicate_data->phone_field_text."', '".$mlw_qmn_duplicate_data->comment_field_text."', '".$mlw_qmn_duplicate_data->email_from_text."', '".$mlw_qmn_duplicate_data->question_answer_template."', '".$mlw_qmn_duplicate_data->leaderboard_template."', ".$mlw_qmn_duplicate_data->system.", ".$mlw_qmn_duplicate_data->randomness_order.", ".$mlw_qmn_duplicate_data->show_score.", ".$mlw_qmn_duplicate_data->send_user_email.", ".$mlw_qmn_duplicate_data->send_admin_email.", ".$mlw_qmn_duplicate_data->contact_info_location.", ".$mlw_qmn_duplicate_data->user_name.", ".$mlw_qmn_duplicate_data->user_comp.", ".$mlw_qmn_duplicate_data->user_email.", ".$mlw_qmn_duplicate_data->user_phone.", '".get_option( 'admin_email', 'Enter email' )."', ".$mlw_qmn_duplicate_data->comment_section.", 0, 0, 0)" );
126
+ if ($results != false)
127
+ {
128
+ $hasDuplicatedQuiz = true;
129
+
130
+ //Insert Action Into Audit Trail
131
+ global $current_user;
132
+ get_currentuserinfo();
133
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
134
+ $insert = "INSERT INTO " . $table_name .
135
+ "(trail_id, action_user, action, time) " .
136
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'New Quiz Has Been Created: ".$mlw_duplicate_quiz_name."' , '" . date("h:i:s A m/d/Y") . "')";
137
+ $results = $wpdb->query( $insert );
138
+ }
139
+ else
140
+ {
141
+ $mlw_qmn_error_code = '0011';
142
+ $mlw_qmn_isQueryError = true;
143
+ }
144
  }
145
 
146
  //Retrieve list of quizzes
147
  global $wpdb;
148
+ $mlw_qmn_table_limit = 10;
149
+ $mlw_qmn_quiz_count = $wpdb->get_var( "SELECT COUNT(quiz_id) FROM " . $wpdb->prefix . "mlw_quizzes WHERE deleted='0'" );
150
+
151
+ if( isset($_GET{'mlw_quiz_page'} ) )
152
+ {
153
+ $mlw_qmn_quiz_page = $_GET{'mlw_quiz_page'} + 1;
154
+ $mlw_qmn_quiz_begin = $mlw_qmn_table_limit * $mlw_qmn_quiz_page ;
155
+ }
156
+ else
157
+ {
158
+ $mlw_qmn_quiz_page = 0;
159
+ $mlw_qmn_quiz_begin = 0;
160
+ }
161
+ $mlw_qmn_quiz_left = $mlw_qmn_quiz_count - ($mlw_qmn_quiz_page * $mlw_qmn_table_limit);
162
+ $mlw_quiz_data = $wpdb->get_results( $wpdb->prepare( "SELECT quiz_id, quiz_name, quiz_views, quiz_taken
163
+ FROM " . $wpdb->prefix . "mlw_quizzes WHERE deleted='0'
164
+ ORDER BY quiz_id DESC LIMIT %d, %d", $mlw_qmn_quiz_begin, $mlw_qmn_table_limit ) );
165
  ?>
166
  <!-- css -->
167
  <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
193
  $j( document ).tooltip();
194
  });
195
  $j(function() {
196
+ $j("button, #prev_page, #next_page").button();
197
 
198
  });
199
  $j(function() {
252
  document.getElementById("edit_quiz_name").value = quizName;
253
  document.getElementById("edit_quiz_id"). value = id;
254
  }
255
+ function duplicateQuiz(id, quizName){
256
+ $j("#duplicate_dialog").dialog({
257
+ autoOpen: false,
258
+ show: 'blind',
259
+ hide: 'explode',
260
+ buttons: {
261
+ Cancel: function() {
262
+ $j(this).dialog('close');
263
+ }
264
+ }
265
+ });
266
+ $j("#duplicate_dialog").dialog('open');
267
+ document.getElementById("duplicate_quiz_name").innerHTML = quizName;
268
+ document.getElementById("duplicate_quiz_id"). value = id;
269
+ }
270
  </script>
271
  <style>
272
  label {
291
  <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
292
  <strong>Hey!</strong> Your new quiz has been created successfully. To begin editing options and adding questions to your quiz, click on the edit link for that quiz.</p>
293
  </div>
294
+ <?php
295
+ }
296
+ if ($hasDuplicatedQuiz)
297
+ {
298
+ ?>
299
+ <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
300
+ <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
301
+ <strong>Hey!</strong> The quiz has been duplicated successfully.</p>
302
+ </div>
303
  <?php
304
  }
305
  ?>
333
  }
334
  ?>
335
  <button id="new_quiz_button_two">Create New Quiz</button>
336
+ <br />
337
  <?php
338
  $quotes_list = "";
339
  $display = "";
342
  else $alternate = " class=\"alternate\"";
343
  $quotes_list .= "<tr{$alternate}>";
344
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_id . "</span></td>";
345
+ $quotes_list .= "<td class='post-title column-title'><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_name ." </span><span style='color:green;font-size:12px;'><a onclick=\"editQuizName('".$mlw_quiz_info->quiz_id."','".str_replace("'", "\'", htmlspecialchars_decode($mlw_quiz_info->quiz_name, ENT_QUOTES))."')\" href='#'>(Edit Name)</a></span><div><span style='color:green;font-size:12px;'><a href='admin.php?page=mlw_quiz_options&&quiz_id=".$mlw_quiz_info->quiz_id."'>Edit</a> | <a onclick=\"deleteQuiz('".$mlw_quiz_info->quiz_id."','".$mlw_quiz_info->quiz_name."')\" href='#'>Delete</a> | <a href='admin.php?page=mlw_quiz_results&&quiz_id=".$mlw_quiz_info->quiz_id."'>Results</a> | <a href='#' onclick=\"duplicateQuiz('".$mlw_quiz_info->quiz_id."','".$mlw_quiz_info->quiz_name."')\">Duplicate</a></span></div></td>";
346
  $quotes_list .= "<td><span style='font-size:16px;'>[mlw_quizmaster quiz=".$mlw_quiz_info->quiz_id."]</span></td>";
347
  $quotes_list .= "<td><span style='font-size:16px;'>[mlw_quizmaster_leaderboard mlw_quiz=".$mlw_quiz_info->quiz_id."]</span></td>";
348
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_views . "</span></td>";
349
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_taken ."</span></td>";
350
  $quotes_list .= "</tr>";
351
  }
352
+
353
+ if( $mlw_qmn_quiz_page > 0 )
354
+ {
355
+ $mlw_qmn_previous_page = $mlw_qmn_quiz_page - 2;
356
+ $display .= "<a id=\"prev_page\" href=\"$_PHP_SELF?page=mlw_quiz_admin&&mlw_quiz_page=$mlw_qmn_previous_page\">Previous 10 Quizzes</a>";
357
+ if( $mlw_qmn_quiz_left > $mlw_qmn_table_limit )
358
+ {
359
+ $display .= "<a id=\"next_page\" href=\"$_PHP_SELF?page=mlw_quiz_admin&&mlw_quiz_page=$mlw_qmn_quiz_page\">Next 10 Quizzes</a>";
360
+ }
361
+ }
362
+ else if( $mlw_qmn_quiz_page == 0 )
363
+ {
364
+ if( $mlw_qmn_quiz_left > $mlw_qmn_table_limit )
365
+ {
366
+ $display .= "<a id=\"next_page\" href=\"$_PHP_SELF?page=mlw_quiz_admin&&mlw_quiz_page=$mlw_qmn_quiz_page\">Next 10 Quizzes</a>";
367
+ }
368
+ }
369
+ else if( $mlw_qmn_quiz_left < $mlw_qmn_table_limit )
370
+ {
371
+ $mlw_qmn_previous_page = $mlw_qmn_quiz_page - 2;
372
+ $display .= "<a id=\"prev_page\" href=\"$_PHP_SELF?page=mlw_quiz_admin&&mlw_quiz_page=$mlw_qmn_previous_page\">Previous 10 Quizzes</a>";
373
+ }
374
 
375
  $display .= "<table class=\"widefat\">";
376
  $display .= "<thead><tr>
432
  <input type="submit" class="button-primary" value="Edit" />
433
  </form>
434
  </div>
435
+ <div id="duplicate_dialog" title="Duplicate Quiz" style="display:none;">
436
+ <h3>This will create a new quiz with the same settings as <span id="duplicate_quiz_name"></span>. </h3><br />
437
+ <p>This does not currently duplicate the questions, only the options, templates, settings, etc...</p>
438
+ <?php
439
+ echo "<form action='" . $PHP_SELF . "' method='post'>";
440
+ ?>
441
+ Name Of New Quiz:
442
+ <input type="text" id="duplicate_new_quiz_name" name="duplicate_new_quiz_name" />
443
+ <input type="hidden" id="duplicate_quiz_id" name="duplicate_quiz_id" />
444
+ <input type='hidden' name='duplicate_quiz' value='confirmation' />
445
+ <input type="submit" class="button-primary" value="Duplicate" />
446
+ </form>
447
+ </div>
448
  <div id="delete_dialog" title="Delete Quiz?" style="display:none;">
449
  <h3><b>Are you sure you want to delete Quiz <span id="delete_quiz_id"></span>?</b></h3>
450
  <?php
includes/mlw_quiz_options.php CHANGED
@@ -13,6 +13,7 @@ function mlw_generate_quiz_options()
13
  $table_name = $wpdb->prefix . "mlw_questions";
14
  $is_new_quiz = 0;
15
  $mlw_qmn_isQueryError = false;
 
16
 
17
  /*
18
  Code for quiz questions tab
@@ -85,6 +86,7 @@ function mlw_generate_quiz_options()
85
  else
86
  {
87
  $mlw_qmn_isQueryError = true;
 
88
  }
89
  }
90
 
@@ -114,6 +116,7 @@ function mlw_generate_quiz_options()
114
  else
115
  {
116
  $mlw_qmn_isQueryError = true;
 
117
  }
118
  }
119
 
@@ -141,6 +144,7 @@ function mlw_generate_quiz_options()
141
  else
142
  {
143
  $mlw_qmn_isQueryError = true;
 
144
  }
145
  }
146
 
@@ -148,10 +152,23 @@ function mlw_generate_quiz_options()
148
  if ($quiz_id != "")
149
  {
150
  global $wpdb;
151
- $table_name = $wpdb->prefix . "mlw_questions";
152
- $sql = "SELECT * FROM " . $table_name . " WHERE quiz_id=".$quiz_id." AND deleted=0";
153
- $sql .= " ORDER BY question_order ASC";
154
- $mlw_question_data = $wpdb->get_results($sql);
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  $is_new_quiz = $wpdb->num_rows;
156
  }
157
 
@@ -197,6 +214,7 @@ function mlw_generate_quiz_options()
197
  else
198
  {
199
  $mlw_qmn_isQueryError = true;
 
200
  }
201
  }
202
 
@@ -241,6 +259,7 @@ function mlw_generate_quiz_options()
241
  else
242
  {
243
  $mlw_qmn_isQueryError = true;
 
244
  }
245
  }
246
 
@@ -274,6 +293,7 @@ function mlw_generate_quiz_options()
274
  else
275
  {
276
  $mlw_qmn_isQueryError = true;
 
277
  }
278
  }
279
 
@@ -307,6 +327,7 @@ function mlw_generate_quiz_options()
307
  else
308
  {
309
  $mlw_qmn_isQueryError = true;
 
310
  }
311
  }
312
 
@@ -492,7 +513,7 @@ function mlw_generate_quiz_options()
492
  $j( "#edit_comments" ).buttonset();
493
  });
494
  $j(function() {
495
- $j("button").button();
496
 
497
  });
498
  $j(function() {
@@ -601,7 +622,7 @@ function mlw_generate_quiz_options()
601
  ?>
602
  <div class="ui-state-error ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
603
  <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
604
- <strong>Uh-Oh!</strong> There has been an error in this action!</p>
605
  </div>
606
  <?php
607
  }
@@ -675,6 +696,7 @@ function mlw_generate_quiz_options()
675
  </ul>
676
  <div id="tabs-1">
677
  <button id="new_question_button_two">Add Question</button><button id="question_tab_help">Help</button>
 
678
  <?php
679
  $question_list = "";
680
  $display = "";
@@ -686,6 +708,28 @@ function mlw_generate_quiz_options()
686
  $question_list .= "<td class='post-title column-title'><span style='font-size:16px;'>" . $mlw_question_info->question_name ."</span><div><span style='color:green;font-size:12px;'><a onclick=\"editQuestion('".$mlw_question_info->question_id."','".str_replace('"', '&quot;', str_replace("'", "\'", htmlspecialchars_decode($mlw_question_info->question_name, ENT_QUOTES)))."', '".str_replace("'", "\'", htmlspecialchars_decode($mlw_question_info->answer_one, ENT_QUOTES))."','".$mlw_question_info->answer_one_points."','".str_replace("'", "\'", htmlspecialchars_decode($mlw_question_info->answer_two, ENT_QUOTES))."','".$mlw_question_info->answer_two_points."','".str_replace("'", "\'", htmlspecialchars_decode($mlw_question_info->answer_three, ENT_QUOTES))."','".$mlw_question_info->answer_three_points."','".str_replace("'", "\'", htmlspecialchars_decode($mlw_question_info->answer_four, ENT_QUOTES))."','".$mlw_question_info->answer_four_points."','".str_replace("'", "\'", htmlspecialchars_decode($mlw_question_info->answer_five, ENT_QUOTES))."','".$mlw_question_info->answer_five_points."','".str_replace("'", "\'", htmlspecialchars_decode($mlw_question_info->answer_six, ENT_QUOTES))."','".$mlw_question_info->answer_six_points."','".$mlw_question_info->correct_answer."', '".$mlw_question_info->question_answer_info."', '".$mlw_question_info->comments."','".$mlw_question_info->hints."', '".$mlw_question_info->question_order."', '".$mlw_question_info->question_type."')\" href='#'>Edit</a> | <a onclick=\"deleteQuestion('".$mlw_question_info->question_id."')\" href='#'>Delete</a></span></div></td>";
687
  $question_list .= "</tr>";
688
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
689
 
690
  $display .= "<table class=\"widefat\">";
691
  $display .= "<thead><tr>
@@ -806,7 +850,7 @@ function mlw_generate_quiz_options()
806
  <td><input type="radio" name="correct_answer" value=6 /></td>
807
  </tr>
808
  <tr>
809
- <td><span style='font-weight:bold;'>Correct Answer Info:</span></td>
810
  <td colspan="3"><input type="text" name="correct_answer_info" value="" id="correct_answer_info" style="border-color:#000000;
811
  color:#3300CC;
812
  cursor:hand;"/></td>
13
  $table_name = $wpdb->prefix . "mlw_questions";
14
  $is_new_quiz = 0;
15
  $mlw_qmn_isQueryError = false;
16
+ $mlw_qmn_error_code = '0000';
17
 
18
  /*
19
  Code for quiz questions tab
86
  else
87
  {
88
  $mlw_qmn_isQueryError = true;
89
+ $mlw_qmn_error_code = '0004';
90
  }
91
  }
92
 
116
  else
117
  {
118
  $mlw_qmn_isQueryError = true;
119
+ $mlw_qmn_error_code = '0002';
120
  }
121
  }
122
 
144
  else
145
  {
146
  $mlw_qmn_isQueryError = true;
147
+ $mlw_qmn_error_code = '0006';
148
  }
149
  }
150
 
152
  if ($quiz_id != "")
153
  {
154
  global $wpdb;
155
+ $mlw_qmn_table_limit = 10;
156
+ $mlw_qmn_question_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(question_id) FROM " . $wpdb->prefix . "mlw_questions WHERE quiz_id=%d AND deleted='0'", $quiz_id ) );
157
+
158
+ if( isset($_GET{'mlw_question_page'} ) )
159
+ {
160
+ $mlw_qmn_question_page = $_GET{'mlw_question_page'} + 1;
161
+ $mlw_qmn_question_begin = $mlw_qmn_table_limit * $mlw_qmn_question_page ;
162
+ }
163
+ else
164
+ {
165
+ $mlw_qmn_question_page = 0;
166
+ $mlw_qmn_question_begin = 0;
167
+ }
168
+ $mlw_qmn_question_left = $mlw_qmn_question_count - ($mlw_qmn_question_page * $mlw_qmn_table_limit);
169
+
170
+ $mlw_question_data = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "mlw_questions WHERE quiz_id=%d AND deleted='0'
171
+ ORDER BY question_order ASC LIMIT %d, %d", $quiz_id, $mlw_qmn_question_begin, $mlw_qmn_table_limit ) );
172
  $is_new_quiz = $wpdb->num_rows;
173
  }
174
 
214
  else
215
  {
216
  $mlw_qmn_isQueryError = true;
217
+ $mlw_qmn_error_code = '0007';
218
  }
219
  }
220
 
259
  else
260
  {
261
  $mlw_qmn_isQueryError = true;
262
+ $mlw_qmn_error_code = '0008';
263
  }
264
  }
265
 
293
  else
294
  {
295
  $mlw_qmn_isQueryError = true;
296
+ $mlw_qmn_error_code = '0009';
297
  }
298
  }
299
 
327
  else
328
  {
329
  $mlw_qmn_isQueryError = true;
330
+ $mlw_qmn_error_code = '0010';
331
  }
332
  }
333
 
513
  $j( "#edit_comments" ).buttonset();
514
  });
515
  $j(function() {
516
+ $j("button, #prev_page, #next_page").button();
517
 
518
  });
519
  $j(function() {
622
  ?>
623
  <div class="ui-state-error ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
624
  <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
625
+ <strong>Uh-Oh!</strong> There has been an error in this action! Please share this with the developer: Error Code <?php echo $mlw_qmn_error_code; ?></p>
626
  </div>
627
  <?php
628
  }
696
  </ul>
697
  <div id="tabs-1">
698
  <button id="new_question_button_two">Add Question</button><button id="question_tab_help">Help</button>
699
+ <br />
700
  <?php
701
  $question_list = "";
702
  $display = "";
708
  $question_list .= "<td class='post-title column-title'><span style='font-size:16px;'>" . $mlw_question_info->question_name ."</span><div><span style='color:green;font-size:12px;'><a onclick=\"editQuestion('".$mlw_question_info->question_id."','".str_replace('"', '&quot;', str_replace("'", "\'", htmlspecialchars_decode($mlw_question_info->question_name, ENT_QUOTES)))."', '".str_replace("'", "\'", htmlspecialchars_decode($mlw_question_info->answer_one, ENT_QUOTES))."','".$mlw_question_info->answer_one_points."','".str_replace("'", "\'", htmlspecialchars_decode($mlw_question_info->answer_two, ENT_QUOTES))."','".$mlw_question_info->answer_two_points."','".str_replace("'", "\'", htmlspecialchars_decode($mlw_question_info->answer_three, ENT_QUOTES))."','".$mlw_question_info->answer_three_points."','".str_replace("'", "\'", htmlspecialchars_decode($mlw_question_info->answer_four, ENT_QUOTES))."','".$mlw_question_info->answer_four_points."','".str_replace("'", "\'", htmlspecialchars_decode($mlw_question_info->answer_five, ENT_QUOTES))."','".$mlw_question_info->answer_five_points."','".str_replace("'", "\'", htmlspecialchars_decode($mlw_question_info->answer_six, ENT_QUOTES))."','".$mlw_question_info->answer_six_points."','".$mlw_question_info->correct_answer."', '".$mlw_question_info->question_answer_info."', '".$mlw_question_info->comments."','".$mlw_question_info->hints."', '".$mlw_question_info->question_order."', '".$mlw_question_info->question_type."')\" href='#'>Edit</a> | <a onclick=\"deleteQuestion('".$mlw_question_info->question_id."')\" href='#'>Delete</a></span></div></td>";
709
  $question_list .= "</tr>";
710
  }
711
+
712
+ if( $mlw_qmn_question_page > 0 )
713
+ {
714
+ $mlw_qmn_previous_page = $mlw_qmn_question_page - 2;
715
+ $display .= "<a id=\"prev_page\" href=\"$_PHP_SELF?page=mlw_quiz_options&&mlw_question_page=$mlw_qmn_previous_page&&quiz_id=$quiz_id\">Previous 10 Questions</a>";
716
+ if( $mlw_qmn_question_left > $mlw_qmn_table_limit )
717
+ {
718
+ $display .= "<a id=\"next_page\" href=\"$_PHP_SELF?page=mlw_quiz_options&&mlw_question_page=$mlw_qmn_question_page&&quiz_id=$quiz_id\">Next 10 Questions</a>";
719
+ }
720
+ }
721
+ else if( $mlw_qmn_question_page == 0 )
722
+ {
723
+ if( $mlw_qmn_question_left > $mlw_qmn_table_limit )
724
+ {
725
+ $display .= "<a id=\"next_page\" href=\"$_PHP_SELF?page=mlw_quiz_options&&mlw_question_page=$mlw_qmn_question_page&&quiz_id=$quiz_id\">Next 10 Questions</a>";
726
+ }
727
+ }
728
+ else if( $mlw_qmn_question_left < $mlw_qmn_table_limit )
729
+ {
730
+ $mlw_qmn_previous_page = $mlw_qmn_question_page - 2;
731
+ $display .= "<a id=\"prev_page\" href=\"$_PHP_SELF?page=mlw_quiz_options&&mlw_question_page=$mlw_qmn_previous_page&&quiz_id=$quiz_id\">Previous 10 Questions</a>";
732
+ }
733
 
734
  $display .= "<table class=\"widefat\">";
735
  $display .= "<thead><tr>
850
  <td><input type="radio" name="correct_answer" value=6 /></td>
851
  </tr>
852
  <tr>
853
+ <td><span style='font-weight:bold;'>Correct Answer Info<a href="#" title="Enter in the reason why the correct answer is correct. Add this to the %QUESTIONS_ANSWERS% template using the new %CORRECT_ANSWER_INFO% variable.">?</a></span></td>
854
  <td colspan="3"><input type="text" name="correct_answer_info" value="" id="correct_answer_info" style="border-color:#000000;
855
  color:#3300CC;
856
  cursor:hand;"/></td>
includes/mlw_results_details.php CHANGED
@@ -68,7 +68,7 @@ function mlw_generate_result_details()
68
  <h2>Quiz Results<a id="opener" href="">(?)</a></h2>
69
  <?php
70
  foreach($mlw_results_data as $mlw_results_info) {
71
- echo $mlw_results_info->quiz_results;
72
  }
73
  ?>
74
  <div id="dialog" title="Help">
68
  <h2>Quiz Results<a id="opener" href="">(?)</a></h2>
69
  <?php
70
  foreach($mlw_results_data as $mlw_results_info) {
71
+ echo htmlspecialchars_decode($mlw_results_info->quiz_results, ENT_QUOTES);
72
  }
73
  ?>
74
  <div id="dialog" title="Help">
includes/mlw_tools.php CHANGED
@@ -35,6 +35,10 @@ function mlw_generate_quiz_tools(){
35
  return false;
36
  } );
37
  });
 
 
 
 
38
  </script>
39
  <style type="text/css">
40
  textarea{
@@ -70,12 +74,25 @@ function mlw_generate_quiz_tools(){
70
  function mlw_tools_box()
71
  {
72
  global $wpdb;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
- $sql = "SELECT trail_id, action_user, action, time
75
- FROM " . $wpdb->prefix . "mlw_qm_audit_trail ";
76
- $sql .= "ORDER BY trail_id DESC";
77
-
78
- $audit_trails = $wpdb->get_results($sql);
79
  $quotes_list = "";
80
  $display = "";
81
  foreach($audit_trails as $quote_data) {
@@ -89,6 +106,27 @@ function mlw_tools_box()
89
  $quotes_list .= "</tr>";
90
  }
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  $display .= "<table class=\"widefat\">";
93
  $display .= "<thead><tr>
94
  <th>ID</th>
35
  return false;
36
  } );
37
  });
38
+ $j(function() {
39
+ $j("button, #prev_page, #next_page").button();
40
+
41
+ });
42
  </script>
43
  <style type="text/css">
44
  textarea{
74
  function mlw_tools_box()
75
  {
76
  global $wpdb;
77
+ $mlw_qmn_table_limit = 25;
78
+ $mlw_qmn_audit_count = $wpdb->get_var( "SELECT COUNT(trail_id) FROM " . $wpdb->prefix . "mlw_qm_audit_trail" );
79
+
80
+ if( isset($_GET{'mlw_audit_page'} ) )
81
+ {
82
+ $mlw_qmn_audit_page = $_GET{'mlw_audit_page'} + 1;
83
+ $mlw_qmn_audit_begin = $mlw_qmn_table_limit * $mlw_qmn_audit_page ;
84
+ }
85
+ else
86
+ {
87
+ $mlw_qmn_audit_page = 0;
88
+ $mlw_qmn_audit_begin = 0;
89
+ }
90
+ $mlw_qmn_audit_left = $mlw_qmn_audit_count - ($mlw_qmn_audit_page * $mlw_qmn_table_limit);
91
+
92
+ $audit_trails = $wpdb->get_results( $wpdb->prepare( "SELECT trail_id, action_user, action, time
93
+ FROM " . $wpdb->prefix . "mlw_qm_audit_trail
94
+ ORDER BY trail_id DESC LIMIT %d, %d", $mlw_qmn_audit_begin, $mlw_qmn_table_limit ) );
95
 
 
 
 
 
 
96
  $quotes_list = "";
97
  $display = "";
98
  foreach($audit_trails as $quote_data) {
106
  $quotes_list .= "</tr>";
107
  }
108
 
109
+ if( $mlw_qmn_audit_page > 0 )
110
+ {
111
+ $mlw_qmn_previous_page = $mlw_qmn_audit_page - 2;
112
+ $display .= "<a id=\"prev_page\" href=\"$_PHP_SELF?page=mlw_quiz_tools&&mlw_audit_page=$mlw_qmn_previous_page\">Previous 25 Audits</a>";
113
+ if( $mlw_qmn_audit_left > $mlw_qmn_table_limit )
114
+ {
115
+ $display .= "<a id=\"next_page\" href=\"$_PHP_SELF?page=mlw_quiz_tools&&mlw_audit_page=$mlw_qmn_audit_page\">Next 25 Audits</a>";
116
+ }
117
+ }
118
+ else if( $mlw_qmn_audit_page == 0 )
119
+ {
120
+ if( $mlw_qmn_audit_left > $mlw_qmn_table_limit )
121
+ {
122
+ $display .= "<a id=\"next_page\" href=\"$_PHP_SELF?page=mlw_quiz_tools&&mlw_audit_page=$mlw_qmn_audit_page\">Next 25 Audits</a>";
123
+ }
124
+ }
125
+ else if( $mlw_qmn_audit_left < $mlw_qmn_table_limit )
126
+ {
127
+ $mlw_qmn_previous_page = $mlw_qmn_audit_page - 2;
128
+ $display .= "<a id=\"prev_page\" href=\"$_PHP_SELF?page=mlw_quiz_tools&&mlw_audit_page=$mlw_qmn_previous_page\">Previous 25 Audits</a>";
129
+ }
130
  $display .= "<table class=\"widefat\">";
131
  $display .= "<thead><tr>
132
  <th>ID</th>
includes/mlw_update.php CHANGED
@@ -6,7 +6,7 @@ function mlw_quiz_update()
6
  {
7
 
8
  //Update this variable each update. This is what is checked when the plugin is deciding to run the upgrade script or not.
9
- $data = "1.1.1";
10
  if ( ! get_option('mlw_quiz_master_version'))
11
  {
12
  add_option('mlw_quiz_master_version' , $data);
6
  {
7
 
8
  //Update this variable each update. This is what is checked when the plugin is deciding to run the upgrade script or not.
9
+ $data = "1.2.1";
10
  if ( ! get_option('mlw_quiz_master_version'))
11
  {
12
  add_option('mlw_quiz_master_version' , $data);
mlw_quizmaster2.php CHANGED
@@ -3,7 +3,7 @@
3
  /*
4
  Plugin Name: Quiz Master Next
5
  Description: Use this plugin to add multiple quizzes, tests, or surveys to your website.
6
- Version: 1.1.1
7
  Author: Frank Corso
8
  Author URI: http://www.mylocalwebstop.com/
9
  Plugin URI: http://www.mylocalwebstop.com/
3
  /*
4
  Plugin Name: Quiz Master Next
5
  Description: Use this plugin to add multiple quizzes, tests, or surveys to your website.
6
+ Version: 1.2.1
7
  Author: Frank Corso
8
  Author URI: http://www.mylocalwebstop.com/
9
  Plugin URI: http://www.mylocalwebstop.com/
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: fpcorso
3
  Tags: quiz, test, score, survey, contact
4
  Requires at least: 3.3
5
  Tested up to: 3.8.1
6
- Stable tag: 1.1.1
7
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
 
9
  Use this plugin to add multiple quizzes, tests, surveys, or contact forms to your website.
@@ -65,6 +65,12 @@ Feel free to use the widget on the quiz dashboard within the plugin or from the
65
 
66
  == Changelog ==
67
 
 
 
 
 
 
 
68
  = 1.1.1 (February 6, 2014) =
69
  * Added %AVERAGE_POINT% Variable That Calculates Average Points Per Question
70
  * Added Field For Reason Why Answer Is Correct
@@ -249,6 +255,9 @@ Feel free to use the widget on the quiz dashboard within the plugin or from the
249
 
250
  == Upgrade Notice ==
251
 
 
 
 
252
  = 1.1.1 =
253
  This update adds the ability to show the user the reason why an answer is correct. Also, added new variable for templates that calculates average points per question. Minor bug fixes.
254
 
3
  Tags: quiz, test, score, survey, contact
4
  Requires at least: 3.3
5
  Tested up to: 3.8.1
6
+ Stable tag: 1.2.1
7
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
 
9
  Use this plugin to add multiple quizzes, tests, surveys, or contact forms to your website.
65
 
66
  == Changelog ==
67
 
68
+ = 1.2.1 (February 11, 2014) =
69
+ * Fixed Quiz Results Details Bug
70
+ * Continued Working On New Error Code System
71
+ * Added Pagination To Tools Page, Quizzes Page And List Of Questions On Quiz Options Page
72
+ * Added Ability To Create A Duplicate Of A Quiz
73
+
74
  = 1.1.1 (February 6, 2014) =
75
  * Added %AVERAGE_POINT% Variable That Calculates Average Points Per Question
76
  * Added Field For Reason Why Answer Is Correct
255
 
256
  == Upgrade Notice ==
257
 
258
+ = 1.2.1 =
259
+ This update adds pagination to the quizzes, audit trail, and question tables to make using the admin side easier. It also adds the ability to duplicate a quiz. Fixes various minor bugs.
260
+
261
  = 1.1.1 =
262
  This update adds the ability to show the user the reason why an answer is correct. Also, added new variable for templates that calculates average points per question. Minor bug fixes.
263