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

Version Description

(March 18, 2014) = * Fixed Bug

Download this release

Release Info

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

Code changes from version 1.9.4 to 1.9.5

includes/mlw_quiz.php CHANGED
@@ -1,985 +1,992 @@
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
-
13
- /*
14
- Code before loading the quiz
15
- */
16
-
17
- //Variables needed throughout script
18
- $mlw_quiz_id = $quiz;
19
- $mlw_display = "";
20
- global $wpdb;
21
- $mlw_qmn_isAllowed = true;
22
- $mlw_qmn_section_count = 1;
23
- $mlw_qmn_section_limit = 0;
24
-
25
-
26
- //Load quiz
27
- $sql = "SELECT * FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=".$mlw_quiz_id." AND deleted='0'";
28
- $mlw_quiz_options = $wpdb->get_results($sql);
29
-
30
- foreach($mlw_quiz_options as $mlw_eaches) {
31
- $mlw_quiz_options = $mlw_eaches;
32
- break;
33
- }
34
-
35
- //Check to see if there is limit on the amount of tries
36
- if ( $mlw_quiz_options->total_user_tries != 0 && is_user_logged_in() )
37
- {
38
- $current_user = wp_get_current_user();
39
- $mlw_qmn_user_try_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_results WHERE email='%s' AND deleted='0' AND quiz_id=%d", $current_user->user_email, $mlw_quiz_id ) );
40
- if ($mlw_qmn_user_try_count >= $mlw_quiz_options->total_user_tries) { $mlw_qmn_isAllowed = false; }
41
- }
42
-
43
-
44
- //Load questions
45
- $sql = "SELECT * FROM " . $wpdb->prefix . "mlw_questions" . " WHERE quiz_id=".$mlw_quiz_id." AND deleted='0' ";
46
- if ($mlw_quiz_options->randomness_order == 0)
47
- {
48
- $sql .= "ORDER BY question_order ASC";
49
- }
50
- if ($mlw_quiz_options->randomness_order == 1)
51
- {
52
- $sql .= "ORDER BY rand()";
53
- }
54
- if ($mlw_quiz_options->question_from_total != 0)
55
- {
56
- $sql .= " LIMIT ".$mlw_quiz_options->question_from_total;
57
- }
58
- $mlw_questions = $wpdb->get_results($sql);
59
-
60
-
61
- //Variables to load if quiz has been taken
62
- if (isset($_POST["complete_quiz"]) && $_POST["complete_quiz"] == "confirmation")
63
- {
64
- $mlw_success = $_POST["complete_quiz"];
65
- $mlw_user_name = isset($_POST["mlwUserName"]) ? $_POST["mlwUserName"] : 'None';
66
- $mlw_user_comp = isset($_POST["mlwUserComp"]) ? $_POST["mlwUserComp"] : 'None';
67
- $mlw_user_email = isset($_POST["mlwUserEmail"]) ? $_POST["mlwUserEmail"] : 'None';
68
- $mlw_user_phone = isset($_POST["mlwUserPhone"]) ? $_POST["mlwUserPhone"] : 'None';
69
- $mlw_qmn_timer = isset($_POST["timer"]) ? $_POST["timer"] : 0;
70
- $mlw_spam_email = $_POST["email"];
71
- }
72
-
73
- wp_enqueue_script( 'jquery' );
74
- wp_enqueue_script( 'jquery-ui-core' );
75
- wp_enqueue_script( 'jquery-effects-core' );
76
- wp_enqueue_script( 'jquery-effects-slide' );
77
- wp_enqueue_script( 'jquery-ui-dialog' );
78
- wp_enqueue_script( 'jquery-ui-button' );
79
- wp_enqueue_script( 'jquery-ui-accordion' );
80
- wp_enqueue_script( 'jquery-ui-tooltip' );
81
- wp_enqueue_script( 'jquery-ui-tabs' );
82
- ?>
83
- <!-- css -->
84
- <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
85
- <script type="text/javascript">
86
- var $j = jQuery.noConflict();
87
- // increase the default animation speed to exaggerate the effect
88
- $j.fx.speeds._default = 1000;
89
- $j(function() {
90
- $j( document ).tooltip();
91
- });
92
- </script>
93
- <style type="text/css">
94
- .ui-tooltip
95
- {
96
- /* tooltip container box */
97
- max-width: 500px !important;
98
- }
99
- .ui-tooltip-content
100
- {
101
- /* tooltip content */
102
- max-width: 500px !important;
103
- }
104
- </style>
105
- <?php
106
-
107
- /*
108
- The following code is for displaying the quiz and completion screen
109
- */
110
-
111
- //If there is no quiz for the shortcode provided
112
- if ($mlw_quiz_options->quiz_name == "")
113
- {
114
- $mlw_display .= "It appears that this quiz is not set up correctly.";
115
- return $mlw_display;
116
- }
117
-
118
- //Display Quiz
119
- if (!isset($_POST["complete_quiz"]) && $mlw_quiz_options->quiz_name != "" && $mlw_qmn_isAllowed)
120
- {
121
- $mlw_qmn_total_questions = 0;
122
- //Calculate number of pages if pagination is turned on
123
- if ($mlw_quiz_options->pagination != 0)
124
- {
125
- $mlw_qmn_section_limit = 2 + $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_questions WHERE quiz_id=%d AND deleted=0", $mlw_quiz_id ) );
126
- if ($mlw_quiz_options->comment_section == 0)
127
- {
128
- $mlw_qmn_section_limit = $mlw_qmn_section_limit + 1;
129
- }
130
-
131
- //Gather text for pagination buttons
132
- $mlw_qmn_pagination_text = "";
133
- $mlw_qmn_pagination_text = @unserialize($mlw_quiz_options->pagination_text);
134
- if (!is_array($mlw_qmn_pagination_text)) {
135
- $mlw_qmn_pagination_text = array('Previous', $mlw_quiz_options->pagination_text);
136
- }
137
- ?>
138
- <script type="text/javascript">
139
- var $j = jQuery.noConflict();
140
- $j(function() {
141
- $j( ".quiz_section" ).hide();
142
- $j( ".quiz_section" ).append( "<br />" );
143
- $j( ".quiz_section" ).not( ".quiz_begin" ).append( "<a class=\"mlw_qmn_quiz_link\" href='#' onclick=\"prevSlide();\"><?php echo $mlw_qmn_pagination_text[0]; ?></a>" );
144
- $j( ".quiz_section" ).not( ".quiz_end" ).append( "<a class=\"mlw_qmn_quiz_link\" href='#' onclick=\"nextSlide();\"><?php echo $mlw_qmn_pagination_text[1]; ?></a>" );
145
- window.mlw_quiz_slide = 0;
146
- window.mlw_quiz_total_slides = <?php echo $mlw_qmn_section_limit; ?>;
147
- nextSlide();
148
- });
149
- function nextSlide()
150
- {
151
- window.mlw_quiz_slide++;
152
- if (window.mlw_quiz_slide == window.mlw_quiz_total_slides)
153
- {
154
- $j(".quiz_link").html("Submit");
155
- }
156
- if (window.mlw_quiz_slide > window.mlw_quiz_total_slides)
157
- {
158
- document.quizForm.submit();
159
- exit();
160
- }
161
- y = window.mlw_quiz_slide-1;
162
- $j( ".quiz_section.slide"+y ).hide();
163
- $j( ".quiz_section.slide"+window.mlw_quiz_slide ).show( "slide", {direction: "right"}, 300 );
164
-
165
- }
166
- function prevSlide()
167
- {
168
- window.mlw_quiz_slide--;
169
- if (window.mlw_quiz_slide == window.mlw_quiz_total_slides)
170
- {
171
- $j(".quiz_link").html("Submit");
172
- }
173
- if (window.mlw_quiz_slide > window.mlw_quiz_total_slides)
174
- {
175
- document.quizForm.submit();
176
- exit();
177
- }
178
- y = window.mlw_quiz_slide+1;
179
- $j( ".quiz_section.slide"+y ).hide();
180
- $j( ".quiz_section.slide"+window.mlw_quiz_slide ).show( "slide", {direction: "left"}, 300 );
181
- }
182
- </script>
183
- <style type="text/css">
184
- a.mlw_qmn_quiz_link
185
- {
186
- border-radius: 4px;
187
- position: relative;
188
- background-image: linear-gradient(#fff,#dedede);
189
- background-color: #eee;
190
- border: #ccc solid 1px;
191
- color: #333;
192
- text-shadow: 0 1px 0 rgba(255,255,255,.5);
193
- box-sizing: border-box;
194
- display: inline-block;
195
- padding: 5px 5px 5px 5px;
196
- margin: auto;
197
- }
198
- </style>
199
- <?php
200
- }
201
- if ($mlw_quiz_options->timer_limit != 0)
202
- {
203
- ?>
204
- <div id="mlw_qmn_timer"></div>
205
- <script type="text/javascript">
206
- var minutes = <?php echo $mlw_quiz_options->timer_limit; ?>;
207
- window.amount = (minutes*60);
208
- window.titleText = window.document.title;
209
- document.getElementById("mlw_qmn_timer").innerHTML = minToSec(window.amount);
210
- window.counter=setInterval(timer, 1000); //1000 will run it every 1 second
211
- function timer()
212
- {
213
- window.amount=window.amount-1;
214
- document.getElementById("mlw_qmn_timer").innerHTML = minToSec(window.amount);
215
- window.document.title = minToSec(window.amount) + " " + window.titleText;
216
- if (window.amount <= 0)
217
- {
218
- clearInterval(window.counter);
219
- document.quizForm.submit();
220
- return;
221
- }
222
- }
223
- function minToSec(amount)
224
- {
225
- var minutes = Math.floor(amount/60);
226
- var seconds = amount - (minutes * 60);
227
- if (seconds == '0')
228
- {
229
- seconds = "00";
230
- }
231
- else if (seconds < 10)
232
- {
233
- seconds = '0' + seconds;
234
- }
235
- return minutes+":"+seconds;
236
- }
237
- </script>
238
- <style type="text/css">
239
- #mlw_qmn_timer {
240
- position:fixed;
241
- top:200px;
242
- right:0px;
243
- width:130px;
244
- color:#00CCFF;
245
- border-radius: 15px;
246
- background:#000000;
247
- text-align: center;
248
- padding: 15px 15px 15px 15px
249
- }
250
- </style>
251
- <?php
252
- }
253
-
254
- ?>
255
- <script type="text/javascript">
256
- var myVar=setInterval("mlwQmnTimer();",1000);
257
- function mlwQmnTimer()
258
- {
259
- var x = +document.getElementById("timer").value;
260
- x = x + 1;
261
- document.getElementById("timer").value = x;
262
- }
263
-
264
- </script>
265
- <style type="text/css">
266
- div.mlw_qmn_quiz input[type=radio],
267
- div.mlw_qmn_quiz input[type=submit],
268
- div.mlw_qmn_quiz label {
269
- cursor: pointer;
270
- }
271
- div.mlw_qmn_quiz input:not([type=submit]):focus,
272
- div.mlw_qmn_quiz textarea:focus {
273
- background: #eaeaea;
274
- }
275
- div.mlw_qmn_quiz_section
276
- {
277
-
278
- }
279
- </style>
280
- <?
281
- //Update the quiz views
282
- $mlw_views = $mlw_quiz_options->quiz_views;
283
- $mlw_views += 1;
284
- $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET quiz_views='".$mlw_views."' WHERE quiz_id=".$mlw_quiz_id;
285
- $results = $wpdb->query( $update );
286
-
287
- //Form validation script
288
- $mlw_display .= "
289
- <script>
290
- function clear_field(field)
291
- {
292
- if (field.defaultValue == field.value) field.value = '';
293
- }
294
-
295
- function mlw_validateForm()
296
- {
297
- ";
298
- if ($mlw_quiz_options->user_name == 1)
299
- {
300
- $mlw_display .= "
301
- var x=document.forms['quizForm']['mlwUserName'].value;
302
- if (x==null || x=='')
303
- {
304
- document.getElementById('mlw_error_message').innerHTML = '**Name must be filled out!**';
305
- document.getElementById('mlw_error_message_bottom').innerHTML = '**Name must be filled out!**';
306
- return false;
307
- }";
308
- }
309
- if ($mlw_quiz_options->user_comp == 1)
310
- {
311
- $mlw_display .= "
312
- var x=document.forms['quizForm']['mlwUserComp'].value;
313
- if (x==null || x=='')
314
- {
315
- document.getElementById('mlw_error_message').innerHTML = '**Business must be filled out!**';
316
- document.getElementById('mlw_error_message_bottom').innerHTML = '**Business must be filled out!**';
317
- return false;
318
- }";
319
- }
320
- if ($mlw_quiz_options->user_email == 1)
321
- {
322
- $mlw_display .= "
323
- var x=document.forms['quizForm']['mlwUserEmail'].value;
324
- if (x==null || x=='')
325
- {
326
- document.getElementById('mlw_error_message').innerHTML = '**Email must be filled out!**';
327
- document.getElementById('mlw_error_message_bottom').innerHTML = '**Email must be filled out!**';
328
- return false;
329
- }";
330
- }
331
- if ($mlw_quiz_options->user_phone == 1)
332
- {
333
- $mlw_display .= "
334
- var x=document.forms['quizForm']['mlwUserPhone'].value;
335
- if (x==null || x=='')
336
- {
337
- document.getElementById('mlw_error_message').innerHTML = '**Phone number must be filled out!**';
338
- document.getElementById('mlw_error_message_bottom').innerHTML = '**Phone number must be filled out!**';
339
- return false;
340
- }";
341
- }
342
- $mlw_display .= "
343
- if (document.forms['quizForm']['mlwUserEmail'].defaultValue != document.forms['quizForm']['mlwUserEmail'].value)
344
- {
345
- var x=document.forms['quizForm']['mlwUserEmail'].value;
346
- var atpos=x.indexOf('@');
347
- var dotpos=x.lastIndexOf('.');
348
- if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
349
- {
350
- document.getElementById('mlw_error_message').innerHTML = '**Not a valid e-mail address!**';
351
- document.getElementById('mlw_error_message_bottom').innerHTML = '**Not a valid e-mail address!**';
352
- return false;
353
- }
354
- }
355
- }
356
- </script>";
357
-
358
- //Begin the quiz
359
- $mlw_display .= "<div class='mlw_qmn_quiz'>";
360
- $mlw_display .= "<form name='quizForm' action='' method='post' class='mlw_quiz_form' onsubmit='return mlw_validateForm()' >";
361
- $mlw_display .= "<div class='quiz_section quiz_begin slide".$mlw_qmn_section_count."'>";
362
- $mlw_message_before = $mlw_quiz_options->message_before;
363
- $mlw_message_before = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_before);
364
- $mlw_message_before = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_before);
365
- $mlw_display .= "<span>".$mlw_message_before."</span><br />";
366
- $mlw_display .= "<span name='mlw_error_message' id='mlw_error_message' style='color: red;'></span><br />";
367
-
368
- if ($mlw_quiz_options->contact_info_location == 0)
369
- {
370
- $mlw_display .= mlwDisplayContactInfo($mlw_quiz_options);
371
- }
372
- $mlw_display .= "</div>";
373
-
374
- //Display the questions
375
- foreach($mlw_questions as $mlw_question) {
376
- $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
377
- $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
378
- $mlw_display .= "<div class='quiz_section slide".$mlw_qmn_section_count."'>";
379
- $mlw_display .= "<span style='font-weight:bold;'>".htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
380
- if ($mlw_question->question_type == 0)
381
- {
382
- if ($mlw_question->answer_one != "")
383
- {
384
- $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_one' value='1' /> <label for='question".$mlw_question->question_id."_one'>".htmlspecialchars_decode($mlw_question->answer_one, ENT_QUOTES)."</label>";
385
- $mlw_display .= "<br />";
386
- }
387
- if ($mlw_question->answer_two != "")
388
- {
389
- $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_two' value='2' /> <label for='question".$mlw_question->question_id."_two'>".htmlspecialchars_decode($mlw_question->answer_two, ENT_QUOTES)."</label>";
390
- $mlw_display .= "<br />";
391
- }
392
- if ($mlw_question->answer_three != "")
393
- {
394
- $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_three' value='3' /> <label for='question".$mlw_question->question_id."_three'>".htmlspecialchars_decode($mlw_question->answer_three, ENT_QUOTES)."</label>";
395
- $mlw_display .= "<br />";
396
- }
397
- if ($mlw_question->answer_four != "")
398
- {
399
- $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_four' value='4' /> <label for='question".$mlw_question->question_id."_four'>".htmlspecialchars_decode($mlw_question->answer_four, ENT_QUOTES)."</label>";
400
- $mlw_display .= "<br />";
401
- }
402
- if ($mlw_question->answer_five != "")
403
- {
404
- $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_five' value='5' /> <label for='question".$mlw_question->question_id."_five'>".htmlspecialchars_decode($mlw_question->answer_five, ENT_QUOTES)."</label>";
405
- $mlw_display .= "<br />";
406
- }
407
- if ($mlw_question->answer_six != "")
408
- {
409
- $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_six' value='6' /> <label for='question".$mlw_question->question_id."_six'>".htmlspecialchars_decode($mlw_question->answer_six, ENT_QUOTES)."</label>";
410
- $mlw_display .= "<br />";
411
- }
412
- }
413
- elseif ($mlw_question->question_type == 1)
414
- {
415
- if ($mlw_question->answer_one != "")
416
- {
417
- $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' value='1' />".htmlspecialchars_decode($mlw_question->answer_one, ENT_QUOTES);
418
- }
419
- if ($mlw_question->answer_two != "")
420
- {
421
- $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' value='2' />".htmlspecialchars_decode($mlw_question->answer_two, ENT_QUOTES);
422
- }
423
- if ($mlw_question->answer_three != "")
424
- {
425
- $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' value='3' />".htmlspecialchars_decode($mlw_question->answer_three, ENT_QUOTES);
426
- }
427
- if ($mlw_question->answer_four != "")
428
- {
429
- $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' value='4' />".htmlspecialchars_decode($mlw_question->answer_four, ENT_QUOTES);
430
- }
431
- if ($mlw_question->answer_five != "")
432
- {
433
- $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' value='5' />".htmlspecialchars_decode($mlw_question->answer_five, ENT_QUOTES);
434
- }
435
- if ($mlw_question->answer_six != "")
436
- {
437
- $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' value='6' />".htmlspecialchars_decode($mlw_question->answer_six, ENT_QUOTES);
438
- }
439
- $mlw_display .= "<br />";
440
- }
441
- else
442
- {
443
- $mlw_display .= "<select required name='question".$mlw_question->question_id."'>";
444
- if ($mlw_question->answer_one != "")
445
- {
446
- $mlw_display .= "<option value='1'>".htmlspecialchars_decode($mlw_question->answer_one, ENT_QUOTES)."</option>";
447
- }
448
- if ($mlw_question->answer_two != "")
449
- {
450
- $mlw_display .= "<option value='2'>".htmlspecialchars_decode($mlw_question->answer_two, ENT_QUOTES)."</option>";
451
- }
452
- if ($mlw_question->answer_three != "")
453
- {
454
- $mlw_display .= "<option value='3'>".htmlspecialchars_decode($mlw_question->answer_three, ENT_QUOTES)."</option>";
455
- }
456
- if ($mlw_question->answer_four != "")
457
- {
458
- $mlw_display .= "<option value='4'>".htmlspecialchars_decode($mlw_question->answer_four, ENT_QUOTES)."</option>";
459
- }
460
- if ($mlw_question->answer_five != "")
461
- {
462
- $mlw_display .= "<option value='5'>".htmlspecialchars_decode($mlw_question->answer_five, ENT_QUOTES)."</option>";
463
- }
464
- if ($mlw_question->answer_six != "")
465
- {
466
- $mlw_display .= "<option value='6'>".htmlspecialchars_decode($mlw_question->answer_six, ENT_QUOTES)."</option>";
467
- }
468
- $mlw_display .= "</select>";
469
- $mlw_display .= "<br />";
470
- }
471
- if ($mlw_question->comments == 0)
472
- {
473
- $mlw_display .= "<input type='text' x-webkit-speech id='mlwComment".$mlw_question->question_id."' name='mlwComment".$mlw_question->question_id."' value='".$mlw_quiz_options->comment_field_text."' onclick='clear_field(this)'/>";
474
- $mlw_display .= "<br />";
475
- }
476
- if ($mlw_question->comments == 2)
477
- {
478
- $mlw_display .= "<textarea cols='70' rows='5' id='mlwComment".$mlw_question->question_id."' name='mlwComment".$mlw_question->question_id."' onclick='clear_field(this)'>".$mlw_quiz_options->comment_field_text."</textarea>";
479
- $mlw_display .= "<br />";
480
- }
481
- if ($mlw_question->hints != "")
482
- {
483
- $mlw_display .= "<span title=\"".htmlspecialchars_decode($mlw_question->hints, ENT_QUOTES)."\" style=\"text-decoration:underline;color:rgb(0,0,255);\">Hint</span>";
484
- $mlw_display .= "<br /><br />";
485
- }
486
- $mlw_display .= "</div>";
487
- if ( $mlw_quiz_options->pagination == 0) { $mlw_display .= "<br />"; }
488
- }
489
-
490
- //Display comment box if needed
491
- if ($mlw_quiz_options->comment_section == 0)
492
- {
493
- $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
494
- $mlw_display .= "<div class='quiz_section slide".$mlw_qmn_section_count."'>";
495
- $mlw_message_comments = $mlw_quiz_options->message_comment;
496
- $mlw_message_comments = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_comments);
497
- $mlw_message_comments = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_comments);
498
- $mlw_display .= "<label for='mlwQuizComments' style='font-weight:bold;'>".$mlw_message_comments."</label><br />";
499
- $mlw_display .= "<textarea cols='70' rows='15' id='mlwQuizComments' name='mlwQuizComments' ></textarea>";
500
- $mlw_display .= "</div>";
501
- if ( $mlw_quiz_options->pagination == 0) { $mlw_display .= "<br /><br />"; }
502
- }
503
- $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
504
- $mlw_display .= "<div class='quiz_section slide".$mlw_qmn_section_count." quiz_end'>";
505
- if ($mlw_quiz_options->message_end_template != '')
506
- {
507
- $mlw_message_end = $mlw_quiz_options->message_end_template;
508
- $mlw_message_end = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_end);
509
- $mlw_message_end = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_end);
510
- $mlw_display .= "<span>".$mlw_message_end."</span>";
511
- $mlw_display .= "<br /><br />";
512
- }
513
- if ($mlw_quiz_options->contact_info_location == 1)
514
- {
515
- $mlw_display .= mlwDisplayContactInfo($mlw_quiz_options);
516
- }
517
- $mlw_display .= "<span style='display: none;'>If you are human, leave this field blank or you will be considered spam:</span>";
518
- $mlw_display .= "<input style='display: none;' type='text' name='email' id='email' />";
519
- $mlw_display .= "<input type='hidden' name='total_questions' id='total_questions' value='".$mlw_qmn_total_questions."'/>";
520
- $mlw_display .= "<input type='hidden' name='timer' id='timer' value='0'/>";
521
- $mlw_display .= "<input type='hidden' name='complete_quiz' value='confirmation' />";
522
- $mlw_display .= "<input type='submit' value='".$mlw_quiz_options->submit_button_text."' />";
523
- $mlw_display .= "<span name='mlw_error_message_bottom' id='mlw_error_message_bottom' style='color: red;'></span><br />";
524
- $mlw_display .= "</form>";
525
- $mlw_display .= "</div>";
526
- $mlw_display .= "</div>";
527
-
528
- }
529
- //Display Completion Screen
530
- else
531
- {
532
- if (empty($mlw_spam_email) && $mlw_qmn_isAllowed)
533
- {
534
-
535
- //Load questions
536
- $sql = "SELECT * FROM " . $wpdb->prefix . "mlw_questions" . " WHERE quiz_id=".$mlw_quiz_id." AND deleted='0' ";
537
- if ($mlw_quiz_options->randomness_order == 0)
538
- {
539
- $sql .= "ORDER BY question_order ASC";
540
- }
541
- if ($mlw_quiz_options->randomness_order == 1)
542
- {
543
- $sql .= "ORDER BY rand()";
544
- }
545
- $mlw_questions = $wpdb->get_results($sql);
546
-
547
- //Variables needed for scoring
548
- $mlw_points = 0;
549
- $mlw_correct = 0;
550
- $mlw_total_questions = 0;
551
- $mlw_total_score = 0;
552
- $mlw_question_answers = "";
553
- isset($_POST["total_questions"]) ? $mlw_total_questions = intval($_POST["total_questions"]) : $mlw_total_questions = 0;
554
-
555
- //Update the amount of times the quiz has been taken
556
- $mlw_taken = $mlw_quiz_options->quiz_taken;
557
- $mlw_taken += 1;
558
- $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET quiz_taken='".$mlw_taken."' WHERE quiz_id=".$mlw_quiz_id;
559
- $results = $wpdb->query( $update );
560
-
561
- //See which answers were correct and award points if necessary
562
- foreach($mlw_questions as $mlw_question) {
563
- if (isset($_POST["question".$mlw_question->question_id]) || isset($_POST["mlwComment".$mlw_question->question_id]))
564
- {
565
- $mlw_user_text;
566
- $mlw_correct_text;
567
- //$mlw_total_questions += 1;
568
- if (isset($_POST["question".$mlw_question->question_id]))
569
- {
570
- $mlw_user_answer = $_POST["question".$mlw_question->question_id];
571
- if ($mlw_user_answer == $mlw_question->correct_answer)
572
- {
573
- $mlw_correct += 1;
574
- }
575
- if ($mlw_user_answer == 1)
576
- {
577
- $mlw_points += $mlw_question->answer_one_points;
578
- $mlw_user_text = $mlw_question->answer_one;
579
- }
580
- if ($mlw_user_answer == 2)
581
- {
582
- $mlw_points += $mlw_question->answer_two_points;
583
- $mlw_user_text = $mlw_question->answer_two;
584
- }
585
- if ($mlw_user_answer == 3)
586
- {
587
- $mlw_points += $mlw_question->answer_three_points;
588
- $mlw_user_text = $mlw_question->answer_three;
589
- }
590
- if ($mlw_user_answer == 4)
591
- {
592
- $mlw_points += $mlw_question->answer_four_points;
593
- $mlw_user_text = $mlw_question->answer_four;
594
- }
595
- if ($mlw_user_answer == 5)
596
- {
597
- $mlw_points += $mlw_question->answer_five_points;
598
- $mlw_user_text = $mlw_question->answer_five;
599
- }
600
- if ($mlw_user_answer == 6)
601
- {
602
- $mlw_points += $mlw_question->answer_six_points;
603
- $mlw_user_text = $mlw_question->answer_six;
604
- }
605
-
606
- if ($mlw_question->correct_answer == 1) {$mlw_correct_text = $mlw_question->answer_one;}
607
- if ($mlw_question->correct_answer == 2) {$mlw_correct_text = $mlw_question->answer_two;}
608
- if ($mlw_question->correct_answer == 3) {$mlw_correct_text = $mlw_question->answer_three;}
609
- if ($mlw_question->correct_answer == 4) {$mlw_correct_text = $mlw_question->answer_four;}
610
- if ($mlw_question->correct_answer == 5) {$mlw_correct_text = $mlw_question->answer_five;}
611
- if ($mlw_question->correct_answer == 6) {$mlw_correct_text = $mlw_question->answer_six;}
612
- }
613
- if (isset($_POST["mlwComment".$mlw_question->question_id]))
614
- {
615
- $mlw_qm_question_comment = $_POST["mlwComment".$mlw_question->question_id];
616
- }
617
- else
618
- {
619
- $mlw_qm_question_comment = "";
620
- }
621
-
622
- $mlw_question_answer_display = $mlw_quiz_options->question_answer_template;
623
- $mlw_question_answer_display = str_replace( "%QUESTION%" , htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES), $mlw_question_answer_display);
624
- $mlw_question_answer_display = str_replace( "%USER_ANSWER%" , $mlw_user_text, $mlw_question_answer_display);
625
- $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER%" , $mlw_correct_text, $mlw_question_answer_display);
626
- $mlw_question_answer_display = str_replace( "%USER_COMMENTS%" , $mlw_qm_question_comment, $mlw_question_answer_display);
627
- $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER_INFO%" , htmlspecialchars_decode($mlw_question->question_answer_info), $mlw_question_answer_display);
628
-
629
- $mlw_question_answers .= $mlw_question_answer_display;
630
- $mlw_question_answers .= "<br />";
631
- }
632
- }
633
-
634
- //Calculate Total Percent Score And Average Points Only If Total Questions Doesn't Equal Zero To Avoid Division By Zero Error
635
- if ($mlw_total_questions != 0)
636
- {
637
- $mlw_total_score = round((($mlw_correct/$mlw_total_questions)*100), 2);
638
- $mlw_average_points = round(($mlw_points/$mlw_total_questions), 2);
639
- }
640
- else
641
- {
642
- $mlw_total_score = 0;
643
- $mlw_average_points = 0;
644
- }
645
-
646
- //Prepare comment section if set
647
- if (isset($_POST["mlwQuizComments"]))
648
- {
649
- $mlw_qm_quiz_comments = $_POST["mlwQuizComments"];
650
- }
651
- else
652
- {
653
- $mlw_qm_quiz_comments = "";
654
- }
655
-
656
-
657
- //Prepare Certificate
658
- $mlw_certificate_link = "";
659
- $mlw_certificate_options = unserialize($mlw_quiz_options->certificate_template);
660
- if (!is_array($mlw_certificate_options)) {
661
- // something went wrong, initialize to empty array
662
- $mlw_certificate_options = array('Enter title here', 'Enter text here', '', '', 1);
663
- }
664
- if ($mlw_certificate_options[4] == 0)
665
- {
666
- $mlw_message_certificate = $mlw_certificate_options[1];
667
- $mlw_message_certificate = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_certificate);
668
- $mlw_message_certificate = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_certificate);
669
- $mlw_message_certificate = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_certificate);
670
- $mlw_message_certificate = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_certificate);
671
- $mlw_message_certificate = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_certificate);
672
- $mlw_message_certificate = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_certificate);
673
- $mlw_message_certificate = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_certificate);
674
- $mlw_message_certificate = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_certificate);
675
- $mlw_message_certificate = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_certificate);
676
- $mlw_message_certificate = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_certificate);
677
- $mlw_message_certificate = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_certificate);
678
- $mlw_message_certificate = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_certificate);
679
- $mlw_message_certificate = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_certificate);
680
- $mlw_message_certificate = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_certificate);
681
- $mlw_message_certificate = str_replace( "\n" , "<br>", $mlw_message_certificate);
682
- $mlw_qmn_certifiicate_file = "<?php
683
- include(\"".plugin_dir_path( __FILE__ )."WriteHTML.php\");
684
- \$pdf = new PDF_HTML();
685
- \$pdf->AddPage('L');";
686
- $mlw_qmn_certifiicate_file .= $mlw_certificate_options[3] != '' ? "\$pdf->Image('".$mlw_certificate_options[3]."',0,0,\$pdf->w, \$pdf->h);" : '';
687
- $mlw_qmn_certifiicate_file .= "\$pdf->Ln(20);
688
- \$pdf->SetFont('Arial','B',24);
689
- \$pdf->MultiCell(280,20,'".$mlw_certificate_options[0]."', 0, 'C');
690
- \$pdf->Ln(15);
691
- \$pdf->SetFont('Arial','',16);
692
- \$pdf->WriteHTML('<p align=\"center\">".$mlw_message_certificate."</p>');";
693
- $mlw_qmn_certifiicate_file .= $mlw_certificate_options[2] != '' ? "\$pdf->Image('".$mlw_certificate_options[2]."',110,130);" : '';
694
- $mlw_qmn_certifiicate_file .= "\$pdf->Output('mlw_qmn_certificate.pdf', 'D');
695
- unlink(__FILE__);
696
- ?>";
697
- $mlw_qmn_certificate_filename = str_replace(home_url()."/", '', plugin_dir_url( __FILE__ ))."certificates/mlw_qmn_quiz".date("YmdHis").$mlw_qmn_timer.".php";
698
- file_put_contents($mlw_qmn_certificate_filename, $mlw_qmn_certifiicate_file);
699
- $mlw_qmn_certificate_filename = plugin_dir_url( __FILE__ )."certificates/mlw_qmn_quiz".date("YmdHis").$mlw_qmn_timer.".php";
700
- $mlw_certificate_link = "<a href='".$mlw_qmn_certificate_filename."' style='color: blue;'>Download Certificate</a>";
701
- }
702
-
703
- /*
704
- Prepare the landing page
705
- -First, unserialize message_after column
706
- -Second, check for array in case user has not updated
707
- Message array = (array( bottomvalue, topvalue, text),array( bottomvalue, topvalue, text), etc..., array(0,0,text))
708
- */
709
- $mlw_message_after_array = @unserialize($mlw_quiz_options->message_after);
710
- if (is_array($mlw_message_after_array))
711
- {
712
- //Cycle through landing pages
713
- foreach($mlw_message_after_array as $mlw_each)
714
- {
715
- //Check to see if default
716
- if ($mlw_each[0] == 0 && $mlw_each[1] == 0)
717
- {
718
- $mlw_message_after = $mlw_each[2];
719
- $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
720
- $mlw_message_after = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_after);
721
- $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
722
- $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
723
- $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
724
- $mlw_message_after = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_after);
725
- $mlw_message_after = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_after);
726
- $mlw_message_after = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_after);
727
- $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
728
- $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
729
- $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
730
- $mlw_message_after = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_after);
731
- $mlw_message_after = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_after);
732
- $mlw_message_after = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message_after);
733
- $mlw_message_after = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_after);
734
- $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
735
- $mlw_display .= $mlw_message_after;
736
- break;
737
- }
738
- else
739
- {
740
- //Check to see if points fall in correct range
741
- if ($mlw_points >= $mlw_each[0] && $mlw_points <= $mlw_each[1])
742
- {
743
- $mlw_message_after = $mlw_each[2];
744
- $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
745
- $mlw_message_after = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_after);
746
- $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
747
- $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
748
- $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
749
- $mlw_message_after = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_after);
750
- $mlw_message_after = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_after);
751
- $mlw_message_after = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_after);
752
- $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
753
- $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
754
- $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
755
- $mlw_message_after = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_after);
756
- $mlw_message_after = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_after);
757
- $mlw_message_after = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message_after);
758
- $mlw_message_after = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_after);
759
- $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
760
- $mlw_display .= $mlw_message_after;
761
- break;
762
- }
763
- //Check to see if score fall in correct range
764
- if ($mlw_total_score >= $mlw_each[0] && $mlw_total_score <= $mlw_each[1])
765
- {
766
- $mlw_message_after = $mlw_each[2];
767
- $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
768
- $mlw_message_after = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_after);
769
- $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
770
- $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
771
- $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
772
- $mlw_message_after = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_after);
773
- $mlw_message_after = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_after);
774
- $mlw_message_after = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_after);
775
- $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
776
- $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
777
- $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
778
- $mlw_message_after = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_after);
779
- $mlw_message_after = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_after);
780
- $mlw_message_after = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message_after);
781
- $mlw_message_after = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_after);
782
- $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
783
- $mlw_display .= $mlw_message_after;
784
- break;
785
- }
786
- }
787
- }
788
- }
789
- else
790
- {
791
- //Prepare the after quiz message
792
- $mlw_message_after = $mlw_quiz_options->message_after;
793
- $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
794
- $mlw_message_after = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_after);
795
- $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
796
- $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
797
- $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
798
- $mlw_message_after = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_after);
799
- $mlw_message_after = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_after);
800
- $mlw_message_after = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_after);
801
- $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
802
- $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
803
- $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
804
- $mlw_message_after = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_after);
805
- $mlw_message_after = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_after);
806
- $mlw_message_after = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message_after);
807
- $mlw_message_after = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_after);
808
- $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
809
- $mlw_display .= $mlw_message_after;
810
- }
811
-
812
- if ($mlw_quiz_options->social_media == 1)
813
- {
814
- $mlw_social_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_quiz_options->social_media_text);
815
- $mlw_social_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_social_message);
816
- $mlw_social_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_social_message);
817
- $mlw_social_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_social_message);
818
- $mlw_social_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_social_message);
819
- $mlw_social_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_social_message);
820
- $mlw_social_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_social_message);
821
- $mlw_social_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_social_message);
822
- $mlw_display .= "<br />
823
- <a href=\"https://twitter.com/share\" data-size=\"large\" data-text=\"".esc_attr($mlw_social_message)."\" class=\"twitter-share-button\" data-lang=\"en\">Tweet</a>
824
- <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=\"https://platform.twitter.com/widgets.js\";fjs.parentNode.insertBefore(js,fjs);}}(document,\"script\",\"twitter-wjs\");</script>
825
- <br />";
826
- }
827
-
828
- //Prepare and send the user email
829
- $mlw_message = "";
830
- if ($mlw_quiz_options->send_user_email == "0")
831
- {
832
- if ($mlw_user_email != "")
833
- {
834
- $mlw_message = $mlw_quiz_options->user_email_template;
835
- $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
836
- $mlw_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message);
837
- $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
838
- $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
839
- $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
840
- $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
841
- $mlw_message = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message);
842
- $mlw_message = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message);
843
- $mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
844
- $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
845
- $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
846
- $mlw_message = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message);
847
- $mlw_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message);
848
- $mlw_message = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message);
849
- $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
850
- $mlw_message = str_replace( "<br />" , "\n", $mlw_message);
851
- $mlw_headers = 'From: '.$mlw_quiz_options->email_from_text.' <'.$mlw_quiz_options->admin_email.'>' . "\r\n";
852
- wp_mail($mlw_user_email, "Quiz Results For ".$mlw_quiz_options->quiz_name, $mlw_message, $mlw_headers);
853
- }
854
- }
855
-
856
- //Prepare and send the admin email
857
- $mlw_message = "";
858
- if ($mlw_quiz_options->send_admin_email == "0")
859
- {
860
- $mlw_message = $mlw_quiz_options->admin_email_template;
861
- $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
862
- $mlw_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message);
863
- $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
864
- $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
865
- $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
866
- $mlw_message = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message);
867
- $mlw_message = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message);
868
- $mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
869
- $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
870
- $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
871
- $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
872
- $mlw_message = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message);
873
- $mlw_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message);
874
- $mlw_message = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message);
875
- $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
876
- $mlw_message .= " This email was generated by the Quiz Master Next script by Frank Corso";
877
- $mlw_message = str_replace( "<br />" , "\n", $mlw_message);
878
- $mlw_headers = 'From: '.$mlw_quiz_options->email_from_text.' <'.$mlw_quiz_options->admin_email.'>' . "\r\n";
879
- wp_mail($mlw_quiz_options->admin_email, "Quiz Results For ".$mlw_quiz_options->quiz_name, $mlw_message, $mlw_headers);
880
- }
881
-
882
- //Save the results into database
883
- $mlw_quiz_results = "Quiz was taken in: ".$mlw_qmn_timer." seconds."."\n".$mlw_question_answers."\n".$mlw_qm_quiz_comments;
884
- $mlw_quiz_results = str_replace( "\n" , "<br>", $mlw_quiz_results);
885
- $mlw_quiz_results = htmlspecialchars($mlw_quiz_results, ENT_QUOTES);
886
- global $wpdb;
887
- $table_name = $wpdb->prefix . "mlw_results";
888
- $insert = "INSERT INTO " . $table_name .
889
- "(result_id, quiz_id, quiz_name, quiz_system, point_score, correct_score, correct, total, name, business, email, phone, time_taken, time_taken_real, quiz_results, deleted) " .
890
- "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")."', '".date("Y-m-d H:i:s")."', '".$mlw_quiz_results."', 0)";
891
- $results = $wpdb->query( $insert );
892
- }
893
- else
894
- {
895
- if (!$mlw_qmn_isAllowed)
896
- {
897
- $mlw_display .= $mlw_quiz_options->total_user_tries_text;
898
- }
899
- else { $mlw_display .= "Thank you."; }
900
- }
901
- }
902
- return $mlw_display;
903
- }
904
-
905
-
906
- /*
907
- This function displays fields to ask for contact information
908
- */
909
- function mlwDisplayContactInfo($mlw_quiz_options)
910
- {
911
- $mlw_contact_display = "";
912
- //Check to see if user is logged in, then ask for contact if not
913
- if ( is_user_logged_in() )
914
- {
915
- //If this quiz does not let user edit contact information we hide this section
916
- if ($mlw_quiz_options->loggedin_user_contact == 1)
917
- {
918
- $mlw_contact_display .= "<div style='display:none;'>";
919
- }
920
-
921
- //Retrieve current user information and save into text fields for contact information
922
- $current_user = wp_get_current_user();
923
- if ($mlw_quiz_options->user_name != 2)
924
- {
925
- $mlw_contact_display .= "<span style='font-weight:bold;';>".$mlw_quiz_options->name_field_text."</span><br />";
926
- $mlw_contact_display .= "<input type='text' x-webkit-speech name='mlwUserName' value='".$current_user->display_name."' />";
927
- $mlw_contact_display .= "<br /><br />";
928
-
929
- }
930
- if ($mlw_quiz_options->user_comp != 2)
931
- {
932
- $mlw_contact_display .= "<span style='font-weight:bold;';>".$mlw_quiz_options->business_field_text."</span><br />";
933
- $mlw_contact_display .= "<input type='text' x-webkit-speech name='mlwUserComp' value='' />";
934
- $mlw_contact_display .= "<br /><br />";
935
- }
936
- if ($mlw_quiz_options->user_email != 2)
937
- {
938
- $mlw_contact_display .= "<span style='font-weight:bold;';>".$mlw_quiz_options->email_field_text."</span><br />";
939
- $mlw_contact_display .= "<input type='text' x-webkit-speech name='mlwUserEmail' value='".$current_user->user_email."' />";
940
- $mlw_contact_display .= "<br /><br />";
941
- }
942
- if ($mlw_quiz_options->user_phone != 2)
943
- {
944
- $mlw_contact_display .= "<span style='font-weight:bold;';>".$mlw_quiz_options->phone_field_text."</span><br />";
945
- $mlw_contact_display .= "<input type='text' x-webkit-speech name='mlwUserPhone' value='' />";
946
- $mlw_contact_display .= "<br /><br />";
947
- }
948
-
949
- //End of hidden section div
950
- if ($mlw_quiz_options->loggedin_user_contact == 1)
951
- {
952
- $mlw_contact_display .= "</div>";
953
- }
954
- }
955
- else
956
- {
957
- //See if the site wants to ask for any contact information, then ask for it
958
- if ($mlw_quiz_options->user_name != 2)
959
- {
960
- $mlw_contact_display .= "<span style='font-weight:bold;';>".$mlw_quiz_options->name_field_text."</span><br />";
961
- $mlw_contact_display .= "<input type='text' x-webkit-speech name='mlwUserName' value='' />";
962
- $mlw_contact_display .= "<br /><br />";
963
- }
964
- if ($mlw_quiz_options->user_comp != 2)
965
- {
966
- $mlw_contact_display .= "<span style='font-weight:bold;';>".$mlw_quiz_options->business_field_text."</span><br />";
967
- $mlw_contact_display .= "<input type='text' x-webkit-speech name='mlwUserComp' value='' />";
968
- $mlw_contact_display .= "<br /><br />";
969
- }
970
- if ($mlw_quiz_options->user_email != 2)
971
- {
972
- $mlw_contact_display .= "<span style='font-weight:bold;';>".$mlw_quiz_options->email_field_text."</span><br />";
973
- $mlw_contact_display .= "<input type='text' x-webkit-speech name='mlwUserEmail' value='' />";
974
- $mlw_contact_display .= "<br /><br />";
975
- }
976
- if ($mlw_quiz_options->user_phone != 2)
977
- {
978
- $mlw_contact_display .= "<span style='font-weight:bold;';>".$mlw_quiz_options->phone_field_text."</span><br />";
979
- $mlw_contact_display .= "<input type='text' x-webkit-speech name='mlwUserPhone' value='' />";
980
- $mlw_contact_display .= "<br /><br />";
981
- }
982
- }
983
- return $mlw_contact_display;
984
- }
 
 
 
 
 
 
 
985
  ?>
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
+
13
+ /*
14
+ Code before loading the quiz
15
+ */
16
+
17
+ //Variables needed throughout script
18
+ $mlw_quiz_id = $quiz;
19
+ $mlw_display = "";
20
+ global $wpdb;
21
+ $mlw_qmn_isAllowed = true;
22
+ $mlw_qmn_section_count = 1;
23
+ $mlw_qmn_section_limit = 0;
24
+
25
+
26
+ //Load quiz
27
+ $sql = "SELECT * FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=".$mlw_quiz_id." AND deleted='0'";
28
+ $mlw_quiz_options = $wpdb->get_results($sql);
29
+
30
+ foreach($mlw_quiz_options as $mlw_eaches) {
31
+ $mlw_quiz_options = $mlw_eaches;
32
+ break;
33
+ }
34
+
35
+ //Check to see if there is limit on the amount of tries
36
+ if ( $mlw_quiz_options->total_user_tries != 0 && is_user_logged_in() )
37
+ {
38
+ $current_user = wp_get_current_user();
39
+ $mlw_qmn_user_try_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_results WHERE email='%s' AND deleted='0' AND quiz_id=%d", $current_user->user_email, $mlw_quiz_id ) );
40
+ if ($mlw_qmn_user_try_count >= $mlw_quiz_options->total_user_tries) { $mlw_qmn_isAllowed = false; }
41
+ }
42
+
43
+
44
+ //Load questions
45
+ $sql = "SELECT * FROM " . $wpdb->prefix . "mlw_questions" . " WHERE quiz_id=".$mlw_quiz_id." AND deleted='0' ";
46
+ if ($mlw_quiz_options->randomness_order == 0)
47
+ {
48
+ $sql .= "ORDER BY question_order ASC";
49
+ }
50
+ if ($mlw_quiz_options->randomness_order == 1)
51
+ {
52
+ $sql .= "ORDER BY rand()";
53
+ }
54
+ if ($mlw_quiz_options->question_from_total != 0)
55
+ {
56
+ $sql .= " LIMIT ".$mlw_quiz_options->question_from_total;
57
+ }
58
+ $mlw_questions = $wpdb->get_results($sql);
59
+
60
+
61
+ //Variables to load if quiz has been taken
62
+ if (isset($_POST["complete_quiz"]) && $_POST["complete_quiz"] == "confirmation")
63
+ {
64
+ $mlw_success = $_POST["complete_quiz"];
65
+ $mlw_user_name = isset($_POST["mlwUserName"]) ? $_POST["mlwUserName"] : 'None';
66
+ $mlw_user_comp = isset($_POST["mlwUserComp"]) ? $_POST["mlwUserComp"] : 'None';
67
+ $mlw_user_email = isset($_POST["mlwUserEmail"]) ? $_POST["mlwUserEmail"] : 'None';
68
+ $mlw_user_phone = isset($_POST["mlwUserPhone"]) ? $_POST["mlwUserPhone"] : 'None';
69
+ $mlw_qmn_timer = isset($_POST["timer"]) ? $_POST["timer"] : 0;
70
+ $mlw_spam_email = $_POST["email"];
71
+ }
72
+
73
+ wp_enqueue_script( 'jquery' );
74
+ wp_enqueue_script( 'jquery-ui-core' );
75
+ wp_enqueue_script( 'jquery-effects-core' );
76
+ wp_enqueue_script( 'jquery-effects-slide' );
77
+ wp_enqueue_script( 'jquery-ui-dialog' );
78
+ wp_enqueue_script( 'jquery-ui-button' );
79
+ wp_enqueue_script( 'jquery-ui-accordion' );
80
+ wp_enqueue_script( 'jquery-ui-tooltip' );
81
+ wp_enqueue_script( 'jquery-ui-tabs' );
82
+ ?>
83
+ <!-- css -->
84
+ <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
85
+ <script type="text/javascript">
86
+ var $j = jQuery.noConflict();
87
+ // increase the default animation speed to exaggerate the effect
88
+ $j.fx.speeds._default = 1000;
89
+ $j(function() {
90
+ $j( document ).tooltip();
91
+ });
92
+ </script>
93
+ <style type="text/css">
94
+ .ui-tooltip
95
+ {
96
+ /* tooltip container box */
97
+ max-width: 500px !important;
98
+ }
99
+ .ui-tooltip-content
100
+ {
101
+ /* tooltip content */
102
+ max-width: 500px !important;
103
+ }
104
+ </style>
105
+ <?php
106
+
107
+ /*
108
+ The following code is for displaying the quiz and completion screen
109
+ */
110
+
111
+ //If there is no quiz for the shortcode provided
112
+ if ($mlw_quiz_options->quiz_name == "")
113
+ {
114
+ $mlw_display .= "It appears that this quiz is not set up correctly.";
115
+ return $mlw_display;
116
+ }
117
+
118
+ //Display Quiz
119
+ if (!isset($_POST["complete_quiz"]) && $mlw_quiz_options->quiz_name != "" && $mlw_qmn_isAllowed)
120
+ {
121
+ $mlw_qmn_total_questions = 0;
122
+ //Calculate number of pages if pagination is turned on
123
+ if ($mlw_quiz_options->pagination != 0)
124
+ {
125
+ $mlw_qmn_section_limit = 2 + $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_questions WHERE quiz_id=%d AND deleted=0", $mlw_quiz_id ) );
126
+ if ($mlw_quiz_options->comment_section == 0)
127
+ {
128
+ $mlw_qmn_section_limit = $mlw_qmn_section_limit + 1;
129
+ }
130
+
131
+ //Gather text for pagination buttons
132
+ $mlw_qmn_pagination_text = "";
133
+ $mlw_qmn_pagination_text = @unserialize($mlw_quiz_options->pagination_text);
134
+ if (!is_array($mlw_qmn_pagination_text)) {
135
+ $mlw_qmn_pagination_text = array('Previous', $mlw_quiz_options->pagination_text);
136
+ }
137
+ ?>
138
+ <script type="text/javascript">
139
+ var $j = jQuery.noConflict();
140
+ $j(function() {
141
+ $j( ".quiz_section" ).hide();
142
+ $j( ".quiz_section" ).append( "<br />" );
143
+ $j( ".quiz_section" ).not( ".quiz_begin" ).append( "<a class=\"mlw_qmn_quiz_link\" href='#' onclick=\"prevSlide();\"><?php echo $mlw_qmn_pagination_text[0]; ?></a>" );
144
+ $j( ".quiz_section" ).not( ".quiz_end" ).append( "<a class=\"mlw_qmn_quiz_link\" href='#' onclick=\"nextSlide();\"><?php echo $mlw_qmn_pagination_text[1]; ?></a>" );
145
+ window.mlw_quiz_slide = 0;
146
+ window.mlw_quiz_total_slides = <?php echo $mlw_qmn_section_limit; ?>;
147
+ nextSlide();
148
+ });
149
+ function nextSlide()
150
+ {
151
+ window.mlw_quiz_slide++;
152
+ if (window.mlw_quiz_slide == window.mlw_quiz_total_slides)
153
+ {
154
+ $j(".quiz_link").html("Submit");
155
+ }
156
+ if (window.mlw_quiz_slide > window.mlw_quiz_total_slides)
157
+ {
158
+ document.quizForm.submit();
159
+ exit();
160
+ }
161
+ y = window.mlw_quiz_slide-1;
162
+ $j( ".quiz_section.slide"+y ).hide();
163
+ $j( ".quiz_section.slide"+window.mlw_quiz_slide ).show( "slide", {direction: "right"}, 300 );
164
+
165
+ }
166
+ function prevSlide()
167
+ {
168
+ window.mlw_quiz_slide--;
169
+ if (window.mlw_quiz_slide == window.mlw_quiz_total_slides)
170
+ {
171
+ $j(".quiz_link").html("Submit");
172
+ }
173
+ if (window.mlw_quiz_slide > window.mlw_quiz_total_slides)
174
+ {
175
+ document.quizForm.submit();
176
+ exit();
177
+ }
178
+ y = window.mlw_quiz_slide+1;
179
+ $j( ".quiz_section.slide"+y ).hide();
180
+ $j( ".quiz_section.slide"+window.mlw_quiz_slide ).show( "slide", {direction: "left"}, 300 );
181
+ }
182
+ </script>
183
+ <style type="text/css">
184
+ a.mlw_qmn_quiz_link
185
+ {
186
+ border-radius: 4px;
187
+ position: relative;
188
+ background-image: linear-gradient(#fff,#dedede);
189
+ background-color: #eee;
190
+ border: #ccc solid 1px;
191
+ color: #333;
192
+ text-shadow: 0 1px 0 rgba(255,255,255,.5);
193
+ box-sizing: border-box;
194
+ display: inline-block;
195
+ padding: 5px 5px 5px 5px;
196
+ margin: auto;
197
+ }
198
+ </style>
199
+ <?php
200
+ }
201
+ if ($mlw_quiz_options->timer_limit != 0)
202
+ {
203
+ ?>
204
+ <div id="mlw_qmn_timer"></div>
205
+ <script type="text/javascript">
206
+ var minutes = <?php echo $mlw_quiz_options->timer_limit; ?>;
207
+ window.amount = (minutes*60);
208
+ window.titleText = window.document.title;
209
+ document.getElementById("mlw_qmn_timer").innerHTML = minToSec(window.amount);
210
+ window.counter=setInterval(timer, 1000); //1000 will run it every 1 second
211
+ function timer()
212
+ {
213
+ window.amount=window.amount-1;
214
+ document.getElementById("mlw_qmn_timer").innerHTML = minToSec(window.amount);
215
+ window.document.title = minToSec(window.amount) + " " + window.titleText;
216
+ if (window.amount <= 0)
217
+ {
218
+ clearInterval(window.counter);
219
+ document.quizForm.submit();
220
+ return;
221
+ }
222
+ }
223
+ function minToSec(amount)
224
+ {
225
+ var minutes = Math.floor(amount/60);
226
+ var seconds = amount - (minutes * 60);
227
+ if (seconds == '0')
228
+ {
229
+ seconds = "00";
230
+ }
231
+ else if (seconds < 10)
232
+ {
233
+ seconds = '0' + seconds;
234
+ }
235
+ return minutes+":"+seconds;
236
+ }
237
+ </script>
238
+ <style type="text/css">
239
+ #mlw_qmn_timer {
240
+ position:fixed;
241
+ top:200px;
242
+ right:0px;
243
+ width:130px;
244
+ color:#00CCFF;
245
+ border-radius: 15px;
246
+ background:#000000;
247
+ text-align: center;
248
+ padding: 15px 15px 15px 15px
249
+ }
250
+ </style>
251
+ <?php
252
+ }
253
+
254
+ ?>
255
+ <script type="text/javascript">
256
+ var myVar=setInterval("mlwQmnTimer();",1000);
257
+ function mlwQmnTimer()
258
+ {
259
+ var x = +document.getElementById("timer").value;
260
+ x = x + 1;
261
+ document.getElementById("timer").value = x;
262
+ }
263
+
264
+ </script>
265
+ <style type="text/css">
266
+ div.mlw_qmn_quiz input[type=radio],
267
+ div.mlw_qmn_quiz input[type=submit],
268
+ div.mlw_qmn_quiz label {
269
+ cursor: pointer;
270
+ }
271
+ div.mlw_qmn_quiz input:not([type=submit]):focus,
272
+ div.mlw_qmn_quiz textarea:focus {
273
+ background: #eaeaea;
274
+ }
275
+ div.mlw_qmn_quiz_section
276
+ {
277
+
278
+ }
279
+ </style>
280
+ <?
281
+ //Update the quiz views
282
+ $mlw_views = $mlw_quiz_options->quiz_views;
283
+ $mlw_views += 1;
284
+ $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET quiz_views='".$mlw_views."' WHERE quiz_id=".$mlw_quiz_id;
285
+ $results = $wpdb->query( $update );
286
+
287
+ //Form validation script
288
+ $mlw_display .= "
289
+ <script>
290
+ function clear_field(field)
291
+ {
292
+ if (field.defaultValue == field.value) field.value = '';
293
+ }
294
+
295
+ function mlw_validateForm()
296
+ {
297
+ ";
298
+ if ($mlw_quiz_options->user_name == 1)
299
+ {
300
+ $mlw_display .= "
301
+ var x=document.forms['quizForm']['mlwUserName'].value;
302
+ if (x==null || x=='')
303
+ {
304
+ document.getElementById('mlw_error_message').innerHTML = '**Name must be filled out!**';
305
+ document.getElementById('mlw_error_message_bottom').innerHTML = '**Name must be filled out!**';
306
+ return false;
307
+ }";
308
+ }
309
+ if ($mlw_quiz_options->user_comp == 1)
310
+ {
311
+ $mlw_display .= "
312
+ var x=document.forms['quizForm']['mlwUserComp'].value;
313
+ if (x==null || x=='')
314
+ {
315
+ document.getElementById('mlw_error_message').innerHTML = '**Business must be filled out!**';
316
+ document.getElementById('mlw_error_message_bottom').innerHTML = '**Business must be filled out!**';
317
+ return false;
318
+ }";
319
+ }
320
+ if ($mlw_quiz_options->user_email == 1)
321
+ {
322
+ $mlw_display .= "
323
+ var x=document.forms['quizForm']['mlwUserEmail'].value;
324
+ if (x==null || x=='')
325
+ {
326
+ document.getElementById('mlw_error_message').innerHTML = '**Email must be filled out!**';
327
+ document.getElementById('mlw_error_message_bottom').innerHTML = '**Email must be filled out!**';
328
+ return false;
329
+ }";
330
+ }
331
+ if ($mlw_quiz_options->user_phone == 1)
332
+ {
333
+ $mlw_display .= "
334
+ var x=document.forms['quizForm']['mlwUserPhone'].value;
335
+ if (x==null || x=='')
336
+ {
337
+ document.getElementById('mlw_error_message').innerHTML = '**Phone number must be filled out!**';
338
+ document.getElementById('mlw_error_message_bottom').innerHTML = '**Phone number must be filled out!**';
339
+ return false;
340
+ }";
341
+ }
342
+ $mlw_display .= "
343
+ if (document.forms['quizForm']['mlwUserEmail'].defaultValue != document.forms['quizForm']['mlwUserEmail'].value)
344
+ {
345
+ var x=document.forms['quizForm']['mlwUserEmail'].value;
346
+ var atpos=x.indexOf('@');
347
+ var dotpos=x.lastIndexOf('.');
348
+ if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
349
+ {
350
+ document.getElementById('mlw_error_message').innerHTML = '**Not a valid e-mail address!**';
351
+ document.getElementById('mlw_error_message_bottom').innerHTML = '**Not a valid e-mail address!**';
352
+ return false;
353
+ }
354
+ }
355
+ }
356
+ </script>";
357
+
358
+ //Begin the quiz
359
+ $mlw_display .= "<div class='mlw_qmn_quiz'>";
360
+ $mlw_display .= "<form name='quizForm' action='' method='post' class='mlw_quiz_form' onsubmit='return mlw_validateForm()' >";
361
+ $mlw_display .= "<div class='quiz_section quiz_begin slide".$mlw_qmn_section_count."'>";
362
+ $mlw_message_before = $mlw_quiz_options->message_before;
363
+ $mlw_message_before = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_before);
364
+ $mlw_message_before = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_before);
365
+ $mlw_display .= "<span>".$mlw_message_before."</span><br />";
366
+ $mlw_display .= "<span name='mlw_error_message' id='mlw_error_message' style='color: red;'></span><br />";
367
+
368
+ if ($mlw_quiz_options->contact_info_location == 0)
369
+ {
370
+ $mlw_display .= mlwDisplayContactInfo($mlw_quiz_options);
371
+ }
372
+ $mlw_display .= "</div>";
373
+
374
+ //Display the questions
375
+ foreach($mlw_questions as $mlw_question) {
376
+ $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
377
+ $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
378
+ $mlw_display .= "<div class='quiz_section slide".$mlw_qmn_section_count."'>";
379
+ $mlw_display .= "<span style='font-weight:bold;'>".htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
380
+ if ($mlw_question->question_type == 0)
381
+ {
382
+ if ($mlw_question->answer_one != "")
383
+ {
384
+ $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_one' value='1' /> <label for='question".$mlw_question->question_id."_one'>".htmlspecialchars_decode($mlw_question->answer_one, ENT_QUOTES)."</label>";
385
+ $mlw_display .= "<br />";
386
+ }
387
+ if ($mlw_question->answer_two != "")
388
+ {
389
+ $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_two' value='2' /> <label for='question".$mlw_question->question_id."_two'>".htmlspecialchars_decode($mlw_question->answer_two, ENT_QUOTES)."</label>";
390
+ $mlw_display .= "<br />";
391
+ }
392
+ if ($mlw_question->answer_three != "")
393
+ {
394
+ $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_three' value='3' /> <label for='question".$mlw_question->question_id."_three'>".htmlspecialchars_decode($mlw_question->answer_three, ENT_QUOTES)."</label>";
395
+ $mlw_display .= "<br />";
396
+ }
397
+ if ($mlw_question->answer_four != "")
398
+ {
399
+ $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_four' value='4' /> <label for='question".$mlw_question->question_id."_four'>".htmlspecialchars_decode($mlw_question->answer_four, ENT_QUOTES)."</label>";
400
+ $mlw_display .= "<br />";
401
+ }
402
+ if ($mlw_question->answer_five != "")
403
+ {
404
+ $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_five' value='5' /> <label for='question".$mlw_question->question_id."_five'>".htmlspecialchars_decode($mlw_question->answer_five, ENT_QUOTES)."</label>";
405
+ $mlw_display .= "<br />";
406
+ }
407
+ if ($mlw_question->answer_six != "")
408
+ {
409
+ $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_six' value='6' /> <label for='question".$mlw_question->question_id."_six'>".htmlspecialchars_decode($mlw_question->answer_six, ENT_QUOTES)."</label>";
410
+ $mlw_display .= "<br />";
411
+ }
412
+ }
413
+ elseif ($mlw_question->question_type == 1)
414
+ {
415
+ if ($mlw_question->answer_one != "")
416
+ {
417
+ $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' value='1' />".htmlspecialchars_decode($mlw_question->answer_one, ENT_QUOTES);
418
+ }
419
+ if ($mlw_question->answer_two != "")
420
+ {
421
+ $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' value='2' />".htmlspecialchars_decode($mlw_question->answer_two, ENT_QUOTES);
422
+ }
423
+ if ($mlw_question->answer_three != "")
424
+ {
425
+ $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' value='3' />".htmlspecialchars_decode($mlw_question->answer_three, ENT_QUOTES);
426
+ }
427
+ if ($mlw_question->answer_four != "")
428
+ {
429
+ $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' value='4' />".htmlspecialchars_decode($mlw_question->answer_four, ENT_QUOTES);
430
+ }
431
+ if ($mlw_question->answer_five != "")
432
+ {
433
+ $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' value='5' />".htmlspecialchars_decode($mlw_question->answer_five, ENT_QUOTES);
434
+ }
435
+ if ($mlw_question->answer_six != "")
436
+ {
437
+ $mlw_display .= "<input type='radio' required name='question".$mlw_question->question_id."' value='6' />".htmlspecialchars_decode($mlw_question->answer_six, ENT_QUOTES);
438
+ }
439
+ $mlw_display .= "<br />";
440
+ }
441
+ else
442
+ {
443
+ $mlw_display .= "<select required name='question".$mlw_question->question_id."'>";
444
+ if ($mlw_question->answer_one != "")
445
+ {
446
+ $mlw_display .= "<option value='1'>".htmlspecialchars_decode($mlw_question->answer_one, ENT_QUOTES)."</option>";
447
+ }
448
+ if ($mlw_question->answer_two != "")
449
+ {
450
+ $mlw_display .= "<option value='2'>".htmlspecialchars_decode($mlw_question->answer_two, ENT_QUOTES)."</option>";
451
+ }
452
+ if ($mlw_question->answer_three != "")
453
+ {
454
+ $mlw_display .= "<option value='3'>".htmlspecialchars_decode($mlw_question->answer_three, ENT_QUOTES)."</option>";
455
+ }
456
+ if ($mlw_question->answer_four != "")
457
+ {
458
+ $mlw_display .= "<option value='4'>".htmlspecialchars_decode($mlw_question->answer_four, ENT_QUOTES)."</option>";
459
+ }
460
+ if ($mlw_question->answer_five != "")
461
+ {
462
+ $mlw_display .= "<option value='5'>".htmlspecialchars_decode($mlw_question->answer_five, ENT_QUOTES)."</option>";
463
+ }
464
+ if ($mlw_question->answer_six != "")
465
+ {
466
+ $mlw_display .= "<option value='6'>".htmlspecialchars_decode($mlw_question->answer_six, ENT_QUOTES)."</option>";
467
+ }
468
+ $mlw_display .= "</select>";
469
+ $mlw_display .= "<br />";
470
+ }
471
+ if ($mlw_question->comments == 0)
472
+ {
473
+ $mlw_display .= "<input type='text' x-webkit-speech id='mlwComment".$mlw_question->question_id."' name='mlwComment".$mlw_question->question_id."' value='".$mlw_quiz_options->comment_field_text."' onclick='clear_field(this)'/>";
474
+ $mlw_display .= "<br />";
475
+ }
476
+ if ($mlw_question->comments == 2)
477
+ {
478
+ $mlw_display .= "<textarea cols='70' rows='5' id='mlwComment".$mlw_question->question_id."' name='mlwComment".$mlw_question->question_id."' onclick='clear_field(this)'>".$mlw_quiz_options->comment_field_text."</textarea>";
479
+ $mlw_display .= "<br />";
480
+ }
481
+ if ($mlw_question->hints != "")
482
+ {
483
+ $mlw_display .= "<span title=\"".htmlspecialchars_decode($mlw_question->hints, ENT_QUOTES)."\" style=\"text-decoration:underline;color:rgb(0,0,255);\">Hint</span>";
484
+ $mlw_display .= "<br /><br />";
485
+ }
486
+ $mlw_display .= "</div>";
487
+ if ( $mlw_quiz_options->pagination == 0) { $mlw_display .= "<br />"; }
488
+ }
489
+
490
+ //Display comment box if needed
491
+ if ($mlw_quiz_options->comment_section == 0)
492
+ {
493
+ $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
494
+ $mlw_display .= "<div class='quiz_section slide".$mlw_qmn_section_count."'>";
495
+ $mlw_message_comments = $mlw_quiz_options->message_comment;
496
+ $mlw_message_comments = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_comments);
497
+ $mlw_message_comments = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_comments);
498
+ $mlw_display .= "<label for='mlwQuizComments' style='font-weight:bold;'>".$mlw_message_comments."</label><br />";
499
+ $mlw_display .= "<textarea cols='70' rows='15' id='mlwQuizComments' name='mlwQuizComments' ></textarea>";
500
+ $mlw_display .= "</div>";
501
+ if ( $mlw_quiz_options->pagination == 0) { $mlw_display .= "<br /><br />"; }
502
+ }
503
+ $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
504
+ $mlw_display .= "<div class='quiz_section slide".$mlw_qmn_section_count." quiz_end'>";
505
+ if ($mlw_quiz_options->message_end_template != '')
506
+ {
507
+ $mlw_message_end = $mlw_quiz_options->message_end_template;
508
+ $mlw_message_end = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_end);
509
+ $mlw_message_end = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_end);
510
+ $mlw_display .= "<span>".$mlw_message_end."</span>";
511
+ $mlw_display .= "<br /><br />";
512
+ }
513
+ if ($mlw_quiz_options->contact_info_location == 1)
514
+ {
515
+ $mlw_display .= mlwDisplayContactInfo($mlw_quiz_options);
516
+ }
517
+ $mlw_display .= "<span style='display: none;'>If you are human, leave this field blank or you will be considered spam:</span>";
518
+ $mlw_display .= "<input style='display: none;' type='text' name='email' id='email' />";
519
+ $mlw_display .= "<input type='hidden' name='total_questions' id='total_questions' value='".$mlw_qmn_total_questions."'/>";
520
+ $mlw_display .= "<input type='hidden' name='timer' id='timer' value='0'/>";
521
+ $mlw_display .= "<input type='hidden' name='complete_quiz' value='confirmation' />";
522
+ $mlw_display .= "<input type='submit' value='".$mlw_quiz_options->submit_button_text."' />";
523
+ $mlw_display .= "<span name='mlw_error_message_bottom' id='mlw_error_message_bottom' style='color: red;'></span><br />";
524
+ $mlw_display .= "</form>";
525
+ $mlw_display .= "</div>";
526
+ $mlw_display .= "</div>";
527
+
528
+ }
529
+ //Display Completion Screen
530
+ else
531
+ {
532
+ if (empty($mlw_spam_email) && $mlw_qmn_isAllowed)
533
+ {
534
+
535
+ //Load questions
536
+ $sql = "SELECT * FROM " . $wpdb->prefix . "mlw_questions" . " WHERE quiz_id=".$mlw_quiz_id." AND deleted='0' ";
537
+ if ($mlw_quiz_options->randomness_order == 0)
538
+ {
539
+ $sql .= "ORDER BY question_order ASC";
540
+ }
541
+ if ($mlw_quiz_options->randomness_order == 1)
542
+ {
543
+ $sql .= "ORDER BY rand()";
544
+ }
545
+ $mlw_questions = $wpdb->get_results($sql);
546
+
547
+ //Variables needed for scoring
548
+ $mlw_points = 0;
549
+ $mlw_correct = 0;
550
+ $mlw_total_questions = 0;
551
+ $mlw_total_score = 0;
552
+ $mlw_question_answers = "";
553
+ isset($_POST["total_questions"]) ? $mlw_total_questions = intval($_POST["total_questions"]) : $mlw_total_questions = 0;
554
+
555
+ //Update the amount of times the quiz has been taken
556
+ $mlw_taken = $mlw_quiz_options->quiz_taken;
557
+ $mlw_taken += 1;
558
+ $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET quiz_taken='".$mlw_taken."' WHERE quiz_id=".$mlw_quiz_id;
559
+ $results = $wpdb->query( $update );
560
+
561
+ //See which answers were correct and award points if necessary
562
+ foreach($mlw_questions as $mlw_question) {
563
+ if (isset($_POST["question".$mlw_question->question_id]) || isset($_POST["mlwComment".$mlw_question->question_id]))
564
+ {
565
+ $mlw_user_text;
566
+ $mlw_correct_text;
567
+ //$mlw_total_questions += 1;
568
+ if (isset($_POST["question".$mlw_question->question_id]))
569
+ {
570
+ $mlw_user_answer = $_POST["question".$mlw_question->question_id];
571
+ if ($mlw_user_answer == $mlw_question->correct_answer)
572
+ {
573
+ $mlw_correct += 1;
574
+ }
575
+ if ($mlw_user_answer == 1)
576
+ {
577
+ $mlw_points += $mlw_question->answer_one_points;
578
+ $mlw_user_text = $mlw_question->answer_one;
579
+ }
580
+ if ($mlw_user_answer == 2)
581
+ {
582
+ $mlw_points += $mlw_question->answer_two_points;
583
+ $mlw_user_text = $mlw_question->answer_two;
584
+ }
585
+ if ($mlw_user_answer == 3)
586
+ {
587
+ $mlw_points += $mlw_question->answer_three_points;
588
+ $mlw_user_text = $mlw_question->answer_three;
589
+ }
590
+ if ($mlw_user_answer == 4)
591
+ {
592
+ $mlw_points += $mlw_question->answer_four_points;
593
+ $mlw_user_text = $mlw_question->answer_four;
594
+ }
595
+ if ($mlw_user_answer == 5)
596
+ {
597
+ $mlw_points += $mlw_question->answer_five_points;
598
+ $mlw_user_text = $mlw_question->answer_five;
599
+ }
600
+ if ($mlw_user_answer == 6)
601
+ {
602
+ $mlw_points += $mlw_question->answer_six_points;
603
+ $mlw_user_text = $mlw_question->answer_six;
604
+ }
605
+
606
+ if ($mlw_question->correct_answer == 1) {$mlw_correct_text = $mlw_question->answer_one;}
607
+ if ($mlw_question->correct_answer == 2) {$mlw_correct_text = $mlw_question->answer_two;}
608
+ if ($mlw_question->correct_answer == 3) {$mlw_correct_text = $mlw_question->answer_three;}
609
+ if ($mlw_question->correct_answer == 4) {$mlw_correct_text = $mlw_question->answer_four;}
610
+ if ($mlw_question->correct_answer == 5) {$mlw_correct_text = $mlw_question->answer_five;}
611
+ if ($mlw_question->correct_answer == 6) {$mlw_correct_text = $mlw_question->answer_six;}
612
+ }
613
+ if (isset($_POST["mlwComment".$mlw_question->question_id]))
614
+ {
615
+ $mlw_qm_question_comment = $_POST["mlwComment".$mlw_question->question_id];
616
+ }
617
+ else
618
+ {
619
+ $mlw_qm_question_comment = "";
620
+ }
621
+
622
+ $mlw_question_answer_display = $mlw_quiz_options->question_answer_template;
623
+ $mlw_question_answer_display = str_replace( "%QUESTION%" , htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES), $mlw_question_answer_display);
624
+ $mlw_question_answer_display = str_replace( "%USER_ANSWER%" , $mlw_user_text, $mlw_question_answer_display);
625
+ $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER%" , $mlw_correct_text, $mlw_question_answer_display);
626
+ $mlw_question_answer_display = str_replace( "%USER_COMMENTS%" , $mlw_qm_question_comment, $mlw_question_answer_display);
627
+ $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER_INFO%" , htmlspecialchars_decode($mlw_question->question_answer_info), $mlw_question_answer_display);
628
+
629
+ $mlw_question_answers .= $mlw_question_answer_display;
630
+ $mlw_question_answers .= "<br />";
631
+ }
632
+ }
633
+
634
+ //Calculate Total Percent Score And Average Points Only If Total Questions Doesn't Equal Zero To Avoid Division By Zero Error
635
+ if ($mlw_total_questions != 0)
636
+ {
637
+ $mlw_total_score = round((($mlw_correct/$mlw_total_questions)*100), 2);
638
+ $mlw_average_points = round(($mlw_points/$mlw_total_questions), 2);
639
+ }
640
+ else
641
+ {
642
+ $mlw_total_score = 0;
643
+ $mlw_average_points = 0;
644
+ }
645
+
646
+ //Prepare comment section if set
647
+ if (isset($_POST["mlwQuizComments"]))
648
+ {
649
+ $mlw_qm_quiz_comments = $_POST["mlwQuizComments"];
650
+ }
651
+ else
652
+ {
653
+ $mlw_qm_quiz_comments = "";
654
+ }
655
+
656
+
657
+ //Prepare Certificate
658
+ $mlw_certificate_link = "";
659
+ $mlw_certificate_options = unserialize($mlw_quiz_options->certificate_template);
660
+ if (!is_array($mlw_certificate_options)) {
661
+ // something went wrong, initialize to empty array
662
+ $mlw_certificate_options = array('Enter title here', 'Enter text here', '', '', 1);
663
+ }
664
+ if ($mlw_certificate_options[4] == 0)
665
+ {
666
+ $mlw_message_certificate = $mlw_certificate_options[1];
667
+ $mlw_message_certificate = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_certificate);
668
+ $mlw_message_certificate = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_certificate);
669
+ $mlw_message_certificate = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_certificate);
670
+ $mlw_message_certificate = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_certificate);
671
+ $mlw_message_certificate = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_certificate);
672
+ $mlw_message_certificate = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_certificate);
673
+ $mlw_message_certificate = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_certificate);
674
+ $mlw_message_certificate = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_certificate);
675
+ $mlw_message_certificate = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_certificate);
676
+ $mlw_message_certificate = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_certificate);
677
+ $mlw_message_certificate = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_certificate);
678
+ $mlw_message_certificate = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_certificate);
679
+ $mlw_message_certificate = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_certificate);
680
+ $mlw_message_certificate = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_certificate);
681
+ $mlw_message_certificate = str_replace( "\n" , "<br>", $mlw_message_certificate);
682
+ $mlw_plugindirpath = plugin_dir_path( __FILE__ );
683
+ $plugindirpath=plugin_dir_path( __FILE__ );
684
+ $mlw_qmn_certificate_file=<<<EOC
685
+ <?php
686
+ include("$plugindirpath/WriteHTML.php");
687
+ \$pdf=new PDF_HTML();
688
+ \$pdf->AddPage('L');
689
+ EOC;
690
+ $mlw_qmn_certificate_file.=$mlw_certificate_options[3] != '' ? '$pdf->Image("'.$mlw_certificate_options[3].'",0,0,$pdf->w, $pdf->h);' : '';
691
+ $mlw_qmn_certificate_file.=<<<EOC
692
+ \$pdf->Ln(20);
693
+ \$pdf->SetFont('Arial','B',24);
694
+ \$pdf->MultiCell(280,20,'$mlw_certificate_options[0]',0,'C');
695
+ \$pdf->Ln(15);
696
+ \$pdf->SetFont('Arial','',16);
697
+ \$pdf->WriteHTML("<p align='center'>$mlw_message_certificate</p>");
698
+ EOC;
699
+ $mlw_qmn_certificate_file.=$mlw_certificate_options[2] != '' ? '$pdf->Image("'.$mlw_certificate_options[2].'",110,130);' : '';
700
+ $mlw_qmn_certificate_file.=<<<EOC
701
+ \$pdf->Output('mlw_qmn_certificate.pdf','D');
702
+ unlink(__FILE__);
703
+ EOC;
704
+ $mlw_qmn_certificate_filename = str_replace(home_url()."/", '', plugin_dir_url( __FILE__ ))."certificates/mlw_qmn_quiz".date("YmdHis").$mlw_qmn_timer.".php";
705
+ file_put_contents($mlw_qmn_certificate_filename, $mlw_qmn_certificate_file);
706
+ $mlw_qmn_certificate_filename = plugin_dir_url( __FILE__ )."certificates/mlw_qmn_quiz".date("YmdHis").$mlw_qmn_timer.".php";
707
+ $mlw_certificate_link = "<a href='".$mlw_qmn_certificate_filename."' style='color: blue;'>Download Certificate</a>";
708
+ }
709
+
710
+ /*
711
+ Prepare the landing page
712
+ -First, unserialize message_after column
713
+ -Second, check for array in case user has not updated
714
+ Message array = (array( bottomvalue, topvalue, text),array( bottomvalue, topvalue, text), etc..., array(0,0,text))
715
+ */
716
+ $mlw_message_after_array = @unserialize($mlw_quiz_options->message_after);
717
+ if (is_array($mlw_message_after_array))
718
+ {
719
+ //Cycle through landing pages
720
+ foreach($mlw_message_after_array as $mlw_each)
721
+ {
722
+ //Check to see if default
723
+ if ($mlw_each[0] == 0 && $mlw_each[1] == 0)
724
+ {
725
+ $mlw_message_after = $mlw_each[2];
726
+ $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
727
+ $mlw_message_after = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_after);
728
+ $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
729
+ $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
730
+ $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
731
+ $mlw_message_after = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_after);
732
+ $mlw_message_after = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_after);
733
+ $mlw_message_after = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_after);
734
+ $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
735
+ $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
736
+ $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
737
+ $mlw_message_after = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_after);
738
+ $mlw_message_after = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_after);
739
+ $mlw_message_after = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message_after);
740
+ $mlw_message_after = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_after);
741
+ $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
742
+ $mlw_display .= $mlw_message_after;
743
+ break;
744
+ }
745
+ else
746
+ {
747
+ //Check to see if points fall in correct range
748
+ if ($mlw_points >= $mlw_each[0] && $mlw_points <= $mlw_each[1])
749
+ {
750
+ $mlw_message_after = $mlw_each[2];
751
+ $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
752
+ $mlw_message_after = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_after);
753
+ $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
754
+ $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
755
+ $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
756
+ $mlw_message_after = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_after);
757
+ $mlw_message_after = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_after);
758
+ $mlw_message_after = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_after);
759
+ $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
760
+ $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
761
+ $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
762
+ $mlw_message_after = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_after);
763
+ $mlw_message_after = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_after);
764
+ $mlw_message_after = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message_after);
765
+ $mlw_message_after = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_after);
766
+ $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
767
+ $mlw_display .= $mlw_message_after;
768
+ break;
769
+ }
770
+ //Check to see if score fall in correct range
771
+ if ($mlw_total_score >= $mlw_each[0] && $mlw_total_score <= $mlw_each[1])
772
+ {
773
+ $mlw_message_after = $mlw_each[2];
774
+ $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
775
+ $mlw_message_after = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_after);
776
+ $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
777
+ $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
778
+ $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
779
+ $mlw_message_after = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_after);
780
+ $mlw_message_after = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_after);
781
+ $mlw_message_after = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_after);
782
+ $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
783
+ $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
784
+ $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
785
+ $mlw_message_after = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_after);
786
+ $mlw_message_after = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_after);
787
+ $mlw_message_after = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message_after);
788
+ $mlw_message_after = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_after);
789
+ $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
790
+ $mlw_display .= $mlw_message_after;
791
+ break;
792
+ }
793
+ }
794
+ }
795
+ }
796
+ else
797
+ {
798
+ //Prepare the after quiz message
799
+ $mlw_message_after = $mlw_quiz_options->message_after;
800
+ $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
801
+ $mlw_message_after = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_after);
802
+ $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
803
+ $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
804
+ $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
805
+ $mlw_message_after = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_after);
806
+ $mlw_message_after = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_after);
807
+ $mlw_message_after = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_after);
808
+ $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
809
+ $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
810
+ $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
811
+ $mlw_message_after = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_after);
812
+ $mlw_message_after = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_after);
813
+ $mlw_message_after = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message_after);
814
+ $mlw_message_after = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_after);
815
+ $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
816
+ $mlw_display .= $mlw_message_after;
817
+ }
818
+
819
+ if ($mlw_quiz_options->social_media == 1)
820
+ {
821
+ $mlw_social_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_quiz_options->social_media_text);
822
+ $mlw_social_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_social_message);
823
+ $mlw_social_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_social_message);
824
+ $mlw_social_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_social_message);
825
+ $mlw_social_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_social_message);
826
+ $mlw_social_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_social_message);
827
+ $mlw_social_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_social_message);
828
+ $mlw_social_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_social_message);
829
+ $mlw_display .= "<br />
830
+ <a href=\"https://twitter.com/share\" data-size=\"large\" data-text=\"".esc_attr($mlw_social_message)."\" class=\"twitter-share-button\" data-lang=\"en\">Tweet</a>
831
+ <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=\"https://platform.twitter.com/widgets.js\";fjs.parentNode.insertBefore(js,fjs);}}(document,\"script\",\"twitter-wjs\");</script>
832
+ <br />";
833
+ }
834
+
835
+ //Prepare and send the user email
836
+ $mlw_message = "";
837
+ if ($mlw_quiz_options->send_user_email == "0")
838
+ {
839
+ if ($mlw_user_email != "")
840
+ {
841
+ $mlw_message = $mlw_quiz_options->user_email_template;
842
+ $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
843
+ $mlw_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message);
844
+ $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
845
+ $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
846
+ $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
847
+ $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
848
+ $mlw_message = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message);
849
+ $mlw_message = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message);
850
+ $mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
851
+ $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
852
+ $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
853
+ $mlw_message = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message);
854
+ $mlw_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message);
855
+ $mlw_message = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message);
856
+ $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
857
+ $mlw_message = str_replace( "<br />" , "\n", $mlw_message);
858
+ $mlw_headers = 'From: '.$mlw_quiz_options->email_from_text.' <'.$mlw_quiz_options->admin_email.'>' . "\r\n";
859
+ wp_mail($mlw_user_email, "Quiz Results For ".$mlw_quiz_options->quiz_name, $mlw_message, $mlw_headers);
860
+ }
861
+ }
862
+
863
+ //Prepare and send the admin email
864
+ $mlw_message = "";
865
+ if ($mlw_quiz_options->send_admin_email == "0")
866
+ {
867
+ $mlw_message = $mlw_quiz_options->admin_email_template;
868
+ $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
869
+ $mlw_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message);
870
+ $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
871
+ $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
872
+ $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
873
+ $mlw_message = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message);
874
+ $mlw_message = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message);
875
+ $mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
876
+ $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
877
+ $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
878
+ $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
879
+ $mlw_message = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message);
880
+ $mlw_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message);
881
+ $mlw_message = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message);
882
+ $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
883
+ $mlw_message .= " This email was generated by the Quiz Master Next script by Frank Corso";
884
+ $mlw_message = str_replace( "<br />" , "\n", $mlw_message);
885
+ $mlw_headers = 'From: '.$mlw_quiz_options->email_from_text.' <'.$mlw_quiz_options->admin_email.'>' . "\r\n";
886
+ wp_mail($mlw_quiz_options->admin_email, "Quiz Results For ".$mlw_quiz_options->quiz_name, $mlw_message, $mlw_headers);
887
+ }
888
+
889
+ //Save the results into database
890
+ $mlw_quiz_results = "Quiz was taken in: ".$mlw_qmn_timer." seconds."."\n".$mlw_question_answers."\n".$mlw_qm_quiz_comments;
891
+ $mlw_quiz_results = str_replace( "\n" , "<br>", $mlw_quiz_results);
892
+ $mlw_quiz_results = htmlspecialchars($mlw_quiz_results, ENT_QUOTES);
893
+ global $wpdb;
894
+ $table_name = $wpdb->prefix . "mlw_results";
895
+ $insert = "INSERT INTO " . $table_name .
896
+ "(result_id, quiz_id, quiz_name, quiz_system, point_score, correct_score, correct, total, name, business, email, phone, time_taken, time_taken_real, quiz_results, deleted) " .
897
+ "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")."', '".date("Y-m-d H:i:s")."', '".$mlw_quiz_results."', 0)";
898
+ $results = $wpdb->query( $insert );
899
+ }
900
+ else
901
+ {
902
+ if (!$mlw_qmn_isAllowed)
903
+ {
904
+ $mlw_display .= $mlw_quiz_options->total_user_tries_text;
905
+ }
906
+ else { $mlw_display .= "Thank you."; }
907
+ }
908
+ }
909
+ return $mlw_display;
910
+ }
911
+
912
+
913
+ /*
914
+ This function displays fields to ask for contact information
915
+ */
916
+ function mlwDisplayContactInfo($mlw_quiz_options)
917
+ {
918
+ $mlw_contact_display = "";
919
+ //Check to see if user is logged in, then ask for contact if not
920
+ if ( is_user_logged_in() )
921
+ {
922
+ //If this quiz does not let user edit contact information we hide this section
923
+ if ($mlw_quiz_options->loggedin_user_contact == 1)
924
+ {
925
+ $mlw_contact_display .= "<div style='display:none;'>";
926
+ }
927
+
928
+ //Retrieve current user information and save into text fields for contact information
929
+ $current_user = wp_get_current_user();
930
+ if ($mlw_quiz_options->user_name != 2)
931
+ {
932
+ $mlw_contact_display .= "<span style='font-weight:bold;';>".$mlw_quiz_options->name_field_text."</span><br />";
933
+ $mlw_contact_display .= "<input type='text' x-webkit-speech name='mlwUserName' value='".$current_user->display_name."' />";
934
+ $mlw_contact_display .= "<br /><br />";
935
+
936
+ }
937
+ if ($mlw_quiz_options->user_comp != 2)
938
+ {
939
+ $mlw_contact_display .= "<span style='font-weight:bold;';>".$mlw_quiz_options->business_field_text."</span><br />";
940
+ $mlw_contact_display .= "<input type='text' x-webkit-speech name='mlwUserComp' value='' />";
941
+ $mlw_contact_display .= "<br /><br />";
942
+ }
943
+ if ($mlw_quiz_options->user_email != 2)
944
+ {
945
+ $mlw_contact_display .= "<span style='font-weight:bold;';>".$mlw_quiz_options->email_field_text."</span><br />";
946
+ $mlw_contact_display .= "<input type='text' x-webkit-speech name='mlwUserEmail' value='".$current_user->user_email."' />";
947
+ $mlw_contact_display .= "<br /><br />";
948
+ }
949
+ if ($mlw_quiz_options->user_phone != 2)
950
+ {
951
+ $mlw_contact_display .= "<span style='font-weight:bold;';>".$mlw_quiz_options->phone_field_text."</span><br />";
952
+ $mlw_contact_display .= "<input type='text' x-webkit-speech name='mlwUserPhone' value='' />";
953
+ $mlw_contact_display .= "<br /><br />";
954
+ }
955
+
956
+ //End of hidden section div
957
+ if ($mlw_quiz_options->loggedin_user_contact == 1)
958
+ {
959
+ $mlw_contact_display .= "</div>";
960
+ }
961
+ }
962
+ else
963
+ {
964
+ //See if the site wants to ask for any contact information, then ask for it
965
+ if ($mlw_quiz_options->user_name != 2)
966
+ {
967
+ $mlw_contact_display .= "<span style='font-weight:bold;';>".$mlw_quiz_options->name_field_text."</span><br />";
968
+ $mlw_contact_display .= "<input type='text' x-webkit-speech name='mlwUserName' value='' />";
969
+ $mlw_contact_display .= "<br /><br />";
970
+ }
971
+ if ($mlw_quiz_options->user_comp != 2)
972
+ {
973
+ $mlw_contact_display .= "<span style='font-weight:bold;';>".$mlw_quiz_options->business_field_text."</span><br />";
974
+ $mlw_contact_display .= "<input type='text' x-webkit-speech name='mlwUserComp' value='' />";
975
+ $mlw_contact_display .= "<br /><br />";
976
+ }
977
+ if ($mlw_quiz_options->user_email != 2)
978
+ {
979
+ $mlw_contact_display .= "<span style='font-weight:bold;';>".$mlw_quiz_options->email_field_text."</span><br />";
980
+ $mlw_contact_display .= "<input type='text' x-webkit-speech name='mlwUserEmail' value='' />";
981
+ $mlw_contact_display .= "<br /><br />";
982
+ }
983
+ if ($mlw_quiz_options->user_phone != 2)
984
+ {
985
+ $mlw_contact_display .= "<span style='font-weight:bold;';>".$mlw_quiz_options->phone_field_text."</span><br />";
986
+ $mlw_contact_display .= "<input type='text' x-webkit-speech name='mlwUserPhone' value='' />";
987
+ $mlw_contact_display .= "<br /><br />";
988
+ }
989
+ }
990
+ return $mlw_contact_display;
991
+ }
992
  ?>
includes/mlw_results_details.php CHANGED
@@ -39,23 +39,29 @@ function mlw_generate_result_details()
39
  $mlw_message_certificate = str_replace( "%USER_PHONE%" , $mlw_quiz_results->email, $mlw_message_certificate);
40
  $mlw_message_certificate = str_replace( "%USER_EMAIL%" , $mlw_quiz_results->phone, $mlw_message_certificate);
41
  $mlw_message_certificate = str_replace( "\n" , "<br>", $mlw_message_certificate);
42
- $mlw_qmn_certifiicate_file = "<?php
43
- include(\"".plugin_dir_path( __FILE__ )."WriteHTML.php\");
44
- \$pdf = new PDF_HTML();
45
- \$pdf->AddPage('L');";
46
- $mlw_qmn_certifiicate_file .= $mlw_certificate_options[3] != '' ? "\$pdf->Image('".$mlw_certificate_options[3]."',0,0,\$pdf->w, \$pdf->h);" : '';
47
- $mlw_qmn_certifiicate_file .= "\$pdf->Ln(20);
48
- \$pdf->SetFont('Arial','B',24);
49
- \$pdf->MultiCell(280,20,'".$mlw_certificate_options[0]."', 0, 'C');
50
- \$pdf->Ln(15);
51
- \$pdf->SetFont('Arial','',16);
52
- \$pdf->WriteHTML('<p align=\"center\">".$mlw_message_certificate."</p>');";
53
- $mlw_qmn_certifiicate_file .= $mlw_certificate_options[2] != '' ? "\$pdf->Image('".$mlw_certificate_options[2]."',110,130);" : '';
54
- $mlw_qmn_certifiicate_file .= "\$pdf->Output('mlw_qmn_certificate.pdf', 'D');
55
- unlink(__FILE__);
56
- ?>";
 
 
 
 
 
 
57
  $mlw_qmn_certificate_filename = "../".str_replace(home_url()."/", '', plugin_dir_url( __FILE__ ))."certificates/mlw_qmn_quiz".date("YmdHis")."admin.php";
58
- file_put_contents($mlw_qmn_certificate_filename, $mlw_qmn_certifiicate_file);
59
  $mlw_qmn_certificate_filename = plugin_dir_url( __FILE__ )."certificates/mlw_qmn_quiz".date("YmdHis")."admin.php";
60
  }
61
 
39
  $mlw_message_certificate = str_replace( "%USER_PHONE%" , $mlw_quiz_results->email, $mlw_message_certificate);
40
  $mlw_message_certificate = str_replace( "%USER_EMAIL%" , $mlw_quiz_results->phone, $mlw_message_certificate);
41
  $mlw_message_certificate = str_replace( "\n" , "<br>", $mlw_message_certificate);
42
+ $plugindirpath=plugin_dir_path( __FILE__ );
43
+ $mlw_qmn_certificate_file=<<<EOC
44
+ <?php
45
+ include("$plugindirpath/WriteHTML.php");
46
+ \$pdf=new PDF_HTML();
47
+ \$pdf->AddPage('L');
48
+ EOC;
49
+ $mlw_qmn_certificate_file.=$mlw_certificate_options[3] != '' ? '$pdf->Image("'.$mlw_certificate_options[3].'",0,0,$pdf->w, $pdf->h);' : '';
50
+ $mlw_qmn_certificate_file.=<<<EOC
51
+ \$pdf->Ln(20);
52
+ \$pdf->SetFont('Arial','B',24);
53
+ \$pdf->MultiCell(280,20,'$mlw_certificate_options[0]',0,'C');
54
+ \$pdf->Ln(15);
55
+ \$pdf->SetFont('Arial','',16);
56
+ \$pdf->WriteHTML("<p align='center'>$mlw_message_certificate</p>");
57
+ EOC;
58
+ $mlw_qmn_certificate_file.=$mlw_certificate_options[2] != '' ? '$pdf->Image("'.$mlw_certificate_options[2].'",110,130);' : '';
59
+ $mlw_qmn_certificate_file.=<<<EOC
60
+ \$pdf->Output('mlw_qmn_certificate.pdf','D');
61
+ unlink(__FILE__);
62
+ EOC;
63
  $mlw_qmn_certificate_filename = "../".str_replace(home_url()."/", '', plugin_dir_url( __FILE__ ))."certificates/mlw_qmn_quiz".date("YmdHis")."admin.php";
64
+ file_put_contents($mlw_qmn_certificate_filename, $mlw_qmn_certificate_file);
65
  $mlw_qmn_certificate_filename = plugin_dir_url( __FILE__ )."certificates/mlw_qmn_quiz".date("YmdHis")."admin.php";
66
  }
67
 
includes/mlw_update.php CHANGED
@@ -6,7 +6,7 @@ function mlw_quiz_update()
6
  {
7
 
8
  //Update this variable each update. This is what is checked when the plugin is deciding to run the upgrade script or not.
9
- $data = "1.9.4";
10
  if ( ! get_option('mlw_quiz_master_version'))
11
  {
12
  add_option('mlw_quiz_master_version' , $data);
6
  {
7
 
8
  //Update this variable each update. This is what is checked when the plugin is deciding to run the upgrade script or not.
9
+ $data = "1.9.5";
10
  if ( ! get_option('mlw_quiz_master_version'))
11
  {
12
  add_option('mlw_quiz_master_version' , $data);
mlw_quizmaster2.php CHANGED
@@ -3,7 +3,7 @@
3
  /*
4
  Plugin Name: Quiz Master Next
5
  Description: Use this plugin to add multiple quizzes, tests, or surveys to your website.
6
- Version: 1.9.4
7
  Author: Frank Corso
8
  Author URI: http://www.mylocalwebstop.com/
9
  Plugin URI: http://www.mylocalwebstop.com/
3
  /*
4
  Plugin Name: Quiz Master Next
5
  Description: Use this plugin to add multiple quizzes, tests, or surveys to your website.
6
+ Version: 1.9.5
7
  Author: Frank Corso
8
  Author URI: http://www.mylocalwebstop.com/
9
  Plugin URI: http://www.mylocalwebstop.com/
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: quiz, test, score, survey, contact, form, email, answer, question
5
  Requires at least: 3.3
6
  Tested up to: 3.8.1
7
- Stable tag: 1.9.4
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  The easiest and most flexible way to add multiple quizzes, tests, and surveys to your website.
@@ -99,6 +99,9 @@ Feel free to use the widget on the quiz dashboard within the plugin or from the
99
 
100
  == Changelog ==
101
 
 
 
 
102
  = 1.9.4 (March 18, 2014) =
103
  * Fixed Bug
104
 
4
  Tags: quiz, test, score, survey, contact, form, email, answer, question
5
  Requires at least: 3.3
6
  Tested up to: 3.8.1
7
+ Stable tag: 1.9.5
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  The easiest and most flexible way to add multiple quizzes, tests, and surveys to your website.
99
 
100
  == Changelog ==
101
 
102
+ = 1.9.5 (March 18, 2014) =
103
+ * Fixed Bug
104
+
105
  = 1.9.4 (March 18, 2014) =
106
  * Fixed Bug
107