Version Description
(September 1, 2013) = * Begun Development * Added ability to create/edit/delete quizzes * Added ability to create/edit/delete questions * Added quiz admin page * Added questions admin page * Added results page
=
Download this release
Release Info
Developer | fpcorso |
Plugin | Quiz And Survey Master (Formerly Quiz Master Next) |
Version | 0.1 |
Comparing to | |
See all releases |
Version 0.1
- assests/screenshot-1.png +0 -0
- assests/screenshot-2.png +0 -0
- includes/mlw_dashboard.php +14 -0
- includes/mlw_main_page.php +327 -0
- includes/mlw_quiz.php +244 -0
- includes/mlw_quiz_admin.php +241 -0
- includes/mlw_quiz_install.php +182 -0
- includes/mlw_quiz_options.php +941 -0
- includes/mlw_results.php +124 -0
- mlw_quizmaster2.php +57 -0
- readme.txt +57 -0
- uninstall.php +21 -0
assests/screenshot-1.png
ADDED
Binary file
|
assests/screenshot-2.png
ADDED
Binary file
|
includes/mlw_dashboard.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
This function creates a widget for the dashboard
|
4 |
+
*/
|
5 |
+
function mlw_quiz_dashboard()
|
6 |
+
{
|
7 |
+
echo "You are currently looking at the new dashboard widget for the Quiz Master 2.0!";
|
8 |
+
}
|
9 |
+
|
10 |
+
function mlw_add_dashboard_widget()
|
11 |
+
{
|
12 |
+
wp_add_dashboard_widget('custom_help_widget', 'Quiz Master 2.0', 'mlw_quiz_dashboard');
|
13 |
+
}
|
14 |
+
?>
|
includes/mlw_main_page.php
ADDED
@@ -0,0 +1,327 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Generates the Main Admin Panel for Quiz Master Next
|
4 |
+
*/
|
5 |
+
/*
|
6 |
+
Copyright 2013, My Local Webstop (email : fpcorso@mylocalwebstop.com)
|
7 |
+
*/
|
8 |
+
|
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");
|
15 |
+
add_meta_box("wpss_mrts", 'News From My Local Webstop', "quiz_wpss_mrt_meta_box4", "quiz_wpss4");
|
16 |
+
add_meta_box("wpss_mrts", 'Contribution', "quiz_wpss_mrt_meta_box5", "quiz_wpss5");
|
17 |
+
add_meta_box("wpss_mrts", 'Brainstorm Idea', "quiz_wpss_mrt_meta_box6", "quiz_wpss6");
|
18 |
+
?>
|
19 |
+
<!-- css -->
|
20 |
+
<link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
|
21 |
+
<!-- jquery scripts -->
|
22 |
+
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
|
23 |
+
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
|
24 |
+
<script type="text/javascript">
|
25 |
+
var $j = jQuery.noConflict();
|
26 |
+
// increase the default animation speed to exaggerate the effect
|
27 |
+
$j.fx.speeds._default = 1000;
|
28 |
+
$j(function() {
|
29 |
+
$j('#dialog').dialog({
|
30 |
+
autoOpen: false,
|
31 |
+
show: 'blind',
|
32 |
+
hide: 'explode',
|
33 |
+
buttons: {
|
34 |
+
Ok: function() {
|
35 |
+
$j(this).dialog('close');
|
36 |
+
}
|
37 |
+
}
|
38 |
+
});
|
39 |
+
|
40 |
+
$j('#opener').click(function() {
|
41 |
+
$j('#dialog').dialog('open');
|
42 |
+
return false;
|
43 |
+
} );
|
44 |
+
});
|
45 |
+
</script>
|
46 |
+
<style type="text/css">
|
47 |
+
div.quiz_email_support {
|
48 |
+
text-align: left;
|
49 |
+
}
|
50 |
+
div.quiz_email_support input[type='text'] {
|
51 |
+
border-color:#000000;
|
52 |
+
color:#3300CC;
|
53 |
+
cursor:hand;
|
54 |
+
}
|
55 |
+
textarea{
|
56 |
+
border-color:#000000;
|
57 |
+
color:#3300CC;
|
58 |
+
cursor:hand;
|
59 |
+
}
|
60 |
+
div.donation {
|
61 |
+
border-width: 1px;
|
62 |
+
border-style: solid;
|
63 |
+
padding: 0 0.6em;
|
64 |
+
margin: 5px 0 15px;
|
65 |
+
-moz-border-radius: 3px;
|
66 |
+
-khtml-border-radius: 3px;
|
67 |
+
-webkit-border-radius: 3px;
|
68 |
+
border-radius: 3px;
|
69 |
+
background-color: #ffffe0;
|
70 |
+
border-color: #e6db55;
|
71 |
+
text-align: center;
|
72 |
+
}
|
73 |
+
donation.p { margin: 0.5em 0;
|
74 |
+
line-height: 1;
|
75 |
+
padding: 2px;
|
76 |
+
}
|
77 |
+
p em {
|
78 |
+
padding-left: 1em;
|
79 |
+
color: #555;
|
80 |
+
font-weight: bold;
|
81 |
+
}
|
82 |
+
</style>
|
83 |
+
<div class="wrap">
|
84 |
+
<h2>Quiz Master Next <a id="opener" href="">(?)</a></h2>
|
85 |
+
|
86 |
+
<h3>Version 0.1</h3>
|
87 |
+
<p>Thank you for trying out my new plugin. I hope you find it beneficial to your website.</p>
|
88 |
+
|
89 |
+
<div style="float:left; width:60%;" class="inner-sidebar1">
|
90 |
+
<?php do_meta_boxes('quiz_wpss','advanced',''); ?>
|
91 |
+
</div>
|
92 |
+
|
93 |
+
<div style="float:right; width:36%; " class="inner-sidebar1">
|
94 |
+
<?php do_meta_boxes('quiz_wpss2','advanced',''); ?>
|
95 |
+
</div>
|
96 |
+
|
97 |
+
<!--<div style="clear:both"></div>-->
|
98 |
+
|
99 |
+
<div style="float:left; width:60%;" class="inner-sidebar1">
|
100 |
+
<?php do_meta_boxes('quiz_wpss3','advanced',''); ?>
|
101 |
+
</div>
|
102 |
+
|
103 |
+
<div style="float:right; width:36%; " class="inner-sidebar1">
|
104 |
+
<?php do_meta_boxes('quiz_wpss4','advanced',''); ?>
|
105 |
+
</div>
|
106 |
+
|
107 |
+
<!--<div style="clear:both"></div>-->
|
108 |
+
|
109 |
+
<!--<div style="float:left; width:100%;" class="inner-sidebar1">
|
110 |
+
<?php /* do_meta_boxes('quiz_wpss6','advanced',''); */?>
|
111 |
+
</div>-->
|
112 |
+
|
113 |
+
<div style="float:right; width:36%; " class="inner-sidebar1">
|
114 |
+
<?php do_meta_boxes('quiz_wpss5','advanced',''); ?>
|
115 |
+
</div>
|
116 |
+
|
117 |
+
<div id="dialog" title="Help">
|
118 |
+
<h3><b>Help</b></h3>
|
119 |
+
<p>This page is the main admin page for the Quiz Master Next.</p>
|
120 |
+
<p>The first widget lists all the statistics collected so far.</p>
|
121 |
+
<p>The second widget lists all the new features added in this update.</p>
|
122 |
+
<p>The third widget contains a contact form for emailing the developer.</p>
|
123 |
+
<p>The fourth widget shows news from My Local Webstop regarding our plugins</p>
|
124 |
+
<p>The last widget is our donation widget.</p>
|
125 |
+
</div>
|
126 |
+
|
127 |
+
</div>
|
128 |
+
<?php
|
129 |
+
}
|
130 |
+
|
131 |
+
function quiz_wpss_mrt_meta_box()
|
132 |
+
{
|
133 |
+
global $wpdb;
|
134 |
+
$sql = "SELECT SUM(quiz_views) AS QuizViews FROM " . $wpdb->prefix . "mlw_quizzes";
|
135 |
+
$mlw_quiz_views = $wpdb->get_results($sql);
|
136 |
+
|
137 |
+
foreach($mlw_quiz_views as $mlw_eaches) {
|
138 |
+
$mlw_quiz_views = $mlw_eaches->QuizViews;
|
139 |
+
break;
|
140 |
+
}
|
141 |
+
|
142 |
+
$sql = "SELECT SUM(quiz_taken) AS QuizTaken FROM " . $wpdb->prefix . "mlw_quizzes";
|
143 |
+
$mlw_quiz_taken = $wpdb->get_results($sql);
|
144 |
+
|
145 |
+
foreach($mlw_quiz_taken as $mlw_eaches) {
|
146 |
+
$mlw_quiz_taken = $mlw_eaches->QuizTaken;
|
147 |
+
break;
|
148 |
+
}
|
149 |
+
?>
|
150 |
+
<div>
|
151 |
+
<table width='100%'>
|
152 |
+
<tr>
|
153 |
+
<td align='left'>Total Times All Quizzes Have Been Viewed</td>
|
154 |
+
<td align='right'><?php echo $mlw_quiz_views; ?></td>
|
155 |
+
</tr>
|
156 |
+
<tr>
|
157 |
+
<td align='left'>Total Times All Quizzes Have Been Taken</td>
|
158 |
+
<td align='right'><?php echo $mlw_quiz_taken; ?></td>
|
159 |
+
</tr>
|
160 |
+
</table>
|
161 |
+
</div>
|
162 |
+
<?php
|
163 |
+
}
|
164 |
+
|
165 |
+
function quiz_wpss_mrt_meta_box2()
|
166 |
+
{
|
167 |
+
?>
|
168 |
+
<div>
|
169 |
+
<table width='100%'>
|
170 |
+
<tr>
|
171 |
+
<td align='left'>0.1 (September 1, 2013)</td>
|
172 |
+
</tr>
|
173 |
+
<tr>
|
174 |
+
<td align='left'>* Begun Development</td>
|
175 |
+
</tr>
|
176 |
+
<tr>
|
177 |
+
<td align='left'>* Added ability to create/edit/delete quizzes</td>
|
178 |
+
</tr>
|
179 |
+
<tr>
|
180 |
+
<td align='left'>* Added ability to create/edit/delete questions</td>
|
181 |
+
</tr>
|
182 |
+
<tr>
|
183 |
+
<td align='left'>* Added quiz admin page</td>
|
184 |
+
</tr>
|
185 |
+
<tr>
|
186 |
+
<td align='left'>* Added questions admin page</td>
|
187 |
+
</tr>
|
188 |
+
<tr>
|
189 |
+
<td align='left'>* Added results page</td>
|
190 |
+
</tr>
|
191 |
+
<tr>
|
192 |
+
<td align='left'>* Added support page</td>
|
193 |
+
</tr>
|
194 |
+
</table>
|
195 |
+
</div>
|
196 |
+
<?php
|
197 |
+
}
|
198 |
+
|
199 |
+
function quiz_wpss_mrt_meta_box3()
|
200 |
+
{
|
201 |
+
/*
|
202 |
+
Copyright 2013, My Local Webstop
|
203 |
+
Please do not re-use this email script without contacting me.
|
204 |
+
*/
|
205 |
+
$quiz_master_email_success = $_POST["action"];
|
206 |
+
$user_name = $_POST["username"];
|
207 |
+
$user_email = $_POST["email"];
|
208 |
+
$user_message = $_POST["message"];
|
209 |
+
$quiz_master_email_message = "";
|
210 |
+
if ($quiz_master_email_success == update and $user_email != "" and $user_message != "")
|
211 |
+
{
|
212 |
+
wp_mail('fpcorso@mylocalwebstop.com' ,'Support From Quiz Master 2.0 Plugin','Message from ' . $user_name . ' at ' . $user_email . " It says: " . "\n" . $user_message);
|
213 |
+
$quiz_master_email_message = "<h3>Message Sent</h3>";
|
214 |
+
}
|
215 |
+
else if ($quiz_master_email_success == update and $user_email == "")
|
216 |
+
{
|
217 |
+
$quiz_master_email_message = "<h3>Please Enter Email</h3>";
|
218 |
+
}
|
219 |
+
else if ($quiz_master_email_success == update and $user_message == "")
|
220 |
+
{
|
221 |
+
$quiz_master_email_message = "<h3>Please Enter In Your Message</h3>";
|
222 |
+
}
|
223 |
+
?>
|
224 |
+
<div class='quiz_email_support'>
|
225 |
+
<form action="<?php echo $PHP_SELF; ?>" method='post'>
|
226 |
+
<input type='hidden' name='action' value='update' />
|
227 |
+
<table width='100%'>
|
228 |
+
<tr>
|
229 |
+
<td>If there is something you would like to suggest to add or even if you just want
|
230 |
+
to let me know if you like the plugin or not, feel free to use the email form below.</td>
|
231 |
+
</tr>
|
232 |
+
<tr>
|
233 |
+
<td><?php echo $quiz_master_email_message; ?></td>
|
234 |
+
</tr>
|
235 |
+
<tr>
|
236 |
+
<td align='left'><p>Name: <input type='text' name='username'/></p></td>
|
237 |
+
</tr>
|
238 |
+
<tr>
|
239 |
+
<td align='left'><p>Email: <input type='text' name='email'/></p></td>
|
240 |
+
</tr>
|
241 |
+
<tr>
|
242 |
+
<td align='left'><p>Message: </p></td>
|
243 |
+
</tr>
|
244 |
+
<tr>
|
245 |
+
<td align='left'><p><TEXTAREA NAME="message" COLS=40 ROWS=6></TEXTAREA></p></td>
|
246 |
+
</tr>
|
247 |
+
<tr>
|
248 |
+
<td align='left'><input type='submit' value='Send Email' /></td>
|
249 |
+
</tr>
|
250 |
+
<tr>
|
251 |
+
<td align='left'></td>
|
252 |
+
</tr>
|
253 |
+
</table>
|
254 |
+
</form>
|
255 |
+
</div>
|
256 |
+
<?php
|
257 |
+
}
|
258 |
+
|
259 |
+
function quiz_wpss_mrt_meta_box4()
|
260 |
+
{
|
261 |
+
?>
|
262 |
+
<div>
|
263 |
+
<table width='100%'>
|
264 |
+
<tr>
|
265 |
+
<td align='left'><?php include("http://www.mylocalwebstop.com/mlw_news.html"); ?></td>
|
266 |
+
</tr>
|
267 |
+
</table>
|
268 |
+
</div>
|
269 |
+
<?php
|
270 |
+
}
|
271 |
+
function quiz_wpss_mrt_meta_box5()
|
272 |
+
{
|
273 |
+
?>
|
274 |
+
<div>
|
275 |
+
<table width='100%'>
|
276 |
+
<tr>
|
277 |
+
<td align='left'>
|
278 |
+
I have spent a lot of time in development for this plugin. If you like it, please help by donating today.
|
279 |
+
</td>
|
280 |
+
</tr>
|
281 |
+
<tr>
|
282 |
+
<td> </td>
|
283 |
+
</tr>
|
284 |
+
<tr>
|
285 |
+
<td></td>
|
286 |
+
</tr>
|
287 |
+
<tr>
|
288 |
+
<td> </td>
|
289 |
+
</tr>
|
290 |
+
<tr>
|
291 |
+
<td>
|
292 |
+
<div class="donation">
|
293 |
+
<p>
|
294 |
+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
|
295 |
+
<input type="hidden" name="cmd" value="_donations">
|
296 |
+
<input type="hidden" name="business" value="fpcorso@gmail.com">
|
297 |
+
<input type="hidden" name="lc" value="US">
|
298 |
+
<input type="hidden" name="no_note" value="0">
|
299 |
+
<input type="hidden" name="currency_code" value="USD">
|
300 |
+
<input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest">
|
301 |
+
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
302 |
+
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
303 |
+
</form>
|
304 |
+
|
305 |
+
</p>
|
306 |
+
</div>
|
307 |
+
</td>
|
308 |
+
</tr>
|
309 |
+
</table>
|
310 |
+
</div>
|
311 |
+
<?php
|
312 |
+
}
|
313 |
+
function quiz_wpss_mrt_meta_box6()
|
314 |
+
{
|
315 |
+
?>
|
316 |
+
<div>
|
317 |
+
<table width='100%'>
|
318 |
+
<tr>
|
319 |
+
<td align='left'>
|
320 |
+
Box Six
|
321 |
+
</td>
|
322 |
+
</tr>
|
323 |
+
</table>
|
324 |
+
</div>
|
325 |
+
<?php
|
326 |
+
}
|
327 |
+
?>
|
includes/mlw_quiz.php
ADDED
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
This function is the very heart of the plugin. This function displays the quiz to the user as well as handles all the scripts that are part of the quiz. Please be very careful if you are editing this script without my assistance.
|
4 |
+
*/
|
5 |
+
function mlw_quiz_shortcode($atts)
|
6 |
+
{
|
7 |
+
extract(shortcode_atts(array(
|
8 |
+
'quiz' => 0
|
9 |
+
), $atts));
|
10 |
+
|
11 |
+
/*
|
12 |
+
Code before loading the quiz
|
13 |
+
*/
|
14 |
+
|
15 |
+
//Variables needed throughout script
|
16 |
+
$mlw_quiz_id = $quiz;
|
17 |
+
$mlw_display = "";
|
18 |
+
global $wpdb;
|
19 |
+
|
20 |
+
|
21 |
+
//Load quiz
|
22 |
+
$sql = "SELECT * FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=".$mlw_quiz_id." AND deleted='0'";
|
23 |
+
$mlw_quiz_options = $wpdb->get_results($sql);
|
24 |
+
|
25 |
+
foreach($mlw_quiz_options as $mlw_eaches) {
|
26 |
+
$mlw_quiz_options = $mlw_eaches;
|
27 |
+
break;
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
//Load questions
|
32 |
+
$sql = "SELECT * FROM " . $wpdb->prefix . "mlw_questions" . " WHERE quiz_id=".$mlw_quiz_id." AND deleted='0'";
|
33 |
+
$mlw_questions = $wpdb->get_results($sql);
|
34 |
+
|
35 |
+
|
36 |
+
//Variables to load if quiz has been taken
|
37 |
+
$mlw_success = $_POST["complete_quiz"];
|
38 |
+
$mlw_user_name = $_POST["mlwUserName"];
|
39 |
+
$mlw_user_comp = $_POST["mlwUserComp"];
|
40 |
+
$mlw_user_email = $_POST["mlwUserEmail"];
|
41 |
+
$mlw_user_phone = $_POST["mlwUserPhone"];
|
42 |
+
|
43 |
+
/*
|
44 |
+
The following code is for displaying the quiz and completion screen
|
45 |
+
*/
|
46 |
+
|
47 |
+
//If there is no quiz for the shortcode provided
|
48 |
+
if ($mlw_quiz_options->quiz_name == "")
|
49 |
+
{
|
50 |
+
$mlw_display .= "It appears this quiz is not set up correctly.";
|
51 |
+
return $mlw_display;
|
52 |
+
}
|
53 |
+
|
54 |
+
//Display Quiz
|
55 |
+
if ($mlw_success != "confirmation" AND $mlw_quiz_options->quiz_name != "")
|
56 |
+
{
|
57 |
+
//Update the quiz views
|
58 |
+
$mlw_views = $mlw_quiz_options->quiz_views;
|
59 |
+
$mlw_views += 1;
|
60 |
+
$update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET quiz_views='".$mlw_views."' WHERE quiz_id=".$mlw_quiz_id;
|
61 |
+
$results = $wpdb->query( $update );
|
62 |
+
|
63 |
+
//Begin the quiz
|
64 |
+
$mlw_message_before = $mlw_quiz_options->message_before;
|
65 |
+
$mlw_message_before = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_before);
|
66 |
+
$mlw_display .= "<p>".$mlw_message_before."</p>";
|
67 |
+
$mlw_display .= "<br />";
|
68 |
+
$mlw_display .= "<form action='" . $PHP_SELF . "' method='post'>";
|
69 |
+
$mlw_display .= "<table>";
|
70 |
+
$mlw_display .= "<thead>";
|
71 |
+
|
72 |
+
//See if the site wants to ask for anything, then ask for it
|
73 |
+
if ($mlw_quiz_options->user_name != 2)
|
74 |
+
{
|
75 |
+
$mlw_display .= "<tr valign='top'>";
|
76 |
+
$mlw_display .= "<th scope='row'>".$mlw_quiz_options->name_field_text."</th>";
|
77 |
+
$mlw_display .= "<td><input type='text' name='mlwUserName' value='' /></td>";
|
78 |
+
$mlw_display .= "</tr>";
|
79 |
+
|
80 |
+
}
|
81 |
+
if ($mlw_quiz_options->user_comp != 2)
|
82 |
+
{
|
83 |
+
$mlw_display .= "<tr valign='top'>";
|
84 |
+
$mlw_display .= "<th scope='row'>".$mlw_quiz_options->business_field_text."</th>";
|
85 |
+
$mlw_display .= "<td><input type='text' name='mlwUserComp' value='' /></td>";
|
86 |
+
$mlw_display .= "</tr>";
|
87 |
+
|
88 |
+
}
|
89 |
+
if ($mlw_quiz_options->user_email != 2)
|
90 |
+
{
|
91 |
+
$mlw_display .= "<tr valign='top'>";
|
92 |
+
$mlw_display .= "<th scope='row'>".$mlw_quiz_options->email_field_text."</th>";
|
93 |
+
$mlw_display .= "<td><input type='text' name='mlwUserEmail' value='' /></td>";
|
94 |
+
$mlw_display .= "</tr>";
|
95 |
+
|
96 |
+
}
|
97 |
+
if ($mlw_quiz_options->user_phone != 2)
|
98 |
+
{
|
99 |
+
$mlw_display .= "<tr valign='top'>";
|
100 |
+
$mlw_display .= "<th scope='row'>".$mlw_quiz_options->phone_field_text."</th>";
|
101 |
+
$mlw_display .= "<td><input type='text' name='mlwUserPhone' value='' /></td>";
|
102 |
+
$mlw_display .= "</tr>";
|
103 |
+
|
104 |
+
}
|
105 |
+
$mlw_display .= "</thead>";
|
106 |
+
$mlw_display .= "</table>";
|
107 |
+
$mlw_display .= "<br />";
|
108 |
+
|
109 |
+
//Display the questions
|
110 |
+
foreach($mlw_questions as $mlw_question) {
|
111 |
+
$mlw_display .= "<p>".$mlw_question->question_name."</p>";
|
112 |
+
if ($mlw_question->answer_one != "")
|
113 |
+
{
|
114 |
+
$mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='1' />".$mlw_question->answer_one;
|
115 |
+
$mlw_display .= "<br />";
|
116 |
+
}
|
117 |
+
if ($mlw_question->answer_two != "")
|
118 |
+
{
|
119 |
+
$mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='2' />".$mlw_question->answer_two;
|
120 |
+
$mlw_display .= "<br />";
|
121 |
+
}
|
122 |
+
if ($mlw_question->answer_three != "")
|
123 |
+
{
|
124 |
+
$mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='3' />".$mlw_question->answer_three;
|
125 |
+
$mlw_display .= "<br />";
|
126 |
+
}
|
127 |
+
if ($mlw_question->answer_four != "")
|
128 |
+
{
|
129 |
+
$mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='4' />".$mlw_question->answer_four;
|
130 |
+
$mlw_display .= "<br />";
|
131 |
+
}
|
132 |
+
if ($mlw_question->answer_five != "")
|
133 |
+
{
|
134 |
+
$mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='5' />".$mlw_question->answer_five;
|
135 |
+
$mlw_display .= "<br />";
|
136 |
+
}
|
137 |
+
if ($mlw_question->answer_six != "")
|
138 |
+
{
|
139 |
+
$mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='6' />".$mlw_question->answer_six;
|
140 |
+
$mlw_display .= "<br />";
|
141 |
+
}
|
142 |
+
$mlw_display .= "<br />";
|
143 |
+
}
|
144 |
+
$mlw_display .= "<input type='hidden' name='complete_quiz' value='confirmation' />";
|
145 |
+
$mlw_display .= "<input type='submit' value='".$mlw_quiz_options->submit_button_text."' />";
|
146 |
+
$mlw_display .= "</form>";
|
147 |
+
|
148 |
+
}
|
149 |
+
//Display Completion Screen
|
150 |
+
else
|
151 |
+
{
|
152 |
+
//Variables needed for scoring
|
153 |
+
$mlw_points = 0;
|
154 |
+
$mlw_correct = 0;
|
155 |
+
$mlw_total_questions = 0;
|
156 |
+
$mlw_total_score = 0;
|
157 |
+
|
158 |
+
//Update the amount of times the quiz has been taken
|
159 |
+
$mlw_taken = $mlw_quiz_options->quiz_taken;
|
160 |
+
$mlw_taken += 1;
|
161 |
+
$update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET quiz_taken='".$mlw_taken."' WHERE quiz_id=".$mlw_quiz_id;
|
162 |
+
$results = $wpdb->query( $update );
|
163 |
+
|
164 |
+
//See which answers were correct and award points if necessary
|
165 |
+
foreach($mlw_questions as $mlw_question) {
|
166 |
+
$mlw_total_questions += 1;
|
167 |
+
$mlw_user_answer = $_POST["question".$mlw_question->question_id];
|
168 |
+
if ($mlw_user_answer == $mlw_question->correct_answer)
|
169 |
+
{
|
170 |
+
$mlw_correct += 1;
|
171 |
+
}
|
172 |
+
if ($mlw_user_answer == 1) {$mlw_points += $mlw_question->answer_one_points;}
|
173 |
+
if ($mlw_user_answer == 2) {$mlw_points += $mlw_question->answer_two_points;}
|
174 |
+
if ($mlw_user_answer == 3) {$mlw_points += $mlw_question->answer_three_points;}
|
175 |
+
if ($mlw_user_answer == 4) {$mlw_points += $mlw_question->answer_four_points;}
|
176 |
+
if ($mlw_user_answer == 5) {$mlw_points += $mlw_question->answer_five_points;}
|
177 |
+
if ($mlw_user_answer == 6) {$mlw_points += $mlw_question->answer_six_points;}
|
178 |
+
}
|
179 |
+
$mlw_total_score = round((($mlw_correct/$mlw_total_questions)*100), 2);
|
180 |
+
|
181 |
+
//Prepare the after quiz message
|
182 |
+
$mlw_message_after = $mlw_quiz_options->message_after;
|
183 |
+
$mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
|
184 |
+
$mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
|
185 |
+
$mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
|
186 |
+
$mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
|
187 |
+
$mlw_message_after = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_after);
|
188 |
+
$mlw_message_after = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_after);
|
189 |
+
$mlw_message_after = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_after);
|
190 |
+
$mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
|
191 |
+
$mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
|
192 |
+
$mlw_display .= $mlw_message_after;
|
193 |
+
|
194 |
+
|
195 |
+
|
196 |
+
//Prepare and send the user email
|
197 |
+
$mlw_message = "";
|
198 |
+
if ($mlw_quiz_options->send_user_email == "0")
|
199 |
+
{
|
200 |
+
if ($mlw_user_email != "")
|
201 |
+
{
|
202 |
+
$mlw_message = $mlw_quiz_options->user_email_template;
|
203 |
+
$mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
|
204 |
+
$mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
|
205 |
+
$mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
|
206 |
+
$mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
|
207 |
+
$mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
|
208 |
+
$mlw_message = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message);
|
209 |
+
$mlw_message = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message);
|
210 |
+
$mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
|
211 |
+
$mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
|
212 |
+
wp_mail($mlw_user_email, "Quiz Results", $mlw_message);
|
213 |
+
}
|
214 |
+
}
|
215 |
+
|
216 |
+
//Prepare and send the admin email
|
217 |
+
$mlw_message = "";
|
218 |
+
if ($mlw_quiz_options->send_admin_email == "0")
|
219 |
+
{
|
220 |
+
$mlw_message = $mlw_quiz_options->admin_email_template;
|
221 |
+
$mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
|
222 |
+
$mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
|
223 |
+
$mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
|
224 |
+
$mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
|
225 |
+
$mlw_message = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message);
|
226 |
+
$mlw_message = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message);
|
227 |
+
$mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
|
228 |
+
$mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
|
229 |
+
$mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
|
230 |
+
$mlw_message .= " This email was generated by the Quiz Master 2.0 script by Frank Corso";
|
231 |
+
wp_mail($mlw_quiz_options->admin_email, "Quiz Results", $mlw_message);
|
232 |
+
}
|
233 |
+
|
234 |
+
//Save the results into database
|
235 |
+
global $wpdb;
|
236 |
+
$table_name = $wpdb->prefix . "mlw_results";
|
237 |
+
$insert = "INSERT INTO " . $table_name .
|
238 |
+
"(result_id, quiz_id, quiz_name, quiz_system, point_score, correct_score, correct, total, name, business, email, phone, time_taken, deleted) " .
|
239 |
+
"VALUES (NULL , " . $mlw_quiz_id . " , '".$mlw_quiz_options->quiz_name."', ".$mlw_quiz_options->system.", ".$mlw_points.", ".$mlw_total_score.", ".$mlw_correct.", ".$mlw_total_questions.", '".$mlw_user_name."', '".$mlw_user_comp."', '".$mlw_user_email."', '".$mlw_user_phone."', '".date("h:i:s A m/d/Y")."', 0)";
|
240 |
+
$results = $wpdb->query( $insert );
|
241 |
+
}
|
242 |
+
return $mlw_display;
|
243 |
+
}
|
244 |
+
?>
|
includes/mlw_quiz_admin.php
ADDED
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
This page lists all the quizzes currently on the website and allows you to create more quizzes.
|
4 |
+
*/
|
5 |
+
/*
|
6 |
+
Copyright 2013, My Local Webstop (email : fpcorso@mylocalwebstop.com)
|
7 |
+
*/
|
8 |
+
|
9 |
+
function mlw_generate_quiz_admin()
|
10 |
+
{
|
11 |
+
global $wpdb;
|
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 = "INSERT INTO " . $table_name .
|
20 |
+
"(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, user_name, user_comp, user_email, user_phone, admin_email, quiz_views, quiz_taken, deleted) " .
|
21 |
+
"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, '".get_option( 'admin_email', 'Enter email' )."', 0, 0, 0)";
|
22 |
+
$results = $wpdb->query( $insert );
|
23 |
+
$hasCreatedQuiz = true;
|
24 |
+
}
|
25 |
+
|
26 |
+
//Variables from delete question form
|
27 |
+
$delete_quiz_success = $_POST["delete_quiz"];
|
28 |
+
$mlw_quiz_id = $_POST["quiz_id"];
|
29 |
+
|
30 |
+
//Delete quiz
|
31 |
+
if ($delete_quiz_success == "confirmation")
|
32 |
+
{
|
33 |
+
$quiz_id = $_POST["quiz_id"];
|
34 |
+
$update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET deleted=1 WHERE quiz_id=".$mlw_quiz_id;
|
35 |
+
$results = $wpdb->query( $update );
|
36 |
+
$update = "UPDATE " . $wpdb->prefix . "mlw_questions" . " SET deleted=1 WHERE quiz_id=".$mlw_quiz_id;
|
37 |
+
$results = $wpdb->query( $update );
|
38 |
+
$hasDeletedQuiz = true;
|
39 |
+
}
|
40 |
+
|
41 |
+
|
42 |
+
global $wpdb;
|
43 |
+
|
44 |
+
$sql = "SELECT quiz_id, quiz_name, quiz_views, quiz_taken
|
45 |
+
FROM " . $wpdb->prefix . "mlw_quizzes WHERE deleted='0'";
|
46 |
+
$sql .= "ORDER BY quiz_id DESC";
|
47 |
+
|
48 |
+
$mlw_quiz_data = $wpdb->get_results($sql);
|
49 |
+
?>
|
50 |
+
<!-- css -->
|
51 |
+
<link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
|
52 |
+
<!-- jquery scripts -->
|
53 |
+
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
|
54 |
+
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
|
55 |
+
<script type="text/javascript">
|
56 |
+
var $j = jQuery.noConflict();
|
57 |
+
// increase the default animation speed to exaggerate the effect
|
58 |
+
$j.fx.speeds._default = 1000;
|
59 |
+
$j(function() {
|
60 |
+
$j('#dialog').dialog({
|
61 |
+
autoOpen: false,
|
62 |
+
show: 'blind',
|
63 |
+
hide: 'explode',
|
64 |
+
buttons: {
|
65 |
+
Ok: function() {
|
66 |
+
$j(this).dialog('close');
|
67 |
+
}
|
68 |
+
}
|
69 |
+
});
|
70 |
+
|
71 |
+
$j('#opener').click(function() {
|
72 |
+
$j('#dialog').dialog('open');
|
73 |
+
return false;
|
74 |
+
} );
|
75 |
+
});
|
76 |
+
$j(function() {
|
77 |
+
$j( document ).tooltip();
|
78 |
+
});
|
79 |
+
$j(function() {
|
80 |
+
$j("button").button();
|
81 |
+
|
82 |
+
});
|
83 |
+
$j(function() {
|
84 |
+
$j('#new_quiz_dialog').dialog({
|
85 |
+
autoOpen: false,
|
86 |
+
show: 'blind',
|
87 |
+
width:700,
|
88 |
+
hide: 'explode',
|
89 |
+
buttons: {
|
90 |
+
Cancel: function() {
|
91 |
+
$j(this).dialog('close');
|
92 |
+
}
|
93 |
+
}
|
94 |
+
});
|
95 |
+
|
96 |
+
$j('#new_quiz_button').click(function() {
|
97 |
+
$j('#new_quiz_dialog').dialog('open');
|
98 |
+
return false;
|
99 |
+
} );
|
100 |
+
});
|
101 |
+
function deleteQuiz(id){
|
102 |
+
$j("#delete_dialog").dialog({
|
103 |
+
autoOpen: false,
|
104 |
+
show: 'blind',
|
105 |
+
hide: 'explode',
|
106 |
+
buttons: {
|
107 |
+
Cancel: function() {
|
108 |
+
$j(this).dialog('close');
|
109 |
+
}
|
110 |
+
}
|
111 |
+
});
|
112 |
+
$j("#delete_dialog").dialog('open');
|
113 |
+
var idText = document.getElementById("delete_quiz_id");
|
114 |
+
var idHidden = document.getElementById("quiz_id");
|
115 |
+
idText.innerHTML = id;
|
116 |
+
idHidden.value = id;
|
117 |
+
};
|
118 |
+
</script>
|
119 |
+
<style>
|
120 |
+
label {
|
121 |
+
display: inline-block;
|
122 |
+
width: 5em;
|
123 |
+
}
|
124 |
+
</style>
|
125 |
+
<style type="text/css">
|
126 |
+
div.mlw_quiz_options input[type='text'] {
|
127 |
+
border-color:#000000;
|
128 |
+
color:#3300CC;
|
129 |
+
cursor:hand;
|
130 |
+
}
|
131 |
+
</style>
|
132 |
+
<div class="wrap">
|
133 |
+
<div class='mlw_quiz_options'>
|
134 |
+
<h2>Quizzes<a id="opener" href="">(?)</a></h2>
|
135 |
+
<?php if ($hasCreatedQuiz)
|
136 |
+
{
|
137 |
+
?>
|
138 |
+
<div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
|
139 |
+
<p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
|
140 |
+
<strong>Hey!</strong> Your new quiz has been created successfully.</p>
|
141 |
+
</div>
|
142 |
+
<?php
|
143 |
+
}
|
144 |
+
?>
|
145 |
+
<?php if ($hasDeletedQuiz)
|
146 |
+
{
|
147 |
+
?>
|
148 |
+
<div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
|
149 |
+
<p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
|
150 |
+
<strong>Hey!</strong> The quiz has been deleted.</p>
|
151 |
+
</div>
|
152 |
+
<?php
|
153 |
+
}
|
154 |
+
?>
|
155 |
+
|
156 |
+
<?php
|
157 |
+
$quotes_list = "";
|
158 |
+
$display = "";
|
159 |
+
foreach($mlw_quiz_data as $mlw_quiz_info) {
|
160 |
+
if($alternate) $alternate = "";
|
161 |
+
else $alternate = " class=\"alternate\"";
|
162 |
+
$quotes_list .= "<tr{$alternate}>";
|
163 |
+
$quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_id . "</span></td>";
|
164 |
+
$quotes_list .= "<td class='post-title column-title'><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_name ."</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."')\" href='#'>Delete</a> | <a href='admin.php?page=mlw_quiz_results&&quiz_id=".$mlw_quiz_info->quiz_id."'>Results</a></span></div></td>";
|
165 |
+
$quotes_list .= "<td><span style='font-size:16px;'>[mlw_quizmaster quiz=".$mlw_quiz_info->quiz_id."]</span></td>";
|
166 |
+
$quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_views . "</span></td>";
|
167 |
+
$quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_taken ."</span></td>";
|
168 |
+
$quotes_list .= "</tr>";
|
169 |
+
}
|
170 |
+
|
171 |
+
$display .= "<table class=\"widefat\">";
|
172 |
+
$display .= "<thead><tr>
|
173 |
+
<th>Quiz ID</th>
|
174 |
+
<th>Quiz Name</th>
|
175 |
+
<th>Shortcode</th>
|
176 |
+
<th>Quiz Views</th>
|
177 |
+
<th>Quiz Taken</th>
|
178 |
+
</tr></thead>";
|
179 |
+
$display .= "<tbody id=\"the-list\">{$quotes_list}</tbody>";
|
180 |
+
$display .= "</table>";
|
181 |
+
echo $display;
|
182 |
+
?>
|
183 |
+
|
184 |
+
<button id="new_quiz_button">Create New Quiz</button>
|
185 |
+
<div id="new_quiz_dialog" title="Create New Quiz" style="display:none;">
|
186 |
+
<table class="wide" style="text-align: left; white-space: nowrap;">
|
187 |
+
<thead>
|
188 |
+
|
189 |
+
<tr valign="top">
|
190 |
+
<th scope="row"> </th>
|
191 |
+
<td></td>
|
192 |
+
</tr>
|
193 |
+
<?php
|
194 |
+
echo "<form action='" . $PHP_SELF . "' method='post'>";
|
195 |
+
echo "<input type='hidden' name='create_quiz' value='confirmation' />";
|
196 |
+
?>
|
197 |
+
|
198 |
+
|
199 |
+
<tr valign="top">
|
200 |
+
<th scope="row"><h3>Create New Quiz</h3></th>
|
201 |
+
<td></td>
|
202 |
+
</tr>
|
203 |
+
|
204 |
+
<tr valign="top">
|
205 |
+
<th scope="row">Quiz Name</th>
|
206 |
+
<td>
|
207 |
+
<input type="text" name="quiz_name" value="" style="border-color:#000000;
|
208 |
+
color:#3300CC;
|
209 |
+
cursor:hand;"/>
|
210 |
+
</td>
|
211 |
+
</tr>
|
212 |
+
</thead>
|
213 |
+
</table>
|
214 |
+
<?php
|
215 |
+
echo "<p class='submit'><input type='submit' class='button-primary' value='Create Quiz' /></p>";
|
216 |
+
echo "</form>";
|
217 |
+
?>
|
218 |
+
</div>
|
219 |
+
|
220 |
+
<div id="delete_dialog" title="Delete Quiz?" style="display:none;">
|
221 |
+
<h3><b>Are you sure you want to delete Quiz <span id="delete_quiz_id"></span>?</b></h3>
|
222 |
+
<?php
|
223 |
+
echo "<form action='" . $PHP_SELF . "' method='post'>";
|
224 |
+
echo "<input type='hidden' name='delete_quiz' value='confirmation' />";
|
225 |
+
echo "<input type='hidden' id='quiz_id' name='quiz_id' value='' />";
|
226 |
+
echo "<p class='submit'><input type='submit' class='button-primary' value='Delete Quiz' /></p>";
|
227 |
+
echo "</form>";
|
228 |
+
?>
|
229 |
+
</div>
|
230 |
+
<div id="dialog" title="Help">
|
231 |
+
<h3><b>Help</b></h3>
|
232 |
+
<p>This page shows all of the quizzes currently on your website.</p>
|
233 |
+
<p>The table shows the quiz id, the name of your quiz, the shortcode to use on your post or page, the amount of views the quiz has had, and the amount of times the quiz was finished</p>
|
234 |
+
<p>To create a new quiz, click the Create New Quiz button and fill out the name.</p>
|
235 |
+
<p>To edit a quiz, click the Edit link underneath the name of the quiz.</p>
|
236 |
+
</div>
|
237 |
+
</div>
|
238 |
+
</div>
|
239 |
+
<?php
|
240 |
+
}
|
241 |
+
?>
|
includes/mlw_quiz_install.php
ADDED
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
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;
|
9 |
+
|
10 |
+
$table_name = $wpdb->prefix . "mlw_quizzes";
|
11 |
+
|
12 |
+
if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name)
|
13 |
+
|
14 |
+
{
|
15 |
+
|
16 |
+
$sql = "CREATE TABLE " . $table_name . " (
|
17 |
+
|
18 |
+
quiz_id mediumint(9) NOT NULL AUTO_INCREMENT,
|
19 |
+
|
20 |
+
quiz_name TEXT NOT NULL,
|
21 |
+
|
22 |
+
message_before TEXT NOT NULL,
|
23 |
+
|
24 |
+
message_after TEXT NOT NULL,
|
25 |
+
|
26 |
+
user_email_template TEXT NOT NULL,
|
27 |
+
|
28 |
+
admin_email_template TEXT NOT NULL,
|
29 |
+
|
30 |
+
submit_button_text TEXT NOT NULL,
|
31 |
+
|
32 |
+
name_field_text TEXT NOT NULL,
|
33 |
+
|
34 |
+
business_field_text TEXT NOT NULL,
|
35 |
+
|
36 |
+
email_field_text TEXT NOT NULL,
|
37 |
+
|
38 |
+
phone_field_text TEXT NOT NULL,
|
39 |
+
|
40 |
+
system INT NOT NULL,
|
41 |
+
|
42 |
+
show_score INT NOT NULL,
|
43 |
+
|
44 |
+
send_user_email INT NOT NULL,
|
45 |
+
|
46 |
+
send_admin_email INT NOT NULL,
|
47 |
+
|
48 |
+
user_name INT NOT NULL,
|
49 |
+
|
50 |
+
user_comp INT NOT NULL,
|
51 |
+
|
52 |
+
user_email INT NOT NULL,
|
53 |
+
|
54 |
+
user_phone INT NOT NULL,
|
55 |
+
|
56 |
+
admin_email TEXT NOT NULL,
|
57 |
+
|
58 |
+
quiz_views INT NOT NULL,
|
59 |
+
|
60 |
+
quiz_taken INT NOT NULL,
|
61 |
+
|
62 |
+
deleted INT NOT NULL,
|
63 |
+
|
64 |
+
PRIMARY KEY (quiz_id)
|
65 |
+
|
66 |
+
);";
|
67 |
+
|
68 |
+
$results = $wpdb->query( $sql );
|
69 |
+
|
70 |
+
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
71 |
+
dbDelta($sql);
|
72 |
+
}
|
73 |
+
|
74 |
+
global $wpdb;
|
75 |
+
|
76 |
+
$table_name = $wpdb->prefix . "mlw_questions";
|
77 |
+
|
78 |
+
if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name)
|
79 |
+
|
80 |
+
{
|
81 |
+
|
82 |
+
$sql = "CREATE TABLE " . $table_name . " (
|
83 |
+
|
84 |
+
question_id mediumint(9) NOT NULL AUTO_INCREMENT,
|
85 |
+
|
86 |
+
quiz_id INT NOT NULL,
|
87 |
+
|
88 |
+
question_name TEXT NOT NULL,
|
89 |
+
|
90 |
+
answer_one TEXT NOT NULL,
|
91 |
+
|
92 |
+
answer_one_points INT NOT NULL,
|
93 |
+
|
94 |
+
answer_two TEXT NOT NULL,
|
95 |
+
|
96 |
+
answer_two_points INT NOT NULL,
|
97 |
+
|
98 |
+
answer_three TEXT NOT NULL,
|
99 |
+
|
100 |
+
answer_three_points INT NOT NULL,
|
101 |
+
|
102 |
+
answer_four TEXT NOT NULL,
|
103 |
+
|
104 |
+
answer_four_points INT NOT NULL,
|
105 |
+
|
106 |
+
answer_five TEXT NOT NULL,
|
107 |
+
|
108 |
+
answer_five_points INT NOT NULL,
|
109 |
+
|
110 |
+
answer_six TEXT NOT NULL,
|
111 |
+
|
112 |
+
answer_six_points INT NOT NULL,
|
113 |
+
|
114 |
+
correct_answer INT NOT NULL,
|
115 |
+
|
116 |
+
deleted INT NOT NULL,
|
117 |
+
|
118 |
+
PRIMARY KEY (question_id)
|
119 |
+
|
120 |
+
);";
|
121 |
+
|
122 |
+
$results = $wpdb->query( $sql );
|
123 |
+
|
124 |
+
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
125 |
+
dbDelta($sql);
|
126 |
+
}
|
127 |
+
|
128 |
+
global $wpdb;
|
129 |
+
|
130 |
+
$table_name = $wpdb->prefix . "mlw_results";
|
131 |
+
|
132 |
+
if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name)
|
133 |
+
|
134 |
+
{
|
135 |
+
|
136 |
+
$sql = "CREATE TABLE " . $table_name . " (
|
137 |
+
|
138 |
+
result_id mediumint(9) NOT NULL AUTO_INCREMENT,
|
139 |
+
|
140 |
+
quiz_id INT NOT NULL,
|
141 |
+
|
142 |
+
quiz_name TEXT NOT NULL,
|
143 |
+
|
144 |
+
quiz_system INT NOT NULL,
|
145 |
+
|
146 |
+
point_score INT NOT NULL,
|
147 |
+
|
148 |
+
correct_score INT NOT NULL,
|
149 |
+
|
150 |
+
correct INT NOT NULL,
|
151 |
+
|
152 |
+
total INT NOT NULL,
|
153 |
+
|
154 |
+
name TEXT NOT NULL,
|
155 |
+
|
156 |
+
business TEXT NOT NULL,
|
157 |
+
|
158 |
+
email TEXT NOT NULL,
|
159 |
+
|
160 |
+
phone TEXT NOT NULL,
|
161 |
+
|
162 |
+
time_taken TEXT NOT NULL,
|
163 |
+
|
164 |
+
deleted INT NOT NULL,
|
165 |
+
|
166 |
+
PRIMARY KEY (result_id)
|
167 |
+
|
168 |
+
);";
|
169 |
+
|
170 |
+
$results = $wpdb->query( $sql );
|
171 |
+
|
172 |
+
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
173 |
+
dbDelta($sql);
|
174 |
+
}
|
175 |
+
}
|
176 |
+
|
177 |
+
function mlw_quiz_deactivate()
|
178 |
+
{
|
179 |
+
|
180 |
+
|
181 |
+
}
|
182 |
+
?>
|
includes/mlw_quiz_options.php
ADDED
@@ -0,0 +1,941 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
This page allows for the editing of quizzes selected from the quiz admin page.
|
4 |
+
*/
|
5 |
+
/*
|
6 |
+
Copyright 2013, My Local Webstop (email : fpcorso@mylocalwebstop.com)
|
7 |
+
*/
|
8 |
+
|
9 |
+
function mlw_generate_quiz_options()
|
10 |
+
{
|
11 |
+
$quiz_id = $_GET["quiz_id"];
|
12 |
+
global $wpdb;
|
13 |
+
$table_name = $wpdb->prefix . "mlw_questions";
|
14 |
+
|
15 |
+
/*
|
16 |
+
Code for quiz questions tab
|
17 |
+
*/
|
18 |
+
|
19 |
+
//Variables from new question form
|
20 |
+
$success = $_POST["create_question"];
|
21 |
+
$question_name = $_POST["question_name"];
|
22 |
+
$answer_one = $_POST["answer_one"];
|
23 |
+
$answer_one_points = $_POST["answer_one_points"];
|
24 |
+
$answer_two = $_POST["answer_two"];
|
25 |
+
$answer_two_points = $_POST["answer_two_points"];
|
26 |
+
$answer_three = $_POST["answer_three"];
|
27 |
+
$answer_three_points = $_POST["answer_three_points"];
|
28 |
+
$answer_four = $_POST["answer_four"];
|
29 |
+
$answer_four_points = $_POST["answer_four_points"];
|
30 |
+
$answer_five = $_POST["answer_five"];
|
31 |
+
$answer_five_points = $_POST["answer_five_points"];
|
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"];
|
38 |
+
$edit_question_name = $_POST["edit_question_name"];
|
39 |
+
$edit_answer_one = $_POST["edit_answer_one"];
|
40 |
+
$edit_answer_one_points = $_POST["edit_answer_one_points"];
|
41 |
+
$edit_answer_two = $_POST["edit_answer_two"];
|
42 |
+
$edit_answer_two_points = $_POST["edit_answer_two_points"];
|
43 |
+
$edit_answer_three = $_POST["edit_answer_three"];
|
44 |
+
$edit_answer_three_points = $_POST["edit_answer_three_points"];
|
45 |
+
$edit_answer_four = $_POST["edit_answer_four"];
|
46 |
+
$edit_answer_four_points = $_POST["edit_answer_four_points"];
|
47 |
+
$edit_answer_five = $_POST["edit_answer_five"];
|
48 |
+
$edit_answer_five_points = $_POST["edit_answer_five_points"];
|
49 |
+
$edit_answer_six = $_POST["edit_answer_six"];
|
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 |
+
}
|
62 |
+
|
63 |
+
//Variables from delete question form
|
64 |
+
$delete_question_success = $_POST["delete_question"];
|
65 |
+
$mlw_question_id = $_POST["question_id"];
|
66 |
+
|
67 |
+
//Delete question from quiz
|
68 |
+
if ($delete_question_success == "confirmation")
|
69 |
+
{
|
70 |
+
$quiz_id = $_POST["quiz_id"];
|
71 |
+
$update = "UPDATE " . $wpdb->prefix . "mlw_questions" . " SET deleted=1 WHERE question_id=".$mlw_question_id;
|
72 |
+
$results = $wpdb->query( $update );
|
73 |
+
$hasDeletedQuestion = true;
|
74 |
+
}
|
75 |
+
|
76 |
+
//Submit new question into database
|
77 |
+
if ($success == "confirmation")
|
78 |
+
{
|
79 |
+
$quiz_id = $_POST["quiz_id"];
|
80 |
+
$insert = "INSERT INTO " . $table_name .
|
81 |
+
" (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)";
|
82 |
+
$results = $wpdb->query( $insert );
|
83 |
+
$hasCreatedQuestion = true;
|
84 |
+
}
|
85 |
+
|
86 |
+
//Get table of questions for this quiz
|
87 |
+
$sql = "SELECT * FROM " . $table_name . " WHERE quiz_id=".$quiz_id." AND deleted=0";
|
88 |
+
$sql .= " ORDER BY question_id ASC";
|
89 |
+
|
90 |
+
$mlw_question_data = $wpdb->get_results($sql);
|
91 |
+
|
92 |
+
|
93 |
+
/*
|
94 |
+
Code for Quiz Text tab
|
95 |
+
*/
|
96 |
+
|
97 |
+
//Variables for save templates form
|
98 |
+
$save_template_success = $_POST["save_templates"];
|
99 |
+
$mlw_before_message = $_POST["mlw_quiz_before_message"];
|
100 |
+
$mlw_after_message = $_POST["mlw_quiz_after_message"];
|
101 |
+
$mlw_user_email_template = $_POST["mlw_quiz_user_email_template"];
|
102 |
+
$mlw_admin_email_template = $_POST["mlw_quiz_admin_email_template"];
|
103 |
+
$mlw_submit_button_text = $_POST["mlw_submitText"];
|
104 |
+
$mlw_name_field_text = $_POST["mlw_nameText"];
|
105 |
+
$mlw_business_field_text = $_POST["mlw_businessText"];
|
106 |
+
$mlw_email_field_text = $_POST["mlw_emailText"];
|
107 |
+
$mlw_phone_field_text = $_POST["mlw_phoneText"];
|
108 |
+
|
109 |
+
//Submit saved templates into database
|
110 |
+
if ($save_template_success == "confirmation")
|
111 |
+
{
|
112 |
+
$quiz_id = $_POST["quiz_id"];
|
113 |
+
$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;
|
114 |
+
$results = $wpdb->query( $update );
|
115 |
+
$hasUpdatedTemplates = true;
|
116 |
+
}
|
117 |
+
|
118 |
+
|
119 |
+
/*
|
120 |
+
Code for Quiz Options tab
|
121 |
+
*/
|
122 |
+
|
123 |
+
//Variables for save options form
|
124 |
+
$save_options_success = $_POST["save_options"];
|
125 |
+
$mlw_system = $_POST["system"];
|
126 |
+
$mlw_send_user_email = $_POST["sendUserEmail"];
|
127 |
+
$mlw_send_admin_email = $_POST["sendAdminEmail"];
|
128 |
+
$mlw_user_name = $_POST["userName"];
|
129 |
+
$mlw_user_comp = $_POST["userComp"];
|
130 |
+
$mlw_user_email = $_POST["userEmail"];
|
131 |
+
$mlw_user_phone = $_POST["userPhone"];
|
132 |
+
$mlw_admin_email = $_POST["adminEmail"];
|
133 |
+
|
134 |
+
//Submit saved options into database
|
135 |
+
if ($save_options_success == "confirmation")
|
136 |
+
{
|
137 |
+
$quiz_id = $_POST["quiz_id"];
|
138 |
+
$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;
|
139 |
+
$results = $wpdb->query( $update );
|
140 |
+
$hasUpdatedOptions = true;
|
141 |
+
}
|
142 |
+
|
143 |
+
|
144 |
+
/*
|
145 |
+
Code for entire page
|
146 |
+
*/
|
147 |
+
|
148 |
+
//Load all quiz data
|
149 |
+
$sql = "SELECT * FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=".$quiz_id;
|
150 |
+
$mlw_quiz_options = $wpdb->get_results($sql);
|
151 |
+
|
152 |
+
foreach($mlw_quiz_options as $testing) {
|
153 |
+
$mlw_quiz_options = $testing;
|
154 |
+
break;
|
155 |
+
}
|
156 |
+
?>
|
157 |
+
<!-- css -->
|
158 |
+
<link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
|
159 |
+
<!-- jquery scripts -->
|
160 |
+
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
|
161 |
+
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
|
162 |
+
<script type="text/javascript">
|
163 |
+
var $j = jQuery.noConflict();
|
164 |
+
// increase the default animation speed to exaggerate the effect
|
165 |
+
$j.fx.speeds._default = 1000;
|
166 |
+
$j(function() {
|
167 |
+
$j('#dialog').dialog({
|
168 |
+
autoOpen: false,
|
169 |
+
show: 'blind',
|
170 |
+
hide: 'explode',
|
171 |
+
buttons: {
|
172 |
+
Ok: function() {
|
173 |
+
$j(this).dialog('close');
|
174 |
+
}
|
175 |
+
}
|
176 |
+
});
|
177 |
+
|
178 |
+
$j('#opener').click(function() {
|
179 |
+
$j('#dialog').dialog('open');
|
180 |
+
return false;
|
181 |
+
} );
|
182 |
+
});
|
183 |
+
$j(function() {
|
184 |
+
$j('#questions_help_dialog').dialog({
|
185 |
+
autoOpen: false,
|
186 |
+
show: 'blind',
|
187 |
+
hide: 'explode',
|
188 |
+
buttons: {
|
189 |
+
Ok: function() {
|
190 |
+
$j(this).dialog('close');
|
191 |
+
}
|
192 |
+
}
|
193 |
+
});
|
194 |
+
|
195 |
+
$j('#question_tab_help').click(function() {
|
196 |
+
$j('#questions_help_dialog').dialog('open');
|
197 |
+
return false;
|
198 |
+
} );
|
199 |
+
});
|
200 |
+
$j(function() {
|
201 |
+
$j('#templates_help_dialog').dialog({
|
202 |
+
autoOpen: false,
|
203 |
+
show: 'blind',
|
204 |
+
hide: 'explode',
|
205 |
+
buttons: {
|
206 |
+
Ok: function() {
|
207 |
+
$j(this).dialog('close');
|
208 |
+
}
|
209 |
+
}
|
210 |
+
});
|
211 |
+
|
212 |
+
$j('#template_tab_help').click(function() {
|
213 |
+
$j('#templates_help_dialog').dialog('open');
|
214 |
+
return false;
|
215 |
+
} );
|
216 |
+
});
|
217 |
+
$j(function() {
|
218 |
+
$j('#options_help_dialog').dialog({
|
219 |
+
autoOpen: false,
|
220 |
+
show: 'blind',
|
221 |
+
hide: 'explode',
|
222 |
+
buttons: {
|
223 |
+
Ok: function() {
|
224 |
+
$j(this).dialog('close');
|
225 |
+
}
|
226 |
+
}
|
227 |
+
});
|
228 |
+
|
229 |
+
$j('#options_tab_help').click(function() {
|
230 |
+
$j('#options_help_dialog').dialog('open');
|
231 |
+
return false;
|
232 |
+
} );
|
233 |
+
});
|
234 |
+
$j(function() {
|
235 |
+
$j( "#tabs" ).tabs();
|
236 |
+
});
|
237 |
+
$j(function() {
|
238 |
+
$j( document ).tooltip();
|
239 |
+
});
|
240 |
+
$j(function() {
|
241 |
+
$j("#accordion").accordion({
|
242 |
+
heightStyle: "content"
|
243 |
+
});
|
244 |
+
|
245 |
+
});
|
246 |
+
$j(function() {
|
247 |
+
$j( "#system" ).buttonset();
|
248 |
+
});
|
249 |
+
$j(function() {
|
250 |
+
$j( "#sendUserEmail" ).buttonset();
|
251 |
+
});
|
252 |
+
$j(function() {
|
253 |
+
$j( "#sendAdminEmail" ).buttonset();
|
254 |
+
});
|
255 |
+
$j(function() {
|
256 |
+
$j( "#userName" ).buttonset();
|
257 |
+
});
|
258 |
+
$j(function() {
|
259 |
+
$j( "#userComp" ).buttonset();
|
260 |
+
});
|
261 |
+
$j(function() {
|
262 |
+
$j( "#userEmail" ).buttonset();
|
263 |
+
});
|
264 |
+
$j(function() {
|
265 |
+
$j( "#userPhone" ).buttonset();
|
266 |
+
});
|
267 |
+
$j(function() {
|
268 |
+
$j("button").button();
|
269 |
+
|
270 |
+
});
|
271 |
+
$j(function() {
|
272 |
+
$j('#new_question_dialog').dialog({
|
273 |
+
autoOpen: false,
|
274 |
+
show: 'blind',
|
275 |
+
width:700,
|
276 |
+
hide: 'explode',
|
277 |
+
buttons: {
|
278 |
+
Cancel: function() {
|
279 |
+
$j(this).dialog('close');
|
280 |
+
}
|
281 |
+
}
|
282 |
+
});
|
283 |
+
|
284 |
+
$j('#new_question_button').click(function() {
|
285 |
+
$j('#new_question_dialog').dialog('open');
|
286 |
+
return false;
|
287 |
+
} );
|
288 |
+
});
|
289 |
+
function deleteQuestion(id){
|
290 |
+
$j("#delete_dialog").dialog({
|
291 |
+
autoOpen: false,
|
292 |
+
show: 'blind',
|
293 |
+
hide: 'explode',
|
294 |
+
buttons: {
|
295 |
+
Cancel: function() {
|
296 |
+
$j(this).dialog('close');
|
297 |
+
}
|
298 |
+
}
|
299 |
+
});
|
300 |
+
$j("#delete_dialog").dialog('open');
|
301 |
+
var idText = document.getElementById("delete_question_id");
|
302 |
+
var idHidden = document.getElementById("question_id");
|
303 |
+
idText.innerHTML = id;
|
304 |
+
idHidden.value = id;
|
305 |
+
};
|
306 |
+
function editQuestion(id, question, answerOne, answerOnePoints, answerTwo, answerTwoPoints, answerThree, answerThreePoints, answerFour, answerFourPoints, answerFive, answerFivePoints, answerSix, answerSixPoints, correctAnswer){
|
307 |
+
$j("#edit_question_dialog").dialog({
|
308 |
+
autoOpen: false,
|
309 |
+
show: 'blind',
|
310 |
+
hide: 'explode',
|
311 |
+
buttons: {
|
312 |
+
Cancel: function() {
|
313 |
+
$j(this).dialog('close');
|
314 |
+
}
|
315 |
+
}
|
316 |
+
});
|
317 |
+
$j("#edit_question_dialog").dialog('open');
|
318 |
+
var idHidden = document.getElementById("edit_question_id");
|
319 |
+
idHidden.value = id;
|
320 |
+
document.getElementById("edit_question_name").value = question;
|
321 |
+
document.getElementById("edit_answer_one").value = answerOne;
|
322 |
+
document.getElementById("edit_answer_two").value = answerTwo;
|
323 |
+
document.getElementById("edit_answer_three").value = answerThree;
|
324 |
+
document.getElementById("edit_answer_four").value = answerFour;
|
325 |
+
document.getElementById("edit_answer_five").value = answerFive;
|
326 |
+
document.getElementById("edit_answer_six").value = answerSix;
|
327 |
+
document.getElementById("edit_answer_one_points").value = answerOnePoints;
|
328 |
+
document.getElementById("edit_answer_two_points").value = answerTwoPoints;
|
329 |
+
document.getElementById("edit_answer_three_points").value = answerThreePoints;
|
330 |
+
document.getElementById("edit_answer_four_points").value = answerFourPoints;
|
331 |
+
document.getElementById("edit_answer_five_points").value = answerFivePoints;
|
332 |
+
document.getElementById("edit_answer_six_points").value = answerSixPoints;
|
333 |
+
if (correctAnswer == 1) document.getElementById("edit_correct_one").checked = true;
|
334 |
+
if (correctAnswer == 2) document.getElementById("edit_correct_two").checked = true;
|
335 |
+
if (correctAnswer == 3) document.getElementById("edit_correct_three").checked = true;
|
336 |
+
if (correctAnswer == 4) document.getElementById("edit_correct_four").checked = true;
|
337 |
+
if (correctAnswer == 5) document.getElementById("edit_correct_five").checked = true;
|
338 |
+
if (correctAnswer == 6) document.getElementById("edit_correct_six").checked = true;
|
339 |
+
};
|
340 |
+
</script>
|
341 |
+
<style>
|
342 |
+
label {
|
343 |
+
display: inline-block;
|
344 |
+
width: 5em;
|
345 |
+
}
|
346 |
+
</style>
|
347 |
+
<style type="text/css">
|
348 |
+
div.mlw_quiz_options input[type='text'] {
|
349 |
+
border-color:#000000;
|
350 |
+
color:#3300CC;
|
351 |
+
cursor:hand;
|
352 |
+
}
|
353 |
+
</style>
|
354 |
+
<div class="wrap">
|
355 |
+
<div class='mlw_quiz_options'>
|
356 |
+
<?php
|
357 |
+
if ($quiz_id != "")
|
358 |
+
{
|
359 |
+
?>
|
360 |
+
<h2>Quiz Options For <?php echo $mlw_quiz_options->quiz_name; ?><a id="opener" href="">(?)</a></h2>
|
361 |
+
<?php if ($hasCreatedQuestion)
|
362 |
+
{
|
363 |
+
?>
|
364 |
+
<div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
|
365 |
+
<p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
|
366 |
+
<strong>Success!</strong> Your new question has been created successfully.</p>
|
367 |
+
</div>
|
368 |
+
<?php
|
369 |
+
}
|
370 |
+
?>
|
371 |
+
<?php if ($hasUpdatedTemplates)
|
372 |
+
{
|
373 |
+
?>
|
374 |
+
<div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
|
375 |
+
<p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
|
376 |
+
<strong>Success!</strong> Your templates for this quiz have been saved.</p>
|
377 |
+
</div>
|
378 |
+
<?php
|
379 |
+
}
|
380 |
+
?>
|
381 |
+
<?php if ($hasUpdatedOptions)
|
382 |
+
{
|
383 |
+
?>
|
384 |
+
<div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
|
385 |
+
<p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
|
386 |
+
<strong>Success!</strong> Your options for this quiz have been saved.</p>
|
387 |
+
</div>
|
388 |
+
<?php
|
389 |
+
}
|
390 |
+
?>
|
391 |
+
<?php if ($hasDeletedQuestion)
|
392 |
+
{
|
393 |
+
?>
|
394 |
+
<div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
|
395 |
+
<p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
|
396 |
+
<strong>Success!</strong> The question has been deleted from this quiz.</p>
|
397 |
+
</div>
|
398 |
+
<?php
|
399 |
+
}
|
400 |
+
?>
|
401 |
+
<?php if ($hasUpdatedQuestion)
|
402 |
+
{
|
403 |
+
?>
|
404 |
+
<div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
|
405 |
+
<p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
|
406 |
+
<strong>Success!</strong> The question has been updated.</p>
|
407 |
+
</div>
|
408 |
+
<?php
|
409 |
+
}
|
410 |
+
?>
|
411 |
+
<div id="tabs">
|
412 |
+
<ul>
|
413 |
+
<li><a href="#tabs-1">Quiz Questions</a></li>
|
414 |
+
<li><a href="#tabs-2">Quiz Text</a></li>
|
415 |
+
<li><a href="#tabs-3">Quiz Options</a></li>
|
416 |
+
</ul>
|
417 |
+
<div id="tabs-1">
|
418 |
+
<?php
|
419 |
+
$question_list = "";
|
420 |
+
$display = "";
|
421 |
+
foreach($mlw_question_data as $mlw_question_info) {
|
422 |
+
if($alternate) $alternate = "";
|
423 |
+
else $alternate = " class=\"alternate\"";
|
424 |
+
$question_list .= "<tr{$alternate}>";
|
425 |
+
$question_list .= "<td><span style='font-size:16px;'>" . $mlw_question_info->question_id . "</span></td>";
|
426 |
+
$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>";
|
427 |
+
$question_list .= "</tr>";
|
428 |
+
}
|
429 |
+
|
430 |
+
$display .= "<table class=\"widefat\">";
|
431 |
+
$display .= "<thead><tr>
|
432 |
+
<th>Question ID</th>
|
433 |
+
<th>Question Name</th>
|
434 |
+
</tr></thead>";
|
435 |
+
$display .= "<tbody id=\"the-list\">{$question_list}</tbody>";
|
436 |
+
$display .= "</table>";
|
437 |
+
echo $display;
|
438 |
+
?>
|
439 |
+
<button id="new_question_button">Add Question</button><button id="question_tab_help">Help</button>
|
440 |
+
<div id="new_question_dialog" title="Create New Question" style="display:none;">
|
441 |
+
<table class="wide" style="text-align: left; white-space: nowrap;">
|
442 |
+
<thead>
|
443 |
+
<?php
|
444 |
+
echo "<form action='" . $PHP_SELF . "' method='post'>";
|
445 |
+
echo "<input type='hidden' name='create_question' value='confirmation' />";
|
446 |
+
echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
|
447 |
+
?>
|
448 |
+
<tr valign="top">
|
449 |
+
<th scope="row">Question</th>
|
450 |
+
<td>
|
451 |
+
<input type="text" name="question_name" value="" style="border-color:#000000;
|
452 |
+
color:#3300CC;
|
453 |
+
cursor:hand;"/>
|
454 |
+
</td>
|
455 |
+
</tr>
|
456 |
+
<tr valign="top">
|
457 |
+
<th scope="row"> </th>
|
458 |
+
<td> </td>
|
459 |
+
</tr>
|
460 |
+
<tr valign="top">
|
461 |
+
<th scope="row"> </th>
|
462 |
+
<td>Answers</td>
|
463 |
+
<td>Points Worth</td>
|
464 |
+
<td>Correct Answer</td>
|
465 |
+
</tr>
|
466 |
+
<tr valign="top">
|
467 |
+
<th scope="row">Answer One</th>
|
468 |
+
<td>
|
469 |
+
<input type="text" name="answer_one" value="" style="border-color:#000000;
|
470 |
+
color:#3300CC;
|
471 |
+
cursor:hand;"/>
|
472 |
+
</td>
|
473 |
+
<td>
|
474 |
+
<input type="text" name="answer_one_points" value="0" style="border-color:#000000;
|
475 |
+
color:#3300CC;
|
476 |
+
cursor:hand;"/>
|
477 |
+
</td>
|
478 |
+
<td><input type="radio" name="correct_answer" checked="checked" value=1 /></td>
|
479 |
+
</tr>
|
480 |
+
<tr valign="top">
|
481 |
+
<th scope="row">Answer Two</th>
|
482 |
+
<td>
|
483 |
+
<input type="text" name="answer_two" value="" style="border-color:#000000;
|
484 |
+
color:#3300CC;
|
485 |
+
cursor:hand;"/>
|
486 |
+
</td>
|
487 |
+
<td>
|
488 |
+
<input type="text" name="answer_two_points" value="0" style="border-color:#000000;
|
489 |
+
color:#3300CC;
|
490 |
+
cursor:hand;"/>
|
491 |
+
</td>
|
492 |
+
<td><input type="radio" name="correct_answer" value=2 /></td>
|
493 |
+
</tr>
|
494 |
+
<tr valign="top">
|
495 |
+
<th scope="row">Answer Three</th>
|
496 |
+
<td>
|
497 |
+
<input type="text" name="answer_three" value="" style="border-color:#000000;
|
498 |
+
color:#3300CC;
|
499 |
+
cursor:hand;"/>
|
500 |
+
</td>
|
501 |
+
<td>
|
502 |
+
<input type="text" name="answer_three_points" value="0" style="border-color:#000000;
|
503 |
+
color:#3300CC;
|
504 |
+
cursor:hand;"/>
|
505 |
+
</td>
|
506 |
+
<td><input type="radio" name="correct_answer" value=3 /></td>
|
507 |
+
</tr>
|
508 |
+
<tr valign="top">
|
509 |
+
<th scope="row">Answer Four</th>
|
510 |
+
<td>
|
511 |
+
<input type="text" name="answer_four" value="" style="border-color:#000000;
|
512 |
+
color:#3300CC;
|
513 |
+
cursor:hand;"/>
|
514 |
+
</td>
|
515 |
+
<td>
|
516 |
+
<input type="text" name="answer_four_points" value="0" style="border-color:#000000;
|
517 |
+
color:#3300CC;
|
518 |
+
cursor:hand;"/>
|
519 |
+
</td>
|
520 |
+
<td><input type="radio" name="correct_answer" value=4 /></td>
|
521 |
+
</tr>
|
522 |
+
<tr valign="top">
|
523 |
+
<th scope="row">Answer Five</th>
|
524 |
+
<td>
|
525 |
+
<input type="text" name="answer_five" value="" style="border-color:#000000;
|
526 |
+
color:#3300CC;
|
527 |
+
cursor:hand;"/>
|
528 |
+
</td>
|
529 |
+
<td>
|
530 |
+
<input type="text" name="answer_five_points" value="0" style="border-color:#000000;
|
531 |
+
color:#3300CC;
|
532 |
+
cursor:hand;"/>
|
533 |
+
</td>
|
534 |
+
<td><input type="radio" name="correct_answer" value=5 /></td>
|
535 |
+
</tr>
|
536 |
+
<tr valign="top">
|
537 |
+
<th scope="row">Answer Six</th>
|
538 |
+
<td>
|
539 |
+
<input type="text" name="answer_six" value="" style="border-color:#000000;
|
540 |
+
color:#3300CC;
|
541 |
+
cursor:hand;"/>
|
542 |
+
</td>
|
543 |
+
<td>
|
544 |
+
<input type="text" name="answer_six_points" value="0" style="border-color:#000000;
|
545 |
+
color:#3300CC;
|
546 |
+
cursor:hand;"/>
|
547 |
+
</td>
|
548 |
+
<td><input type="radio" name="correct_answer" value=6 /></td>
|
549 |
+
</tr>
|
550 |
+
</thead>
|
551 |
+
</table>
|
552 |
+
<?php
|
553 |
+
echo "<p class='submit'><input type='submit' class='button-primary' value='Create Question' /></p>";
|
554 |
+
echo "</form>";
|
555 |
+
?>
|
556 |
+
</div>
|
557 |
+
|
558 |
+
|
559 |
+
<div id="edit_question_dialog" title="Edit Question" style="display:none;">
|
560 |
+
<table class="wide" style="text-align: left; white-space: nowrap;">
|
561 |
+
<thead>
|
562 |
+
<?php
|
563 |
+
echo "<form action='" . $PHP_SELF . "' method='post'>";
|
564 |
+
echo "<input type='hidden' name='edit_question' value='confirmation' />";
|
565 |
+
echo "<input type='hidden' id='edit_question_id' name='edit_question_id' value='' />";
|
566 |
+
echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
|
567 |
+
?>
|
568 |
+
<tr valign="top">
|
569 |
+
<th scope="row">Question</th>
|
570 |
+
<td>
|
571 |
+
<input type="text" name="edit_question_name" id="edit_question_name" value="" style="border-color:#000000;
|
572 |
+
color:#3300CC;
|
573 |
+
cursor:hand;"/>
|
574 |
+
</td>
|
575 |
+
</tr>
|
576 |
+
<tr valign="top">
|
577 |
+
<th scope="row"> </th>
|
578 |
+
<td> </td>
|
579 |
+
</tr>
|
580 |
+
<tr valign="top">
|
581 |
+
<th scope="row"> </th>
|
582 |
+
<td>Answers</td>
|
583 |
+
<td>Points Worth</td>
|
584 |
+
<td>Correct Answer</td>
|
585 |
+
</tr>
|
586 |
+
<tr valign="top">
|
587 |
+
<th scope="row">Answer One</th>
|
588 |
+
<td>
|
589 |
+
<input type="text" name="edit_answer_one" id="edit_answer_one" value="" style="border-color:#000000;
|
590 |
+
color:#3300CC;
|
591 |
+
cursor:hand;"/>
|
592 |
+
</td>
|
593 |
+
<td>
|
594 |
+
<input type="text" name="edit_answer_one_points" id="edit_answer_one_points" value="0" style="border-color:#000000;
|
595 |
+
color:#3300CC;
|
596 |
+
cursor:hand;"/>
|
597 |
+
</td>
|
598 |
+
<td><input type="radio" id="edit_correct_one" name="edit_correct_answer" checked="checked" value=1 /></td>
|
599 |
+
</tr>
|
600 |
+
<tr valign="top">
|
601 |
+
<th scope="row">Answer Two</th>
|
602 |
+
<td>
|
603 |
+
<input type="text" name="edit_answer_two" id="edit_answer_two" value="" style="border-color:#000000;
|
604 |
+
color:#3300CC;
|
605 |
+
cursor:hand;"/>
|
606 |
+
</td>
|
607 |
+
<td>
|
608 |
+
<input type="text" name="edit_answer_two_points" id="edit_answer_two_points" value="0" style="border-color:#000000;
|
609 |
+
color:#3300CC;
|
610 |
+
cursor:hand;"/>
|
611 |
+
</td>
|
612 |
+
<td><input type="radio" id="edit_correct_two" name="edit_correct_answer" value=2 /></td>
|
613 |
+
</tr>
|
614 |
+
<tr valign="top">
|
615 |
+
<th scope="row">Answer Three</th>
|
616 |
+
<td>
|
617 |
+
<input type="text" name="edit_answer_three" id="edit_answer_three" value="" style="border-color:#000000;
|
618 |
+
color:#3300CC;
|
619 |
+
cursor:hand;"/>
|
620 |
+
</td>
|
621 |
+
<td>
|
622 |
+
<input type="text" name="edit_answer_three_points" id="edit_answer_three_points" value="0" style="border-color:#000000;
|
623 |
+
color:#3300CC;
|
624 |
+
cursor:hand;"/>
|
625 |
+
</td>
|
626 |
+
<td><input type="radio" id="edit_correct_three" name="edit_correct_answer" value=3 /></td>
|
627 |
+
</tr>
|
628 |
+
<tr valign="top">
|
629 |
+
<th scope="row">Answer Four</th>
|
630 |
+
<td>
|
631 |
+
<input type="text" name="edit_answer_four" value="" id="edit_answer_four" style="border-color:#000000;
|
632 |
+
color:#3300CC;
|
633 |
+
cursor:hand;"/>
|
634 |
+
</td>
|
635 |
+
<td>
|
636 |
+
<input type="text" name="edit_answer_four_points" id="edit_answer_four_points" value="0" style="border-color:#000000;
|
637 |
+
color:#3300CC;
|
638 |
+
cursor:hand;"/>
|
639 |
+
</td>
|
640 |
+
<td><input type="radio" id="edit_correct_four" name="edit_correct_answer" value=4 /></td>
|
641 |
+
</tr>
|
642 |
+
<tr valign="top">
|
643 |
+
<th scope="row">Answer Five</th>
|
644 |
+
<td>
|
645 |
+
<input type="text" name="edit_answer_five" value="" id="edit_answer_five" style="border-color:#000000;
|
646 |
+
color:#3300CC;
|
647 |
+
cursor:hand;"/>
|
648 |
+
</td>
|
649 |
+
<td>
|
650 |
+
<input type="text" name="edit_answer_five_points" id="edit_answer_five_points" value="0" style="border-color:#000000;
|
651 |
+
color:#3300CC;
|
652 |
+
cursor:hand;"/>
|
653 |
+
</td>
|
654 |
+
<td><input type="radio" id="edit_correct_five" name="edit_correct_answer" value=5 /></td>
|
655 |
+
</tr>
|
656 |
+
<tr valign="top">
|
657 |
+
<th scope="row">Answer Six</th>
|
658 |
+
<td>
|
659 |
+
<input type="text" name="edit_answer_six" value="" id="edit_answer_six" style="border-color:#000000;
|
660 |
+
color:#3300CC;
|
661 |
+
cursor:hand;"/>
|
662 |
+
</td>
|
663 |
+
<td>
|
664 |
+
<input type="text" name="edit_answer_six_points" id="edit_answer_six_points" value="0" style="border-color:#000000;
|
665 |
+
color:#3300CC;
|
666 |
+
cursor:hand;"/>
|
667 |
+
</td>
|
668 |
+
<td><input type="radio" id="edit_correct_six" name="edit_correct_answer" value=6 /></td>
|
669 |
+
</tr>
|
670 |
+
</thead>
|
671 |
+
</table>
|
672 |
+
<?php
|
673 |
+
echo "<p class='submit'><input type='submit' class='button-primary' value='Edit Question' /></p>";
|
674 |
+
echo "</form>";
|
675 |
+
?>
|
676 |
+
</div>
|
677 |
+
|
678 |
+
</div>
|
679 |
+
<div id="tabs-2">
|
680 |
+
<h3>Template Variables</h3>
|
681 |
+
<table class="form-table">
|
682 |
+
<tr>
|
683 |
+
<td><strong>%POINT_SCORE%</strong> - Score for the quiz when using points</td>
|
684 |
+
<td><strong>%AMOUNT_CORRECT%</strong> - The number of correct answers the user had</td>
|
685 |
+
</tr>
|
686 |
+
|
687 |
+
<tr>
|
688 |
+
<td><strong>%TOTAL_QUESTIONS%</strong> - The total number of questions in the quiz</td>
|
689 |
+
<td><strong>%CORRECT_SCORE%</strong> - Score for the quiz when using correct answers</td>
|
690 |
+
</tr>
|
691 |
+
|
692 |
+
<tr>
|
693 |
+
<td><strong>%USER_NAME%</strong> - The name the user entered before the quiz</td>
|
694 |
+
<td><strong>%USER_BUSINESS%</strong> - The business the user entered before the quiz</td>
|
695 |
+
</tr>
|
696 |
+
<tr>
|
697 |
+
<td><strong>%USER_PHONE%</strong> - The phone number the user entered before the quiz</td>
|
698 |
+
<td><strong>%USER_EMAIL%</strong> - The email the user entered before the quiz</td>
|
699 |
+
</tr>
|
700 |
+
<tr>
|
701 |
+
<td><strong>%QUIZ_NAME%</strong> - The name of the quiz</td>
|
702 |
+
</tr>
|
703 |
+
</table>
|
704 |
+
<button id="save_template_button" onclick="javascript: document.quiz_template_form.submit();">Save Templates</button><button id="template_tab_help">Help</button>
|
705 |
+
<?php
|
706 |
+
echo "<form action='" . $PHP_SELF . "' method='post' name='quiz_template_form'>";
|
707 |
+
echo "<input type='hidden' name='save_templates' value='confirmation' />";
|
708 |
+
echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
|
709 |
+
?>
|
710 |
+
<div id="accordion">
|
711 |
+
<h3><a href="#">Message Template</a></h3>
|
712 |
+
<div>
|
713 |
+
<table class="form-table">
|
714 |
+
<tr>
|
715 |
+
<td width="30%">
|
716 |
+
<strong>Message Displayed Before Quiz</strong>
|
717 |
+
<br />
|
718 |
+
<p>Allowed Variables: </p>
|
719 |
+
<p style="margin: 2px 0">- %QUIZ_NAME%</p>
|
720 |
+
</td>
|
721 |
+
<td><textarea cols="80" rows="15" id="mlw_quiz_before_message" name="mlw_quiz_before_message"><?php echo $mlw_quiz_options->message_before; ?></textarea>
|
722 |
+
</td>
|
723 |
+
</tr>
|
724 |
+
<tr>
|
725 |
+
<td width="30%">
|
726 |
+
<strong>Message Displayed After Quiz</strong>
|
727 |
+
<br />
|
728 |
+
<p>Allowed Variables: </p>
|
729 |
+
<p style="margin: 2px 0">- %POINT_SCORE%</p>
|
730 |
+
<p style="margin: 2px 0">- %AMOUNT_CORRECT%</p>
|
731 |
+
<p style="margin: 2px 0">- %TOTAL_QUESTIONS%</p>
|
732 |
+
<p style="margin: 2px 0">- %CORRECT_SCORE%</p>
|
733 |
+
<p style="margin: 2px 0">- %QUIZ_NAME%</p>
|
734 |
+
<p style="margin: 2px 0">- %USER_NAME%</p>
|
735 |
+
<p style="margin: 2px 0">- %USER_BUSINESS%</p>
|
736 |
+
<p style="margin: 2px 0">- %USER_PHONE%</p>
|
737 |
+
<p style="margin: 2px 0">- %USER_EMAIL%</p>
|
738 |
+
</td>
|
739 |
+
<td><textarea cols="80" rows="15" id="mlw_quiz_after_message" name="mlw_quiz_after_message"><?php echo $mlw_quiz_options->message_after; ?></textarea>
|
740 |
+
</td>
|
741 |
+
</tr>
|
742 |
+
</table>
|
743 |
+
|
744 |
+
</div>
|
745 |
+
<h3><a href="#">Email Template</a></h3>
|
746 |
+
<div>
|
747 |
+
<table class="form-table">
|
748 |
+
<tr>
|
749 |
+
<td width="30%">
|
750 |
+
<strong>Email sent to user after completion (If turned on in options)</strong>
|
751 |
+
<br />
|
752 |
+
<p>Allowed Variables: </p>
|
753 |
+
<p style="margin: 2px 0">- %POINT_SCORE%</p>
|
754 |
+
<p style="margin: 2px 0">- %AMOUNT_CORRECT%</p>
|
755 |
+
<p style="margin: 2px 0">- %TOTAL_QUESTIONS%</p>
|
756 |
+
<p style="margin: 2px 0">- %CORRECT_SCORE%</p>
|
757 |
+
<p style="margin: 2px 0">- %QUIZ_NAME%</p>
|
758 |
+
<p style="margin: 2px 0">- %USER_NAME%</p>
|
759 |
+
<p style="margin: 2px 0">- %USER_BUSINESS%</p>
|
760 |
+
<p style="margin: 2px 0">- %USER_PHONE%</p>
|
761 |
+
<p style="margin: 2px 0">- %USER_EMAIL%</p>
|
762 |
+
</td>
|
763 |
+
<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>
|
764 |
+
</td>
|
765 |
+
</tr>
|
766 |
+
<tr>
|
767 |
+
<td width="30%">
|
768 |
+
<strong>Email sent to admin after completion</strong>
|
769 |
+
<br />
|
770 |
+
<p>Allowed Variables: </p>
|
771 |
+
<p style="margin: 2px 0">- %POINT_SCORE%</p>
|
772 |
+
<p style="margin: 2px 0">- %AMOUNT_CORRECT%</p>
|
773 |
+
<p style="margin: 2px 0">- %TOTAL_QUESTIONS%</p>
|
774 |
+
<p style="margin: 2px 0">- %CORRECT_SCORE%</p>
|
775 |
+
<p style="margin: 2px 0">- %USER_NAME%</p>
|
776 |
+
<p style="margin: 2px 0">- %USER_BUSINESS%</p>
|
777 |
+
<p style="margin: 2px 0">- %USER_PHONE%</p>
|
778 |
+
<p style="margin: 2px 0">- %USER_EMAIL%</p>
|
779 |
+
<p style="margin: 2px 0">- %QUIZ_NAME%</p>
|
780 |
+
</td>
|
781 |
+
<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>
|
782 |
+
</td>
|
783 |
+
</tr>
|
784 |
+
</table>
|
785 |
+
|
786 |
+
</div>
|
787 |
+
<h3><a href="#">Other Template</a></h3>
|
788 |
+
<div>
|
789 |
+
<table class="form-table">
|
790 |
+
<tr valign="top">
|
791 |
+
<th scope="row"><label for="mlw_submitText">Text for submit button</label></th>
|
792 |
+
<td><input name="mlw_submitText" type="text" id="mlw_submitText" value="<?php echo $mlw_quiz_options->submit_button_text; ?>" class="regular-text" /></td>
|
793 |
+
</tr>
|
794 |
+
<tr valign="top">
|
795 |
+
<th scope="row"><label for="mlw_nameText">Text for name field</label></th>
|
796 |
+
<td><input name="mlw_nameText" type="text" id="mlw_nameText" value="<?php echo $mlw_quiz_options->name_field_text; ?>" class="regular-text" /></td>
|
797 |
+
</tr>
|
798 |
+
<tr valign="top">
|
799 |
+
<th scope="row"><label for="mlw_businessText">Text for business field</label></th>
|
800 |
+
<td><input name="mlw_businessText" type="text" id="mlw_businessText" value="<?php echo $mlw_quiz_options->business_field_text; ?>" class="regular-text" /></td>
|
801 |
+
</tr>
|
802 |
+
<tr valign="top">
|
803 |
+
<th scope="row"><label for="mlw_emailText">Text for email field</label></th>
|
804 |
+
<td><input name="mlw_emailText" type="text" id="mlw_emailText" value="<?php echo $mlw_quiz_options->email_field_text; ?>" class="regular-text" /></td>
|
805 |
+
</tr>
|
806 |
+
<tr valign="top">
|
807 |
+
<th scope="row"><label for="mlw_phoneText">Text for phone number field</label></th>
|
808 |
+
<td><input name="mlw_phoneText" type="text" id="mlw_phoneText" value="<?php echo $mlw_quiz_options->phone_field_text; ?>" class="regular-text" /></td>
|
809 |
+
</tr>
|
810 |
+
</table>
|
811 |
+
|
812 |
+
</div>
|
813 |
+
</div>
|
814 |
+
<?php echo "</form>"; ?>
|
815 |
+
</div>
|
816 |
+
<div id="tabs-3">
|
817 |
+
<button id="save_options_button" onclick="javascript: document.quiz_options_form.submit();">Save Options</button><button id="options_tab_help">Help</button>
|
818 |
+
<?php
|
819 |
+
echo "<form action='" . $PHP_SELF . "' method='post' name='quiz_options_form'>";
|
820 |
+
echo "<input type='hidden' name='save_options' value='confirmation' />";
|
821 |
+
echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
|
822 |
+
?>
|
823 |
+
<table class="form-table">
|
824 |
+
<tr valign="top">
|
825 |
+
<th scope="row"><label for="system">Which system is this quiz graded on?</label></th>
|
826 |
+
<td><div id="system">
|
827 |
+
<input type="radio" id="radio1" name="system" <?php if ($mlw_quiz_options->system == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio1">Correct/Incorrect</label>
|
828 |
+
<input type="radio" id="radio2" name="system" <?php if ($mlw_quiz_options->system == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio2">Points</label>
|
829 |
+
</div></td>
|
830 |
+
</tr>
|
831 |
+
<tr valign="top">
|
832 |
+
<th scope="row"><label for="sendUserEmail">Send user email upon completion?</label></th>
|
833 |
+
<td><div id="sendUserEmail">
|
834 |
+
<input type="radio" id="radio5" name="sendUserEmail" <?php if ($mlw_quiz_options->send_user_email == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio5">Yes</label>
|
835 |
+
<input type="radio" id="radio6" name="sendUserEmail" <?php if ($mlw_quiz_options->send_user_email == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio6">No</label>
|
836 |
+
</div></td>
|
837 |
+
</tr>
|
838 |
+
<tr valign="top">
|
839 |
+
<th scope="row"><label for="userName">Should we ask for user's name?</label></th>
|
840 |
+
<td><div id="userName">
|
841 |
+
<input type="radio" id="radio7" name="userName" <?php if ($mlw_quiz_options->user_name == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio7">Yes</label>
|
842 |
+
<!--<input type="radio" id="radio8" name="userName" <?php if ($mlw_quiz_options->user_name == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio8">Require</label>-->
|
843 |
+
<input type="radio" id="radio9" name="userName" <?php if ($mlw_quiz_options->user_name == 2) {echo 'checked="checked"';} ?> value='2' /><label for="radio9">No</label>
|
844 |
+
</div></td>
|
845 |
+
</tr>
|
846 |
+
<tr valign="top">
|
847 |
+
<th scope="row"><label for="userComp">Should we ask for user's business?</label></th>
|
848 |
+
<td><div id="userComp">
|
849 |
+
<input type="radio" id="radio10" name="userComp" <?php if ($mlw_quiz_options->user_comp == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio10">Yes</label>
|
850 |
+
<!--<input type="radio" id="radio11" name="userComp" <?php if ($mlw_quiz_options->user_comp == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio11">Require</label>-->
|
851 |
+
<input type="radio" id="radio12" name="userComp" <?php if ($mlw_quiz_options->user_comp == 2) {echo 'checked="checked"';} ?> value='2' /><label for="radio12">No</label>
|
852 |
+
</div></td>
|
853 |
+
</tr>
|
854 |
+
<tr valign="top">
|
855 |
+
<th scope="row"><label for="userEmail">Should we ask for user's email?</label></th>
|
856 |
+
<td><div id="userEmail">
|
857 |
+
<input type="radio" id="radio13" name="userEmail" <?php if ($mlw_quiz_options->user_email == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio13">Yes</label>
|
858 |
+
<!--<input type="radio" id="radio14" name="userEmail" <?php if ($mlw_quiz_options->user_email == 1) {echo 'checked="checked"';} ?> value='1'/><label for="radio14">Require</label>-->
|
859 |
+
<input type="radio" id="radio15" name="userEmail" <?php if ($mlw_quiz_options->user_email == 2) {echo 'checked="checked"';} ?> value='2' /><label for="radio15">No</label>
|
860 |
+
</div></td>
|
861 |
+
</tr>
|
862 |
+
<tr valign="top">
|
863 |
+
<th scope="row"><label for="userPhone">Should we ask for user's phone number?</label></th>
|
864 |
+
<td><div id="userPhone">
|
865 |
+
<input type="radio" id="radio16" name="userPhone" <?php if ($mlw_quiz_options->user_phone == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio16">Yes</label>
|
866 |
+
<!--<input type="radio" id="radio17" name="userPhone" <?php if ($mlw_quiz_options->user_phone == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio17">Require</label>-->
|
867 |
+
<input type="radio" id="radio18" name="userPhone" <?php if ($mlw_quiz_options->user_phone == 2) {echo 'checked="checked"';} ?> value='2' /><label for="radio18">No</label>
|
868 |
+
</div></td>
|
869 |
+
</tr>
|
870 |
+
<tr valign="top">
|
871 |
+
<th scope="row"><label for="sendAdminEmail">Send admin email upon completion?</label></th>
|
872 |
+
<td><div id="sendAdminEmail">
|
873 |
+
<input type="radio" id="radio19" name="sendAdminEmail" <?php if ($mlw_quiz_options->send_admin_email == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio19">Yes</label>
|
874 |
+
<input type="radio" id="radio20" name="sendAdminEmail" <?php if ($mlw_quiz_options->send_admin_email == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio20">No</label>
|
875 |
+
</div></td>
|
876 |
+
</tr>
|
877 |
+
<tr valign="top">
|
878 |
+
<th scope="row"><label for="adminEmail">What email should we send the answers to?</label></th>
|
879 |
+
<td><input name="adminEmail" type="email" id="adminEmail" value="<?php echo $mlw_quiz_options->admin_email; ?>" class="regular-text" /></td>
|
880 |
+
</tr>
|
881 |
+
</table>
|
882 |
+
<?php echo "</form>"; ?>
|
883 |
+
</div>
|
884 |
+
</div>
|
885 |
+
|
886 |
+
|
887 |
+
<div id="delete_dialog" title="Delete Question?" style="display:none;">
|
888 |
+
<h3><b>Are you sure you want to delete Question <span id="delete_question_id"></span>?</b></h3>
|
889 |
+
<?php
|
890 |
+
echo "<form action='" . $PHP_SELF . "' method='post'>";
|
891 |
+
echo "<input type='hidden' name='delete_question' value='confirmation' />";
|
892 |
+
echo "<input type='hidden' id='question_id' name='question_id' value='' />";
|
893 |
+
echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
|
894 |
+
echo "<p class='submit'><input type='submit' class='button-primary' value='Delete Question' /></p>";
|
895 |
+
echo "</form>";
|
896 |
+
?>
|
897 |
+
</div>
|
898 |
+
<div id="dialog" title="Help">
|
899 |
+
<h3><b>Help</b></h3>
|
900 |
+
<p>This page is used edit the questions and options for your quiz. Use the help buttons on each tab for assistance.</p>
|
901 |
+
</div>
|
902 |
+
<div id="questions_help_dialog" title="Help">
|
903 |
+
<p>The question table lists the ID of the question and the question itself.</p>
|
904 |
+
<p>To edit a question, use the Edit link below the question.</p>
|
905 |
+
<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>
|
906 |
+
</div>
|
907 |
+
<div id="templates_help_dialog" title="Help">
|
908 |
+
<p>This tab is used to edit the different messages the user and admin may see.</p>
|
909 |
+
<p>The Message Displayed Before Quiz text is shown to the user at the beginning of the quiz.</p>
|
910 |
+
<p>The Message Displayed After Quiz text is show to the user at the end of the quiz.</p>
|
911 |
+
<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>
|
912 |
+
<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>
|
913 |
+
<p>The other templates section is for customizing the text on the submit button as well as the fields where are user can input his or her information.</p>
|
914 |
+
<p>Some templates are able to have variables inside the text. When the quiz is run, these variables will change to their values.</p>
|
915 |
+
</div>
|
916 |
+
<div id="options_help_dialog" title="Help">
|
917 |
+
<p>This tab is used to edit the different options for the quiz.</p>
|
918 |
+
<p>The system option allows you to have the quiz be graded using a correct/incorrect system or the quiz can have each answer worth different amount of points.</p>
|
919 |
+
<p>The second option asks whether you want the user to his or her score after completing the quiz.</p>
|
920 |
+
<p>The third option asks whether you want the user to be emailed after completing the quiz.</p>
|
921 |
+
<p>The next four options asks whether you want the quiz to ask for the user's name, business, email, and phone number.</p>
|
922 |
+
<p>The next option asks if you want the admin to receive an email after a quiz has been taken.</p>
|
923 |
+
<p>The last option asks for the email address of the admin you would like the quiz to email.</p>
|
924 |
+
</div>
|
925 |
+
|
926 |
+
<?php
|
927 |
+
}
|
928 |
+
else
|
929 |
+
{
|
930 |
+
?>
|
931 |
+
<div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
|
932 |
+
<p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
|
933 |
+
<strong>Hey!</strong> Please go to the quizzes page and click on the Edit link from the quiz you wish to edit.</p>
|
934 |
+
<?php
|
935 |
+
}
|
936 |
+
?>
|
937 |
+
</div>
|
938 |
+
</div>
|
939 |
+
<?php
|
940 |
+
}
|
941 |
+
?>
|
includes/mlw_results.php
ADDED
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
This page shows all of the results from the taken quizzes.
|
4 |
+
*/
|
5 |
+
/*
|
6 |
+
Copyright 2013, My Local Webstop (email : fpcorso@mylocalwebstop.com)
|
7 |
+
*/
|
8 |
+
|
9 |
+
function mlw_generate_quiz_results()
|
10 |
+
{
|
11 |
+
$quiz_id = $_GET["quiz_id"];
|
12 |
+
|
13 |
+
global $wpdb;
|
14 |
+
|
15 |
+
$sql = "SELECT * FROM " . $wpdb->prefix . "mlw_results WHERE deleted='0'";
|
16 |
+
if ($quiz_id != "")
|
17 |
+
{
|
18 |
+
$sql .= " AND quiz_id=".$quiz_id;
|
19 |
+
}
|
20 |
+
$sql .= " ORDER BY result_id DESC";
|
21 |
+
|
22 |
+
$mlw_quiz_data = $wpdb->get_results($sql);
|
23 |
+
?>
|
24 |
+
<!-- css -->
|
25 |
+
<link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
|
26 |
+
<!-- jquery scripts -->
|
27 |
+
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
|
28 |
+
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
|
29 |
+
<script type="text/javascript">
|
30 |
+
var $j = jQuery.noConflict();
|
31 |
+
// increase the default animation speed to exaggerate the effect
|
32 |
+
$j.fx.speeds._default = 1000;
|
33 |
+
$j(function() {
|
34 |
+
$j('#dialog').dialog({
|
35 |
+
autoOpen: false,
|
36 |
+
show: 'blind',
|
37 |
+
hide: 'explode',
|
38 |
+
buttons: {
|
39 |
+
Ok: function() {
|
40 |
+
$j(this).dialog('close');
|
41 |
+
}
|
42 |
+
}
|
43 |
+
});
|
44 |
+
|
45 |
+
$j('#opener').click(function() {
|
46 |
+
$j('#dialog').dialog('open');
|
47 |
+
return false;
|
48 |
+
} );
|
49 |
+
});
|
50 |
+
$j(function() {
|
51 |
+
$j( document ).tooltip();
|
52 |
+
});
|
53 |
+
$j(function() {
|
54 |
+
$j("button").button();
|
55 |
+
|
56 |
+
});
|
57 |
+
</script>
|
58 |
+
<style>
|
59 |
+
label {
|
60 |
+
display: inline-block;
|
61 |
+
width: 5em;
|
62 |
+
}
|
63 |
+
</style>
|
64 |
+
<style type="text/css">
|
65 |
+
div.mlw_quiz_options input[type='text'] {
|
66 |
+
border-color:#000000;
|
67 |
+
color:#3300CC;
|
68 |
+
cursor:hand;
|
69 |
+
}
|
70 |
+
</style>
|
71 |
+
<div class="wrap">
|
72 |
+
<div class='mlw_quiz_options'>
|
73 |
+
<h2>Quiz Results<a id="opener" href="">(?)</a></h2>
|
74 |
+
<?php
|
75 |
+
$quotes_list = "";
|
76 |
+
$display = "";
|
77 |
+
foreach($mlw_quiz_data as $mlw_quiz_info) {
|
78 |
+
if($alternate) $alternate = "";
|
79 |
+
else $alternate = " class=\"alternate\"";
|
80 |
+
$quotes_list .= "<tr{$alternate}>";
|
81 |
+
$quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->result_id . "</span></td>";
|
82 |
+
$quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_name . "</span></td>";
|
83 |
+
if ($mlw_quiz_info->quiz_system == 0)
|
84 |
+
{
|
85 |
+
$quotes_list .= "<td class='post-title column-title'><span style='font-size:16px;'>" . $mlw_quiz_info->correct ." out of ".$mlw_quiz_info->total." or ".$mlw_quiz_info->correct_score."%</span></td>";
|
86 |
+
}
|
87 |
+
else
|
88 |
+
{
|
89 |
+
$quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->point_score . " Points</span></td>";
|
90 |
+
}
|
91 |
+
$quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->name ."</span></td>";
|
92 |
+
$quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->business ."</span></td>";
|
93 |
+
$quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->email ."</span></td>";
|
94 |
+
$quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->phone ."</span></td>";
|
95 |
+
$quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->time_taken ."</span></td>";
|
96 |
+
$quotes_list .= "</tr>";
|
97 |
+
}
|
98 |
+
|
99 |
+
$display .= "<table class=\"widefat\">";
|
100 |
+
$display .= "<thead><tr>
|
101 |
+
<th>Result ID</th>
|
102 |
+
<th>Quiz Name</th>
|
103 |
+
<th>Score</th>
|
104 |
+
<th>Name</th>
|
105 |
+
<th>Business</th>
|
106 |
+
<th>Email</th>
|
107 |
+
<th>Phone</th>
|
108 |
+
<th>Time Taken</th>
|
109 |
+
</tr></thead>";
|
110 |
+
$display .= "<tbody id=\"the-list\">{$quotes_list}</tbody>";
|
111 |
+
$display .= "</table>";
|
112 |
+
echo $display;
|
113 |
+
?>
|
114 |
+
|
115 |
+
<div id="dialog" title="Help">
|
116 |
+
<h3><b>Help</b></h3>
|
117 |
+
<p>This page shows all of the results from the taken quizzes.</p>
|
118 |
+
<p>The table show the result id, the score from the quiz, the contact information provided, and the time the quiz was taken.</p>
|
119 |
+
</div>
|
120 |
+
</div>
|
121 |
+
</div>
|
122 |
+
<?php
|
123 |
+
}
|
124 |
+
?>
|
mlw_quizmaster2.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
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.1
|
7 |
+
Author: Frank Corso
|
8 |
+
Author URI: http://www.mylocalwebstop.com/
|
9 |
+
Plugin URI: http://www.mylocalwebstop.com/
|
10 |
+
*/
|
11 |
+
|
12 |
+
/*
|
13 |
+
Copyright 2013, My Local Webstop (email : fpcorso@mylocalwebstop.com)
|
14 |
+
|
15 |
+
Disclaimer of Warranties.
|
16 |
+
|
17 |
+
The plugin is provided "as is". My Local Webstop and its suppliers and licensors hereby disclaim all warranties of any kind,
|
18 |
+
express or implied, including, without limitation, the warranties of merchantability, fitness for a particular purpose and non-infringement.
|
19 |
+
Neither My Local Webstop nor its suppliers and licensors, makes any warranty that the plugin will be error free or that access thereto will be continuous or uninterrupted.
|
20 |
+
You understand that you install, operate, and unistall the plugin at your own discretion and risk.
|
21 |
+
*/
|
22 |
+
|
23 |
+
|
24 |
+
///Files to Include
|
25 |
+
include("includes/mlw_main_page.php");
|
26 |
+
include("includes/mlw_quiz.php");
|
27 |
+
include("includes/mlw_dashboard.php");
|
28 |
+
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
|
35 |
+
add_action('admin_menu', 'mlw_add_menu');
|
36 |
+
add_shortcode('mlw_quizmaster', 'mlw_quiz_shortcode');
|
37 |
+
//add_action('wp_dashboard_setup', "mlw_add_dashboard_widget"); Commented out until I have a use for it. Creates dashboard widget
|
38 |
+
register_activation_hook( __FILE__, 'mlw_quiz_activate');
|
39 |
+
register_deactivation_hook( __FILE__, 'mlw_quiz_deactivate');
|
40 |
+
|
41 |
+
|
42 |
+
///Create Admin Pages
|
43 |
+
function mlw_add_menu()
|
44 |
+
{
|
45 |
+
if (function_exists('add_menu_page'))
|
46 |
+
{
|
47 |
+
add_menu_page('Quizzes', 'Quizzes', 8, __FILE__, '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 |
+
/*
|
54 |
+
|
55 |
+
|
56 |
+
*/
|
57 |
+
?>
|
readme.txt
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Quiz Master Next ===
|
2 |
+
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.1
|
7 |
+
License: GPLv2 or later
|
8 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
|
10 |
+
Use this plugin to add multiple quizzes or tests to your website.
|
11 |
+
|
12 |
+
== Description ==
|
13 |
+
|
14 |
+
This is the successor plugin to the wildly popular Quiz Master plugin I wrote years ago. Re-wrote from the ground up.
|
15 |
+
|
16 |
+
Use this plugin to add multiple quizzes or tests to your website. This plugin allows for unlimited quizzes each with unlimited amount of questions. The plugin allows you to create the quiz, add it to any page using a customized shortcode, allows the user to take to quiz, and then saves the results.
|
17 |
+
|
18 |
+
Features include:
|
19 |
+
|
20 |
+
* Allows for Unlimited Quizzes
|
21 |
+
* Allows for Unlimited Questions in each Quiz
|
22 |
+
* Can ask for user's contact information
|
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 either an incorrect/correct system or a points based system
|
26 |
+
* Saves the results after a user takes the quiz
|
27 |
+
|
28 |
+
== Installation ==
|
29 |
+
|
30 |
+
* Upload plugin dir to the `/wp-content/plugins/` directory
|
31 |
+
* Activate the plugin through the 'Plugins' menu in WordPress
|
32 |
+
|
33 |
+
== Frequently Asked Questions ==
|
34 |
+
|
35 |
+
= I have an idea, how do I contact you? =
|
36 |
+
|
37 |
+
Feel free to use the support option on the main page of the plugin.
|
38 |
+
|
39 |
+
== Screenshots ==
|
40 |
+
|
41 |
+
1. Quiz Admin Page
|
42 |
+
2. Quiz Options Page
|
43 |
+
|
44 |
+
== Changelog ==
|
45 |
+
|
46 |
+
= 0.1 (September 1, 2013) =
|
47 |
+
* Begun Development
|
48 |
+
* Added ability to create/edit/delete quizzes
|
49 |
+
* Added ability to create/edit/delete questions
|
50 |
+
* Added quiz admin page
|
51 |
+
* Added questions admin page
|
52 |
+
* Added results page
|
53 |
+
|
54 |
+
== Upgrade Notice ==
|
55 |
+
|
56 |
+
= 0.1 =
|
57 |
+
Initial Version
|
uninstall.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
global $wpdb;
|
3 |
+
|
4 |
+
$table_name = $wpdb->prefix . "mlw_results";
|
5 |
+
|
6 |
+
$sql = "DROP TABLE IF EXISTS ".$table_name;
|
7 |
+
|
8 |
+
$results = $wpdb->query( $sql );
|
9 |
+
|
10 |
+
$table_name = $wpdb->prefix . "mlw_quizzes";
|
11 |
+
|
12 |
+
$sql = "DROP TABLE IF EXISTS ".$table_name;
|
13 |
+
|
14 |
+
$results = $wpdb->query( $sql );
|
15 |
+
|
16 |
+
$table_name = $wpdb->prefix . "mlw_questions";
|
17 |
+
|
18 |
+
$sql = "DROP TABLE IF EXISTS ".$table_name;
|
19 |
+
|
20 |
+
$results = $wpdb->query( $sql );
|
21 |
+
?>
|