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

Version Description

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.

Download this release

Release Info

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

Code changes from version 1.0.1 to 1.1.1

assets/screenshot-2.png CHANGED
Binary file
includes/mlw_dashboard.php CHANGED
@@ -410,16 +410,25 @@ function mlw_dashboard_box_six()
410
  <div>
411
  <table width='100%'>
412
  <tr>
413
- <td align='left'>1.0 (February 1, 2014)</td>
414
  </tr>
415
  <tr>
416
- <td align='left'>* Added Ability To Customize From Name For User And Admin Emails</td>
417
  </tr>
418
  <tr>
419
- <td align='left'>* Changed Question Editor</td>
420
  </tr>
421
  <tr>
422
- <td align='left'>* Minor Change To Help System</td>
 
 
 
 
 
 
 
 
 
423
  </tr>
424
  </table>
425
  </div>
@@ -537,6 +546,8 @@ function mlw_dashboard_box_eight()
537
  <li>Tracy B</li>
538
  <li>Bobby L</li>
539
  <li>Kristal P</li>
 
 
540
  </ul>
541
  </div>
542
  <?php
410
  <div>
411
  <table width='100%'>
412
  <tr>
413
+ <td align='left'>1.1.1 (February 6, 2014)</td>
414
  </tr>
415
  <tr>
416
+ <td align='left'>* Added %AVERAGE_POINT% Variable That Calculates Average Points Per Question</td>
417
  </tr>
418
  <tr>
419
+ <td align='left'>* Added Field For Reason Why Answer Is Correct</td>
420
  </tr>
421
  <tr>
422
+ <td align='left'>* Added %CORRECT_ANSWER_INFO% To Display Why Answer Is Correct</td>
423
+ </tr>
424
+ <tr>
425
+ <td align='left'>* Begun Creating New Error Code System</td>
426
+ </tr>
427
+ <tr>
428
+ <td align='left'>* Fixed Edit Quiz Name Bug</td>
429
+ </tr>
430
+ <tr>
431
+ <td align='left'>* Fixed New Quiz Bug</td>
432
  </tr>
433
  </table>
434
  </div>
546
  <li>Tracy B</li>
547
  <li>Bobby L</li>
548
  <li>Kristal P</li>
549
+ <li>Jürgen C</li>
550
+ <li>Larry J</li>
551
  </ul>
552
  </div>
553
  <?php
includes/mlw_quiz.php CHANGED
@@ -429,6 +429,7 @@ function mlw_quiz_shortcode($atts)
429
  $mlw_question_answer_display = str_replace( "%USER_ANSWER%" , $mlw_user_text, $mlw_question_answer_display);
430
  $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER%" , $mlw_correct_text, $mlw_question_answer_display);
431
  $mlw_question_answer_display = str_replace( "%USER_COMMENTS%" , $_POST["mlwComment".$mlw_question->question_id], $mlw_question_answer_display);
 
432
 
433
  $mlw_question_answers .= $mlw_question_answer_display;
434
  $mlw_question_answers .= "<br />";
@@ -438,6 +439,7 @@ function mlw_quiz_shortcode($atts)
438
  //Prepare the after quiz message
439
  $mlw_message_after = $mlw_quiz_options->message_after;
440
  $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
 
441
  $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
442
  $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
443
  $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
@@ -459,6 +461,7 @@ function mlw_quiz_shortcode($atts)
459
  {
460
  $mlw_message = $mlw_quiz_options->user_email_template;
461
  $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
 
462
  $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
463
  $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
464
  $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
@@ -481,6 +484,7 @@ function mlw_quiz_shortcode($atts)
481
  {
482
  $mlw_message = $mlw_quiz_options->admin_email_template;
483
  $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
 
484
  $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
485
  $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
486
  $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
429
  $mlw_question_answer_display = str_replace( "%USER_ANSWER%" , $mlw_user_text, $mlw_question_answer_display);
430
  $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER%" , $mlw_correct_text, $mlw_question_answer_display);
431
  $mlw_question_answer_display = str_replace( "%USER_COMMENTS%" , $_POST["mlwComment".$mlw_question->question_id], $mlw_question_answer_display);
432
+ $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER_INFO%" , $mlw_question->question_answer_info, $mlw_question_answer_display);
433
 
434
  $mlw_question_answers .= $mlw_question_answer_display;
435
  $mlw_question_answers .= "<br />";
439
  //Prepare the after quiz message
440
  $mlw_message_after = $mlw_quiz_options->message_after;
441
  $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
442
+ $mlw_message_after = str_replace( "%AVERAGE_POINT%" , round(($mlw_points/$mlw_total_questions), 2), $mlw_message_after);
443
  $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
444
  $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
445
  $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
461
  {
462
  $mlw_message = $mlw_quiz_options->user_email_template;
463
  $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
464
+ $mlw_message = str_replace( "%AVERAGE_POINT%" , round(($mlw_points/$mlw_total_questions), 2), $mlw_message);
465
  $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
466
  $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
467
  $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
484
  {
485
  $mlw_message = $mlw_quiz_options->admin_email_template;
486
  $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
487
+ $mlw_message = str_replace( "%AVERAGE_POINT%" , round(($mlw_points/$mlw_total_questions), 2), $mlw_message);
488
  $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
489
  $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
490
  $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
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
 
18
  //Create new quiz
19
  if ($success == "confirmation")
@@ -27,19 +29,27 @@ function mlw_generate_quiz_admin()
27
  5. %FIFTH_PLACE_NAME%-%FIFTH_PLACE_SCORE%<br />";
28
  $mlw_question_answer_default = "%QUESTION%<br /> Answer Provided: %USER_ANSWER%<br /> Correct Answer: %CORRECT_ANSWER%<br /> Comments Entered: %USER_COMMENTS%<br />";
29
  $insert = "INSERT INTO " . $table_name .
30
- "(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, question_answer_template, leaderboard_template, system, randomness_order, show_score, send_user_email, send_admin_email, user_name, user_comp, user_email, user_phone, admin_email, comment_section, quiz_views, quiz_taken, deleted) " .
31
- "VALUES (NULL , '" . $quiz_name . "' , 'Enter your text here', 'Enter your text here', 'Enter your text here', 'Enter your text here', 'Enter your text here', 'Submit Quiz', 'Name', 'Business', 'Email', 'Phone Number', 'Comments', '".$mlw_question_answer_default."', '".$mlw_leaderboard_default."', 0, 0, 0, 0, 0, 0, 0, 0, 0, '".get_option( 'admin_email', 'Enter email' )."', 0, 0, 0, 0)";
32
  $results = $wpdb->query( $insert );
33
- $hasCreatedQuiz = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
- //Insert Action Into Audit Trail
36
- global $current_user;
37
- get_currentuserinfo();
38
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
39
- $insert = "INSERT INTO " . $table_name .
40
- "(trail_id, action_user, action, time) " .
41
- "VALUES (NULL , '" . $current_user->display_name . "' , 'New Quiz Has Been Created: ".$quiz_name."' , '" . date("h:i:s A m/d/Y") . "')";
42
- $results = $wpdb->query( $insert );
43
  }
44
 
45
  //Variables from delete question form
@@ -212,7 +222,16 @@ function mlw_generate_quiz_admin()
212
  <?php
213
  }
214
  ?>
215
- <?php if ($hasDeletedQuiz)
 
 
 
 
 
 
 
 
 
216
  {
217
  ?>
218
  <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
@@ -241,7 +260,7 @@ function mlw_generate_quiz_admin()
241
  else $alternate = " class=\"alternate\"";
242
  $quotes_list .= "<tr{$alternate}>";
243
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_id . "</span></td>";
244
- $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."','".$mlw_quiz_info->quiz_name."')\" 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>";
245
  $quotes_list .= "<td><span style='font-size:16px;'>[mlw_quizmaster quiz=".$mlw_quiz_info->quiz_id."]</span></td>";
246
  $quotes_list .= "<td><span style='font-size:16px;'>[mlw_quizmaster_leaderboard mlw_quiz=".$mlw_quiz_info->quiz_id."]</span></td>";
247
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_views . "</span></td>";
14
  $quiz_name = $_POST["quiz_name"];
15
  $hasCreatedQuiz = false;
16
  $hasDeletedQuiz = false;
17
+ $mlw_qmn_isQueryError = false;
18
+ $mlw_qmn_error_code = '0';
19
 
20
  //Create new quiz
21
  if ($success == "confirmation")
29
  5. %FIFTH_PLACE_NAME%-%FIFTH_PLACE_SCORE%<br />";
30
  $mlw_question_answer_default = "%QUESTION%<br /> Answer Provided: %USER_ANSWER%<br /> Correct Answer: %CORRECT_ANSWER%<br /> Comments Entered: %USER_COMMENTS%<br />";
31
  $insert = "INSERT INTO " . $table_name .
32
+ "(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) " .
33
+ "VALUES (NULL , '" . $quiz_name . "' , 'Enter your text here', 'Enter your text here', 'Enter your text here', 'Enter your text here', 'Enter your text here', 'Submit Quiz', 'Name', 'Business', 'Email', 'Phone Number', 'Comments', 'Wordpress', '".$mlw_question_answer_default."', '".$mlw_leaderboard_default."', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '".get_option( 'admin_email', 'Enter email' )."', 0, 0, 0, 0)";
34
  $results = $wpdb->query( $insert );
35
+ if ($results != false)
36
+ {
37
+ $hasCreatedQuiz = true;
38
+ //Insert Action Into Audit Trail
39
+ global $current_user;
40
+ get_currentuserinfo();
41
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
42
+ $insert = "INSERT INTO " . $table_name .
43
+ "(trail_id, action_user, action, time) " .
44
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'New Quiz Has Been Created: ".$quiz_name."' , '" . date("h:i:s A m/d/Y") . "')";
45
+ $results = $wpdb->query( $insert );
46
+ }
47
+ else
48
+ {
49
+ $mlw_qmn_error_code = '0001';
50
+ $mlw_qmn_isQueryError = true;
51
+ }
52
 
 
 
 
 
 
 
 
 
53
  }
54
 
55
  //Variables from delete question form
222
  <?php
223
  }
224
  ?>
225
+ <?php if ($mlw_qmn_isQueryError)
226
+ {
227
+ ?>
228
+ <div class="ui-state-error ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
229
+ <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
230
+ <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>
231
+ </div>
232
+ <?php
233
+ }
234
+ if ($hasDeletedQuiz)
235
  {
236
  ?>
237
  <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
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>";
includes/mlw_quiz_install.php CHANGED
@@ -127,6 +127,8 @@ function mlw_quiz_activate()
127
 
128
  correct_answer INT NOT NULL,
129
 
 
 
130
  comments INT NOT NULL,
131
 
132
  hints TEXT NOT NULL,
127
 
128
  correct_answer INT NOT NULL,
129
 
130
+ question_answer_info TEXT NOT NULL,
131
+
132
  comments INT NOT NULL,
133
 
134
  hints TEXT NOT NULL,
includes/mlw_quiz_options.php CHANGED
@@ -12,7 +12,7 @@ function mlw_generate_quiz_options()
12
  global $wpdb;
13
  $table_name = $wpdb->prefix . "mlw_questions";
14
  $is_new_quiz = 0;
15
- $mlw_qmn_hasEditedSocial = false;
16
 
17
  /*
18
  Code for quiz questions tab
@@ -34,6 +34,7 @@ function mlw_generate_quiz_options()
34
  $answer_six = htmlspecialchars($_POST["answer_six"], ENT_QUOTES);
35
  $answer_six_points = $_POST["answer_six_points"];
36
  $correct_answer = $_POST["correct_answer"];
 
37
  $question_type = $_POST["question_type"];
38
  $comments = $_POST["comments"];
39
  $hint = $_POST["hint"];
@@ -55,6 +56,7 @@ function mlw_generate_quiz_options()
55
  $edit_answer_six = htmlspecialchars($_POST["edit_answer_six"], ENT_QUOTES);
56
  $edit_answer_six_points = $_POST["edit_answer_six_points"];
57
  $edit_correct_answer = $_POST["edit_correct_answer"];
 
58
  $mlw_edit_question_id = $_POST["edit_question_id"];
59
  $mlw_edit_question_type = $_POST["edit_question_type"];
60
  $edit_comments = $_POST["edit_comments"];
@@ -65,18 +67,25 @@ function mlw_generate_quiz_options()
65
  if ($edit_question_success == "confirmation")
66
  {
67
  $quiz_id = $_POST["quiz_id"];
68
- $update = "UPDATE " . $wpdb->prefix . "mlw_questions" . " SET question_name='".$edit_question_name."', answer_one='".$edit_answer_one."', answer_one_points='".$edit_answer_one_points."', answer_two='".$edit_answer_two."', answer_two_points='".$edit_answer_two_points."', answer_three='".$edit_answer_three."', answer_three_points='".$edit_answer_three_points."', answer_four='".$edit_answer_four."', answer_four_points='".$edit_answer_four_points."', answer_five='".$edit_answer_five."', answer_five_points='".$edit_answer_five_points."', answer_six='".$edit_answer_six."', answer_six_points='".$edit_answer_six_points."', correct_answer='".$edit_correct_answer."', comments='".$edit_comments."', hints='".$edit_hint."', question_order='".$edit_question_order."', question_type='".$mlw_edit_question_type."' WHERE question_id=".$mlw_edit_question_id;
69
  $results = $wpdb->query( $update );
70
- $hasUpdatedQuestion = true;
 
 
71
 
72
- //Insert Action Into Audit Trail
73
- global $current_user;
74
- get_currentuserinfo();
75
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
76
- $insert = "INSERT INTO " . $table_name .
77
- "(trail_id, action_user, action, time) " .
78
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Question Has Been Edited: ".$edit_question_name."' , '" . date("h:i:s A m/d/Y") . "')";
79
- $results = $wpdb->query( $insert );
 
 
 
 
 
80
  }
81
 
82
  //Variables from delete question form
@@ -89,16 +98,23 @@ function mlw_generate_quiz_options()
89
  $quiz_id = $_POST["quiz_id"];
90
  $update = "UPDATE " . $wpdb->prefix . "mlw_questions" . " SET deleted=1 WHERE question_id=".$mlw_question_id;
91
  $results = $wpdb->query( $update );
92
- $hasDeletedQuestion = true;
 
 
93
 
94
- //Insert Action Into Audit Trail
95
- global $current_user;
96
- get_currentuserinfo();
97
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
98
- $insert = "INSERT INTO " . $table_name .
99
- "(trail_id, action_user, action, time) " .
100
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Question Has Been Deleted: ".$mlw_question_id."' , '" . date("h:i:s A m/d/Y") . "')";
101
- $results = $wpdb->query( $insert );
 
 
 
 
 
102
  }
103
 
104
  //Submit new question into database
@@ -107,18 +123,25 @@ function mlw_generate_quiz_options()
107
  $quiz_id = $_POST["quiz_id"];
108
  $table_name = $wpdb->prefix . "mlw_questions";
109
  $insert = "INSERT INTO " . $table_name .
110
- " (question_id, quiz_id, question_name, answer_one, answer_one_points, answer_two, answer_two_points, answer_three, answer_three_points, answer_four, answer_four_points, answer_five, answer_five_points, answer_six, answer_six_points, correct_answer, comments, hints, question_order, question_type, deleted) VALUES (NULL , ".$quiz_id.", '" . $question_name . "' , '" . $answer_one . "', ".$answer_one_points.", '" . $answer_two . "', ".$answer_two_points.", '" . $answer_three . "', ".$answer_three_points.", '" . $answer_four . "', ".$answer_four_points.", '" . $answer_five . "', ".$answer_five_points.", '" . $answer_six . "', ".$answer_six_points.", ".$correct_answer.", '".$comments."', '".$hint."', ".$new_question_order.", '".$question_type."', 0)";
111
  $results = $wpdb->query( $insert );
112
- $hasCreatedQuestion = true;
 
 
113
 
114
- //Insert Action Into Audit Trail
115
- global $current_user;
116
- get_currentuserinfo();
117
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
118
- $insert = "INSERT INTO " . $table_name .
119
- "(trail_id, action_user, action, time) " .
120
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Question Has Been Added: ".$question_name."' , '" . date("h:i:s A m/d/Y") . "')";
121
- $results = $wpdb->query( $insert );
 
 
 
 
 
122
  }
123
 
124
  //Get table of questions for this quiz
@@ -158,16 +181,23 @@ function mlw_generate_quiz_options()
158
  $quiz_id = $_POST["quiz_id"];
159
  $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET message_before='".$mlw_before_message."', message_comment='".$mlw_before_comments."', comment_field_text='".$mlw_comment_field_text."', email_from_text='".$mlw_email_from_text."', question_answer_template='".$mlw_question_answer_template."', submit_button_text='".$mlw_submit_button_text."', name_field_text='".$mlw_name_field_text."', business_field_text='".$mlw_business_field_text."', email_field_text='".$mlw_email_field_text."', phone_field_text='".$mlw_phone_field_text."', message_after='".$mlw_after_message."', user_email_template='".$mlw_user_email_template."', admin_email_template='".$mlw_admin_email_template."' WHERE quiz_id=".$quiz_id;
160
  $results = $wpdb->query( $update );
161
- $hasUpdatedTemplates = true;
 
 
162
 
163
- //Insert Action Into Audit Trail
164
- global $current_user;
165
- get_currentuserinfo();
166
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
167
- $insert = "INSERT INTO " . $table_name .
168
- "(trail_id, action_user, action, time) " .
169
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Templates Have Been Edited For Quiz Number ".$quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
170
- $results = $wpdb->query( $insert );
 
 
 
 
 
171
  }
172
 
173
 
@@ -195,16 +225,23 @@ function mlw_generate_quiz_options()
195
  $quiz_id = $_POST["quiz_id"];
196
  $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET system='".$mlw_system."', send_user_email='".$mlw_send_user_email."', send_admin_email='".$mlw_send_admin_email."', contact_info_location=".$mlw_contact_location.", user_name='".$mlw_user_name."', user_comp='".$mlw_user_comp."', user_email='".$mlw_user_email."', user_phone='".$mlw_user_phone."', admin_email='".$mlw_admin_email."', comment_section='".$mlw_comment_section."', randomness_order='".$mlw_randomness_order."' WHERE quiz_id=".$quiz_id;
197
  $results = $wpdb->query( $update );
198
- $hasUpdatedOptions = true;
199
-
200
- //Insert Action Into Audit Trail
201
- global $current_user;
202
- get_currentuserinfo();
203
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
204
- $insert = "INSERT INTO " . $table_name .
205
- "(trail_id, action_user, action, time) " .
206
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Options Have Been Edited For Quiz Number ".$quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
207
- $results = $wpdb->query( $insert );
 
 
 
 
 
 
 
208
  }
209
 
210
  /*
@@ -221,16 +258,23 @@ function mlw_generate_quiz_options()
221
  {
222
  $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET leaderboard_template='".$mlw_leaderboard_template."' WHERE quiz_id=".$mlw_leaderboard_quiz_id;
223
  $results = $wpdb->query( $update );
224
- $hasUpdatedLeaderboardOptions = true;
225
-
226
- //Insert Action Into Audit Trail
227
- global $current_user;
228
- get_currentuserinfo();
229
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
230
- $insert = "INSERT INTO " . $table_name .
231
- "(trail_id, action_user, action, time) " .
232
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Leaderboard Options Have Been Edited For Quiz Number ".$mlw_leaderboard_quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
233
- $results = $wpdb->query( $insert );
 
 
 
 
 
 
 
234
  }
235
 
236
 
@@ -247,16 +291,23 @@ function mlw_generate_quiz_options()
247
  {
248
  $mlw_reset_update_sql = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET quiz_views=0, quiz_taken=0 WHERE quiz_id=".$mlw_reset_stats_quiz_id;
249
  $mlw_reset_sql_results = $wpdb->query( $mlw_reset_update_sql );
250
- $mlw_hasResetQuizStats = true;
251
-
252
- //Insert Action Into Audit Trail
253
- global $current_user;
254
- get_currentuserinfo();
255
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
256
- $insert = "INSERT INTO " . $table_name .
257
- "(trail_id, action_user, action, time) " .
258
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Quiz Stats Have Been Reset For Quiz Number ".$mlw_leaderboard_quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
259
- $results = $wpdb->query( $insert );
 
 
 
 
 
 
 
260
  }
261
 
262
 
@@ -483,7 +534,7 @@ function mlw_generate_quiz_options()
483
  idText.innerHTML = id;
484
  idHidden.value = id;
485
  };
486
- function editQuestion(id, question, answerOne, answerOnePoints, answerTwo, answerTwoPoints, answerThree, answerThreePoints, answerFour, answerFourPoints, answerFive, answerFivePoints, answerSix, answerSixPoints, correctAnswer, comments, hint, question_order, question_type){
487
  $j("#edit_question_dialog").dialog({
488
  autoOpen: false,
489
  show: 'blind',
@@ -511,6 +562,7 @@ function mlw_generate_quiz_options()
511
  document.getElementById("edit_answer_four_points").value = answerFourPoints;
512
  document.getElementById("edit_answer_five_points").value = answerFivePoints;
513
  document.getElementById("edit_answer_six_points").value = answerSixPoints;
 
514
  document.getElementById("edit_hint").value = hint;
515
  document.getElementById("edit_question_order").value = question_order;
516
  if (correctAnswer == 1) document.getElementById("edit_correct_one").checked = true;
@@ -544,7 +596,16 @@ function mlw_generate_quiz_options()
544
  <?php
545
  }
546
  ?>
547
- <?php if ($hasCreatedQuestion)
 
 
 
 
 
 
 
 
 
548
  {
549
  ?>
550
  <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
@@ -622,7 +683,7 @@ function mlw_generate_quiz_options()
622
  else $alternate = " class=\"alternate\"";
623
  $question_list .= "<tr{$alternate}>";
624
  $question_list .= "<td><span style='font-size:16px;'>" . $mlw_question_info->question_order . "</span></td>";
625
- $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->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>";
626
  $question_list .= "</tr>";
627
  }
628
 
@@ -744,6 +805,12 @@ function mlw_generate_quiz_options()
744
  </td>
745
  <td><input type="radio" name="correct_answer" value=6 /></td>
746
  </tr>
 
 
 
 
 
 
747
  <tr><td>&nbsp;</td></tr>
748
  <tr><td>&nbsp;</td></tr>
749
  <tr valign="top">
@@ -890,6 +957,12 @@ function mlw_generate_quiz_options()
890
  </td>
891
  <td><input type="radio" id="edit_correct_six" name="edit_correct_answer" value=6 /></td>
892
  </tr>
 
 
 
 
 
 
893
  <tr><td>&nbsp;</td></tr>
894
  <tr><td>&nbsp;</td></tr>
895
  <tr valign="top">
@@ -932,37 +1005,47 @@ function mlw_generate_quiz_options()
932
  <h3>Template Variables</h3>
933
  <table class="form-table">
934
  <tr>
935
- <td><strong>%POINT_SCORE%</strong> - Score for the quiz when using points</td>
936
- <td><strong>%AMOUNT_CORRECT%</strong> - The number of correct answers the user had</td>
937
  </tr>
938
 
939
  <tr>
940
- <td><strong>%TOTAL_QUESTIONS%</strong> - The total number of questions in the quiz</td>
941
- <td><strong>%CORRECT_SCORE%</strong> - Score for the quiz when using correct answers</td>
 
 
 
 
942
  </tr>
943
 
944
  <tr>
945
- <td><strong>%USER_NAME%</strong> - The name the user entered before the quiz</td>
946
- <td><strong>%USER_BUSINESS%</strong> - The business the user entered before the quiz</td>
947
  </tr>
 
948
  <tr>
949
- <td><strong>%USER_PHONE%</strong> - The phone number the user entered before the quiz</td>
950
- <td><strong>%USER_EMAIL%</strong> - The email the user entered before the quiz</td>
951
  </tr>
 
952
  <tr>
953
- <td><strong>%QUIZ_NAME%</strong> - The name of the quiz</td>
954
- <td><strong>%QUESTIONS_ANSWERS%</strong> - Shows the question, the answer the user provided, and the correct answer</td>
955
  </tr>
 
956
  <tr>
957
- <td><strong>%COMMENT_SECTION%</strong> - The comments the user entered into comment box if enabled</td>
958
- <td><strong>%QUESTION%</strong> - The question that the user answered</td>
959
  </tr>
 
960
  <tr>
961
- <td><strong>%USER_ANSWER%</strong> - The answer the user gave for the question</td>
962
- <td><strong>%CORRECT_ANSWER%</strong> - The correct answer for the question</td>
963
  </tr>
 
964
  <tr>
965
- <td><strong>%USER_COMMENTS%</strong> - The comments the user provided in the comment field for the question</td>
 
966
  </tr>
967
  </table>
968
  <button id="save_template_button" onclick="javascript: document.quiz_template_form.submit();">Save Templates</button><button id="template_tab_help">Help</button>
@@ -1001,6 +1084,7 @@ function mlw_generate_quiz_options()
1001
  <br />
1002
  <p>Allowed Variables: </p>
1003
  <p style="margin: 2px 0">- %POINT_SCORE%</p>
 
1004
  <p style="margin: 2px 0">- %AMOUNT_CORRECT%</p>
1005
  <p style="margin: 2px 0">- %TOTAL_QUESTIONS%</p>
1006
  <p style="margin: 2px 0">- %CORRECT_SCORE%</p>
@@ -1027,6 +1111,7 @@ function mlw_generate_quiz_options()
1027
  <br />
1028
  <p>Allowed Variables: </p>
1029
  <p style="margin: 2px 0">- %POINT_SCORE%</p>
 
1030
  <p style="margin: 2px 0">- %AMOUNT_CORRECT%</p>
1031
  <p style="margin: 2px 0">- %TOTAL_QUESTIONS%</p>
1032
  <p style="margin: 2px 0">- %CORRECT_SCORE%</p>
@@ -1047,6 +1132,7 @@ function mlw_generate_quiz_options()
1047
  <br />
1048
  <p>Allowed Variables: </p>
1049
  <p style="margin: 2px 0">- %POINT_SCORE%</p>
 
1050
  <p style="margin: 2px 0">- %AMOUNT_CORRECT%</p>
1051
  <p style="margin: 2px 0">- %TOTAL_QUESTIONS%</p>
1052
  <p style="margin: 2px 0">- %CORRECT_SCORE%</p>
@@ -1106,6 +1192,7 @@ function mlw_generate_quiz_options()
1106
  <p style="margin: 2px 0">- %USER_ANSWER%</p>
1107
  <p style="margin: 2px 0">- %CORRECT_ANSWER%</p>
1108
  <p style="margin: 2px 0">- %USER_COMMENTS%</p>
 
1109
  </td>
1110
  <td><textarea cols="80" rows="15" id="mlw_quiz_question_answer_template" name="mlw_quiz_question_answer_template"><?php echo $mlw_quiz_options->question_answer_template; ?></textarea>
1111
  </td>
12
  global $wpdb;
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
34
  $answer_six = htmlspecialchars($_POST["answer_six"], ENT_QUOTES);
35
  $answer_six_points = $_POST["answer_six_points"];
36
  $correct_answer = $_POST["correct_answer"];
37
+ $question_answer_info = $_POST["correct_answer_info"];
38
  $question_type = $_POST["question_type"];
39
  $comments = $_POST["comments"];
40
  $hint = $_POST["hint"];
56
  $edit_answer_six = htmlspecialchars($_POST["edit_answer_six"], ENT_QUOTES);
57
  $edit_answer_six_points = $_POST["edit_answer_six_points"];
58
  $edit_correct_answer = $_POST["edit_correct_answer"];
59
+ $edit_question_answer_info = $_POST["edit_correct_answer_info"];
60
  $mlw_edit_question_id = $_POST["edit_question_id"];
61
  $mlw_edit_question_type = $_POST["edit_question_type"];
62
  $edit_comments = $_POST["edit_comments"];
67
  if ($edit_question_success == "confirmation")
68
  {
69
  $quiz_id = $_POST["quiz_id"];
70
+ $update = "UPDATE " . $wpdb->prefix . "mlw_questions" . " SET question_name='".$edit_question_name."', answer_one='".$edit_answer_one."', answer_one_points='".$edit_answer_one_points."', answer_two='".$edit_answer_two."', answer_two_points='".$edit_answer_two_points."', answer_three='".$edit_answer_three."', answer_three_points='".$edit_answer_three_points."', answer_four='".$edit_answer_four."', answer_four_points='".$edit_answer_four_points."', answer_five='".$edit_answer_five."', answer_five_points='".$edit_answer_five_points."', answer_six='".$edit_answer_six."', answer_six_points='".$edit_answer_six_points."', correct_answer='".$edit_correct_answer."', question_answer_info='".$edit_question_answer_info."', comments='".$edit_comments."', hints='".$edit_hint."', question_order='".$edit_question_order."', question_type='".$mlw_edit_question_type."' WHERE question_id=".$mlw_edit_question_id;
71
  $results = $wpdb->query( $update );
72
+ if ($results != false)
73
+ {
74
+ $hasUpdatedQuestion = true;
75
 
76
+ //Insert Action Into Audit Trail
77
+ global $current_user;
78
+ get_currentuserinfo();
79
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
80
+ $insert = "INSERT INTO " . $table_name .
81
+ "(trail_id, action_user, action, time) " .
82
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Question Has Been Edited: ".$edit_question_name."' , '" . date("h:i:s A m/d/Y") . "')";
83
+ $results = $wpdb->query( $insert );
84
+ }
85
+ else
86
+ {
87
+ $mlw_qmn_isQueryError = true;
88
+ }
89
  }
90
 
91
  //Variables from delete question form
98
  $quiz_id = $_POST["quiz_id"];
99
  $update = "UPDATE " . $wpdb->prefix . "mlw_questions" . " SET deleted=1 WHERE question_id=".$mlw_question_id;
100
  $results = $wpdb->query( $update );
101
+ if ($results != false)
102
+ {
103
+ $hasDeletedQuestion = true;
104
 
105
+ //Insert Action Into Audit Trail
106
+ global $current_user;
107
+ get_currentuserinfo();
108
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
109
+ $insert = "INSERT INTO " . $table_name .
110
+ "(trail_id, action_user, action, time) " .
111
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Question Has Been Deleted: ".$mlw_question_id."' , '" . date("h:i:s A m/d/Y") . "')";
112
+ $results = $wpdb->query( $insert );
113
+ }
114
+ else
115
+ {
116
+ $mlw_qmn_isQueryError = true;
117
+ }
118
  }
119
 
120
  //Submit new question into database
123
  $quiz_id = $_POST["quiz_id"];
124
  $table_name = $wpdb->prefix . "mlw_questions";
125
  $insert = "INSERT INTO " . $table_name .
126
+ " (question_id, quiz_id, question_name, answer_one, answer_one_points, answer_two, answer_two_points, answer_three, answer_three_points, answer_four, answer_four_points, answer_five, answer_five_points, answer_six, answer_six_points, correct_answer, question_answer_info, comments, hints, question_order, question_type, deleted) VALUES (NULL , ".$quiz_id.", '" . $question_name . "' , '" . $answer_one . "', ".$answer_one_points.", '" . $answer_two . "', ".$answer_two_points.", '" . $answer_three . "', ".$answer_three_points.", '" . $answer_four . "', ".$answer_four_points.", '" . $answer_five . "', ".$answer_five_points.", '" . $answer_six . "', ".$answer_six_points.", ".$correct_answer.", '".$question_answer_info."', '".$comments."', '".$hint."', ".$new_question_order.", '".$question_type."', 0)";
127
  $results = $wpdb->query( $insert );
128
+ if ($results != false)
129
+ {
130
+ $hasCreatedQuestion = true;
131
 
132
+ //Insert Action Into Audit Trail
133
+ global $current_user;
134
+ get_currentuserinfo();
135
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
136
+ $insert = "INSERT INTO " . $table_name .
137
+ "(trail_id, action_user, action, time) " .
138
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Question Has Been Added: ".$question_name."' , '" . date("h:i:s A m/d/Y") . "')";
139
+ $results = $wpdb->query( $insert );
140
+ }
141
+ else
142
+ {
143
+ $mlw_qmn_isQueryError = true;
144
+ }
145
  }
146
 
147
  //Get table of questions for this quiz
181
  $quiz_id = $_POST["quiz_id"];
182
  $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET message_before='".$mlw_before_message."', message_comment='".$mlw_before_comments."', comment_field_text='".$mlw_comment_field_text."', email_from_text='".$mlw_email_from_text."', question_answer_template='".$mlw_question_answer_template."', submit_button_text='".$mlw_submit_button_text."', name_field_text='".$mlw_name_field_text."', business_field_text='".$mlw_business_field_text."', email_field_text='".$mlw_email_field_text."', phone_field_text='".$mlw_phone_field_text."', message_after='".$mlw_after_message."', user_email_template='".$mlw_user_email_template."', admin_email_template='".$mlw_admin_email_template."' WHERE quiz_id=".$quiz_id;
183
  $results = $wpdb->query( $update );
184
+ if ($results != false)
185
+ {
186
+ $hasUpdatedTemplates = true;
187
 
188
+ //Insert Action Into Audit Trail
189
+ global $current_user;
190
+ get_currentuserinfo();
191
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
192
+ $insert = "INSERT INTO " . $table_name .
193
+ "(trail_id, action_user, action, time) " .
194
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Templates Have Been Edited For Quiz Number ".$quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
195
+ $results = $wpdb->query( $insert );
196
+ }
197
+ else
198
+ {
199
+ $mlw_qmn_isQueryError = true;
200
+ }
201
  }
202
 
203
 
225
  $quiz_id = $_POST["quiz_id"];
226
  $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET system='".$mlw_system."', send_user_email='".$mlw_send_user_email."', send_admin_email='".$mlw_send_admin_email."', contact_info_location=".$mlw_contact_location.", user_name='".$mlw_user_name."', user_comp='".$mlw_user_comp."', user_email='".$mlw_user_email."', user_phone='".$mlw_user_phone."', admin_email='".$mlw_admin_email."', comment_section='".$mlw_comment_section."', randomness_order='".$mlw_randomness_order."' WHERE quiz_id=".$quiz_id;
227
  $results = $wpdb->query( $update );
228
+ if ($results != false)
229
+ {
230
+ $hasUpdatedOptions = true;
231
+
232
+ //Insert Action Into Audit Trail
233
+ global $current_user;
234
+ get_currentuserinfo();
235
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
236
+ $insert = "INSERT INTO " . $table_name .
237
+ "(trail_id, action_user, action, time) " .
238
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Options Have Been Edited For Quiz Number ".$quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
239
+ $results = $wpdb->query( $insert );
240
+ }
241
+ else
242
+ {
243
+ $mlw_qmn_isQueryError = true;
244
+ }
245
  }
246
 
247
  /*
258
  {
259
  $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET leaderboard_template='".$mlw_leaderboard_template."' WHERE quiz_id=".$mlw_leaderboard_quiz_id;
260
  $results = $wpdb->query( $update );
261
+ if ($results != false)
262
+ {
263
+ $hasUpdatedLeaderboardOptions = true;
264
+
265
+ //Insert Action Into Audit Trail
266
+ global $current_user;
267
+ get_currentuserinfo();
268
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
269
+ $insert = "INSERT INTO " . $table_name .
270
+ "(trail_id, action_user, action, time) " .
271
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Leaderboard Options Have Been Edited For Quiz Number ".$mlw_leaderboard_quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
272
+ $results = $wpdb->query( $insert );
273
+ }
274
+ else
275
+ {
276
+ $mlw_qmn_isQueryError = true;
277
+ }
278
  }
279
 
280
 
291
  {
292
  $mlw_reset_update_sql = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET quiz_views=0, quiz_taken=0 WHERE quiz_id=".$mlw_reset_stats_quiz_id;
293
  $mlw_reset_sql_results = $wpdb->query( $mlw_reset_update_sql );
294
+ if ($mlw_reset_sql_results != false)
295
+ {
296
+ $mlw_hasResetQuizStats = true;
297
+
298
+ //Insert Action Into Audit Trail
299
+ global $current_user;
300
+ get_currentuserinfo();
301
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
302
+ $insert = "INSERT INTO " . $table_name .
303
+ "(trail_id, action_user, action, time) " .
304
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Quiz Stats Have Been Reset For Quiz Number ".$mlw_leaderboard_quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
305
+ $results = $wpdb->query( $insert );
306
+ }
307
+ else
308
+ {
309
+ $mlw_qmn_isQueryError = true;
310
+ }
311
  }
312
 
313
 
534
  idText.innerHTML = id;
535
  idHidden.value = id;
536
  };
537
+ function editQuestion(id, question, answerOne, answerOnePoints, answerTwo, answerTwoPoints, answerThree, answerThreePoints, answerFour, answerFourPoints, answerFive, answerFivePoints, answerSix, answerSixPoints, correctAnswer, answer_info, comments, hint, question_order, question_type){
538
  $j("#edit_question_dialog").dialog({
539
  autoOpen: false,
540
  show: 'blind',
562
  document.getElementById("edit_answer_four_points").value = answerFourPoints;
563
  document.getElementById("edit_answer_five_points").value = answerFivePoints;
564
  document.getElementById("edit_answer_six_points").value = answerSixPoints;
565
+ document.getElementById("edit_correct_answer_info").value = answer_info;
566
  document.getElementById("edit_hint").value = hint;
567
  document.getElementById("edit_question_order").value = question_order;
568
  if (correctAnswer == 1) document.getElementById("edit_correct_one").checked = true;
596
  <?php
597
  }
598
  ?>
599
+ <?php if ($mlw_qmn_isQueryError)
600
+ {
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
+ }
608
+ if ($hasCreatedQuestion)
609
  {
610
  ?>
611
  <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
683
  else $alternate = " class=\"alternate\"";
684
  $question_list .= "<tr{$alternate}>";
685
  $question_list .= "<td><span style='font-size:16px;'>" . $mlw_question_info->question_order . "</span></td>";
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
 
805
  </td>
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>
813
+ </tr>
814
  <tr><td>&nbsp;</td></tr>
815
  <tr><td>&nbsp;</td></tr>
816
  <tr valign="top">
957
  </td>
958
  <td><input type="radio" id="edit_correct_six" name="edit_correct_answer" value=6 /></td>
959
  </tr>
960
+ <tr>
961
+ <td><span style='font-weight:bold;'>Correct Answer Info:</span></td>
962
+ <td colspan="3"><input type="text" name="edit_correct_answer_info" value="" id="edit_correct_answer_info" style="border-color:#000000;
963
+ color:#3300CC;
964
+ cursor:hand;"/></td>
965
+ </tr>
966
  <tr><td>&nbsp;</td></tr>
967
  <tr><td>&nbsp;</td></tr>
968
  <tr valign="top">
1005
  <h3>Template Variables</h3>
1006
  <table class="form-table">
1007
  <tr>
1008
+ <td><strong>%POINT_SCORE%</strong> - Score for the quiz when using points</td>
1009
+ <td><strong>%AVERAGE_POINT%</strong> - The average amount of points user had per question</td>
1010
  </tr>
1011
 
1012
  <tr>
1013
+ <td><strong>%AMOUNT_CORRECT%</strong> - The number of correct answers the user had</td>
1014
+ <td><strong>%TOTAL_QUESTIONS%</strong> - The total number of questions in the quiz</td>
1015
+ </tr>
1016
+
1017
+ <tr>
1018
+ <td><strong>%CORRECT_SCORE%</strong> - Score for the quiz when using correct answers</td>
1019
  </tr>
1020
 
1021
  <tr>
1022
+ <td><strong>%USER_NAME%</strong> - The name the user entered before the quiz</td>
1023
+ <td><strong>%USER_BUSINESS%</strong> - The business the user entered before the quiz</td>
1024
  </tr>
1025
+
1026
  <tr>
1027
+ <td><strong>%USER_PHONE%</strong> - The phone number the user entered before the quiz</td>
1028
+ <td><strong>%USER_EMAIL%</strong> - The email the user entered before the quiz</td>
1029
  </tr>
1030
+
1031
  <tr>
1032
+ <td><strong>%QUIZ_NAME%</strong> - The name of the quiz</td>
1033
+ <td><strong>%QUESTIONS_ANSWERS%</strong> - Shows the question, the answer the user provided, and the correct answer</td>
1034
  </tr>
1035
+
1036
  <tr>
1037
+ <td><strong>%COMMENT_SECTION%</strong> - The comments the user entered into comment box if enabled</td>
1038
+ <td><strong>%QUESTION%</strong> - The question that the user answered</td>
1039
  </tr>
1040
+
1041
  <tr>
1042
+ <td><strong>%USER_ANSWER%</strong> - The answer the user gave for the question</td>
1043
+ <td><strong>%CORRECT_ANSWER%</strong> - The correct answer for the question</td>
1044
  </tr>
1045
+
1046
  <tr>
1047
+ <td><strong>%USER_COMMENTS%</strong> - The comments the user provided in the comment field for the question</td>
1048
+ <td><strong>%CORRECT_ANSWER_INFO%</strong> - Reason why the correct answer is the correct answer</td>
1049
  </tr>
1050
  </table>
1051
  <button id="save_template_button" onclick="javascript: document.quiz_template_form.submit();">Save Templates</button><button id="template_tab_help">Help</button>
1084
  <br />
1085
  <p>Allowed Variables: </p>
1086
  <p style="margin: 2px 0">- %POINT_SCORE%</p>
1087
+ <p style="margin: 2px 0">- %AVERAGE_POINT%</p>
1088
  <p style="margin: 2px 0">- %AMOUNT_CORRECT%</p>
1089
  <p style="margin: 2px 0">- %TOTAL_QUESTIONS%</p>
1090
  <p style="margin: 2px 0">- %CORRECT_SCORE%</p>
1111
  <br />
1112
  <p>Allowed Variables: </p>
1113
  <p style="margin: 2px 0">- %POINT_SCORE%</p>
1114
+ <p style="margin: 2px 0">- %AVERAGE_POINT%</p>
1115
  <p style="margin: 2px 0">- %AMOUNT_CORRECT%</p>
1116
  <p style="margin: 2px 0">- %TOTAL_QUESTIONS%</p>
1117
  <p style="margin: 2px 0">- %CORRECT_SCORE%</p>
1132
  <br />
1133
  <p>Allowed Variables: </p>
1134
  <p style="margin: 2px 0">- %POINT_SCORE%</p>
1135
+ <p style="margin: 2px 0">- %AVERAGE_POINT%</p>
1136
  <p style="margin: 2px 0">- %AMOUNT_CORRECT%</p>
1137
  <p style="margin: 2px 0">- %TOTAL_QUESTIONS%</p>
1138
  <p style="margin: 2px 0">- %CORRECT_SCORE%</p>
1192
  <p style="margin: 2px 0">- %USER_ANSWER%</p>
1193
  <p style="margin: 2px 0">- %CORRECT_ANSWER%</p>
1194
  <p style="margin: 2px 0">- %USER_COMMENTS%</p>
1195
+ <p style="margin: 2px 0">- %CORRECT_ANSWER_INFO%</p>
1196
  </td>
1197
  <td><textarea cols="80" rows="15" id="mlw_quiz_question_answer_template" name="mlw_quiz_question_answer_template"><?php echo $mlw_quiz_options->question_answer_template; ?></textarea>
1198
  </td>
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.0.1";
10
  if ( ! get_option('mlw_quiz_master_version'))
11
  {
12
  add_option('mlw_quiz_master_version' , $data);
@@ -109,6 +109,15 @@ function mlw_quiz_update()
109
  $results = $wpdb->query( $update_sql );
110
  }
111
 
 
 
 
 
 
 
 
 
 
112
  update_option('mlw_quiz_master_version' , $data);
113
  }
114
  }
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);
109
  $results = $wpdb->query( $update_sql );
110
  }
111
 
112
+ //Update 1.1.1
113
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_answer_info'") != "question_answer_info")
114
+ {
115
+ $sql = "ALTER TABLE ".$table_name." ADD question_answer_info TEXT NOT NULL AFTER correct_answer";
116
+ $results = $wpdb->query( $sql );
117
+ $update_sql = "UPDATE ".$table_name." SET question_answer_info=''";
118
+ $results = $wpdb->query( $update_sql );
119
+ }
120
+
121
  update_option('mlw_quiz_master_version' , $data);
122
  }
123
  }
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.0.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.1.1
7
  Author: Frank Corso
8
  Author URI: http://www.mylocalwebstop.com/
9
  Plugin URI: http://www.mylocalwebstop.com/
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Quiz Master Next ===
2
  Contributors: fpcorso
3
  Tags: quiz, test, score, survey, contact
4
- Requires at least: 3.0.1
5
  Tested up to: 3.8.1
6
- Stable tag: 1.0.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.
@@ -24,6 +24,7 @@ Features include:
24
  * Can score the quiz using an incorrect/correct system, a points based system, or a not-graded system
25
  * Can enable comment boxes for each question and/or comment section at the end of the quiz
26
  * Can enable hints for questions
 
27
  * Saves the results after a user takes the quiz
28
  * Saves the users answers and comments after taking the quiz
29
  * Features audit trail so admins can keep track of who adds, edits, or deletes quizzes and questions
@@ -64,6 +65,14 @@ Feel free to use the widget on the quiz dashboard within the plugin or from the
64
 
65
  == Changelog ==
66
 
 
 
 
 
 
 
 
 
67
  = 1.0.1 (February 4, 2014) =
68
  * Fixed Saving Results Bug
69
  * Fixed Leaderboard Bug
@@ -240,6 +249,9 @@ Feel free to use the widget on the quiz dashboard within the plugin or from the
240
 
241
  == Upgrade Notice ==
242
 
 
 
 
243
  = 1.0.1 =
244
  This update fixes minor bugs.
245
 
1
  === Quiz Master Next ===
2
  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.
24
  * Can score the quiz using an incorrect/correct system, a points based system, or a not-graded system
25
  * Can enable comment boxes for each question and/or comment section at the end of the quiz
26
  * Can enable hints for questions
27
+ * Can show user why the answer is the correct answer
28
  * Saves the results after a user takes the quiz
29
  * Saves the users answers and comments after taking the quiz
30
  * Features audit trail so admins can keep track of who adds, edits, or deletes quizzes and questions
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
71
+ * Added %CORRECT_ANSWER_INFO% To Display Why Answer Is Correct
72
+ * Begun Creating New Error Code System
73
+ * Fixed Edit Quiz Name Bug
74
+ * Fixed New Quiz Bug
75
+
76
  = 1.0.1 (February 4, 2014) =
77
  * Fixed Saving Results Bug
78
  * Fixed Leaderboard Bug
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
+
255
  = 1.0.1 =
256
  This update fixes minor bugs.
257