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

Version Description

(September 18, 2013) = * Created New Tools Page And Moved Audit Trail To It * Added Ability For Comment Section At End Of Quiz * Added Ability To Have Hints * Added Option To Have Comment Boxes On Questions * Added More Statistics To Main Page

Download this release

Release Info

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

Code changes from version 0.4.1 to 0.5

includes/mlw_dashboard.php CHANGED
@@ -7,9 +7,9 @@ Copyright 2013, My Local Webstop (email : fpcorso@mylocalwebstop.com)
7
  */
8
 
9
  function mlw_generate_quiz_dashboard(){
 
10
  add_meta_box("wpss_mrts", 'Quiz Stats', "mlw_dashboard_box", "quiz_wpss");
11
- add_meta_box("wpss_mrts", 'Help', "mlw_dashboard_box_two", "quiz_wpss2");
12
- add_meta_box("wpss_mrts", 'Audit Trail', "mlw_dashboard_box_three", "quiz_wpss3");
13
  ?>
14
  <!-- css -->
15
  <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
@@ -53,7 +53,7 @@ function mlw_generate_quiz_dashboard(){
53
  <div class="wrap">
54
  <h2>Quiz Master Next Dashboard<a id="opener" href="">(?)</a></h2>
55
 
56
- <h3>Version 0.4.1</h3>
57
  <p>Thank you for trying out my new plugin. I hope you find it beneficial to your website.</p>
58
 
59
  <div style="float:left; width:60%;" class="inner-sidebar1">
@@ -64,20 +64,13 @@ function mlw_generate_quiz_dashboard(){
64
  <?php do_meta_boxes('quiz_wpss2','advanced',''); ?>
65
  </div>
66
 
67
- <!--<div style="clear:both"></div>-->
68
-
69
- <div style="float:left; width:100%;" class="inner-sidebar1">
70
- <?php do_meta_boxes('quiz_wpss3','advanced',''); ?>
71
- </div>
72
-
73
  <!--<div style="clear:both"></div>-->
74
 
75
  <div id="dialog" title="Help">
76
  <h3><b>Help</b></h3>
77
  <p>This page is the main admin page for the Quiz Master Next.</p>
78
  <p>The first widget lists all the statistics collected so far.</p>
79
- <p>The second widget lists all the new features added in this update.</p>
80
- <p>The third widget lists the audit trail.</p>
81
  </div>
82
 
83
  </div>
@@ -102,6 +95,22 @@ function mlw_dashboard_box()
102
  $mlw_quiz_taken = $mlw_eaches->QuizTaken;
103
  break;
104
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  ?>
106
  <div>
107
  <table width='100%'>
@@ -113,6 +122,14 @@ function mlw_dashboard_box()
113
  <td align='left'>Total Times All Quizzes Have Been Taken</td>
114
  <td align='right'><?php echo $mlw_quiz_taken; ?></td>
115
  </tr>
 
 
 
 
 
 
 
 
116
  </table>
117
  </div>
118
  <?php
@@ -148,48 +165,4 @@ function mlw_dashboard_box_two()
148
  </div>
149
  <?php
150
  }
151
-
152
- function mlw_dashboard_box_three()
153
- {
154
- global $wpdb;
155
-
156
- $sql = "SELECT trail_id, action_user, action, time
157
- FROM " . $wpdb->prefix . "mlw_qm_audit_trail ";
158
- $sql .= "ORDER BY trail_id DESC";
159
-
160
- $audit_trails = $wpdb->get_results($sql);
161
- $quotes_list = "";
162
- $display = "";
163
- foreach($audit_trails as $quote_data) {
164
- if($alternate) $alternate = "";
165
- else $alternate = " class=\"alternate\"";
166
- $quotes_list .= "<tr{$alternate}>";
167
- $quotes_list .= "<td>" . $quote_data->trail_id . "</td>";
168
- $quotes_list .= "<td>" . $quote_data->action_user . "</td>";
169
- $quotes_list .= "<td>" . $quote_data->action ."</td>";
170
- $quotes_list .= "<td>" . $quote_data->time . "</td>";
171
- $quotes_list .= "</tr>";
172
- }
173
-
174
- $display .= "<table class=\"widefat\">";
175
- $display .= "<thead><tr>
176
- <th>ID</th>
177
- <th>User</th>
178
- <th>Action</th>
179
- <th>Time</th>
180
- </tr></thead>";
181
- $display .= "<tbody id=\"the-list\">{$quotes_list}</tbody>";
182
- $display .= "</table>";
183
- ?>
184
- <div>
185
- <table width='100%'>
186
- <tr>
187
- <td align='left'>
188
- <?php echo $display; ?>
189
- </td>
190
- </tr>
191
- </table>
192
- </div>
193
- <?php
194
- }
195
  ?>
7
  */
8
 
9
  function mlw_generate_quiz_dashboard(){
10
+ $mlw_quiz_version = get_option('mlw_quiz_master_version');
11
  add_meta_box("wpss_mrts", 'Quiz Stats', "mlw_dashboard_box", "quiz_wpss");
12
+ add_meta_box("wpss_mrts", 'Help', "mlw_dashboard_box_two", "quiz_wpss2");
 
13
  ?>
14
  <!-- css -->
15
  <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
53
  <div class="wrap">
54
  <h2>Quiz Master Next Dashboard<a id="opener" href="">(?)</a></h2>
55
 
56
+ <h3>Version <?php echo $mlw_quiz_version; ?></h3>
57
  <p>Thank you for trying out my new plugin. I hope you find it beneficial to your website.</p>
58
 
59
  <div style="float:left; width:60%;" class="inner-sidebar1">
64
  <?php do_meta_boxes('quiz_wpss2','advanced',''); ?>
65
  </div>
66
 
 
 
 
 
 
 
67
  <!--<div style="clear:both"></div>-->
68
 
69
  <div id="dialog" title="Help">
70
  <h3><b>Help</b></h3>
71
  <p>This page is the main admin page for the Quiz Master Next.</p>
72
  <p>The first widget lists all the statistics collected so far.</p>
73
+ <p>The second widget gives tips to better use the plugin.</p>
 
74
  </div>
75
 
76
  </div>
95
  $mlw_quiz_taken = $mlw_eaches->QuizTaken;
96
  break;
97
  }
98
+
99
+ $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_quizzes ORDER BY quiz_views DESC LIMIT 1";
100
+ $mlw_quiz_most_viewed = $wpdb->get_results($sql);
101
+
102
+ foreach($mlw_quiz_most_viewed as $mlw_eaches) {
103
+ $mlw_quiz_most_viewed = $mlw_eaches->quiz_name;
104
+ break;
105
+ }
106
+
107
+ $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_quizzes ORDER BY quiz_taken DESC LIMIT 1";
108
+ $mlw_quiz_most_taken = $wpdb->get_results($sql);
109
+
110
+ foreach($mlw_quiz_most_taken as $mlw_eaches) {
111
+ $mlw_quiz_most_taken = $mlw_eaches->quiz_name;
112
+ break;
113
+ }
114
  ?>
115
  <div>
116
  <table width='100%'>
122
  <td align='left'>Total Times All Quizzes Have Been Taken</td>
123
  <td align='right'><?php echo $mlw_quiz_taken; ?></td>
124
  </tr>
125
+ <tr>
126
+ <td align='left'>Quiz That Has Been Viewed The Most</td>
127
+ <td align='right'><?php echo $mlw_quiz_most_viewed; ?></td>
128
+ </tr>
129
+ <tr>
130
+ <td align='left'>Quiz That Has Been Taken The Most</td>
131
+ <td align='right'><?php echo $mlw_quiz_most_taken; ?></td>
132
+ </tr>
133
  </table>
134
  </div>
135
  <?php
165
  </div>
166
  <?php
167
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  ?>
includes/mlw_main_page.php CHANGED
@@ -9,6 +9,7 @@ Copyright 2013, My Local Webstop (email : fpcorso@mylocalwebstop.com)
9
 
10
  function mlw_generate_main_page()
11
  {
 
12
  add_meta_box("wpss_mrts", 'Quiz Master Next', "quiz_wpss_mrt_meta_box", "quiz_wpss");
13
  add_meta_box("wpss_mrts", 'In This Update', "quiz_wpss_mrt_meta_box2", "quiz_wpss2");
14
  add_meta_box("wpss_mrts", 'Support', "quiz_wpss_mrt_meta_box3", "quiz_wpss3");
@@ -83,9 +84,8 @@ function mlw_generate_main_page()
83
  <div class="wrap">
84
  <h2>Quiz Master Next Support <a id="opener" href="">(?)</a></h2>
85
 
86
- <h3>Version 0.4.1</h3>
87
- <p>Thank you for trying out my new plugin. I hope you find it beneficial to your website.</p>
88
- <p>Please consider rating this plugin <a href="http://wordpress.org/support/view/plugin-reviews/quiz-master-next">here</a>.</p>
89
 
90
  <div style="float:left; width:60%;" class="inner-sidebar1">
91
  <?php do_meta_boxes('quiz_wpss3','advanced',''); ?>
@@ -161,10 +161,22 @@ function quiz_wpss_mrt_meta_box2()
161
  <div>
162
  <table width='100%'>
163
  <tr>
164
- <td align='left'>0.4.1 (September 13, 2013)</td>
165
  </tr>
166
  <tr>
167
- <td align='left'>* Bug Fixes</td>
 
 
 
 
 
 
 
 
 
 
 
 
168
  </tr>
169
  </table>
170
  </div>
@@ -182,16 +194,16 @@ function quiz_wpss_mrt_meta_box3()
182
  $user_email = $_POST["email"];
183
  $user_message = $_POST["message"];
184
  $quiz_master_email_message = "";
185
- if ($quiz_master_email_success == update and $user_email != "" and $user_message != "")
186
  {
187
- wp_mail('fpcorso@mylocalwebstop.com' ,'Support From Quiz Master Next Plugin','Message from ' . $user_name . ' at ' . $user_email . " It says: " . "\n" . $user_message . "\n" . "Version 0.4");
188
  $quiz_master_email_message = "<h3>Message Sent</h3>";
189
  }
190
- else if ($quiz_master_email_success == update and $user_email == "")
191
  {
192
  $quiz_master_email_message = "<h3>Please Enter Email</h3>";
193
  }
194
- else if ($quiz_master_email_success == update and $user_message == "")
195
  {
196
  $quiz_master_email_message = "<h3>Please Enter In Your Message</h3>";
197
  }
9
 
10
  function mlw_generate_main_page()
11
  {
12
+ $mlw_quiz_version = get_option('mlw_quiz_master_version');
13
  add_meta_box("wpss_mrts", 'Quiz Master Next', "quiz_wpss_mrt_meta_box", "quiz_wpss");
14
  add_meta_box("wpss_mrts", 'In This Update', "quiz_wpss_mrt_meta_box2", "quiz_wpss2");
15
  add_meta_box("wpss_mrts", 'Support', "quiz_wpss_mrt_meta_box3", "quiz_wpss3");
84
  <div class="wrap">
85
  <h2>Quiz Master Next Support <a id="opener" href="">(?)</a></h2>
86
 
87
+ <h3>Version <?php echo $mlw_quiz_version; ?></h3>
88
+ <p>Thank you for trying out my new plugin. I hope you find it beneficial to your website. Please consider rating this plugin <a href="http://wordpress.org/support/view/plugin-reviews/quiz-master-next">here</a>.</p>
 
89
 
90
  <div style="float:left; width:60%;" class="inner-sidebar1">
91
  <?php do_meta_boxes('quiz_wpss3','advanced',''); ?>
161
  <div>
162
  <table width='100%'>
163
  <tr>
164
+ <td align='left'>0.5 (September 18, 2013)</td>
165
  </tr>
166
  <tr>
167
+ <td align='left'>* Created New Tools Page And Moved Audit Trail To It</td>
168
+ </tr>
169
+ <tr>
170
+ <td align='left'>* Added Ability For Comment Section At End Of Quiz</td>
171
+ </tr>
172
+ <tr>
173
+ <td align='left'>* Added Ability To Have Hints</td>
174
+ </tr>
175
+ <tr>
176
+ <td align='left'>* Added Option To Have Comment Boxes On Questions</td>
177
+ </tr>
178
+ <tr>
179
+ <td align='left'>* Added More Statistics To Main Page</td>
180
  </tr>
181
  </table>
182
  </div>
194
  $user_email = $_POST["email"];
195
  $user_message = $_POST["message"];
196
  $quiz_master_email_message = "";
197
+ if ($quiz_master_email_success == 'update' and $user_email != "" and $user_message != "")
198
  {
199
+ wp_mail('fpcorso@mylocalwebstop.com' ,'Support From Quiz Master Next Plugin','Message from ' . $user_name . ' at ' . $user_email . " It says: " . "\n" . $user_message . "\n" . "Version ".$mlw_quiz_version);
200
  $quiz_master_email_message = "<h3>Message Sent</h3>";
201
  }
202
+ else if ($quiz_master_email_success == 'update' and $user_email == "")
203
  {
204
  $quiz_master_email_message = "<h3>Please Enter Email</h3>";
205
  }
206
+ else if ($quiz_master_email_success == 'update' and $user_message == "")
207
  {
208
  $quiz_master_email_message = "<h3>Please Enter In Your Message</h3>";
209
  }
includes/mlw_quiz.php CHANGED
@@ -63,6 +63,11 @@ function mlw_quiz_shortcode($atts)
63
  //Form validation script
64
  $mlw_display .= "
65
  <script>
 
 
 
 
 
66
  function validateForm()
67
  {
68
  ";
@@ -198,6 +203,24 @@ function mlw_quiz_shortcode($atts)
198
  $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='6' />".$mlw_question->answer_six;
199
  $mlw_display .= "<br />";
200
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  $mlw_display .= "<br />";
202
  }
203
  $mlw_display .= "<input type='hidden' name='complete_quiz' value='confirmation' />";
@@ -239,10 +262,14 @@ function mlw_quiz_shortcode($atts)
239
  $mlw_question_answers .= $mlw_question->question_name . "\n";
240
  $mlw_question_answers .= "Your Answer: " . $mlw_user_answer . "\n";
241
  $mlw_question_answers .= "Correct Answer: " . $mlw_question->correct_answer . "\n";
 
 
 
 
242
  $mlw_question_answers .= "\n";
243
  }
244
  $mlw_total_score = round((($mlw_correct/$mlw_total_questions)*100), 2);
245
-
246
  //Prepare the after quiz message
247
  $mlw_message_after = $mlw_quiz_options->message_after;
248
  $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
@@ -255,6 +282,7 @@ function mlw_quiz_shortcode($atts)
255
  $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
256
  $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
257
  $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
 
258
  $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
259
  $mlw_display .= $mlw_message_after;
260
 
@@ -277,6 +305,7 @@ function mlw_quiz_shortcode($atts)
277
  $mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
278
  $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
279
  $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
 
280
  wp_mail($mlw_user_email, "Quiz Results", $mlw_message);
281
  }
282
  }
@@ -296,6 +325,7 @@ function mlw_quiz_shortcode($atts)
296
  $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
297
  $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
298
  $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
 
299
  $mlw_message .= " This email was generated by the Quiz Master Next script by Frank Corso";
300
  wp_mail($mlw_quiz_options->admin_email, "Quiz Results", $mlw_message);
301
  }
63
  //Form validation script
64
  $mlw_display .= "
65
  <script>
66
+ function clear_field(field)
67
+ {
68
+ if (field.defaultValue == field.value) field.value = '';
69
+ }
70
+
71
  function validateForm()
72
  {
73
  ";
203
  $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='6' />".$mlw_question->answer_six;
204
  $mlw_display .= "<br />";
205
  }
206
+ if ($mlw_question->comments == 0)
207
+ {
208
+ $mlw_display .= "<input type='text' id='mlwComment".$mlw_question->question_id."' name='mlwComment".$mlw_question->question_id."' value='".$mlw_quiz_options->comment_field_text."' onclick='clear_field(this)'/>";
209
+ $mlw_display .= "<br />";
210
+ }
211
+ if ($mlw_question->hints != "")
212
+ {
213
+ $mlw_display .= "<p>Hint: ".$mlw_question->hints."</p>";
214
+ $mlw_display .= "<br />";
215
+ }
216
+ $mlw_display .= "<br />";
217
+ }
218
+
219
+ //Display comment box if needed
220
+ if ($mlw_quiz_options->comment_section == 0)
221
+ {
222
+ $mlw_display .= "<label for='mlwQuizComments'>".$mlw_quiz_options->message_comment."</label>";
223
+ $mlw_display .= "<textarea cols='80' rows='15' id='mlwQuizComments' name='mlwQuizComments' ></textarea>";
224
  $mlw_display .= "<br />";
225
  }
226
  $mlw_display .= "<input type='hidden' name='complete_quiz' value='confirmation' />";
262
  $mlw_question_answers .= $mlw_question->question_name . "\n";
263
  $mlw_question_answers .= "Your Answer: " . $mlw_user_answer . "\n";
264
  $mlw_question_answers .= "Correct Answer: " . $mlw_question->correct_answer . "\n";
265
+ if ($mlw_question->comments == 0)
266
+ {
267
+ $mlw_question_answers .= "Your Comments: " . $_POST["mlwComment".$mlw_question->question_id] . "\n";
268
+ }
269
  $mlw_question_answers .= "\n";
270
  }
271
  $mlw_total_score = round((($mlw_correct/$mlw_total_questions)*100), 2);
272
+
273
  //Prepare the after quiz message
274
  $mlw_message_after = $mlw_quiz_options->message_after;
275
  $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
282
  $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
283
  $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
284
  $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
285
+ $mlw_message_after = str_replace( "%COMMENT_SECTION%" , $_POST["mlwQuizComments"], $mlw_message_after);
286
  $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
287
  $mlw_display .= $mlw_message_after;
288
 
305
  $mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
306
  $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
307
  $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
308
+ $mlw_message = str_replace( "%COMMENT_SECTION%" , $_POST["mlwQuizComments"], $mlw_message);
309
  wp_mail($mlw_user_email, "Quiz Results", $mlw_message);
310
  }
311
  }
325
  $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
326
  $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
327
  $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
328
+ $mlw_message = str_replace( "%COMMENT_SECTION%" , $_POST["mlwQuizComments"], $mlw_message);
329
  $mlw_message .= " This email was generated by the Quiz Master Next script by Frank Corso";
330
  wp_mail($mlw_quiz_options->admin_email, "Quiz Results", $mlw_message);
331
  }
includes/mlw_quiz_admin.php CHANGED
@@ -12,14 +12,16 @@ function mlw_generate_quiz_admin()
12
  $table_name = $wpdb->prefix . "mlw_quizzes";
13
  $success = $_POST["create_quiz"];
14
  $quiz_name = $_POST["quiz_name"];
 
 
15
 
16
  //Create new quiz
17
  if ($success == "confirmation")
18
  {
19
  //Insert New Quiz Into Table
20
  $insert = "INSERT INTO " . $table_name .
21
- "(quiz_id, quiz_name, message_before, message_after, user_email_template, admin_email_template, submit_button_text, name_field_text, business_field_text, email_field_text, phone_field_text, system, show_score, send_user_email, send_admin_email, user_name, user_comp, user_email, user_phone, admin_email, quiz_views, quiz_taken, deleted) " .
22
- "VALUES (NULL , '" . $quiz_name . "' , 'Enter your text here', 'Enter your text here', 'Enter your text here', 'Enter your text here', 'Submit Quiz', 'Name', 'Business', 'Email', 'Phone Number', 0, 0, 0, 0, 0, 0, 0, 0, '".get_option( 'admin_email', 'Enter email' )."', 0, 0, 0)";
23
  $results = $wpdb->query( $insert );
24
  $hasCreatedQuiz = true;
25
 
12
  $table_name = $wpdb->prefix . "mlw_quizzes";
13
  $success = $_POST["create_quiz"];
14
  $quiz_name = $_POST["quiz_name"];
15
+ $hasCreatedQuiz = false;
16
+ $hasDeletedQuiz = false;
17
 
18
  //Create new quiz
19
  if ($success == "confirmation")
20
  {
21
  //Insert New Quiz Into Table
22
  $insert = "INSERT INTO " . $table_name .
23
+ "(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, system, 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) " .
24
+ "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', 0, 0, 0, 0, 0, 0, 0, 0, '".get_option( 'admin_email', 'Enter email' )."', 0, 0, 0, 0)";
25
  $results = $wpdb->query( $insert );
26
  $hasCreatedQuiz = true;
27
 
includes/mlw_quiz_install.php CHANGED
@@ -2,7 +2,6 @@
2
  /*
3
  These functions are used for installing and uninstalling all necessary databases, options, page, etc.. for the plugin to work properly.
4
  */
5
-
6
  function mlw_quiz_activate()
7
  {
8
  global $wpdb;
@@ -22,6 +21,8 @@ function mlw_quiz_activate()
22
  message_before TEXT NOT NULL,
23
 
24
  message_after TEXT NOT NULL,
 
 
25
 
26
  user_email_template TEXT NOT NULL,
27
 
@@ -36,6 +37,8 @@ function mlw_quiz_activate()
36
  email_field_text TEXT NOT NULL,
37
 
38
  phone_field_text TEXT NOT NULL,
 
 
39
 
40
  system INT NOT NULL,
41
 
@@ -54,6 +57,8 @@ function mlw_quiz_activate()
54
  user_phone INT NOT NULL,
55
 
56
  admin_email TEXT NOT NULL,
 
 
57
 
58
  quiz_views INT NOT NULL,
59
 
@@ -70,6 +75,29 @@ function mlw_quiz_activate()
70
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
71
  dbDelta($sql);
72
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
  global $wpdb;
75
 
@@ -112,6 +140,10 @@ function mlw_quiz_activate()
112
  answer_six_points INT NOT NULL,
113
 
114
  correct_answer INT NOT NULL,
 
 
 
 
115
 
116
  deleted INT NOT NULL,
117
 
@@ -124,6 +156,25 @@ function mlw_quiz_activate()
124
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
125
  dbDelta($sql);
126
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
 
128
  global $wpdb;
129
 
@@ -201,11 +252,15 @@ function mlw_quiz_activate()
201
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
202
  dbDelta($sql);
203
  }
204
- $data = "0.4.1";
205
  if ( ! get_option('mlw_quiz_master_version'))
206
  {
207
  add_option('mlw_quiz_master_version' , $data);
208
  }
 
 
 
 
209
  }
210
 
211
  function mlw_quiz_deactivate()
2
  /*
3
  These functions are used for installing and uninstalling all necessary databases, options, page, etc.. for the plugin to work properly.
4
  */
 
5
  function mlw_quiz_activate()
6
  {
7
  global $wpdb;
21
  message_before TEXT NOT NULL,
22
 
23
  message_after TEXT NOT NULL,
24
+
25
+ message_comment TEXT NOT NULL,
26
 
27
  user_email_template TEXT NOT NULL,
28
 
37
  email_field_text TEXT NOT NULL,
38
 
39
  phone_field_text TEXT NOT NULL,
40
+
41
+ comment_field_text TEXT NOT NULL,
42
 
43
  system INT NOT NULL,
44
 
57
  user_phone INT NOT NULL,
58
 
59
  admin_email TEXT NOT NULL,
60
+
61
+ comment_section INT NOT NULL,
62
 
63
  quiz_views INT NOT NULL,
64
 
75
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
76
  dbDelta($sql);
77
  }
78
+
79
+ else
80
+
81
+ {
82
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'comment_section'") != "comment_section")
83
+ {
84
+ $sql = "ALTER TABLE ".$table_name." ADD comment_field_text TEXT NOT NULL AFTER phone_field_text";
85
+
86
+ $results = $wpdb->query( $sql );
87
+
88
+ $sql = "ALTER TABLE ".$table_name." ADD comment_section INT NOT NULL AFTER admin_email";
89
+
90
+ $results = $wpdb->query( $sql );
91
+
92
+ $sql = "ALTER TABLE ".$table_name." ADD message_comment TEXT NOT NULL AFTER message_after";
93
+
94
+ $results = $wpdb->query( $sql );
95
+
96
+ $update_sql = "UPDATE ".$table_name." SET comment_field_text='Comments', comment_section=0, message_comment='Enter You Text Here'";
97
+
98
+ $results = $wpdb->query( $update_sql );
99
+ }
100
+ }
101
 
102
  global $wpdb;
103
 
140
  answer_six_points INT NOT NULL,
141
 
142
  correct_answer INT NOT NULL,
143
+
144
+ comments INT NOT NULL,
145
+
146
+ hints TEXT NOT NULL,
147
 
148
  deleted INT NOT NULL,
149
 
156
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
157
  dbDelta($sql);
158
  }
159
+
160
+ else
161
+
162
+ {
163
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'comments'") != "comments")
164
+ {
165
+ $sql = "ALTER TABLE ".$table_name." ADD comments INT NOT NULL AFTER correct_answer";
166
+
167
+ $results = $wpdb->query( $sql );
168
+
169
+ $sql = "ALTER TABLE ".$table_name." ADD hints TEXT NOT NULL AFTER comments";
170
+
171
+ $results = $wpdb->query( $sql );
172
+
173
+ $update_sql = "UPDATE ".$table_name." SET comments=0, hints=''";
174
+
175
+ $results = $wpdb->query( $update_sql );
176
+ }
177
+ }
178
 
179
  global $wpdb;
180
 
252
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
253
  dbDelta($sql);
254
  }
255
+ $data = "0.5";
256
  if ( ! get_option('mlw_quiz_master_version'))
257
  {
258
  add_option('mlw_quiz_master_version' , $data);
259
  }
260
+ else
261
+ {
262
+ update_option('mlw_quiz_master_version' , $data);
263
+ }
264
  }
265
 
266
  function mlw_quiz_deactivate()
includes/mlw_quiz_options.php CHANGED
@@ -32,6 +32,8 @@ function mlw_generate_quiz_options()
32
  $answer_six = $_POST["answer_six"];
33
  $answer_six_points = $_POST["answer_six_points"];
34
  $correct_answer = $_POST["correct_answer"];
 
 
35
 
36
  //Variables from edit question form
37
  $edit_question_success = $_POST["edit_question"];
@@ -50,12 +52,14 @@ function mlw_generate_quiz_options()
50
  $edit_answer_six_points = $_POST["edit_answer_six_points"];
51
  $edit_correct_answer = $_POST["edit_correct_answer"];
52
  $mlw_edit_question_id = $_POST["edit_question_id"];
 
 
53
 
54
  //Edit question
55
  if ($edit_question_success == "confirmation")
56
  {
57
  $quiz_id = $_POST["quiz_id"];
58
- $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."' WHERE question_id=".$mlw_edit_question_id;
59
  $results = $wpdb->query( $update );
60
  $hasUpdatedQuestion = true;
61
 
@@ -97,7 +101,7 @@ function mlw_generate_quiz_options()
97
  $quiz_id = $_POST["quiz_id"];
98
  $table_name = $wpdb->prefix . "mlw_questions";
99
  $insert = "INSERT INTO " . $table_name .
100
- " (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, 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.", 0)";
101
  $results = $wpdb->query( $insert );
102
  $hasCreatedQuestion = true;
103
 
@@ -136,12 +140,14 @@ function mlw_generate_quiz_options()
136
  $mlw_business_field_text = $_POST["mlw_businessText"];
137
  $mlw_email_field_text = $_POST["mlw_emailText"];
138
  $mlw_phone_field_text = $_POST["mlw_phoneText"];
 
 
139
 
140
  //Submit saved templates into database
141
  if ($save_template_success == "confirmation")
142
  {
143
  $quiz_id = $_POST["quiz_id"];
144
- $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET message_before='".$mlw_before_message."', 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;
145
  $results = $wpdb->query( $update );
146
  $hasUpdatedTemplates = true;
147
 
@@ -170,12 +176,13 @@ function mlw_generate_quiz_options()
170
  $mlw_user_email = $_POST["userEmail"];
171
  $mlw_user_phone = $_POST["userPhone"];
172
  $mlw_admin_email = $_POST["adminEmail"];
 
173
 
174
  //Submit saved options into database
175
  if ($save_options_success == "confirmation")
176
  {
177
  $quiz_id = $_POST["quiz_id"];
178
- $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET system='".$mlw_system."', send_user_email='".$mlw_send_user_email."', send_admin_email='".$mlw_send_admin_email."', 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."' WHERE quiz_id=".$quiz_id;
179
  $results = $wpdb->query( $update );
180
  $hasUpdatedOptions = true;
181
 
@@ -316,6 +323,15 @@ function mlw_generate_quiz_options()
316
  $j(function() {
317
  $j( "#userPhone" ).buttonset();
318
  });
 
 
 
 
 
 
 
 
 
319
  $j(function() {
320
  $j("button").button();
321
 
@@ -355,7 +371,7 @@ function mlw_generate_quiz_options()
355
  idText.innerHTML = id;
356
  idHidden.value = id;
357
  };
358
- function editQuestion(id, question, answerOne, answerOnePoints, answerTwo, answerTwoPoints, answerThree, answerThreePoints, answerFour, answerFourPoints, answerFive, answerFivePoints, answerSix, answerSixPoints, correctAnswer){
359
  $j("#edit_question_dialog").dialog({
360
  autoOpen: false,
361
  show: 'blind',
@@ -382,12 +398,15 @@ function mlw_generate_quiz_options()
382
  document.getElementById("edit_answer_four_points").value = answerFourPoints;
383
  document.getElementById("edit_answer_five_points").value = answerFivePoints;
384
  document.getElementById("edit_answer_six_points").value = answerSixPoints;
 
385
  if (correctAnswer == 1) document.getElementById("edit_correct_one").checked = true;
386
  if (correctAnswer == 2) document.getElementById("edit_correct_two").checked = true;
387
  if (correctAnswer == 3) document.getElementById("edit_correct_three").checked = true;
388
  if (correctAnswer == 4) document.getElementById("edit_correct_four").checked = true;
389
  if (correctAnswer == 5) document.getElementById("edit_correct_five").checked = true;
390
  if (correctAnswer == 6) document.getElementById("edit_correct_six").checked = true;
 
 
391
  };
392
  </script>
393
  <style>
@@ -475,7 +494,7 @@ function mlw_generate_quiz_options()
475
  else $alternate = " class=\"alternate\"";
476
  $question_list .= "<tr{$alternate}>";
477
  $question_list .= "<td><span style='font-size:16px;'>" . $mlw_question_info->question_id . "</span></td>";
478
- $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."','".$mlw_question_info->question_name."','".$mlw_question_info->answer_one."','".$mlw_question_info->answer_one_points."','".$mlw_question_info->answer_two."','".$mlw_question_info->answer_two_points."','".$mlw_question_info->answer_three."','".$mlw_question_info->answer_three_points."','".$mlw_question_info->answer_four."','".$mlw_question_info->answer_four_points."','".$mlw_question_info->answer_five."','".$mlw_question_info->answer_five_points."','".$mlw_question_info->answer_six."','".$mlw_question_info->answer_six_points."','".$mlw_question_info->correct_answer."')\" href='#'>Edit</a> | <a onclick=\"deleteQuestion('".$mlw_question_info->question_id."')\" href='#'>Delete</a></span></div></td>";
479
  $question_list .= "</tr>";
480
  }
481
 
@@ -599,6 +618,19 @@ function mlw_generate_quiz_options()
599
  </td>
600
  <td><input type="radio" name="correct_answer" value=6 /></td>
601
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
602
  </thead>
603
  </table>
604
  <?php
@@ -719,6 +751,19 @@ function mlw_generate_quiz_options()
719
  </td>
720
  <td><input type="radio" id="edit_correct_six" name="edit_correct_answer" value=6 /></td>
721
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
722
  </thead>
723
  </table>
724
  <?php
@@ -753,6 +798,9 @@ function mlw_generate_quiz_options()
753
  <td><strong>%QUIZ_NAME%</strong> - The name of the quiz</td>
754
  <td><strong>%QUESTIONS_ANSWERS%</strong> - Shows the question, the answer the user provided, and the correct answer</td>
755
  </tr>
 
 
 
756
  </table>
757
  <button id="save_template_button" onclick="javascript: document.quiz_template_form.submit();">Save Templates</button><button id="template_tab_help">Help</button>
758
  <?php
@@ -774,6 +822,16 @@ function mlw_generate_quiz_options()
774
  <td><textarea cols="80" rows="15" id="mlw_quiz_before_message" name="mlw_quiz_before_message"><?php echo $mlw_quiz_options->message_before; ?></textarea>
775
  </td>
776
  </tr>
 
 
 
 
 
 
 
 
 
 
777
  <tr>
778
  <td width="30%">
779
  <strong>Message Displayed After Quiz</strong>
@@ -815,7 +873,7 @@ function mlw_generate_quiz_options()
815
  <p style="margin: 2px 0">- %USER_EMAIL%</p>
816
  <p style="margin: 2px 0">- %QUESTIONS_ANSWERS%</p>
817
  </td>
818
- <td><textarea cols="80" rows="15" id="mlw_quiz_before_message" name="mlw_quiz_user_email_template"><?php echo $mlw_quiz_options->user_email_template; ?></textarea>
819
  </td>
820
  </tr>
821
  <tr>
@@ -834,7 +892,7 @@ function mlw_generate_quiz_options()
834
  <p style="margin: 2px 0">- %QUIZ_NAME%</p>
835
  <p style="margin: 2px 0">- %QUESTIONS_ANSWERS%</p>
836
  </td>
837
- <td><textarea cols="80" rows="15" id="mlw_quiz_after_message" name="mlw_quiz_admin_email_template"><?php echo $mlw_quiz_options->admin_email_template; ?></textarea>
838
  </td>
839
  </tr>
840
  </table>
@@ -863,6 +921,10 @@ function mlw_generate_quiz_options()
863
  <th scope="row"><label for="mlw_phoneText">Text for phone number field</label></th>
864
  <td><input name="mlw_phoneText" type="text" id="mlw_phoneText" value="<?php echo $mlw_quiz_options->phone_field_text; ?>" class="regular-text" /></td>
865
  </tr>
 
 
 
 
866
  </table>
867
 
868
  </div>
@@ -935,6 +997,13 @@ function mlw_generate_quiz_options()
935
  <th scope="row"><label for="adminEmail">What email should we send the answers to?</label></th>
936
  <td><input name="adminEmail" type="email" id="adminEmail" value="<?php echo $mlw_quiz_options->admin_email; ?>" class="regular-text" /></td>
937
  </tr>
 
 
 
 
 
 
 
938
  </table>
939
  <?php echo "</form>"; ?>
940
  </div>
@@ -959,11 +1028,13 @@ function mlw_generate_quiz_options()
959
  <div id="questions_help_dialog" title="Help">
960
  <p>The question table lists the ID of the question and the question itself.</p>
961
  <p>To edit a question, use the Edit link below the question.</p>
962
- <p>To add a question, click on the Add Question button. This will open a window for you to add a question. The window will ask for the question and up to 6 answers. If you are using the points system, enter in the amount of points each answer is worth. If you are using the correct system, check the answer that is the correct answer. Click create question when you are finished.</p>
 
963
  </div>
964
  <div id="templates_help_dialog" title="Help">
965
  <p>This tab is used to edit the different messages the user and admin may see.</p>
966
  <p>The Message Displayed Before Quiz text is shown to the user at the beginning of the quiz.</p>
 
967
  <p>The Message Displayed After Quiz text is show to the user at the end of the quiz.</p>
968
  <p>The Email sent to user after completion text is the email that is sent to the user after completing the quiz. (This is only used if you have turned on the option on the options tab.)</p>
969
  <p>The Email sent to admin after completion text is the email that is sent to the admin after the quiz has been completed. Along with this text, the answers to the quiz will also be attached in the email.</p>
@@ -977,7 +1048,8 @@ function mlw_generate_quiz_options()
977
  <p>The third option asks whether you want the user to be emailed after completing the quiz.</p>
978
  <p>The next four options asks whether you want the quiz to ask for the user's name, business, email, and phone number.</p>
979
  <p>The next option asks if you want the admin to receive an email after a quiz has been taken.</p>
980
- <p>The last option asks for the email address of the admin you would like the quiz to email.</p>
 
981
  </div>
982
 
983
  <?php
32
  $answer_six = $_POST["answer_six"];
33
  $answer_six_points = $_POST["answer_six_points"];
34
  $correct_answer = $_POST["correct_answer"];
35
+ $comments = $_POST["comments"];
36
+ $hint = $_POST["hint"];
37
 
38
  //Variables from edit question form
39
  $edit_question_success = $_POST["edit_question"];
52
  $edit_answer_six_points = $_POST["edit_answer_six_points"];
53
  $edit_correct_answer = $_POST["edit_correct_answer"];
54
  $mlw_edit_question_id = $_POST["edit_question_id"];
55
+ $edit_comments = $_POST["edit_comments"];
56
+ $edit_hint = $_POST["edit_hint"];
57
 
58
  //Edit question
59
  if ($edit_question_success == "confirmation")
60
  {
61
  $quiz_id = $_POST["quiz_id"];
62
+ $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."' WHERE question_id=".$mlw_edit_question_id;
63
  $results = $wpdb->query( $update );
64
  $hasUpdatedQuestion = true;
65
 
101
  $quiz_id = $_POST["quiz_id"];
102
  $table_name = $wpdb->prefix . "mlw_questions";
103
  $insert = "INSERT INTO " . $table_name .
104
+ " (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, 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."', 0)";
105
  $results = $wpdb->query( $insert );
106
  $hasCreatedQuestion = true;
107
 
140
  $mlw_business_field_text = $_POST["mlw_businessText"];
141
  $mlw_email_field_text = $_POST["mlw_emailText"];
142
  $mlw_phone_field_text = $_POST["mlw_phoneText"];
143
+ $mlw_before_comments = $_POST["mlw_quiz_before_comments"];
144
+ $mlw_comment_field_text = $_POST["mlw_commentText"];
145
 
146
  //Submit saved templates into database
147
  if ($save_template_success == "confirmation")
148
  {
149
  $quiz_id = $_POST["quiz_id"];
150
+ $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET message_before='".$mlw_before_message."', message_comment='".$mlw_before_comments."', comment_field_text='".$mlw_comment_field_text."', 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;
151
  $results = $wpdb->query( $update );
152
  $hasUpdatedTemplates = true;
153
 
176
  $mlw_user_email = $_POST["userEmail"];
177
  $mlw_user_phone = $_POST["userPhone"];
178
  $mlw_admin_email = $_POST["adminEmail"];
179
+ $mlw_comment_section = $_POST["commentSection"];
180
 
181
  //Submit saved options into database
182
  if ($save_options_success == "confirmation")
183
  {
184
  $quiz_id = $_POST["quiz_id"];
185
+ $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET system='".$mlw_system."', send_user_email='".$mlw_send_user_email."', send_admin_email='".$mlw_send_admin_email."', 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."' WHERE quiz_id=".$quiz_id;
186
  $results = $wpdb->query( $update );
187
  $hasUpdatedOptions = true;
188
 
323
  $j(function() {
324
  $j( "#userPhone" ).buttonset();
325
  });
326
+ $j(function() {
327
+ $j( "#commentSection" ).buttonset();
328
+ });
329
+ $j(function() {
330
+ $j( "#comments" ).buttonset();
331
+ });
332
+ $j(function() {
333
+ $j( "#edit_comments" ).buttonset();
334
+ });
335
  $j(function() {
336
  $j("button").button();
337
 
371
  idText.innerHTML = id;
372
  idHidden.value = id;
373
  };
374
+ function editQuestion(id, question, answerOne, answerOnePoints, answerTwo, answerTwoPoints, answerThree, answerThreePoints, answerFour, answerFourPoints, answerFive, answerFivePoints, answerSix, answerSixPoints, correctAnswer, comments, hint){
375
  $j("#edit_question_dialog").dialog({
376
  autoOpen: false,
377
  show: 'blind',
398
  document.getElementById("edit_answer_four_points").value = answerFourPoints;
399
  document.getElementById("edit_answer_five_points").value = answerFivePoints;
400
  document.getElementById("edit_answer_six_points").value = answerSixPoints;
401
+ document.getElementById("edit_hint").value = hint;
402
  if (correctAnswer == 1) document.getElementById("edit_correct_one").checked = true;
403
  if (correctAnswer == 2) document.getElementById("edit_correct_two").checked = true;
404
  if (correctAnswer == 3) document.getElementById("edit_correct_three").checked = true;
405
  if (correctAnswer == 4) document.getElementById("edit_correct_four").checked = true;
406
  if (correctAnswer == 5) document.getElementById("edit_correct_five").checked = true;
407
  if (correctAnswer == 6) document.getElementById("edit_correct_six").checked = true;
408
+ if (comments == 0) document.getElementById("editCommentRadio1").checked = true;
409
+ if (comments == 1) document.getElementById("editCommentRadio2").checked = true;
410
  };
411
  </script>
412
  <style>
494
  else $alternate = " class=\"alternate\"";
495
  $question_list .= "<tr{$alternate}>";
496
  $question_list .= "<td><span style='font-size:16px;'>" . $mlw_question_info->question_id . "</span></td>";
497
+ $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."','".$mlw_question_info->question_name."','".$mlw_question_info->answer_one."','".$mlw_question_info->answer_one_points."','".$mlw_question_info->answer_two."','".$mlw_question_info->answer_two_points."','".$mlw_question_info->answer_three."','".$mlw_question_info->answer_three_points."','".$mlw_question_info->answer_four."','".$mlw_question_info->answer_four_points."','".$mlw_question_info->answer_five."','".$mlw_question_info->answer_five_points."','".$mlw_question_info->answer_six."','".$mlw_question_info->answer_six_points."','".$mlw_question_info->correct_answer."','".$mlw_question_info->comments."','".$mlw_question_info->hints."')\" href='#'>Edit</a> | <a onclick=\"deleteQuestion('".$mlw_question_info->question_id."')\" href='#'>Delete</a></span></div></td>";
498
  $question_list .= "</tr>";
499
  }
500
 
618
  </td>
619
  <td><input type="radio" name="correct_answer" value=6 /></td>
620
  </tr>
621
+ <tr valign="top">
622
+ <th scope="row">Comments?</th>
623
+ <td><input type="radio" id="commentsRadio1" name="comments" checked="checked" value=0 /><label for="commentsRadio1">Yes</label></td>
624
+ <td><input type="radio" id="commentsRadio2" name="comments" value=1 /><label for="commentsRadio2">No</label></td>
625
+ </tr>
626
+ <tr valign="top">
627
+ <th scope="row">Hint</th>
628
+ <td>
629
+ <input type="text" name="hint" value="" id="hint" style="border-color:#000000;
630
+ color:#3300CC;
631
+ cursor:hand;"/>
632
+ </td>
633
+ </tr>
634
  </thead>
635
  </table>
636
  <?php
751
  </td>
752
  <td><input type="radio" id="edit_correct_six" name="edit_correct_answer" value=6 /></td>
753
  </tr>
754
+ <tr valign="top">
755
+ <th scope="row">Comments?</th>
756
+ <td><input type="radio" id="editCommentRadio1" name="edit_comments" value=0 /><label for="editCommentRadio1">Yes</label></td>
757
+ <td><input type="radio" id="editCommentRadio2" name="edit_comments" value=1 /><label for="editCommentRadio2">No</label></td>
758
+ </tr>
759
+ <tr valign="top">
760
+ <th scope="row">Hint</th>
761
+ <td>
762
+ <input type="text" name="edit_hint" value="" id="edit_hint" style="border-color:#000000;
763
+ color:#3300CC;
764
+ cursor:hand;"/>
765
+ </td>
766
+ </tr>
767
  </thead>
768
  </table>
769
  <?php
798
  <td><strong>%QUIZ_NAME%</strong> - The name of the quiz</td>
799
  <td><strong>%QUESTIONS_ANSWERS%</strong> - Shows the question, the answer the user provided, and the correct answer</td>
800
  </tr>
801
+ <tr>
802
+ <td><strong>%COMMENT_SECTION%</strong> - The comments the user entered into comment box if enabled</td>
803
+ </tr>
804
  </table>
805
  <button id="save_template_button" onclick="javascript: document.quiz_template_form.submit();">Save Templates</button><button id="template_tab_help">Help</button>
806
  <?php
822
  <td><textarea cols="80" rows="15" id="mlw_quiz_before_message" name="mlw_quiz_before_message"><?php echo $mlw_quiz_options->message_before; ?></textarea>
823
  </td>
824
  </tr>
825
+ <tr>
826
+ <td width="30%">
827
+ <strong>Message Displayed Before Comments Box If Enabled</strong>
828
+ <br />
829
+ <p>Allowed Variables: </p>
830
+ <p style="margin: 2px 0">- %QUIZ_NAME%</p>
831
+ </td>
832
+ <td><textarea cols="80" rows="15" id="mlw_quiz_before_comments" name="mlw_quiz_before_comments"><?php echo $mlw_quiz_options->message_comment; ?></textarea>
833
+ </td>
834
+ </tr>
835
  <tr>
836
  <td width="30%">
837
  <strong>Message Displayed After Quiz</strong>
873
  <p style="margin: 2px 0">- %USER_EMAIL%</p>
874
  <p style="margin: 2px 0">- %QUESTIONS_ANSWERS%</p>
875
  </td>
876
+ <td><textarea cols="80" rows="15" id="mlw_quiz_user_email_template" name="mlw_quiz_user_email_template"><?php echo $mlw_quiz_options->user_email_template; ?></textarea>
877
  </td>
878
  </tr>
879
  <tr>
892
  <p style="margin: 2px 0">- %QUIZ_NAME%</p>
893
  <p style="margin: 2px 0">- %QUESTIONS_ANSWERS%</p>
894
  </td>
895
+ <td><textarea cols="80" rows="15" id="mlw_quiz_admin_email_template" name="mlw_quiz_admin_email_template"><?php echo $mlw_quiz_options->admin_email_template; ?></textarea>
896
  </td>
897
  </tr>
898
  </table>
921
  <th scope="row"><label for="mlw_phoneText">Text for phone number field</label></th>
922
  <td><input name="mlw_phoneText" type="text" id="mlw_phoneText" value="<?php echo $mlw_quiz_options->phone_field_text; ?>" class="regular-text" /></td>
923
  </tr>
924
+ <tr valign="top">
925
+ <th scope="row"><label for="mlw_commentText">Text for comments field</label></th>
926
+ <td><input name="mlw_commentText" type="text" id="mlw_commentText" value="<?php echo $mlw_quiz_options->comment_field_text; ?>" class="regular-text" /></td>
927
+ </tr>
928
  </table>
929
 
930
  </div>
997
  <th scope="row"><label for="adminEmail">What email should we send the answers to?</label></th>
998
  <td><input name="adminEmail" type="email" id="adminEmail" value="<?php echo $mlw_quiz_options->admin_email; ?>" class="regular-text" /></td>
999
  </tr>
1000
+ <tr valign="top">
1001
+ <th scope="row"><label for="commentSection">Would you like a place for the user to enter comments?</label></th>
1002
+ <td><div id="commentSection">
1003
+ <input type="radio" id="radio21" name="commentSection" <?php if ($mlw_quiz_options->comment_section == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio21">Yes</label>
1004
+ <input type="radio" id="radio22" name="commentSection" <?php if ($mlw_quiz_options->comment_section == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio22">No</label>
1005
+ </div></td>
1006
+ </tr>
1007
  </table>
1008
  <?php echo "</form>"; ?>
1009
  </div>
1028
  <div id="questions_help_dialog" title="Help">
1029
  <p>The question table lists the ID of the question and the question itself.</p>
1030
  <p>To edit a question, use the Edit link below the question.</p>
1031
+ <p>To add a question, click on the Add Question button. This will open a window for you to add a question. The window will ask for the question and up to 6 answers. If you are using the points system, enter in the amount of points each answer is worth. If you are using the correct system, check the answer that is the correct answer.
1032
+ You can choose if you would like a comment field after the question be selecting yes to the Comment question. You can also have a hint displayed to the user. Click create question when you are finished.</p>
1033
  </div>
1034
  <div id="templates_help_dialog" title="Help">
1035
  <p>This tab is used to edit the different messages the user and admin may see.</p>
1036
  <p>The Message Displayed Before Quiz text is shown to the user at the beginning of the quiz.</p>
1037
+ <p>The Message Display Before Comment Box is shown to the user right before the section the user can type in comments if that option is enabled.</p>
1038
  <p>The Message Displayed After Quiz text is show to the user at the end of the quiz.</p>
1039
  <p>The Email sent to user after completion text is the email that is sent to the user after completing the quiz. (This is only used if you have turned on the option on the options tab.)</p>
1040
  <p>The Email sent to admin after completion text is the email that is sent to the admin after the quiz has been completed. Along with this text, the answers to the quiz will also be attached in the email.</p>
1048
  <p>The third option asks whether you want the user to be emailed after completing the quiz.</p>
1049
  <p>The next four options asks whether you want the quiz to ask for the user's name, business, email, and phone number.</p>
1050
  <p>The next option asks if you want the admin to receive an email after a quiz has been taken.</p>
1051
+ <p>The next option asks for the email address of the admin you would like the quiz to email.</p>
1052
+ <p>The last option asks if you would like for the user to be able to leave comments at the end of the quiz.</p>
1053
  </div>
1054
 
1055
  <?php
includes/mlw_tools.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ This page creates the main dashboard for the Quiz Master Next plugin
4
+ */
5
+ /*
6
+ Copyright 2013, My Local Webstop (email : fpcorso@mylocalwebstop.com)
7
+ */
8
+
9
+ function mlw_generate_quiz_tools(){
10
+ add_meta_box("wpss_mrts", 'Audit Trail', "mlw_tools_box", "quiz_wpss");
11
+ ?>
12
+ <!-- css -->
13
+ <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
14
+ <!-- jquery scripts -->
15
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
16
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
17
+ <script type="text/javascript">
18
+ var $j = jQuery.noConflict();
19
+ // increase the default animation speed to exaggerate the effect
20
+ $j.fx.speeds._default = 1000;
21
+ $j(function() {
22
+ $j('#dialog').dialog({
23
+ autoOpen: false,
24
+ show: 'blind',
25
+ hide: 'explode',
26
+ buttons: {
27
+ Ok: function() {
28
+ $j(this).dialog('close');
29
+ }
30
+ }
31
+ });
32
+
33
+ $j('#opener').click(function() {
34
+ $j('#dialog').dialog('open');
35
+ return false;
36
+ } );
37
+ });
38
+ </script>
39
+ <style type="text/css">
40
+ textarea{
41
+ border-color:#000000;
42
+ color:#3300CC;
43
+ cursor:hand;
44
+ }
45
+ p em {
46
+ padding-left: 1em;
47
+ color: #555;
48
+ font-weight: bold;
49
+ }
50
+ </style>
51
+ <div class="wrap">
52
+ <h2>Quiz Master Next Tools<a id="opener" href="">(?)</a></h2>
53
+
54
+ <div style="float:left; width:100%;" class="inner-sidebar1">
55
+ <?php do_meta_boxes('quiz_wpss','advanced',''); ?>
56
+ </div>
57
+
58
+ <!--<div style="clear:both"></div>-->
59
+
60
+ <div id="dialog" title="Help">
61
+ <h3><b>Help</b></h3>
62
+ <p>This page is the tools for the Quiz Master Next.</p>
63
+ <p>The first widget lists the audit trail.</p>
64
+ </div>
65
+
66
+ </div>
67
+ <?php
68
+ }
69
+
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) {
82
+ if($alternate) $alternate = "";
83
+ else $alternate = " class=\"alternate\"";
84
+ $quotes_list .= "<tr{$alternate}>";
85
+ $quotes_list .= "<td>" . $quote_data->trail_id . "</td>";
86
+ $quotes_list .= "<td>" . $quote_data->action_user . "</td>";
87
+ $quotes_list .= "<td>" . $quote_data->action ."</td>";
88
+ $quotes_list .= "<td>" . $quote_data->time . "</td>";
89
+ $quotes_list .= "</tr>";
90
+ }
91
+
92
+ $display .= "<table class=\"widefat\">";
93
+ $display .= "<thead><tr>
94
+ <th>ID</th>
95
+ <th>User</th>
96
+ <th>Action</th>
97
+ <th>Time</th>
98
+ </tr></thead>";
99
+ $display .= "<tbody id=\"the-list\">{$quotes_list}</tbody>";
100
+ $display .= "</table>";
101
+ ?>
102
+ <div>
103
+ <table width='100%'>
104
+ <tr>
105
+ <td align='left'>
106
+ <?php echo $display; ?>
107
+ </td>
108
+ </tr>
109
+ </table>
110
+ </div>
111
+ <?php
112
+ }
113
+ ?>
mlw_quizmaster2.php CHANGED
@@ -3,7 +3,7 @@
3
  /*
4
  Plugin Name: Quiz Master Next
5
  Description: This adds a quiz function to your website. This is the new version of the wildly popular Quiz Master.
6
- Version: 0.4.1
7
  Author: Frank Corso
8
  Author URI: http://www.mylocalwebstop.com/
9
  Plugin URI: http://www.mylocalwebstop.com/
@@ -29,6 +29,7 @@ include("includes/mlw_quiz_admin.php");
29
  include("includes/mlw_quiz_options.php");
30
  include("includes/mlw_quiz_install.php");
31
  include("includes/mlw_results.php");
 
32
 
33
 
34
  ///Activation Actions
@@ -47,7 +48,8 @@ function mlw_add_menu()
47
  add_submenu_page(__FILE__, 'Quizzes', 'Quizzes', 8, 'mlw_quiz_admin', 'mlw_generate_quiz_admin');
48
  add_submenu_page(__FILE__, 'Quiz Options', 'Quiz Options', 8, 'mlw_quiz_options', 'mlw_generate_quiz_options');
49
  add_submenu_page(__FILE__, 'Quiz Results', 'Quiz Results', 8, 'mlw_quiz_results', 'mlw_generate_quiz_results');
50
- add_submenu_page(__FILE__, 'Support', 'Support', 8, 'mlw_quiz_tools', 'mlw_generate_main_page');
 
51
  }
52
  }
53
  /*
3
  /*
4
  Plugin Name: Quiz Master Next
5
  Description: This adds a quiz function to your website. This is the new version of the wildly popular Quiz Master.
6
+ Version: 0.5
7
  Author: Frank Corso
8
  Author URI: http://www.mylocalwebstop.com/
9
  Plugin URI: http://www.mylocalwebstop.com/
29
  include("includes/mlw_quiz_options.php");
30
  include("includes/mlw_quiz_install.php");
31
  include("includes/mlw_results.php");
32
+ include("includes/mlw_tools.php");
33
 
34
 
35
  ///Activation Actions
48
  add_submenu_page(__FILE__, 'Quizzes', 'Quizzes', 8, 'mlw_quiz_admin', 'mlw_generate_quiz_admin');
49
  add_submenu_page(__FILE__, 'Quiz Options', 'Quiz Options', 8, 'mlw_quiz_options', 'mlw_generate_quiz_options');
50
  add_submenu_page(__FILE__, 'Quiz Results', 'Quiz Results', 8, 'mlw_quiz_results', 'mlw_generate_quiz_results');
51
+ add_submenu_page(__FILE__, 'Tools', 'Tools', 8, 'mlw_quiz_tools', 'mlw_generate_quiz_tools');
52
+ add_submenu_page(__FILE__, 'Support', 'Support', 8, 'mlw_quiz_support', 'mlw_generate_main_page');
53
  }
54
  }
55
  /*
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: fpcorso
3
  Tags: quiz, test, score, survey
4
  Requires at least: 3.0.1
5
  Tested up to: 3.6.1
6
- Stable tag: 0.4.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -23,8 +23,11 @@ Features include:
23
  * Can email user after taking the quiz
24
  * Can email an admin after a user takes the quiz
25
  * Can score the quiz using an incorrect/correct system, a points based system, or a not-graded system
 
 
26
  * Saves the results after a user takes the quiz
27
  * Features audit trail so admins can keep track of who adds, edits, or deletes quizzes and questions
 
28
 
29
  == Installation ==
30
 
@@ -45,6 +48,13 @@ Feel free to use the support option on the main page of the plugin.
45
 
46
  == Changelog ==
47
 
 
 
 
 
 
 
 
48
  = 0.4.1 (September 15, 2013) =
49
  * Bug Fixes
50
 
3
  Tags: quiz, test, score, survey
4
  Requires at least: 3.0.1
5
  Tested up to: 3.6.1
6
+ Stable tag: 0.5
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
23
  * Can email user after taking the quiz
24
  * Can email an admin after a user takes the quiz
25
  * Can score the quiz using an incorrect/correct system, a points based system, or a not-graded system
26
+ * Can enable comment boxes for each question and/or comment section at the end of the quiz
27
+ * Can enable hints for questions
28
  * Saves the results after a user takes the quiz
29
  * Features audit trail so admins can keep track of who adds, edits, or deletes quizzes and questions
30
+ * Create surveys by utilizing the comment boxes instead of answers
31
 
32
  == Installation ==
33
 
48
 
49
  == Changelog ==
50
 
51
+ = 0.5 (September 18, 2013) =
52
+ * Created New Tools Page And Moved Audit Trail To It
53
+ * Added Ability For Comment Section At End Of Quiz
54
+ * Added Ability To Have Hints
55
+ * Added Option To Have Comment Boxes On Questions
56
+ * Added More Statistics To Main Page
57
+
58
  = 0.4.1 (September 15, 2013) =
59
  * Bug Fixes
60