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

Version Description

Upgrade for categories, new editor for results pages, shortcode capability on results pages, enhanced required question system, and more.

Download this release

Release Info

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

Code changes from version 3.9.0 to 4.0.0

Files changed (65) hide show
  1. assets/screenshot-2.png +0 -0
  2. assets/screenshot-3.png +0 -0
  3. includes/css/qmn_addons_page.css +18 -0
  4. includes/{qmn_quiz.css → css/qmn_quiz.css} +0 -0
  5. includes/{WriteHTML.php → fpdf/WriteHTML.php} +0 -0
  6. includes/{font → fpdf/font}/courier.php +0 -0
  7. includes/{font → fpdf/font}/courierb.php +0 -0
  8. includes/{font → fpdf/font}/courierbi.php +0 -0
  9. includes/{font → fpdf/font}/courieri.php +0 -0
  10. includes/{font → fpdf/font}/helvetica.php +0 -0
  11. includes/{font → fpdf/font}/helveticab.php +0 -0
  12. includes/{font → fpdf/font}/helveticabi.php +0 -0
  13. includes/{font → fpdf/font}/helveticai.php +0 -0
  14. includes/{font → fpdf/font}/symbol.php +0 -0
  15. includes/{font → fpdf/font}/times.php +0 -0
  16. includes/{font → fpdf/font}/timesb.php +0 -0
  17. includes/{font → fpdf/font}/timesbi.php +0 -0
  18. includes/{font → fpdf/font}/timesi.php +0 -0
  19. includes/{font → fpdf/font}/zapfdingbats.php +0 -0
  20. includes/{fpdf.php → fpdf/fpdf.php} +0 -0
  21. includes/{qmn_pagination.js → js/qmn_pagination.js} +0 -0
  22. includes/{qmn_quiz.js → js/qmn_quiz.js} +37 -16
  23. includes/{qmn_social_share.js → js/qmn_social_share.js} +0 -0
  24. includes/{qmn_timer.js → js/qmn_timer.js} +4 -3
  25. includes/{jquery_sparkline.js → js/sparkline/jquery_sparkline.js} +0 -0
  26. includes/mlw_quiz.php +0 -1294
  27. includes/mlw_quiz_admin.php +0 -355
  28. includes/mlw_quiz_options.php +0 -2602
  29. includes/mlw_results.php +0 -254
  30. includes/mlw_template_variables.php +0 -128
  31. includes/qmn_addons.php +76 -0
  32. includes/{mlw_adverts.php → qmn_adverts.php} +0 -0
  33. includes/{mlw_alerts.php → qmn_alerts.php} +6 -6
  34. includes/{mlw_qmn_credits.php → qmn_credits.php} +55 -22
  35. includes/{mlw_dashboard.php → qmn_dashboard.php} +127 -88
  36. includes/qmn_dashboard_widgets.php +23 -20
  37. includes/{mlw_help.php → qmn_help.php} +25 -25
  38. includes/qmn_helper.php +336 -0
  39. includes/{mlw_leaderboard.php → qmn_leaderboard.php} +1 -1
  40. includes/qmn_options_certificate_tab.php +133 -0
  41. includes/qmn_options_email_tab.php +489 -0
  42. includes/qmn_options_leaderboard_tab.php +112 -0
  43. includes/qmn_options_option_tab.php +225 -0
  44. includes/qmn_options_preview_tab.php +19 -0
  45. includes/qmn_options_questions_tab.php +879 -0
  46. includes/qmn_options_results_page_tab.php +266 -0
  47. includes/qmn_options_style_tab.php +155 -0
  48. includes/qmn_options_text_tab.php +312 -0
  49. includes/qmn_options_tools_tab.php +96 -0
  50. includes/qmn_question_types.php +574 -0
  51. includes/qmn_quiz.php +1310 -0
  52. includes/qmn_quiz_admin.php +368 -0
  53. includes/{mlw_quiz_creator.php → qmn_quiz_creator.php} +170 -164
  54. includes/{mlw_quiz_install.php → qmn_quiz_install.php} +75 -71
  55. includes/qmn_quiz_options.php +105 -0
  56. includes/qmn_results.php +226 -0
  57. includes/{mlw_results_details.php → qmn_results_details.php} +45 -55
  58. includes/qmn_template_variables.php +322 -0
  59. includes/{mlw_tools.php → qmn_tools.php} +48 -76
  60. includes/{mlw_update.php → qmn_update.php} +50 -33
  61. includes/{mlw_qmn_widgets.php → qmn_widgets.php} +14 -14
  62. languages/index.php +5 -0
  63. languages/quiz-master-next.pot +1491 -0
  64. mlw_quizmaster2.php +100 -57
  65. readme.txt +39 -17
assets/screenshot-2.png CHANGED
Binary file
assets/screenshot-3.png CHANGED
Binary file
includes/css/qmn_addons_page.css ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .qmn_addons
2
+ {
3
+ float: left;
4
+ width: 300px;
5
+ height: 300px;
6
+ border: 1px solid #ccc;
7
+ padding: 10px;
8
+ margin: 10px;
9
+ position: relative;
10
+ }
11
+ .qmn_addons_title
12
+ {
13
+ font-size: 15px;
14
+ }
15
+ .qmn_addons_desc
16
+ {
17
+
18
+ }
includes/{qmn_quiz.css → css/qmn_quiz.css} RENAMED
File without changes
includes/{WriteHTML.php → fpdf/WriteHTML.php} RENAMED
File without changes
includes/{font → fpdf/font}/courier.php RENAMED
File without changes
includes/{font → fpdf/font}/courierb.php RENAMED
File without changes
includes/{font → fpdf/font}/courierbi.php RENAMED
File without changes
includes/{font → fpdf/font}/courieri.php RENAMED
File without changes
includes/{font → fpdf/font}/helvetica.php RENAMED
File without changes
includes/{font → fpdf/font}/helveticab.php RENAMED
File without changes
includes/{font → fpdf/font}/helveticabi.php RENAMED
File without changes
includes/{font → fpdf/font}/helveticai.php RENAMED
File without changes
includes/{font → fpdf/font}/symbol.php RENAMED
File without changes
includes/{font → fpdf/font}/times.php RENAMED
File without changes
includes/{font → fpdf/font}/timesb.php RENAMED
File without changes
includes/{font → fpdf/font}/timesbi.php RENAMED
File without changes
includes/{font → fpdf/font}/timesi.php RENAMED
File without changes
includes/{font → fpdf/font}/zapfdingbats.php RENAMED
File without changes
includes/{fpdf.php → fpdf/fpdf.php} RENAMED
File without changes
includes/{qmn_pagination.js → js/qmn_pagination.js} RENAMED
File without changes
includes/{qmn_quiz.js → js/qmn_quiz.js} RENAMED
@@ -30,8 +30,8 @@ function clear_field(field)
30
  function mlw_validateForm()
31
  {
32
  mlw_validateResult = true;
33
-
34
- jQuery('#quizForm *').filter(':input').each(function(){
35
  jQuery(this).css("outline", "");
36
  if (jQuery(this).attr('class'))
37
  {
@@ -42,48 +42,69 @@ function mlw_validateForm()
42
  var dotpos=x.lastIndexOf('.');
43
  if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
44
  {
45
- document.getElementById('mlw_error_message').innerHTML = '**Not a valid e-mail address!**';
46
- document.getElementById('mlw_error_message_bottom').innerHTML = '**Not a valid e-mail address!**';
47
  mlw_validateResult = false;
48
  jQuery(this).css("outline", "2px solid red");
49
  }
50
  }
51
  if(jQuery(this).attr('class').indexOf('mlwRequiredNumber') > -1 && this.value == "" && +this.value != NaN)
52
  {
53
- document.getElementById('mlw_error_message').innerHTML = '**This field must be a number!**';
54
- document.getElementById('mlw_error_message_bottom').innerHTML = '**This field must be a number!**';
55
  jQuery(this).css("outline", "2px solid red");
56
  mlw_validateResult = false;
57
  }
58
  if(jQuery(this).attr('class').indexOf('mlwRequiredText') > -1 && this.value == "")
59
  {
60
- document.getElementById('mlw_error_message').innerHTML = '**Please complete all required fields!**';
61
- document.getElementById('mlw_error_message_bottom').innerHTML = '**Please complete all required fields!**';
62
  jQuery(this).css("outline", "2px solid red");
63
  mlw_validateResult = false;
64
  }
65
  if(jQuery(this).attr('class').indexOf('mlwRequiredCaptcha') > -1 && this.value != mlw_code)
66
  {
67
- document.getElementById('mlw_error_message').innerHTML = '**The entered text is not correct!**';
68
- document.getElementById('mlw_error_message_bottom').innerHTML = '**The entered text is not correct!**';
69
  jQuery(this).css("outline", "2px solid red");
70
  mlw_validateResult = false;
71
  }
72
- if(jQuery(this).attr('class').indexOf('mlwRequiredCheck') > -1 && !this.checked)
73
  {
74
- document.getElementById('mlw_error_message').innerHTML = '**Please complete all required fields!**';
75
- document.getElementById('mlw_error_message_bottom').innerHTML = '**Please complete all required fields!**';
76
  jQuery(this).css("outline", "2px solid red");
77
  mlw_validateResult = false;
78
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
80
  });
81
-
82
  if (!mlw_validateResult) {return mlw_validateResult;}
83
-
84
  jQuery( '.mlw_qmn_quiz input:radio' ).attr('disabled',false);
85
  jQuery( '.mlw_qmn_quiz input:checkbox' ).attr('disabled',false);
86
  jQuery( '.mlw_qmn_quiz select' ).attr('disabled',false);
87
  jQuery( '.mlw_qmn_question_comment' ).attr('disabled',false);
88
  jQuery( '.mlw_answer_open_text' ).attr('disabled',false);
89
- }
30
  function mlw_validateForm()
31
  {
32
  mlw_validateResult = true;
33
+
34
+ jQuery('#quizForm *').each(function(){
35
  jQuery(this).css("outline", "");
36
  if (jQuery(this).attr('class'))
37
  {
42
  var dotpos=x.lastIndexOf('.');
43
  if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
44
  {
45
+ document.getElementById('mlw_error_message').innerHTML = '**'+email_error+'**';
46
+ document.getElementById('mlw_error_message_bottom').innerHTML = '**'+email_error+'**';
47
  mlw_validateResult = false;
48
  jQuery(this).css("outline", "2px solid red");
49
  }
50
  }
51
  if(jQuery(this).attr('class').indexOf('mlwRequiredNumber') > -1 && this.value == "" && +this.value != NaN)
52
  {
53
+ document.getElementById('mlw_error_message').innerHTML = '**'+number_error+'**';
54
+ document.getElementById('mlw_error_message_bottom').innerHTML = '**'+number_error+'**';
55
  jQuery(this).css("outline", "2px solid red");
56
  mlw_validateResult = false;
57
  }
58
  if(jQuery(this).attr('class').indexOf('mlwRequiredText') > -1 && this.value == "")
59
  {
60
+ document.getElementById('mlw_error_message').innerHTML = '**'+empty_error+'**';
61
+ document.getElementById('mlw_error_message_bottom').innerHTML = '**'+empty_error+'**';
62
  jQuery(this).css("outline", "2px solid red");
63
  mlw_validateResult = false;
64
  }
65
  if(jQuery(this).attr('class').indexOf('mlwRequiredCaptcha') > -1 && this.value != mlw_code)
66
  {
67
+ document.getElementById('mlw_error_message').innerHTML = '**'+incorrect_error+'**';
68
+ document.getElementById('mlw_error_message_bottom').innerHTML = '**'+incorrect_error+'**';
69
  jQuery(this).css("outline", "2px solid red");
70
  mlw_validateResult = false;
71
  }
72
+ if(jQuery(this).attr('class').indexOf('mlwRequiredAccept') > -1 && !this.checked)
73
  {
74
+ document.getElementById('mlw_error_message').innerHTML = '**'+empty_error+'**';
75
+ document.getElementById('mlw_error_message_bottom').innerHTML = '**'+empty_error+'**';
76
  jQuery(this).css("outline", "2px solid red");
77
  mlw_validateResult = false;
78
  }
79
+ if(jQuery(this).attr('class').indexOf('mlwRequiredRadio') > -1)
80
+ {
81
+ check_val = jQuery(this).find('input:checked').val();
82
+ if (check_val == "No Answer Provided")
83
+ {
84
+ document.getElementById('mlw_error_message').innerHTML = '**'+empty_error+'**';
85
+ document.getElementById('mlw_error_message_bottom').innerHTML = '**'+empty_error+'**';
86
+ jQuery(this).css("outline", "2px solid red");
87
+ mlw_validateResult = false;
88
+ }
89
+ }
90
+ if(jQuery(this).attr('class').indexOf('mlwRequiredCheck') > -1)
91
+ {
92
+ if (!jQuery(this).find('input:checked').length)
93
+ {
94
+ document.getElementById('mlw_error_message').innerHTML = '**'+empty_error+'**';
95
+ document.getElementById('mlw_error_message_bottom').innerHTML = '**'+empty_error+'**';
96
+ jQuery(this).css("outline", "2px solid red");
97
+ mlw_validateResult = false;
98
+ }
99
+ }
100
  }
101
  });
102
+
103
  if (!mlw_validateResult) {return mlw_validateResult;}
104
+
105
  jQuery( '.mlw_qmn_quiz input:radio' ).attr('disabled',false);
106
  jQuery( '.mlw_qmn_quiz input:checkbox' ).attr('disabled',false);
107
  jQuery( '.mlw_qmn_quiz select' ).attr('disabled',false);
108
  jQuery( '.mlw_qmn_question_comment' ).attr('disabled',false);
109
  jQuery( '.mlw_answer_open_text' ).attr('disabled',false);
110
+ }
includes/{qmn_social_share.js → js/qmn_social_share.js} RENAMED
File without changes
includes/{qmn_timer.js → js/qmn_timer.js} RENAMED
@@ -18,7 +18,7 @@ function timer()
18
  window.amount=window.amount-1;
19
  if (window.amount < 0)
20
  {
21
- window.amount = 0;
22
  }
23
  window.sessionStorage.setItem('mlw_time_quiz'+qmn_quiz_id, window.amount/60);
24
  window.sessionStorage.setItem('mlw_started_quiz'+qmn_quiz_id, "yes");
@@ -32,6 +32,7 @@ function timer()
32
  jQuery( ".mlw_qmn_quiz select" ).attr('disabled',true);
33
  jQuery( ".mlw_qmn_question_comment" ).attr('disabled',true);
34
  jQuery( ".mlw_answer_open_text" ).attr('disabled',true);
 
35
  //document.quizForm.submit();
36
  return;
37
  }
@@ -66,8 +67,8 @@ function minToSec(amount)
66
  timer_display = timer_display + minutes + ":";
67
  }
68
  var seconds = Math.floor(amount % 60);
69
- if (seconds == '0')
70
- {
71
  timer_display = timer_display +"00";
72
  }
73
  else if (seconds < 10)
18
  window.amount=window.amount-1;
19
  if (window.amount < 0)
20
  {
21
+ window.amount = 0;
22
  }
23
  window.sessionStorage.setItem('mlw_time_quiz'+qmn_quiz_id, window.amount/60);
24
  window.sessionStorage.setItem('mlw_started_quiz'+qmn_quiz_id, "yes");
32
  jQuery( ".mlw_qmn_quiz select" ).attr('disabled',true);
33
  jQuery( ".mlw_qmn_question_comment" ).attr('disabled',true);
34
  jQuery( ".mlw_answer_open_text" ).attr('disabled',true);
35
+ jQuery( ".mlw_answer_number" ).attr('disabled',true);
36
  //document.quizForm.submit();
37
  return;
38
  }
67
  timer_display = timer_display + minutes + ":";
68
  }
69
  var seconds = Math.floor(amount % 60);
70
+ if (seconds == '0')
71
+ {
72
  timer_display = timer_display +"00";
73
  }
74
  else if (seconds < 10)
includes/{jquery_sparkline.js → js/sparkline/jquery_sparkline.js} RENAMED
File without changes
includes/mlw_quiz.php DELETED
@@ -1,1294 +0,0 @@
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
- global $mlwQuizMasterNext;
12
- $mlwQuizMasterNext->quizCreator->set_id($quiz);
13
- date_default_timezone_set(get_option('timezone_string'));
14
-
15
- /*
16
- Code before loading the quiz
17
- */
18
-
19
- //Variables needed throughout script
20
- $mlw_quiz_id = intval($quiz);
21
- $GLOBALS['mlw_qmn_quiz'] = $mlw_quiz_id;
22
- $mlw_display = "";
23
- global $wpdb;
24
- $mlw_qmn_isAllowed = true;
25
- $mlw_qmn_section_count = 1;
26
- $mlw_qmn_section_limit = 0;
27
-
28
-
29
- //Load quiz
30
- $sql = "SELECT * FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=".$mlw_quiz_id." AND deleted='0'";
31
- $mlw_quiz_options = $wpdb->get_results($sql);
32
-
33
- foreach($mlw_quiz_options as $mlw_eaches) {
34
- $mlw_quiz_options = $mlw_eaches;
35
- break;
36
- }
37
-
38
- $mlw_qmn_quiz_options_array = array(
39
- 'quiz_name' => $mlw_quiz_options->quiz_name,
40
- 'quiz_id' => $mlw_quiz_options->quiz_id
41
- );
42
-
43
- //Check if user is required to be checked in
44
- if ( $mlw_quiz_options->require_log_in == 1 && !is_user_logged_in() )
45
- {
46
- $mlw_message = htmlspecialchars_decode($mlw_quiz_options->require_log_in_text, ENT_QUOTES);
47
- $mlw_message = apply_filters( 'mlw_qmn_template_variable_quiz_page', $mlw_message, $mlw_qmn_quiz_options_array);
48
- $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
49
- $mlw_display = $mlw_message;
50
- $mlw_display .= wp_login_form( array('echo' => false) );
51
- return $mlw_display;
52
- $mlw_qmn_isAllowed = false;
53
- }
54
-
55
- //Check if date is inside scheduled timeframe
56
- if (is_serialized($mlw_quiz_options->scheduled_timeframe) && is_array(@unserialize($mlw_quiz_options->scheduled_timeframe)))
57
- {
58
- $qmn_scheduled_timeframe = @unserialize($mlw_quiz_options->scheduled_timeframe);
59
- if ($qmn_scheduled_timeframe["start"] != '' && $qmn_scheduled_timeframe["end"] != '')
60
- {
61
- $qmn_scheduled_start = strtotime($qmn_scheduled_timeframe["start"]);
62
- $qmn_scheduled_end = strtotime($qmn_scheduled_timeframe["end"]) + 86399; ///Added seconds to bring time to 11:59:59 PM of given day
63
- if (time() < $qmn_scheduled_start | time() > $qmn_scheduled_end)
64
- {
65
- $mlw_message = htmlspecialchars_decode($mlw_quiz_options->scheduled_timeframe_text, ENT_QUOTES);
66
- $mlw_message = apply_filters( 'mlw_qmn_template_variable_quiz_page', $mlw_message, $mlw_qmn_quiz_options_array);
67
- $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
68
- $mlw_display = $mlw_message;
69
- return $mlw_display;
70
- $mlw_qmn_isAllowed = false;
71
- }
72
- }
73
- }
74
-
75
- //Check to see if there is limit on the amount of tries
76
- if ( $mlw_quiz_options->total_user_tries != 0 && is_user_logged_in() )
77
- {
78
- $current_user = wp_get_current_user();
79
- $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 ) );
80
- if ($mlw_qmn_user_try_count >= $mlw_quiz_options->total_user_tries) { $mlw_qmn_isAllowed = false; }
81
- }
82
-
83
-
84
- //Load questions
85
- $sql = "SELECT * FROM " . $wpdb->prefix . "mlw_questions" . " WHERE quiz_id=".$mlw_quiz_id." AND deleted='0' ";
86
- if ($mlw_quiz_options->randomness_order == 0)
87
- {
88
- $sql .= "ORDER BY question_order ASC";
89
- }
90
- if ($mlw_quiz_options->randomness_order == 1 || $mlw_quiz_options->randomness_order == 2)
91
- {
92
- $sql .= "ORDER BY rand()";
93
- }
94
- if ($mlw_quiz_options->question_from_total != 0)
95
- {
96
- $sql .= " LIMIT ".$mlw_quiz_options->question_from_total;
97
- }
98
- $mlw_questions = $wpdb->get_results($sql);
99
-
100
-
101
- //Load and prepare answer arrays
102
- $mlw_qmn_answer_arrays = array();
103
- foreach($mlw_questions as $mlw_question_info) {
104
- if (is_serialized($mlw_question_info->answer_array) && is_array(@unserialize($mlw_question_info->answer_array)))
105
- {
106
- $mlw_qmn_answer_array_each = @unserialize($mlw_question_info->answer_array);
107
- $mlw_qmn_answer_arrays[$mlw_question_info->question_id] = $mlw_qmn_answer_array_each;
108
- }
109
- else
110
- {
111
- $mlw_answer_array_correct = array(0, 0, 0, 0, 0, 0);
112
- $mlw_answer_array_correct[$mlw_question_info->correct_answer-1] = 1;
113
- $mlw_qmn_answer_arrays[$mlw_question_info->question_id] = array(
114
- array($mlw_question_info->answer_one, $mlw_question_info->answer_one_points, $mlw_answer_array_correct[0]),
115
- array($mlw_question_info->answer_two, $mlw_question_info->answer_two_points, $mlw_answer_array_correct[1]),
116
- array($mlw_question_info->answer_three, $mlw_question_info->answer_three_points, $mlw_answer_array_correct[2]),
117
- array($mlw_question_info->answer_four, $mlw_question_info->answer_four_points, $mlw_answer_array_correct[3]),
118
- array($mlw_question_info->answer_five, $mlw_question_info->answer_five_points, $mlw_answer_array_correct[4]),
119
- array($mlw_question_info->answer_six, $mlw_question_info->answer_six_points, $mlw_answer_array_correct[5]));
120
- }
121
- }
122
-
123
-
124
- //Variables to load if quiz has been taken
125
- if (isset($_POST["complete_quiz"]) && $_POST["complete_quiz"] == "confirmation")
126
- {
127
- $mlw_success = $_POST["complete_quiz"];
128
- $mlw_user_name = isset($_POST["mlwUserName"]) ? $_POST["mlwUserName"] : 'None';
129
- $mlw_user_comp = isset($_POST["mlwUserComp"]) ? $_POST["mlwUserComp"] : 'None';
130
- $mlw_user_email = isset($_POST["mlwUserEmail"]) ? $_POST["mlwUserEmail"] : 'None';
131
- $mlw_user_phone = isset($_POST["mlwUserPhone"]) ? $_POST["mlwUserPhone"] : 'None';
132
- $mlw_qmn_timer = isset($_POST["timer"]) ? $_POST["timer"] : 0;
133
- $mlw_spam_email = $_POST["email"];
134
- }
135
-
136
- wp_enqueue_script( 'json2' );
137
- wp_enqueue_script( 'jquery' );
138
- wp_enqueue_script( 'jquery-ui-core' );
139
- wp_enqueue_script( 'jquery-effects-core' );
140
- wp_enqueue_script( 'jquery-effects-slide' );
141
- wp_enqueue_script( 'jquery-ui-dialog' );
142
- wp_enqueue_script( 'jquery-ui-button' );
143
- wp_enqueue_script( 'jquery-ui-tooltip' );
144
- wp_enqueue_style( 'qmn_jquery_redmond_theme', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css' );
145
-
146
- wp_enqueue_script( 'qmn_quiz', plugins_url( 'qmn_quiz.js' , __FILE__ ) );
147
- wp_enqueue_style( 'qmn_quiz_style', plugins_url( 'qmn_quiz.css' , __FILE__ ) );
148
- wp_enqueue_script( 'math_jax', '//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' );
149
-
150
- if ($mlw_quiz_options->theme_selected == "default")
151
- {
152
- echo "<style type='text/css'>".$mlw_quiz_options->quiz_stye."</style>";
153
- }
154
- else
155
- {
156
- echo "<link type='text/css' href='".get_option('mlw_qmn_theme_'.$mlw_quiz_options->theme_selected)."' rel='stylesheet' />";
157
- }
158
-
159
- /*
160
- The following code is for displaying the quiz and completion screen
161
- */
162
-
163
- //If there is no quiz for the shortcode provided
164
- if ($mlw_quiz_options->quiz_name == "")
165
- {
166
- $mlw_display .= "It appears that this quiz is not set up correctly.";
167
- return $mlw_display;
168
- }
169
-
170
-
171
-
172
- //Display Quiz
173
- if (!isset($_POST["complete_quiz"]) && $mlw_quiz_options->quiz_name != "" && $mlw_qmn_isAllowed)
174
- {
175
- //Check if total entries are limited
176
- if ( $mlw_quiz_options->limit_total_entries != 0 )
177
- {
178
- $mlw_qmn_entries_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(quiz_id) FROM ".$wpdb->prefix."mlw_results WHERE deleted='0' AND quiz_id=%d", $mlw_quiz_id ) );
179
- if ($mlw_qmn_entries_count >= $mlw_quiz_options->limit_total_entries)
180
- {
181
- $mlw_message = htmlspecialchars_decode($mlw_quiz_options->limit_total_entries_text, ENT_QUOTES);
182
- $mlw_message = apply_filters( 'mlw_qmn_template_variable_quiz_page', $mlw_message, $mlw_qmn_quiz_options_array);
183
- $mlw_display = $mlw_message;
184
- return $mlw_display;
185
- $mlw_qmn_isAllowed = false;
186
- }
187
- }
188
- $mlw_qmn_total_questions = 0;
189
- //Calculate number of pages if pagination is turned on
190
- if ($mlw_quiz_options->pagination != 0)
191
- {
192
- $mlw_qmn_section_limit = 2 + count($mlw_questions);
193
- if ($mlw_quiz_options->comment_section == 0)
194
- {
195
- $mlw_qmn_section_limit = $mlw_qmn_section_limit + 1;
196
- }
197
-
198
- //Gather text for pagination buttons
199
- $mlw_qmn_pagination_text = "";
200
- if (is_serialized($mlw_quiz_options->pagination_text) && is_array(@unserialize($mlw_quiz_options->pagination_text)))
201
- {
202
- $mlw_qmn_pagination_text = @unserialize($mlw_quiz_options->pagination_text);
203
- }
204
- else
205
- {
206
- $mlw_qmn_pagination_text = array('Previous', $mlw_quiz_options->pagination_text);
207
- }
208
- ?>
209
- <script type="text/javascript">
210
- var qmn_pagination = <?php echo $mlw_quiz_options->pagination; ?>;
211
- var qmn_section_limit = <?php echo $mlw_qmn_section_limit; ?>;
212
- var qmn_pagination_previous_text = '<?php echo $mlw_qmn_pagination_text[0]; ?>';
213
- var qmn_pagination_next_text = '<?php echo $mlw_qmn_pagination_text[1]; ?>';
214
- </script>
215
- <?php
216
- wp_enqueue_script( 'qmn_quiz_pagination', plugins_url( 'qmn_pagination.js' , __FILE__ ) );
217
- }
218
- if ($mlw_quiz_options->timer_limit != 0)
219
- {
220
- ?>
221
- <div id="mlw_qmn_timer" class="mlw_qmn_timer"></div>
222
- <script type="text/javascript">
223
- var qmn_quiz_id = <?php echo $mlw_quiz_id; ?>;
224
- var qmn_timer_limit = <?php echo $mlw_quiz_options->timer_limit; ?>;
225
- </script>
226
- <?php
227
- wp_enqueue_script( 'qmn_quiz_timer', plugins_url( 'qmn_timer.js' , __FILE__ ) );
228
- }
229
-
230
- //Update the quiz views
231
- $mlw_views = $mlw_quiz_options->quiz_views;
232
- $mlw_views += 1;
233
- $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET quiz_views='".$mlw_views."' WHERE quiz_id=".$mlw_quiz_id;
234
- $results = $wpdb->query( $update );
235
-
236
- if ( $mlw_quiz_options->pagination != 0) { $mlw_display .= "<style>.quiz_section { display: none; }</style>"; }
237
-
238
- //Begin the quiz
239
- $mlw_display .= "<div class='mlw_qmn_quiz'>";
240
- $mlw_display .= "<form name='quizForm' id='quizForm' action='' method='post' class='mlw_quiz_form' onsubmit='return mlw_validateForm()' novalidate >";
241
- $mlw_display .= "<span id='mlw_top_of_quiz'></span>";
242
- $mlw_display .= "<div class='quiz_section quiz_begin slide".$mlw_qmn_section_count."'>";
243
- $mlw_message_before = htmlspecialchars_decode($mlw_quiz_options->message_before, ENT_QUOTES);
244
- $mlw_message_before = apply_filters( 'mlw_qmn_template_variable_quiz_page', $mlw_message_before, $mlw_qmn_quiz_options_array);
245
- $mlw_display .= "<span class='mlw_qmn_message_before'>".$mlw_message_before."</span><br />";
246
- $mlw_display .= "<span name='mlw_error_message' id='mlw_error_message' class='qmn_error'></span><br />";
247
-
248
- if ($mlw_quiz_options->contact_info_location == 0)
249
- {
250
- $mlw_display .= mlwDisplayContactInfo($mlw_quiz_options);
251
- }
252
- $mlw_display .= "</div>";
253
-
254
- //Display the questions
255
- foreach($mlw_questions as $mlw_question) {
256
- if (is_serialized($mlw_question->question_settings) && is_array(@unserialize($mlw_question->question_settings)))
257
- {
258
- $mlw_question_settings = @unserialize($mlw_question->question_settings);
259
- }
260
- else
261
- {
262
- $mlw_question_settings = array();
263
- $mlw_question_settings['required'] = 1;
264
- }
265
- if ( !isset($mlw_question_settings['required']))
266
- {
267
- $mlw_question_settings['required'] = 1;
268
- }
269
- $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
270
- $mlw_display .= "<div class='quiz_section slide".$mlw_qmn_section_count."'>";
271
- if ($mlw_question->question_type == 0)
272
- {
273
- $mlw_display .= "<span class='mlw_qmn_question'>";
274
- $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
275
- if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
276
- $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
277
- $mlw_qmn_answer_array = $mlw_qmn_answer_arrays[$mlw_question->question_id];
278
- if (is_array($mlw_qmn_answer_array))
279
- {
280
- if ($mlw_quiz_options->randomness_order == 2)
281
- {
282
- shuffle($mlw_qmn_answer_array);
283
- }
284
- $mlw_answer_total = 0;
285
- foreach($mlw_qmn_answer_array as $mlw_qmn_answer_each)
286
- {
287
- $mlw_answer_total++;
288
- if ($mlw_qmn_answer_each[0] != "")
289
- {
290
- $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_".$mlw_answer_total."' value='".esc_attr($mlw_qmn_answer_each[0])."' /> <label for='question".$mlw_question->question_id."_".$mlw_answer_total."'>".htmlspecialchars_decode($mlw_qmn_answer_each[0], ENT_QUOTES)."</label>";
291
- $mlw_display .= "<br />";
292
- }
293
- }
294
- $mlw_display .= "<input type='radio' style='display: none;' name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_none' checked='checked' value='No Answer Provided' />";
295
- }
296
- else
297
- {
298
- if ($mlw_question->answer_one != "")
299
- {
300
- $mlw_display .= "<input type='radio' 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>";
301
- $mlw_display .= "<br />";
302
- }
303
- if ($mlw_question->answer_two != "")
304
- {
305
- $mlw_display .= "<input type='radio' 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>";
306
- $mlw_display .= "<br />";
307
- }
308
- if ($mlw_question->answer_three != "")
309
- {
310
- $mlw_display .= "<input type='radio' 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>";
311
- $mlw_display .= "<br />";
312
- }
313
- if ($mlw_question->answer_four != "")
314
- {
315
- $mlw_display .= "<input type='radio' 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>";
316
- $mlw_display .= "<br />";
317
- }
318
- if ($mlw_question->answer_five != "")
319
- {
320
- $mlw_display .= "<input type='radio' 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>";
321
- $mlw_display .= "<br />";
322
- }
323
- if ($mlw_question->answer_six != "")
324
- {
325
- $mlw_display .= "<input type='radio' 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>";
326
- $mlw_display .= "<br />";
327
- }
328
- }
329
- }
330
- elseif ($mlw_question->question_type == 4)
331
- {
332
- $mlw_display .= "<span class='mlw_qmn_question'>";
333
- $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
334
- if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
335
- $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
336
- $mlw_qmn_answer_array = $mlw_qmn_answer_arrays[$mlw_question->question_id];
337
- if (is_array($mlw_qmn_answer_array))
338
- {
339
- if ($mlw_quiz_options->randomness_order == 2)
340
- {
341
- shuffle($mlw_qmn_answer_array);
342
- }
343
- $mlw_answer_total = 0;
344
- foreach($mlw_qmn_answer_array as $mlw_qmn_answer_each)
345
- {
346
- $mlw_answer_total++;
347
- if ($mlw_qmn_answer_each[0] != "")
348
- {
349
- $mlw_display .= "<input type='hidden' name='question".$mlw_question->question_id."' value='This value does not matter' />";
350
- $mlw_display .= "<input type='checkbox' name='question".$mlw_question->question_id."_".$mlw_answer_total."' id='question".$mlw_question->question_id."_".$mlw_answer_total."' value='".esc_attr($mlw_qmn_answer_each[0])."' /> <label for='question".$mlw_question->question_id."_".$mlw_answer_total."'>".htmlspecialchars_decode($mlw_qmn_answer_each[0], ENT_QUOTES)."</label>";
351
- $mlw_display .= "<br />";
352
- }
353
- }
354
- }
355
- }
356
- elseif ($mlw_question->question_type == 10)
357
- {
358
- $mlw_display .= "<span class='mlw_qmn_question'>";
359
- $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
360
- if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
361
- $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
362
- $mlw_qmn_answer_array = $mlw_qmn_answer_arrays[$mlw_question->question_id];
363
- if (is_array($mlw_qmn_answer_array))
364
- {
365
- if ($mlw_quiz_options->randomness_order == 2)
366
- {
367
- shuffle($mlw_qmn_answer_array);
368
- }
369
- $mlw_answer_total = 0;
370
- foreach($mlw_qmn_answer_array as $mlw_qmn_answer_each)
371
- {
372
- $mlw_answer_total++;
373
- if ($mlw_qmn_answer_each[0] != "")
374
- {
375
- $mlw_display .= "<input type='hidden' name='question".$mlw_question->question_id."' value='This value does not matter' />";
376
- $mlw_display .= "<span class='mlw_horizontal_multiple'><input type='checkbox' name='question".$mlw_question->question_id."_".$mlw_answer_total."' id='question".$mlw_question->question_id."_".$mlw_answer_total."' value='".esc_attr($mlw_qmn_answer_each[0])."' /> <label for='question".$mlw_question->question_id."_".$mlw_answer_total."'>".htmlspecialchars_decode($mlw_qmn_answer_each[0], ENT_QUOTES)."&nbsp;</label></span>";
377
- }
378
- }
379
- }
380
- }
381
- elseif ($mlw_question->question_type == 1)
382
- {
383
- $mlw_display .= "<span class='mlw_qmn_question'>";
384
- $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
385
- if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
386
- $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
387
- $mlw_qmn_answer_array = $mlw_qmn_answer_arrays[$mlw_question->question_id];
388
- if (is_array($mlw_qmn_answer_array))
389
- {
390
- if ($mlw_quiz_options->randomness_order == 2)
391
- {
392
- shuffle($mlw_qmn_answer_array);
393
- }
394
- $mlw_answer_total = 0;
395
- foreach($mlw_qmn_answer_array as $mlw_qmn_answer_each)
396
- {
397
- $mlw_answer_total++;
398
- if ($mlw_qmn_answer_each[0] != "")
399
- {
400
- $mlw_display .= "<input type='radio' id='question".$mlw_question->question_id."_".$mlw_answer_total."' name='question".$mlw_question->question_id."' value='".esc_attr($mlw_qmn_answer_each[0])."' /> <label for='question".$mlw_question->question_id."_".$mlw_answer_total."'>".htmlspecialchars_decode($mlw_qmn_answer_each[0], ENT_QUOTES)."</label> ";
401
- }
402
- }
403
- $mlw_display .= "<input type='radio' style='display: none;' name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_none' checked='checked' value='No Answer Provided' />";
404
- }
405
- else
406
- {
407
- if ($mlw_question->answer_one != "")
408
- {
409
- $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='1' />".htmlspecialchars_decode($mlw_question->answer_one, ENT_QUOTES);
410
- }
411
- if ($mlw_question->answer_two != "")
412
- {
413
- $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='2' />".htmlspecialchars_decode($mlw_question->answer_two, ENT_QUOTES);
414
- }
415
- if ($mlw_question->answer_three != "")
416
- {
417
- $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='3' />".htmlspecialchars_decode($mlw_question->answer_three, ENT_QUOTES);
418
- }
419
- if ($mlw_question->answer_four != "")
420
- {
421
- $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='4' />".htmlspecialchars_decode($mlw_question->answer_four, ENT_QUOTES);
422
- }
423
- if ($mlw_question->answer_five != "")
424
- {
425
- $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='5' />".htmlspecialchars_decode($mlw_question->answer_five, ENT_QUOTES);
426
- }
427
- if ($mlw_question->answer_six != "")
428
- {
429
- $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='6' />".htmlspecialchars_decode($mlw_question->answer_six, ENT_QUOTES);
430
- }
431
- }
432
- $mlw_display .= "<br />";
433
- }
434
- elseif ($mlw_question->question_type == 2)
435
- {
436
- $mlw_display .= "<span class='mlw_qmn_question'>";
437
- $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
438
- if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
439
- $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
440
- $mlw_display .= "<select name='question".$mlw_question->question_id."'>";
441
- $mlw_qmn_answer_array = $mlw_qmn_answer_arrays[$mlw_question->question_id];
442
- if (is_array($mlw_qmn_answer_array))
443
- {
444
- if ($mlw_quiz_options->randomness_order == 2)
445
- {
446
- shuffle($mlw_qmn_answer_array);
447
- }
448
- $mlw_answer_total = 0;
449
- foreach($mlw_qmn_answer_array as $mlw_qmn_answer_each)
450
- {
451
- $mlw_answer_total++;
452
- if ($mlw_qmn_answer_each[0] != "")
453
- {
454
- $mlw_display .= "<option value='".esc_attr($mlw_qmn_answer_each[0])."'>".htmlspecialchars_decode($mlw_qmn_answer_each[0], ENT_QUOTES)."</option>";
455
- }
456
- }
457
- }
458
- else
459
- {
460
- if ($mlw_question->answer_one != "")
461
- {
462
- $mlw_display .= "<option value='1'>".htmlspecialchars_decode($mlw_question->answer_one, ENT_QUOTES)."</option>";
463
- }
464
- if ($mlw_question->answer_two != "")
465
- {
466
- $mlw_display .= "<option value='2'>".htmlspecialchars_decode($mlw_question->answer_two, ENT_QUOTES)."</option>";
467
- }
468
- if ($mlw_question->answer_three != "")
469
- {
470
- $mlw_display .= "<option value='3'>".htmlspecialchars_decode($mlw_question->answer_three, ENT_QUOTES)."</option>";
471
- }
472
- if ($mlw_question->answer_four != "")
473
- {
474
- $mlw_display .= "<option value='4'>".htmlspecialchars_decode($mlw_question->answer_four, ENT_QUOTES)."</option>";
475
- }
476
- if ($mlw_question->answer_five != "")
477
- {
478
- $mlw_display .= "<option value='5'>".htmlspecialchars_decode($mlw_question->answer_five, ENT_QUOTES)."</option>";
479
- }
480
- if ($mlw_question->answer_six != "")
481
- {
482
- $mlw_display .= "<option value='6'>".htmlspecialchars_decode($mlw_question->answer_six, ENT_QUOTES)."</option>";
483
- }
484
- }
485
- $mlw_display .= "</select>";
486
- $mlw_display .= "<br />";
487
- }
488
- elseif ($mlw_question->question_type == 5)
489
- {
490
- $mlw_display .= "<span class='mlw_qmn_question'>";
491
- $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
492
- if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
493
- $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
494
- if ($mlw_question_settings['required'] == 0) {$mlw_requireClass = "mlwRequiredText";} else {$mlw_requireClass = "";}
495
- $mlw_display .= "<textarea class='mlw_answer_open_text $mlw_requireClass' cols='70' rows='5' name='question".$mlw_question->question_id."' /></textarea>";
496
- $mlw_display .= "<br />";
497
- }
498
- elseif ($mlw_question->question_type == 6)
499
- {
500
- $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES);
501
- $mlw_display .= "<br />";
502
- }
503
- elseif ($mlw_question->question_type == 7)
504
- {
505
- $mlw_display .= "<span class='mlw_qmn_question'>";
506
- $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
507
- if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
508
- $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
509
- if ($mlw_question_settings['required'] == 0) {$mlw_requireClass = "mlwRequiredNumber";} else {$mlw_requireClass = "";}
510
- $mlw_display .= "<input type='number' class='mlw_answer_number $mlw_requireClass' name='question".$mlw_question->question_id."' />";
511
- $mlw_display .= "<br />";
512
- }
513
- elseif ($mlw_question->question_type == 8)
514
- {
515
- if ($mlw_question_settings['required'] == 0) {$mlw_requireClass = "mlwRequiredCheck";} else {$mlw_requireClass = "";}
516
- $mlw_display .= "<input type='checkbox' id='mlwAcceptance' class='$mlw_requireClass ' />";
517
- $mlw_display .= "<label for='mlwAcceptance'><span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span></label>";
518
- $mlw_display .= "<br />";
519
- }
520
- elseif ($mlw_question->question_type == 9)
521
- {
522
- if ($mlw_question_settings['required'] == 0) {$mlw_requireClass = "mlwRequiredCaptcha";} else {$mlw_requireClass = "";}
523
- $mlw_display .= "<div class='mlw_captchaWrap'>";
524
- $mlw_display .= "<canvas alt='' id='mlw_captcha' class='mlw_captcha' width='100' height='50'></canvas>";
525
- $mlw_display .= "</div>";
526
- $mlw_display .= "<span class='mlw_qmn_question'>";
527
- $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
528
- $mlw_display .= "<input type='text' class='mlw_answer_open_text $mlw_requireClass' id='mlw_captcha_text' name='mlw_user_captcha'/>";
529
- $mlw_display .= "<input type='hidden' name='mlw_code_captcha' id='mlw_code_captcha' value='none' />";
530
- $mlw_display .= "<br />";
531
- $mlw_display .= "<script>
532
- var mlw_code = '';
533
- var mlw_chars = '0123456789ABCDEFGHIJKL!@#$%^&*()MNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
534
- var mlw_code_length = 5;
535
- for (var i=0; i<mlw_code_length; i++) {
536
- var rnum = Math.floor(Math.random() * mlw_chars.length);
537
- mlw_code += mlw_chars.substring(rnum,rnum+1);
538
- }
539
- var mlw_captchaCTX = document.getElementById('mlw_captcha').getContext('2d');
540
- mlw_captchaCTX.font = 'normal 24px Verdana';
541
- mlw_captchaCTX.strokeStyle = '#000000';
542
- mlw_captchaCTX.clearRect(0,0,100,50);
543
- mlw_captchaCTX.strokeText(mlw_code,10,30,70);
544
- mlw_captchaCTX.textBaseline = 'middle';
545
- document.getElementById('mlw_code_captcha').value = mlw_code;
546
- </script>
547
- ";
548
- }
549
- else
550
- {
551
- $mlw_display .= "<span class='mlw_qmn_question'>";
552
- $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
553
- if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
554
- $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
555
- if ($mlw_question_settings['required'] == 0) {$mlw_requireClass = "mlwRequiredText";} else {$mlw_requireClass = "";}
556
- $mlw_display .= "<input type='text' class='mlw_answer_open_text $mlw_requireClass' name='question".$mlw_question->question_id."' />";
557
- $mlw_display .= "<br />";
558
- }
559
- if ($mlw_question->comments == 0)
560
- {
561
- $mlw_display .= "<input type='text' class='mlw_qmn_question_comment' x-webkit-speech id='mlwComment".$mlw_question->question_id."' name='mlwComment".$mlw_question->question_id."' value='".esc_attr(htmlspecialchars_decode($mlw_quiz_options->comment_field_text, ENT_QUOTES))."' onclick='clear_field(this)'/>";
562
- $mlw_display .= "<br />";
563
- }
564
- if ($mlw_question->comments == 2)
565
- {
566
- $mlw_display .= "<textarea cols='70' rows='5' class='mlw_qmn_question_comment' id='mlwComment".$mlw_question->question_id."' name='mlwComment".$mlw_question->question_id."' onclick='clear_field(this)'>".htmlspecialchars_decode($mlw_quiz_options->comment_field_text, ENT_QUOTES)."</textarea>";
567
- $mlw_display .= "<br />";
568
- }
569
- if ($mlw_question->hints != "")
570
- {
571
- $mlw_display .= "<span title=\"".htmlspecialchars_decode($mlw_question->hints, ENT_QUOTES)."\" class='mlw_qmn_hint_link'>Hint</span>";
572
- $mlw_display .= "<br /><br />";
573
- }
574
- $mlw_display .= "</div>";
575
- if ( $mlw_quiz_options->pagination == 0) { $mlw_display .= "<br />"; }
576
- }
577
-
578
- //Display comment box if needed
579
- if ($mlw_quiz_options->comment_section == 0)
580
- {
581
- $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
582
- $mlw_display .= "<div class='quiz_section slide".$mlw_qmn_section_count."'>";
583
- $mlw_message_comments = htmlspecialchars_decode($mlw_quiz_options->message_comment, ENT_QUOTES);
584
- $mlw_message_comments = apply_filters( 'mlw_qmn_template_variable_quiz_page', $mlw_message_comments, $mlw_qmn_quiz_options_array);
585
- $mlw_display .= "<label for='mlwQuizComments' class='mlw_qmn_comment_section_text'>".$mlw_message_comments."</label><br />";
586
- $mlw_display .= "<textarea cols='70' rows='15' id='mlwQuizComments' name='mlwQuizComments' ></textarea>";
587
- $mlw_display .= "</div>";
588
- if ( $mlw_quiz_options->pagination == 0) { $mlw_display .= "<br /><br />"; }
589
- }
590
- $mlw_display .= "<br />";
591
- $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
592
- $mlw_display .= "<div class='quiz_section slide".$mlw_qmn_section_count." quiz_end'>";
593
- if ($mlw_quiz_options->message_end_template != '')
594
- {
595
- $mlw_message_end = htmlspecialchars_decode($mlw_quiz_options->message_end_template, ENT_QUOTES);
596
- $mlw_message_end = apply_filters( 'mlw_qmn_template_variable_quiz_page', $mlw_message_end, $mlw_qmn_quiz_options_array);
597
- $mlw_display .= "<span class='mlw_qmn_message_end'>".$mlw_message_end."</span>";
598
- $mlw_display .= "<br /><br />";
599
- }
600
- if ($mlw_quiz_options->contact_info_location == 1)
601
- {
602
- $mlw_display .= mlwDisplayContactInfo($mlw_quiz_options);
603
- }
604
- ob_start();
605
- do_action('mlw_qmn_end_quiz_section');
606
- $mlw_display .= ob_get_contents();
607
- ob_end_clean();
608
- $mlw_display .= "<span style='display: none;'>If you are human, leave this field blank or you will be considered spam:</span>";
609
- $mlw_display .= "<input style='display: none;' type='text' name='email' id='email' />";
610
- $mlw_display .= "<input type='hidden' name='total_questions' id='total_questions' value='".$mlw_qmn_total_questions."'/>";
611
- $mlw_display .= "<input type='hidden' name='timer' id='timer' value='0'/>";
612
- $mlw_display .= "<input type='hidden' name='complete_quiz' value='confirmation' />";
613
- $mlw_display .= "<input type='submit' value='".esc_attr(htmlspecialchars_decode($mlw_quiz_options->submit_button_text, ENT_QUOTES))."' />";
614
- $mlw_display .= "<span name='mlw_error_message_bottom' id='mlw_error_message_bottom' class='qmn_error'></span><br />";
615
- $mlw_display .= "</form>";
616
- $mlw_display .= "</div>";
617
- $mlw_display .= "</div>";
618
-
619
- }
620
- //Display Completion Screen
621
- else
622
- {
623
- $mlw_display .= "<div id='top_of_results'></div>";
624
- $mlw_display .= "<script>
625
- window.location.hash='top_of_results';
626
- </script>";
627
- ?>
628
- <script type="text/javascript">
629
- window.sessionStorage.setItem('mlw_time_quiz<?php echo $mlw_quiz_id; ?>', 'completed');
630
- window.sessionStorage.setItem('mlw_started_quiz<?php echo $mlw_quiz_id; ?>', "no");
631
- </script>
632
- <?php
633
- if (empty($mlw_spam_email) && $mlw_qmn_isAllowed && ((!isset($_POST["mlw_code_captcha"])) || isset($_POST["mlw_code_captcha"]) && $_POST["mlw_user_captcha"] == $_POST["mlw_code_captcha"]))
634
- {
635
-
636
- //Load questions
637
- $sql = "SELECT * FROM " . $wpdb->prefix . "mlw_questions" . " WHERE quiz_id=".$mlw_quiz_id." AND deleted='0' ";
638
- if ($mlw_quiz_options->randomness_order == 0)
639
- {
640
- $sql .= "ORDER BY question_order ASC";
641
- }
642
- if ($mlw_quiz_options->randomness_order == 1 || $mlw_quiz_options->randomness_order == 2)
643
- {
644
- $sql .= "ORDER BY rand()";
645
- }
646
- $mlw_questions = $wpdb->get_results($sql);
647
-
648
- //Load and prepare answer arrays
649
- $mlw_qmn_loaded_answer_arrays = array();
650
- foreach($mlw_questions as $mlw_question_info) {
651
- if (is_serialized($mlw_question_info->answer_array) && is_array(@unserialize($mlw_question_info->answer_array)))
652
- {
653
- $mlw_qmn_answer_array_each = @unserialize($mlw_question_info->answer_array);
654
- $mlw_qmn_loaded_answer_arrays[$mlw_question_info->question_id] = $mlw_qmn_answer_array_each;
655
- }
656
- else
657
- {
658
- $mlw_answer_array_correct = array(0, 0, 0, 0, 0, 0);
659
- $mlw_answer_array_correct[$mlw_question_info->correct_answer-1] = 1;
660
- $mlw_qmn_loaded_answer_arrays[$mlw_question_info->question_id] = array(
661
- array($mlw_question_info->answer_one, $mlw_question_info->answer_one_points, $mlw_answer_array_correct[0]),
662
- array($mlw_question_info->answer_two, $mlw_question_info->answer_two_points, $mlw_answer_array_correct[1]),
663
- array($mlw_question_info->answer_three, $mlw_question_info->answer_three_points, $mlw_answer_array_correct[2]),
664
- array($mlw_question_info->answer_four, $mlw_question_info->answer_four_points, $mlw_answer_array_correct[3]),
665
- array($mlw_question_info->answer_five, $mlw_question_info->answer_five_points, $mlw_answer_array_correct[4]),
666
- array($mlw_question_info->answer_six, $mlw_question_info->answer_six_points, $mlw_answer_array_correct[5]));
667
- }
668
- }
669
-
670
- //Variables needed for scoring
671
- $mlw_points = 0;
672
- $mlw_correct = 0;
673
- $mlw_total_questions = 0;
674
- $mlw_total_score = 0;
675
- $mlw_question_answers = "";
676
- isset($_POST["total_questions"]) ? $mlw_total_questions = intval($_POST["total_questions"]) : $mlw_total_questions = 0;
677
-
678
- //Update the amount of times the quiz has been taken
679
- $mlw_taken = $mlw_quiz_options->quiz_taken;
680
- $mlw_taken += 1;
681
- $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET quiz_taken='".$mlw_taken."' WHERE quiz_id=".$mlw_quiz_id;
682
- $results = $wpdb->query( $update );
683
-
684
- //See which answers were correct and award points if necessary
685
- $mlw_user_text = "";
686
- $mlw_correct_text = "";
687
- $qmn_correct = "incorrect";
688
- $mlw_qmn_answer_array = array();
689
- foreach($mlw_questions as $mlw_question) {
690
- $mlw_user_text = "";
691
- $mlw_correct_text = "";
692
- $qmn_correct = "incorrect";
693
- if ( isset($_POST["question".$mlw_question->question_id]) || isset($_POST["mlwComment".$mlw_question->question_id]) )
694
- {
695
- if ( $mlw_question->question_type == 0 || $mlw_question->question_type == 1 || $mlw_question->question_type == 2)
696
- {
697
- if (isset($_POST["question".$mlw_question->question_id]))
698
- {
699
- $mlw_user_answer = $_POST["question".$mlw_question->question_id];
700
- }
701
- else
702
- {
703
- $mlw_user_answer = " ";
704
- }
705
- $mlw_qmn_question_answers_array = $mlw_qmn_loaded_answer_arrays[$mlw_question->question_id];
706
- foreach($mlw_qmn_question_answers_array as $mlw_qmn_question_answers_each)
707
- {
708
- if (htmlspecialchars(stripslashes($mlw_user_answer), ENT_QUOTES) == esc_attr($mlw_qmn_question_answers_each[0]))
709
- {
710
- $mlw_points += $mlw_qmn_question_answers_each[1];
711
- $mlw_user_text .= strval(htmlspecialchars_decode($mlw_qmn_question_answers_each[0], ENT_QUOTES));
712
- if ($mlw_qmn_question_answers_each[2] == 1)
713
- {
714
- $mlw_correct += 1;
715
- $qmn_correct = "correct";
716
- }
717
- }
718
- if ($mlw_qmn_question_answers_each[2] == 1)
719
- {
720
- $mlw_correct_text .= htmlspecialchars_decode($mlw_qmn_question_answers_each[0], ENT_QUOTES);
721
- }
722
- }
723
- }
724
- elseif ( $mlw_question->question_type == 3 || $mlw_question->question_type == 5 || $mlw_question->question_type == 7)
725
- {
726
- if (isset($_POST["question".$mlw_question->question_id]))
727
- {
728
- $mlw_user_answer = $_POST["question".$mlw_question->question_id];
729
- }
730
- else
731
- {
732
- $mlw_user_answer = " ";
733
- }
734
- $mlw_user_text .= strval(stripslashes(htmlspecialchars_decode($mlw_user_answer, ENT_QUOTES)));
735
- $mlw_qmn_question_answers_array = $mlw_qmn_loaded_answer_arrays[$mlw_question->question_id];
736
- foreach($mlw_qmn_question_answers_array as $mlw_qmn_question_answers_each)
737
- {
738
- $mlw_correct_text = strval(htmlspecialchars_decode($mlw_qmn_question_answers_each[0], ENT_QUOTES));
739
- if (strtoupper($mlw_user_text) == strtoupper($mlw_correct_text))
740
- {
741
- $mlw_correct += 1;
742
- $qmn_correct = "correct";
743
- $mlw_points += $mlw_qmn_question_answers_each[1];
744
- break;
745
- }
746
- }
747
- }
748
- elseif ( $mlw_question->question_type == 4 || $mlw_question->question_type == 10)
749
- {
750
- $mlw_qmn_user_correct_answers = 0;
751
- $mlw_qmn_total_correct_answers = 0;
752
- $mlw_qmn_question_answers_array = $mlw_qmn_loaded_answer_arrays[$mlw_question->question_id];
753
- $mlw_qmn_total_answers = count($mlw_qmn_question_answers_array);
754
- foreach($mlw_qmn_question_answers_array as $mlw_qmn_question_answers_each)
755
- {
756
- for ($i = 1; $i <= $mlw_qmn_total_answers; $i++) {
757
- if (isset($_POST["question".$mlw_question->question_id."_".$i]) && htmlspecialchars(stripslashes($_POST["question".$mlw_question->question_id."_".$i]), ENT_QUOTES) == esc_attr($mlw_qmn_question_answers_each[0]))
758
- {
759
- $mlw_points += $mlw_qmn_question_answers_each[1];
760
- $mlw_user_text .= strval(htmlspecialchars_decode($mlw_qmn_question_answers_each[0], ENT_QUOTES)).".";
761
- if ($mlw_qmn_question_answers_each[2] == 1)
762
- {
763
- $mlw_qmn_user_correct_answers += 1;
764
- }
765
- else
766
- {
767
- $mlw_qmn_user_correct_answers = -1;
768
- }
769
- }
770
- }
771
- if ($mlw_qmn_question_answers_each[2] == 1)
772
- {
773
- $mlw_correct_text .= htmlspecialchars_decode($mlw_qmn_question_answers_each[0], ENT_QUOTES).".";
774
- $mlw_qmn_total_correct_answers++;
775
- }
776
- }
777
- if ($mlw_qmn_user_correct_answers == $mlw_qmn_total_correct_answers)
778
- {
779
- $mlw_correct += 1;
780
- $qmn_correct = "correct";
781
- }
782
- }
783
- if (isset($_POST["mlwComment".$mlw_question->question_id]))
784
- {
785
- $mlw_qm_question_comment = $_POST["mlwComment".$mlw_question->question_id];
786
- }
787
- else
788
- {
789
- $mlw_qm_question_comment = "";
790
- }
791
-
792
- $mlw_question_answer_display = htmlspecialchars_decode($mlw_quiz_options->question_answer_template, ENT_QUOTES);
793
- $mlw_question_answer_display = str_replace( "%QUESTION%" , htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES), $mlw_question_answer_display);
794
- $mlw_question_answer_display = str_replace( "%USER_ANSWER%" , $mlw_user_text, $mlw_question_answer_display);
795
- $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER%" , $mlw_correct_text, $mlw_question_answer_display);
796
- $mlw_question_answer_display = str_replace( "%USER_COMMENTS%" , $mlw_qm_question_comment, $mlw_question_answer_display);
797
- $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER_INFO%" , htmlspecialchars_decode($mlw_question->question_answer_info, ENT_QUOTES), $mlw_question_answer_display);
798
-
799
- $mlw_qmn_answer_array[] = array($mlw_question->question_name, htmlspecialchars($mlw_user_text, ENT_QUOTES), htmlspecialchars($mlw_correct_text, ENT_QUOTES), htmlspecialchars(stripslashes($mlw_qm_question_comment), ENT_QUOTES), "correct" => $qmn_correct, "id" => $mlw_question->question_id);
800
-
801
- $mlw_question_answers .= $mlw_question_answer_display;
802
- $mlw_question_answers .= "<br />";
803
- }
804
- }
805
-
806
- //Calculate Total Percent Score And Average Points Only If Total Questions Doesn't Equal Zero To Avoid Division By Zero Error
807
- if ($mlw_total_questions != 0)
808
- {
809
- $mlw_total_score = round((($mlw_correct/$mlw_total_questions)*100), 2);
810
- $mlw_average_points = round(($mlw_points/$mlw_total_questions), 2);
811
- }
812
- else
813
- {
814
- $mlw_total_score = 0;
815
- $mlw_average_points = 0;
816
- }
817
-
818
- //Prepare comment section if set
819
- if (isset($_POST["mlwQuizComments"]))
820
- {
821
- $mlw_qm_quiz_comments = $_POST["mlwQuizComments"];
822
- }
823
- else
824
- {
825
- $mlw_qm_quiz_comments = "";
826
- }
827
-
828
- $mlw_qmn_result_array = array(
829
- 'quiz_id' => $mlw_quiz_id,
830
- 'quiz_name' => $mlw_quiz_options->quiz_name,
831
- 'quiz_system' => $mlw_quiz_options->system,
832
- 'total_points' => $mlw_points,
833
- 'total_score' => $mlw_total_score,
834
- 'total_correct' => $mlw_correct,
835
- 'total_questions' => $mlw_total_questions,
836
- 'user_name' => $mlw_user_name,
837
- 'user_business' => $mlw_user_comp,
838
- 'user_email' => $mlw_user_email,
839
- 'user_phone' => $mlw_user_phone,
840
- 'user_id' => get_current_user_id(),
841
- 'question_answers_display' => $mlw_question_answers,
842
- 'question_answers_array' => $mlw_qmn_answer_array,
843
- 'timer' => $mlw_qmn_timer,
844
- 'comments' => $mlw_qm_quiz_comments,
845
- 'certificate_link' => ''
846
- );
847
-
848
- //Prepare Certificate
849
- $mlw_certificate_link = "";
850
- if (is_serialized($mlw_quiz_options->certificate_template) && is_array(@unserialize($mlw_quiz_options->certificate_template)))
851
- {
852
- $mlw_certificate_options = unserialize($mlw_quiz_options->certificate_template);
853
- }
854
- else
855
- {
856
- $mlw_certificate_options = array('Enter title here', 'Enter text here', '', '', 1);
857
- }
858
- if ($mlw_certificate_options[4] == 0)
859
- {
860
- $mlw_message_certificate = $mlw_certificate_options[1];
861
- $mlw_message_certificate = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message_certificate, $mlw_qmn_result_array);
862
- $mlw_message_certificate = str_replace( "\n" , "<br>", $mlw_message_certificate);
863
- $mlw_plugindirpath = plugin_dir_path( __FILE__ );
864
- $plugindirpath=plugin_dir_path( __FILE__ );
865
- $mlw_qmn_certificate_file=<<<EOC
866
- <?php
867
- include("$plugindirpath/WriteHTML.php");
868
- \$pdf=new PDF_HTML();
869
- \$pdf->AddPage('L');
870
- EOC;
871
- $mlw_qmn_certificate_file.=$mlw_certificate_options[3] != '' ? '$pdf->Image("'.$mlw_certificate_options[3].'",0,0,$pdf->w, $pdf->h);' : '';
872
- $mlw_qmn_certificate_file.=<<<EOC
873
- \$pdf->Ln(20);
874
- \$pdf->SetFont('Arial','B',24);
875
- \$pdf->MultiCell(280,20,'$mlw_certificate_options[0]',0,'C');
876
- \$pdf->Ln(15);
877
- \$pdf->SetFont('Arial','',16);
878
- \$pdf->WriteHTML("<p align='center'>$mlw_message_certificate</p>");
879
- EOC;
880
- $mlw_qmn_certificate_file.=$mlw_certificate_options[2] != '' ? '$pdf->Image("'.$mlw_certificate_options[2].'",110,130);' : '';
881
- $mlw_qmn_certificate_file.=<<<EOC
882
- \$pdf->Output('mlw_qmn_certificate.pdf','D');
883
- unlink(__FILE__);
884
- EOC;
885
- $mlw_qmn_certificate_filename = str_replace(home_url()."/", '', plugin_dir_url( __FILE__ ))."certificates/mlw_qmn_quiz".date("YmdHis").$mlw_qmn_timer.".php";
886
- file_put_contents($mlw_qmn_certificate_filename, $mlw_qmn_certificate_file);
887
- $mlw_qmn_certificate_filename = plugin_dir_url( __FILE__ )."certificates/mlw_qmn_quiz".date("YmdHis").$mlw_qmn_timer.".php";
888
- $mlw_qmn_result_array["certificate_link"] = "<a href='".$mlw_qmn_certificate_filename."' class='qmn_certificate_link'>Download Certificate</a>";
889
- }
890
-
891
- /*
892
- Prepare the landing page
893
- -First, unserialize message_after column
894
- -Second, check for array in case user has not updated
895
- Message array = (array( bottomvalue, topvalue, text),array( bottomvalue, topvalue, text), etc..., array(0,0,text))
896
- */
897
- if (is_serialized($mlw_quiz_options->message_after) && is_array(@unserialize($mlw_quiz_options->message_after)))
898
- {
899
- $mlw_message_after_array = @unserialize($mlw_quiz_options->message_after);
900
- //Cycle through landing pages
901
- foreach($mlw_message_after_array as $mlw_each)
902
- {
903
- //Check to see if default
904
- if ($mlw_each[0] == 0 && $mlw_each[1] == 0)
905
- {
906
- $mlw_message_after = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
907
- $mlw_message_after = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message_after, $mlw_qmn_result_array);
908
- $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
909
- $mlw_display .= $mlw_message_after;
910
- break;
911
- }
912
- else
913
- {
914
- //Check to see if points fall in correct range
915
- if ($mlw_quiz_options->system == 1 && $mlw_points >= $mlw_each[0] && $mlw_points <= $mlw_each[1])
916
- {
917
- $mlw_message_after = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
918
- $mlw_message_after = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message_after, $mlw_qmn_result_array);
919
- $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
920
- $mlw_display .= $mlw_message_after;
921
- break;
922
- }
923
- //Check to see if score fall in correct range
924
- if ($mlw_quiz_options->system == 0 && $mlw_total_score >= $mlw_each[0] && $mlw_total_score <= $mlw_each[1])
925
- {
926
- $mlw_message_after = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
927
- $mlw_message_after = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message_after, $mlw_qmn_result_array);
928
- $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
929
- $mlw_display .= $mlw_message_after;
930
- break;
931
- }
932
- }
933
- }
934
- }
935
- else
936
- {
937
- //Prepare the after quiz message
938
- $mlw_message_after = htmlspecialchars_decode($mlw_quiz_options->message_after, ENT_QUOTES);
939
- $mlw_message_after = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message_after, $mlw_qmn_result_array);
940
- $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
941
- $mlw_display .= $mlw_message_after;
942
- }
943
-
944
- if ($mlw_quiz_options->social_media == 1)
945
- {
946
- wp_enqueue_script( 'qmn_quiz_social_share', plugins_url( 'qmn_social_share.js' , __FILE__ ) );
947
-
948
- //Load Social Media Text
949
- $qmn_social_media_text = "";
950
- if (is_serialized($mlw_quiz_options->social_media_text) && is_array(@unserialize($mlw_quiz_options->social_media_text)))
951
- {
952
- $qmn_social_media_text = @unserialize($mlw_quiz_options->social_media_text);
953
- }
954
- else
955
- {
956
- $qmn_social_media_text = array(
957
- 'twitter' => $mlw_quiz_options->social_media_text,
958
- 'facebook' => $mlw_quiz_options->social_media_text
959
- );
960
- }
961
- $qmn_social_media_text["twitter"] = apply_filters( 'mlw_qmn_template_variable_results_page', $qmn_social_media_text["twitter"], $mlw_qmn_result_array);
962
- $qmn_social_media_text["facebook"] = apply_filters( 'mlw_qmn_template_variable_results_page', $qmn_social_media_text["facebook"], $mlw_qmn_result_array);
963
- $mlw_display .= "<br />
964
- <a class=\"mlw_qmn_quiz_link\" onclick=\"mlw_qmn_share('facebook', '".esc_js($qmn_social_media_text["facebook"])."', '".esc_js($mlw_quiz_options->quiz_name)."');\">Facebook</a>
965
- <a class=\"mlw_qmn_quiz_link\" onclick=\"mlw_qmn_share('twitter', '".esc_js($qmn_social_media_text["twitter"])."', '".esc_js($mlw_quiz_options->quiz_name)."');\">Twitter</a>
966
- <br />";
967
- }
968
-
969
- //Switch email type to HTML
970
- add_filter( 'wp_mail_content_type', 'mlw_qmn_set_html_content_type' );
971
-
972
- /*
973
- Prepare and send the user email
974
- - First, check to see if user_email_template is the newer array format, if not use it as the template
975
- - If it is an array, check to see if the score meets the parameter of one of the templates. If, not send the default
976
- */
977
- $mlw_message = "";
978
- if ($mlw_quiz_options->send_user_email == "0")
979
- {
980
- if ($mlw_user_email != "")
981
- {
982
- if (is_serialized($mlw_quiz_options->user_email_template) && is_array(@unserialize($mlw_quiz_options->user_email_template)))
983
- {
984
- $mlw_user_email_array = @unserialize($mlw_quiz_options->user_email_template);
985
-
986
- //Cycle through landing pages
987
- foreach($mlw_user_email_array as $mlw_each)
988
- {
989
-
990
- //Generate Email Subject
991
- if (!isset($mlw_each[3]))
992
- {
993
- $mlw_each[3] = "Quiz Results For %QUIZ_NAME";
994
- }
995
- $mlw_each[3] = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_each[3], $mlw_qmn_result_array);
996
-
997
- //Check to see if default
998
- if ($mlw_each[0] == 0 && $mlw_each[1] == 0)
999
- {
1000
- $mlw_message = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
1001
- $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $mlw_qmn_result_array);
1002
- $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
1003
- $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
1004
- $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
1005
- $mlw_headers = 'From: '.$mlw_quiz_options->email_from_text.' <'.$mlw_quiz_options->admin_email.'>' . "\r\n";
1006
- wp_mail($mlw_user_email, $mlw_each[3], $mlw_message, $mlw_headers);
1007
- break;
1008
- }
1009
- else
1010
- {
1011
- //Check to see if points fall in correct range
1012
- if ($mlw_quiz_options->system == 1 && $mlw_points >= $mlw_each[0] && $mlw_points <= $mlw_each[1])
1013
- {
1014
- $mlw_message = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
1015
- $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $mlw_qmn_result_array);
1016
- $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
1017
- $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
1018
- $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
1019
- $mlw_headers = 'From: '.$mlw_quiz_options->email_from_text.' <'.$mlw_quiz_options->admin_email.'>' . "\r\n";
1020
- wp_mail($mlw_user_email, $mlw_each[3], $mlw_message, $mlw_headers);
1021
- break;
1022
- }
1023
-
1024
- //Check to see if score fall in correct range
1025
- if ($mlw_quiz_options->system == 0 && $mlw_total_score >= $mlw_each[0] && $mlw_total_score <= $mlw_each[1])
1026
- {
1027
- $mlw_message = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
1028
- $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $mlw_qmn_result_array);
1029
- $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
1030
- $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
1031
- $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
1032
- $mlw_headers = 'From: '.$mlw_quiz_options->email_from_text.' <'.$mlw_quiz_options->admin_email.'>' . "\r\n";
1033
- wp_mail($mlw_user_email, $mlw_each[3], $mlw_message, $mlw_headers);
1034
- break;
1035
- }
1036
- }
1037
- }
1038
- }
1039
- else
1040
- {
1041
- $mlw_message = htmlspecialchars_decode($mlw_quiz_options->user_email_template, ENT_QUOTES);
1042
- $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $mlw_qmn_result_array);
1043
- $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
1044
- $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
1045
- $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
1046
- $mlw_headers = 'From: '.$mlw_quiz_options->email_from_text.' <'.$mlw_quiz_options->admin_email.'>' . "\r\n";
1047
- wp_mail($mlw_user_email, "Quiz Results For ".$mlw_quiz_options->quiz_name, $mlw_message, $mlw_headers);
1048
- }
1049
- }
1050
- }
1051
-
1052
- //Prepare and send the admin email
1053
- $mlw_message = "";
1054
- if ($mlw_quiz_options->send_admin_email == "0")
1055
- {
1056
- if ($mlw_quiz_options->admin_email != "")
1057
- {
1058
- $mlw_message = "";
1059
- $mlw_subject = "";
1060
- if (is_serialized($mlw_quiz_options->admin_email_template) && is_array(@unserialize($mlw_quiz_options->admin_email_template)))
1061
- {
1062
- $mlw_admin_email_array = @unserialize($mlw_quiz_options->admin_email_template);
1063
-
1064
- //Cycle through landing pages
1065
- foreach($mlw_admin_email_array as $mlw_each)
1066
- {
1067
-
1068
- //Generate Email Subject
1069
- if (!isset($mlw_each["subject"]))
1070
- {
1071
- $mlw_each["subject"] = "Quiz Results For %QUIZ_NAME";
1072
- }
1073
- $mlw_each["subject"] = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_each["subject"], $mlw_qmn_result_array);
1074
-
1075
- //Check to see if default
1076
- if ($mlw_each["begin_score"] == 0 && $mlw_each["end_score"] == 0)
1077
- {
1078
- $mlw_message = htmlspecialchars_decode($mlw_each["message"], ENT_QUOTES);
1079
- $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $mlw_qmn_result_array);
1080
- $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
1081
- $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
1082
- $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
1083
- $mlw_subject = $mlw_each["subject"];
1084
- break;
1085
- }
1086
- else
1087
- {
1088
- //Check to see if points fall in correct range
1089
- if ($mlw_quiz_options->system == 1 && $mlw_points >= $mlw_each["begin_score"] && $mlw_points <= $mlw_each["end_score"])
1090
- {
1091
- $mlw_message = htmlspecialchars_decode($mlw_each["message"], ENT_QUOTES);
1092
- $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $mlw_qmn_result_array);
1093
- $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
1094
- $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
1095
- $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
1096
- $mlw_subject = $mlw_each["subject"];
1097
- break;
1098
- }
1099
-
1100
- //Check to see if score fall in correct range
1101
- if ($mlw_quiz_options->system == 0 && $mlw_total_score >= $mlw_each["begin_score"] && $mlw_total_score <= $mlw_each["end_score"])
1102
- {
1103
- $mlw_message = htmlspecialchars_decode($mlw_each["message"], ENT_QUOTES);
1104
- $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $mlw_qmn_result_array);
1105
- $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
1106
- $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
1107
- $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
1108
- $mlw_subject = $mlw_each["subject"];
1109
- break;
1110
- }
1111
- }
1112
- }
1113
- }
1114
- else
1115
- {
1116
- $mlw_message = htmlspecialchars_decode($mlw_quiz_options->admin_email_template, ENT_QUOTES);
1117
- $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $mlw_qmn_result_array);
1118
- $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
1119
- $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
1120
- $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
1121
- $mlw_subject = "Quiz Results For ".$mlw_quiz_options->quiz_name;
1122
- }
1123
- }
1124
- if ( get_option('mlw_advert_shows') == 'true' ) {$mlw_message .= "<br>This email was generated by the Quiz Master Next script by Frank Corso";}
1125
- $mlw_headers = 'From: '.$mlw_quiz_options->email_from_text.' <'.$mlw_quiz_options->admin_email.'>' . "\r\n";
1126
- $mlw_qmn_admin_emails = explode(",", $mlw_quiz_options->admin_email);
1127
- foreach($mlw_qmn_admin_emails as $admin_email)
1128
- {
1129
- wp_mail($admin_email, $mlw_subject, $mlw_message, $mlw_headers);
1130
- }
1131
- }
1132
-
1133
- //Remove HTML type for emails
1134
- remove_filter( 'wp_mail_content_type', 'mlw_qmn_set_html_content_type' );
1135
-
1136
- //Save the results into database
1137
- $mlw_quiz_results_array = array( intval($mlw_qmn_timer), $mlw_qmn_answer_array, htmlspecialchars(stripslashes($mlw_qm_quiz_comments), ENT_QUOTES));
1138
- $mlw_quiz_results = serialize($mlw_quiz_results_array);
1139
-
1140
- global $wpdb;
1141
- $table_name = $wpdb->prefix . "mlw_results";
1142
- $results = $wpdb->query( $wpdb->prepare( "INSERT INTO " . $table_name . " (result_id, quiz_id, quiz_name, quiz_system, point_score, correct_score, correct, total, name, business, email, phone, user, time_taken, time_taken_real, quiz_results, deleted) VALUES (NULL, %d, '%s', %d, %d, %d, %d, %d, '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', 0)", $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, get_current_user_id(), date("h:i:s A m/d/Y"), date("Y-m-d H:i:s"), $mlw_quiz_results) );
1143
-
1144
- //Integration Action
1145
- do_action('mlw_qmn_load_results_page', $wpdb->insert_id, $mlw_quiz_options->quiz_settings);
1146
- }
1147
- else
1148
- {
1149
- if (!$mlw_qmn_isAllowed)
1150
- {
1151
- $current_user = wp_get_current_user();
1152
- $mlw_message = htmlspecialchars_decode($mlw_quiz_options->total_user_tries_text, ENT_QUOTES);
1153
- $mlw_message = apply_filters( 'mlw_qmn_template_variable_quiz_page', $mlw_message, $mlw_qmn_quiz_options_array);
1154
- $mlw_display .= $mlw_message;
1155
- }
1156
- elseif (isset($_POST["mlw_code_captcha"]) && $_POST["mlw_user_captcha"] != $_POST["mlw_code_captcha"])
1157
- {
1158
- $mlw_display .= "There was an issue with the captcha verification. Please try again.";
1159
- }
1160
- else { $mlw_display .= "Thank you."; }
1161
- }
1162
- }
1163
- return $mlw_display;
1164
- }
1165
-
1166
-
1167
- /*
1168
- This function displays fields to ask for contact information
1169
- */
1170
- function mlwDisplayContactInfo($mlw_quiz_options)
1171
- {
1172
- $mlw_contact_display = "";
1173
- //Check to see if user is logged in, then ask for contact if not
1174
- if ( is_user_logged_in() )
1175
- {
1176
- //If this quiz does not let user edit contact information we hide this section
1177
- if ($mlw_quiz_options->loggedin_user_contact == 1)
1178
- {
1179
- $mlw_contact_display .= "<div style='display:none;'>";
1180
- }
1181
-
1182
- //Retrieve current user information and save into text fields for contact information
1183
- $current_user = wp_get_current_user();
1184
- if ($mlw_quiz_options->user_name != 2)
1185
- {
1186
- $mlw_contact_class = "class=\"\"";
1187
- if ($mlw_quiz_options->user_name == 1)
1188
- {
1189
- $mlw_contact_class = "class=\"mlwRequiredText\"";
1190
- }
1191
- $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->name_field_text, ENT_QUOTES)."</span><br />";
1192
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserName' value='".$current_user->display_name."' />";
1193
- $mlw_contact_display .= "<br /><br />";
1194
-
1195
- }
1196
- if ($mlw_quiz_options->user_comp != 2)
1197
- {
1198
- $mlw_contact_class = "class=\"\"";
1199
- if ($mlw_quiz_options->user_comp == 1)
1200
- {
1201
- $mlw_contact_class = "class=\"mlwRequiredText\"";
1202
- }
1203
- $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->business_field_text, ENT_QUOTES)."</span><br />";
1204
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserComp' value='' />";
1205
- $mlw_contact_display .= "<br /><br />";
1206
- }
1207
- if ($mlw_quiz_options->user_email != 2)
1208
- {
1209
- $mlw_contact_class = "class=\"mlwEmail\"";
1210
- if ($mlw_quiz_options->user_email == 1)
1211
- {
1212
- $mlw_contact_class = "class=\"mlwEmail mlwRequiredText\"";
1213
- }
1214
- $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->email_field_text, ENT_QUOTES)."</span><br />";
1215
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserEmail' value='".$current_user->user_email."' />";
1216
- $mlw_contact_display .= "<br /><br />";
1217
- }
1218
- if ($mlw_quiz_options->user_phone != 2)
1219
- {
1220
- $mlw_contact_class = "class=\"\"";
1221
- if ($mlw_quiz_options->user_phone == 1)
1222
- {
1223
- $mlw_contact_class = "class=\"mlwRequiredText\"";
1224
- }
1225
- $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->phone_field_text, ENT_QUOTES)."</span><br />";
1226
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserPhone' value='' />";
1227
- $mlw_contact_display .= "<br /><br />";
1228
- }
1229
-
1230
- //End of hidden section div
1231
- if ($mlw_quiz_options->loggedin_user_contact == 1)
1232
- {
1233
- $mlw_contact_display .= "</div>";
1234
- }
1235
- }
1236
- else
1237
- {
1238
- //See if the site wants to ask for any contact information, then ask for it
1239
- if ($mlw_quiz_options->user_name != 2)
1240
- {
1241
- $mlw_contact_class = "class=\"\"";
1242
- if ($mlw_quiz_options->user_name == 1)
1243
- {
1244
- $mlw_contact_class = "class=\"mlwRequiredText\"";
1245
- }
1246
- $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->name_field_text, ENT_QUOTES)."</span><br />";
1247
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserName' value='' />";
1248
- $mlw_contact_display .= "<br /><br />";
1249
- }
1250
- if ($mlw_quiz_options->user_comp != 2)
1251
- {
1252
- $mlw_contact_class = "class=\"\"";
1253
- if ($mlw_quiz_options->user_comp == 1)
1254
- {
1255
- $mlw_contact_class = "class=\"mlwRequiredText\"";
1256
- }
1257
- $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->business_field_text, ENT_QUOTES)."</span><br />";
1258
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserComp' value='' />";
1259
- $mlw_contact_display .= "<br /><br />";
1260
- }
1261
- if ($mlw_quiz_options->user_email != 2)
1262
- {
1263
- $mlw_contact_class = "class=\"mlwEmail\"";
1264
- if ($mlw_quiz_options->user_email == 1)
1265
- {
1266
- $mlw_contact_class = "class=\"mlwEmail mlwRequiredText\"";
1267
- }
1268
- $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->email_field_text, ENT_QUOTES)."</span><br />";
1269
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserEmail' value='' />";
1270
- $mlw_contact_display .= "<br /><br />";
1271
- }
1272
- if ($mlw_quiz_options->user_phone != 2)
1273
- {
1274
- $mlw_contact_class = "class=\"\"";
1275
- if ($mlw_quiz_options->user_phone == 1)
1276
- {
1277
- $mlw_contact_class = "class=\"mlwRequiredText\"";
1278
- }
1279
- $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->phone_field_text, ENT_QUOTES)."</span><br />";
1280
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserPhone' value='' />";
1281
- $mlw_contact_display .= "<br /><br />";
1282
- }
1283
- }
1284
- return $mlw_contact_display;
1285
- }
1286
-
1287
- /*
1288
- This function helps set the email type to HTML
1289
- */
1290
- function mlw_qmn_set_html_content_type() {
1291
-
1292
- return 'text/html';
1293
- }
1294
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/mlw_quiz_admin.php DELETED
@@ -1,355 +0,0 @@
1
- <?php
2
- /*
3
- This page lists all the quizzes currently on the website and allows you to create more quizzes.
4
- */
5
- /*
6
- Copyright 2013, My Local Webstop (email : fpcorso@mylocalwebstop.com)
7
- */
8
-
9
- function mlw_generate_quiz_admin()
10
- {
11
- global $wpdb;
12
- global $mlwQuizMasterNext;
13
- $table_name = $wpdb->prefix . "mlw_quizzes";
14
-
15
- //Create new quiz
16
- if ( isset( $_POST["create_quiz"] ) && $_POST["create_quiz"] == "confirmation" )
17
- {
18
- $quiz_name = htmlspecialchars($_POST["quiz_name"], ENT_QUOTES);
19
- $mlwQuizMasterNext->quizCreator->create_quiz($quiz_name);
20
- }
21
-
22
- //Delete quiz
23
- if (isset( $_POST["delete_quiz"] ) && $_POST["delete_quiz"] == "confirmation")
24
- {
25
- $mlw_quiz_id = intval($_POST["quiz_id"]);
26
- $quiz_name = $_POST["delete_quiz_name"];
27
- $mlwQuizMasterNext->quizCreator->delete_quiz($mlw_quiz_id, $quiz_name);
28
- }
29
-
30
- //Edit Quiz Name
31
- if (isset($_POST["quiz_name_editted"]) && $_POST["quiz_name_editted"] == "confirmation")
32
- {
33
- $mlw_edit_quiz_id = intval($_POST["edit_quiz_id"]);
34
- $mlw_edit_quiz_name = htmlspecialchars($_POST["edit_quiz_name"], ENT_QUOTES);
35
- $mlwQuizMasterNext->quizCreator->edit_quiz_name($mlw_edit_quiz_id, $mlw_edit_quiz_name);
36
- }
37
-
38
- //Duplicate Quiz
39
- if (isset($_POST["duplicate_quiz"]) && $_POST["duplicate_quiz"] == "confirmation")
40
- {
41
- $mlw_duplicate_quiz_id = intval($_POST["duplicate_quiz_id"]);
42
- $mlw_duplicate_quiz_name = htmlspecialchars($_POST["duplicate_new_quiz_name"], ENT_QUOTES);
43
- $mlwQuizMasterNext->quizCreator->duplicate_quiz($mlw_duplicate_quiz_id, $mlw_duplicate_quiz_name, isset($_POST["duplicate_questions"]));
44
- }
45
-
46
- //Retrieve list of quizzes
47
- global $wpdb;
48
- $mlw_qmn_table_limit = 25;
49
- $mlw_qmn_quiz_count = $wpdb->get_var( "SELECT COUNT(quiz_id) FROM " . $wpdb->prefix . "mlw_quizzes WHERE deleted='0'" );
50
-
51
- if( isset($_GET{'mlw_quiz_page'} ) )
52
- {
53
- $mlw_qmn_quiz_page = $_GET{'mlw_quiz_page'} + 1;
54
- $mlw_qmn_quiz_begin = $mlw_qmn_table_limit * $mlw_qmn_quiz_page ;
55
- }
56
- else
57
- {
58
- $mlw_qmn_quiz_page = 0;
59
- $mlw_qmn_quiz_begin = 0;
60
- }
61
- $mlw_qmn_quiz_left = $mlw_qmn_quiz_count - ($mlw_qmn_quiz_page * $mlw_qmn_table_limit);
62
- $mlw_quiz_data = $wpdb->get_results( $wpdb->prepare( "SELECT quiz_id, quiz_name, quiz_views, quiz_taken, last_activity
63
- FROM " . $wpdb->prefix . "mlw_quizzes WHERE deleted='0'
64
- ORDER BY quiz_id DESC LIMIT %d, %d", $mlw_qmn_quiz_begin, $mlw_qmn_table_limit ) );
65
- ?>
66
- <!-- css -->
67
- <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
68
- <script type="text/javascript"
69
- src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
70
- </script>
71
- <!-- jquery scripts -->
72
- <?php
73
- wp_enqueue_script( 'jquery' );
74
- wp_enqueue_script( 'jquery-ui-core' );
75
- wp_enqueue_script( 'jquery-ui-dialog' );
76
- wp_enqueue_script( 'jquery-ui-button' );
77
- wp_enqueue_script( 'jquery-effects-blind' );
78
- wp_enqueue_script( 'jquery-effects-explode' );
79
- ?>
80
- <script type="text/javascript">
81
- var $j = jQuery.noConflict();
82
- // increase the default animation speed to exaggerate the effect
83
- $j.fx.speeds._default = 1000;
84
- $j(function() {
85
- $j('#new_quiz_dialog').dialog({
86
- autoOpen: false,
87
- show: 'blind',
88
- width:700,
89
- hide: 'explode',
90
- buttons: {
91
- Cancel: function() {
92
- $j(this).dialog('close');
93
- }
94
- }
95
- });
96
-
97
- $j('#new_quiz_button').click(function() {
98
- $j('#new_quiz_dialog').dialog('open');
99
- return false;
100
- } );
101
- $j('#new_quiz_button_two').click(function() {
102
- $j('#new_quiz_dialog').dialog('open');
103
- return false;
104
- } );
105
- });
106
- function deleteQuiz(id,quizName){
107
- $j("#delete_dialog").dialog({
108
- autoOpen: false,
109
- show: 'blind',
110
- hide: 'explode',
111
- buttons: {
112
- Cancel: function() {
113
- $j(this).dialog('close');
114
- }
115
- }
116
- });
117
- $j("#delete_dialog").dialog('open');
118
- var idText = document.getElementById("delete_quiz_id");
119
- var idHidden = document.getElementById("quiz_id");
120
- var idHiddenName = document.getElementById("delete_quiz_name");
121
- idText.innerHTML = id;
122
- idHidden.value = id;
123
- idHiddenName.value = quizName;
124
- };
125
- function editQuizName(id, quizName){
126
- $j("#edit_dialog").dialog({
127
- autoOpen: false,
128
- show: 'blind',
129
- hide: 'explode',
130
- buttons: {
131
- Cancel: function() {
132
- $j(this).dialog('close');
133
- }
134
- }
135
- });
136
- $j("#edit_dialog").dialog('open');
137
- document.getElementById("edit_quiz_name").value = quizName;
138
- document.getElementById("edit_quiz_id"). value = id;
139
- }
140
- function duplicateQuiz(id, quizName){
141
- $j("#duplicate_dialog").dialog({
142
- autoOpen: false,
143
- show: 'blind',
144
- hide: 'explode',
145
- buttons: {
146
- Cancel: function() {
147
- $j(this).dialog('close');
148
- }
149
- }
150
- });
151
- $j("#duplicate_dialog").dialog('open');
152
- document.getElementById("duplicate_quiz_name").innerHTML = quizName;
153
- document.getElementById("duplicate_quiz_id"). value = id;
154
- }
155
- </script>
156
- <style type="text/css">
157
- div.mlw_quiz_options input[type='text'] {
158
- border-color:#000000;
159
- color:#3300CC;
160
- cursor:hand;
161
- }
162
- </style>
163
- <style>
164
- .linkOptions
165
- {
166
- font-size: 14px !important;
167
- }
168
- .linkDelete
169
- {
170
- color: red !important;
171
- }
172
- .linkOptions:hover
173
- {
174
- background-color: black;
175
- }
176
- </style>
177
- <div class="wrap">
178
- <div class='mlw_quiz_options'>
179
- <h2>Quizzes<a id="new_quiz_button" href="javascript:();" class="add-new-h2">Add New</a></h2>
180
- <?php $mlwQuizMasterNext->alertManager->showAlerts(); ?>
181
- <div style="width: 85%; float: left;">
182
- <div class="tablenav top">
183
- <div class="tablenav-pages">
184
- <span class="displaying-num"><?php echo $mlw_qmn_quiz_count; ?> quizzes</span>
185
- <span class="pagination-links">
186
- <?php
187
- $mlw_qmn_previous_page = 0;
188
- $mlw_current_page = $mlw_qmn_quiz_page+1;
189
- $mlw_total_pages = ceil($mlw_qmn_quiz_count/$mlw_qmn_table_limit);
190
- if( $mlw_qmn_quiz_page > 0 )
191
- {
192
- $mlw_qmn_previous_page = $mlw_qmn_quiz_page - 2;
193
- echo "<a class=\"prev-page\" title=\"Go to the previous page\" href=\"?page=quiz-master-next/mlw_quizmaster2.php&&mlw_quiz_page=$mlw_qmn_previous_page\"><</a>";
194
- echo "<span class=\"paging-input\">$mlw_current_page of $mlw_total_pages</span>";
195
- if( $mlw_qmn_quiz_left > $mlw_qmn_table_limit )
196
- {
197
- echo "<a class=\"next-page\" title=\"Go to the next page\" href=\"?page=quiz-master-next/mlw_quizmaster2.php&&mlw_quiz_page=$mlw_qmn_quiz_page\">></a>";
198
- }
199
- else
200
- {
201
- echo "<a class=\"next-page disabled\" title=\"Go to the next page\" href=\"?page=quiz-master-next/mlw_quizmaster2.php&&mlw_quiz_page=$mlw_qmn_quiz_page\">></a>";
202
- }
203
- }
204
- else if( $mlw_qmn_quiz_page == 0 )
205
- {
206
- if( $mlw_qmn_quiz_left > $mlw_qmn_table_limit )
207
- {
208
- echo "<a class=\"prev-page disabled\" title=\"Go to the previous page\" href=\"?page=quiz-master-next/mlw_quizmaster2.php&&mlw_quiz_page=$mlw_qmn_previous_page\"><</a>";
209
- echo "<span class=\"paging-input\">$mlw_current_page of $mlw_total_pages</span>";
210
- echo "<a class=\"next-page\" title=\"Go to the next page\" href=\"?page=quiz-master-next/mlw_quizmaster2.php&&mlw_quiz_page=$mlw_qmn_quiz_page\">></a>";
211
- }
212
- }
213
- else if( $mlw_qmn_quiz_left < $mlw_qmn_table_limit )
214
- {
215
- $mlw_qmn_previous_page = $mlw_qmn_quiz_page - 2;
216
- echo "<a class=\"prev-page\" title=\"Go to the previous page\" href=\"?page=quiz-master-next/mlw_quizmaster2.php&&mlw_quiz_page=$mlw_qmn_previous_page\"><</a>";
217
- echo "<span class=\"paging-input\">$mlw_current_page of $mlw_total_pages</span>";
218
- echo "<a class=\"next-page disabled\" title=\"Go to the next page\" href=\"?page=quiz-master-next/mlw_quizmaster2.php&&mlw_quiz_page=$mlw_qmn_quiz_page\">></a>";
219
- }
220
- ?>
221
- </span>
222
- <br class="clear">
223
- </div>
224
- </div>
225
- <table class="widefat">
226
- <thead>
227
- <tr>
228
- <th>Quiz ID</th>
229
- <th>Quiz Name</th>
230
- <th>Quiz Shortcode</th>
231
- <th>Leaderboard Shortcode</th>
232
- <th>Quiz Views</th>
233
- <th>Quiz Taken</th>
234
- <th>Last Modified</th>
235
- </tr>
236
- </thead>
237
- <tbody id="the-list">
238
- <?php
239
- $quotes_list = "";
240
- $display = "";
241
- $alternate = "";
242
- foreach($mlw_quiz_data as $mlw_quiz_info) {
243
- if($alternate) $alternate = "";
244
- else $alternate = " class=\"alternate\"";
245
- $quotes_list .= "<tr{$alternate}>";
246
- $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_id . "</span></td>";
247
- $quotes_list .= "<td class='post-title column-title'><span style='font-size:16px;'>" . esc_html($mlw_quiz_info->quiz_name) ." </span><span style='color:green;font-size:12px;'><a onclick=\"editQuizName('".$mlw_quiz_info->quiz_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='javascript:();'>(Edit Name)</a></span>";
248
- $quotes_list .= "<div class=\"row-actions\"><a class='linkOptions' href='admin.php?page=mlw_quiz_options&&quiz_id=".$mlw_quiz_info->quiz_id."'>Edit</a> | <a class='linkOptions' href='admin.php?page=mlw_quiz_results&&quiz_id=".$mlw_quiz_info->quiz_id."'>Results</a> | <a href='javascript:();' class='linkOptions' onclick=\"duplicateQuiz('".$mlw_quiz_info->quiz_id."','".esc_js($mlw_quiz_info->quiz_name)."')\">Duplicate</a> | <a class='linkOptions linkDelete' onclick=\"deleteQuiz('".$mlw_quiz_info->quiz_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='javascript:();'>Delete</a></div></td>";
249
- $quotes_list .= "<td><span style='font-size:16px;'>[mlw_quizmaster quiz=".$mlw_quiz_info->quiz_id."]</span></td>";
250
- $quotes_list .= "<td><span style='font-size:16px;'>[mlw_quizmaster_leaderboard mlw_quiz=".$mlw_quiz_info->quiz_id."]</span></td>";
251
- $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_views . "</span></td>";
252
- $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_taken ."</span></td>";
253
- $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->last_activity ."</span></td>";
254
- $quotes_list .= "</tr>";
255
- }
256
- echo $quotes_list; ?>
257
- </tbody>
258
- <tfoot>
259
- <tr>
260
- <th>Quiz ID</th>
261
- <th>Quiz Name</th>
262
- <th>Quiz Shortcode</th>
263
- <th>Leaderboard Shortcode</th>
264
- <th>Quiz Views</th>
265
- <th>Quiz Taken</th>
266
- <th>Last Modified</th>
267
- </tr>
268
- </tfoot>
269
- </table>
270
- </div>
271
- <div style="width: 15%; float:right;">
272
- <h3 style="text-align: center;">My Local Webstop News</h3>
273
- <iframe src="http://www.mylocalwebstop.com/mlw_news.html?cache=<?php echo rand(); ?>" seamless="seamless" style="width: 100%; height: 550px;"></iframe>
274
- </div>
275
- <div style="clear: both;"></div>
276
- <?php echo mlw_qmn_show_adverts(); ?>
277
- <!--Dialogs-->
278
-
279
- <!--New Quiz Dialog-->
280
- <div id="new_quiz_dialog" title="Create New Quiz" style="display:none;">
281
- <?php
282
- echo "<form action='' method='post'>";
283
- echo "<input type='hidden' name='create_quiz' value='confirmation' />";
284
- ?>
285
- <table class="wide" style="text-align: left; white-space: nowrap;">
286
- <thead>
287
-
288
- <tr valign="top">
289
- <th scope="row">&nbsp;</th>
290
- <td></td>
291
- </tr>
292
-
293
- <tr valign="top">
294
- <th scope="row"><h3>Create New Quiz</h3></th>
295
- <td></td>
296
- </tr>
297
-
298
- <tr valign="top">
299
- <th scope="row">Quiz Name</th>
300
- <td>
301
- <input type="text" name="quiz_name" value="" style="border-color:#000000;
302
- color:#3300CC;
303
- cursor:hand;"/>
304
- </td>
305
- </tr>
306
- </thead>
307
- </table>
308
- <?php
309
- echo "<p class='submit'><input type='submit' class='button-primary' value='Create Quiz' /></p>";
310
- echo "</form>";
311
- ?>
312
- </div>
313
-
314
- <!--Edit Quiz Name Dialog-->
315
- <div id="edit_dialog" title="Edit Quiz Name" style="display:none;">
316
- <h3>Quiz Name:</h3><br />
317
- <form action='' method='post'>
318
- <input type="text" id="edit_quiz_name" name="edit_quiz_name" />
319
- <input type="hidden" id="edit_quiz_id" name="edit_quiz_id" />
320
- <input type='hidden' name='quiz_name_editted' value='confirmation' />
321
- <input type="submit" class="button-primary" value="Edit" />
322
- </form>
323
- </div>
324
-
325
- <!--Duplicate Quiz Dialog-->
326
- <div id="duplicate_dialog" title="Duplicate Quiz" style="display:none;">
327
- <h3>Create a new quiz with the same settings as <span id="duplicate_quiz_name"></span>. </h3><br />
328
- <form action='' method='post'>
329
- <label for="duplicate_questions">Duplicate questions with quiz</label><input type="checkbox" name="duplicate_questions" id="duplicate_questions"/><br />
330
- <br />
331
- <label for="duplicate_new_quiz_name">Name Of New Quiz:</label><input type="text" id="duplicate_new_quiz_name" name="duplicate_new_quiz_name" /><br />
332
- <input type="hidden" id="duplicate_quiz_id" name="duplicate_quiz_id" />
333
- <input type='hidden' name='duplicate_quiz' value='confirmation' />
334
- <input type="submit" class="button-primary" value="Duplicate" />
335
- </form>
336
- </div>
337
-
338
- <!--Delete Quiz Dialog-->
339
- <div id="delete_dialog" title="Delete Quiz?" style="display:none;">
340
- <h3><b>Are you sure you want to delete Quiz <span id="delete_quiz_id"></span>?</b></h3>
341
- <?php
342
- echo "<form action='' method='post'>";
343
- echo "<input type='hidden' name='delete_quiz' value='confirmation' />";
344
- echo "<input type='hidden' id='quiz_id' name='quiz_id' value='' />";
345
- echo "<input type='hidden' id='delete_quiz_name' name='delete_quiz_name' value='' />";
346
- echo "<p class='submit'><input type='submit' class='button-primary' value='Delete Quiz' /></p>";
347
- echo "</form>";
348
- ?>
349
- </div>
350
-
351
- </div>
352
- </div>
353
- <?php
354
- }
355
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/mlw_quiz_options.php DELETED
@@ -1,2602 +0,0 @@
1
- <?php
2
- /*
3
- This page allows for the editing of quizzes selected from the quiz admin page.
4
- */
5
- /*
6
- Copyright 2014, My Local Webstop (email : fpcorso@mylocalwebstop.com)
7
- */
8
-
9
- function mlw_generate_quiz_options()
10
- {
11
- global $wpdb;
12
- global $mlwQuizMasterNext;
13
- $quiz_id = $_GET["quiz_id"];
14
- if (isset($_GET["quiz_id"]))
15
- {
16
- $table_name = $wpdb->prefix . "mlw_quizzes";
17
- $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
18
- }
19
- ?>
20
-
21
- <script type="text/javascript"
22
- src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
23
- </script>
24
- <!-- css -->
25
- <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
26
- <!-- jquery scripts -->
27
- <?php
28
- wp_enqueue_script( 'jquery' );
29
- wp_enqueue_script( 'jquery-ui-core' );
30
- wp_enqueue_script( 'jquery-ui-dialog' );
31
- wp_enqueue_script( 'jquery-ui-button' );
32
- wp_enqueue_script( 'jquery-ui-datepicker' );
33
- wp_enqueue_script( 'jquery-ui-tabs' );
34
- wp_enqueue_script( 'jquery-effects-blind' );
35
- wp_enqueue_script( 'jquery-effects-explode' );
36
- ?>
37
- <script type="text/javascript">
38
- var $j = jQuery.noConflict();
39
- // increase the default animation speed to exaggerate the effect
40
- $j.fx.speeds._default = 1000;
41
- $j(function() {
42
- $j( "#tabs" ).tabs();
43
- });
44
- </script>
45
- <style>
46
- .mlw_tab_content
47
- {
48
- padding: 20px 20px 20px 20px;
49
- margin: 20px 20px 20px 20px;
50
- }
51
- </style>
52
- <div class="wrap">
53
- <div class='mlw_quiz_options'>
54
- <h2>Quiz Settings For <?php echo $mlw_quiz_options->quiz_name; ?></h2>
55
- <?php
56
- ob_start();
57
- if ($quiz_id != "")
58
- {
59
- ?>
60
- <div id="tabs">
61
- <ul>
62
- <?php do_action('mlw_qmn_options_tab'); ?>
63
- </ul>
64
- <?php do_action('mlw_qmn_options_tab_content'); ?>
65
-
66
- </div>
67
- <?php
68
- }
69
- else
70
- {
71
- ?>
72
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
73
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
74
- <strong>Hey!</strong> Please go to the quizzes page and click on the Edit link from the quiz you wish to edit.</p
75
- </div>
76
- <?php
77
- }
78
- $mlw_output = ob_get_contents();
79
- ob_end_clean();
80
- $mlwQuizMasterNext->alertManager->showAlerts();
81
- echo mlw_qmn_show_adverts();
82
- echo $mlw_output;
83
- ?>
84
- </div>
85
- </div>
86
- <?php
87
- }
88
-
89
- add_action('mlw_qmn_options_tab', 'mlw_options_questions_tab');
90
- add_action('mlw_qmn_options_tab', 'mlw_options_text_tab');
91
- add_action('mlw_qmn_options_tab', 'mlw_options_option_tab');
92
- add_action('mlw_qmn_options_tab', 'mlw_options_leaderboard_tab');
93
- add_action('mlw_qmn_options_tab', 'mlw_options_certificate_tab');
94
- add_action('mlw_qmn_options_tab', 'mlw_options_emails_tab');
95
- add_action('mlw_qmn_options_tab', 'mlw_options_results_tab');
96
- add_action('mlw_qmn_options_tab', 'mlw_options_styling_tab');
97
- add_action('mlw_qmn_options_tab', 'mlw_options_tools_tab');
98
- add_action('mlw_qmn_options_tab', 'mlw_options_preview_tab');
99
-
100
- function mlw_options_questions_tab()
101
- {
102
- echo "<li><a href=\"#tabs-1\">Questions</a></li>";
103
- }
104
- function mlw_options_text_tab()
105
- {
106
- echo "<li><a href=\"#tabs-2\">Text</a></li>";
107
- }
108
- function mlw_options_option_tab()
109
- {
110
- echo "<li><a href=\"#tabs-3\">Options</a></li>";
111
- }
112
- function mlw_options_leaderboard_tab()
113
- {
114
- echo "<li><a href=\"#tabs-4\">Leaderboard</a></li>";
115
- }
116
- function mlw_options_certificate_tab()
117
- {
118
- echo "<li><a href=\"#tabs-5\">Certificate (Beta)</a></li>";
119
- }
120
- function mlw_options_emails_tab()
121
- {
122
- echo "<li><a href=\"#tabs-9\">Emails</a></li>";
123
- }
124
- function mlw_options_results_tab()
125
- {
126
- echo "<li><a href=\"#tabs-6\">Results Page</a></li>";
127
- }
128
- function mlw_options_styling_tab()
129
- {
130
- echo "<li><a href=\"#tabs-7\">Styling</a></li>";
131
- }
132
- function mlw_options_tools_tab()
133
- {
134
- echo "<li><a href=\"#tabs-8\">Tools/Add-Ons</a></li>";
135
- }
136
- function mlw_options_preview_tab()
137
- {
138
- echo "<li><a href=\"#tabs-preview\">Preview (Beta)</a></li>";
139
- }
140
-
141
- add_action('mlw_qmn_options_tab_content', 'mlw_options_questions_tab_content');
142
- add_action('mlw_qmn_options_tab_content', 'mlw_options_text_tab_content');
143
- add_action('mlw_qmn_options_tab_content', 'mlw_options_option_tab_content');
144
- add_action('mlw_qmn_options_tab_content', 'mlw_options_leaderboard_tab_content');
145
- add_action('mlw_qmn_options_tab_content', 'mlw_options_certificate_tab_content');
146
- add_action('mlw_qmn_options_tab_content', 'mlw_options_emails_tab_content');
147
- add_action('mlw_qmn_options_tab_content', 'mlw_options_results_tab_content');
148
- add_action('mlw_qmn_options_tab_content', 'mlw_options_styling_tab_content');
149
- add_action('mlw_qmn_options_tab_content', 'mlw_options_tools_tab_content');
150
- add_action('mlw_qmn_options_tab_content', 'mlw_options_preview_tab_content');
151
-
152
- function mlw_options_questions_tab_content()
153
- {
154
- global $wpdb;
155
- global $mlwQuizMasterNext;
156
- $quiz_id = $_GET["quiz_id"];
157
-
158
- //Edit question
159
- if ( isset($_POST["edit_question"]) && $_POST["edit_question"] == "confirmation")
160
- {
161
- //Variables from edit question form
162
- $edit_question_name = trim(preg_replace('/\s+/',' ', nl2br(htmlspecialchars($_POST["edit_question_name"], ENT_QUOTES))));
163
- $edit_question_answer_info = $_POST["edit_correct_answer_info"];
164
- $mlw_edit_question_id = intval($_POST["edit_question_id"]);
165
- $mlw_edit_question_type = $_POST["edit_question_type"];
166
- $edit_comments = htmlspecialchars($_POST["edit_comments"], ENT_QUOTES);
167
- $edit_hint = htmlspecialchars($_POST["edit_hint"], ENT_QUOTES);
168
- $edit_question_order = intval($_POST["edit_question_order"]);
169
- $mlw_edit_answer_total = intval($_POST["question_".$mlw_edit_question_id."_answer_total"]);
170
- $mlw_row_settings = $wpdb->get_row( $wpdb->prepare( "SELECT question_settings FROM " . $wpdb->prefix . "mlw_questions" . " WHERE question_id=%d", $mlw_edit_question_id ) );
171
- if (is_serialized($mlw_row_settings->question_settings) && is_array(@unserialize($mlw_row_settings->question_settings)))
172
- {
173
- $mlw_settings = @unserialize($mlw_row_settings->question_settings);
174
- }
175
- else
176
- {
177
- $mlw_settings = array();
178
- $mlw_settings['required'] = intval($_POST["edit_required"]);
179
- }
180
- if ( !isset($mlw_settings['required']))
181
- {
182
- $mlw_settings['required'] = intval($_POST["edit_required"]);
183
- }
184
- $mlw_settings['required'] = intval($_POST["edit_required"]);
185
- $mlw_settings = serialize($mlw_settings);
186
- $i = 1;
187
- $mlw_qmn_new_answer_array = array();
188
- while ($i <= $mlw_edit_answer_total)
189
- {
190
- if ($_POST["edit_answer_".$i] != "")
191
- {
192
- $mlw_qmn_correct = 0;
193
- if (isset($_POST["edit_answer_".$i."_correct"]) && $_POST["edit_answer_".$i."_correct"] == 1)
194
- {
195
- $mlw_qmn_correct = 1;
196
- }
197
- $mlw_qmn_answer_each = array(htmlspecialchars(stripslashes($_POST["edit_answer_".$i]), ENT_QUOTES), floatval($_POST["edit_answer_".$i."_points"]), $mlw_qmn_correct);
198
- $mlw_qmn_new_answer_array[] = $mlw_qmn_answer_each;
199
- }
200
- $i++;
201
- }
202
- $mlw_qmn_new_answer_array = serialize($mlw_qmn_new_answer_array);
203
- $quiz_id = $_POST["quiz_id"];
204
-
205
- $update = "UPDATE " . $wpdb->prefix . "mlw_questions" . " SET question_name='".$edit_question_name."',answer_array='".$mlw_qmn_new_answer_array."', question_answer_info='".$edit_question_answer_info."', comments='".$edit_comments."', hints='".$edit_hint."', question_order='".$edit_question_order."', question_type='".$mlw_edit_question_type."', question_settings='".$mlw_settings."' WHERE question_id=".$mlw_edit_question_id;
206
- $results = $wpdb->query( $update );
207
- if ($results != false)
208
- {
209
- $mlwQuizMasterNext->alertManager->newAlert('The question has been updated successfully.', 'success');
210
-
211
- //Insert Action Into Audit Trail
212
- global $current_user;
213
- get_currentuserinfo();
214
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
215
- $insert = "INSERT INTO " . $table_name .
216
- "(trail_id, action_user, action, time) " .
217
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Question Has Been Edited: ".$edit_question_name."' , '" . date("h:i:s A m/d/Y") . "')";
218
- $results = $wpdb->query( $insert );
219
- }
220
- else
221
- {
222
- $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0004.', 'error');
223
- }
224
- }
225
-
226
- //Delete question from quiz
227
- if ( isset($_POST["delete_question"]) && $_POST["delete_question"] == "confirmation")
228
- {
229
- //Variables from delete question form
230
- $mlw_question_id = intval($_POST["question_id"]);
231
- $quiz_id = $_POST["quiz_id"];
232
-
233
- $update = "UPDATE " . $wpdb->prefix . "mlw_questions" . " SET deleted=1 WHERE question_id=".$mlw_question_id;
234
- $results = $wpdb->query( $update );
235
- if ($results != false)
236
- {
237
- $mlwQuizMasterNext->alertManager->newAlert('The question has been deleted successfully.', 'success');
238
-
239
- //Insert Action Into Audit Trail
240
- global $current_user;
241
- get_currentuserinfo();
242
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
243
- $insert = "INSERT INTO " . $table_name .
244
- "(trail_id, action_user, action, time) " .
245
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Question Has Been Deleted: ".$mlw_question_id."' , '" . date("h:i:s A m/d/Y") . "')";
246
- $results = $wpdb->query( $insert );
247
- }
248
- else
249
- {
250
- $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0005.', 'error');
251
- }
252
- }
253
-
254
- //Duplicate Questions
255
- if ( isset($_POST["duplicate_question"]) && $_POST["duplicate_question"] == "confirmation")
256
- {
257
- //Variables from delete question form
258
- $mlw_question_id = intval($_POST["duplicate_question_id"]);
259
- $quiz_id = $_POST["quiz_id"];
260
-
261
- $mlw_original = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM ".$wpdb->prefix."mlw_questions WHERE question_id=%d", $mlw_question_id ), ARRAY_A );
262
-
263
- $results = $wpdb->insert(
264
- $wpdb->prefix."mlw_questions",
265
- array(
266
- 'quiz_id' => $mlw_original['quiz_id'],
267
- 'question_name' => $mlw_original['question_name'],
268
- 'answer_array' => $mlw_original['answer_array'],
269
- 'answer_one' => $mlw_original['answer_one'],
270
- 'answer_one_points' => $mlw_original['answer_one_points'],
271
- 'answer_two' => $mlw_original['answer_two'],
272
- 'answer_two_points' => $mlw_original['answer_two_points'],
273
- 'answer_three' => $mlw_original['answer_three'],
274
- 'answer_three_points' => $mlw_original['answer_three_points'],
275
- 'answer_four' => $mlw_original['answer_four'],
276
- 'answer_four_points' => $mlw_original['answer_four_points'],
277
- 'answer_five' => $mlw_original['answer_five'],
278
- 'answer_five_points' => $mlw_original['answer_five_points'],
279
- 'answer_six' => $mlw_original['answer_six'],
280
- 'answer_six_points' => $mlw_original['answer_six_points'],
281
- 'correct_answer' => $mlw_original['correct_answer'],
282
- 'question_answer_info' => $mlw_original['question_answer_info'],
283
- 'comments' => $mlw_original['comments'],
284
- 'hints' => $mlw_original['hints'],
285
- 'question_order' => $mlw_original['question_order'],
286
- 'question_type' => $mlw_original['question_type'],
287
- 'question_settings' => $mlw_original['question_settings'],
288
- 'deleted' => $mlw_original['deleted']
289
- ),
290
- array(
291
- '%d',
292
- '%s',
293
- '%s',
294
- '%s',
295
- '%d',
296
- '%s',
297
- '%d',
298
- '%s',
299
- '%d',
300
- '%s',
301
- '%d',
302
- '%s',
303
- '%d',
304
- '%s',
305
- '%d',
306
- '%d',
307
- '%s',
308
- '%d',
309
- '%s',
310
- '%d',
311
- '%d',
312
- '%s',
313
- '%d'
314
- )
315
- );
316
-
317
- if ($results != false)
318
- {
319
- $mlwQuizMasterNext->alertManager->newAlert('The question has been duplicated successfully.', 'success');
320
-
321
- //Insert Action Into Audit Trail
322
- global $current_user;
323
- get_currentuserinfo();
324
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
325
- $insert = "INSERT INTO " . $table_name .
326
- "(trail_id, action_user, action, time) " .
327
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Question Has Been Duplicated: ".$mlw_question_id."' , '" . date("h:i:s A m/d/Y") . "')";
328
- $results = $wpdb->query( $insert );
329
- }
330
- else
331
- {
332
- $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0019.', 'error');
333
- }
334
- }
335
-
336
-
337
- //Submit new question into database
338
- if ( isset($_POST["create_question"]) && $_POST["create_question"] == "confirmation")
339
- {
340
- //Variables from new question form
341
- $question_name = trim(preg_replace('/\s+/',' ', nl2br(htmlspecialchars($_POST["question_name"], ENT_QUOTES))));
342
- $question_answer_info = $_POST["correct_answer_info"];
343
- $question_type = $_POST["question_type"];
344
- $comments = htmlspecialchars($_POST["comments"], ENT_QUOTES);
345
- $hint = htmlspecialchars($_POST["hint"], ENT_QUOTES);
346
- $new_question_order = intval($_POST["new_question_order"]);
347
- $mlw_answer_total = intval($_POST["new_question_answer_total"]);
348
- $mlw_settings = array();
349
- $mlw_settings['required'] = intval($_POST["required"]);
350
- $mlw_settings = serialize($mlw_settings);
351
- $i = 1;
352
- $mlw_qmn_new_answer_array = array();
353
- while ($i <= $mlw_answer_total)
354
- {
355
- if ($_POST["answer_".$i] != "")
356
- {
357
- $mlw_qmn_correct = 0;
358
- if (isset($_POST["answer_".$i."_correct"]) && $_POST["answer_".$i."_correct"] == 1)
359
- {
360
- $mlw_qmn_correct = 1;
361
- }
362
- $mlw_qmn_answer_each = array(htmlspecialchars(stripslashes($_POST["answer_".$i]), ENT_QUOTES), floatval($_POST["answer_".$i."_points"]), $mlw_qmn_correct);
363
- $mlw_qmn_new_answer_array[] = $mlw_qmn_answer_each;
364
- }
365
- $i++;
366
- }
367
- $mlw_qmn_new_answer_array = serialize($mlw_qmn_new_answer_array);
368
- $quiz_id = $_POST["quiz_id"];
369
- $table_name = $wpdb->prefix . "mlw_questions";
370
- $insert = "INSERT INTO " . $table_name .
371
- " (question_id, quiz_id, question_name, answer_array, question_answer_info, comments, hints, question_order, question_type, question_settings, deleted) VALUES (NULL , ".$quiz_id.", '" . $question_name . "' , '".$mlw_qmn_new_answer_array."', '".$question_answer_info."', '".$comments."', '".$hint."', ".$new_question_order.", '".$question_type."', '".$mlw_settings."', 0)";
372
- $results = $wpdb->query( $insert );
373
- if ($results != false)
374
- {
375
- $mlwQuizMasterNext->alertManager->newAlert('The question has been created successfully.', 'success');
376
-
377
- //Insert Action Into Audit Trail
378
- global $current_user;
379
- get_currentuserinfo();
380
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
381
- $insert = "INSERT INTO " . $table_name .
382
- "(trail_id, action_user, action, time) " .
383
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Question Has Been Added: ".$question_name."' , '" . date("h:i:s A m/d/Y") . "')";
384
- $results = $wpdb->query( $insert );
385
- }
386
- else
387
- {
388
- $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0006.', 'error');
389
- }
390
- }
391
-
392
- if (isset($_GET["quiz_id"]))
393
- {
394
- $table_name = $wpdb->prefix . "mlw_quizzes";
395
- $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
396
- }
397
-
398
- $mlw_qmn_table_limit = 10;
399
- $mlw_qmn_question_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(question_id) FROM " . $wpdb->prefix . "mlw_questions WHERE quiz_id=%d AND deleted='0'", $quiz_id ) );
400
-
401
- if( isset($_GET{'mlw_question_page'} ) )
402
- {
403
- $mlw_qmn_question_page = $_GET{'mlw_question_page'} + 1;
404
- $mlw_qmn_question_begin = $mlw_qmn_table_limit * $mlw_qmn_question_page ;
405
- }
406
- else
407
- {
408
- $mlw_qmn_question_page = 0;
409
- $mlw_qmn_question_begin = 0;
410
- }
411
- $mlw_qmn_question_left = $mlw_qmn_question_count - ($mlw_qmn_question_page * $mlw_qmn_table_limit);
412
-
413
- $mlw_question_data = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "mlw_questions WHERE quiz_id=%d AND deleted='0'
414
- ORDER BY question_order ASC LIMIT %d, %d", $quiz_id, $mlw_qmn_question_begin, $mlw_qmn_table_limit ) );
415
-
416
- //Load and prepare answer arrays
417
- $mlw_qmn_answer_arrays = array();
418
- foreach($mlw_question_data as $mlw_question_info) {
419
- if (is_serialized($mlw_question_info->answer_array) && is_array(@unserialize($mlw_question_info->answer_array)))
420
- {
421
- $mlw_qmn_answer_array_each = @unserialize($mlw_question_info->answer_array);
422
- $mlw_qmn_answer_arrays[$mlw_question_info->question_id] = $mlw_qmn_answer_array_each;
423
- }
424
- else
425
- {
426
- $mlw_answer_array_correct = array(0, 0, 0, 0, 0, 0);
427
- $mlw_answer_array_correct[$mlw_question_info->correct_answer-1] = 1;
428
- $mlw_qmn_answer_arrays[$mlw_question_info->question_id] = array(
429
- array($mlw_question_info->answer_one, $mlw_question_info->answer_one_points, $mlw_answer_array_correct[0]),
430
- array($mlw_question_info->answer_two, $mlw_question_info->answer_two_points, $mlw_answer_array_correct[1]),
431
- array($mlw_question_info->answer_three, $mlw_question_info->answer_three_points, $mlw_answer_array_correct[2]),
432
- array($mlw_question_info->answer_four, $mlw_question_info->answer_four_points, $mlw_answer_array_correct[3]),
433
- array($mlw_question_info->answer_five, $mlw_question_info->answer_five_points, $mlw_answer_array_correct[4]),
434
- array($mlw_question_info->answer_six, $mlw_question_info->answer_six_points, $mlw_answer_array_correct[5]));
435
- }
436
- }
437
- $is_new_quiz = $wpdb->num_rows;
438
- ?>
439
- <div id="tabs-1" class="mlw_tab_content">
440
- <script>
441
- jQuery(function() {
442
- jQuery('#new_question_dialog').dialog({
443
- autoOpen: false,
444
- show: 'blind',
445
- width:800,
446
- hide: 'explode',
447
- buttons: {
448
- Cancel: function() {
449
- jQuery(this).dialog('close');
450
- }
451
- }
452
- });
453
-
454
- jQuery('#new_question_button').click(function() {
455
- jQuery('#new_question_dialog').dialog('open');
456
- document.getElementById("question_name").focus();
457
- return false;
458
- } );
459
- jQuery('#new_question_button_two').click(function() {
460
- jQuery('#new_question_dialog').dialog('open');
461
- document.getElementById("question_name").focus();
462
- return false;
463
- } );
464
- });
465
- function deleteQuestion(id){
466
- jQuery("#delete_dialog").dialog({
467
- autoOpen: false,
468
- show: 'blind',
469
- hide: 'explode',
470
- buttons: {
471
- Cancel: function() {
472
- jQuery(this).dialog('close');
473
- }
474
- }
475
- });
476
- jQuery("#delete_dialog").dialog('open');
477
- var idText = document.getElementById("delete_question_id");
478
- var idHidden = document.getElementById("question_id");
479
- idText.innerHTML = id;
480
- idHidden.value = id;
481
- };
482
- function duplicateQuestion(id){
483
- jQuery("#duplicate_dialog").dialog({
484
- autoOpen: false,
485
- show: 'blind',
486
- hide: 'explode',
487
- buttons: {
488
- Cancel: function() {
489
- jQuery(this).dialog('close');
490
- }
491
- }
492
- });
493
- jQuery("#duplicate_dialog").dialog('open');
494
- var idHidden = document.getElementById("duplicate_question_id");
495
- idHidden.value = id;
496
- };
497
- function editQuestion(id){
498
- jQuery("#edit_question_dialog_"+id).dialog({
499
- autoOpen: false,
500
- show: 'blind',
501
- width:800,
502
- hide: 'explode',
503
- buttons: {
504
- Cancel: function() {
505
- jQuery(this).dialog('close');
506
- }
507
- }
508
- });
509
- jQuery("#edit_question_dialog_"+id).dialog('open');
510
- };
511
- function mlw_add_new_question(id)
512
- {
513
- var total_answers = parseFloat(document.getElementById("question_"+id+"_answer_total").value);
514
- total_answers = total_answers + 1;
515
- document.getElementById("question_"+id+"_answer_total").value = total_answers;
516
- jQuery("#question_"+id+"_answers").append("<tr valign='top'><td><span style='font-weight:bold;'>Answer "+total_answers+"</span></td><td><input type='text' name='edit_answer_"+total_answers+"' id='edit_answer_"+total_answers+"' style='border-color:#000000;color:#3300CC;cursor:hand;width: 250px;'/></td><td><input type='text' name='edit_answer_"+total_answers+"_points' id='edit_answer_"+total_answers+"_points' value=0 style='border-color:#000000;color:#3300CC; cursor:hand;'/></td><td><input type='checkbox' id='edit_answer_"+total_answers+"_correct' name='edit_answer_"+total_answers+"_correct' value=1 /></td></tr>");
517
- }
518
- function mlw_add_answer_to_new_question()
519
- {
520
- var total_answers = parseFloat(document.getElementById("new_question_answer_total").value);
521
- total_answers = total_answers + 1;
522
- document.getElementById("new_question_answer_total").value = total_answers;
523
- jQuery("#new_question_answers").append("<tr valign='top'><td><span style='font-weight:bold;'>Answer "+total_answers+"</span></td><td><input type='text' name='answer_"+total_answers+"' id='answer_"+total_answers+"' style='border-color:#000000;color:#3300CC;cursor:hand;width: 250px;'/></td><td><input type='text' name='answer_"+total_answers+"_points' id='answer_"+total_answers+"_points' value=0 style='border-color:#000000;color:#3300CC; cursor:hand;'/></td><td><input type='checkbox' id='answer_"+total_answers+"_correct' name='answer_"+total_answers+"_correct' value=1 /></td></tr>");
524
- }
525
- </script>
526
- <style>
527
- .linkOptions
528
- {
529
- color: #0074a2 !important;
530
- font-size: 14px !important;
531
- }
532
- .linkDelete
533
- {
534
- color: red !important;
535
- font-size: 14px !important;
536
- }
537
- .linkOptions:hover,
538
- .linkDelete:hover
539
- {
540
- background-color: black;
541
- }
542
- </style>
543
- <button class="button" id="new_question_button_two">Add Question</button>
544
- <br />
545
- <?php
546
- $question_list = "";
547
- $display = "";
548
- $alternate = "";
549
- foreach($mlw_question_data as $mlw_question_info) {
550
- if (is_serialized($mlw_question_info->question_settings) && is_array(@unserialize($mlw_question_info->question_settings)))
551
- {
552
- $mlw_question_settings = @unserialize($mlw_question_info->question_settings);
553
- }
554
- else
555
- {
556
- $mlw_question_settings = array();
557
- $mlw_question_settings['required'] = 1;
558
- }
559
- $mlw_question_type_text = "";
560
- switch ($mlw_question_info->question_type) {
561
- case 0:
562
- $mlw_question_type_text = "Multiple Choice";
563
- break;
564
- case 1:
565
- $mlw_question_type_text = "Horizontal Multiple Choice";
566
- break;
567
- case 2:
568
- $mlw_question_type_text = "Drop Down";
569
- break;
570
- case 3:
571
- $mlw_question_type_text = "Small Open Answer";
572
- break;
573
- case 4:
574
- $mlw_question_type_text = "Multiple Response";
575
- break;
576
- case 5:
577
- $mlw_question_type_text = "Large Open Answer";
578
- break;
579
- case 6:
580
- $mlw_question_type_text = "Text Block";
581
- break;
582
- case 7:
583
- $mlw_question_type_text = "Number";
584
- break;
585
- case 8:
586
- $mlw_question_type_text = "Accept";
587
- break;
588
- case 9:
589
- $mlw_question_type_text = "Captcha";
590
- break;
591
- case 10:
592
- $mlw_question_type_text = "Horizontal Multiple Response";
593
- break;
594
- default:
595
- $mlw_question_type_text = "Error Code ";
596
- }
597
- if($alternate) $alternate = "";
598
- else $alternate = " class=\"alternate\"";
599
- $question_list .= "<tr{$alternate}>";
600
- $question_list .= "<td><span style='font-size:16px;'>" . $mlw_question_info->question_order . "</span></td>";
601
- $question_list .= "<td><span style='font-size:16px;'>" . $mlw_question_type_text . "</span></td>";
602
- $question_list .= "<td class='post-title column-title'><span style='font-size:16px;'>" . $mlw_question_info->question_name ."</span><div class='row-actions'><a class='linkOptions' onclick=\"editQuestion('".$mlw_question_info->question_id."')\" href='#'>Edit</a> | <a class='linkOptions' onclick=\"duplicateQuestion('".$mlw_question_info->question_id."')\" href='#'>Duplicate</a>| <a class='linkDelete' onclick=\"deleteQuestion('".$mlw_question_info->question_id."')\" href='#'>Delete</a></div></td>";
603
- $question_list .= "</tr>";
604
-
605
-
606
- $mlw_question_answer_array = $mlw_qmn_answer_arrays[$mlw_question_info->question_id];
607
- ?>
608
- <div id="edit_question_dialog_<?php echo $mlw_question_info->question_id; ?>" title="Edit Question" style="display:none;">
609
- <?php
610
- echo "<form action='' method='post'>";
611
- echo "<input type='hidden' name='edit_question' value='confirmation' />";
612
- echo "<input type='hidden' id='edit_question_id' name='edit_question_id' value='".$mlw_question_info->question_id."' />";
613
- echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
614
- ?>
615
- <table class="wide" style="text-align: left; white-space: nowrap;" id="question_<?php echo $mlw_question_info->question_id; ?>_answers" name="question_<?php echo $mlw_question_info->question_id; ?>_answers">
616
- <tr>
617
- <td><span style='font-weight:bold;'>Question</span></td>
618
- <td colspan="3">
619
- <textarea name="edit_question_name" id="edit_question_name" style="width: 500px; height: 150px;"><?php echo htmlspecialchars_decode($mlw_question_info->question_name, ENT_QUOTES); ?></textarea>
620
- </td>
621
- </tr>
622
- <tr valign="top">
623
- <td>&nbsp;</td>
624
- <td>&nbsp;</td>
625
- </tr>
626
- <tr valign="top">
627
- <td>&nbsp;</td>
628
- <td><span style='font-weight:bold;'>Answers</span></td>
629
- <td><span style='font-weight:bold;'>Points Worth</span></td>
630
- <td><span style='font-weight:bold;'>Correct Answer</span></td>
631
- </tr>
632
- <?php
633
- $mlw_answer_total = 0;
634
- foreach($mlw_question_answer_array as $mlw_question_answer_each)
635
- {
636
- $mlw_answer_total = $mlw_answer_total + 1;
637
- ?>
638
- <tr valign="top">
639
- <td><span style='font-weight:bold;'>Answer <?php echo $mlw_answer_total; ?></span></td>
640
- <td>
641
- <input type="text" name="edit_answer_<?php echo $mlw_answer_total; ?>" id="edit_answer_<?php echo $mlw_answer_total; ?>" value="<?php echo esc_attr(htmlspecialchars_decode($mlw_question_answer_each[0], ENT_QUOTES)); ?>" style="border-color:#000000;
642
- color:#3300CC;
643
- cursor:hand;
644
- width: 250px;"/>
645
- </td>
646
- <td>
647
- <input type="text" name="edit_answer_<?php echo $mlw_answer_total; ?>_points" id="edit_answer_<?php echo $mlw_answer_total; ?>_points" value="<?php echo $mlw_question_answer_each[1]; ?>" style="border-color:#000000;
648
- color:#3300CC;
649
- cursor:hand;"/>
650
- </td>
651
- <td><input type="checkbox" id="edit_answer_<?php echo $mlw_answer_total; ?>_correct" name="edit_answer_<?php echo $mlw_answer_total; ?>_correct" <?php if ($mlw_question_answer_each[2] == 1) { echo 'checked="checked"'; } ?> value=1 /></td>
652
- </tr>
653
- <?php
654
- }
655
- ?>
656
- </table>
657
- <a href="#" class="button" id="new_answer_button" onclick="mlw_add_new_question(<?php echo $mlw_question_info->question_id; ?>);">Add New Answer!</a>
658
- <br />
659
- <br />
660
- <table class="wide" style="text-align: left; white-space: nowrap;">
661
- <tr>
662
- <td><span style='font-weight:bold;'>Correct Answer Info:</span></td>
663
- <td colspan="3"><input type="text" name="edit_correct_answer_info" id="edit_correct_answer_info" style="border-color:#000000;
664
- color:#3300CC;
665
- cursor:hand;
666
- width:550px;" value="<?php echo esc_attr(htmlspecialchars_decode($mlw_question_info->question_answer_info, ENT_QUOTES)); ?>"/></td>
667
- </tr>
668
- <tr valign="top">
669
- <td><span style='font-weight:bold;'>Hint</span></td>
670
- <td colspan="3">
671
- <input type="text" name="edit_hint" id="edit_hint" style="border-color:#000000;
672
- color:#3300CC;
673
- cursor:hand;
674
- width:550px;" value="<?php echo htmlspecialchars_decode($mlw_question_info->hints, ENT_QUOTES); ?>"/>
675
- </td>
676
- </tr>
677
- <tr><td>&nbsp;</td></tr>
678
- <tr><td>&nbsp;</td></tr>
679
- <tr valign="top">
680
- <td><span style='font-weight:bold;'>Question Type</span></td>
681
- <td colspan="3">
682
- <select name="edit_question_type">
683
- <option value="0" <?php if ($mlw_question_info->question_type == 0) { echo 'selected="selected"'; } ?>>Normal Multiple Choice (Vertical Radio)</option>
684
- <option value="1" <?php if ($mlw_question_info->question_type == 1) { echo 'selected="selected"'; } ?>>Horizontal Multiple Choice (Horizontal Radio)</option>
685
- <option value="2" <?php if ($mlw_question_info->question_type == 2) { echo 'selected="selected"'; } ?>>Drop Down (Select)</option>
686
- <option value="3" <?php if ($mlw_question_info->question_type == 3) { echo 'selected="selected"'; } ?>>Open Answer (Text Input)</option>
687
- <option value="5" <?php if ($mlw_question_info->question_type == 5) { echo 'selected="selected"'; } ?>>Open Answer (Large Text Input)</option>
688
- <option value="4" <?php if ($mlw_question_info->question_type == 4) { echo 'selected="selected"'; } ?>>Multiple Response (Checkbox)</option>
689
- <option value="10" <?php if ($mlw_question_info->question_type == 10) { echo 'selected="selected"'; } ?>>Horizontal Multiple Response (Checkbox)</option>
690
- <option value="6" <?php if ($mlw_question_info->question_type == 6) { echo 'selected="selected"'; } ?>>Text Block</option>
691
- <option value="7" <?php if ($mlw_question_info->question_type == 7) { echo 'selected="selected"'; } ?>>Number</option>
692
- <option value="8" <?php if ($mlw_question_info->question_type == 8) { echo 'selected="selected"'; } ?>>Accept</option>
693
- <option value="9" <?php if ($mlw_question_info->question_type == 9) { echo 'selected="selected"'; } ?>>Captcha</option>
694
- </select>
695
- </div></td>
696
- </tr>
697
- <tr valign="top">
698
- <td><span style='font-weight:bold;'>Comment Field</span></td>
699
- <td colspan="3">
700
- <input type="radio" id="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio1" name="edit_comments" value=0 <?php if ($mlw_question_info->comments == 0) { echo 'checked="checked"'; } ?>/><label for="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio1">Small Text Field</label>
701
- <input type="radio" id="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio3" name="edit_comments" value=2 <?php if ($mlw_question_info->comments == 2) { echo 'checked="checked"'; } ?>/><label for="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio3">Large Text Field</label>
702
- <input type="radio" id="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio2" name="edit_comments" value=1 <?php if ($mlw_question_info->comments == 1) { echo 'checked="checked"'; } ?>/><label for="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio2">None</label>
703
- </td>
704
- </tr>
705
- <tr valign="top">
706
- <td><span style='font-weight:bold;'>Question Order</span></td>
707
- <td>
708
- <input type="number" step="1" min="1" name="edit_question_order" value="<?php echo $mlw_question_info->question_order; ?>" id="edit_question_order" style="border-color:#000000;
709
- color:#3300CC;
710
- cursor:hand;"/>
711
- </td>
712
- </tr>
713
- <tr valign="top">
714
- <td><span style='font-weight:bold;'>Required?</span></td>
715
- <td colspan="3">
716
- <select name="edit_required">
717
- <option value="0" <?php if ($mlw_question_settings['required'] == 0) { echo 'selected="selected"'; } ?>>Yes</option>
718
- <option value="1" <?php if ($mlw_question_settings['required'] == 1) { echo 'selected="selected"'; } ?>>No</option>
719
- </select>
720
- </div></td>
721
- </tr>
722
- </table>
723
- <p> *Required currently only works on open answer, number, accept, and captcha question types</p>
724
- <input type="hidden" name="question_<?php echo $mlw_question_info->question_id; ?>_answer_total" id="question_<?php echo $mlw_question_info->question_id; ?>_answer_total" value="<?php echo $mlw_answer_total; ?>" />
725
- <p class='submit'><input type='submit' class='button-primary' value='Edit Question' /></p>
726
- </form>
727
- </div>
728
-
729
- <?php
730
- }
731
-
732
- if( $mlw_qmn_question_page > 0 )
733
- {
734
- $mlw_qmn_previous_page = $mlw_qmn_question_page - 2;
735
- $display .= "<a id=\"prev_page\" href=\"?page=mlw_quiz_options&&mlw_question_page=$mlw_qmn_previous_page&&quiz_id=$quiz_id\">Previous 10 Questions</a>";
736
- if( $mlw_qmn_question_left > $mlw_qmn_table_limit )
737
- {
738
- $display .= "<a id=\"next_page\" href=\"?page=mlw_quiz_options&&mlw_question_page=$mlw_qmn_question_page&&quiz_id=$quiz_id\">Next 10 Questions</a>";
739
- }
740
- }
741
- else if( $mlw_qmn_question_page == 0 )
742
- {
743
- if( $mlw_qmn_question_left > $mlw_qmn_table_limit )
744
- {
745
- $display .= "<a id=\"next_page\" href=\"?page=mlw_quiz_options&&mlw_question_page=$mlw_qmn_question_page&&quiz_id=$quiz_id\">Next 10 Questions</a>";
746
- }
747
- }
748
- else if( $mlw_qmn_question_left < $mlw_qmn_table_limit )
749
- {
750
- $mlw_qmn_previous_page = $mlw_qmn_question_page - 2;
751
- $display .= "<a id=\"prev_page\" href=\"?page=mlw_quiz_options&&mlw_question_page=$mlw_qmn_previous_page&&quiz_id=$quiz_id\">Previous 10 Questions</a>";
752
- }
753
-
754
- $display .= "<table class=\"widefat\">";
755
- $display .= "<thead><tr>
756
- <th>Question Order</th>
757
- <th>Question Type</th>
758
- <th>Question</th>
759
- </tr></thead>";
760
- $display .= "<tbody id=\"the-list\">{$question_list}</tbody>";
761
- $display .= "<tfoot><tr>
762
- <th>Question Order</th>
763
- <th>Question Type</th>
764
- <th>Question</th>
765
- </tr></tfoot>";
766
- $display .= "</table>";
767
- echo $display;
768
- ?>
769
- <button class="button" id="new_question_button">Add Question</button>
770
- <div id="new_question_dialog" title="Create New Question" style="display:none;">
771
-
772
- <?php
773
- echo "<form action='' method='post'>";
774
- echo "<input type='hidden' name='create_question' value='confirmation' />";
775
- echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
776
- ?>
777
- <table class="wide" style="text-align: left; white-space: nowrap;" id="new_question_answers" name="new_question_answers">
778
- <tr>
779
- <td><span style='font-weight:bold;'>Question</span></td>
780
- <td colspan="3">
781
- <textarea name="question_name" id="question_name" style="width: 500px; height: 150px;"></textarea>
782
- </td>
783
- </tr>
784
- <tr valign="top">
785
- <td>&nbsp;</td>
786
- <td>&nbsp;</td>
787
- </tr>
788
- <tr valign="top">
789
- <td>&nbsp;</td>
790
- <td><span style='font-weight:bold;'>Answers</span></td>
791
- <td><span style='font-weight:bold;'>Points Worth</span></td>
792
- <td><span style='font-weight:bold;'>Correct Answer</span></td>
793
- </tr>
794
- <?php
795
- $mlw_answer_total = 0;
796
- $mlw_answer_total = $mlw_answer_total + 1;
797
- ?>
798
- <tr valign="top">
799
- <td><span style='font-weight:bold;'>Answer <?php echo $mlw_answer_total; ?></span></td>
800
- <td>
801
- <input type="text" name="answer_<?php echo $mlw_answer_total; ?>" id="answer_<?php echo $mlw_answer_total; ?>" value="" style="border-color:#000000;
802
- color:#3300CC;
803
- cursor:hand;
804
- width: 250px;"/>
805
- </td>
806
- <td>
807
- <input type="text" name="answer_<?php echo $mlw_answer_total; ?>_points" id="answer_<?php echo $mlw_answer_total; ?>_points" value=0 style="border-color:#000000;
808
- color:#3300CC;
809
- cursor:hand;"/>
810
- </td>
811
- <td><input type="checkbox" id="answer_<?php echo $mlw_answer_total; ?>_correct" name="answer_<?php echo $mlw_answer_total; ?>_correct" checked="checked" value=1 /></td>
812
- </tr>
813
- </table>
814
- <a href="#" class="button" id="new_answer_button" onclick="mlw_add_answer_to_new_question();">Add New Answer!</a>
815
- <br />
816
- <br />
817
- <table class="wide" style="text-align: left; white-space: nowrap;">
818
- <tr>
819
- <td><span style='font-weight:bold;'>Correct Answer Info</span></td>
820
- <td colspan="3"><input type="text" name="correct_answer_info" value="" id="correct_answer_info" style="border-color:#000000;
821
- color:#3300CC;
822
- cursor:hand;
823
- width:550px;"/></td>
824
- </tr>
825
- <tr valign="top">
826
- <td><span style='font-weight:bold;'>Hint</span></td>
827
- <td colspan="3">
828
- <input type="text" name="hint" value="" id="hint" style="border-color:#000000;
829
- color:#3300CC;
830
- cursor:hand;
831
- width:550px;"/>
832
- </td>
833
- </tr>
834
- <tr><td>&nbsp;</td></tr>
835
- <tr><td>&nbsp;</td></tr>
836
- <tr valign="top">
837
- <td><span style='font-weight:bold;'>Question Type</span></td>
838
- <td colspan="3">
839
- <select name="question_type">
840
- <option value="0" selected="selected">Normal Multiple Choice (Vertical Radio)</option>
841
- <option value="1">Horizontal Multiple Choice (Horizontal Radio)</option>
842
- <option value="2">Drop Down (Select)</option>
843
- <option value="3">Open Answer (Text Input)</option>
844
- <option value="5">Open Answer (Large Text Input)</option>
845
- <option value="4">Multiple Response (Checkbox)</option>
846
- <option value="10">Horizontal Multiple Response (Checkbox)</option>
847
- <option value="6">Text Block</option>
848
- <option value="7">Number</option>
849
- <option value="8">Accept</option>
850
- <option value="9">Captcha</option>
851
- </select>
852
- </div></td>
853
- </tr>
854
- <tr valign="top">
855
- <td><span style='font-weight:bold;'>Comment Field</span></td>
856
- <td colspan="3"><div id="comments">
857
- <input type="radio" id="commentsRadio1" name="comments" value=0 /><label for="commentsRadio1">Small Text Field</label>
858
- <input type="radio" id="commentsRadio3" name="comments" value=2 /><label for="commentsRadio3">Large Text Field</label>
859
- <input type="radio" id="commentsRadio2" name="comments" checked="checked" value=1 /><label for="commentsRadio2">None</label>
860
- </div></td>
861
- </tr>
862
- <tr valign="top">
863
- <td><span style='font-weight:bold;'>Question Order</span></td>
864
- <td>
865
- <input type="number" step="1" min="1" name="new_question_order" value="<?php echo $mlw_qmn_question_count+1; ?>" id="new_question_order" style="border-color:#000000;
866
- color:#3300CC;
867
- cursor:hand;"/>
868
- </td>
869
- </tr>
870
- <tr valign="top">
871
- <td><span style='font-weight:bold;'>Required?</span></td>
872
- <td colspan="3">
873
- <select name="required">
874
- <option value="0" selected="selected">Yes</option>
875
- <option value="1">No</option>
876
- </select>
877
- </div></td>
878
- </tr>
879
- </table>
880
- <p> *Required currently only works on open answer, number, accept, and captcha question types</p>
881
- <input type="hidden" name="new_question_answer_total" id="new_question_answer_total" value="<?php echo $mlw_answer_total; ?>" />
882
- <?php
883
- echo "<p class='submit'><input type='submit' class='button-primary' value='Create Question' /></p>";
884
- echo "</form>";
885
- ?>
886
- </div>
887
- <!--Dialogs-->
888
- <div id="delete_dialog" title="Delete Question?" style="display:none;">
889
- <h3><b>Are you sure you want to delete Question <span id="delete_question_id"></span>?</b></h3>
890
- <?php
891
- echo "<form action='' method='post'>";
892
- echo "<input type='hidden' name='delete_question' value='confirmation' />";
893
- echo "<input type='hidden' id='question_id' name='question_id' value='' />";
894
- echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
895
- echo "<p class='submit'><input type='submit' class='button-primary' value='Delete Question' /></p>";
896
- echo "</form>";
897
- ?>
898
- </div>
899
-
900
- <div id="duplicate_dialog" title="Duplicate Question?" style="display:none;">
901
- <h3><b>Are you sure you want to duplicate this Question?</b></h3>
902
- <?php
903
- echo "<form action='' method='post'>";
904
- echo "<input type='hidden' name='duplicate_question' value='confirmation' />";
905
- echo "<input type='hidden' id='duplicate_question_id' name='duplicate_question_id' value='' />";
906
- echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
907
- echo "<p class='submit'><input type='submit' class='button-primary' value='Duplicate Question' /></p>";
908
- echo "</form>";
909
- ?>
910
- </div>
911
- </div>
912
- <?php
913
- }
914
-
915
- function mlw_options_text_tab_content()
916
- {
917
- global $wpdb;
918
- global $mlwQuizMasterNext;
919
- $quiz_id = $_GET["quiz_id"];
920
- //Submit saved templates into database
921
- if ( isset($_POST["save_templates"]) && $_POST["save_templates"] == "confirmation")
922
- {
923
- //Variables for save templates form
924
- $mlw_before_message = htmlspecialchars($_POST["mlw_quiz_before_message"], ENT_QUOTES);
925
- $mlw_qmn_message_end = htmlspecialchars($_POST["message_end_template"], ENT_QUOTES);
926
- $mlw_user_tries_text = htmlspecialchars($_POST["mlw_quiz_total_user_tries_text"], ENT_QUOTES);
927
- $mlw_submit_button_text = htmlspecialchars($_POST["mlw_submitText"], ENT_QUOTES);
928
- $mlw_name_field_text = htmlspecialchars($_POST["mlw_nameText"], ENT_QUOTES);
929
- $mlw_business_field_text = htmlspecialchars($_POST["mlw_businessText"], ENT_QUOTES);
930
- $mlw_email_field_text = htmlspecialchars($_POST["mlw_emailText"], ENT_QUOTES);
931
- $mlw_phone_field_text = htmlspecialchars($_POST["mlw_phoneText"], ENT_QUOTES);
932
- $mlw_before_comments = htmlspecialchars($_POST["mlw_quiz_before_comments"], ENT_QUOTES);
933
- $mlw_comment_field_text = htmlspecialchars($_POST["mlw_commentText"], ENT_QUOTES);
934
- $mlw_require_log_in_text = htmlspecialchars($_POST["mlw_require_log_in_text"], ENT_QUOTES);
935
- $mlw_scheduled_timeframe_text = htmlspecialchars($_POST["mlw_scheduled_timeframe_text"], ENT_QUOTES);
936
- $mlw_limit_total_entries_text = htmlspecialchars($_POST["mlw_limit_total_entries_text"], ENT_QUOTES);
937
- $mlw_qmn_pagination_field = serialize(array( $_POST["pagination_prev_text"], $_POST["pagination_next_text"] ));
938
- $qmn_social_media_text = serialize(array('twitter' => $_POST["mlw_quiz_twitter_text_template"], 'facebook' => $_POST["mlw_quiz_facebook_text_template"]));
939
- $mlw_email_from_text = $_POST["emailFromText"];
940
- $mlw_question_answer_template = htmlspecialchars($_POST["mlw_quiz_question_answer_template"], ENT_QUOTES);
941
- $quiz_id = $_POST["quiz_id"];
942
-
943
- $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET message_before='".$mlw_before_message."', message_comment='".$mlw_before_comments."', message_end_template='".$mlw_qmn_message_end."', comment_field_text='".$mlw_comment_field_text."', email_from_text='".$mlw_email_from_text."', question_answer_template='".$mlw_question_answer_template."', submit_button_text='".$mlw_submit_button_text."', name_field_text='".$mlw_name_field_text."', business_field_text='".$mlw_business_field_text."', email_field_text='".$mlw_email_field_text."', phone_field_text='".$mlw_phone_field_text."', total_user_tries_text='".$mlw_user_tries_text."', social_media_text='".$qmn_social_media_text."', pagination_text='".$mlw_qmn_pagination_field."', require_log_in_text='".$mlw_require_log_in_text."', limit_total_entries_text='".$mlw_limit_total_entries_text."', last_activity='".date("Y-m-d H:i:s")."', scheduled_timeframe_text='".$mlw_scheduled_timeframe_text."' WHERE quiz_id=".$quiz_id;
944
- $results = $wpdb->query( $update );
945
- if ($results != false)
946
- {
947
- $mlwQuizMasterNext->alertManager->newAlert('The templates has been updated successfully.', 'success');
948
-
949
- //Insert Action Into Audit Trail
950
- global $current_user;
951
- get_currentuserinfo();
952
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
953
- $insert = "INSERT INTO " . $table_name .
954
- "(trail_id, action_user, action, time) " .
955
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Templates Have Been Edited For Quiz Number ".$quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
956
- $results = $wpdb->query( $insert );
957
- }
958
- else
959
- {
960
- $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0007.', 'error');
961
- }
962
- }
963
-
964
- if (isset($_GET["quiz_id"]))
965
- {
966
- $table_name = $wpdb->prefix . "mlw_quizzes";
967
- $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
968
- }
969
-
970
- //Load Pagination Text
971
- $mlw_qmn_pagination_text = "";
972
- if (is_serialized($mlw_quiz_options->pagination_text) && is_array(@unserialize($mlw_quiz_options->pagination_text)))
973
- {
974
- $mlw_qmn_pagination_text = @unserialize($mlw_quiz_options->pagination_text);
975
- }
976
- else
977
- {
978
- $mlw_qmn_pagination_text = array('Previous', $mlw_quiz_options->pagination_text);
979
- }
980
-
981
- //Load Social Media Text
982
- $qmn_social_media_text = "";
983
- if (is_serialized($mlw_quiz_options->social_media_text) && is_array(@unserialize($mlw_quiz_options->social_media_text)))
984
- {
985
- $qmn_social_media_text = @unserialize($mlw_quiz_options->social_media_text);
986
- }
987
- else
988
- {
989
- $qmn_social_media_text = array(
990
- 'twitter' => $mlw_quiz_options->social_media_text,
991
- 'facebook' => $mlw_quiz_options->social_media_text
992
- );
993
- }
994
- ?>
995
- <div id="tabs-2" class="mlw_tab_content">
996
- <h3 style="text-align: center;">Template Variables</h3>
997
- <table class="form-table">
998
- <tr>
999
- <td><strong>%POINT_SCORE%</strong> - Total points user earned when taking quiz</td>
1000
- <td><strong>%AVERAGE_POINT%</strong> - The average amount of points user had per question</td>
1001
- </tr>
1002
-
1003
- <tr>
1004
- <td><strong>%AMOUNT_CORRECT%</strong> - The number of correct answers the user had</td>
1005
- <td><strong>%TOTAL_QUESTIONS%</strong> - The total number of questions in the quiz</td>
1006
- </tr>
1007
-
1008
- <tr>
1009
- <td><strong>%CORRECT_SCORE%</strong> - The percent score for the quiz showing percent of total quetions answered correctly</td>
1010
- </tr>
1011
-
1012
- <tr>
1013
- <td><strong>%USER_NAME%</strong> - The name the user entered before the quiz</td>
1014
- <td><strong>%USER_BUSINESS%</strong> - The business the user entered before the quiz</td>
1015
- </tr>
1016
-
1017
- <tr>
1018
- <td><strong>%USER_PHONE%</strong> - The phone number the user entered before the quiz</td>
1019
- <td><strong>%USER_EMAIL%</strong> - The email the user entered before the quiz</td>
1020
- </tr>
1021
-
1022
- <tr>
1023
- <td><strong>%QUIZ_NAME%</strong> - The name of the quiz</td>
1024
- <td><strong>%QUESTIONS_ANSWERS%</strong> - Shows the question, the answer the user provided, and the correct answer</td>
1025
- </tr>
1026
-
1027
- <tr>
1028
- <td><strong>%COMMENT_SECTION%</strong> - The comments the user entered into comment box if enabled</td>
1029
- <td><strong>%QUESTION%</strong> - The question that the user answered</td>
1030
- </tr>
1031
-
1032
- <tr>
1033
- <td><strong>%USER_ANSWER%</strong> - The answer the user gave for the question</td>
1034
- <td><strong>%CORRECT_ANSWER%</strong> - The correct answer for the question</td>
1035
- </tr>
1036
-
1037
- <tr>
1038
- <td><strong>%USER_COMMENTS%</strong> - The comments the user provided in the comment field for the question</td>
1039
- <td><strong>%CORRECT_ANSWER_INFO%</strong> - Reason why the correct answer is the correct answer</td>
1040
- </tr>
1041
- <tr>
1042
- <td><strong>%TIMER%</strong> - The amount of time user spent of quiz</td>
1043
- <td><strong>%CERTIFICATE_LINK%</strong> - The link to the certificate after completing the quiz</td>
1044
- </tr>
1045
- <tr>
1046
- <td><strong>%CURRENT_DATE%</strong> - The Current Date</td>
1047
- </tr>
1048
- </table>
1049
- <button id="save_template_button" class="button" onclick="javascript: document.quiz_template_form.submit();">Save Templates</button>
1050
- <?php
1051
- echo "<form action='' method='post' name='quiz_template_form'>";
1052
- echo "<input type='hidden' name='save_templates' value='confirmation' />";
1053
- echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
1054
- ?>
1055
- <h3 style="text-align: center;">Message Templates</h3>
1056
- <table class="form-table">
1057
- <tr>
1058
- <td width="30%">
1059
- <strong>Message Displayed Before Quiz</strong>
1060
- <br />
1061
- <p>Allowed Variables: </p>
1062
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
1063
- <p style="margin: 2px 0">- %CURRENT_DATE%</p>
1064
- </td>
1065
- <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->message_before, ENT_QUOTES), 'mlw_quiz_before_message' ); ?></td>
1066
- </tr>
1067
- <tr>
1068
- <td width="30%">
1069
- <strong>Message Displayed Before Comments Box If Enabled</strong>
1070
- <br />
1071
- <p>Allowed Variables: </p>
1072
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
1073
- <p style="margin: 2px 0">- %CURRENT_DATE%</p>
1074
- </td>
1075
- <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->message_comment, ENT_QUOTES), 'mlw_quiz_before_comments' ); ?></td>
1076
- </tr>
1077
- <tr>
1078
- <td width="30%">
1079
- <strong>Message Displayed At End Of Quiz (Leave Blank To Omit Text Section)</strong>
1080
- <br />
1081
- <p>Allowed Variables: </p>
1082
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
1083
- <p style="margin: 2px 0">- %CURRENT_DATE%</p>
1084
- </td>
1085
- <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->message_end_template, ENT_QUOTES), 'message_end_template' ); ?></td>
1086
- </tr>
1087
- <tr>
1088
- <td width="30%">
1089
- <strong>Message Displayed If User Has Tried Quiz Too Many Times</strong>
1090
- <br />
1091
- <p>Allowed Variables: </p>
1092
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
1093
- <p style="margin: 2px 0">- %CURRENT_DATE%</p>
1094
- </td>
1095
- <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->total_user_tries_text, ENT_QUOTES), 'mlw_quiz_total_user_tries_text' ); ?></td>
1096
- </tr>
1097
- <tr>
1098
- <td width="30%">
1099
- <strong>Message Displayed If User Is Not Logged In And Quiz Requires Users To Be Logged In</strong>
1100
- <br />
1101
- <p>Allowed Variables: </p>
1102
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
1103
- <p style="margin: 2px 0">- %CURRENT_DATE%</p>
1104
- </td>
1105
- <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->require_log_in_text, ENT_QUOTES), 'mlw_require_log_in_text' ); ?></td>
1106
- </tr>
1107
- <tr>
1108
- <td width="30%">
1109
- <strong>Message Displayed If Date Is Outside Scheduled Timeframe</strong>
1110
- <br />
1111
- <p>Allowed Variables: </p>
1112
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
1113
- <p style="margin: 2px 0">- %CURRENT_DATE%</p>
1114
- </td>
1115
- <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->scheduled_timeframe_text, ENT_QUOTES), 'mlw_scheduled_timeframe_text' ); ?></td>
1116
- </tr>
1117
- <tr>
1118
- <td width="30%">
1119
- <strong>Message Displayed If The Limit Of Total Entries Has Been Reached</strong>
1120
- <br />
1121
- <p>Allowed Variables: </p>
1122
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
1123
- <p style="margin: 2px 0">- %CURRENT_DATE%</p>
1124
- </td>
1125
- <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->limit_total_entries_text, ENT_QUOTES), 'mlw_limit_total_entries_text' ); ?></td>
1126
- </tr>
1127
- <tr>
1128
- <td width="30%">
1129
- <strong>%QUESTIONS_ANSWERS% Text</strong>
1130
- <br />
1131
- <p>Allowed Variables: </p>
1132
- <p style="margin: 2px 0">- %QUESTION%</p>
1133
- <p style="margin: 2px 0">- %USER_ANSWER%</p>
1134
- <p style="margin: 2px 0">- %CORRECT_ANSWER%</p>
1135
- <p style="margin: 2px 0">- %USER_COMMENTS%</p>
1136
- <p style="margin: 2px 0">- %CORRECT_ANSWER_INFO%</p>
1137
- </td>
1138
- <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->question_answer_template, ENT_QUOTES), 'mlw_quiz_question_answer_template' ); ?></td>
1139
- </tr>
1140
- <tr>
1141
- <td width="30%">
1142
- <strong>Twitter Sharing Text</strong>
1143
- <br />
1144
- <p>Allowed Variables: </p>
1145
- <p style="margin: 2px 0">- %POINT_SCORE%</p>
1146
- <p style="margin: 2px 0">- %AVERAGE_POINT%</p>
1147
- <p style="margin: 2px 0">- %AMOUNT_CORRECT%</p>
1148
- <p style="margin: 2px 0">- %TOTAL_QUESTIONS%</p>
1149
- <p style="margin: 2px 0">- %CORRECT_SCORE%</p>
1150
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
1151
- <p style="margin: 2px 0">- %TIMER%</p>
1152
- <p style="margin: 2px 0">- %CURRENT_DATE%</p>
1153
- </td>
1154
- <td><?php wp_editor( htmlspecialchars_decode($qmn_social_media_text["twitter"], ENT_QUOTES), 'mlw_quiz_twitter_text_template' ); ?></td>
1155
- </td>
1156
- </tr>
1157
- <tr>
1158
- <td width="30%">
1159
- <strong>Facebook Sharing Text</strong>
1160
- <br />
1161
- <p>Allowed Variables: </p>
1162
- <p style="margin: 2px 0">- %POINT_SCORE%</p>
1163
- <p style="margin: 2px 0">- %AVERAGE_POINT%</p>
1164
- <p style="margin: 2px 0">- %AMOUNT_CORRECT%</p>
1165
- <p style="margin: 2px 0">- %TOTAL_QUESTIONS%</p>
1166
- <p style="margin: 2px 0">- %CORRECT_SCORE%</p>
1167
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
1168
- <p style="margin: 2px 0">- %TIMER%</p>
1169
- <p style="margin: 2px 0">- %CURRENT_DATE%</p>
1170
- </td>
1171
- <td><?php wp_editor( htmlspecialchars_decode($qmn_social_media_text["facebook"], ENT_QUOTES), 'mlw_quiz_facebook_text_template' ); ?></td>
1172
- </tr>
1173
- </table>
1174
- <h3 style="text-align: center;">Other Templates</h3>
1175
- <table class="form-table">
1176
- <tr valign="top">
1177
- <th scope="row"><label for="mlw_submitText">Text for submit button</label></th>
1178
- <td><input name="mlw_submitText" type="text" id="mlw_submitText" value="<?php echo $mlw_quiz_options->submit_button_text; ?>" class="regular-text" /></td>
1179
- </tr>
1180
- <tr valign="top">
1181
- <th scope="row"><label for="mlw_nameText">Text for name field</label></th>
1182
- <td><input name="mlw_nameText" type="text" id="mlw_nameText" value="<?php echo $mlw_quiz_options->name_field_text; ?>" class="regular-text" /></td>
1183
- </tr>
1184
- <tr valign="top">
1185
- <th scope="row"><label for="mlw_businessText">Text for business field</label></th>
1186
- <td><input name="mlw_businessText" type="text" id="mlw_businessText" value="<?php echo $mlw_quiz_options->business_field_text; ?>" class="regular-text" /></td>
1187
- </tr>
1188
- <tr valign="top">
1189
- <th scope="row"><label for="mlw_emailText">Text for email field</label></th>
1190
- <td><input name="mlw_emailText" type="text" id="mlw_emailText" value="<?php echo $mlw_quiz_options->email_field_text; ?>" class="regular-text" /></td>
1191
- </tr>
1192
- <tr valign="top">
1193
- <th scope="row"><label for="mlw_phoneText">Text for phone number field</label></th>
1194
- <td><input name="mlw_phoneText" type="text" id="mlw_phoneText" value="<?php echo $mlw_quiz_options->phone_field_text; ?>" class="regular-text" /></td>
1195
- </tr>
1196
- <tr valign="top">
1197
- <th scope="row"><label for="mlw_commentText">Text for comments field</label></th>
1198
- <td><input name="mlw_commentText" type="text" id="mlw_commentText" value="<?php echo $mlw_quiz_options->comment_field_text; ?>" class="regular-text" /></td>
1199
- </tr>
1200
- <tr valign="top">
1201
- <th scope="row"><label for="pagination_prev_text">Text for previous button</label></th>
1202
- <td><input name="pagination_prev_text" type="text" id="pagination_prev_text" value="<?php echo $mlw_qmn_pagination_text[0]; ?>" class="regular-text" /></td>
1203
- </tr>
1204
- <tr valign="top">
1205
- <th scope="row"><label for="pagination_next_text">Text for next button</label></th>
1206
- <td><input name="pagination_next_text" type="text" id="pagination_next_text" value="<?php echo $mlw_qmn_pagination_text[1]; ?>" class="regular-text" /></td>
1207
- </tr>
1208
- <tr valign="top">
1209
- <th scope="row"><label for="emailFromText">What is the From Name for the email sent to users and admin?</label></th>
1210
- <td><input name="emailFromText" type="text" id="emailFromText" value="<?php echo $mlw_quiz_options->email_from_text; ?>" class="regular-text" /></td>
1211
- </tr>
1212
- </table>
1213
- <button id="save_template_button" class="button" onclick="javascript: document.quiz_template_form.submit();">Save Templates</button>
1214
- <?php echo "</form>"; ?>
1215
- </div>
1216
- <?php
1217
- }
1218
-
1219
- function mlw_options_option_tab_content()
1220
- {
1221
- global $wpdb;
1222
- global $mlwQuizMasterNext;
1223
- $quiz_id = $_GET["quiz_id"];
1224
- //Submit saved options into database
1225
- if ( isset($_POST["save_options"]) && $_POST["save_options"] == "confirmation")
1226
- {
1227
- //Variables for save options form
1228
- $mlw_system = $_POST["system"];
1229
- $mlw_qmn_pagination = intval($_POST["pagination"]);
1230
- $mlw_qmn_social_media = intval($_POST["social_media"]);
1231
- $mlw_qmn_question_numbering = intval($_POST["question_numbering"]);
1232
- $mlw_qmn_timer = intval($_POST["timer_limit"]);
1233
- $mlw_qmn_questions_from_total = $_POST["question_from_total"];
1234
- $mlw_randomness_order = $_POST["randomness_order"];
1235
- $mlw_total_user_tries = intval($_POST["total_user_tries"]);
1236
- $mlw_require_log_in = $_POST["require_log_in"];
1237
- $mlw_limit_total_entries = $_POST["limit_total_entries"];
1238
- $mlw_contact_location = $_POST["contact_info_location"];
1239
- $mlw_user_name = $_POST["userName"];
1240
- $mlw_user_comp = $_POST["userComp"];
1241
- $mlw_user_email = $_POST["userEmail"];
1242
- $mlw_user_phone = $_POST["userPhone"];
1243
- $mlw_comment_section = $_POST["commentSection"];
1244
- $mlw_qmn_loggedin_contact = $_POST["loggedin_user_contact"];
1245
- $qmn_scheduled_timeframe = serialize(array("start" => $_POST["scheduled_time_start"], "end" => $_POST["scheduled_time_end"]));
1246
- $quiz_id = $_POST["quiz_id"];
1247
-
1248
- $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET system='".$mlw_system."', loggedin_user_contact='".$mlw_qmn_loggedin_contact."', contact_info_location=".$mlw_contact_location.", user_name='".$mlw_user_name."', user_comp='".$mlw_user_comp."', user_email='".$mlw_user_email."', user_phone='".$mlw_user_phone."', comment_section='".$mlw_comment_section."', randomness_order='".$mlw_randomness_order."', question_from_total=".$mlw_qmn_questions_from_total.", total_user_tries=".$mlw_total_user_tries.", social_media=".$mlw_qmn_social_media.", pagination=".$mlw_qmn_pagination.", timer_limit=".$mlw_qmn_timer.", question_numbering=".$mlw_qmn_question_numbering.", require_log_in=".$mlw_require_log_in.", limit_total_entries=".$mlw_limit_total_entries.", last_activity='".date("Y-m-d H:i:s")."', scheduled_timeframe='".$qmn_scheduled_timeframe."' WHERE quiz_id=".$quiz_id;
1249
- $results = $wpdb->query( $update );
1250
- if ($results != false)
1251
- {
1252
- $mlwQuizMasterNext->alertManager->newAlert('The options has been updated successfully.', 'success');
1253
-
1254
- //Insert Action Into Audit Trail
1255
- global $current_user;
1256
- get_currentuserinfo();
1257
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
1258
- $insert = "INSERT INTO " . $table_name .
1259
- "(trail_id, action_user, action, time) " .
1260
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Options Have Been Edited For Quiz Number ".$quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
1261
- $results = $wpdb->query( $insert );
1262
- }
1263
- else
1264
- {
1265
- $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0008.', 'error');
1266
- }
1267
- }
1268
-
1269
- if (isset($_GET["quiz_id"]))
1270
- {
1271
- $table_name = $wpdb->prefix . "mlw_quizzes";
1272
- $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
1273
- }
1274
-
1275
- //Load Scheduled Timeframe
1276
- $qmn_scheduled_timeframe = "";
1277
- if (is_serialized($mlw_quiz_options->scheduled_timeframe) && is_array(@unserialize($mlw_quiz_options->scheduled_timeframe)))
1278
- {
1279
- $qmn_scheduled_timeframe = @unserialize($mlw_quiz_options->scheduled_timeframe);
1280
- }
1281
- else
1282
- {
1283
- $qmn_scheduled_timeframe = array("start" => '', "end" => '');
1284
- }
1285
- ?>
1286
- <div id="tabs-3" class="mlw_tab_content">
1287
- <script>
1288
- jQuery(function() {
1289
- jQuery( "#system, #require_log_in, #randomness_order, #loggedin_user_contact, #sendUserEmail, #sendAdminEmail, #contact_info_location, #userName, #userComp, #userEmail, #userPhone, #pagination, #commentSection, #social_media, #question_numbering, #comments" ).buttonset();
1290
- jQuery( "#scheduled_time_start, #scheduled_time_end" ).datepicker();
1291
- });
1292
- </script>
1293
- <button id="save_options_button" class="button" onclick="javascript: document.quiz_options_form.submit();">Save Options</button>
1294
- <?php
1295
- echo "<form action='' method='post' name='quiz_options_form'>";
1296
- echo "<input type='hidden' name='save_options' value='confirmation' />";
1297
- echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
1298
- ?>
1299
- <table class="form-table" style="width: 100%;">
1300
- <tr valign="top">
1301
- <th scope="row"><label for="system">Which system is this quiz graded on?</label></th>
1302
- <td><div id="system">
1303
- <input type="radio" id="radio1" name="system" <?php if ($mlw_quiz_options->system == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio1">Correct/Incorrect</label>
1304
- <input type="radio" id="radio2" name="system" <?php if ($mlw_quiz_options->system == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio2">Points</label>
1305
- <input type="radio" id="radio3" name="system" <?php if ($mlw_quiz_options->system == 2) {echo 'checked="checked"';} ?> value='2' /><label for="radio3">Not Graded</label>
1306
- </div></td>
1307
- </tr>
1308
- <tr valign="top">
1309
- <th scope="row"><label for="require_log_in">Should the user be required to be logged in to take this quiz?</label></th>
1310
- <td><div id="require_log_in">
1311
- <input type="radio" id="radio_login_1" name="require_log_in" <?php if ($mlw_quiz_options->require_log_in == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio_login_1">Yes</label>
1312
- <input type="radio" id="radio_login_2" name="require_log_in" <?php if ($mlw_quiz_options->require_log_in == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio_login_2">No</label>
1313
- </div></td>
1314
- </tr>
1315
- <tr valign="top">
1316
- <th scope="row"><label for="pagination">How many questions per page would you like? (Leave 0 for all questions on one page)</label></th>
1317
- <td>
1318
- <input type="number" step="1" min="0" max="1000" name="pagination" value="<?php echo $mlw_quiz_options->pagination; ?>" class="regular-text" />
1319
- </td>
1320
- </tr>
1321
- <tr valign="top">
1322
- <th scope="row"><label for="timer_limit">How many minutes does the user have to finish the quiz? (Leave 0 for no time limit)</label></th>
1323
- <td>
1324
- <input name="timer_limit" type="number" step="1" min="0" id="timer_limit" value="<?php echo $mlw_quiz_options->timer_limit; ?>" class="regular-text" />
1325
- </td>
1326
- </tr>
1327
- <tr valign="top">
1328
- <th scope="row"><label for="total_user_tries">How many times can a user take this quiz? (Leave 0 for as many times as the user wants to. Currently only works for registered users)</label></th>
1329
- <td>
1330
- <input name="total_user_tries" type="number" step="1" min="0" id="total_user_tries" value="<?php echo $mlw_quiz_options->total_user_tries; ?>" class="regular-text" />
1331
- </td>
1332
- </tr>
1333
- <tr valign="top">
1334
- <th scope="row"><label for="limit_total_entries">How many total entries can this quiz have? (Leave 0 for unlimited entries)</label></th>
1335
- <td>
1336
- <input name="limit_total_entries" type="number" step="1" min="0" id="limit_total_entries" value="<?php echo $mlw_quiz_options->limit_total_entries; ?>" class="regular-text" />
1337
- </td>
1338
- </tr>
1339
- <tr valign="top">
1340
- <th scope="row"><label for="question_from_total">How many questions should be loaded for quiz? (Leave 0 to load all questions)</label></th>
1341
- <td>
1342
- <input name="question_from_total" type="number" step="1" min="0" id="question_from_total" value="<?php echo $mlw_quiz_options->question_from_total; ?>" class="regular-text" />
1343
- </td>
1344
- </tr>
1345
- <tr valign="top">
1346
- <th scope="row"><label for="scheduled_time_start">What time-frame should the user be able to access the quiz? (Leave blank if the user can access anytime)</label></th>
1347
- <td>
1348
- <input name="scheduled_time_start" placeholder="start date" type="text" id="scheduled_time_start" value="<?php echo $qmn_scheduled_timeframe["start"] ?>" class="regular-text" />
1349
- </td>
1350
- <td>
1351
- <input name="scheduled_time_end" type="text" placeholder="end date" id="scheduled_time_end" value="<?php echo $qmn_scheduled_timeframe["end"] ?>" class="regular-text" />
1352
- </td>
1353
- </tr>
1354
- <tr valign="top">
1355
- <th scope="row"><label for="randomness_order">Are the questions random? (Question Order will not apply if this is yes)</label></th>
1356
- <td><div id="randomness_order">
1357
- <input type="radio" id="radio24" name="randomness_order" <?php if ($mlw_quiz_options->randomness_order == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio24">Random Questions</label>
1358
- <input type="radio" id="randomness2" name="randomness_order" <?php if ($mlw_quiz_options->randomness_order == 2) {echo 'checked="checked"';} ?> value='2' /><label for="randomness2">Random Questions And Answers</label>
1359
- <input type="radio" id="radio23" name="randomness_order" <?php if ($mlw_quiz_options->randomness_order == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio23">No</label>
1360
- </div></td>
1361
- </tr>
1362
- <tr valign="top">
1363
- <th scope="row"><label for="contact_info_location">Would you like to ask for the contact information at the beginning or at the end of the quiz?</label></th>
1364
- <td><div id="contact_info_location">
1365
- <input type="radio" id="radio25" name="contact_info_location" <?php if ($mlw_quiz_options->contact_info_location == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio25">Beginning</label>
1366
- <input type="radio" id="radio26" name="contact_info_location" <?php if ($mlw_quiz_options->contact_info_location == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio26">End</label>
1367
- </div></td>
1368
- </tr>
1369
- <tr valign="top">
1370
- <th scope="row"><label for="loggedin_user_contact">If a logged-in user takes the quiz, would you like them to be able to edit contact information? If set to no, the fields will not show up for logged in users; however, the users information will be saved for the fields.</label></th>
1371
- <td><div id="loggedin_user_contact">
1372
- <input type="radio" id="radio27" name="loggedin_user_contact" <?php if ($mlw_quiz_options->loggedin_user_contact == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio27">Yes</label>
1373
- <input type="radio" id="radio28" name="loggedin_user_contact" <?php if ($mlw_quiz_options->loggedin_user_contact == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio28">No</label>
1374
- </div></td>
1375
- </tr>
1376
- <tr valign="top">
1377
- <th scope="row"><label for="userName">Should we ask for user's name?</label></th>
1378
- <td><div id="userName">
1379
- <input type="radio" id="radio7" name="userName" <?php if ($mlw_quiz_options->user_name == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio7">Yes</label>
1380
- <input type="radio" id="radio8" name="userName" <?php if ($mlw_quiz_options->user_name == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio8">Require</label>
1381
- <input type="radio" id="radio9" name="userName" <?php if ($mlw_quiz_options->user_name == 2) {echo 'checked="checked"';} ?> value='2' /><label for="radio9">No</label>
1382
- </div></td>
1383
- </tr>
1384
- <tr valign="top">
1385
- <th scope="row"><label for="userComp">Should we ask for user's business?</label></th>
1386
- <td><div id="userComp">
1387
- <input type="radio" id="radio10" name="userComp" <?php if ($mlw_quiz_options->user_comp == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio10">Yes</label>
1388
- <input type="radio" id="radio11" name="userComp" <?php if ($mlw_quiz_options->user_comp == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio11">Require</label>
1389
- <input type="radio" id="radio12" name="userComp" <?php if ($mlw_quiz_options->user_comp == 2) {echo 'checked="checked"';} ?> value='2' /><label for="radio12">No</label>
1390
- </div></td>
1391
- </tr>
1392
- <tr valign="top">
1393
- <th scope="row"><label for="userEmail">Should we ask for user's email?</label></th>
1394
- <td><div id="userEmail">
1395
- <input type="radio" id="radio13" name="userEmail" <?php if ($mlw_quiz_options->user_email == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio13">Yes</label>
1396
- <input type="radio" id="radio14" name="userEmail" <?php if ($mlw_quiz_options->user_email == 1) {echo 'checked="checked"';} ?> value='1'/><label for="radio14">Require</label>
1397
- <input type="radio" id="radio15" name="userEmail" <?php if ($mlw_quiz_options->user_email == 2) {echo 'checked="checked"';} ?> value='2' /><label for="radio15">No</label>
1398
- </div></td>
1399
- </tr>
1400
- <tr valign="top">
1401
- <th scope="row"><label for="userPhone">Should we ask for user's phone number?</label></th>
1402
- <td><div id="userPhone">
1403
- <input type="radio" id="radio16" name="userPhone" <?php if ($mlw_quiz_options->user_phone == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio16">Yes</label>
1404
- <input type="radio" id="radio17" name="userPhone" <?php if ($mlw_quiz_options->user_phone == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio17">Require</label>
1405
- <input type="radio" id="radio18" name="userPhone" <?php if ($mlw_quiz_options->user_phone == 2) {echo 'checked="checked"';} ?> value='2' /><label for="radio18">No</label>
1406
- </div></td>
1407
- </tr>
1408
- <tr valign="top">
1409
- <th scope="row"><label for="commentSection">Would you like a place for the user to enter comments?</label></th>
1410
- <td><div id="commentSection">
1411
- <input type="radio" id="radio21" name="commentSection" <?php if ($mlw_quiz_options->comment_section == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio21">Yes</label>
1412
- <input type="radio" id="radio22" name="commentSection" <?php if ($mlw_quiz_options->comment_section == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio22">No</label>
1413
- </div></td>
1414
- </tr>
1415
- <tr valign="top">
1416
- <th scope="row"><label for="question_numbering">Show question number on quiz?</label></th>
1417
- <td><div id="question_numbering">
1418
- <input type="radio" id="question_numbering_radio2" name="question_numbering" <?php if ($mlw_quiz_options->question_numbering == 1) {echo 'checked="checked"';} ?> value='1' /><label for="question_numbering_radio2">Yes</label>
1419
- <input type="radio" id="question_numbering_radio" name="question_numbering" <?php if ($mlw_quiz_options->question_numbering == 0) {echo 'checked="checked"';} ?> value='0' /><label for="question_numbering_radio">No</label>
1420
- </div></td>
1421
- </tr>
1422
- <tr valign="top">
1423
- <th scope="row"><label for="social_media">Show social media sharing buttons? (Twitter & Facebook)</label></th>
1424
- <td><div id="social_media">
1425
- <input type="radio" id="social_media_radio2" name="social_media" <?php if ($mlw_quiz_options->social_media == 1) {echo 'checked="checked"';} ?> value='1' /><label for="social_media_radio2">Yes</label>
1426
- <input type="radio" id="social_media_radio" name="social_media" <?php if ($mlw_quiz_options->social_media == 0) {echo 'checked="checked"';} ?> value='0' /><label for="social_media_radio">No</label>
1427
- </div></td>
1428
- </tr>
1429
- </table>
1430
- <button id="save_options_button" class="button" onclick="javascript: document.quiz_options_form.submit();">Save Options</button>
1431
- <?php echo "</form>"; ?>
1432
- </div>
1433
- <?php
1434
- }
1435
-
1436
- function mlw_options_leaderboard_tab_content()
1437
- {
1438
- global $wpdb;
1439
- global $mlwQuizMasterNext;
1440
- $quiz_id = $_GET["quiz_id"];
1441
- ///Submit saved leaderboard template into database
1442
- if ( isset($_POST["save_leaderboard_options"]) && $_POST["save_leaderboard_options"] == "confirmation")
1443
- {
1444
- ///Variables for save leaderboard options form
1445
- $mlw_leaderboard_template = $_POST["mlw_quiz_leaderboard_template"];
1446
- $mlw_leaderboard_quiz_id = $_POST["leaderboard_quiz_id"];
1447
- $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET leaderboard_template='".$mlw_leaderboard_template."', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$mlw_leaderboard_quiz_id;
1448
- $results = $wpdb->query( $update );
1449
- if ($results != false)
1450
- {
1451
- $mlwQuizMasterNext->alertManager->newAlert('The leaderboards has been updated successfully.', 'success');
1452
-
1453
- //Insert Action Into Audit Trail
1454
- global $current_user;
1455
- get_currentuserinfo();
1456
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
1457
- $insert = "INSERT INTO " . $table_name .
1458
- "(trail_id, action_user, action, time) " .
1459
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Leaderboard Options Have Been Edited For Quiz Number ".$mlw_leaderboard_quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
1460
- $results = $wpdb->query( $insert );
1461
- }
1462
- else
1463
- {
1464
- $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0009.', 'error');
1465
- }
1466
- }
1467
-
1468
- if (isset($_GET["quiz_id"]))
1469
- {
1470
- $table_name = $wpdb->prefix . "mlw_quizzes";
1471
- $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
1472
- }
1473
- ?>
1474
- <div id="tabs-4" class="mlw_tab_content">
1475
- <h3>Template Variables</h3>
1476
- <table class="form-table">
1477
- <tr>
1478
- <td><strong>%FIRST_PLACE_NAME%</strong> - The name of the user who is in first place</td>
1479
- <td><strong>%FIRST_PLACE_SCORE%</strong> - The score from the first place's quiz</td>
1480
- </tr>
1481
-
1482
- <tr>
1483
- <td><strong>%SECOND_PLACE_NAME%</strong> - The name of the user who is in second place</td>
1484
- <td><strong>%SECOND_PLACE_SCORE%</strong> - The score from the second place's quiz</td>
1485
- </tr>
1486
-
1487
- <tr>
1488
- <td><strong>%THIRD_PLACE_NAME%</strong> - The name of the user who is in third place</td>
1489
- <td><strong>%THIRD_PLACE_SCORE%</strong> - The score from the third place's quiz</td>
1490
- </tr>
1491
-
1492
- <tr>
1493
- <td><strong>%FOURTH_PLACE_NAME%</strong> - The name of the user who is in fourth place</td>
1494
- <td><strong>%FOURTH_PLACE_SCORE%</strong> - The score from the fourth place's quiz</td>
1495
- </tr>
1496
-
1497
- <tr>
1498
- <td><strong>%FIFTH_PLACE_NAME%</strong> - The name of the user who is in fifth place</td>
1499
- <td><strong>%FIFTH_PLACE_SCORE%</strong> - The score from the fifth place's quiz</td>
1500
- </tr>
1501
-
1502
- <tr>
1503
- <td><strong>%QUIZ_NAME%</strong> - The name of the quiz</td>
1504
- </tr>
1505
- </table>
1506
- <button id="save_template_button" class="button" onclick="javascript: document.quiz_leaderboard_options_form.submit();">Save Leaderboard Options</button>
1507
- <?php
1508
- echo "<form action='' method='post' name='quiz_leaderboard_options_form'>";
1509
- echo "<input type='hidden' name='save_leaderboard_options' value='confirmation' />";
1510
- echo "<input type='hidden' name='leaderboard_quiz_id' value='".$quiz_id."' />";
1511
- ?>
1512
- <table class="form-table">
1513
- <tr>
1514
- <td width="30%">
1515
- <strong>Leaderboard Template</strong>
1516
- <br />
1517
- <p>Allowed Variables: </p>
1518
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
1519
- <p style="margin: 2px 0">- %FIRST_PLACE_NAME%</p>
1520
- <p style="margin: 2px 0">- %FIRST_PLACE_SCORE%</p>
1521
- <p style="margin: 2px 0">- %SECOND_PLACE_NAME%</p>
1522
- <p style="margin: 2px 0">- %SECOND_PLACE_SCORE%</p>
1523
- <p style="margin: 2px 0">- %THIRD_PLACE_NAME%</p>
1524
- <p style="margin: 2px 0">- %THIRD_PLACE_SCORE%</p>
1525
- <p style="margin: 2px 0">- %FOURTH_PLACE_NAME%</p>
1526
- <p style="margin: 2px 0">- %FOURTH_PLACE_SCORE%</p>
1527
- <p style="margin: 2px 0">- %FIFTH_PLACE_NAME%</p>
1528
- <p style="margin: 2px 0">- %FIFTH_PLACE_SCORE%</p>
1529
- </td>
1530
- <td><textarea cols="80" rows="15" id="mlw_quiz_leaderboard_template" name="mlw_quiz_leaderboard_template"><?php echo $mlw_quiz_options->leaderboard_template; ?></textarea>
1531
- </td>
1532
- </tr>
1533
- </table>
1534
- <button id="save_template_button" class="button" onclick="javascript: document.quiz_leaderboard_options_form.submit();">Save Leaderboard Options</button>
1535
- </form>
1536
- </div>
1537
- <?php
1538
- }
1539
-
1540
- function mlw_options_certificate_tab_content()
1541
- {
1542
- global $wpdb;
1543
- global $mlwQuizMasterNext;
1544
- $quiz_id = $_GET["quiz_id"];
1545
- //Saved Certificate Options
1546
- if (isset($_POST["save_certificate_options"]) && $_POST["save_certificate_options"] == "confirmation")
1547
- {
1548
- $mlw_certificate_id = intval($_POST["certificate_quiz_id"]);
1549
- $mlw_certificate_title = $_POST["certificate_title"];
1550
- $mlw_certificate_text = $_POST["certificate_template"];
1551
- $mlw_certificate_logo = $_POST["certificate_logo"];
1552
- $mlw_certificate_background = $_POST["certificate_background"];
1553
- $mlw_enable_certificates = intval($_POST["enableCertificates"]);
1554
- $mlw_certificate = array($mlw_certificate_title, $mlw_certificate_text, $mlw_certificate_logo, $mlw_certificate_background, $mlw_enable_certificates);
1555
- $mlw_certificate_serialized = serialize($mlw_certificate);
1556
-
1557
- $mlw_certificate_sql_results = $wpdb->query( $wpdb->prepare( "UPDATE " . $wpdb->prefix . "mlw_quizzes SET certificate_template=%s, last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_certificate_serialized, $mlw_certificate_id ) );
1558
-
1559
-
1560
- if ($mlw_certificate_sql_results != false)
1561
- {
1562
- $mlwQuizMasterNext->alertManager->newAlert('The certificate has been updated successfully.', 'success');
1563
-
1564
- //Insert Action Into Audit Trail
1565
- global $current_user;
1566
- get_currentuserinfo();
1567
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
1568
- $insert = "INSERT INTO " . $table_name .
1569
- "(trail_id, action_user, action, time) " .
1570
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Certificate Options Have Been Edited For Quiz Number ".$mlw_certificate_id."' , '" . date("h:i:s A m/d/Y") . "')";
1571
- $results = $wpdb->query( $insert );
1572
- }
1573
- else
1574
- {
1575
- $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0012.', 'error');
1576
- }
1577
- }
1578
- if (isset($_GET["quiz_id"]))
1579
- {
1580
- $table_name = $wpdb->prefix . "mlw_quizzes";
1581
- $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
1582
- }
1583
-
1584
- //Load Certificate Options Variables
1585
- if (is_serialized($mlw_quiz_options->certificate_template) && is_array(@unserialize($mlw_quiz_options->certificate_template)))
1586
- {
1587
- $mlw_certificate_options = @unserialize($mlw_quiz_options->certificate_template);
1588
- }
1589
- else
1590
- {
1591
- $mlw_certificate_options = array('Enter title here', 'Enter text here', '', '', 1);
1592
- }
1593
- ?>
1594
- <div id="tabs-5" class="mlw_tab_content">
1595
- <script>
1596
- jQuery(function() {
1597
- jQuery( "#enableCertificates" ).buttonset();
1598
- });
1599
- </script>
1600
- <h3>Quiz Certificate (Beta)</h3>
1601
- <p>Enter in your text here to fill in the certificate for this quiz. Be sure to enter in the link variable into the templates on the Quiz Text tab so the user can access the certificate.</p>
1602
- <p>These fields cannot contain HTML.</p>
1603
- <button id="save_certificate_button" class="button" onclick="javascript: document.quiz_certificate_options_form.submit();">Save Certificate Options</button>
1604
- <?php
1605
- echo "<form action='' method='post' name='quiz_certificate_options_form'>";
1606
- echo "<input type='hidden' name='save_certificate_options' value='confirmation' />";
1607
- echo "<input type='hidden' name='certificate_quiz_id' value='".$quiz_id."' />";
1608
- ?>
1609
- <table class="form-table">
1610
- <tr valign="top">
1611
- <td><label for="enableCertificates">Enable Certificates For This Quiz?</label></td>
1612
- <td><div id="enableCertificates">
1613
- <input type="radio" id="radio30" name="enableCertificates" <?php if ($mlw_certificate_options[4] == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio30">Yes</label>
1614
- <input type="radio" id="radio31" name="enableCertificates" <?php if ($mlw_certificate_options[4] == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio31">No</label>
1615
- </div></td>
1616
- </tr>
1617
- <tr>
1618
- <td width="30%">
1619
- <strong>Certificate Title</strong>
1620
- </td>
1621
- <td><textarea cols="80" rows="15" id="certificate_title" name="certificate_title"><?php echo $mlw_certificate_options[0]; ?></textarea>
1622
- </td>
1623
- </tr>
1624
- <tr>
1625
- <td width="30%">
1626
- <strong>Message Displayed On Certificate</strong>
1627
- <br />
1628
- <p>Allowed Variables: </p>
1629
- <p style="margin: 2px 0">- %POINT_SCORE%</p>
1630
- <p style="margin: 2px 0">- %AVERAGE_POINT%</p>
1631
- <p style="margin: 2px 0">- %AMOUNT_CORRECT%</p>
1632
- <p style="margin: 2px 0">- %TOTAL_QUESTIONS%</p>
1633
- <p style="margin: 2px 0">- %CORRECT_SCORE%</p>
1634
- <p style="margin: 2px 0">- %QUIZ_NAME%</p>
1635
- <p style="margin: 2px 0">- %USER_NAME%</p>
1636
- <p style="margin: 2px 0">- %USER_BUSINESS%</p>
1637
- <p style="margin: 2px 0">- %USER_PHONE%</p>
1638
- <p style="margin: 2px 0">- %USER_EMAIL%</p>
1639
- <p style="margin: 2px 0">- %CURRENT_DATE%</p>
1640
- </td>
1641
- <td><label for="certificate_template">Allowed tags: &lt;b&gt; - bold, &lt;i&gt;-italics, &lt;u&gt;-underline, &lt;br&gt;-New Line or start a new line by pressing enter</label><textarea cols="80" rows="15" id="certificate_template" name="certificate_template"><?php echo $mlw_certificate_options[1]; ?></textarea>
1642
- </td>
1643
- </tr>
1644
- <tr>
1645
- <td width="30%">
1646
- <strong>URL To Logo (Must be JPG, JPEG, PNG or GIF)</strong>
1647
- </td>
1648
- <td><textarea cols="80" rows="15" id="certificate_logo" name="certificate_logo"><?php echo $mlw_certificate_options[2]; ?></textarea>
1649
- </td>
1650
- </tr>
1651
- <tr>
1652
- <td width="30%">
1653
- <strong>URL To Background Img (Must be JPG, JPEG, PNG or GIF)</strong>
1654
- </td>
1655
- <td><textarea cols="80" rows="15" id="certificate_background" name="certificate_background"><?php echo $mlw_certificate_options[3]; ?></textarea>
1656
- </td>
1657
- </tr>
1658
- </table>
1659
- <button id="save_certificate_button" class="button" onclick="javascript: document.quiz_certificate_options_form.submit();">Save Certificate Options</button>
1660
- </form>
1661
- </div>
1662
- <?php
1663
- }
1664
-
1665
- function mlw_options_emails_tab_content()
1666
- {
1667
- global $wpdb;
1668
- global $mlwQuizMasterNext;
1669
- $quiz_id = $_GET["quiz_id"];
1670
- //Check to add new user email template
1671
- if (isset($_POST["mlw_add_email_page"]) && $_POST["mlw_add_email_page"] == "confirmation")
1672
- {
1673
- //Function variables
1674
- $mlw_qmn_add_email_id = intval($_POST["mlw_add_email_quiz_id"]);
1675
- $mlw_qmn_user_email = $wpdb->get_var( $wpdb->prepare( "SELECT user_email_template FROM ".$wpdb->prefix."mlw_quizzes WHERE quiz_id=%d", $mlw_qmn_add_email_id ) );
1676
-
1677
- //Load user email and check if it is array already. If not, turn it into one
1678
- if (is_serialized($mlw_qmn_user_email) && is_array(@unserialize($mlw_qmn_user_email)))
1679
- {
1680
- $mlw_qmn_email_array = @unserialize($mlw_qmn_user_email);
1681
- $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here', 'Quiz Results For %QUIZ_NAME%');
1682
- array_unshift($mlw_qmn_email_array , $mlw_new_landing_array);
1683
- $mlw_qmn_email_array = serialize($mlw_qmn_email_array);
1684
-
1685
- }
1686
- else
1687
- {
1688
- $mlw_qmn_email_array = array(array(0, 0, $mlw_qmn_user_email, 'Quiz Results For %QUIZ_NAME%'));
1689
- $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here', 'Quiz Results For %QUIZ_NAME%');
1690
- array_unshift($mlw_qmn_email_array , $mlw_new_landing_array);
1691
- $mlw_qmn_email_array = serialize($mlw_qmn_email_array);
1692
- }
1693
- //Update email template with new array then check to see if worked
1694
- $mlw_new_email_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET user_email_template='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_email_array, $mlw_qmn_add_email_id ) );
1695
- if ($mlw_new_email_results != false)
1696
- {
1697
- $mlwQuizMasterNext->alertManager->newAlert('The email has been added successfully.', 'success');
1698
-
1699
- //Insert Action Into Audit Trail
1700
- global $current_user;
1701
- get_currentuserinfo();
1702
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
1703
- $insert = "INSERT INTO " . $table_name .
1704
- "(trail_id, action_user, action, time) " .
1705
- "VALUES (NULL , '" . $current_user->display_name . "' , 'New User Email Has Been Created For Quiz Number ".$mlw_qmn_add_email_id."' , '" . date("h:i:s A m/d/Y") . "')";
1706
- $results = $wpdb->query( $insert );
1707
- }
1708
- else
1709
- {
1710
- $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0016.', 'error');
1711
- }
1712
- }
1713
-
1714
- //Check to add new admin email template
1715
- if (isset($_POST["mlw_add_admin_email_page"]) && $_POST["mlw_add_admin_email_page"] == "confirmation")
1716
- {
1717
- //Function variables
1718
- $mlw_qmn_add_email_id = intval($_POST["mlw_add_admin_email_quiz_id"]);
1719
- $mlw_qmn_admin_email = $wpdb->get_var( $wpdb->prepare( "SELECT admin_email_template FROM ".$wpdb->prefix."mlw_quizzes WHERE quiz_id=%d", $mlw_qmn_add_email_id ) );
1720
-
1721
- //Load user email and check if it is array already. If not, turn it into one
1722
- if (is_serialized($mlw_qmn_admin_email) && is_array(@unserialize($mlw_qmn_admin_email)))
1723
- {
1724
- $mlw_qmn_email_array = @unserialize($mlw_qmn_admin_email);
1725
- $mlw_new_landing_array = array(
1726
- "begin_score" => 0,
1727
- "end_score" => 100,
1728
- "message" => 'Enter Your Text Here',
1729
- "subject" => 'Quiz Results For %QUIZ_NAME%'
1730
- );
1731
- array_unshift($mlw_qmn_email_array , $mlw_new_landing_array);
1732
- $mlw_qmn_email_array = serialize($mlw_qmn_email_array);
1733
-
1734
- }
1735
- else
1736
- {
1737
- $mlw_qmn_email_array = array(array(
1738
- "begin_score" => 0,
1739
- "end_score" => 0,
1740
- "message" => $mlw_qmn_admin_email,
1741
- "subject" => 'Quiz Results For %QUIZ_NAME%'
1742
- ));
1743
- $mlw_new_landing_array = array(
1744
- "begin_score" => 0,
1745
- "end_score" => 100,
1746
- "message" => 'Enter Your Text Here',
1747
- "subject" => 'Quiz Results For %QUIZ_NAME%'
1748
- );
1749
- array_unshift($mlw_qmn_email_array , $mlw_new_landing_array);
1750
- $mlw_qmn_email_array = serialize($mlw_qmn_email_array);
1751
- }
1752
- //Update email template with new array then check to see if worked
1753
- $mlw_new_email_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET admin_email_template='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_email_array, $mlw_qmn_add_email_id ) );
1754
- if ($mlw_new_email_results != false)
1755
- {
1756
- $mlwQuizMasterNext->alertManager->newAlert('The email has been added successfully.', 'success');
1757
-
1758
- //Insert Action Into Audit Trail
1759
- global $current_user;
1760
- get_currentuserinfo();
1761
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
1762
- $insert = "INSERT INTO " . $table_name .
1763
- "(trail_id, action_user, action, time) " .
1764
- "VALUES (NULL , '" . $current_user->display_name . "' , 'New Admin Email Has Been Created For Quiz Number ".$mlw_qmn_add_email_id."' , '" . date("h:i:s A m/d/Y") . "')";
1765
- $results = $wpdb->query( $insert );
1766
- }
1767
- else
1768
- {
1769
- $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0016.', 'error');
1770
- }
1771
- }
1772
-
1773
- //Check to save email templates
1774
- if (isset($_POST["mlw_save_email_template"]) && $_POST["mlw_save_email_template"] == "confirmation")
1775
- {
1776
- //Function Variables
1777
- $mlw_qmn_email_id = intval($_POST["mlw_email_quiz_id"]);
1778
- $mlw_qmn_email_template_total = intval($_POST["mlw_email_template_total"]);
1779
- $mlw_qmn_email_admin_total = intval($_POST["mlw_email_admin_total"]);
1780
- $mlw_send_user_email = $_POST["sendUserEmail"];
1781
- $mlw_send_admin_email = $_POST["sendAdminEmail"];
1782
- $mlw_admin_email = $_POST["adminEmail"];
1783
-
1784
- //Create new array
1785
- $i = 1;
1786
- $mlw_qmn_new_email_array = array();
1787
- while ($i <= $mlw_qmn_email_template_total)
1788
- {
1789
- if ($_POST["user_email_".$i] != "Delete")
1790
- {
1791
- $mlw_qmn_email_each = array(intval($_POST["user_email_begin_".$i]), intval($_POST["user_email_end_".$i]), htmlspecialchars(stripslashes($_POST["user_email_".$i]), ENT_QUOTES), htmlspecialchars(stripslashes($_POST["user_email_subject_".$i]), ENT_QUOTES));
1792
- $mlw_qmn_new_email_array[] = $mlw_qmn_email_each;
1793
- }
1794
- $i++;
1795
- }
1796
-
1797
- //Create new array
1798
- $i = 1;
1799
- $mlw_qmn_new_admin_array = array();
1800
- while ($i <= $mlw_qmn_email_admin_total)
1801
- {
1802
- if ($_POST["admin_email_".$i] != "Delete")
1803
- {
1804
- $mlw_qmn_email_each = array(
1805
- "begin_score" => intval($_POST["admin_email_begin_".$i]),
1806
- "end_score" => intval($_POST["admin_email_end_".$i]),
1807
- "message" => htmlspecialchars(stripslashes($_POST["admin_email_".$i]), ENT_QUOTES),
1808
- "subject" => htmlspecialchars(stripslashes($_POST["admin_email_subject_".$i]), ENT_QUOTES)
1809
- );
1810
- $mlw_qmn_new_admin_array[] = $mlw_qmn_email_each;
1811
- }
1812
- $i++;
1813
- }
1814
- $mlw_qmn_new_email_array = serialize($mlw_qmn_new_email_array);
1815
- $mlw_qmn_new_admin_array = serialize($mlw_qmn_new_admin_array);
1816
- $mlw_new_email_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET send_user_email='%s', send_admin_email='%s', admin_email='%s', user_email_template='%s', admin_email_template='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_send_user_email, $mlw_send_admin_email, $mlw_admin_email, $mlw_qmn_new_email_array, $mlw_qmn_new_admin_array, $mlw_qmn_email_id ) );
1817
- if ($mlw_new_email_results != false)
1818
- {
1819
- $mlwQuizMasterNext->alertManager->newAlert('The email has been updated successfully.', 'success');
1820
-
1821
- //Insert Action Into Audit Trail
1822
- global $current_user;
1823
- get_currentuserinfo();
1824
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
1825
- $insert = "INSERT INTO " . $table_name .
1826
- "(trail_id, action_user, action, time) " .
1827
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Email Templates Have Been Saved For Quiz Number ".$mlw_qmn_email_id."' , '" . date("h:i:s A m/d/Y") . "')";
1828
- $results = $wpdb->query( $insert );
1829
- }
1830
- else
1831
- {
1832
- $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0017.', 'error');
1833
- }
1834
- }
1835
-
1836
- if (isset($_GET["quiz_id"]))
1837
- {
1838
- $table_name = $wpdb->prefix . "mlw_quizzes";
1839
- $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
1840
- }
1841
-
1842
- //Load User Email Templates
1843
- if (is_serialized($mlw_quiz_options->user_email_template) && is_array(@unserialize($mlw_quiz_options->user_email_template)))
1844
- {
1845
- $mlw_qmn_user_email_array = @unserialize($mlw_quiz_options->user_email_template);
1846
- }
1847
- else
1848
- {
1849
- $mlw_qmn_user_email_array = array(array(0, 0, $mlw_quiz_options->user_email_template, 'Quiz Results For %QUIZ_NAME%'));
1850
- }
1851
-
1852
- //Load Admin Email Templates
1853
- if (is_serialized($mlw_quiz_options->admin_email_template) && is_array(@unserialize($mlw_quiz_options->admin_email_template)))
1854
- {
1855
- $mlw_qmn_admin_email_array = @unserialize($mlw_quiz_options->admin_email_template);
1856
- }
1857
- else
1858
- {
1859
- $mlw_qmn_admin_email_array = array(array(
1860
- "begin_score" => 0,
1861
- "end_score" => 0,
1862
- "message" => $mlw_quiz_options->admin_email_template,
1863
- "subject" => 'Quiz Results For %QUIZ_NAME%'
1864
- ));
1865
- }
1866
- ?>
1867
-
1868
- <div id="tabs-9" class="mlw_tab_content">
1869
- <script>
1870
- function delete_email(id)
1871
- {
1872
- document.getElementById('user_email_'+id).value = "Delete";
1873
- document.mlw_quiz_save_email_form.submit();
1874
- }
1875
- function delete_admin_email(id)
1876
- {
1877
- document.getElementById('admin_email_'+id).value = "Delete";
1878
- document.mlw_quiz_save_email_form.submit();
1879
- }
1880
- </script>
1881
- <h3>Template Variables</h3>
1882
- <table class="form-table">
1883
- <tr>
1884
- <td><strong>%POINT_SCORE%</strong> - Score for the quiz when using points</td>
1885
- <td><strong>%AVERAGE_POINT%</strong> - The average amount of points user had per question</td>
1886
- </tr>
1887
-
1888
- <tr>
1889
- <td><strong>%AMOUNT_CORRECT%</strong> - The number of correct answers the user had</td>
1890
- <td><strong>%TOTAL_QUESTIONS%</strong> - The total number of questions in the quiz</td>
1891
- </tr>
1892
-
1893
- <tr>
1894
- <td><strong>%CORRECT_SCORE%</strong> - Score for the quiz when using correct answers</td>
1895
- </tr>
1896
-
1897
- <tr>
1898
- <td><strong>%USER_NAME%</strong> - The name the user entered before the quiz</td>
1899
- <td><strong>%USER_BUSINESS%</strong> - The business the user entered before the quiz</td>
1900
- </tr>
1901
-
1902
- <tr>
1903
- <td><strong>%USER_PHONE%</strong> - The phone number the user entered before the quiz</td>
1904
- <td><strong>%USER_EMAIL%</strong> - The email the user entered before the quiz</td>
1905
- </tr>
1906
-
1907
- <tr>
1908
- <td><strong>%QUIZ_NAME%</strong> - The name of the quiz</td>
1909
- <td><strong>%QUESTIONS_ANSWERS%</strong> - Shows the question, the answer the user provided, and the correct answer</td>
1910
- </tr>
1911
-
1912
- <tr>
1913
- <td><strong>%COMMENT_SECTION%</strong> - The comments the user entered into comment box if enabled</td>
1914
- <td><strong>%TIMER%</strong> - The amount of time user spent of quiz</td>
1915
- </tr>
1916
- </table>
1917
- <br />
1918
- <br />
1919
- <form method="post" action="" name="mlw_quiz_add_email_form">
1920
- <input type='hidden' name='mlw_add_email_page' value='confirmation' />
1921
- <input type='hidden' name='mlw_add_email_quiz_id' value='<?php echo $quiz_id; ?>' />
1922
- </form>
1923
- <form method="post" action="" name="mlw_quiz_add_admin_email_form">
1924
- <input type='hidden' name='mlw_add_admin_email_page' value='confirmation' />
1925
- <input type='hidden' name='mlw_add_admin_email_quiz_id' value='<?php echo $quiz_id; ?>' />
1926
- </form>
1927
- <button id="save_email_button" class="button" onclick="javascript: document.mlw_quiz_save_email_form.submit();">Save Email Templates And Settings</button>
1928
- <form method="post" action="" name="mlw_quiz_save_email_form">
1929
- <table class="form-table">
1930
- <tr valign="top">
1931
- <th scope="row"><label for="sendUserEmail">Send user email upon completion?</label></th>
1932
- <td><div id="sendUserEmail">
1933
- <input type="radio" id="radio5" name="sendUserEmail" <?php if ($mlw_quiz_options->send_user_email == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio5">Yes</label>
1934
- <input type="radio" id="radio6" name="sendUserEmail" <?php if ($mlw_quiz_options->send_user_email == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio6">No</label>
1935
- </div></td>
1936
- </tr>
1937
- <tr valign="top">
1938
- <th scope="row"><label for="sendAdminEmail">Send admin email upon completion?</label></th>
1939
- <td><div id="sendAdminEmail">
1940
- <input type="radio" id="radio19" name="sendAdminEmail" <?php if ($mlw_quiz_options->send_admin_email == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio19">Yes</label>
1941
- <input type="radio" id="radio20" name="sendAdminEmail" <?php if ($mlw_quiz_options->send_admin_email == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio20">No</label>
1942
- </div></td>
1943
- </tr>
1944
- <tr valign="top">
1945
- <th scope="row"><label for="adminEmail">What emails should we send the admin email to? Separate emails with a comma.</label></th>
1946
- <td><input name="adminEmail" type="text" id="adminEmail" value="<?php echo $mlw_quiz_options->admin_email; ?>" class="regular-text" /></td>
1947
- </tr>
1948
- </table>
1949
- <br />
1950
- <br />
1951
- <h3>Email Sent To User</h3>
1952
- <a id="new_email_button_top" class="button" href="#" onclick="javascript: document.mlw_quiz_add_email_form.submit();">Add New User Email</a>
1953
- <table class="widefat">
1954
- <thead>
1955
- <tr>
1956
- <th>ID</th>
1957
- <th>Score Greater Than Or Equal To</th>
1958
- <th>Score Less Than Or Equal To</th>
1959
- <th>Subject</th>
1960
- <th>Email To Send</th>
1961
- </tr>
1962
- </thead>
1963
- <tbody>
1964
- <?php
1965
- $mlw_each_count = 0;
1966
- $alternate = "";
1967
- foreach($mlw_qmn_user_email_array as $mlw_each)
1968
- {
1969
- if($alternate) $alternate = "";
1970
- else $alternate = " class=\"alternate\"";
1971
- $mlw_each_count += 1;
1972
- if (!isset($mlw_each[3]))
1973
- {
1974
- $mlw_each[3] = "Quiz Results For %QUIZ_NAME%";
1975
- }
1976
- if ($mlw_each[0] == 0 && $mlw_each[1] == 0)
1977
- {
1978
- echo "<tr{$alternate}>";
1979
- echo "<td>";
1980
- echo "Default";
1981
- echo "</td>";
1982
- echo "<td>";
1983
- echo "<input type='hidden' id='user_email_begin_".$mlw_each_count."' name='user_email_begin_".$mlw_each_count."' value='0'/>-";
1984
- echo "</td>";
1985
- echo "<td>";
1986
- echo "<input type='hidden' id='user_email_end_".$mlw_each_count."' name='user_email_end_".$mlw_each_count."' value='0'/>-";
1987
- echo "</td>";
1988
- echo "<td>";
1989
- echo "<input type='text' id='user_email_subject_".$mlw_each_count."' name='user_email_subject_".$mlw_each_count."' value='".$mlw_each[3]."' />";
1990
- echo "</td>";
1991
- echo "<td>";
1992
- echo "<textarea cols='80' rows='15' id='user_email_".$mlw_each_count."' name='user_email_".$mlw_each_count."'>".$mlw_each[2]."</textarea>";
1993
- echo "</td>";
1994
- echo "</tr>";
1995
- break;
1996
- }
1997
- else
1998
- {
1999
- echo "<tr{$alternate}>";
2000
- echo "<td>";
2001
- echo $mlw_each_count."<div><span style='color:green;font-size:12px;'><a onclick=\"\$j('#trying_delete_email_".$mlw_each_count."').show();\">Delete</a></span></div><div style=\"display: none;\" id='trying_delete_email_".$mlw_each_count."'>Are you sure?<br /><a onclick=\"delete_email(".$mlw_each_count.")\">Yes</a>|<a onclick=\"\$j('#trying_delete_email_".$mlw_each_count."').hide();\">No</a></div>";
2002
- echo "</td>";
2003
- echo "<td>";
2004
- echo "<input type='text' id='user_email_begin_".$mlw_each_count."' name='user_email_begin_".$mlw_each_count."' title='What score must the user score better than to see this page' value='".$mlw_each[0]."'/>";
2005
- echo "</td>";
2006
- echo "<td>";
2007
- echo "<input type='text' id='user_email_end_".$mlw_each_count."' name='user_email_end_".$mlw_each_count."' title='What score must the user score worse than to see this page' value='".$mlw_each[1]."' />";
2008
- echo "</td>";
2009
- echo "<td>";
2010
- echo "<input type='text' id='user_email_subject_".$mlw_each_count."' name='user_email_subject_".$mlw_each_count."' value='".$mlw_each[3]."' />";
2011
- echo "</td>";
2012
- echo "<td>";
2013
- echo "<textarea cols='80' rows='15' id='user_email_".$mlw_each_count."' title='What email will the user be sent' name='user_email_".$mlw_each_count."'>".$mlw_each[2]."</textarea>";
2014
- echo "</td>";
2015
- echo "</tr>";
2016
- }
2017
- }
2018
- ?>
2019
- </tbody>
2020
- <tfoot>
2021
- <tr>
2022
- <th>ID</th>
2023
- <th>Score Greater Than Or Equal To</th>
2024
- <th>Score Less Than Or Equal To</th>
2025
- <th>Subject</th>
2026
- <th>Email To Send</th>
2027
- </tr>
2028
- </tfoot>
2029
- </table>
2030
- <a id="new_email_button_bottom" class="button" href="#" onclick="javascript: document.mlw_quiz_add_email_form.submit();">Add New User Email</a>
2031
- <input type='hidden' name='mlw_save_email_template' value='confirmation' />
2032
- <input type='hidden' name='mlw_email_quiz_id' value='<?php echo $quiz_id; ?>' />
2033
- <input type='hidden' name='mlw_email_template_total' value='<?php echo $mlw_each_count; ?>' />
2034
- <br />
2035
- <br />
2036
- <br />
2037
- <br />
2038
- <h3>Email Sent To Admin</h3>
2039
- <a id="new_admin_email_button_top" class="button" href="#" onclick="javascript: document.mlw_quiz_add_admin_email_form.submit();">Add New Admin Email</a>
2040
- <table class="widefat">
2041
- <thead>
2042
- <tr>
2043
- <th>ID</th>
2044
- <th>Score Greater Than Or Equal To</th>
2045
- <th>Score Less Than Or Equal To</th>
2046
- <th>Subject</th>
2047
- <th>Email To Send</th>
2048
- </tr>
2049
- </thead>
2050
- <tbody>
2051
- <?php
2052
- $mlw_admin_count = 0;
2053
- $alternate = "";
2054
- foreach($mlw_qmn_admin_email_array as $mlw_each)
2055
- {
2056
- if($alternate) $alternate = "";
2057
- else $alternate = " class=\"alternate\"";
2058
- $mlw_admin_count += 1;
2059
- if (!isset($mlw_each["subject"]))
2060
- {
2061
- $mlw_each[3] = "Quiz Results For %QUIZ_NAME%";
2062
- }
2063
- if ($mlw_each["begin_score"] == 0 && $mlw_each["end_score"] == 0)
2064
- {
2065
- echo "<tr{$alternate}>";
2066
- echo "<td>";
2067
- echo "Default";
2068
- echo "</td>";
2069
- echo "<td>";
2070
- echo "<input type='hidden' id='admin_email_begin_".$mlw_admin_count."' name='admin_email_begin_".$mlw_admin_count."' value='0'/>-";
2071
- echo "</td>";
2072
- echo "<td>";
2073
- echo "<input type='hidden' id='admin_email_end_".$mlw_admin_count."' name='admin_email_end_".$mlw_admin_count."' value='0'/>-";
2074
- echo "</td>";
2075
- echo "<td>";
2076
- echo "<input type='text' id='admin_email_subject_".$mlw_admin_count."' name='admin_email_subject_".$mlw_admin_count."' value='".$mlw_each["subject"]."' />";
2077
- echo "</td>";
2078
- echo "<td>";
2079
- echo "<textarea cols='80' rows='15' id='admin_email_".$mlw_admin_count."' name='admin_email_".$mlw_admin_count."'>".$mlw_each["message"]."</textarea>";
2080
- echo "</td>";
2081
- echo "</tr>";
2082
- break;
2083
- }
2084
- else
2085
- {
2086
- echo "<tr{$alternate}>";
2087
- echo "<td>";
2088
- echo $mlw_admin_count."<div><span style='color:green;font-size:12px;'><a onclick=\"\$j('#trying_delete_admin_email_".$mlw_admin_count."').show();\">Delete</a></span></div><div style=\"display: none;\" id='trying_delete_admin_email_".$mlw_admin_count."'>Are you sure?<br /><a onclick=\"delete_admin_email(".$mlw_admin_count.")\">Yes</a>|<a onclick=\"\$j('#trying_delete_admin_email_".$mlw_admin_count."').hide();\">No</a></div>";
2089
- echo "</td>";
2090
- echo "<td>";
2091
- echo "<input type='text' id='admin_email_begin_".$mlw_admin_count."' name='admin_email_begin_".$mlw_admin_count."' title='What score must the user score better than to see this page' value='".$mlw_each["begin_score"]."'/>";
2092
- echo "</td>";
2093
- echo "<td>";
2094
- echo "<input type='text' id='admin_email_end_".$mlw_admin_count."' name='admin_email_end_".$mlw_admin_count."' title='What score must the user score worse than to see this page' value='".$mlw_each["end_score"]."' />";
2095
- echo "</td>";
2096
- echo "<td>";
2097
- echo "<input type='text' id='admin_email_subject_".$mlw_admin_count."' name='admin_email_subject_".$mlw_admin_count."' value='".$mlw_each["subject"]."' />";
2098
- echo "</td>";
2099
- echo "<td>";
2100
- echo "<textarea cols='80' rows='15' id='admin_email_".$mlw_admin_count."' title='What email will the user be sent' name='admin_email_".$mlw_admin_count."'>".$mlw_each["message"]."</textarea>";
2101
- echo "</td>";
2102
- echo "</tr>";
2103
- }
2104
- }
2105
- ?>
2106
- </tbody>
2107
- <tfoot>
2108
- <tr>
2109
- <th>ID</th>
2110
- <th>Score Greater Than Or Equal To</th>
2111
- <th>Score Less Than Or Equal To</th>
2112
- <th>Subject</th>
2113
- <th>Email To Send</th>
2114
- </tr>
2115
- </tfoot>
2116
- </table>
2117
- <a id="new_admin_email_button_bottom" class="button" href="#" onclick="javascript: document.mlw_quiz_add_admin_email_form.submit();">Add New Admin Email</a>
2118
- <input type='hidden' name='mlw_email_admin_total' value='<?php echo $mlw_admin_count; ?>' />
2119
- </form>
2120
- <br />
2121
- <br />
2122
- <button id="save_email_button" class="button" onclick="javascript: document.mlw_quiz_save_email_form.submit();">Save Email Templates And Settings</button>
2123
- </div>
2124
- <?php
2125
- }
2126
-
2127
- function mlw_options_results_tab_content()
2128
- {
2129
- global $wpdb;
2130
- global $mlwQuizMasterNext;
2131
- $quiz_id = $_GET["quiz_id"];
2132
- //Check to add new results page
2133
- if (isset($_POST["mlw_add_landing_page"]) && $_POST["mlw_add_landing_page"] == "confirmation")
2134
- {
2135
- //Function variables
2136
- $mlw_qmn_landing_id = intval($_POST["mlw_add_landing_quiz_id"]);
2137
- $mlw_qmn_message_after = $wpdb->get_var( $wpdb->prepare( "SELECT message_after FROM ".$wpdb->prefix."mlw_quizzes WHERE quiz_id=%d", $mlw_qmn_landing_id ) );
2138
- //Load message_after and check if it is array already. If not, turn it into one
2139
- if (is_serialized($mlw_qmn_message_after) && is_array(@unserialize($mlw_qmn_message_after)))
2140
- {
2141
- $mlw_qmn_landing_array = @unserialize($mlw_qmn_message_after);
2142
- $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here');
2143
- array_unshift($mlw_qmn_landing_array , $mlw_new_landing_array);
2144
- $mlw_qmn_landing_array = serialize($mlw_qmn_landing_array);
2145
-
2146
- }
2147
- else
2148
- {
2149
- $mlw_qmn_landing_array = array(array(0, 0, $mlw_qmn_message_after));
2150
- $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here');
2151
- array_unshift($mlw_qmn_landing_array , $mlw_new_landing_array);
2152
- $mlw_qmn_landing_array = serialize($mlw_qmn_landing_array);
2153
- }
2154
-
2155
- //Update message_after with new array then check to see if worked
2156
- $mlw_new_landing_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET message_after=%s, last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_landing_array, $mlw_qmn_landing_id ) );
2157
- if ($mlw_new_landing_results != false)
2158
- {
2159
- $mlwQuizMasterNext->alertManager->newAlert('The results page has been added successfully.', 'success');
2160
-
2161
- //Insert Action Into Audit Trail
2162
- global $current_user;
2163
- get_currentuserinfo();
2164
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
2165
- $insert = "INSERT INTO " . $table_name .
2166
- "(trail_id, action_user, action, time) " .
2167
- "VALUES (NULL , '" . $current_user->display_name . "' , 'New Landing Page Has Been Created For Quiz Number ".$mlw_qmn_landing_id."' , '" . date("h:i:s A m/d/Y") . "')";
2168
- $results = $wpdb->query( $insert );
2169
- }
2170
- else
2171
- {
2172
- $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0013.', 'error');
2173
- }
2174
- }
2175
-
2176
- //Check to save landing pages
2177
- if (isset($_POST["mlw_save_landing_pages"]) && $_POST["mlw_save_landing_pages"] == "confirmation")
2178
- {
2179
- //Function Variables
2180
- $mlw_qmn_landing_id = intval($_POST["mlw_landing_quiz_id"]);
2181
- $mlw_qmn_landing_total = intval($_POST["mlw_landing_page_total"]);
2182
-
2183
- //Create new array
2184
- $i = 1;
2185
- $mlw_qmn_new_landing_array = array();
2186
- while ($i <= $mlw_qmn_landing_total)
2187
- {
2188
- if ($_POST["message_after_".$i] != "Delete")
2189
- {
2190
- $mlw_qmn_landing_each = array(intval($_POST["message_after_begin_".$i]), intval($_POST["message_after_end_".$i]), htmlspecialchars(stripslashes($_POST["message_after_".$i]), ENT_QUOTES));
2191
- $mlw_qmn_new_landing_array[] = $mlw_qmn_landing_each;
2192
- }
2193
- $i++;
2194
- }
2195
- $mlw_qmn_new_landing_array = serialize($mlw_qmn_new_landing_array);
2196
- $mlw_new_landing_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET message_after='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_new_landing_array, $mlw_qmn_landing_id ) );
2197
- if ($mlw_new_landing_results != false)
2198
- {
2199
- $mlwQuizMasterNext->alertManager->newAlert('The results page has been saved successfully.', 'success');
2200
-
2201
- //Insert Action Into Audit Trail
2202
- global $current_user;
2203
- get_currentuserinfo();
2204
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
2205
- $insert = "INSERT INTO " . $table_name .
2206
- "(trail_id, action_user, action, time) " .
2207
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Landing Pages Have Been Saved For Quiz Number ".$mlw_qmn_landing_id."' , '" . date("h:i:s A m/d/Y") . "')";
2208
- $results = $wpdb->query( $insert );
2209
- }
2210
- else
2211
- {
2212
- $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0014.', 'error');
2213
- }
2214
- }
2215
-
2216
- if (isset($_GET["quiz_id"]))
2217
- {
2218
- $table_name = $wpdb->prefix . "mlw_quizzes";
2219
- $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
2220
- }
2221
-
2222
- //Load Landing Pages
2223
- if (is_serialized($mlw_quiz_options->message_after) && is_array(@unserialize($mlw_quiz_options->message_after)))
2224
- {
2225
- $mlw_message_after_array = @unserialize($mlw_quiz_options->message_after);
2226
- }
2227
- else
2228
- {
2229
- $mlw_message_after_array = array(array(0, 0, $mlw_quiz_options->message_after));
2230
- }
2231
- ?>
2232
- <div id="tabs-6" class="mlw_tab_content">
2233
- <script>
2234
- function delete_landing(id)
2235
- {
2236
- document.getElementById('message_after_'+id).value = "Delete";
2237
- document.mlw_quiz_save_landing_form.submit();
2238
- }
2239
- </script>
2240
- <h3>Template Variables</h3>
2241
- <table class="form-table">
2242
- <tr>
2243
- <td><strong>%POINT_SCORE%</strong> - Score for the quiz when using points</td>
2244
- <td><strong>%AVERAGE_POINT%</strong> - The average amount of points user had per question</td>
2245
- </tr>
2246
-
2247
- <tr>
2248
- <td><strong>%AMOUNT_CORRECT%</strong> - The number of correct answers the user had</td>
2249
- <td><strong>%TOTAL_QUESTIONS%</strong> - The total number of questions in the quiz</td>
2250
- </tr>
2251
-
2252
- <tr>
2253
- <td><strong>%CORRECT_SCORE%</strong> - Score for the quiz when using correct answers</td>
2254
- </tr>
2255
-
2256
- <tr>
2257
- <td><strong>%USER_NAME%</strong> - The name the user entered before the quiz</td>
2258
- <td><strong>%USER_BUSINESS%</strong> - The business the user entered before the quiz</td>
2259
- </tr>
2260
-
2261
- <tr>
2262
- <td><strong>%USER_PHONE%</strong> - The phone number the user entered before the quiz</td>
2263
- <td><strong>%USER_EMAIL%</strong> - The email the user entered before the quiz</td>
2264
- </tr>
2265
-
2266
- <tr>
2267
- <td><strong>%QUIZ_NAME%</strong> - The name of the quiz</td>
2268
- <td><strong>%QUESTIONS_ANSWERS%</strong> - Shows the question, the answer the user provided, and the correct answer</td>
2269
- </tr>
2270
-
2271
- <tr>
2272
- <td><strong>%COMMENT_SECTION%</strong> - The comments the user entered into comment box if enabled</td>
2273
-
2274
- </tr>
2275
- <tr>
2276
- <td><strong>%TIMER%</strong> - The amount of time user spent of quiz</td>
2277
- <td><strong>%CERTIFICATE_LINK%</strong> - The link to the certificate after completing the quiz</td>
2278
- </tr>
2279
- </table>
2280
- <button id="save_landing_button" class="button" onclick="javascript: document.mlw_quiz_save_landing_form.submit();">Save Results Pages</button>
2281
- <button id="new_landing_button" class="button" onclick="javascript: document.mlw_quiz_add_landing_form.submit();">Add New Results Page</button>
2282
- <form method="post" action="" name="mlw_quiz_save_landing_form" style=" display:inline!important;">
2283
- <table class="widefat">
2284
- <thead>
2285
- <tr>
2286
- <th>ID</th>
2287
- <th>Score Greater Than Or Equal To</th>
2288
- <th>Score Less Than Or Equal To</th>
2289
- <th>Results Page Shown</th>
2290
- </tr>
2291
- </thead>
2292
- <tbody>
2293
- <?php
2294
- $mlw_each_count = 0;
2295
- $alternate = "";
2296
- foreach($mlw_message_after_array as $mlw_each)
2297
- {
2298
- if($alternate) $alternate = "";
2299
- else $alternate = " class=\"alternate\"";
2300
- $mlw_each_count += 1;
2301
- if ($mlw_each[0] == 0 && $mlw_each[1] == 0)
2302
- {
2303
- echo "<tr{$alternate}>";
2304
- echo "<td>";
2305
- echo "Default";
2306
- echo "</td>";
2307
- echo "<td>";
2308
- echo "<input type='hidden' id='message_after_begin_".$mlw_each_count."' name='message_after_begin_".$mlw_each_count."' value='0'/>-";
2309
- echo "</td>";
2310
- echo "<td>";
2311
- echo "<input type='hidden' id='message_after_end_".$mlw_each_count."' name='message_after_end_".$mlw_each_count."' value='0'/>-";
2312
- echo "</td>";
2313
- echo "<td>";
2314
- echo "<textarea cols='80' rows='15' id='message_after_".$mlw_each_count."' name='message_after_".$mlw_each_count."'>".$mlw_each[2]."</textarea>";
2315
- echo "</td>";
2316
- echo "</tr>";
2317
- break;
2318
- }
2319
- else
2320
- {
2321
- echo "<tr{$alternate}>";
2322
- echo "<td>";
2323
- echo $mlw_each_count."<div><span style='color:green;font-size:12px;'><a onclick=\"\$j('#trying_delete_".$mlw_each_count."').show();\">Delete</a></span></div><div style=\"display: none;\" id='trying_delete_".$mlw_each_count."'>Are you sure?<br /><a onclick=\"delete_landing(".$mlw_each_count.")\">Yes</a>|<a onclick=\"\$j('#trying_delete_".$mlw_each_count."').hide();\">No</a></div>";
2324
- echo "</td>";
2325
- echo "<td>";
2326
- echo "<input type='text' id='message_after_begin_".$mlw_each_count."' name='message_after_begin_".$mlw_each_count."' title='What score must the user score better than to see this page' value='".$mlw_each[0]."'/>";
2327
- echo "</td>";
2328
- echo "<td>";
2329
- echo "<input type='text' id='message_after_end_".$mlw_each_count."' name='message_after_end_".$mlw_each_count."' title='What score must the user score worse than to see this page' value='".$mlw_each[1]."' />";
2330
- echo "</td>";
2331
- echo "<td>";
2332
- echo "<textarea cols='80' rows='15' id='message_after_".$mlw_each_count."' title='What text will the user see when reaching this page' name='message_after_".$mlw_each_count."'>".$mlw_each[2]."</textarea>";
2333
- echo "</td>";
2334
- echo "</tr>";
2335
- }
2336
- }
2337
- ?>
2338
- </tbody>
2339
- <tfoot>
2340
- <tr>
2341
- <th>ID</th>
2342
- <th>Score Greater Than Or Equal To</th>
2343
- <th>Score Less Than Or Equal To</th>
2344
- <th>Results Page Shown</th>
2345
- </tr>
2346
- </tfoot>
2347
- </table>
2348
- <input type='hidden' name='mlw_save_landing_pages' value='confirmation' />
2349
- <input type='hidden' name='mlw_landing_quiz_id' value='<?php echo $quiz_id; ?>' />
2350
- <input type='hidden' name='mlw_landing_page_total' value='<?php echo $mlw_each_count; ?>' />
2351
- <button id="save_landing_button" class="button" onclick="javascript: document.mlw_quiz_save_landing_form.submit();">Save Results Pages</button>
2352
- </form>
2353
- <form method="post" action="" name="mlw_quiz_add_landing_form" style=" display:inline!important;">
2354
- <input type='hidden' name='mlw_add_landing_page' value='confirmation' />
2355
- <input type='hidden' name='mlw_add_landing_quiz_id' value='<?php echo $quiz_id; ?>' />
2356
- <button id="new_landing_button" class="button" onclick="javascript: document.mlw_quiz_add_landing_form.submit();">Add New Results Page</button>
2357
- </form>
2358
- </div>
2359
- <?php
2360
- }
2361
-
2362
- function mlw_options_styling_tab_content()
2363
- {
2364
- global $wpdb;
2365
- global $mlwQuizMasterNext;
2366
- $quiz_id = $_GET["quiz_id"];
2367
- if (isset($_POST["save_style_options"]) && $_POST["save_style_options"] == "confirmation")
2368
- {
2369
- //Function Variables
2370
- $mlw_qmn_style_id = intval($_POST["style_quiz_id"]);
2371
- $mlw_qmn_theme = $_POST["save_quiz_theme"];
2372
- $mlw_qmn_style = htmlspecialchars(stripslashes($_POST["quiz_css"]), ENT_QUOTES);
2373
-
2374
- //Save the new css
2375
- $mlw_save_stle_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET quiz_stye='%s', theme_selected='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_style, $mlw_qmn_theme, $mlw_qmn_style_id ) );
2376
- if ($mlw_save_stle_results != false)
2377
- {
2378
- $mlwQuizMasterNext->alertManager->newAlert('The style has been saved successfully.', 'success');
2379
-
2380
- //Insert Action Into Audit Trail
2381
- global $current_user;
2382
- get_currentuserinfo();
2383
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
2384
- $insert = "INSERT INTO " . $table_name .
2385
- "(trail_id, action_user, action, time) " .
2386
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Styles Have Been Saved For Quiz Number ".$mlw_qmn_style_id."' , '" . date("h:i:s A m/d/Y") . "')";
2387
- $results = $wpdb->query( $insert );
2388
- }
2389
- else
2390
- {
2391
- $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0015.', 'error');
2392
- }
2393
- }
2394
-
2395
- if (isset($_GET["quiz_id"]))
2396
- {
2397
- $table_name = $wpdb->prefix . "mlw_quizzes";
2398
- $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
2399
- }
2400
- ?>
2401
- <div id="tabs-7" class="mlw_tab_content">
2402
- <script>
2403
- function mlw_qmn_theme(theme)
2404
- {
2405
- document.getElementById('save_quiz_theme').value = theme;
2406
- jQuery("div.mlw_qmn_themeBlockActive").toggleClass("mlw_qmn_themeBlockActive");
2407
- jQuery("#mlw_qmn_theme_block_"+theme).toggleClass("mlw_qmn_themeBlockActive");
2408
-
2409
- }
2410
- </script>
2411
- <?php
2412
- echo "<form action='' method='post' name='quiz_style_form'>";
2413
- echo "<input type='hidden' name='save_style_options' value='confirmation' />";
2414
- echo "<input type='hidden' name='style_quiz_id' value='".$quiz_id."' />";
2415
- echo "<input type='hidden' name='save_quiz_theme' id='save_quiz_theme' value='".$mlw_quiz_options->theme_selected."' />";
2416
- ?>
2417
- <h3>Quiz Styles</h3>
2418
- <p>Choose your style:</p>
2419
- <style>
2420
- div.mlw_qmn_themeBlock
2421
- {
2422
- cursor: pointer;
2423
- position: relative;
2424
- height: 100px;
2425
- width: 100px;
2426
- background-color: #eee;
2427
- color: blue;
2428
- border: #ccc solid 1px;
2429
- border-radius: 4px;
2430
- padding: 5px 5px 5px 5px;
2431
- display: inline-block;
2432
- box-sizing: border-box;
2433
- margin: auto;
2434
- }
2435
- div.mlw_qmn_themeBlockActive
2436
- {
2437
- background-color: yellow;
2438
- }
2439
- </style>
2440
- <div onclick="mlw_qmn_theme('default');" id="mlw_qmn_theme_block_default" class="mlw_qmn_themeBlock <?php if ($mlw_quiz_options->theme_selected == 'default') {echo 'mlw_qmn_themeBlockActive';} ?>">Custom</div>
2441
- <?php do_action('mlw_qmn_quiz_themes'); ?>
2442
- <script>
2443
- mlw_qmn_theme('<?php echo $mlw_quiz_options->theme_selected; ?>');
2444
- </script>
2445
- <br /><br />
2446
- <button id="save_styles_button" class="button" onclick="javascript: document.quiz_style_form.submit();">Save Quiz Style</button>
2447
- <hr />
2448
- <h3>Custom Theme CSS</h3>
2449
- <p>Entire quiz is a div with class 'mlw_qmn_quiz'</p>
2450
- <p>Each page of the quiz is div with class 'quiz_section'</p>
2451
- <p>Message before quiz text is a span with class 'mlw_qmn_message_before'</p>
2452
- <p>The text for each question is wrapped in class 'mlw_qmn_question'</p>
2453
- <p>Each comment field for the questions is wrapped in class 'mlw_qmn_question_comment'</p>
2454
- <p>Label text for comment section is wrapped in class 'mlw_qmn_comment_section_text'</p>
2455
- <p>The message displayed at end of quiz is a span with class 'mlw_qmn_message_end'</p>
2456
- <p>Each button shown for pagination (i.e Next/Previous) is wrapped in class 'mlw_qmn_quiz_link'</p>
2457
- <p>Timer is wrapped in class 'mlw_qmn_timer'</p>
2458
- <p>Each horizontal multiple response is wrapped in a span with class 'mlw_horizontal_multiple'</p>
2459
- <button id="save_styles_button" class="button" onclick="javascript: document.quiz_style_form.submit();">Save Quiz Style</button>
2460
-
2461
- <table class="form-table">
2462
- <tr>
2463
- <td width="66%"><textarea style="width: 100%; height: 100%;" id="quiz_css" name="quiz_css"><?php echo $mlw_quiz_options->quiz_stye; ?></textarea>
2464
- </td>
2465
- <td width="30%">
2466
- <strong>Default:</strong><br />
2467
- div.mlw_qmn_quiz input[type=radio],<br />
2468
- div.mlw_qmn_quiz input[type=submit],<br />
2469
- div.mlw_qmn_quiz label {<br />
2470
- cursor: pointer;<br />
2471
- }<br />
2472
- div.mlw_qmn_quiz input:not([type=submit]):focus,<br />
2473
- div.mlw_qmn_quiz textarea:focus {<br />
2474
- background: #eaeaea;<br />
2475
- }<br />
2476
- div.mlw_qmn_quiz {<br />
2477
- text-align: left;<br />
2478
- }<br />
2479
- div.quiz_section {<br />
2480
- <br />
2481
- }<br />
2482
- div.mlw_qmn_timer {<br />
2483
- position:fixed;<br />
2484
- top:200px;<br />
2485
- right:0px;<br />
2486
- width:130px;<br />
2487
- color:#00CCFF;<br />
2488
- border-radius: 15px;<br />
2489
- background:#000000;<br />
2490
- text-align: center;<br />
2491
- padding: 15px 15px 15px 15px<br />
2492
- }<br />
2493
- div.mlw_qmn_quiz input[type=submit],<br />
2494
- a.mlw_qmn_quiz_link<br />
2495
- {<br />
2496
- border-radius: 4px;<br />
2497
- position: relative;<br />
2498
- background-image: linear-gradient(#fff,#dedede);<br />
2499
- background-color: #eee;<br />
2500
- border: #ccc solid 1px;<br />
2501
- color: #333;<br />
2502
- text-shadow: 0 1px 0 rgba(255,255,255,.5);<br />
2503
- box-sizing: border-box;<br />
2504
- display: inline-block;<br />
2505
- padding: 5px 5px 5px 5px;<br />
2506
- margin: auto;<br />
2507
- }<br />
2508
- </td>
2509
- </tr>
2510
- </table>
2511
- <button id="save_styles_button" class="button" onclick="javascript: document.quiz_style_form.submit();">Save Quiz Style</button>
2512
- </form>
2513
- </div>
2514
- <?php
2515
- }
2516
-
2517
- function mlw_options_tools_tab_content()
2518
- {
2519
- global $wpdb;
2520
- global $mlwQuizMasterNext;
2521
- $quiz_id = $_GET["quiz_id"];
2522
- //Update Quiz Table
2523
- if (isset($_POST["mlw_reset_quiz_stats"]) && $_POST["mlw_reset_quiz_stats"] == "confirmation")
2524
- {
2525
- //Variables from reset stats form
2526
- $mlw_reset_stats_quiz_id = $_POST["mlw_reset_quiz_id"];
2527
- $mlw_reset_update_sql = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET quiz_views=0, quiz_taken=0, last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$mlw_reset_stats_quiz_id;
2528
- $mlw_reset_sql_results = $wpdb->query( $mlw_reset_update_sql );
2529
- if ($mlw_reset_sql_results != false)
2530
- {
2531
- $mlwQuizMasterNext->alertManager->newAlert('The stats has been reset successfully.', 'success');
2532
-
2533
- //Insert Action Into Audit Trail
2534
- global $current_user;
2535
- get_currentuserinfo();
2536
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
2537
- $insert = "INSERT INTO " . $table_name .
2538
- "(trail_id, action_user, action, time) " .
2539
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Quiz Stats Have Been Reset For Quiz Number ".$mlw_leaderboard_quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
2540
- $results = $wpdb->query( $insert );
2541
- }
2542
- else
2543
- {
2544
- $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0010.', 'error');
2545
- }
2546
- }
2547
-
2548
- if (isset($_GET["quiz_id"]))
2549
- {
2550
- $table_name = $wpdb->prefix . "mlw_quizzes";
2551
- $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
2552
- }
2553
- ?>
2554
- <div id="tabs-8" class="mlw_tab_content">
2555
- <script>
2556
- jQuery(function() {
2557
- jQuery('#mlw_reset_stats_dialog').dialog({
2558
- autoOpen: false,
2559
- show: 'blind',
2560
- width:700,
2561
- hide: 'explode',
2562
- buttons: {
2563
- Ok: function() {
2564
- jQuery(this).dialog('close');
2565
- }
2566
- }
2567
- });
2568
-
2569
- jQuery('#mlw_reset_stats_button').click(function() {
2570
- jQuery('#mlw_reset_stats_dialog').dialog('open');
2571
- return false;
2572
- } );
2573
- });
2574
- </script>
2575
- <p>Use this button to reset all the stats collected for this quiz (Quiz Views and Times Quiz Has Been Taken). </p>
2576
- <button class="button" id="mlw_reset_stats_button">Reset Quiz Views And Taken Stats</button>
2577
- <?php do_action('mlw_qmn_quiz_tools'); ?>
2578
- <div id="mlw_reset_stats_dialog" title="Reset Stats For This Quiz" style="display:none;">
2579
- <p>Are you sure you want to reset the stats to 0? All views and taken stats for this quiz will be reset. This is permanent and cannot be undone.</p>
2580
- <?php
2581
- echo "<form action='' method='post'>";
2582
- echo "<input type='hidden' name='mlw_reset_quiz_stats' value='confirmation' />";
2583
- echo "<input type='hidden' name='mlw_reset_quiz_id' value='".$quiz_id."' />";
2584
- echo "<p class='submit'><input type='submit' class='button-primary' value='Reset All Stats For Quiz' /></p>";
2585
- echo "</form>";
2586
- ?>
2587
- </div>
2588
- </div>
2589
- <?php
2590
- }
2591
-
2592
- function mlw_options_preview_tab_content()
2593
- {
2594
- ?>
2595
- <div id="tabs-preview" class="mlw_tab_content">
2596
- <?php
2597
- echo do_shortcode( '[mlw_quizmaster quiz='.intval($_GET["quiz_id"]).']' );
2598
- ?>
2599
- </div>
2600
- <?php
2601
- }
2602
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/mlw_results.php DELETED
@@ -1,254 +0,0 @@
1
- <?php
2
- /*
3
- This page shows all of the results from the taken quizzes.
4
- */
5
- /*
6
- Copyright 2013, My Local Webstop (email : fpcorso@mylocalwebstop.com)
7
- */
8
-
9
- function mlw_generate_quiz_results()
10
- {
11
- global $wpdb;
12
- global $mlwQuizMasterNext;
13
-
14
- ///Delete Results Function
15
- if (isset($_POST["delete_results"]) && $_POST["delete_results"] == "confirmation")
16
- {
17
- ///Variables from delete result form
18
- $mlw_delete_results_confirmation = $_POST["delete_results"];
19
- $mlw_delete_results_id = $_POST["result_id"];
20
- $mlw_delete_results_name = $_POST["delete_quiz_name"];
21
- $mlw_delete_results_update_sql = "UPDATE " . $wpdb->prefix . "mlw_results" . " SET deleted=1 WHERE result_id=".$mlw_delete_results_id;
22
- $mlw_delete_results_results = $wpdb->query( $mlw_delete_results_update_sql );
23
- if ($mlw_delete_results_results != false)
24
- {
25
- $mlwQuizMasterNext->alertManager->newAlert('Your results has been deleted successfully.', 'success');
26
-
27
- //Insert Action Into Audit Trail
28
- global $current_user;
29
- get_currentuserinfo();
30
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
31
- $insert = "INSERT INTO " . $table_name .
32
- "(trail_id, action_user, action, time) " .
33
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Results Has Been Deleted From: ".$mlw_delete_results_name."' , '" . date("h:i:s A m/d/Y") . "')";
34
- $results = $wpdb->query( $insert );
35
- }
36
- else
37
- {
38
- $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0021.', 'error');
39
- }
40
- }
41
-
42
- global $wpdb;
43
- $mlw_qmn_table_limit = 30;
44
- $mlw_qmn_results_count = $wpdb->get_var( "SELECT COUNT(result_id) FROM " . $wpdb->prefix . "mlw_results WHERE deleted='0'" );
45
-
46
- if( isset($_GET['mlw_result_page'] ) )
47
- {
48
- $mlw_qmn_result_page = $_GET['mlw_result_page'] + 1;
49
- $mlw_qmn_result_begin = $mlw_qmn_table_limit * $mlw_qmn_result_page ;
50
- }
51
- else
52
- {
53
- $mlw_qmn_result_page = 0;
54
- $mlw_qmn_result_begin = 0;
55
- }
56
- $mlw_qmn_result_left = $mlw_qmn_results_count - ($mlw_qmn_result_page * $mlw_qmn_table_limit);
57
- if (isset($_GET["quiz_id"]) && $_GET["quiz_id"] != "")
58
- {
59
- $mlw_quiz_data = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "mlw_results WHERE deleted='0' AND quiz_id=%d ORDER BY result_id DESC LIMIT %d, %d", intval($_GET["quiz_id"]), $mlw_qmn_result_begin, $mlw_qmn_table_limit ) );
60
- }
61
- else
62
- {
63
- $mlw_quiz_data = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "mlw_results WHERE deleted='0' ORDER BY result_id DESC LIMIT %d, %d", $mlw_qmn_result_begin, $mlw_qmn_table_limit ) );
64
- }
65
- ?>
66
- <!-- css -->
67
- <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
68
- <!-- jquery scripts -->
69
- <?php
70
- wp_enqueue_script( 'jquery' );
71
- wp_enqueue_script( 'jquery-ui-core' );
72
- wp_enqueue_script( 'jquery-ui-dialog' );
73
- wp_enqueue_script( 'jquery-ui-button' );
74
- wp_enqueue_script( 'jquery-ui-accordion' );
75
- wp_enqueue_script( 'jquery-ui-tooltip' );
76
- wp_enqueue_script( 'jquery-ui-tabs' );
77
- wp_enqueue_script( 'jquery-effects-blind' );
78
- wp_enqueue_script( 'jquery-effects-explode' );
79
- ?>
80
- <!--<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
81
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>-->
82
- <script type="text/javascript">
83
- var $j = jQuery.noConflict();
84
- // increase the default animation speed to exaggerate the effect
85
- $j.fx.speeds._default = 1000;
86
- $j(function() {
87
- $j('#dialog').dialog({
88
- autoOpen: false,
89
- show: 'blind',
90
- hide: 'explode',
91
- buttons: {
92
- Ok: function() {
93
- $j(this).dialog('close');
94
- }
95
- }
96
- });
97
-
98
- $j('#opener').click(function() {
99
- $j('#dialog').dialog('open');
100
- return false;
101
- } );
102
- });
103
- $j(function() {
104
- $j("button, #prev_page, #next_page").button();
105
-
106
- });
107
- function deleteResults(id,quizName){
108
- $j("#delete_dialog").dialog({
109
- autoOpen: false,
110
- show: 'blind',
111
- hide: 'explode',
112
- buttons: {
113
- Cancel: function() {
114
- $j(this).dialog('close');
115
- }
116
- }
117
- });
118
- $j("#delete_dialog").dialog('open');
119
- var idHidden = document.getElementById("result_id");
120
- var idHiddenName = document.getElementById("delete_quiz_name");
121
- idHidden.value = id;
122
- idHiddenName.value = quizName;
123
- };
124
- </script>
125
- <style>
126
- label {
127
- display: inline-block;
128
- width: 5em;
129
- }
130
- </style>
131
- <style type="text/css">
132
- div.mlw_quiz_options input[type='text'] {
133
- border-color:#000000;
134
- color:#3300CC;
135
- cursor:hand;
136
- }
137
- </style>
138
- <div class="wrap">
139
- <div class='mlw_quiz_options'>
140
- <h2>Quiz Results<a id="opener" href="">(?)</a></h2>
141
- <?php
142
- $mlwQuizMasterNext->alertManager->showAlerts();
143
-
144
- $quotes_list = "";
145
- $display = "";
146
- $alternate = "";
147
- foreach($mlw_quiz_data as $mlw_quiz_info) {
148
- if($alternate) $alternate = "";
149
- else $alternate = " class=\"alternate\"";
150
- $mlw_complete_time = '';
151
- $mlw_qmn_results_array = @unserialize($mlw_quiz_info->quiz_results);
152
- if (is_array($mlw_qmn_results_array))
153
- {
154
- $mlw_complete_hours = floor($mlw_qmn_results_array[0] / 3600);
155
- if ($mlw_complete_hours > 0)
156
- {
157
- $mlw_complete_time .= "$mlw_complete_hours hours ";
158
- }
159
- $mlw_complete_minutes = floor(($mlw_qmn_results_array[0] % 3600) / 60);
160
- if ($mlw_complete_minutes > 0)
161
- {
162
- $mlw_complete_time .= "$mlw_complete_minutes minutes ";
163
- }
164
- $mlw_complete_seconds = $mlw_qmn_results_array[0] % 60;
165
- $mlw_complete_time .= "$mlw_complete_seconds seconds";
166
- }
167
-
168
- $quotes_list .= "<tr{$alternate}>";
169
- $quotes_list .= "<td><span style='color:green;font-size:16px;'><a href='admin.php?page=mlw_quiz_result_details&&result_id=".$mlw_quiz_info->result_id."'>View</a>|<a onclick=\"deleteResults('".$mlw_quiz_info->result_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='#'>Delete</a></span></td>";
170
- $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_name . "</span></td>";
171
- if ($mlw_quiz_info->quiz_system == 0)
172
- {
173
- $quotes_list .= "<td class='post-title column-title'><span style='font-size:16px;'>" . $mlw_quiz_info->correct ." out of ".$mlw_quiz_info->total." or ".$mlw_quiz_info->correct_score."%</span></td>";
174
- }
175
- if ($mlw_quiz_info->quiz_system == 1)
176
- {
177
- $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->point_score . " Points</span></td>";
178
- }
179
- if ($mlw_quiz_info->quiz_system == 2)
180
- {
181
- $quotes_list .= "<td><span style='font-size:16px;'>Not Graded</span></td>";
182
- }
183
- $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_complete_time ."</span></td>";
184
- $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->name ."</span></td>";
185
- $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->business ."</span></td>";
186
- $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->email ."</span></td>";
187
- $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->phone ."</span></td>";
188
- $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->time_taken ."</span></td>";
189
- $quotes_list .= "</tr>";
190
- }
191
-
192
- if( $mlw_qmn_result_page > 0 )
193
- {
194
- $mlw_qmn_previous_page = $mlw_qmn_result_page - 2;
195
- $display .= "<a id=\"prev_page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_previous_page\">Previous $mlw_qmn_table_limit Quizzes</a>";
196
- if( $mlw_qmn_result_left > $mlw_qmn_table_limit )
197
- {
198
- $display .= "<a id=\"next_page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_result_page\">Next $mlw_qmn_table_limit Quizzes</a>";
199
- }
200
- }
201
- else if( $mlw_qmn_result_page == 0 )
202
- {
203
- if( $mlw_qmn_result_left > $mlw_qmn_table_limit )
204
- {
205
- $display .= "<a id=\"next_page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_result_page\">Next $mlw_qmn_table_limit Quizzes</a>";
206
- }
207
- }
208
- else if( $mlw_qmn_result_left < $mlw_qmn_table_limit )
209
- {
210
- $mlw_qmn_previous_page = $mlw_qmn_result_page - 2;
211
- $display .= "<a id=\"prev_page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_previous_page\">Previous $mlw_qmn_table_limit Quizzes</a>";
212
- }
213
-
214
- $display .= "<table class=\"widefat\">";
215
- $display .= "<thead><tr>
216
- <th>Actions</th>
217
- <th>Quiz Name</th>
218
- <th>Score</th>
219
- <th>Time To Complete</th>
220
- <th>Name</th>
221
- <th>Business</th>
222
- <th>Email</th>
223
- <th>Phone</th>
224
- <th>Time Taken</th>
225
- </tr></thead>";
226
- $display .= "<tbody id=\"the-list\">{$quotes_list}</tbody>";
227
- $display .= "</table>";
228
- echo $display;
229
- ?>
230
-
231
- <?php echo mlw_qmn_show_adverts(); ?>
232
-
233
- <div id="dialog" title="Help" style="display:none;">
234
- <h3><b>Help</b></h3>
235
- <p>This page shows all of the results from the taken quizzes.</p>
236
- <p>The table show the result id, the score from the quiz, the contact information provided, and the time the quiz was taken.</p>
237
- <p>To get results to a specific quiz, go to quiz page and click on results from that quiz.</p>
238
- </div>
239
- <div id="delete_dialog" title="Delete Results?" style="display:none;">
240
- <h3><b>Are you sure you want to delete these results?</b></h3>
241
- <?php
242
- echo "<form action='' method='post'>";
243
- echo "<input type='hidden' name='delete_results' value='confirmation' />";
244
- echo "<input type='hidden' id='result_id' name='result_id' value='' />";
245
- echo "<input type='hidden' id='delete_quiz_name' name='delete_quiz_name' value='' />";
246
- echo "<p class='submit'><input type='submit' class='button-primary' value='Delete Results' /></p>";
247
- echo "</form>";
248
- ?>
249
- </div>
250
- </div>
251
- </div>
252
- <?php
253
- }
254
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/mlw_template_variables.php DELETED
@@ -1,128 +0,0 @@
1
- <?php
2
- /*
3
-
4
- Results Array For Reference:
5
-
6
- $mlw_qmn_result_array = array(
7
- 'quiz_id' => $mlw_quiz_id,
8
- 'quiz_name' => $mlw_quiz_options->quiz_name,
9
- 'quiz_system' => $mlw_quiz_options->system,
10
- 'total_points' => $mlw_points,
11
- 'total_score' => $mlw_total_score,
12
- 'total_correct' => $mlw_correct,
13
- 'total_questions' => $mlw_total_questions,
14
- 'user_name' => $mlw_user_name,
15
- 'user_business' => $mlw_user_comp,
16
- 'user_email' => $mlw_user_email,
17
- 'user_phone' => $mlw_user_phone,
18
- 'user_id' => get_current_user_id(),
19
- 'question_answers_display' => $mlw_question_answers,
20
- 'question_answers_array' => $mlw_qmn_answer_array,
21
- 'timer' => $mlw_qmn_timer,
22
- 'comments' => $mlw_qm_quiz_comments,
23
- 'certificate_link' => CERTIFICATE LINK
24
- );
25
-
26
- */
27
- add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_point_score',10,2);
28
- add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_average_point',10,2);
29
- add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_amount_correct',10,2);
30
- add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_total_questions',10,2);
31
- add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_correct_score',10,2);
32
- add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_quiz_name',10,2);
33
- add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_user_name',10,2);
34
- add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_user_business',10,2);
35
- add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_user_phone',10,2);
36
- add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_user_email',10,2);
37
- add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_question_answers',10,2);
38
- add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_comments',10,2);
39
- add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_timer',10,2);
40
- add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_date',10,2);
41
- add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_certificate_link',10,2);
42
-
43
- add_filter('mlw_qmn_template_variable_quiz_page', 'mlw_qmn_variable_quiz_name',10,2);
44
- add_filter('mlw_qmn_template_variable_quiz_page', 'mlw_qmn_variable_date',10,2);
45
- add_filter('mlw_qmn_template_variable_quiz_page', 'mlw_qmn_variable_current_user',10,2);
46
- function mlw_qmn_variable_point_score($content, $mlw_quiz_array)
47
- {
48
- $content = str_replace( "%POINT_SCORE%" , $mlw_quiz_array["total_points"], $content);
49
- return $content;
50
- }
51
- function mlw_qmn_variable_average_point($content, $mlw_quiz_array)
52
- {
53
- $mlw_average_points = $mlw_quiz_array["total_points"]/$mlw_quiz_array["total_questions"];
54
- $content = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $content);
55
- return $content;
56
- }
57
- function mlw_qmn_variable_amount_correct($content, $mlw_quiz_array)
58
- {
59
- $content = str_replace( "%AMOUNT_CORRECT%" , $mlw_quiz_array["total_correct"], $content);
60
- return $content;
61
- }
62
- function mlw_qmn_variable_total_questions($content, $mlw_quiz_array)
63
- {
64
- $content = str_replace( "%TOTAL_QUESTIONS%" , $mlw_quiz_array["total_questions"], $content);
65
- return $content;
66
- }
67
- function mlw_qmn_variable_correct_score($content, $mlw_quiz_array)
68
- {
69
- $content = str_replace( "%CORRECT_SCORE%" , $mlw_quiz_array["total_score"], $content);
70
- return $content;
71
- }
72
- function mlw_qmn_variable_quiz_name($content, $mlw_quiz_array)
73
- {
74
- $content = str_replace( "%QUIZ_NAME%" , $mlw_quiz_array["quiz_name"], $content);
75
- return $content;
76
- }
77
- function mlw_qmn_variable_user_name($content, $mlw_quiz_array)
78
- {
79
- $content = str_replace( "%USER_NAME%" , $mlw_quiz_array["user_name"], $content);
80
- return $content;
81
- }
82
- function mlw_qmn_variable_current_user($content, $mlw_quiz_array)
83
- {
84
- $current_user = wp_get_current_user();
85
- $content = str_replace( "%USER_NAME%" , $current_user->display_name, $content);
86
- return $content;
87
- }
88
- function mlw_qmn_variable_user_business($content, $mlw_quiz_array)
89
- {
90
- $content = str_replace( "%USER_BUSINESS%" , $mlw_quiz_array["user_business"], $content);
91
- return $content;
92
- }
93
- function mlw_qmn_variable_user_phone($content, $mlw_quiz_array)
94
- {
95
- $content = str_replace( "%USER_PHONE%" , $mlw_quiz_array["user_phone"], $content);
96
- return $content;
97
- }
98
- function mlw_qmn_variable_user_email($content, $mlw_quiz_array)
99
- {
100
- $content = str_replace( "%USER_EMAIL%" , $mlw_quiz_array["user_email"], $content);
101
- return $content;
102
- }
103
- function mlw_qmn_variable_question_answers($content, $mlw_quiz_array)
104
- {
105
- $content = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_quiz_array["question_answers_display"], $content);
106
- return $content;
107
- }
108
- function mlw_qmn_variable_comments($content, $mlw_quiz_array)
109
- {
110
- $content = str_replace( "%COMMENT_SECTION%" , $mlw_quiz_array["comments"], $content);
111
- return $content;
112
- }
113
- function mlw_qmn_variable_timer($content, $mlw_quiz_array)
114
- {
115
- $content = str_replace( "%TIMER%" , $mlw_quiz_array["timer"], $content);
116
- return $content;
117
- }
118
- function mlw_qmn_variable_date($content, $mlw_quiz_array)
119
- {
120
- $content = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $content);
121
- return $content;
122
- }
123
- function mlw_qmn_variable_certificate_link($content, $mlw_quiz_array)
124
- {
125
- $content = str_replace( "%CERTIFICATE_LINK%" , $mlw_quiz_array["certificate_link"], $content);
126
- return $content;
127
- }
128
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/qmn_addons.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function qmn_addons_page()
3
+ {
4
+ global $mlwQuizMasterNext;
5
+ $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'featured-addons';
6
+ $tab_array = $mlwQuizMasterNext->pluginHelper->get_addon_tabs();
7
+ ?>
8
+ <div class="wrap">
9
+ <h2>Quiz Master Next Addon Settings</h2>
10
+ <h2 class="nav-tab-wrapper">
11
+ <?php
12
+ foreach($tab_array as $tab)
13
+ {
14
+ $active_class = '';
15
+ if ($active_tab == $tab['slug'])
16
+ {
17
+ $active_class = 'nav-tab-active';
18
+ }
19
+ echo "<a href=\"?page=qmn_addons&tab=".$tab['slug']."\" class=\"nav-tab $active_class\">".$tab['title']."</a>";
20
+ }
21
+ ?>
22
+ </h2>
23
+ <div>
24
+ <?php
25
+ foreach($tab_array as $tab)
26
+ {
27
+ if ($active_tab == $tab['slug'])
28
+ {
29
+ call_user_func($tab['function']);
30
+ }
31
+ }
32
+ ?>
33
+ </div>
34
+ </div>
35
+ <?php
36
+ }
37
+
38
+
39
+ function qmn_generate_featured_addons()
40
+ {
41
+ wp_enqueue_style( 'qmn_addons_style', plugins_url( 'css/qmn_addons_page.css' , __FILE__ ) );
42
+ ?>
43
+ <p><?php _e('These addons extend the functionality of Quiz Master Next', 'quiz-master-next'); ?></p>
44
+ <div class="qmn_addons">
45
+ <h3 class="qmn_addons_title">Export Results</h3>
46
+ <p class="qmn_addons_desc">This add-on gives you the ability to export your quiz results as a CSV file.</p>
47
+ <a href="http://mylocalwebstop.com/downloads/export-results/" target="_blank" class="button">Get This Addon</a>
48
+ </div>
49
+ <div class="qmn_addons">
50
+ <h3 class="qmn_addons_title">Advertisement Be Gone</h3>
51
+ <p class="qmn_addons_desc">This add-on will remove all services/add-on advertisements in all of our Master Suite plugins.</p>
52
+ <a href="http://mylocalwebstop.com/downloads/advertisement-gone/" target="_blank" class="button">Get This Addon</a>
53
+ </div>
54
+ <div class="qmn_addons">
55
+ <h3 class="qmn_addons_title">MailPoet Integration</h3>
56
+ <p class="qmn_addons_desc">Grow your list of subscribers in MailPoet by using this add-on to add users who take your quizzes!</p>
57
+ <a href="http://mylocalwebstop.com/downloads/mailpoet-integration/" target="_blank" class="button">Get This Addon</a>
58
+ </div>
59
+ <div class="qmn_addons">
60
+ <h3 class="qmn_addons_title">Advanced Leaderboard</h3>
61
+ <p class="qmn_addons_desc">This add-on gives you 4 new leaderboard shortcodes and 2 new widgets that you can customize per use. You can edit how many results are listed, the name of the leaderboard, and the order the results are listed in.</p>
62
+ <a href="http://mylocalwebstop.com/downloads/advanced-leaderboard-quiz-master-next/" target="_blank" class="button">Get This Addon</a>
63
+ </div>
64
+ <div style="clear:both;">
65
+ <br />
66
+ <a href="http://mylocalwebstop.com/store/" target="_blank" class="button-primary"><?php _e('Browse All Addons', 'quiz-master-next'); ?></a>
67
+ <?php
68
+ }
69
+
70
+ function qmn_featured_addons_tab()
71
+ {
72
+ global $mlwQuizMasterNext;
73
+ $mlwQuizMasterNext->pluginHelper->register_addon_settings_tab(__("Featured Addons", 'quiz-master-next'), "qmn_generate_featured_addons");
74
+ }
75
+ add_action("plugins_loaded", 'qmn_featured_addons_tab');
76
+ ?>
includes/{mlw_adverts.php → qmn_adverts.php} RENAMED
File without changes
includes/{mlw_alerts.php → qmn_alerts.php} RENAMED
@@ -1,13 +1,13 @@
1
  <?php
2
  class MlwQmnAlertManager {
3
-
4
  public $alerts = array();
5
-
6
  public function newAlert($message, $type)
7
  {
8
  $this->alerts[] = array( 'message' => $message, 'type' => $type );
9
  }
10
-
11
  public function showAlerts()
12
  {
13
  $alert_list = "";
@@ -15,15 +15,15 @@ class MlwQmnAlertManager {
15
  {
16
  if ($alert['type'] == "success")
17
  {
18
- $alert_list .= "<div id=\"message\" class=\"updated below-h2\"><p><strong>Success! </strong>".$alert["message"]."</p></div>";
19
  }
20
  if ($alert['type'] == "error")
21
  {
22
- $alert_list .= "<div id=\"message\" class=\"error below-h2\"><p><strong>Error! </strong>".$alert["message"]."</p></div>";
23
  }
24
  }
25
  echo $alert_list;
26
  }
27
-
28
  }
29
  ?>
1
  <?php
2
  class MlwQmnAlertManager {
3
+
4
  public $alerts = array();
5
+
6
  public function newAlert($message, $type)
7
  {
8
  $this->alerts[] = array( 'message' => $message, 'type' => $type );
9
  }
10
+
11
  public function showAlerts()
12
  {
13
  $alert_list = "";
15
  {
16
  if ($alert['type'] == "success")
17
  {
18
+ $alert_list .= "<div id=\"message\" class=\"updated below-h2\"><p><strong>".__('Success!', 'quiz-master-next')." </strong>".$alert["message"]."</p></div>";
19
  }
20
  if ($alert['type'] == "error")
21
  {
22
+ $alert_list .= "<div id=\"message\" class=\"error below-h2\"><p><strong>".__('Error!', 'quiz-master-next')." </strong>".$alert["message"]."</p></div>";
23
  }
24
  }
25
  echo $alert_list;
26
  }
27
+
28
  }
29
  ?>
includes/{mlw_qmn_credits.php → qmn_credits.php} RENAMED
@@ -2,7 +2,7 @@
2
  /*
3
  This page shows the about page
4
  */
5
- /*
6
  Copyright 2014, My Local Webstop (email : fpcorso@mylocalwebstop.com)
7
  */
8
 
@@ -58,9 +58,9 @@ function mlw_generate_about_page()
58
  {
59
  background: <?php echo 'url("'.plugins_url( 'images/quiz_icon.png' , __FILE__ ).'")'; ?> no-repeat;
60
  background: none, <?php echo 'url("'.plugins_url( 'images/quiz_icon.png' , __FILE__ ).'")'; ?> no-repeat;
61
- position: absolute;
62
- top: 0;
63
- right: 0;
64
  background-color: #0d97d8;
65
  color: yellow;
66
  background-position: center 24px;
@@ -82,36 +82,71 @@ function mlw_generate_about_page()
82
  }
83
  </style>
84
  <div class="wrap about-wrap">
85
- <h1>Welcome To Quiz Master Next <?php echo $mlw_quiz_version; ?></h1>
86
- <div class="about-text">Thank you for updating!</div>
87
- <div class="mlw_qmn_icon_wrap">Version <?php echo $mlw_quiz_version; ?></div>
88
  <h2 class="nav-tab-wrapper">
89
  <a href="javascript:mlw_qmn_setTab(1);" id="mlw_qmn_tab_1" class="nav-tab nav-tab-active">
90
- What&#8217;s New In 3.9</a>
91
  <a href="javascript:mlw_qmn_setTab(2);" id="mlw_qmn_tab_2" class="nav-tab">
92
- Changelog For <?php echo $mlw_quiz_version; ?> </a>
93
  <a href="javascript:mlw_qmn_setTab(3);" id="mlw_qmn_tab_3" class="nav-tab">
94
- Requested Features</a>
95
  </h2>
96
  <div id="mlw_quiz_what_new">
97
- <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">New Text Editors On Text Tab</h2>
98
- <p style="text-align: center;">When editing text on the text tab, you will now being using the WordPress editor. You will be able to easily style your text as well as add media.</p>
99
  <br />
100
- <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">Please Take Our Survey To Better Improve This Plugin</h2>
101
- <p style="text-align: center;">When you have a moment, please take our survey for this plugin. By filling out the survey, you are helping us improve this plugin. Users who take the survey between now and December 31st, 2014 will be emailed a 25% off coupon for our WordPress Store. When you are ready, please <a href='http://mylocalwebstop.com/quiz-master-next-survey/'>take our survey</a>.</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  <br />
103
  <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">We Are On GitHub Now</h2>
104
  <p style="text-align: center;">We have had several users ask for this so we thought we would try it out. We now love github! Be sure to <a href="https://github.com/fpcorso/quiz_master_next/">make suggestions or contribute</a>.</p>
105
  <br />
 
 
 
106
  </div>
107
  <div id="mlw_quiz_changelog" style="display: none;">
108
- <h3><?php echo $mlw_quiz_version; ?> (December 30, 2014)</h3>
109
  <ul>
110
- <li>* Added Wp Editor To Text Tab</li>
111
- <li>* Added Weekly Stats To Snapshot Widget</li>
112
- <li>* Moved Email Settings To Emails Tab</li>
113
- <li>* Default Question Order Auto-increments For New Questions</li>
114
- <li>* In Code: Separated CSS/JS From Core Quiz PHP File</li>
 
 
 
 
 
 
 
 
115
  </ul>
116
  </div>
117
  <div id="mlw_quiz_requested" style="display: none;">
@@ -123,10 +158,8 @@ function mlw_generate_about_page()
123
  <ul>
124
  <li>Importing Questions</li>
125
  <li>Stats For Each Quiz</li>
126
- <li>Categories</li>
127
  <li>More Social Media Integration</li>
128
  <li>Show Question Amount On Pagination</li>
129
- <li>Required Questions</li>
130
  <li>Allow Quiz To Not Show Start Page</li>
131
  <li>Progress Bar For Timer</li>
132
  <li>Ability To Redirect User Instead Of Showing Results Page</li>
2
  /*
3
  This page shows the about page
4
  */
5
+ /*
6
  Copyright 2014, My Local Webstop (email : fpcorso@mylocalwebstop.com)
7
  */
8
 
58
  {
59
  background: <?php echo 'url("'.plugins_url( 'images/quiz_icon.png' , __FILE__ ).'")'; ?> no-repeat;
60
  background: none, <?php echo 'url("'.plugins_url( 'images/quiz_icon.png' , __FILE__ ).'")'; ?> no-repeat;
61
+ position: absolute;
62
+ top: 0;
63
+ right: 0;
64
  background-color: #0d97d8;
65
  color: yellow;
66
  background-position: center 24px;
82
  }
83
  </style>
84
  <div class="wrap about-wrap">
85
+ <h1><?php _e('Welcome To Quiz Master Next', 'quiz-master-next'); ?></h1>
86
+ <div class="about-text"><?php _e('Thank you for updating!', 'quiz-master-next'); ?></div>
87
+ <div class="mlw_qmn_icon_wrap"><?php echo $mlw_quiz_version; ?></div>
88
  <h2 class="nav-tab-wrapper">
89
  <a href="javascript:mlw_qmn_setTab(1);" id="mlw_qmn_tab_1" class="nav-tab nav-tab-active">
90
+ <?php _e("What's New!", 'quiz-master-next'); ?></a>
91
  <a href="javascript:mlw_qmn_setTab(2);" id="mlw_qmn_tab_2" class="nav-tab">
92
+ <?php _e('Changelog', 'quiz-master-next'); ?></a>
93
  <a href="javascript:mlw_qmn_setTab(3);" id="mlw_qmn_tab_3" class="nav-tab">
94
+ <?php _e('Requested Features', 'quiz-master-next'); ?></a>
95
  </h2>
96
  <div id="mlw_quiz_what_new">
97
+ <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">Categories</h2>
98
+ <p style="text-align: center;">You can now assign a category when editing a question or adding a new question. You can then use the new variables to show the user their score in a particular category or an average of the categories.</p>
99
  <br />
100
+ <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">Enhanced Required System</h2>
101
+ <p style="text-align: center;">You can now require multiple choice and multiple response questions to be answered before submitting the quiz.</p>
102
+ <br />
103
+ <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">Enhanced Results Pages</h2>
104
+ <p style="text-align: center;">You now use the WordPress editor when editing the Results Pages. You can also now use some shortcodes!</p>
105
+ <br />
106
+ <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">New Settings Page Designs</h2>
107
+ <p style="text-align: center;">You will notice many design changes on the settings page as we are still converting our design to a more WordPress feel.</p>
108
+ <br />
109
+ <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">This Plugin Is Now Translation Ready!</h2>
110
+ <p style="text-align: center;">For those who wish to assist in translating, you can find the POT in the languages folder. If you do not know what that is, feel free to contact me and I will assist you with it.</p>
111
+ <br />
112
+ <hr />
113
+ <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">For Developers:</h2>
114
+ <br />
115
+ <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">New Plugin Helper Class</h2>
116
+ <p style="text-align: center;">Our new plugin helper class has many functions to assist you in extending the plugin.</p>
117
+ <br />
118
+ <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">Converted To Extendable Question Types</h2>
119
+ <p style="text-align: center;">With the new system, you can use the plugin helper class to create custom question types.</p>
120
+ <br />
121
+ <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">20 New Filters And Hooks</h2>
122
+ <p style="text-align: center;">We added lots of filters and hooks throughout the code especially in the redesigned quiz shortcode file.</p>
123
+ <br />
124
+ <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">Rewrote 75% Of Quiz Shortcode File</h2>
125
+ <p style="text-align: center;">We took the time to rewrite almost all of the quiz shortcode file as it severly needed it. We created the new Quiz Manager class here as well.</p>
126
  <br />
127
  <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">We Are On GitHub Now</h2>
128
  <p style="text-align: center;">We have had several users ask for this so we thought we would try it out. We now love github! Be sure to <a href="https://github.com/fpcorso/quiz_master_next/">make suggestions or contribute</a>.</p>
129
  <br />
130
+ <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">Please Take Our Survey To Better Improve This Plugin</h2>
131
+ <p style="text-align: center;">When you have a moment, please take our survey for this plugin. By filling out the survey, you are helping us improve this plugin. Users who take the survey between now and December 31st, 2014 will be emailed a 25% off coupon for our WordPress Store. When you are ready, please <a href='http://mylocalwebstop.com/quiz-master-next-survey/'>take our survey</a>.</p>
132
+ <br />
133
  </div>
134
  <div id="mlw_quiz_changelog" style="display: none;">
135
+ <h3><?php echo $mlw_quiz_version; ?> (January 14, 2015)</h3>
136
  <ul>
137
+ <li>* Added Ability To Add Categories To Your Quizzes</li>
138
+ <li>* Added Multiple Choice And Multiple Response To Required System</li>
139
+ <li>* Added Wp Editor To Results Pages</li>
140
+ <li>* Added Shortcode Capability To Results Pages</li>
141
+ <li>* Added Translation Capabilities</li>
142
+ <li>* Created New Addon Settings Page</li>
143
+ <li>* Design Changes To Quiz Settings Page</li>
144
+ <li>* In Code: Added 20 New Filters And Hooks</li>
145
+ <li>* In Code: Turned Question Types Into Extendable Functions For Creating Own Question Types</li>
146
+ <li>* In Code: Created New Plugin Helper Class For Extending Plugin</li>
147
+ <li>* In Code: Rewrote 75% of quiz shortcode file. Now With New Quiz Manager Class</li>
148
+ <li>* In Code: Re-organized File/Directory Structure</li>
149
+ <li>* In Code: Separated Quiz Settings Functions Into Own Files</li>
150
  </ul>
151
  </div>
152
  <div id="mlw_quiz_requested" style="display: none;">
158
  <ul>
159
  <li>Importing Questions</li>
160
  <li>Stats For Each Quiz</li>
 
161
  <li>More Social Media Integration</li>
162
  <li>Show Question Amount On Pagination</li>
 
163
  <li>Allow Quiz To Not Show Start Page</li>
164
  <li>Progress Bar For Timer</li>
165
  <li>Ability To Redirect User Instead Of Showing Results Page</li>
includes/{mlw_dashboard.php → qmn_dashboard.php} RENAMED
@@ -2,7 +2,7 @@
2
  /*
3
  This page creates the main dashboard for the Quiz Master Next plugin
4
  */
5
- /*
6
  Copyright 2014, My Local Webstop (email : fpcorso@mylocalwebstop.com)
7
  */
8
 
@@ -10,20 +10,21 @@ function mlw_generate_quiz_dashboard()
10
  {
11
  //Page Variables
12
  $mlw_quiz_version = get_option('mlw_quiz_master_version');
13
-
14
  ///Creates the widgets
15
- add_meta_box("wpss_mrts", 'Quiz Daily Stats - Times Taken', "mlw_dashboard_box", "quiz_wpss");
16
- add_meta_box("wpss_mrts", 'Quiz Total Stats', "mlw_dashboard_box_three", "quiz_wpss3");
17
- add_meta_box("wpss_mrts", 'Quiz Weekly Stats - Times Taken', "mlw_dashboard_box_four", "quiz_wpss4");
18
- add_meta_box("wpss_mrts", 'Quiz Monthly Stats - Times Taken', "mlw_dashboard_box_five", "quiz_wpss5");
 
19
  if ( get_option('mlw_advert_shows') == 'true' )
20
  {
21
- add_meta_box("wpss_mrts", 'My Local Webstop Services', "mlw_dashboard_box_six", "quiz_wpss6");
22
  }
23
- add_meta_box("wpss_mrts", 'Quizzes Taken Today', "mlw_qmn_daily_percent_taken_widget", "quiz_wpss10");
24
- add_meta_box("wpss_mrts", 'Quizzes Taken Last 7 Days', "mlw_qmn_weekly_percent_taken_widget", "quiz_wpss11");
25
- add_meta_box("wpss_mrts", 'Quizzes Taken Last 30 Days', "mlw_qmn_monthly_percent_taken_widget", "quiz_wpss12");
26
- add_meta_box("wpss_mrts", 'Quizzes Taken Last 120 Days', "mlw_qmn_quaterly_percent_taken_widget", "quiz_wpss13");
27
  ?>
28
  <!-- css -->
29
  <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
@@ -34,7 +35,7 @@ function mlw_generate_quiz_dashboard()
34
  wp_enqueue_script( 'jquery-ui-button' );
35
  wp_enqueue_script( 'jquery-ui-tooltip' );
36
  ?>
37
- <script type="text/javascript" src="<?php echo plugin_dir_url( __FILE__ ); ?>jquery_sparkline.js"></script>
38
  <script type="text/javascript">
39
  var $j = jQuery.noConflict();
40
  // increase the default animation speed to exaggerate the effect
@@ -45,52 +46,56 @@ function mlw_generate_quiz_dashboard()
45
  });
46
  });
47
  $j(function() {
48
- $j('.inlinesparkline').sparkline('html', {type: 'line', width: '400', height: '200'});
49
  });
50
  </script>
51
  <div class="wrap">
52
- <h2>Quiz Master Next Version <?php echo $mlw_quiz_version; ?> Statistics</h2>
53
-
54
  <?php echo mlw_qmn_show_adverts(); ?>
55
  <!--Display Widget Boxes-->
56
  <div style="float:left; width:19%;" class="inner-sidebar1">
57
- <?php do_meta_boxes('quiz_wpss10','advanced',''); ?>
58
  </div>
59
-
60
  <div style="float:left; width:19%;" class="inner-sidebar1">
61
- <?php do_meta_boxes('quiz_wpss11','advanced',''); ?>
62
  </div>
63
-
64
  <div style="float:left; width:19%;" class="inner-sidebar1">
65
- <?php do_meta_boxes('quiz_wpss12','advanced',''); ?>
66
  </div>
67
-
68
  <div style="float:left; width:19%;" class="inner-sidebar1">
69
- <?php do_meta_boxes('quiz_wpss13','advanced',''); ?>
70
  </div>
71
-
72
  <div style="float:right; width:24%; " class="inner-sidebar1">
73
- <?php if ( get_option('mlw_advert_shows') == 'true' ) {do_meta_boxes('quiz_wpss6','advanced','');} ?>
74
  </div>
75
-
76
  <div style="float:left; width:38%;" class="inner-sidebar1">
77
- <?php do_meta_boxes('quiz_wpss','advanced',''); ?>
78
  </div>
79
-
80
  <div style="float:left; width:38%;" class="inner-sidebar1">
81
- <?php do_meta_boxes('quiz_wpss4','advanced',''); ?>
82
  </div>
83
-
84
  <!--<div style="clear:both">-->
85
-
 
 
 
 
86
  <div style="float:left; width:38%;" class="inner-sidebar1">
87
- <?php do_meta_boxes('quiz_wpss5','advanced',''); ?>
88
  </div>
89
-
90
  <div style="float:left; width:38%;" class="inner-sidebar1">
91
- <?php do_meta_boxes('quiz_wpss3','advanced',''); ?>
92
  </div>
93
-
94
  <div style="clear:both">
95
  </div>
96
  <?php
@@ -104,43 +109,43 @@ function mlw_dashboard_box()
104
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".date("Y-m-d")." 00:00:00' AND '".date("Y-m-d")." 23:59:59') AND deleted=0";
105
  $mlw_quiz_taken_today = $wpdb->get_results($sql);
106
  $mlw_quiz_taken_today = $wpdb->num_rows;
107
-
108
  $mlw_yesterday = mktime(0, 0, 0, date("m") , date("d")-1, date("Y"));
109
  $mlw_yesterday = date("Y-m-d", $mlw_yesterday);
110
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_yesterday." 00:00:00' AND '".$mlw_yesterday." 23:59:59') AND deleted=0";
111
  $mlw_quiz_taken_yesterday = $wpdb->get_results($sql);
112
  $mlw_quiz_taken_yesterday = $wpdb->num_rows;
113
-
114
  $mlw_two_days_ago = mktime(0, 0, 0, date("m") , date("d")-2, date("Y"));
115
  $mlw_two_days_ago = date("Y-m-d", $mlw_two_days_ago);
116
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_two_days_ago." 00:00:00' AND '".$mlw_two_days_ago." 23:59:59') AND deleted=0";
117
  $mlw_quiz_taken_two_days = $wpdb->get_results($sql);
118
  $mlw_quiz_taken_two_days = $wpdb->num_rows;
119
-
120
  $mlw_three_days_ago = mktime(0, 0, 0, date("m") , date("d")-3, date("Y"));
121
  $mlw_three_days_ago = date("Y-m-d", $mlw_three_days_ago);
122
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_three_days_ago." 00:00:00' AND '".$mlw_three_days_ago." 23:59:59') AND deleted=0";
123
  $mlw_quiz_taken_three_days = $wpdb->get_results($sql);
124
  $mlw_quiz_taken_three_days = $wpdb->num_rows;
125
-
126
  $mlw_four_days_ago = mktime(0, 0, 0, date("m") , date("d")-4, date("Y"));
127
  $mlw_four_days_ago = date("Y-m-d", $mlw_four_days_ago);
128
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_four_days_ago." 00:00:00' AND '".$mlw_four_days_ago." 23:59:59') AND deleted=0";
129
  $mlw_quiz_taken_four_days = $wpdb->get_results($sql);
130
  $mlw_quiz_taken_four_days = $wpdb->num_rows;
131
-
132
  $mlw_five_days_ago = mktime(0, 0, 0, date("m") , date("d")-5, date("Y"));
133
  $mlw_five_days_ago = date("Y-m-d", $mlw_five_days_ago);
134
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_five_days_ago." 00:00:00' AND '".$mlw_five_days_ago." 23:59:59') AND deleted=0";
135
  $mlw_quiz_taken_five_days = $wpdb->get_results($sql);
136
  $mlw_quiz_taken_five_days = $wpdb->num_rows;
137
-
138
  $mlw_six_days_ago = mktime(0, 0, 0, date("m") , date("d")-6, date("Y"));
139
  $mlw_six_days_ago = date("Y-m-d", $mlw_six_days_ago);
140
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_six_days_ago." 00:00:00' AND '".$mlw_six_days_ago." 23:59:59') AND deleted=0";
141
  $mlw_quiz_taken_six_days = $wpdb->get_results($sql);
142
  $mlw_quiz_taken_six_days = $wpdb->num_rows;
143
-
144
  $mlw_last_week = mktime(0, 0, 0, date("m") , date("d")-7, date("Y"));
145
  $mlw_last_week = date("Y-m-d", $mlw_last_week);
146
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_last_week." 00:00:00' AND '".$mlw_last_week." 23:59:59') AND deleted=0";
@@ -158,16 +163,16 @@ function mlw_dashboard_box_three()
158
  {
159
  //Function Variables
160
  global $wpdb;
161
-
162
  //Stats From Quiz Table
163
  $mlw_stat_total_quiz = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_quizzes" );
164
  $mlw_stat_total_deleted_quiz = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_quizzes WHERE deleted=1" );
165
  $mlw_stat_total_active_quiz = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_quizzes WHERE deleted=0" );
166
-
167
  //Stats From Question Table
168
  $mlw_stat_total_questions = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_questions" );
169
-
170
-
171
  $sql = "SELECT SUM(quiz_views) AS QuizViews FROM " . $wpdb->prefix . "mlw_quizzes WHERE deleted=0";
172
  $mlw_quiz_views = $wpdb->get_results($sql);
173
 
@@ -183,7 +188,7 @@ function mlw_dashboard_box_three()
183
  $mlw_quiz_taken = $mlw_eaches->QuizTaken;
184
  break;
185
  }
186
-
187
  $sql = "SELECT ROUND(AVG(quiz_views), 0) AS AvgViews FROM " . $wpdb->prefix . "mlw_quizzes WHERE deleted=0";
188
  $mlw_average_views = $wpdb->get_results($sql);
189
 
@@ -191,7 +196,7 @@ function mlw_dashboard_box_three()
191
  $mlw_average_views = $mlw_eaches->AvgViews;
192
  break;
193
  }
194
-
195
  $sql = "SELECT ROUND(AVG(quiz_taken), 0) AS AvgTaken FROM " . $wpdb->prefix . "mlw_quizzes WHERE deleted=0";
196
  $mlw_average_taken = $wpdb->get_results($sql);
197
 
@@ -199,7 +204,7 @@ function mlw_dashboard_box_three()
199
  $mlw_average_taken = $mlw_eaches->AvgTaken;
200
  break;
201
  }
202
-
203
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_quizzes WHERE deleted=0 ORDER BY quiz_views DESC LIMIT 1";
204
  $mlw_quiz_most_viewed = $wpdb->get_results($sql);
205
 
@@ -207,7 +212,7 @@ function mlw_dashboard_box_three()
207
  $mlw_quiz_most_viewed = $mlw_eaches->quiz_name;
208
  break;
209
  }
210
-
211
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_quizzes WHERE deleted=0 ORDER BY quiz_taken DESC LIMIT 1";
212
  $mlw_quiz_most_taken = $wpdb->get_results($sql);
213
 
@@ -219,59 +224,59 @@ function mlw_dashboard_box_three()
219
  <div>
220
  <table width='100%'>
221
  <tr>
222
- <td align='left'>Total Created Quizzes</td>
223
  <td align='right'><?php echo $mlw_stat_total_quiz; ?></td>
224
  </tr>
225
  <tr>
226
- <td align='left'>Total Deleted Quizzes</td>
227
  <td align='right'><?php echo $mlw_stat_total_deleted_quiz; ?></td>
228
  </tr>
229
  <tr>
230
- <td align='left'>Total Active Quizzes</td>
231
  <td align='right'><?php echo $mlw_stat_total_active_quiz; ?></td>
232
  </tr>
233
  <tr>
234
- <td align='left'>Total Created Questions</td>
235
  <td align='right'><?php echo $mlw_stat_total_questions; ?></td>
236
  </tr>
237
  <tr>
238
- <td align='left'>Total Times All Active Quizzes Have Been Viewed</td>
239
  <td align='right'><?php echo $mlw_quiz_views; ?></td>
240
  </tr>
241
  <tr>
242
- <td align='left'>Total Times All Active Quizzes Have Been Taken</td>
243
  <td align='right'><?php echo $mlw_quiz_taken; ?></td>
244
  </tr>
245
  <tr>
246
- <td align='left'>Average Amount Each Active Quiz Has Been Viewed</td>
247
  <td align='right'><?php echo $mlw_average_views; ?></td>
248
  </tr>
249
  <tr>
250
- <td align='left'>Average Amount Each Active Quiz Has Been Taken</td>
251
  <td align='right'><?php echo $mlw_average_taken; ?></td>
252
  </tr>
253
  <tr>
254
- <td align='left'>Quiz That Has Been Viewed The Most</td>
255
  <td align='right'><?php echo $mlw_quiz_most_viewed; ?></td>
256
  </tr>
257
  <tr>
258
- <td align='left'>Quiz That Has Been Taken The Most</td>
259
  <td align='right'><?php echo $mlw_quiz_most_taken; ?></td>
260
  </tr>
261
  </table>
262
  </div>
263
- <?php
264
  }
265
  function mlw_dashboard_box_four()
266
  {
267
  //Gather the weekly stats, one variable for each day for the graph
268
- global $wpdb;
269
  $mlw_this_week = mktime(0, 0, 0, date("m") , date("d")-6, date("Y"));
270
  $mlw_this_week = date("Y-m-d", $mlw_this_week);
271
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_this_week." 00:00:00' AND '".date("Y-m-d")." 23:59:59') AND deleted=0";
272
  $mlw_quiz_taken_this_week = $wpdb->get_results($sql);
273
  $mlw_quiz_taken_this_week = $wpdb->num_rows;
274
-
275
  $mlw_last_week_first = mktime(0, 0, 0, date("m") , date("d")-13, date("Y"));
276
  $mlw_last_week_first = date("Y-m-d", $mlw_last_week_first);
277
  $mlw_last_week_last = mktime(0, 0, 0, date("m") , date("d")-7, date("Y"));
@@ -279,7 +284,7 @@ function mlw_dashboard_box_four()
279
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_last_week_first." 00:00:00' AND '".$mlw_last_week_last." 23:59:59') AND deleted=0";
280
  $mlw_quiz_taken_last_week = $wpdb->get_results($sql);
281
  $mlw_quiz_taken_last_week = $wpdb->num_rows;
282
-
283
  $mlw_two_week_first = mktime(0, 0, 0, date("m") , date("d")-20, date("Y"));
284
  $mlw_two_week_first = date("Y-m-d", $mlw_two_week_first);
285
  $mlw_two_week_last = mktime(0, 0, 0, date("m") , date("d")-14, date("Y"));
@@ -287,7 +292,7 @@ function mlw_dashboard_box_four()
287
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_two_week_first." 00:00:00' AND '".$mlw_two_week_last." 23:59:59') AND deleted=0";
288
  $mlw_quiz_taken_two_week = $wpdb->get_results($sql);
289
  $mlw_quiz_taken_two_week = $wpdb->num_rows;
290
-
291
  $mlw_three_week_first = mktime(0, 0, 0, date("m") , date("d")-27, date("Y"));
292
  $mlw_three_week_first = date("Y-m-d", $mlw_three_week_first);
293
  $mlw_three_week_last = mktime(0, 0, 0, date("m") , date("d")-21, date("Y"));
@@ -301,16 +306,50 @@ function mlw_dashboard_box_four()
301
  </div>
302
  <?php
303
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
  function mlw_dashboard_box_five()
305
  {
306
  //Gather the monthly stats, one variable for each day for the graph
307
- global $wpdb;
308
  $mlw_this_month = mktime(0, 0, 0, date("m") , date("d")-29, date("Y"));
309
  $mlw_this_month = date("Y-m-d", $mlw_this_month);
310
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_this_month." 00:00:00' AND '".date("Y-m-d")." 23:59:59') AND deleted=0";
311
  $mlw_quiz_taken_this_month = $wpdb->get_results($sql);
312
  $mlw_quiz_taken_this_month = $wpdb->num_rows;
313
-
314
  $mlw_last_month_first = mktime(0, 0, 0, date("m") , date("d")-59, date("Y"));
315
  $mlw_last_month_first = date("Y-m-d", $mlw_last_month_first);
316
  $mlw_last_month_last = mktime(0, 0, 0, date("m") , date("d")-30, date("Y"));
@@ -318,7 +357,7 @@ function mlw_dashboard_box_five()
318
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_last_month_first." 00:00:00' AND '".$mlw_last_month_last." 23:59:59') AND deleted=0";
319
  $mlw_quiz_taken_last_month = $wpdb->get_results($sql);
320
  $mlw_quiz_taken_last_month = $wpdb->num_rows;
321
-
322
  $mlw_two_month_first = mktime(0, 0, 0, date("m") , date("d")-89, date("Y"));
323
  $mlw_two_month_first = date("Y-m-d", $mlw_two_month_first);
324
  $mlw_two_month_last = mktime(0, 0, 0, date("m") , date("d")-60, date("Y"));
@@ -326,7 +365,7 @@ function mlw_dashboard_box_five()
326
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_two_month_first." 00:00:00' AND '".$mlw_two_month_last." 23:59:59') AND deleted=0";
327
  $mlw_quiz_taken_two_month = $wpdb->get_results($sql);
328
  $mlw_quiz_taken_two_month = $wpdb->num_rows;
329
-
330
  $mlw_three_month_first = mktime(0, 0, 0, date("m") , date("d")-119, date("Y"));
331
  $mlw_three_month_first = date("Y-m-d", $mlw_three_month_first);
332
  $mlw_three_month_last = mktime(0, 0, 0, date("m") , date("d")-90, date("Y"));
@@ -334,7 +373,7 @@ function mlw_dashboard_box_five()
334
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_three_month_first." 00:00:00' AND '".$mlw_three_month_last." 23:59:59') AND deleted=0";
335
  $mlw_quiz_taken_three_month = $wpdb->get_results($sql);
336
  $mlw_quiz_taken_three_month = $wpdb->num_rows;
337
-
338
  $mlw_four_month_first = mktime(0, 0, 0, date("m") , date("d")-149, date("Y"));
339
  $mlw_four_month_first = date("Y-m-d", $mlw_four_month_first);
340
  $mlw_four_month_last = mktime(0, 0, 0, date("m") , date("d")-120, date("Y"));
@@ -342,7 +381,7 @@ function mlw_dashboard_box_five()
342
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_four_month_first." 00:00:00' AND '".$mlw_four_month_last." 23:59:59') AND deleted=0";
343
  $mlw_quiz_taken_four_month = $wpdb->get_results($sql);
344
  $mlw_quiz_taken_four_month = $wpdb->num_rows;
345
-
346
  ?>
347
  <div>
348
  <span class="inlinesparkline"><?php echo $mlw_quiz_taken_four_month.",".$mlw_quiz_taken_three_month.",".$mlw_quiz_taken_two_month.",".$mlw_quiz_taken_last_month.",".$mlw_quiz_taken_this_month; ?></span>
@@ -357,7 +396,7 @@ function mlw_dashboard_box_six()
357
  <h2>Plugin Premium Support</h2>
358
  <p>Get access to premium support and always be a priority in our support. We will provide technical support and even access your site to solve your problems. With premium support, we will answer your responses as quickly as possible and your feature requests will be priorities in our future updates.</p>
359
  <p>For details, visit our <a href="http://mylocalwebstop.com/downloads/plugin-premium-support/" target="_blank" style="color:blue;">Plugin Premium Support</a> page.</p>
360
- <hr />
361
  <h2>Plugin Installation Services</h2>
362
  <p>We will install and configure any or all of our WordPress plugins on your existing WordPress site.</p>
363
  <p>For details, visit our <a href="http://mylocalwebstop.com/downloads/plugin-installation/" target="_blank" style="color:blue;">Plugin Installation</a> page.</p>
@@ -372,17 +411,17 @@ function mlw_dashboard_box_six()
372
  function mlw_qmn_weekly_percent_taken_widget()
373
  {
374
  global $wpdb;
375
-
376
  $mlw_this_week = mktime(0, 0, 0, date("m") , date("d")-6, date("Y"));
377
  $mlw_this_week = date("Y-m-d", $mlw_this_week);
378
  $mlw_qmn_this_week_taken = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_this_week." 00:00:00' AND '".date("Y-m-d")." 23:59:59') AND deleted=0");
379
-
380
  $mlw_last_week_start = mktime(0, 0, 0, date("m") , date("d")-13, date("Y"));
381
  $mlw_last_week_start = date("Y-m-d", $mlw_last_week_start);
382
  $mlw_last_week_end = mktime(0, 0, 0, date("m") , date("d")-7, date("Y"));
383
  $mlw_last_week_end = date("Y-m-d", $mlw_last_week_end);
384
  $mlw_qmn_last_week_taken = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_last_week_start." 00:00:00' AND '".$mlw_last_week_end." 23:59:59') AND deleted=0");
385
-
386
  if ($mlw_qmn_last_week_taken != 0)
387
  {
388
  $mlw_qmn_analyze_week = round((($mlw_qmn_this_week_taken - $mlw_qmn_last_week_taken) / $mlw_qmn_last_week_taken) * 100, 2);
@@ -401,8 +440,8 @@ function mlw_qmn_weekly_percent_taken_widget()
401
  <tr>
402
  <td>
403
  <div style="font-size: 40px; text-align:center;">
404
- <?php
405
- echo "<span title='Compared to the previous 7 days'>".$mlw_qmn_analyze_week."%</span>";
406
  if ($mlw_qmn_analyze_week >= 0)
407
  {
408
  echo "<img src='".plugin_dir_url( __FILE__ )."images/green_triangle.png' width='40px' height='40px'/>";
@@ -444,8 +483,8 @@ function mlw_qmn_daily_percent_taken_widget()
444
  <tr>
445
  <td>
446
  <div style="font-size: 40px; text-align:center;">
447
- <?php
448
- echo "<span title='Compared to this day last week'>".$mlw_qmn_analyze_today."%</span>";
449
  if ($mlw_qmn_analyze_today >= 0)
450
  {
451
  echo "<img src='".plugin_dir_url( __FILE__ )."images/green_triangle.png' width='40px' height='40px'/>";
@@ -465,17 +504,17 @@ function mlw_qmn_daily_percent_taken_widget()
465
  function mlw_qmn_monthly_percent_taken_widget()
466
  {
467
  global $wpdb;
468
-
469
  $mlw_this_month = mktime(0, 0, 0, date("m") , date("d")-29, date("Y"));
470
  $mlw_this_month = date("Y-m-d", $mlw_this_month);
471
  $mlw_qmn_this_month_taken = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_this_month." 00:00:00' AND '".date("Y-m-d")." 23:59:59') AND deleted=0");
472
-
473
  $mlw_last_month_start = mktime(0, 0, 0, date("m") , date("d")-59, date("Y"));
474
  $mlw_last_month_start = date("Y-m-d", $mlw_last_month_start);
475
  $mlw_last_month_end = mktime(0, 0, 0, date("m") , date("d")-30, date("Y"));
476
  $mlw_last_month_end = date("Y-m-d", $mlw_last_month_end);
477
  $mlw_qmn_last_month_taken = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_last_month_start." 00:00:00' AND '".$mlw_last_month_end." 23:59:59') AND deleted=0");
478
-
479
  if ($mlw_qmn_last_month_taken != 0)
480
  {
481
  $mlw_qmn_analyze_month = round((($mlw_qmn_this_month_taken - $mlw_qmn_last_month_taken) / $mlw_qmn_last_month_taken) * 100, 2);
@@ -494,8 +533,8 @@ function mlw_qmn_monthly_percent_taken_widget()
494
  <tr>
495
  <td>
496
  <div style="font-size: 40px; text-align:center;">
497
- <?php
498
- echo "<span title='Compared to the previous 30 days'>".$mlw_qmn_analyze_month."%</span>";
499
  if ($mlw_qmn_analyze_month >= 0)
500
  {
501
  echo "<img src='".plugin_dir_url( __FILE__ )."images/green_triangle.png' width='40px' height='40px'/>";
@@ -515,17 +554,17 @@ function mlw_qmn_monthly_percent_taken_widget()
515
  function mlw_qmn_quaterly_percent_taken_widget()
516
  {
517
  global $wpdb;
518
-
519
  $mlw_this_quater = mktime(0, 0, 0, date("m") , date("d")-89, date("Y"));
520
  $mlw_this_quater = date("Y-m-d", $mlw_this_quater);
521
  $mlw_qmn_this_quater_taken = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_this_quater." 00:00:00' AND '".date("Y-m-d")." 23:59:59') AND deleted=0");
522
-
523
  $mlw_last_quater_start = mktime(0, 0, 0, date("m") , date("d")-179, date("Y"));
524
  $mlw_last_quater_start = date("Y-m-d", $mlw_last_quater_start);
525
  $mlw_last_quater_end = mktime(0, 0, 0, date("m") , date("d")-90, date("Y"));
526
  $mlw_last_quater_end = date("Y-m-d", $mlw_last_quater_end);
527
  $mlw_qmn_last_quater_taken = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_last_quater_start." 00:00:00' AND '".$mlw_last_quater_end." 23:59:59') AND deleted=0");
528
-
529
  if ($mlw_qmn_last_quater_taken != 0)
530
  {
531
  $mlw_qmn_analyze_quater = round((($mlw_qmn_this_quater_taken - $mlw_qmn_last_quater_taken) / $mlw_qmn_last_quater_taken) * 100, 2);
@@ -544,8 +583,8 @@ function mlw_qmn_quaterly_percent_taken_widget()
544
  <tr>
545
  <td>
546
  <div style="font-size: 40px; text-align:center;">
547
- <?php
548
- echo "<span title='Compared to the previous 120 days'>".$mlw_qmn_analyze_quater."%</span>";
549
  if ($mlw_qmn_analyze_quater >= 0)
550
  {
551
  echo "<img src='".plugin_dir_url( __FILE__ )."images/green_triangle.png' width='40px' height='40px'/>";
2
  /*
3
  This page creates the main dashboard for the Quiz Master Next plugin
4
  */
5
+ /*
6
  Copyright 2014, My Local Webstop (email : fpcorso@mylocalwebstop.com)
7
  */
8
 
10
  {
11
  //Page Variables
12
  $mlw_quiz_version = get_option('mlw_quiz_master_version');
13
+
14
  ///Creates the widgets
15
+ add_meta_box("wpss_mrts", __('Quiz Daily Stats - Times Taken', 'quiz-master-next'), "mlw_dashboard_box", "quiz_wpss");
16
+ add_meta_box("wpss_mrts", __('Quiz Total Stats', 'quiz-master-next'), "mlw_dashboard_box_three", "quiz_wpss3");
17
+ add_meta_box("wpss_mrts", __('Quiz Weekly Stats - Times Taken', 'quiz-master-next'), "mlw_dashboard_box_four", "quiz_wpss4");
18
+ add_meta_box("wpss_mrts", __('Quiz Monthly Stats - Times Taken', 'quiz-master-next'), "mlw_dashboard_box_five", "quiz_wpss5");
19
+ add_meta_box("wpss_mrts", __('Quiz Quarterly Stats - Times Taken', 'quiz-master-next'), "qmn_meta_quarterly_stats", "quiz_wpss2");
20
  if ( get_option('mlw_advert_shows') == 'true' )
21
  {
22
+ add_meta_box("wpss_mrts", 'My Local Webstop Services', "mlw_dashboard_box_six", "quiz_wpss6");
23
  }
24
+ add_meta_box("wpss_mrts", __('Quizzes Taken Today', 'quiz-master-next'), "mlw_qmn_daily_percent_taken_widget", "quiz_wpss10");
25
+ add_meta_box("wpss_mrts", __('Quizzes Taken Last 7 Days', 'quiz-master-next'), "mlw_qmn_weekly_percent_taken_widget", "quiz_wpss11");
26
+ add_meta_box("wpss_mrts", __('Quizzes Taken Last 30 Days', 'quiz-master-next'), "mlw_qmn_monthly_percent_taken_widget", "quiz_wpss12");
27
+ add_meta_box("wpss_mrts", __('Quizzes Taken Last 120 Days', 'quiz-master-next'), "mlw_qmn_quaterly_percent_taken_widget", "quiz_wpss13");
28
  ?>
29
  <!-- css -->
30
  <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
35
  wp_enqueue_script( 'jquery-ui-button' );
36
  wp_enqueue_script( 'jquery-ui-tooltip' );
37
  ?>
38
+ <script type="text/javascript" src="<?php echo plugin_dir_url( __FILE__ ); ?>js/sparkline/jquery_sparkline.js"></script>
39
  <script type="text/javascript">
40
  var $j = jQuery.noConflict();
41
  // increase the default animation speed to exaggerate the effect
46
  });
47
  });
48
  $j(function() {
49
+ $j('.inlinesparkline').sparkline('html', {type: 'line', width: '400', height: '200'});
50
  });
51
  </script>
52
  <div class="wrap">
53
+ <h2><?php _e('Quiz Statistics', 'quiz-master-next'); ?></h2>
54
+
55
  <?php echo mlw_qmn_show_adverts(); ?>
56
  <!--Display Widget Boxes-->
57
  <div style="float:left; width:19%;" class="inner-sidebar1">
58
+ <?php do_meta_boxes('quiz_wpss10','advanced',''); ?>
59
  </div>
60
+
61
  <div style="float:left; width:19%;" class="inner-sidebar1">
62
+ <?php do_meta_boxes('quiz_wpss11','advanced',''); ?>
63
  </div>
64
+
65
  <div style="float:left; width:19%;" class="inner-sidebar1">
66
+ <?php do_meta_boxes('quiz_wpss12','advanced',''); ?>
67
  </div>
68
+
69
  <div style="float:left; width:19%;" class="inner-sidebar1">
70
+ <?php do_meta_boxes('quiz_wpss13','advanced',''); ?>
71
  </div>
72
+
73
  <div style="float:right; width:24%; " class="inner-sidebar1">
74
+ <?php if ( get_option('mlw_advert_shows') == 'true' ) {do_meta_boxes('quiz_wpss6','advanced','');} ?>
75
  </div>
76
+
77
  <div style="float:left; width:38%;" class="inner-sidebar1">
78
+ <?php do_meta_boxes('quiz_wpss','advanced',''); ?>
79
  </div>
80
+
81
  <div style="float:left; width:38%;" class="inner-sidebar1">
82
+ <?php do_meta_boxes('quiz_wpss4','advanced',''); ?>
83
  </div>
84
+
85
  <!--<div style="clear:both">-->
86
+
87
+ <div style="float:left; width:38%;" class="inner-sidebar1">
88
+ <?php do_meta_boxes('quiz_wpss5','advanced',''); ?>
89
+ </div>
90
+
91
  <div style="float:left; width:38%;" class="inner-sidebar1">
92
+ <?php do_meta_boxes('quiz_wpss2','advanced',''); ?>
93
  </div>
94
+
95
  <div style="float:left; width:38%;" class="inner-sidebar1">
96
+ <?php do_meta_boxes('quiz_wpss3','advanced',''); ?>
97
  </div>
98
+
99
  <div style="clear:both">
100
  </div>
101
  <?php
109
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".date("Y-m-d")." 00:00:00' AND '".date("Y-m-d")." 23:59:59') AND deleted=0";
110
  $mlw_quiz_taken_today = $wpdb->get_results($sql);
111
  $mlw_quiz_taken_today = $wpdb->num_rows;
112
+
113
  $mlw_yesterday = mktime(0, 0, 0, date("m") , date("d")-1, date("Y"));
114
  $mlw_yesterday = date("Y-m-d", $mlw_yesterday);
115
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_yesterday." 00:00:00' AND '".$mlw_yesterday." 23:59:59') AND deleted=0";
116
  $mlw_quiz_taken_yesterday = $wpdb->get_results($sql);
117
  $mlw_quiz_taken_yesterday = $wpdb->num_rows;
118
+
119
  $mlw_two_days_ago = mktime(0, 0, 0, date("m") , date("d")-2, date("Y"));
120
  $mlw_two_days_ago = date("Y-m-d", $mlw_two_days_ago);
121
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_two_days_ago." 00:00:00' AND '".$mlw_two_days_ago." 23:59:59') AND deleted=0";
122
  $mlw_quiz_taken_two_days = $wpdb->get_results($sql);
123
  $mlw_quiz_taken_two_days = $wpdb->num_rows;
124
+
125
  $mlw_three_days_ago = mktime(0, 0, 0, date("m") , date("d")-3, date("Y"));
126
  $mlw_three_days_ago = date("Y-m-d", $mlw_three_days_ago);
127
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_three_days_ago." 00:00:00' AND '".$mlw_three_days_ago." 23:59:59') AND deleted=0";
128
  $mlw_quiz_taken_three_days = $wpdb->get_results($sql);
129
  $mlw_quiz_taken_three_days = $wpdb->num_rows;
130
+
131
  $mlw_four_days_ago = mktime(0, 0, 0, date("m") , date("d")-4, date("Y"));
132
  $mlw_four_days_ago = date("Y-m-d", $mlw_four_days_ago);
133
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_four_days_ago." 00:00:00' AND '".$mlw_four_days_ago." 23:59:59') AND deleted=0";
134
  $mlw_quiz_taken_four_days = $wpdb->get_results($sql);
135
  $mlw_quiz_taken_four_days = $wpdb->num_rows;
136
+
137
  $mlw_five_days_ago = mktime(0, 0, 0, date("m") , date("d")-5, date("Y"));
138
  $mlw_five_days_ago = date("Y-m-d", $mlw_five_days_ago);
139
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_five_days_ago." 00:00:00' AND '".$mlw_five_days_ago." 23:59:59') AND deleted=0";
140
  $mlw_quiz_taken_five_days = $wpdb->get_results($sql);
141
  $mlw_quiz_taken_five_days = $wpdb->num_rows;
142
+
143
  $mlw_six_days_ago = mktime(0, 0, 0, date("m") , date("d")-6, date("Y"));
144
  $mlw_six_days_ago = date("Y-m-d", $mlw_six_days_ago);
145
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_six_days_ago." 00:00:00' AND '".$mlw_six_days_ago." 23:59:59') AND deleted=0";
146
  $mlw_quiz_taken_six_days = $wpdb->get_results($sql);
147
  $mlw_quiz_taken_six_days = $wpdb->num_rows;
148
+
149
  $mlw_last_week = mktime(0, 0, 0, date("m") , date("d")-7, date("Y"));
150
  $mlw_last_week = date("Y-m-d", $mlw_last_week);
151
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_last_week." 00:00:00' AND '".$mlw_last_week." 23:59:59') AND deleted=0";
163
  {
164
  //Function Variables
165
  global $wpdb;
166
+
167
  //Stats From Quiz Table
168
  $mlw_stat_total_quiz = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_quizzes" );
169
  $mlw_stat_total_deleted_quiz = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_quizzes WHERE deleted=1" );
170
  $mlw_stat_total_active_quiz = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_quizzes WHERE deleted=0" );
171
+
172
  //Stats From Question Table
173
  $mlw_stat_total_questions = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_questions" );
174
+
175
+
176
  $sql = "SELECT SUM(quiz_views) AS QuizViews FROM " . $wpdb->prefix . "mlw_quizzes WHERE deleted=0";
177
  $mlw_quiz_views = $wpdb->get_results($sql);
178
 
188
  $mlw_quiz_taken = $mlw_eaches->QuizTaken;
189
  break;
190
  }
191
+
192
  $sql = "SELECT ROUND(AVG(quiz_views), 0) AS AvgViews FROM " . $wpdb->prefix . "mlw_quizzes WHERE deleted=0";
193
  $mlw_average_views = $wpdb->get_results($sql);
194
 
196
  $mlw_average_views = $mlw_eaches->AvgViews;
197
  break;
198
  }
199
+
200
  $sql = "SELECT ROUND(AVG(quiz_taken), 0) AS AvgTaken FROM " . $wpdb->prefix . "mlw_quizzes WHERE deleted=0";
201
  $mlw_average_taken = $wpdb->get_results($sql);
202
 
204
  $mlw_average_taken = $mlw_eaches->AvgTaken;
205
  break;
206
  }
207
+
208
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_quizzes WHERE deleted=0 ORDER BY quiz_views DESC LIMIT 1";
209
  $mlw_quiz_most_viewed = $wpdb->get_results($sql);
210
 
212
  $mlw_quiz_most_viewed = $mlw_eaches->quiz_name;
213
  break;
214
  }
215
+
216
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_quizzes WHERE deleted=0 ORDER BY quiz_taken DESC LIMIT 1";
217
  $mlw_quiz_most_taken = $wpdb->get_results($sql);
218
 
224
  <div>
225
  <table width='100%'>
226
  <tr>
227
+ <td align='left'><?php _e('Total Created Quizzes', 'quiz-master-next'); ?></td>
228
  <td align='right'><?php echo $mlw_stat_total_quiz; ?></td>
229
  </tr>
230
  <tr>
231
+ <td align='left'><?php _e('Total Deleted Quizzes', 'quiz-master-next'); ?></td>
232
  <td align='right'><?php echo $mlw_stat_total_deleted_quiz; ?></td>
233
  </tr>
234
  <tr>
235
+ <td align='left'><?php _e('Total Active Quizzes', 'quiz-master-next'); ?></td>
236
  <td align='right'><?php echo $mlw_stat_total_active_quiz; ?></td>
237
  </tr>
238
  <tr>
239
+ <td align='left'><?php _e('Total Created Questions', 'quiz-master-next'); ?></td>
240
  <td align='right'><?php echo $mlw_stat_total_questions; ?></td>
241
  </tr>
242
  <tr>
243
+ <td align='left'><?php _e('Total Times All Active Quizzes Have Been Viewed', 'quiz-master-next'); ?></td>
244
  <td align='right'><?php echo $mlw_quiz_views; ?></td>
245
  </tr>
246
  <tr>
247
+ <td align='left'><?php _e('Total Times All Active Quizzes Have Been Taken', 'quiz-master-next'); ?></td>
248
  <td align='right'><?php echo $mlw_quiz_taken; ?></td>
249
  </tr>
250
  <tr>
251
+ <td align='left'><?php _e('Average Amount Each Active Quiz Has Been Viewed', 'quiz-master-next'); ?></td>
252
  <td align='right'><?php echo $mlw_average_views; ?></td>
253
  </tr>
254
  <tr>
255
+ <td align='left'><?php _e('Average Amount Each Active Quiz Has Been Taken', 'quiz-master-next'); ?></td>
256
  <td align='right'><?php echo $mlw_average_taken; ?></td>
257
  </tr>
258
  <tr>
259
+ <td align='left'><?php _e('Quiz That Has Been Viewed The Most', 'quiz-master-next'); ?></td>
260
  <td align='right'><?php echo $mlw_quiz_most_viewed; ?></td>
261
  </tr>
262
  <tr>
263
+ <td align='left'><?php _e('Quiz That Has Been Taken The Most', 'quiz-master-next'); ?></td>
264
  <td align='right'><?php echo $mlw_quiz_most_taken; ?></td>
265
  </tr>
266
  </table>
267
  </div>
268
+ <?php
269
  }
270
  function mlw_dashboard_box_four()
271
  {
272
  //Gather the weekly stats, one variable for each day for the graph
273
+ global $wpdb;
274
  $mlw_this_week = mktime(0, 0, 0, date("m") , date("d")-6, date("Y"));
275
  $mlw_this_week = date("Y-m-d", $mlw_this_week);
276
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_this_week." 00:00:00' AND '".date("Y-m-d")." 23:59:59') AND deleted=0";
277
  $mlw_quiz_taken_this_week = $wpdb->get_results($sql);
278
  $mlw_quiz_taken_this_week = $wpdb->num_rows;
279
+
280
  $mlw_last_week_first = mktime(0, 0, 0, date("m") , date("d")-13, date("Y"));
281
  $mlw_last_week_first = date("Y-m-d", $mlw_last_week_first);
282
  $mlw_last_week_last = mktime(0, 0, 0, date("m") , date("d")-7, date("Y"));
284
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_last_week_first." 00:00:00' AND '".$mlw_last_week_last." 23:59:59') AND deleted=0";
285
  $mlw_quiz_taken_last_week = $wpdb->get_results($sql);
286
  $mlw_quiz_taken_last_week = $wpdb->num_rows;
287
+
288
  $mlw_two_week_first = mktime(0, 0, 0, date("m") , date("d")-20, date("Y"));
289
  $mlw_two_week_first = date("Y-m-d", $mlw_two_week_first);
290
  $mlw_two_week_last = mktime(0, 0, 0, date("m") , date("d")-14, date("Y"));
292
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_two_week_first." 00:00:00' AND '".$mlw_two_week_last." 23:59:59') AND deleted=0";
293
  $mlw_quiz_taken_two_week = $wpdb->get_results($sql);
294
  $mlw_quiz_taken_two_week = $wpdb->num_rows;
295
+
296
  $mlw_three_week_first = mktime(0, 0, 0, date("m") , date("d")-27, date("Y"));
297
  $mlw_three_week_first = date("Y-m-d", $mlw_three_week_first);
298
  $mlw_three_week_last = mktime(0, 0, 0, date("m") , date("d")-21, date("Y"));
306
  </div>
307
  <?php
308
  }
309
+
310
+ function qmn_meta_quarterly_stats()
311
+ {
312
+ //Gather the monthly stats, one variable for each day for the graph
313
+ global $wpdb;
314
+ $mlw_this_quarter = mktime(0, 0, 0, date("m") , date("d")-89, date("Y"));
315
+ $mlw_this_quarter = date("Y-m-d", $mlw_this_quarter);
316
+ $mlw_quiz_this_quarter = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE deleted=0 AND (time_taken_real BETWEEN '".$mlw_this_quarter." 00:00:00' AND '".date("Y-m-d")." 23:59:59')");
317
+
318
+ $mlw_last_quarter_first = mktime(0, 0, 0, date("m") , date("d")-179, date("Y"));
319
+ $mlw_last_quarter_first = date("Y-m-d", $mlw_last_quarter_first);
320
+ $mlw_last_quarter_last = mktime(0, 0, 0, date("m") , date("d")-90, date("Y"));
321
+ $mlw_last_quarter_last = date("Y-m-d", $mlw_last_quarter_last);
322
+ $mlw_quiz_last_quarter = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE deleted=0 AND (time_taken_real BETWEEN '".$mlw_last_quarter_first." 00:00:00' AND '".$mlw_last_quarter_last." 23:59:59')");
323
+
324
+ $mlw_two_quarter_first = mktime(0, 0, 0, date("m") , date("d")-269, date("Y"));
325
+ $mlw_two_quarter_first = date("Y-m-d", $mlw_two_quarter_first);
326
+ $mlw_two_quarter_last = mktime(0, 0, 0, date("m") , date("d")-180, date("Y"));
327
+ $mlw_two_quarter_last = date("Y-m-d", $mlw_two_quarter_last);
328
+ $mlw_quiz_two_quarters = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE deleted=0 AND (time_taken_real BETWEEN '".$mlw_two_quarter_first." 00:00:00' AND '".$mlw_two_quarter_last." 23:59:59')");
329
+
330
+ $mlw_three_quarter_first = mktime(0, 0, 0, date("m") , date("d")-359, date("Y"));
331
+ $mlw_three_quarter_first = date("Y-m-d", $mlw_three_quarter_first);
332
+ $mlw_three_quarter_last = mktime(0, 0, 0, date("m") , date("d")-270, date("Y"));
333
+ $mlw_three_quarter_last = date("Y-m-d", $mlw_three_quarter_last);
334
+ $mlw_quiz_three_quarters = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE deleted=0 AND (time_taken_real BETWEEN '".$mlw_three_quarter_first." 00:00:00' AND '".$mlw_three_quarter_last." 23:59:59')");
335
+
336
+ ?>
337
+ <div>
338
+ <span class="inlinesparkline"><?php echo $mlw_quiz_three_quarters.",".$mlw_quiz_two_quarters.",".$mlw_quiz_last_quarter.",".$mlw_quiz_this_quarter; ?></span>
339
+ </div>
340
+ <?php
341
+ }
342
+
343
  function mlw_dashboard_box_five()
344
  {
345
  //Gather the monthly stats, one variable for each day for the graph
346
+ global $wpdb;
347
  $mlw_this_month = mktime(0, 0, 0, date("m") , date("d")-29, date("Y"));
348
  $mlw_this_month = date("Y-m-d", $mlw_this_month);
349
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_this_month." 00:00:00' AND '".date("Y-m-d")." 23:59:59') AND deleted=0";
350
  $mlw_quiz_taken_this_month = $wpdb->get_results($sql);
351
  $mlw_quiz_taken_this_month = $wpdb->num_rows;
352
+
353
  $mlw_last_month_first = mktime(0, 0, 0, date("m") , date("d")-59, date("Y"));
354
  $mlw_last_month_first = date("Y-m-d", $mlw_last_month_first);
355
  $mlw_last_month_last = mktime(0, 0, 0, date("m") , date("d")-30, date("Y"));
357
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_last_month_first." 00:00:00' AND '".$mlw_last_month_last." 23:59:59') AND deleted=0";
358
  $mlw_quiz_taken_last_month = $wpdb->get_results($sql);
359
  $mlw_quiz_taken_last_month = $wpdb->num_rows;
360
+
361
  $mlw_two_month_first = mktime(0, 0, 0, date("m") , date("d")-89, date("Y"));
362
  $mlw_two_month_first = date("Y-m-d", $mlw_two_month_first);
363
  $mlw_two_month_last = mktime(0, 0, 0, date("m") , date("d")-60, date("Y"));
365
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_two_month_first." 00:00:00' AND '".$mlw_two_month_last." 23:59:59') AND deleted=0";
366
  $mlw_quiz_taken_two_month = $wpdb->get_results($sql);
367
  $mlw_quiz_taken_two_month = $wpdb->num_rows;
368
+
369
  $mlw_three_month_first = mktime(0, 0, 0, date("m") , date("d")-119, date("Y"));
370
  $mlw_three_month_first = date("Y-m-d", $mlw_three_month_first);
371
  $mlw_three_month_last = mktime(0, 0, 0, date("m") , date("d")-90, date("Y"));
373
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_three_month_first." 00:00:00' AND '".$mlw_three_month_last." 23:59:59') AND deleted=0";
374
  $mlw_quiz_taken_three_month = $wpdb->get_results($sql);
375
  $mlw_quiz_taken_three_month = $wpdb->num_rows;
376
+
377
  $mlw_four_month_first = mktime(0, 0, 0, date("m") , date("d")-149, date("Y"));
378
  $mlw_four_month_first = date("Y-m-d", $mlw_four_month_first);
379
  $mlw_four_month_last = mktime(0, 0, 0, date("m") , date("d")-120, date("Y"));
381
  $sql = "SELECT quiz_name FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_four_month_first." 00:00:00' AND '".$mlw_four_month_last." 23:59:59') AND deleted=0";
382
  $mlw_quiz_taken_four_month = $wpdb->get_results($sql);
383
  $mlw_quiz_taken_four_month = $wpdb->num_rows;
384
+
385
  ?>
386
  <div>
387
  <span class="inlinesparkline"><?php echo $mlw_quiz_taken_four_month.",".$mlw_quiz_taken_three_month.",".$mlw_quiz_taken_two_month.",".$mlw_quiz_taken_last_month.",".$mlw_quiz_taken_this_month; ?></span>
396
  <h2>Plugin Premium Support</h2>
397
  <p>Get access to premium support and always be a priority in our support. We will provide technical support and even access your site to solve your problems. With premium support, we will answer your responses as quickly as possible and your feature requests will be priorities in our future updates.</p>
398
  <p>For details, visit our <a href="http://mylocalwebstop.com/downloads/plugin-premium-support/" target="_blank" style="color:blue;">Plugin Premium Support</a> page.</p>
399
+ <hr />
400
  <h2>Plugin Installation Services</h2>
401
  <p>We will install and configure any or all of our WordPress plugins on your existing WordPress site.</p>
402
  <p>For details, visit our <a href="http://mylocalwebstop.com/downloads/plugin-installation/" target="_blank" style="color:blue;">Plugin Installation</a> page.</p>
411
  function mlw_qmn_weekly_percent_taken_widget()
412
  {
413
  global $wpdb;
414
+
415
  $mlw_this_week = mktime(0, 0, 0, date("m") , date("d")-6, date("Y"));
416
  $mlw_this_week = date("Y-m-d", $mlw_this_week);
417
  $mlw_qmn_this_week_taken = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_this_week." 00:00:00' AND '".date("Y-m-d")." 23:59:59') AND deleted=0");
418
+
419
  $mlw_last_week_start = mktime(0, 0, 0, date("m") , date("d")-13, date("Y"));
420
  $mlw_last_week_start = date("Y-m-d", $mlw_last_week_start);
421
  $mlw_last_week_end = mktime(0, 0, 0, date("m") , date("d")-7, date("Y"));
422
  $mlw_last_week_end = date("Y-m-d", $mlw_last_week_end);
423
  $mlw_qmn_last_week_taken = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_last_week_start." 00:00:00' AND '".$mlw_last_week_end." 23:59:59') AND deleted=0");
424
+
425
  if ($mlw_qmn_last_week_taken != 0)
426
  {
427
  $mlw_qmn_analyze_week = round((($mlw_qmn_this_week_taken - $mlw_qmn_last_week_taken) / $mlw_qmn_last_week_taken) * 100, 2);
440
  <tr>
441
  <td>
442
  <div style="font-size: 40px; text-align:center;">
443
+ <?php
444
+ echo "<span title='Compared to the previous 7 days'>".$mlw_qmn_analyze_week."%</span>";
445
  if ($mlw_qmn_analyze_week >= 0)
446
  {
447
  echo "<img src='".plugin_dir_url( __FILE__ )."images/green_triangle.png' width='40px' height='40px'/>";
483
  <tr>
484
  <td>
485
  <div style="font-size: 40px; text-align:center;">
486
+ <?php
487
+ echo "<span title='Compared to this day last week'>".$mlw_qmn_analyze_today."%</span>";
488
  if ($mlw_qmn_analyze_today >= 0)
489
  {
490
  echo "<img src='".plugin_dir_url( __FILE__ )."images/green_triangle.png' width='40px' height='40px'/>";
504
  function mlw_qmn_monthly_percent_taken_widget()
505
  {
506
  global $wpdb;
507
+
508
  $mlw_this_month = mktime(0, 0, 0, date("m") , date("d")-29, date("Y"));
509
  $mlw_this_month = date("Y-m-d", $mlw_this_month);
510
  $mlw_qmn_this_month_taken = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_this_month." 00:00:00' AND '".date("Y-m-d")." 23:59:59') AND deleted=0");
511
+
512
  $mlw_last_month_start = mktime(0, 0, 0, date("m") , date("d")-59, date("Y"));
513
  $mlw_last_month_start = date("Y-m-d", $mlw_last_month_start);
514
  $mlw_last_month_end = mktime(0, 0, 0, date("m") , date("d")-30, date("Y"));
515
  $mlw_last_month_end = date("Y-m-d", $mlw_last_month_end);
516
  $mlw_qmn_last_month_taken = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_last_month_start." 00:00:00' AND '".$mlw_last_month_end." 23:59:59') AND deleted=0");
517
+
518
  if ($mlw_qmn_last_month_taken != 0)
519
  {
520
  $mlw_qmn_analyze_month = round((($mlw_qmn_this_month_taken - $mlw_qmn_last_month_taken) / $mlw_qmn_last_month_taken) * 100, 2);
533
  <tr>
534
  <td>
535
  <div style="font-size: 40px; text-align:center;">
536
+ <?php
537
+ echo "<span title='Compared to the previous 30 days'>".$mlw_qmn_analyze_month."%</span>";
538
  if ($mlw_qmn_analyze_month >= 0)
539
  {
540
  echo "<img src='".plugin_dir_url( __FILE__ )."images/green_triangle.png' width='40px' height='40px'/>";
554
  function mlw_qmn_quaterly_percent_taken_widget()
555
  {
556
  global $wpdb;
557
+
558
  $mlw_this_quater = mktime(0, 0, 0, date("m") , date("d")-89, date("Y"));
559
  $mlw_this_quater = date("Y-m-d", $mlw_this_quater);
560
  $mlw_qmn_this_quater_taken = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_this_quater." 00:00:00' AND '".date("Y-m-d")." 23:59:59') AND deleted=0");
561
+
562
  $mlw_last_quater_start = mktime(0, 0, 0, date("m") , date("d")-179, date("Y"));
563
  $mlw_last_quater_start = date("Y-m-d", $mlw_last_quater_start);
564
  $mlw_last_quater_end = mktime(0, 0, 0, date("m") , date("d")-90, date("Y"));
565
  $mlw_last_quater_end = date("Y-m-d", $mlw_last_quater_end);
566
  $mlw_qmn_last_quater_taken = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_last_quater_start." 00:00:00' AND '".$mlw_last_quater_end." 23:59:59') AND deleted=0");
567
+
568
  if ($mlw_qmn_last_quater_taken != 0)
569
  {
570
  $mlw_qmn_analyze_quater = round((($mlw_qmn_this_quater_taken - $mlw_qmn_last_quater_taken) / $mlw_qmn_last_quater_taken) * 100, 2);
583
  <tr>
584
  <td>
585
  <div style="font-size: 40px; text-align:center;">
586
+ <?php
587
+ echo "<span title='Compared to the previous 120 days'>".$mlw_qmn_analyze_quater."%</span>";
588
  if ($mlw_qmn_analyze_quater >= 0)
589
  {
590
  echo "<img src='".plugin_dir_url( __FILE__ )."images/green_triangle.png' width='40px' height='40px'/>";
includes/qmn_dashboard_widgets.php CHANGED
@@ -1,17 +1,20 @@
1
  <?php
2
- function qmn_add_dashboard_widget()
3
  {
4
- wp_add_dashboard_widget(
5
- 'qmn_snapshot_widget',
6
- 'Quiz Master Next Snapshot',
7
- 'qmn_snapshot_dashboard_widget'
8
- );
 
 
 
9
  }
10
 
11
  add_action( 'wp_dashboard_setup', 'qmn_add_dashboard_widget' );
12
 
13
 
14
- function qmn_snapshot_dashboard_widget()
15
  {
16
  global $wpdb;
17
  $mlw_qmn_today_taken = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".date("Y-m-d")." 00:00:00' AND '".date("Y-m-d")." 23:59:59') AND deleted=0");
@@ -26,17 +29,17 @@ function qmn_snapshot_dashboard_widget()
26
  {
27
  $mlw_qmn_analyze_today = $mlw_qmn_today_taken * 100;
28
  }
29
-
30
  $mlw_this_week = mktime(0, 0, 0, date("m") , date("d")-6, date("Y"));
31
  $mlw_this_week = date("Y-m-d", $mlw_this_week);
32
  $mlw_qmn_this_week_taken = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_this_week." 00:00:00' AND '".date("Y-m-d")." 23:59:59') AND deleted=0");
33
-
34
  $mlw_last_week_start = mktime(0, 0, 0, date("m") , date("d")-13, date("Y"));
35
  $mlw_last_week_start = date("Y-m-d", $mlw_last_week_start);
36
  $mlw_last_week_end = mktime(0, 0, 0, date("m") , date("d")-7, date("Y"));
37
  $mlw_last_week_end = date("Y-m-d", $mlw_last_week_end);
38
  $mlw_qmn_last_week_taken = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_last_week_start." 00:00:00' AND '".$mlw_last_week_end." 23:59:59') AND deleted=0");
39
-
40
  if ($mlw_qmn_last_week_taken != 0)
41
  {
42
  $mlw_qmn_analyze_week = round((($mlw_qmn_this_week_taken - $mlw_qmn_last_week_taken) / $mlw_qmn_last_week_taken) * 100, 2);
@@ -45,10 +48,10 @@ function qmn_snapshot_dashboard_widget()
45
  {
46
  $mlw_qmn_analyze_week = $mlw_qmn_this_week_taken * 100;
47
  }
48
-
49
  $mlw_stat_total_active_quiz = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_quizzes WHERE deleted=0 LIMIT 1" );
50
  $mlw_stat_total_questions = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_questions WHERE deleted=0 LIMIT 1" );
51
-
52
  $mlw_stat_most_popular_quiz = $wpdb->get_row( "SELECT quiz_name FROM ".$wpdb->prefix."mlw_quizzes WHERE deleted=0 ORDER BY quiz_taken Desc LIMIT 1" );
53
  $mlw_stat_least_popular_quiz = $wpdb->get_row( "SELECT quiz_name FROM ".$wpdb->prefix."mlw_quizzes WHERE deleted=0 ORDER BY quiz_taken ASC LIMIT 1" );
54
  ?>
@@ -121,9 +124,9 @@ function qmn_snapshot_dashboard_widget()
121
  <li class="qmn_dashboard_element qmn_full_width">
122
  <div class="qmn_dashboard_inside">
123
  <strong><?php echo $mlw_qmn_today_taken; ?></strong>
124
- quizzes taken today
125
  <span class="qmn_dashboard_graph">
126
- <?php
127
  echo $mlw_qmn_analyze_today."% ";
128
  if ($mlw_qmn_analyze_today >= 0)
129
  {
@@ -140,9 +143,9 @@ function qmn_snapshot_dashboard_widget()
140
  <li class="qmn_dashboard_element qmn_full_width">
141
  <div class="qmn_dashboard_inside">
142
  <strong><?php echo $mlw_qmn_this_week_taken; ?></strong>
143
- quizzes taken last 7 days
144
  <span class="qmn_dashboard_graph">
145
- <?php
146
  echo $mlw_qmn_analyze_week."% ";
147
  if ($mlw_qmn_analyze_week >= 0)
148
  {
@@ -159,25 +162,25 @@ function qmn_snapshot_dashboard_widget()
159
  <li class="qmn_dashboard_element qmn_half_width">
160
  <div class="qmn_dashboard_inside">
161
  <strong><?php echo $mlw_stat_total_active_quiz; ?></strong>
162
- total active quizzes
163
  </div>
164
  </li>
165
  <li class="qmn_dashboard_element qmn_half_width">
166
  <div class="qmn_dashboard_inside">
167
  <strong><?php echo $mlw_stat_total_questions; ?></strong>
168
- total active questions
169
  </div>
170
  </li>
171
  <li class="qmn_dashboard_element qmn_half_width">
172
  <div class="qmn_dashboard_inside">
173
  <strong><?php echo $mlw_stat_most_popular_quiz->quiz_name; ?></strong>
174
- most popular quiz
175
  </div>
176
  </li>
177
  <li class="qmn_dashboard_element qmn_half_width">
178
  <div class="qmn_dashboard_inside">
179
  <strong><?php echo $mlw_stat_least_popular_quiz->quiz_name; ?></strong>
180
- least popular quiz
181
  </div>
182
  </li>
183
  </ul>
1
  <?php
2
+ function qmn_add_dashboard_widget()
3
  {
4
+ if ( current_user_can( 'publish_posts' ) )
5
+ {
6
+ wp_add_dashboard_widget(
7
+ 'qmn_snapshot_widget',
8
+ __('Quiz Master Next Snapshot', 'quiz-master-next'),
9
+ 'qmn_snapshot_dashboard_widget'
10
+ );
11
+ }
12
  }
13
 
14
  add_action( 'wp_dashboard_setup', 'qmn_add_dashboard_widget' );
15
 
16
 
17
+ function qmn_snapshot_dashboard_widget()
18
  {
19
  global $wpdb;
20
  $mlw_qmn_today_taken = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".date("Y-m-d")." 00:00:00' AND '".date("Y-m-d")." 23:59:59') AND deleted=0");
29
  {
30
  $mlw_qmn_analyze_today = $mlw_qmn_today_taken * 100;
31
  }
32
+
33
  $mlw_this_week = mktime(0, 0, 0, date("m") , date("d")-6, date("Y"));
34
  $mlw_this_week = date("Y-m-d", $mlw_this_week);
35
  $mlw_qmn_this_week_taken = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_this_week." 00:00:00' AND '".date("Y-m-d")." 23:59:59') AND deleted=0");
36
+
37
  $mlw_last_week_start = mktime(0, 0, 0, date("m") , date("d")-13, date("Y"));
38
  $mlw_last_week_start = date("Y-m-d", $mlw_last_week_start);
39
  $mlw_last_week_end = mktime(0, 0, 0, date("m") , date("d")-7, date("Y"));
40
  $mlw_last_week_end = date("Y-m-d", $mlw_last_week_end);
41
  $mlw_qmn_last_week_taken = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_last_week_start." 00:00:00' AND '".$mlw_last_week_end." 23:59:59') AND deleted=0");
42
+
43
  if ($mlw_qmn_last_week_taken != 0)
44
  {
45
  $mlw_qmn_analyze_week = round((($mlw_qmn_this_week_taken - $mlw_qmn_last_week_taken) / $mlw_qmn_last_week_taken) * 100, 2);
48
  {
49
  $mlw_qmn_analyze_week = $mlw_qmn_this_week_taken * 100;
50
  }
51
+
52
  $mlw_stat_total_active_quiz = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_quizzes WHERE deleted=0 LIMIT 1" );
53
  $mlw_stat_total_questions = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_questions WHERE deleted=0 LIMIT 1" );
54
+
55
  $mlw_stat_most_popular_quiz = $wpdb->get_row( "SELECT quiz_name FROM ".$wpdb->prefix."mlw_quizzes WHERE deleted=0 ORDER BY quiz_taken Desc LIMIT 1" );
56
  $mlw_stat_least_popular_quiz = $wpdb->get_row( "SELECT quiz_name FROM ".$wpdb->prefix."mlw_quizzes WHERE deleted=0 ORDER BY quiz_taken ASC LIMIT 1" );
57
  ?>
124
  <li class="qmn_dashboard_element qmn_full_width">
125
  <div class="qmn_dashboard_inside">
126
  <strong><?php echo $mlw_qmn_today_taken; ?></strong>
127
+ <?php _e('quizzes taken today', 'quiz-master-next'); ?>
128
  <span class="qmn_dashboard_graph">
129
+ <?php
130
  echo $mlw_qmn_analyze_today."% ";
131
  if ($mlw_qmn_analyze_today >= 0)
132
  {
143
  <li class="qmn_dashboard_element qmn_full_width">
144
  <div class="qmn_dashboard_inside">
145
  <strong><?php echo $mlw_qmn_this_week_taken; ?></strong>
146
+ <?php _e('quizzes taken last 7 days', 'quiz-master-next'); ?>
147
  <span class="qmn_dashboard_graph">
148
+ <?php
149
  echo $mlw_qmn_analyze_week."% ";
150
  if ($mlw_qmn_analyze_week >= 0)
151
  {
162
  <li class="qmn_dashboard_element qmn_half_width">
163
  <div class="qmn_dashboard_inside">
164
  <strong><?php echo $mlw_stat_total_active_quiz; ?></strong>
165
+ <?php _e('total active quizzes', 'quiz-master-next'); ?>
166
  </div>
167
  </li>
168
  <li class="qmn_dashboard_element qmn_half_width">
169
  <div class="qmn_dashboard_inside">
170
  <strong><?php echo $mlw_stat_total_questions; ?></strong>
171
+ <?php _e('total active questions', 'quiz-master-next'); ?>
172
  </div>
173
  </li>
174
  <li class="qmn_dashboard_element qmn_half_width">
175
  <div class="qmn_dashboard_inside">
176
  <strong><?php echo $mlw_stat_most_popular_quiz->quiz_name; ?></strong>
177
+ <?php _e('most popular quiz', 'quiz-master-next'); ?>
178
  </div>
179
  </li>
180
  <li class="qmn_dashboard_element qmn_half_width">
181
  <div class="qmn_dashboard_inside">
182
  <strong><?php echo $mlw_stat_least_popular_quiz->quiz_name; ?></strong>
183
+ <?php _e('least popular quiz', 'quiz-master-next'); ?>
184
  </div>
185
  </li>
186
  </ul>
includes/{mlw_help.php → qmn_help.php} RENAMED
@@ -2,44 +2,44 @@
2
  /*
3
  This page shows the user how-to's for using the plugin
4
  */
5
- /*
6
  Copyright 2014, My Local Webstop (email : fpcorso@mylocalwebstop.com)
7
  */
8
 
9
  function mlw_generate_help_page()
10
  {
11
  ///Creates the widgets
12
- add_meta_box("wpss_mrts", 'Plugin Documentation', "qmn_documentation_meta_box_content", "meta_box_help");
13
- add_meta_box("wpss_mrts", 'Support', "qmn_support_meta_box_content", "meta_box_support");
14
- add_meta_box("wpss_mrts", 'System Info', "qmn_system_meta_box_content", "meta_box_sys_info");
15
  ?>
16
  <div class="wrap">
17
- <h2>QMN Help</h2>
18
  <?php echo mlw_qmn_show_adverts(); ?>
19
-
20
  <!--Display Widget Boxes-->
21
  <div style="float:left; width:50%;" class="inner-sidebar1">
22
- <?php do_meta_boxes('meta_box_help','advanced',''); ?>
23
  </div>
24
-
25
  <div style="float:left; width:50%;" class="inner-sidebar1">
26
- <?php do_meta_boxes('meta_box_support','advanced',''); ?>
27
  </div>
28
-
29
  <div style="float:left; width:100%;" class="inner-sidebar1">
30
- <?php do_meta_boxes('meta_box_sys_info','advanced',''); ?>
 
 
31
  </div>
32
-
33
- </div>
34
  <?php
35
  }
36
 
37
  function qmn_documentation_meta_box_content()
38
  {
39
  ?>
40
- <h3>Need help with the plugin? Try any of the following:</h3>
41
  <ul>
42
- <li>Visit our <a href="http://mylocalwebstop.com/plugin-documentation/">Documentation</a> for using this plugin</li>
43
  <li>Fill out the form in the Support widget to send us an email</li>
44
  <li>Fill out the form on our <a href="http://mylocalwebstop.com/contact-us/">Contact Us Page</a></li>
45
  <li>Create a topic in the <a href="https://wordpress.org/support/plugin/quiz-master-next">WordPress Support Forums</a></li>
@@ -107,7 +107,7 @@ function qmn_support_meta_box_content()
107
  <input type='hidden' name='action' value='update' />
108
  <table>
109
  <tr>
110
- <td>If there is something you would like to suggest to add or even if you just want
111
  to let me know if you like the plugin or not, feel free to use the email form below.</td>
112
  </tr>
113
  <tr>
@@ -159,22 +159,22 @@ function qmn_get_system_info()
159
  {
160
  global $wpdb;
161
  $qmn_sys_info = "";
162
-
163
  $theme_data = wp_get_theme();
164
  $theme = $theme_data->Name . ' ' . $theme_data->Version;
165
-
166
  $qmn_sys_info .= "<h3>Site Information</h3><br />";
167
  $qmn_sys_info .= "Site URL: ".site_url()."<br />";
168
  $qmn_sys_info .= "Home URL: ".home_url()."<br />";
169
  $qmn_sys_info .= "Multisite: ".( is_multisite() ? 'Yes' : 'No' )."<br />";
170
-
171
  $qmn_sys_info .= "<h3>WordPress Information</h3><br />";
172
  $qmn_sys_info .= "Version: ".get_bloginfo( 'version' )."<br />";
173
  $qmn_sys_info .= "Language: ".( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' )."<br />";
174
  $qmn_sys_info .= "Active Theme: ".$theme."<br />";
175
  $qmn_sys_info .= "Debug Mode: ".( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' )."<br />";
176
  $qmn_sys_info .= "Memory Limit: ".WP_MEMORY_LIMIT."<br />";
177
-
178
  $qmn_sys_info .= "<h3>Plugins Information</h3><br />";
179
  $qmn_plugin_mu = get_mu_plugins();
180
  if( count( $qmn_plugin_mu > 0 ) ) {
@@ -197,24 +197,24 @@ function qmn_get_system_info()
197
  continue;
198
  $qmn_sys_info .= $plugin['Name'] . ': ' . $plugin['Version'] . "<br />";
199
  }
200
-
201
  $qmn_sys_info .= "<h3>Server Information</h3><br />";
202
  $qmn_sys_info .= "PHP : ".PHP_VERSION."<br />";
203
  $qmn_sys_info .= "MySQL : ".$wpdb->db_version()."<br />";
204
  $qmn_sys_info .= "Webserver : ".$_SERVER['SERVER_SOFTWARE']."<br />";
205
-
206
  $mlw_stat_total_quiz = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_quizzes LIMIT 1" );
207
  $mlw_stat_total_active_quiz = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_quizzes WHERE deleted=0 LIMIT 1" );
208
  $mlw_stat_total_questions = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_questions LIMIT 1" );
209
  $mlw_stat_total_active_questions = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_questions WHERE deleted=0 LIMIT 1" );
210
-
211
  $qmn_sys_info .= "<h3>QMN Information</h3><br />";
212
  $qmn_sys_info .= "Total Quizzes : ".$mlw_stat_total_quiz."<br />";
213
  $qmn_sys_info .= "Total Active Quizzes : ".$mlw_stat_total_active_quiz."<br />";
214
  $qmn_sys_info .= "Total Questions : ".$mlw_stat_total_questions."<br />";
215
  $qmn_sys_info .= "Total Active Questions : ".$mlw_stat_total_active_questions."<br />";
216
-
217
-
218
  return $qmn_sys_info;
219
  }
220
 
2
  /*
3
  This page shows the user how-to's for using the plugin
4
  */
5
+ /*
6
  Copyright 2014, My Local Webstop (email : fpcorso@mylocalwebstop.com)
7
  */
8
 
9
  function mlw_generate_help_page()
10
  {
11
  ///Creates the widgets
12
+ add_meta_box("wpss_mrts", __('Need Help?', 'quiz-master-next'), "qmn_documentation_meta_box_content", "meta_box_help");
13
+ add_meta_box("wpss_mrts", __('Support', 'quiz-master-next'), "qmn_support_meta_box_content", "meta_box_support");
14
+ add_meta_box("wpss_mrts", __('System Info', 'quiz-master-next'), "qmn_system_meta_box_content", "meta_box_sys_info");
15
  ?>
16
  <div class="wrap">
17
+ <h2><?php _e('Help Page', 'quiz-master-next'); ?></h2>
18
  <?php echo mlw_qmn_show_adverts(); ?>
19
+
20
  <!--Display Widget Boxes-->
21
  <div style="float:left; width:50%;" class="inner-sidebar1">
22
+ <?php do_meta_boxes('meta_box_help','advanced',''); ?>
23
  </div>
24
+
25
  <div style="float:left; width:50%;" class="inner-sidebar1">
26
+ <?php do_meta_boxes('meta_box_support','advanced',''); ?>
27
  </div>
28
+
29
  <div style="float:left; width:100%;" class="inner-sidebar1">
30
+ <?php do_meta_boxes('meta_box_sys_info','advanced',''); ?>
31
+ </div>
32
+
33
  </div>
 
 
34
  <?php
35
  }
36
 
37
  function qmn_documentation_meta_box_content()
38
  {
39
  ?>
40
+ <p><?php _e('Need help with the plugin? Try any of the following:', 'quiz-master-next'); ?></p>
41
  <ul>
42
+ <li>Visit our <a href="http://mylocalwebstop.com/plugin-documentation/">documentation</a> for using this plugin</li>
43
  <li>Fill out the form in the Support widget to send us an email</li>
44
  <li>Fill out the form on our <a href="http://mylocalwebstop.com/contact-us/">Contact Us Page</a></li>
45
  <li>Create a topic in the <a href="https://wordpress.org/support/plugin/quiz-master-next">WordPress Support Forums</a></li>
107
  <input type='hidden' name='action' value='update' />
108
  <table>
109
  <tr>
110
+ <td>If there is something you would like to suggest to add or even if you just want
111
  to let me know if you like the plugin or not, feel free to use the email form below.</td>
112
  </tr>
113
  <tr>
159
  {
160
  global $wpdb;
161
  $qmn_sys_info = "";
162
+
163
  $theme_data = wp_get_theme();
164
  $theme = $theme_data->Name . ' ' . $theme_data->Version;
165
+
166
  $qmn_sys_info .= "<h3>Site Information</h3><br />";
167
  $qmn_sys_info .= "Site URL: ".site_url()."<br />";
168
  $qmn_sys_info .= "Home URL: ".home_url()."<br />";
169
  $qmn_sys_info .= "Multisite: ".( is_multisite() ? 'Yes' : 'No' )."<br />";
170
+
171
  $qmn_sys_info .= "<h3>WordPress Information</h3><br />";
172
  $qmn_sys_info .= "Version: ".get_bloginfo( 'version' )."<br />";
173
  $qmn_sys_info .= "Language: ".( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' )."<br />";
174
  $qmn_sys_info .= "Active Theme: ".$theme."<br />";
175
  $qmn_sys_info .= "Debug Mode: ".( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' )."<br />";
176
  $qmn_sys_info .= "Memory Limit: ".WP_MEMORY_LIMIT."<br />";
177
+
178
  $qmn_sys_info .= "<h3>Plugins Information</h3><br />";
179
  $qmn_plugin_mu = get_mu_plugins();
180
  if( count( $qmn_plugin_mu > 0 ) ) {
197
  continue;
198
  $qmn_sys_info .= $plugin['Name'] . ': ' . $plugin['Version'] . "<br />";
199
  }
200
+
201
  $qmn_sys_info .= "<h3>Server Information</h3><br />";
202
  $qmn_sys_info .= "PHP : ".PHP_VERSION."<br />";
203
  $qmn_sys_info .= "MySQL : ".$wpdb->db_version()."<br />";
204
  $qmn_sys_info .= "Webserver : ".$_SERVER['SERVER_SOFTWARE']."<br />";
205
+
206
  $mlw_stat_total_quiz = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_quizzes LIMIT 1" );
207
  $mlw_stat_total_active_quiz = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_quizzes WHERE deleted=0 LIMIT 1" );
208
  $mlw_stat_total_questions = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_questions LIMIT 1" );
209
  $mlw_stat_total_active_questions = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_questions WHERE deleted=0 LIMIT 1" );
210
+
211
  $qmn_sys_info .= "<h3>QMN Information</h3><br />";
212
  $qmn_sys_info .= "Total Quizzes : ".$mlw_stat_total_quiz."<br />";
213
  $qmn_sys_info .= "Total Active Quizzes : ".$mlw_stat_total_active_quiz."<br />";
214
  $qmn_sys_info .= "Total Questions : ".$mlw_stat_total_questions."<br />";
215
  $qmn_sys_info .= "Total Active Questions : ".$mlw_stat_total_active_questions."<br />";
216
+
217
+
218
  return $qmn_sys_info;
219
  }
220
 
includes/qmn_helper.php ADDED
@@ -0,0 +1,336 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This class is a helper class to be used for extending the plugin
4
+ *
5
+ * This class contains many functions for extending the plugin
6
+ *
7
+ *
8
+ * @since 4.0.0
9
+ */
10
+ class QMNPluginHelper
11
+ {
12
+ /**
13
+ * Addon Page tabs array
14
+ *
15
+ * @var array
16
+ * @since 4.0.0
17
+ */
18
+ public $addon_tabs = array();
19
+
20
+ /**
21
+ * Settings Page tabs array
22
+ *
23
+ * @var array
24
+ * @since 4.0.0
25
+ */
26
+ public $settings_tabs = array();
27
+
28
+ /**
29
+ * Question types array
30
+ *
31
+ * @var array
32
+ * @since 4.0.0
33
+ */
34
+ public $question_types = array();
35
+
36
+ /**
37
+ * Main Construct Function
38
+ *
39
+ * Call functions within class
40
+ *
41
+ * @since 4.0.0
42
+ * @return void
43
+ */
44
+ public function __construct()
45
+ {
46
+
47
+ }
48
+
49
+ /**
50
+ * Register Question Types
51
+ *
52
+ * Adds a question type to the question type array using the parameters given
53
+ *
54
+ * @since 4.0.0
55
+ * @param string $name The name of the Question Type which will be shown when selecting type
56
+ * @param string $display_function The name of the function to call when displaying the question
57
+ * @param bool $graded Tells the plugin if this question is graded or not. This will affect scoring.
58
+ * @param string $review_function The name of the function to call when scoring the question
59
+ * @param string $slug The slug of the question type to be stored with question in database
60
+ * @return void
61
+ */
62
+ public function register_question_type($name, $display_function, $graded, $review_function = null, $slug = null)
63
+ {
64
+ if (is_null($slug))
65
+ {
66
+ $slug = strtolower(str_replace( " ", "-", $name));
67
+ }
68
+ else
69
+ {
70
+ $slug = strtolower(str_replace( " ", "-", $slug));
71
+ }
72
+ $new_type = array(
73
+ 'name' => $name,
74
+ 'display' => $display_function,
75
+ 'review' => $review_function,
76
+ 'graded' => $graded,
77
+ 'slug' => $slug
78
+ );
79
+ $this->question_types[] = $new_type;
80
+ }
81
+
82
+ /**
83
+ * Retrieves List Of Question Types
84
+ *
85
+ * retrieves a list of the slugs and names of the question types
86
+ *
87
+ * @since 4.0.0
88
+ * @return array An array which contains the slug and name of question types that have been registered
89
+ */
90
+ public function get_question_type_options()
91
+ {
92
+ $type_array = array();
93
+ foreach($this->question_types as $type)
94
+ {
95
+ $type_array[] = array(
96
+ 'slug' => $type["slug"],
97
+ 'name' => $type["name"]
98
+ );
99
+ }
100
+ return $type_array;
101
+ }
102
+
103
+ /**
104
+ * Displays A Question
105
+ *
106
+ * Retrieves the question types display function and creates the HTML for the question
107
+ *
108
+ * @since 4.0.0
109
+ * @param string $slug The slug of the question type that the question is
110
+ * @param int $question_id The id of the question
111
+ * @param array $quiz_options An array of the columns of the quiz row from the database
112
+ * @return string The HTML for the question
113
+ */
114
+ public function display_question($slug, $question_id, $quiz_options)
115
+ {
116
+ $display = '';
117
+ global $wpdb;
118
+ global $qmn_total_questions;
119
+ $question = $wpdb->get_row($wpdb->prepare("SELECT * FROM ".$wpdb->prefix."mlw_questions WHERE question_id=%d", intval($question_id)));
120
+ $answers = array();
121
+ if (is_serialized($question->answer_array) && is_array(@unserialize($question->answer_array)))
122
+ {
123
+ $answers = @unserialize($question->answer_array);
124
+ }
125
+ else
126
+ {
127
+ $mlw_answer_array_correct = array(0, 0, 0, 0, 0, 0);
128
+ $mlw_answer_array_correct[$question->correct_answer-1] = 1;
129
+ $answers = array(
130
+ array($question->answer_one, $question->answer_one_points, $mlw_answer_array_correct[0]),
131
+ array($question->answer_two, $question->answer_two_points, $mlw_answer_array_correct[1]),
132
+ array($question->answer_three, $question->answer_three_points, $mlw_answer_array_correct[2]),
133
+ array($question->answer_four, $question->answer_four_points, $mlw_answer_array_correct[3]),
134
+ array($question->answer_five, $question->answer_five_points, $mlw_answer_array_correct[4]),
135
+ array($question->answer_six, $question->answer_six_points, $mlw_answer_array_correct[5]));
136
+ }
137
+ if ($quiz_options->randomness_order == 2)
138
+ {
139
+ shuffle($answers);
140
+ }
141
+ foreach($this->question_types as $type)
142
+ {
143
+ if ($type["slug"] == strtolower(str_replace( " ", "-", $slug)))
144
+ {
145
+ if ($type["graded"])
146
+ {
147
+ $qmn_total_questions += 1;
148
+ if ($quiz_options->question_numbering == 1)
149
+ {
150
+ $display .= "<span class='mlw_qmn_question'>$qmn_total_questions)</span>";
151
+ }
152
+ }
153
+ $display .= call_user_func($type['display'], intval($question_id), $question->question_name, $answers);
154
+ }
155
+ }
156
+ return $display;
157
+ }
158
+
159
+ /**
160
+ * Calculates Score For Question
161
+ *
162
+ * Calculates the score for the question based on the question type
163
+ *
164
+ * @since 4.0.0
165
+ * @param string $slug The slug of the question type that the question is
166
+ * @param int $question_id The id of the question
167
+ * @return array An array of the user's score from the question
168
+ */
169
+ public function display_review($slug, $question_id)
170
+ {
171
+ $results_array = array();
172
+ global $wpdb;
173
+ $question = $wpdb->get_row($wpdb->prepare("SELECT * FROM ".$wpdb->prefix."mlw_questions WHERE question_id=%d", intval($question_id)));
174
+ $answers = array();
175
+ if (is_serialized($question->answer_array) && is_array(@unserialize($question->answer_array)))
176
+ {
177
+ $answers = @unserialize($question->answer_array);
178
+ }
179
+ else
180
+ {
181
+ $mlw_answer_array_correct = array(0, 0, 0, 0, 0, 0);
182
+ $mlw_answer_array_correct[$question->correct_answer-1] = 1;
183
+ $answers = array(
184
+ array($question->answer_one, $question->answer_one_points, $mlw_answer_array_correct[0]),
185
+ array($question->answer_two, $question->answer_two_points, $mlw_answer_array_correct[1]),
186
+ array($question->answer_three, $question->answer_three_points, $mlw_answer_array_correct[2]),
187
+ array($question->answer_four, $question->answer_four_points, $mlw_answer_array_correct[3]),
188
+ array($question->answer_five, $question->answer_five_points, $mlw_answer_array_correct[4]),
189
+ array($question->answer_six, $question->answer_six_points, $mlw_answer_array_correct[5]));
190
+ }
191
+ foreach($this->question_types as $type)
192
+ {
193
+ if ($type["slug"] == strtolower(str_replace( " ", "-", $slug)))
194
+ {
195
+ if (!is_null($type["review"]))
196
+ {
197
+ $results_array = call_user_func($type['review'], intval($question_id), $question->question_name, $answers);
198
+ }
199
+ else
200
+ {
201
+ $results_array = array('null_review' => true);
202
+ }
203
+ }
204
+ }
205
+ return $results_array;
206
+ }
207
+
208
+ /**
209
+ * Retrieves A Question Setting
210
+ *
211
+ * Retrieves a setting stored in the question settings array
212
+ *
213
+ * @since 4.0.0
214
+ * @param int $question_id The id of the question
215
+ * @param string $setting The name of the setting
216
+ * @return string The value stored for the setting
217
+ */
218
+ public function get_question_setting($question_id, $setting)
219
+ {
220
+ global $wpdb;
221
+ $qmn_settings_array = '';
222
+ $settings = $wpdb->get_var( $wpdb->prepare( "SELECT question_settings FROM " . $wpdb->prefix . "mlw_questions WHERE question_id=%d", $question_id ) );
223
+ if (is_serialized($settings) && is_array(@unserialize($settings)))
224
+ {
225
+ $qmn_settings_array = @unserialize($settings);
226
+ }
227
+ if (is_array($qmn_settings_array) && isset($qmn_settings_array[$setting]))
228
+ {
229
+ return $qmn_settings_array[$setting];
230
+ }
231
+ else
232
+ {
233
+ return '';
234
+ }
235
+ }
236
+
237
+ /**
238
+ * Retrieves A Quiz Setting
239
+ *
240
+ * Retrieves a setting stored in the quiz settings array
241
+ *
242
+ * @since 4.0.0
243
+ * @param string $setting The name of the setting
244
+ * @return string The value stored for the setting
245
+ */
246
+ public function get_quiz_setting($setting)
247
+ {
248
+ global $mlwQuizMasterNext;
249
+ return $mlwQuizMasterNext->quizCreator->get_setting($setting);
250
+ }
251
+
252
+ /**
253
+ * Updates A Quiz Setting
254
+ *
255
+ * Sets the value of a setting stored in the quiz settings array
256
+ *
257
+ * @since 4.0.0
258
+ * @param string $setting The name of the setting
259
+ * @param any $value The value to be store in the setting
260
+ * @return bool True if update was successful
261
+ */
262
+ public function update_quiz_setting($setting, $value)
263
+ {
264
+ global $mlwQuizMasterNext;
265
+ return $mlwQuizMasterNext->quizCreator->update_setting($setting, $value);
266
+ }
267
+
268
+ /**
269
+ * Registers Addon Settings Tab
270
+ *
271
+ * Registers a new tab on the addon settings page
272
+ *
273
+ * @since 4.0.0
274
+ * @param string $title The name of the tab
275
+ * @param string $function The function that displays the tab's content
276
+ * @return void
277
+ */
278
+ public function register_addon_settings_tab($title, $function)
279
+ {
280
+ $slug = strtolower(str_replace( " ", "-", $title));
281
+ $new_tab = array(
282
+ 'title' => $title,
283
+ 'function' => $function,
284
+ 'slug' => $slug
285
+ );
286
+ $this->addon_tabs[] = $new_tab;
287
+ }
288
+
289
+ /**
290
+ * Retrieves Addon Settings Tab Array
291
+ *
292
+ * Retrieves the array of titles and functions of the registered tabs
293
+ *
294
+ * @since 4.0.0
295
+ * @return array The array of registered tabs
296
+ */
297
+ public function get_addon_tabs()
298
+ {
299
+ return $this->addon_tabs;
300
+ }
301
+
302
+ /**
303
+ * Registers Quiz Settings Tab
304
+ *
305
+ * Registers a new tab on the quiz settings page
306
+ *
307
+ * @since 4.0.0
308
+ * @param string $title The name of the tab
309
+ * @param string $function The function that displays the tab's content
310
+ * @return void
311
+ */
312
+ public function register_quiz_settings_tabs($title, $function)
313
+ {
314
+ $slug = strtolower(str_replace( " ", "-", $title));
315
+ $new_tab = array(
316
+ 'title' => $title,
317
+ 'function' => $function,
318
+ 'slug' => $slug
319
+ );
320
+ $this->settings_tabs[] = $new_tab;
321
+ }
322
+
323
+ /**
324
+ * Echos Registered Tabs Title Link
325
+ *
326
+ * Echos the title link of the registered tabs
327
+ *
328
+ * @since 4.0.0
329
+ * @return array The array of registered tabs
330
+ */
331
+ public function get_settings_tabs()
332
+ {
333
+ return $this->settings_tabs;
334
+ }
335
+ }
336
+ ?>
includes/{mlw_leaderboard.php → qmn_leaderboard.php} RENAMED
@@ -72,4 +72,4 @@ function mlw_quiz_leaderboard_shortcode($atts)
72
 
73
  return $mlw_quiz_leaderboard_display;
74
  }
75
- ?>
72
 
73
  return $mlw_quiz_leaderboard_display;
74
  }
75
+ ?>
includes/qmn_options_certificate_tab.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function qmn_settings_certificate_tab()
3
+ {
4
+ global $mlwQuizMasterNext;
5
+ $mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs(__("Certificate (Beta)", 'quiz-master-next'), 'mlw_options_certificate_tab_content');
6
+ }
7
+ add_action("plugins_loaded", 'qmn_settings_certificate_tab', 5);
8
+
9
+ function mlw_options_certificate_tab_content()
10
+ {
11
+ global $wpdb;
12
+ global $mlwQuizMasterNext;
13
+ $quiz_id = $_GET["quiz_id"];
14
+ //Saved Certificate Options
15
+ if (isset($_POST["save_certificate_options"]) && $_POST["save_certificate_options"] == "confirmation")
16
+ {
17
+ $mlw_certificate_id = intval($_POST["certificate_quiz_id"]);
18
+ $mlw_certificate_title = $_POST["certificate_title"];
19
+ $mlw_certificate_text = $_POST["certificate_template"];
20
+ $mlw_certificate_logo = $_POST["certificate_logo"];
21
+ $mlw_certificate_background = $_POST["certificate_background"];
22
+ $mlw_enable_certificates = intval($_POST["enableCertificates"]);
23
+ $mlw_certificate = array($mlw_certificate_title, $mlw_certificate_text, $mlw_certificate_logo, $mlw_certificate_background, $mlw_enable_certificates);
24
+ $mlw_certificate_serialized = serialize($mlw_certificate);
25
+
26
+ $mlw_certificate_sql_results = $wpdb->query( $wpdb->prepare( "UPDATE " . $wpdb->prefix . "mlw_quizzes SET certificate_template=%s, last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_certificate_serialized, $mlw_certificate_id ) );
27
+
28
+
29
+ if ($mlw_certificate_sql_results != false)
30
+ {
31
+ $mlwQuizMasterNext->alertManager->newAlert(__('The certificate has been updated successfully.', 'quiz-master-next'), 'success');
32
+
33
+ //Insert Action Into Audit Trail
34
+ global $current_user;
35
+ get_currentuserinfo();
36
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
37
+ $insert = "INSERT INTO " . $table_name .
38
+ "(trail_id, action_user, action, time) " .
39
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Certificate Options Have Been Edited For Quiz Number ".$mlw_certificate_id."' , '" . date("h:i:s A m/d/Y") . "')";
40
+ $results = $wpdb->query( $insert );
41
+ }
42
+ else
43
+ {
44
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0012'), 'error');
45
+ }
46
+ }
47
+ if (isset($_GET["quiz_id"]))
48
+ {
49
+ $table_name = $wpdb->prefix . "mlw_quizzes";
50
+ $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
51
+ }
52
+
53
+ //Load Certificate Options Variables
54
+ if (is_serialized($mlw_quiz_options->certificate_template) && is_array(@unserialize($mlw_quiz_options->certificate_template)))
55
+ {
56
+ $mlw_certificate_options = @unserialize($mlw_quiz_options->certificate_template);
57
+ }
58
+ else
59
+ {
60
+ $mlw_certificate_options = array(__('Enter title here', 'quiz-master-next'), __('Enter text here', 'quiz-master-next'), '', '', 1);
61
+ }
62
+ ?>
63
+ <div id="tabs-5" class="mlw_tab_content">
64
+ <script>
65
+ jQuery(function() {
66
+ jQuery( "#enableCertificates" ).buttonset();
67
+ });
68
+ </script>
69
+ <h3><?php _e('Quiz Certificate (Beta)', 'quiz-master-next'); ?></h3>
70
+ <p><?php _e('Enter in your text here to fill in the certificate for this quiz. Be sure to enter in the link variable into the templates on the Quiz Text tab so the user can access the certificate.', 'quiz-master-next'); ?></p>
71
+ <p><?php _e('These fields cannot contain HTML.', 'quiz-master-next'); ?></p>
72
+ <button id="save_certificate_button" class="button" onclick="javascript: document.quiz_certificate_options_form.submit();"><?php _e('Save Certificate Options', 'quiz-master-next'); ?></button>
73
+ <?php
74
+ echo "<form action='' method='post' name='quiz_certificate_options_form'>";
75
+ echo "<input type='hidden' name='save_certificate_options' value='confirmation' />";
76
+ echo "<input type='hidden' name='certificate_quiz_id' value='".$quiz_id."' />";
77
+ ?>
78
+ <table class="form-table">
79
+ <tr valign="top">
80
+ <td><label for="enableCertificates"><?php _e('Enable Certificates For This Quiz?', 'quiz-master-next'); ?></label></td>
81
+ <td><div id="enableCertificates">
82
+ <input type="radio" id="radio30" name="enableCertificates" <?php if ($mlw_certificate_options[4] == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio30"><?php _e('Yes', 'quiz-master-next'); ?></label>
83
+ <input type="radio" id="radio31" name="enableCertificates" <?php if ($mlw_certificate_options[4] == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio31"><?php _e('No', 'quiz-master-next'); ?></label>
84
+ </div></td>
85
+ </tr>
86
+ <tr>
87
+ <td width="30%">
88
+ <strong><?php _e('Certificate Title', 'quiz-master-next'); ?></strong>
89
+ </td>
90
+ <td><textarea cols="80" rows="15" id="certificate_title" name="certificate_title"><?php echo $mlw_certificate_options[0]; ?></textarea>
91
+ </td>
92
+ </tr>
93
+ <tr>
94
+ <td width="30%">
95
+ <strong><?php _e('Message Displayed On Certificate', 'quiz-master-next'); ?></strong>
96
+ <br />
97
+ <p><?php _e('Allowed Variables:', 'quiz-master-next'); ?></p>
98
+ <p style="margin: 2px 0">- %POINT_SCORE%</p>
99
+ <p style="margin: 2px 0">- %AVERAGE_POINT%</p>
100
+ <p style="margin: 2px 0">- %AMOUNT_CORRECT%</p>
101
+ <p style="margin: 2px 0">- %TOTAL_QUESTIONS%</p>
102
+ <p style="margin: 2px 0">- %CORRECT_SCORE%</p>
103
+ <p style="margin: 2px 0">- %QUIZ_NAME%</p>
104
+ <p style="margin: 2px 0">- %USER_NAME%</p>
105
+ <p style="margin: 2px 0">- %USER_BUSINESS%</p>
106
+ <p style="margin: 2px 0">- %USER_PHONE%</p>
107
+ <p style="margin: 2px 0">- %USER_EMAIL%</p>
108
+ <p style="margin: 2px 0">- %CURRENT_DATE%</p>
109
+ </td>
110
+ <td><label for="certificate_template">Allowed tags: &lt;b&gt; - bold, &lt;i&gt;-italics, &lt;u&gt;-underline, &lt;br&gt;-New Line or start a new line by pressing enter</label><textarea cols="80" rows="15" id="certificate_template" name="certificate_template"><?php echo $mlw_certificate_options[1]; ?></textarea>
111
+ </td>
112
+ </tr>
113
+ <tr>
114
+ <td width="30%">
115
+ <strong><?php _e('URL To Logo (Must be JPG, JPEG, PNG or GIF)', 'quiz-master-next'); ?></strong>
116
+ </td>
117
+ <td><textarea cols="80" rows="15" id="certificate_logo" name="certificate_logo"><?php echo $mlw_certificate_options[2]; ?></textarea>
118
+ </td>
119
+ </tr>
120
+ <tr>
121
+ <td width="30%">
122
+ <strong><?php _e('URL To Background Img (Must be JPG, JPEG, PNG or GIF)', 'quiz-master-next'); ?></strong>
123
+ </td>
124
+ <td><textarea cols="80" rows="15" id="certificate_background" name="certificate_background"><?php echo $mlw_certificate_options[3]; ?></textarea>
125
+ </td>
126
+ </tr>
127
+ </table>
128
+ <button id="save_certificate_button" class="button" onclick="javascript: document.quiz_certificate_options_form.submit();"><?php _e('Save Certificate Options', 'quiz-master-next'); ?></button>
129
+ </form>
130
+ </div>
131
+ <?php
132
+ }
133
+ ?>
includes/qmn_options_email_tab.php ADDED
@@ -0,0 +1,489 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function qmn_settings_email_tab()
3
+ {
4
+ global $mlwQuizMasterNext;
5
+ $mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs(__("Emails", 'quiz-master-next'), 'mlw_options_emails_tab_content');
6
+ }
7
+ add_action("plugins_loaded", 'qmn_settings_email_tab', 5);
8
+
9
+ function mlw_options_emails_tab_content()
10
+ {
11
+ global $wpdb;
12
+ global $mlwQuizMasterNext;
13
+ $quiz_id = $_GET["quiz_id"];
14
+ //Check to add new user email template
15
+ if (isset($_POST["mlw_add_email_page"]) && $_POST["mlw_add_email_page"] == "confirmation")
16
+ {
17
+ //Function variables
18
+ $mlw_qmn_add_email_id = intval($_POST["mlw_add_email_quiz_id"]);
19
+ $mlw_qmn_user_email = $wpdb->get_var( $wpdb->prepare( "SELECT user_email_template FROM ".$wpdb->prefix."mlw_quizzes WHERE quiz_id=%d", $mlw_qmn_add_email_id ) );
20
+
21
+ //Load user email and check if it is array already. If not, turn it into one
22
+ if (is_serialized($mlw_qmn_user_email) && is_array(@unserialize($mlw_qmn_user_email)))
23
+ {
24
+ $mlw_qmn_email_array = @unserialize($mlw_qmn_user_email);
25
+ $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here', 'Quiz Results For %QUIZ_NAME%');
26
+ array_unshift($mlw_qmn_email_array , $mlw_new_landing_array);
27
+ $mlw_qmn_email_array = serialize($mlw_qmn_email_array);
28
+
29
+ }
30
+ else
31
+ {
32
+ $mlw_qmn_email_array = array(array(0, 0, $mlw_qmn_user_email, 'Quiz Results For %QUIZ_NAME%'));
33
+ $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here', 'Quiz Results For %QUIZ_NAME%');
34
+ array_unshift($mlw_qmn_email_array , $mlw_new_landing_array);
35
+ $mlw_qmn_email_array = serialize($mlw_qmn_email_array);
36
+ }
37
+ //Update email template with new array then check to see if worked
38
+ $mlw_new_email_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET user_email_template='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_email_array, $mlw_qmn_add_email_id ) );
39
+ if ($mlw_new_email_results != false)
40
+ {
41
+ $mlwQuizMasterNext->alertManager->newAlert(__('The email has been added successfully.', 'quiz-master-next'), 'success');
42
+
43
+ //Insert Action Into Audit Trail
44
+ global $current_user;
45
+ get_currentuserinfo();
46
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
47
+ $insert = "INSERT INTO " . $table_name .
48
+ "(trail_id, action_user, action, time) " .
49
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'New User Email Has Been Created For Quiz Number ".$mlw_qmn_add_email_id."' , '" . date("h:i:s A m/d/Y") . "')";
50
+ $results = $wpdb->query( $insert );
51
+ }
52
+ else
53
+ {
54
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0016'), 'error');
55
+ }
56
+ }
57
+
58
+ //Check to add new admin email template
59
+ if (isset($_POST["mlw_add_admin_email_page"]) && $_POST["mlw_add_admin_email_page"] == "confirmation")
60
+ {
61
+ //Function variables
62
+ $mlw_qmn_add_email_id = intval($_POST["mlw_add_admin_email_quiz_id"]);
63
+ $mlw_qmn_admin_email = $wpdb->get_var( $wpdb->prepare( "SELECT admin_email_template FROM ".$wpdb->prefix."mlw_quizzes WHERE quiz_id=%d", $mlw_qmn_add_email_id ) );
64
+
65
+ //Load user email and check if it is array already. If not, turn it into one
66
+ if (is_serialized($mlw_qmn_admin_email) && is_array(@unserialize($mlw_qmn_admin_email)))
67
+ {
68
+ $mlw_qmn_email_array = @unserialize($mlw_qmn_admin_email);
69
+ $mlw_new_landing_array = array(
70
+ "begin_score" => 0,
71
+ "end_score" => 100,
72
+ "message" => __('Enter text here', 'quiz-master-next'),
73
+ "subject" => 'Quiz Results For %QUIZ_NAME%'
74
+ );
75
+ array_unshift($mlw_qmn_email_array , $mlw_new_landing_array);
76
+ $mlw_qmn_email_array = serialize($mlw_qmn_email_array);
77
+
78
+ }
79
+ else
80
+ {
81
+ $mlw_qmn_email_array = array(array(
82
+ "begin_score" => 0,
83
+ "end_score" => 0,
84
+ "message" => $mlw_qmn_admin_email,
85
+ "subject" => 'Quiz Results For %QUIZ_NAME%'
86
+ ));
87
+ $mlw_new_landing_array = array(
88
+ "begin_score" => 0,
89
+ "end_score" => 100,
90
+ "message" => __('Enter text here', 'quiz-master-next'),
91
+ "subject" => 'Quiz Results For %QUIZ_NAME%'
92
+ );
93
+ array_unshift($mlw_qmn_email_array , $mlw_new_landing_array);
94
+ $mlw_qmn_email_array = serialize($mlw_qmn_email_array);
95
+ }
96
+ //Update email template with new array then check to see if worked
97
+ $mlw_new_email_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET admin_email_template='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_email_array, $mlw_qmn_add_email_id ) );
98
+ if ($mlw_new_email_results != false)
99
+ {
100
+ $mlwQuizMasterNext->alertManager->newAlert(__('The email has been added successfully.', 'quiz-master-next'), 'success');
101
+
102
+ //Insert Action Into Audit Trail
103
+ global $current_user;
104
+ get_currentuserinfo();
105
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
106
+ $insert = "INSERT INTO " . $table_name .
107
+ "(trail_id, action_user, action, time) " .
108
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'New Admin Email Has Been Created For Quiz Number ".$mlw_qmn_add_email_id."' , '" . date("h:i:s A m/d/Y") . "')";
109
+ $results = $wpdb->query( $insert );
110
+ }
111
+ else
112
+ {
113
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0016'), 'error');
114
+ }
115
+ }
116
+
117
+ //Check to save email templates
118
+ if (isset($_POST["mlw_save_email_template"]) && $_POST["mlw_save_email_template"] == "confirmation")
119
+ {
120
+ //Function Variables
121
+ $mlw_qmn_email_id = intval($_POST["mlw_email_quiz_id"]);
122
+ $mlw_qmn_email_template_total = intval($_POST["mlw_email_template_total"]);
123
+ $mlw_qmn_email_admin_total = intval($_POST["mlw_email_admin_total"]);
124
+ $mlw_send_user_email = $_POST["sendUserEmail"];
125
+ $mlw_send_admin_email = $_POST["sendAdminEmail"];
126
+ $mlw_admin_email = $_POST["adminEmail"];
127
+
128
+ //Create new array
129
+ $i = 1;
130
+ $mlw_qmn_new_email_array = array();
131
+ while ($i <= $mlw_qmn_email_template_total)
132
+ {
133
+ if ($_POST["user_email_".$i] != "Delete")
134
+ {
135
+ $mlw_qmn_email_each = array(intval($_POST["user_email_begin_".$i]), intval($_POST["user_email_end_".$i]), htmlspecialchars(stripslashes($_POST["user_email_".$i]), ENT_QUOTES), htmlspecialchars(stripslashes($_POST["user_email_subject_".$i]), ENT_QUOTES));
136
+ $mlw_qmn_new_email_array[] = $mlw_qmn_email_each;
137
+ }
138
+ $i++;
139
+ }
140
+
141
+ //Create new array
142
+ $i = 1;
143
+ $mlw_qmn_new_admin_array = array();
144
+ while ($i <= $mlw_qmn_email_admin_total)
145
+ {
146
+ if ($_POST["admin_email_".$i] != "Delete")
147
+ {
148
+ $mlw_qmn_email_each = array(
149
+ "begin_score" => intval($_POST["admin_email_begin_".$i]),
150
+ "end_score" => intval($_POST["admin_email_end_".$i]),
151
+ "message" => htmlspecialchars(stripslashes($_POST["admin_email_".$i]), ENT_QUOTES),
152
+ "subject" => htmlspecialchars(stripslashes($_POST["admin_email_subject_".$i]), ENT_QUOTES)
153
+ );
154
+ $mlw_qmn_new_admin_array[] = $mlw_qmn_email_each;
155
+ }
156
+ $i++;
157
+ }
158
+ $mlw_qmn_new_email_array = serialize($mlw_qmn_new_email_array);
159
+ $mlw_qmn_new_admin_array = serialize($mlw_qmn_new_admin_array);
160
+ $mlw_new_email_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET send_user_email='%s', send_admin_email='%s', admin_email='%s', user_email_template='%s', admin_email_template='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_send_user_email, $mlw_send_admin_email, $mlw_admin_email, $mlw_qmn_new_email_array, $mlw_qmn_new_admin_array, $mlw_qmn_email_id ) );
161
+ if ($mlw_new_email_results != false)
162
+ {
163
+ $mlwQuizMasterNext->alertManager->newAlert(__('The email has been updated successfully.', 'quiz-master-next'), 'success');
164
+
165
+ //Insert Action Into Audit Trail
166
+ global $current_user;
167
+ get_currentuserinfo();
168
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
169
+ $insert = "INSERT INTO " . $table_name .
170
+ "(trail_id, action_user, action, time) " .
171
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Email Templates Have Been Saved For Quiz Number ".$mlw_qmn_email_id."' , '" . date("h:i:s A m/d/Y") . "')";
172
+ $results = $wpdb->query( $insert );
173
+ }
174
+ else
175
+ {
176
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0017'), 'error');
177
+ }
178
+ }
179
+
180
+ if (isset($_GET["quiz_id"]))
181
+ {
182
+ $table_name = $wpdb->prefix . "mlw_quizzes";
183
+ $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
184
+ }
185
+
186
+ //Load User Email Templates
187
+ if (is_serialized($mlw_quiz_options->user_email_template) && is_array(@unserialize($mlw_quiz_options->user_email_template)))
188
+ {
189
+ $mlw_qmn_user_email_array = @unserialize($mlw_quiz_options->user_email_template);
190
+ }
191
+ else
192
+ {
193
+ $mlw_qmn_user_email_array = array(array(0, 0, $mlw_quiz_options->user_email_template, 'Quiz Results For %QUIZ_NAME%'));
194
+ }
195
+
196
+ //Load Admin Email Templates
197
+ if (is_serialized($mlw_quiz_options->admin_email_template) && is_array(@unserialize($mlw_quiz_options->admin_email_template)))
198
+ {
199
+ $mlw_qmn_admin_email_array = @unserialize($mlw_quiz_options->admin_email_template);
200
+ }
201
+ else
202
+ {
203
+ $mlw_qmn_admin_email_array = array(array(
204
+ "begin_score" => 0,
205
+ "end_score" => 0,
206
+ "message" => $mlw_quiz_options->admin_email_template,
207
+ "subject" => 'Quiz Results For %QUIZ_NAME%'
208
+ ));
209
+ }
210
+ ?>
211
+ <script type="text/javascript">
212
+ var $j = jQuery.noConflict();
213
+ // increase the default animation speed to exaggerate the effect
214
+ $j.fx.speeds._default = 1000;
215
+ </script>
216
+ <div id="tabs-9" class="mlw_tab_content">
217
+ <script>
218
+ function delete_email(id)
219
+ {
220
+ document.getElementById('user_email_'+id).value = "Delete";
221
+ document.mlw_quiz_save_email_form.submit();
222
+ }
223
+ function delete_admin_email(id)
224
+ {
225
+ document.getElementById('admin_email_'+id).value = "Delete";
226
+ document.mlw_quiz_save_email_form.submit();
227
+ }
228
+ </script>
229
+ <h3><?php _e('Template Variables', 'quiz-master-next'); ?></h3>
230
+ <table class="form-table">
231
+ <tr>
232
+ <td><strong>%POINT_SCORE%</strong> - <?php _e('Score for the quiz when using points', 'quiz-master-next'); ?></td>
233
+ <td><strong>%AVERAGE_POINT%</strong> - <?php _e('The average amount of points user had per question', 'quiz-master-next'); ?></td>
234
+ </tr>
235
+
236
+ <tr>
237
+ <td><strong>%AMOUNT_CORRECT%</strong> - <?php _e('The number of correct answers the user had', 'quiz-master-next'); ?></td>
238
+ <td><strong>%TOTAL_QUESTIONS%</strong> - <?php _e('The total number of questions in the quiz', 'quiz-master-next'); ?></td>
239
+ </tr>
240
+
241
+ <tr>
242
+ <td><strong>%CORRECT_SCORE%</strong> - <?php _e('Score for the quiz when using correct answers', 'quiz-master-next'); ?></td>
243
+ </tr>
244
+
245
+ <tr>
246
+ <td><strong>%USER_NAME%</strong> - <?php _e('The name the user entered before the quiz', 'quiz-master-next'); ?></td>
247
+ <td><strong>%USER_BUSINESS%</strong> - <?php _e('The business the user entered before the quiz', 'quiz-master-next'); ?></td>
248
+ </tr>
249
+
250
+ <tr>
251
+ <td><strong>%USER_PHONE%</strong> - <?php _e('The phone number the user entered before the quiz', 'quiz-master-next'); ?></td>
252
+ <td><strong>%USER_EMAIL%</strong> - <?php _e('The email the user entered before the quiz', 'quiz-master-next'); ?></td>
253
+ </tr>
254
+
255
+ <tr>
256
+ <td><strong>%QUIZ_NAME%</strong> - <?php _e('The name of the quiz', 'quiz-master-next'); ?></td>
257
+ <td><strong>%QUESTIONS_ANSWERS%</strong> - <?php _e('Shows the question, the answer the user provided, and the correct answer', 'quiz-master-next'); ?></td>
258
+ </tr>
259
+
260
+ <tr>
261
+ <td><strong>%COMMENT_SECTION%</strong> - <?php _e('The comments the user entered into comment box if enabled', 'quiz-master-next'); ?></td>
262
+ <td><strong>%TIMER%</strong> - <?php _e('The amount of time user spent of quiz', 'quiz-master-next'); ?></td>
263
+ </tr>
264
+ <tr>
265
+ <td><strong>%CERTIFICATE_LINK%</strong> - <?php _e('The link to the certificate after completing the quiz', 'quiz-master-next'); ?></td>
266
+ </tr>
267
+ <tr>
268
+ <td><strong>%CATEGORY_POINTS%%/CATEGORY_POINTS%</strong> - <?php _e('The amount of points a specific category earned.', 'quiz-master-next'); ?></td>
269
+ <td><strong>%CATEGORY_SCORE%%/CATEGORY_SCORE%</strong> - <?php _e('The score a specific category earned.', 'quiz-master-next'); ?></td>
270
+ </tr>
271
+ <tr>
272
+ <td><strong>Example: %CATEGORY_POINTS%Tech%/CATEGORY_POINTS%</strong></td>
273
+ <td><strong>Example: %CATEGORY_SCORE%Tech%/CATEGORY_SCORE%</strong></td>
274
+ </tr>
275
+ <tr>
276
+ <td><strong>%CATEGORY_AVERAGE_POINTS%</strong> - <?php _e('The average points from all categories.', 'quiz-master-next'); ?></td>
277
+ <td><strong>%CATEGORY_AVERAGE_SCORE%</strong> - <?php _e('The average score from all categories.', 'quiz-master-next'); ?></td>
278
+ </tr>
279
+ </table>
280
+ <br />
281
+ <br />
282
+ <form method="post" action="" name="mlw_quiz_add_email_form">
283
+ <input type='hidden' name='mlw_add_email_page' value='confirmation' />
284
+ <input type='hidden' name='mlw_add_email_quiz_id' value='<?php echo $quiz_id; ?>' />
285
+ </form>
286
+ <form method="post" action="" name="mlw_quiz_add_admin_email_form">
287
+ <input type='hidden' name='mlw_add_admin_email_page' value='confirmation' />
288
+ <input type='hidden' name='mlw_add_admin_email_quiz_id' value='<?php echo $quiz_id; ?>' />
289
+ </form>
290
+ <button id="save_email_button" class="button" onclick="javascript: document.mlw_quiz_save_email_form.submit();"><?php _e('Save Email Templates And Settings', 'quiz-master-next'); ?></button>
291
+ <form method="post" action="" name="mlw_quiz_save_email_form">
292
+ <table class="form-table">
293
+ <tr valign="top">
294
+ <th scope="row"><label for="sendUserEmail"><?php _e('Send user email upon completion?', 'quiz-master-next'); ?></label></th>
295
+ <td><div id="sendUserEmail">
296
+ <input type="radio" id="radio5" name="sendUserEmail" <?php if ($mlw_quiz_options->send_user_email == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio5"><?php _e('Yes', 'quiz-master-next'); ?></label>
297
+ <input type="radio" id="radio6" name="sendUserEmail" <?php if ($mlw_quiz_options->send_user_email == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio6"><?php _e('No', 'quiz-master-next'); ?></label>
298
+ </div></td>
299
+ </tr>
300
+ <tr valign="top">
301
+ <th scope="row"><label for="sendAdminEmail"><?php _e('Send admin email upon completion?', 'quiz-master-next'); ?></label></th>
302
+ <td><div id="sendAdminEmail">
303
+ <input type="radio" id="radio19" name="sendAdminEmail" <?php if ($mlw_quiz_options->send_admin_email == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio19"><?php _e('Yes', 'quiz-master-next'); ?></label>
304
+ <input type="radio" id="radio20" name="sendAdminEmail" <?php if ($mlw_quiz_options->send_admin_email == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio20"><?php _e('No', 'quiz-master-next'); ?></label>
305
+ </div></td>
306
+ </tr>
307
+ <tr valign="top">
308
+ <th scope="row"><label for="adminEmail"><?php _e('What emails should we send the admin email to? Separate emails with a comma.', 'quiz-master-next'); ?></label></th>
309
+ <td><input name="adminEmail" type="text" id="adminEmail" value="<?php echo $mlw_quiz_options->admin_email; ?>" class="regular-text" /></td>
310
+ </tr>
311
+ </table>
312
+ <br />
313
+ <br />
314
+ <h3><?php _e('Email Sent To User', 'quiz-master-next'); ?></h3>
315
+ <a id="new_email_button_top" class="button" href="#" onclick="javascript: document.mlw_quiz_add_email_form.submit();"><?php _e('Add New User Email', 'quiz-master-next'); ?></a>
316
+ <table class="widefat">
317
+ <thead>
318
+ <tr>
319
+ <th>ID</th>
320
+ <th><?php _e('Score Greater Than Or Equal To', 'quiz-master-next'); ?></th>
321
+ <th><?php _e('Score Less Than Or Equal To', 'quiz-master-next'); ?></th>
322
+ <th><?php _e('Subject', 'quiz-master-next'); ?></th>
323
+ <th><?php _e('Email To Send', 'quiz-master-next'); ?></th>
324
+ </tr>
325
+ </thead>
326
+ <tbody>
327
+ <?php
328
+ $mlw_each_count = 0;
329
+ $alternate = "";
330
+ foreach($mlw_qmn_user_email_array as $mlw_each)
331
+ {
332
+ if($alternate) $alternate = "";
333
+ else $alternate = " class=\"alternate\"";
334
+ $mlw_each_count += 1;
335
+ if (!isset($mlw_each[3]))
336
+ {
337
+ $mlw_each[3] = "Quiz Results For %QUIZ_NAME%";
338
+ }
339
+ if ($mlw_each[0] == 0 && $mlw_each[1] == 0)
340
+ {
341
+ echo "<tr{$alternate}>";
342
+ echo "<td>";
343
+ echo "Default";
344
+ echo "</td>";
345
+ echo "<td>";
346
+ echo "<input type='hidden' id='user_email_begin_".$mlw_each_count."' name='user_email_begin_".$mlw_each_count."' value='0'/>-";
347
+ echo "</td>";
348
+ echo "<td>";
349
+ echo "<input type='hidden' id='user_email_end_".$mlw_each_count."' name='user_email_end_".$mlw_each_count."' value='0'/>-";
350
+ echo "</td>";
351
+ echo "<td>";
352
+ echo "<input type='text' id='user_email_subject_".$mlw_each_count."' name='user_email_subject_".$mlw_each_count."' value='".$mlw_each[3]."' />";
353
+ echo "</td>";
354
+ echo "<td>";
355
+ echo "<textarea cols='80' rows='15' id='user_email_".$mlw_each_count."' name='user_email_".$mlw_each_count."'>".$mlw_each[2]."</textarea>";
356
+ echo "</td>";
357
+ echo "</tr>";
358
+ break;
359
+ }
360
+ else
361
+ {
362
+ echo "<tr{$alternate}>";
363
+ echo "<td>";
364
+ echo $mlw_each_count."<div><span style='color:green;font-size:12px;'><a onclick=\"\$j('#trying_delete_email_".$mlw_each_count."').show();\">Delete</a></span></div><div style=\"display: none;\" id='trying_delete_email_".$mlw_each_count."'>Are you sure?<br /><a onclick=\"delete_email(".$mlw_each_count.")\">Yes</a>|<a onclick=\"\$j('#trying_delete_email_".$mlw_each_count."').hide();\">No</a></div>";
365
+ echo "</td>";
366
+ echo "<td>";
367
+ echo "<input type='text' id='user_email_begin_".$mlw_each_count."' name='user_email_begin_".$mlw_each_count."' title='What score must the user score better than to see this page' value='".$mlw_each[0]."'/>";
368
+ echo "</td>";
369
+ echo "<td>";
370
+ echo "<input type='text' id='user_email_end_".$mlw_each_count."' name='user_email_end_".$mlw_each_count."' title='What score must the user score worse than to see this page' value='".$mlw_each[1]."' />";
371
+ echo "</td>";
372
+ echo "<td>";
373
+ echo "<input type='text' id='user_email_subject_".$mlw_each_count."' name='user_email_subject_".$mlw_each_count."' value='".$mlw_each[3]."' />";
374
+ echo "</td>";
375
+ echo "<td>";
376
+ echo "<textarea cols='80' rows='15' id='user_email_".$mlw_each_count."' title='What email will the user be sent' name='user_email_".$mlw_each_count."'>".$mlw_each[2]."</textarea>";
377
+ echo "</td>";
378
+ echo "</tr>";
379
+ }
380
+ }
381
+ ?>
382
+ </tbody>
383
+ <tfoot>
384
+ <tr>
385
+ <th>ID</th>
386
+ <th><?php _e('Score Greater Than Or Equal To', 'quiz-master-next'); ?></th>
387
+ <th><?php _e('Score Less Than Or Equal To', 'quiz-master-next'); ?></th>
388
+ <th><?php _e('Subject', 'quiz-master-next'); ?></th>
389
+ <th><?php _e('Email To Send', 'quiz-master-next'); ?></th>
390
+ </tr>
391
+ </tfoot>
392
+ </table>
393
+ <a id="new_email_button_bottom" class="button" href="#" onclick="javascript: document.mlw_quiz_add_email_form.submit();"><?php _e('Add New User Email', 'quiz-master-next'); ?></a>
394
+ <input type='hidden' name='mlw_save_email_template' value='confirmation' />
395
+ <input type='hidden' name='mlw_email_quiz_id' value='<?php echo $quiz_id; ?>' />
396
+ <input type='hidden' name='mlw_email_template_total' value='<?php echo $mlw_each_count; ?>' />
397
+ <br />
398
+ <br />
399
+ <br />
400
+ <br />
401
+ <h3><?php _e('Email Sent To Admin', 'quiz-master-next'); ?></h3>
402
+ <a id="new_admin_email_button_top" class="button" href="#" onclick="javascript: document.mlw_quiz_add_admin_email_form.submit();"><?php _e('Add New Admin Email', 'quiz-master-next'); ?></a>
403
+ <table class="widefat">
404
+ <thead>
405
+ <tr>
406
+ <th>ID</th>
407
+ <th><?php _e('Score Greater Than Or Equal To', 'quiz-master-next'); ?></th>
408
+ <th><?php _e('Score Less Than Or Equal To', 'quiz-master-next'); ?></th>
409
+ <th><?php _e('Subject', 'quiz-master-next'); ?></th>
410
+ <th><?php _e('Email To Send', 'quiz-master-next'); ?></th>
411
+ </tr>
412
+ </thead>
413
+ <tbody>
414
+ <?php
415
+ $mlw_admin_count = 0;
416
+ $alternate = "";
417
+ foreach($mlw_qmn_admin_email_array as $mlw_each)
418
+ {
419
+ if($alternate) $alternate = "";
420
+ else $alternate = " class=\"alternate\"";
421
+ $mlw_admin_count += 1;
422
+ if (!isset($mlw_each["subject"]))
423
+ {
424
+ $mlw_each[3] = "Quiz Results For %QUIZ_NAME%";
425
+ }
426
+ if ($mlw_each["begin_score"] == 0 && $mlw_each["end_score"] == 0)
427
+ {
428
+ echo "<tr{$alternate}>";
429
+ echo "<td>";
430
+ echo "Default";
431
+ echo "</td>";
432
+ echo "<td>";
433
+ echo "<input type='hidden' id='admin_email_begin_".$mlw_admin_count."' name='admin_email_begin_".$mlw_admin_count."' value='0'/>-";
434
+ echo "</td>";
435
+ echo "<td>";
436
+ echo "<input type='hidden' id='admin_email_end_".$mlw_admin_count."' name='admin_email_end_".$mlw_admin_count."' value='0'/>-";
437
+ echo "</td>";
438
+ echo "<td>";
439
+ echo "<input type='text' id='admin_email_subject_".$mlw_admin_count."' name='admin_email_subject_".$mlw_admin_count."' value='".$mlw_each["subject"]."' />";
440
+ echo "</td>";
441
+ echo "<td>";
442
+ echo "<textarea cols='80' rows='15' id='admin_email_".$mlw_admin_count."' name='admin_email_".$mlw_admin_count."'>".$mlw_each["message"]."</textarea>";
443
+ echo "</td>";
444
+ echo "</tr>";
445
+ break;
446
+ }
447
+ else
448
+ {
449
+ echo "<tr{$alternate}>";
450
+ echo "<td>";
451
+ echo $mlw_admin_count."<div><span style='color:green;font-size:12px;'><a onclick=\"\$j('#trying_delete_admin_email_".$mlw_admin_count."').show();\">Delete</a></span></div><div style=\"display: none;\" id='trying_delete_admin_email_".$mlw_admin_count."'>Are you sure?<br /><a onclick=\"delete_admin_email(".$mlw_admin_count.")\">Yes</a>|<a onclick=\"\$j('#trying_delete_admin_email_".$mlw_admin_count."').hide();\">No</a></div>";
452
+ echo "</td>";
453
+ echo "<td>";
454
+ echo "<input type='text' id='admin_email_begin_".$mlw_admin_count."' name='admin_email_begin_".$mlw_admin_count."' title='What score must the user score better than to see this page' value='".$mlw_each["begin_score"]."'/>";
455
+ echo "</td>";
456
+ echo "<td>";
457
+ echo "<input type='text' id='admin_email_end_".$mlw_admin_count."' name='admin_email_end_".$mlw_admin_count."' title='What score must the user score worse than to see this page' value='".$mlw_each["end_score"]."' />";
458
+ echo "</td>";
459
+ echo "<td>";
460
+ echo "<input type='text' id='admin_email_subject_".$mlw_admin_count."' name='admin_email_subject_".$mlw_admin_count."' value='".$mlw_each["subject"]."' />";
461
+ echo "</td>";
462
+ echo "<td>";
463
+ echo "<textarea cols='80' rows='15' id='admin_email_".$mlw_admin_count."' title='What email will the user be sent' name='admin_email_".$mlw_admin_count."'>".$mlw_each["message"]."</textarea>";
464
+ echo "</td>";
465
+ echo "</tr>";
466
+ }
467
+ }
468
+ ?>
469
+ </tbody>
470
+ <tfoot>
471
+ <tr>
472
+ <th>ID</th>
473
+ <th><?php _e('Score Greater Than Or Equal To', 'quiz-master-next'); ?></th>
474
+ <th><?php _e('Score Less Than Or Equal To', 'quiz-master-next'); ?></th>
475
+ <th><?php _e('Subject', 'quiz-master-next'); ?></th>
476
+ <th><?php _e('Email To Send', 'quiz-master-next'); ?></th>
477
+ </tr>
478
+ </tfoot>
479
+ </table>
480
+ <a id="new_admin_email_button_bottom" class="button" href="#" onclick="javascript: document.mlw_quiz_add_admin_email_form.submit();"><?php _e('Add New Admin Email', 'quiz-master-next'); ?></a>
481
+ <input type='hidden' name='mlw_email_admin_total' value='<?php echo $mlw_admin_count; ?>' />
482
+ </form>
483
+ <br />
484
+ <br />
485
+ <button id="save_email_button" class="button" onclick="javascript: document.mlw_quiz_save_email_form.submit();"><?php _e('Save Email Templates And Settings', 'quiz-master-next'); ?></button>
486
+ </div>
487
+ <?php
488
+ }
489
+ ?>
includes/qmn_options_leaderboard_tab.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function qmn_settings_leaderboard_tab()
3
+ {
4
+ global $mlwQuizMasterNext;
5
+ $mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs(__("Leaderboard", 'quiz-master-next'), 'mlw_options_leaderboard_tab_content');
6
+ }
7
+ add_action("plugins_loaded", 'qmn_settings_leaderboard_tab', 5);
8
+
9
+ function mlw_options_leaderboard_tab_content()
10
+ {
11
+ global $wpdb;
12
+ global $mlwQuizMasterNext;
13
+ $quiz_id = $_GET["quiz_id"];
14
+ ///Submit saved leaderboard template into database
15
+ if ( isset($_POST["save_leaderboard_options"]) && $_POST["save_leaderboard_options"] == "confirmation")
16
+ {
17
+ ///Variables for save leaderboard options form
18
+ $mlw_leaderboard_template = $_POST["mlw_quiz_leaderboard_template"];
19
+ $mlw_leaderboard_quiz_id = $_POST["leaderboard_quiz_id"];
20
+ $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET leaderboard_template='".$mlw_leaderboard_template."', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$mlw_leaderboard_quiz_id;
21
+ $results = $wpdb->query( $update );
22
+ if ($results != false)
23
+ {
24
+ $mlwQuizMasterNext->alertManager->newAlert(__('The leaderboards has been updated successfully.', 'quiz-master-next'), 'success');
25
+
26
+ //Insert Action Into Audit Trail
27
+ global $current_user;
28
+ get_currentuserinfo();
29
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
30
+ $insert = "INSERT INTO " . $table_name .
31
+ "(trail_id, action_user, action, time) " .
32
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Leaderboard Options Have Been Edited For Quiz Number ".$mlw_leaderboard_quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
33
+ $results = $wpdb->query( $insert );
34
+ }
35
+ else
36
+ {
37
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0009'), 'error');
38
+ }
39
+ }
40
+
41
+ if (isset($_GET["quiz_id"]))
42
+ {
43
+ $table_name = $wpdb->prefix . "mlw_quizzes";
44
+ $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
45
+ }
46
+ ?>
47
+ <div id="tabs-4" class="mlw_tab_content">
48
+ <h3><?php _e('Template Variables', 'quiz-master-next'); ?></h3>
49
+ <table class="form-table">
50
+ <tr>
51
+ <td><strong>%FIRST_PLACE_NAME%</strong> - <?php _e("The name of the user who is in first place", 'quiz-master-next'); ?></td>
52
+ <td><strong>%FIRST_PLACE_SCORE%</strong> - <?php _e("The score from the first place's quiz", 'quiz-master-next'); ?></td>
53
+ </tr>
54
+
55
+ <tr>
56
+ <td><strong>%SECOND_PLACE_NAME%</strong> - <?php _e("The name of the user who is in second place", 'quiz-master-next'); ?></td>
57
+ <td><strong>%SECOND_PLACE_SCORE%</strong> - <?php _e("The score from the second place's quiz", 'quiz-master-next'); ?></td>
58
+ </tr>
59
+
60
+ <tr>
61
+ <td><strong>%THIRD_PLACE_NAME%</strong> - <?php _e('The name of the user who is in third place', 'quiz-master-next'); ?></td>
62
+ <td><strong>%THIRD_PLACE_SCORE%</strong> - <?php _e("The score from the third place's quiz", 'quiz-master-next'); ?></td>
63
+ </tr>
64
+
65
+ <tr>
66
+ <td><strong>%FOURTH_PLACE_NAME%</strong> - <?php _e('The name of the user who is in fourth place', 'quiz-master-next'); ?></td>
67
+ <td><strong>%FOURTH_PLACE_SCORE%</strong> - <?php _e("The score from the fourth place's quiz", 'quiz-master-next'); ?></td>
68
+ </tr>
69
+
70
+ <tr>
71
+ <td><strong>%FIFTH_PLACE_NAME%</strong> - <?php _e('The name of the user who is in fifth place', 'quiz-master-next'); ?></td>
72
+ <td><strong>%FIFTH_PLACE_SCORE%</strong> - <?php _e("The score from the fifth place's quiz", 'quiz-master-next'); ?></td>
73
+ </tr>
74
+
75
+ <tr>
76
+ <td><strong>%QUIZ_NAME%</strong> - <?php _e("The name of the quiz", 'quiz-master-next'); ?></td>
77
+ </tr>
78
+ </table>
79
+ <button id="save_template_button" class="button" onclick="javascript: document.quiz_leaderboard_options_form.submit();"><?php _e("Save Leaderboard Options", 'quiz-master-next'); ?></button>
80
+ <?php
81
+ echo "<form action='' method='post' name='quiz_leaderboard_options_form'>";
82
+ echo "<input type='hidden' name='save_leaderboard_options' value='confirmation' />";
83
+ echo "<input type='hidden' name='leaderboard_quiz_id' value='".$quiz_id."' />";
84
+ ?>
85
+ <table class="form-table">
86
+ <tr>
87
+ <td width="30%">
88
+ <strong><?php _e("Leaderboard Template", 'quiz-master-next'); ?></strong>
89
+ <br />
90
+ <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
91
+ <p style="margin: 2px 0">- %QUIZ_NAME%</p>
92
+ <p style="margin: 2px 0">- %FIRST_PLACE_NAME%</p>
93
+ <p style="margin: 2px 0">- %FIRST_PLACE_SCORE%</p>
94
+ <p style="margin: 2px 0">- %SECOND_PLACE_NAME%</p>
95
+ <p style="margin: 2px 0">- %SECOND_PLACE_SCORE%</p>
96
+ <p style="margin: 2px 0">- %THIRD_PLACE_NAME%</p>
97
+ <p style="margin: 2px 0">- %THIRD_PLACE_SCORE%</p>
98
+ <p style="margin: 2px 0">- %FOURTH_PLACE_NAME%</p>
99
+ <p style="margin: 2px 0">- %FOURTH_PLACE_SCORE%</p>
100
+ <p style="margin: 2px 0">- %FIFTH_PLACE_NAME%</p>
101
+ <p style="margin: 2px 0">- %FIFTH_PLACE_SCORE%</p>
102
+ </td>
103
+ <td><textarea cols="80" rows="15" id="mlw_quiz_leaderboard_template" name="mlw_quiz_leaderboard_template"><?php echo $mlw_quiz_options->leaderboard_template; ?></textarea>
104
+ </td>
105
+ </tr>
106
+ </table>
107
+ <button id="save_template_button" class="button" onclick="javascript: document.quiz_leaderboard_options_form.submit();"><?php _e("Save Leaderboard Options", 'quiz-master-next'); ?></button>
108
+ </form>
109
+ </div>
110
+ <?php
111
+ }
112
+ ?>
includes/qmn_options_option_tab.php ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function qmn_settings_options_tab()
3
+ {
4
+ global $mlwQuizMasterNext;
5
+ $mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs(__("Options", 'quiz-master-next'), 'mlw_options_option_tab_content');
6
+ }
7
+ add_action("plugins_loaded", 'qmn_settings_options_tab', 5);
8
+
9
+ function mlw_options_option_tab_content()
10
+ {
11
+ global $wpdb;
12
+ global $mlwQuizMasterNext;
13
+ $quiz_id = $_GET["quiz_id"];
14
+ //Submit saved options into database
15
+ if ( isset($_POST["save_options"]) && $_POST["save_options"] == "confirmation")
16
+ {
17
+ //Variables for save options form
18
+ $mlw_system = $_POST["system"];
19
+ $mlw_qmn_pagination = intval($_POST["pagination"]);
20
+ $mlw_qmn_social_media = intval($_POST["social_media"]);
21
+ $mlw_qmn_question_numbering = intval($_POST["question_numbering"]);
22
+ $mlw_qmn_timer = intval($_POST["timer_limit"]);
23
+ $mlw_qmn_questions_from_total = $_POST["question_from_total"];
24
+ $mlw_randomness_order = $_POST["randomness_order"];
25
+ $mlw_total_user_tries = intval($_POST["total_user_tries"]);
26
+ $mlw_require_log_in = $_POST["require_log_in"];
27
+ $mlw_limit_total_entries = $_POST["limit_total_entries"];
28
+ $mlw_contact_location = $_POST["contact_info_location"];
29
+ $mlw_user_name = $_POST["userName"];
30
+ $mlw_user_comp = $_POST["userComp"];
31
+ $mlw_user_email = $_POST["userEmail"];
32
+ $mlw_user_phone = $_POST["userPhone"];
33
+ $mlw_comment_section = $_POST["commentSection"];
34
+ $mlw_qmn_loggedin_contact = $_POST["loggedin_user_contact"];
35
+ $qmn_scheduled_timeframe = serialize(array("start" => $_POST["scheduled_time_start"], "end" => $_POST["scheduled_time_end"]));
36
+ $quiz_id = $_POST["quiz_id"];
37
+
38
+ $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET system='".$mlw_system."', loggedin_user_contact='".$mlw_qmn_loggedin_contact."', contact_info_location=".$mlw_contact_location.", user_name='".$mlw_user_name."', user_comp='".$mlw_user_comp."', user_email='".$mlw_user_email."', user_phone='".$mlw_user_phone."', comment_section='".$mlw_comment_section."', randomness_order='".$mlw_randomness_order."', question_from_total=".$mlw_qmn_questions_from_total.", total_user_tries=".$mlw_total_user_tries.", social_media=".$mlw_qmn_social_media.", pagination=".$mlw_qmn_pagination.", timer_limit=".$mlw_qmn_timer.", question_numbering=".$mlw_qmn_question_numbering.", require_log_in=".$mlw_require_log_in.", limit_total_entries=".$mlw_limit_total_entries.", last_activity='".date("Y-m-d H:i:s")."', scheduled_timeframe='".$qmn_scheduled_timeframe."' WHERE quiz_id=".$quiz_id;
39
+ $results = $wpdb->query( $update );
40
+ if ($results != false)
41
+ {
42
+ $mlwQuizMasterNext->alertManager->newAlert(__('The options has been updated successfully.', 'quiz-master-next'), 'success');
43
+
44
+ //Insert Action Into Audit Trail
45
+ global $current_user;
46
+ get_currentuserinfo();
47
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
48
+ $insert = "INSERT INTO " . $table_name .
49
+ "(trail_id, action_user, action, time) " .
50
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Options Have Been Edited For Quiz Number ".$quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
51
+ $results = $wpdb->query( $insert );
52
+ }
53
+ else
54
+ {
55
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0008'), 'error');
56
+ }
57
+ }
58
+
59
+ if (isset($_GET["quiz_id"]))
60
+ {
61
+ $table_name = $wpdb->prefix . "mlw_quizzes";
62
+ $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
63
+ }
64
+
65
+ //Load Scheduled Timeframe
66
+ $qmn_scheduled_timeframe = "";
67
+ if (is_serialized($mlw_quiz_options->scheduled_timeframe) && is_array(@unserialize($mlw_quiz_options->scheduled_timeframe)))
68
+ {
69
+ $qmn_scheduled_timeframe = @unserialize($mlw_quiz_options->scheduled_timeframe);
70
+ }
71
+ else
72
+ {
73
+ $qmn_scheduled_timeframe = array("start" => '', "end" => '');
74
+ }
75
+ ?>
76
+ <div id="tabs-3" class="mlw_tab_content">
77
+ <script>
78
+ jQuery(function() {
79
+ jQuery( "#system, #require_log_in, #randomness_order, #loggedin_user_contact, #sendUserEmail, #sendAdminEmail, #contact_info_location, #userName, #userComp, #userEmail, #userPhone, #pagination, #commentSection, #social_media, #question_numbering, #comments" ).buttonset();
80
+ jQuery( "#scheduled_time_start, #scheduled_time_end" ).datepicker();
81
+ });
82
+ </script>
83
+ <button id="save_options_button" class="button" onclick="javascript: document.quiz_options_form.submit();"><?php _e('Save Options', 'quiz-master-next'); ?></button>
84
+ <?php
85
+ echo "<form action='' method='post' name='quiz_options_form'>";
86
+ echo "<input type='hidden' name='save_options' value='confirmation' />";
87
+ echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
88
+ ?>
89
+ <table class="form-table" style="width: 100%;">
90
+ <tr valign="top">
91
+ <th scope="row"><label for="system"><?php _e('Which system is this quiz graded on?', 'quiz-master-next'); ?></label></th>
92
+ <td><div id="system">
93
+ <input type="radio" id="radio1" name="system" <?php if ($mlw_quiz_options->system == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio1"><?php _e('Correct/Incorrect', 'quiz-master-next'); ?></label>
94
+ <input type="radio" id="radio2" name="system" <?php if ($mlw_quiz_options->system == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio2"><?php _e('Points', 'quiz-master-next'); ?></label>
95
+ <input type="radio" id="radio3" name="system" <?php if ($mlw_quiz_options->system == 2) {echo 'checked="checked"';} ?> value='2' /><label for="radio3"><?php _e('Not Graded', 'quiz-master-next'); ?></label>
96
+ </div></td>
97
+ </tr>
98
+ <tr valign="top">
99
+ <th scope="row"><label for="require_log_in"><?php _e('Should the user be required to be logged in to take this quiz?', 'quiz-master-next'); ?></label></th>
100
+ <td><div id="require_log_in">
101
+ <input type="radio" id="radio_login_1" name="require_log_in" <?php if ($mlw_quiz_options->require_log_in == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio_login_1"><?php _e('Yes', 'quiz-master-next'); ?></label>
102
+ <input type="radio" id="radio_login_2" name="require_log_in" <?php if ($mlw_quiz_options->require_log_in == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio_login_2"><?php _e('No', 'quiz-master-next'); ?></label>
103
+ </div></td>
104
+ </tr>
105
+ <tr valign="top">
106
+ <th scope="row"><label for="pagination"><?php _e('How many questions per page would you like? (Leave 0 for all questions on one page)', 'quiz-master-next'); ?></label></th>
107
+ <td>
108
+ <input type="number" step="1" min="0" max="1000" name="pagination" value="<?php echo $mlw_quiz_options->pagination; ?>" class="regular-text" />
109
+ </td>
110
+ </tr>
111
+ <tr valign="top">
112
+ <th scope="row"><label for="timer_limit"><?php _e('How many minutes does the user have to finish the quiz? (Leave 0 for no time limit)', 'quiz-master-next'); ?></label></th>
113
+ <td>
114
+ <input name="timer_limit" type="number" step="1" min="0" id="timer_limit" value="<?php echo $mlw_quiz_options->timer_limit; ?>" class="regular-text" />
115
+ </td>
116
+ </tr>
117
+ <tr valign="top">
118
+ <th scope="row"><label for="total_user_tries"><?php _e('How many times can a user take this quiz? (Leave 0 for as many times as the user wants to. Currently only works for registered users)', 'quiz-master-next'); ?></label></th>
119
+ <td>
120
+ <input name="total_user_tries" type="number" step="1" min="0" id="total_user_tries" value="<?php echo $mlw_quiz_options->total_user_tries; ?>" class="regular-text" />
121
+ </td>
122
+ </tr>
123
+ <tr valign="top">
124
+ <th scope="row"><label for="limit_total_entries"><?php _e('How many total entries can this quiz have? (Leave 0 for unlimited entries', 'quiz-master-next'); ?>)</label></th>
125
+ <td>
126
+ <input name="limit_total_entries" type="number" step="1" min="0" id="limit_total_entries" value="<?php echo $mlw_quiz_options->limit_total_entries; ?>" class="regular-text" />
127
+ </td>
128
+ </tr>
129
+ <tr valign="top">
130
+ <th scope="row"><label for="question_from_total"><?php _e('How many questions should be loaded for quiz? (Leave 0 to load all questions)', 'quiz-master-next'); ?></label></th>
131
+ <td>
132
+ <input name="question_from_total" type="number" step="1" min="0" id="question_from_total" value="<?php echo $mlw_quiz_options->question_from_total; ?>" class="regular-text" />
133
+ </td>
134
+ </tr>
135
+ <tr valign="top">
136
+ <th scope="row"><label for="scheduled_time_start"><?php _e('What time-frame should the user be able to access the quiz? (Leave blank if the user can access anytime)', 'quiz-master-next'); ?></label></th>
137
+ <td>
138
+ <input name="scheduled_time_start" placeholder="<?php _e('start date', 'quiz-master-next'); ?>" type="text" id="scheduled_time_start" value="<?php echo $qmn_scheduled_timeframe["start"] ?>" class="regular-text" />
139
+ </td>
140
+ <td>
141
+ <input name="scheduled_time_end" type="text" placeholder="<?php _e('end date', 'quiz-master-next'); ?>" id="scheduled_time_end" value="<?php echo $qmn_scheduled_timeframe["end"] ?>" class="regular-text" />
142
+ </td>
143
+ </tr>
144
+ <tr valign="top">
145
+ <th scope="row"><label for="randomness_order"><?php _e('Are the questions random? (Question Order will not apply if this is yes)', 'quiz-master-next'); ?></label></th>
146
+ <td><div id="randomness_order">
147
+ <input type="radio" id="radio24" name="randomness_order" <?php if ($mlw_quiz_options->randomness_order == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio24"><?php _e('Random Questions', 'quiz-master-next'); ?></label>
148
+ <input type="radio" id="randomness2" name="randomness_order" <?php if ($mlw_quiz_options->randomness_order == 2) {echo 'checked="checked"';} ?> value='2' /><label for="randomness2"><?php _e('Random Questions And Answers', 'quiz-master-next'); ?></label>
149
+ <input type="radio" id="radio23" name="randomness_order" <?php if ($mlw_quiz_options->randomness_order == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio23"><?php _e('No', 'quiz-master-next'); ?></label>
150
+ </div></td>
151
+ </tr>
152
+ <tr valign="top">
153
+ <th scope="row"><label for="contact_info_location"><?php _e('Would you like to ask for the contact information at the beginning or at the end of the quiz?', 'quiz-master-next'); ?></label></th>
154
+ <td><div id="contact_info_location">
155
+ <input type="radio" id="radio25" name="contact_info_location" <?php if ($mlw_quiz_options->contact_info_location == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio25"><?php _e('Beginning', 'quiz-master-next'); ?></label>
156
+ <input type="radio" id="radio26" name="contact_info_location" <?php if ($mlw_quiz_options->contact_info_location == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio26"><?php _e('End', 'quiz-master-next'); ?></label>
157
+ </div></td>
158
+ </tr>
159
+ <tr valign="top">
160
+ <th scope="row"><label for="loggedin_user_contact"><?php _e('If a logged-in user takes the quiz, would you like them to be able to edit contact information? If set to no, the fields will not show up for logged in users; however, the users information will be saved for the fields.', 'quiz-master-next'); ?></label></th>
161
+ <td><div id="loggedin_user_contact">
162
+ <input type="radio" id="radio27" name="loggedin_user_contact" <?php if ($mlw_quiz_options->loggedin_user_contact == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio27"><?php _e('Yes', 'quiz-master-next'); ?></label>
163
+ <input type="radio" id="radio28" name="loggedin_user_contact" <?php if ($mlw_quiz_options->loggedin_user_contact == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio28"><?php _e('No', 'quiz-master-next'); ?></label>
164
+ </div></td>
165
+ </tr>
166
+ <tr valign="top">
167
+ <th scope="row"><label for="userName"><?php _e('Should we ask for users name?', 'quiz-master-next'); ?></label></th>
168
+ <td><div id="userName">
169
+ <input type="radio" id="radio7" name="userName" <?php if ($mlw_quiz_options->user_name == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio7"><?php _e('Yes', 'quiz-master-next'); ?></label>
170
+ <input type="radio" id="radio8" name="userName" <?php if ($mlw_quiz_options->user_name == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio8"><?php _e('Require', 'quiz-master-next'); ?></label>
171
+ <input type="radio" id="radio9" name="userName" <?php if ($mlw_quiz_options->user_name == 2) {echo 'checked="checked"';} ?> value='2' /><label for="radio9"><?php _e('No', 'quiz-master-next'); ?></label>
172
+ </div></td>
173
+ </tr>
174
+ <tr valign="top">
175
+ <th scope="row"><label for="userComp"><?php _e('Should we ask for users business?', 'quiz-master-next'); ?></label></th>
176
+ <td><div id="userComp">
177
+ <input type="radio" id="radio10" name="userComp" <?php if ($mlw_quiz_options->user_comp == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio10"><?php _e('Yes', 'quiz-master-next'); ?></label>
178
+ <input type="radio" id="radio11" name="userComp" <?php if ($mlw_quiz_options->user_comp == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio11"><?php _e('Require', 'quiz-master-next'); ?></label>
179
+ <input type="radio" id="radio12" name="userComp" <?php if ($mlw_quiz_options->user_comp == 2) {echo 'checked="checked"';} ?> value='2' /><label for="radio12"><?php _e('No', 'quiz-master-next'); ?></label>
180
+ </div></td>
181
+ </tr>
182
+ <tr valign="top">
183
+ <th scope="row"><label for="userEmail"><?php _e('Should we ask for users email?', 'quiz-master-next'); ?></label></th>
184
+ <td><div id="userEmail">
185
+ <input type="radio" id="radio13" name="userEmail" <?php if ($mlw_quiz_options->user_email == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio13"><?php _e('Yes', 'quiz-master-next'); ?></label>
186
+ <input type="radio" id="radio14" name="userEmail" <?php if ($mlw_quiz_options->user_email == 1) {echo 'checked="checked"';} ?> value='1'/><label for="radio14"><?php _e('Require', 'quiz-master-next'); ?></label>
187
+ <input type="radio" id="radio15" name="userEmail" <?php if ($mlw_quiz_options->user_email == 2) {echo 'checked="checked"';} ?> value='2' /><label for="radio15"><?php _e('No', 'quiz-master-next'); ?></label>
188
+ </div></td>
189
+ </tr>
190
+ <tr valign="top">
191
+ <th scope="row"><label for="userPhone"><?php _e('Should we ask for users phone number?', 'quiz-master-next'); ?></label></th>
192
+ <td><div id="userPhone">
193
+ <input type="radio" id="radio16" name="userPhone" <?php if ($mlw_quiz_options->user_phone == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio16"><?php _e('Yes', 'quiz-master-next'); ?></label>
194
+ <input type="radio" id="radio17" name="userPhone" <?php if ($mlw_quiz_options->user_phone == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio17"><?php _e('Require', 'quiz-master-next'); ?></label>
195
+ <input type="radio" id="radio18" name="userPhone" <?php if ($mlw_quiz_options->user_phone == 2) {echo 'checked="checked"';} ?> value='2' /><label for="radio18"><?php _e('No', 'quiz-master-next'); ?></label>
196
+ </div></td>
197
+ </tr>
198
+ <tr valign="top">
199
+ <th scope="row"><label for="commentSection"><?php _e('Would you like a place for the user to enter comments?', 'quiz-master-next'); ?></label></th>
200
+ <td><div id="commentSection">
201
+ <input type="radio" id="radio21" name="commentSection" <?php if ($mlw_quiz_options->comment_section == 0) {echo 'checked="checked"';} ?> value='0' /><label for="radio21"><?php _e('Yes', 'quiz-master-next'); ?></label>
202
+ <input type="radio" id="radio22" name="commentSection" <?php if ($mlw_quiz_options->comment_section == 1) {echo 'checked="checked"';} ?> value='1' /><label for="radio22"><?php _e('No', 'quiz-master-next'); ?></label>
203
+ </div></td>
204
+ </tr>
205
+ <tr valign="top">
206
+ <th scope="row"><label for="question_numbering"><?php _e('Show question number on quiz?', 'quiz-master-next'); ?></label></th>
207
+ <td><div id="question_numbering">
208
+ <input type="radio" id="question_numbering_radio2" name="question_numbering" <?php if ($mlw_quiz_options->question_numbering == 1) {echo 'checked="checked"';} ?> value='1' /><label for="question_numbering_radio2"><?php _e('Yes', 'quiz-master-next'); ?></label>
209
+ <input type="radio" id="question_numbering_radio" name="question_numbering" <?php if ($mlw_quiz_options->question_numbering == 0) {echo 'checked="checked"';} ?> value='0' /><label for="question_numbering_radio"><?php _e('No', 'quiz-master-next'); ?></label>
210
+ </div></td>
211
+ </tr>
212
+ <tr valign="top">
213
+ <th scope="row"><label for="social_media"><?php _e('Show social media sharing buttons? (Twitter & Facebook)', 'quiz-master-next'); ?></label></th>
214
+ <td><div id="social_media">
215
+ <input type="radio" id="social_media_radio2" name="social_media" <?php if ($mlw_quiz_options->social_media == 1) {echo 'checked="checked"';} ?> value='1' /><label for="social_media_radio2"><?php _e('Yes', 'quiz-master-next'); ?></label>
216
+ <input type="radio" id="social_media_radio" name="social_media" <?php if ($mlw_quiz_options->social_media == 0) {echo 'checked="checked"';} ?> value='0' /><label for="social_media_radio"><?php _e('No', 'quiz-master-next'); ?></label>
217
+ </div></td>
218
+ </tr>
219
+ </table>
220
+ <button id="save_options_button" class="button" onclick="javascript: document.quiz_options_form.submit();"><?php _e('Save Options', 'quiz-master-next'); ?></button>
221
+ </form>
222
+ </div>
223
+ <?php
224
+ }
225
+ ?>
includes/qmn_options_preview_tab.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function qmn_settings_preview_tab()
3
+ {
4
+ global $mlwQuizMasterNext;
5
+ $mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs(__("Preview", 'quiz-master-next'), 'mlw_options_preview_tab_content');
6
+ }
7
+ add_action("plugins_loaded", 'qmn_settings_preview_tab', 5);
8
+
9
+ function mlw_options_preview_tab_content()
10
+ {
11
+ ?>
12
+ <div id="tabs-preview" class="mlw_tab_content">
13
+ <?php
14
+ echo do_shortcode( '[mlw_quizmaster quiz='.intval($_GET["quiz_id"]).']' );
15
+ ?>
16
+ </div>
17
+ <?php
18
+ }
19
+ ?>
includes/qmn_options_questions_tab.php ADDED
@@ -0,0 +1,879 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function qmn_settings_questions_tab()
3
+ {
4
+ global $mlwQuizMasterNext;
5
+ $mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs(__("Questions", 'quiz-master-next'), 'mlw_options_questions_tab_content');
6
+ }
7
+ add_action("plugins_loaded", 'qmn_settings_questions_tab', 5);
8
+
9
+ function mlw_options_questions_tab_content()
10
+ {
11
+ global $wpdb;
12
+ global $mlwQuizMasterNext;
13
+ $quiz_id = $_GET["quiz_id"];
14
+
15
+ //Edit question
16
+ if ( isset($_POST["edit_question"]) && $_POST["edit_question"] == "confirmation")
17
+ {
18
+ //Variables from edit question form
19
+ $edit_question_name = trim(preg_replace('/\s+/',' ', nl2br(htmlspecialchars($_POST["edit_question_name"], ENT_QUOTES))));
20
+ $edit_question_answer_info = $_POST["edit_correct_answer_info"];
21
+ $mlw_edit_question_id = intval($_POST["edit_question_id"]);
22
+ $mlw_edit_question_type = $_POST["edit_question_type"];
23
+ $edit_comments = htmlspecialchars($_POST["edit_comments"], ENT_QUOTES);
24
+ $edit_hint = htmlspecialchars($_POST["edit_hint"], ENT_QUOTES);
25
+ $edit_question_order = intval($_POST["edit_question_order"]);
26
+ $mlw_edit_answer_total = intval($_POST["question_".$mlw_edit_question_id."_answer_total"]);
27
+
28
+ if (isset($_POST["edit_category"]))
29
+ {
30
+ $qmn_edit_category = $_POST["edit_category"];
31
+ if ($qmn_edit_category == 'new_category')
32
+ {
33
+ $qmn_edit_category = $_POST["edit_new_category"];
34
+ }
35
+ }
36
+ else
37
+ {
38
+ $qmn_edit_category = '';
39
+ }
40
+ $mlw_row_settings = $wpdb->get_row( $wpdb->prepare( "SELECT question_settings FROM " . $wpdb->prefix . "mlw_questions" . " WHERE question_id=%d", $mlw_edit_question_id ) );
41
+ if (is_serialized($mlw_row_settings->question_settings) && is_array(@unserialize($mlw_row_settings->question_settings)))
42
+ {
43
+ $mlw_settings = @unserialize($mlw_row_settings->question_settings);
44
+ }
45
+ else
46
+ {
47
+ $mlw_settings = array();
48
+ $mlw_settings['required'] = intval($_POST["edit_required"]);
49
+ }
50
+ if ( !isset($mlw_settings['required']))
51
+ {
52
+ $mlw_settings['required'] = intval($_POST["edit_required"]);
53
+ }
54
+ $mlw_settings['required'] = intval($_POST["edit_required"]);
55
+ $mlw_settings = serialize($mlw_settings);
56
+ $i = 1;
57
+ $mlw_qmn_new_answer_array = array();
58
+ while ($i <= $mlw_edit_answer_total)
59
+ {
60
+ if ($_POST["edit_answer_".$i] != "")
61
+ {
62
+ $mlw_qmn_correct = 0;
63
+ if (isset($_POST["edit_answer_".$i."_correct"]) && $_POST["edit_answer_".$i."_correct"] == 1)
64
+ {
65
+ $mlw_qmn_correct = 1;
66
+ }
67
+ $mlw_qmn_answer_each = array(htmlspecialchars(stripslashes($_POST["edit_answer_".$i]), ENT_QUOTES), floatval($_POST["edit_answer_".$i."_points"]), $mlw_qmn_correct);
68
+ $mlw_qmn_new_answer_array[] = $mlw_qmn_answer_each;
69
+ }
70
+ $i++;
71
+ }
72
+ $mlw_qmn_new_answer_array = serialize($mlw_qmn_new_answer_array);
73
+ $quiz_id = $_POST["quiz_id"];
74
+
75
+ $results = $wpdb->update(
76
+ $wpdb->prefix . "mlw_questions",
77
+ array(
78
+ 'question_name' => $edit_question_name,
79
+ 'answer_array' => $mlw_qmn_new_answer_array,
80
+ 'question_answer_info' => $edit_question_answer_info,
81
+ 'comments' => $edit_comments,
82
+ 'hints' => $edit_hint,
83
+ 'question_order' => $edit_question_order,
84
+ 'question_type_new' => $mlw_edit_question_type,
85
+ 'question_settings' => $mlw_settings,
86
+ 'category' => $qmn_edit_category
87
+ ),
88
+ array( 'question_id' => $mlw_edit_question_id ),
89
+ array(
90
+ '%s',
91
+ '%s',
92
+ '%s',
93
+ '%d',
94
+ '%s',
95
+ '%d',
96
+ '%d',
97
+ '%s',
98
+ '%s'
99
+ ),
100
+ array( '%d' )
101
+ );
102
+ if ($results != false)
103
+ {
104
+ $mlwQuizMasterNext->alertManager->newAlert(__('The question has been updated successfully.', 'quiz-master-next'), 'success');
105
+
106
+ //Insert Action Into Audit Trail
107
+ global $current_user;
108
+ get_currentuserinfo();
109
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
110
+ $insert = "INSERT INTO " . $table_name .
111
+ "(trail_id, action_user, action, time) " .
112
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Question Has Been Edited: ".$edit_question_name."' , '" . date("h:i:s A m/d/Y") . "')";
113
+ $results = $wpdb->query( $insert );
114
+ }
115
+ else
116
+ {
117
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0004'), 'error');
118
+ }
119
+ }
120
+ //Delete question from quiz
121
+ if ( isset($_POST["delete_question"]) && $_POST["delete_question"] == "confirmation")
122
+ {
123
+ //Variables from delete question form
124
+ $mlw_question_id = intval($_POST["question_id"]);
125
+ $quiz_id = $_POST["quiz_id"];
126
+
127
+ $update = "UPDATE " . $wpdb->prefix . "mlw_questions" . " SET deleted=1 WHERE question_id=".$mlw_question_id;
128
+ $results = $wpdb->query( $update );
129
+ if ($results != false)
130
+ {
131
+ $mlwQuizMasterNext->alertManager->newAlert(__('The question has been deleted successfully.', 'quiz-master-next'), 'success');
132
+
133
+ //Insert Action Into Audit Trail
134
+ global $current_user;
135
+ get_currentuserinfo();
136
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
137
+ $insert = "INSERT INTO " . $table_name .
138
+ "(trail_id, action_user, action, time) " .
139
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Question Has Been Deleted: ".$mlw_question_id."' , '" . date("h:i:s A m/d/Y") . "')";
140
+ $results = $wpdb->query( $insert );
141
+ }
142
+ else
143
+ {
144
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0005'), 'error');
145
+ }
146
+ }
147
+
148
+ //Duplicate Questions
149
+ if ( isset($_POST["duplicate_question"]) && $_POST["duplicate_question"] == "confirmation")
150
+ {
151
+ //Variables from delete question form
152
+ $mlw_question_id = intval($_POST["duplicate_question_id"]);
153
+ $quiz_id = $_POST["quiz_id"];
154
+
155
+ $mlw_original = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM ".$wpdb->prefix."mlw_questions WHERE question_id=%d", $mlw_question_id ), ARRAY_A );
156
+
157
+ $results = $wpdb->insert(
158
+ $wpdb->prefix."mlw_questions",
159
+ array(
160
+ 'quiz_id' => $mlw_original['quiz_id'],
161
+ 'question_name' => $mlw_original['question_name'],
162
+ 'answer_array' => $mlw_original['answer_array'],
163
+ 'answer_one' => $mlw_original['answer_one'],
164
+ 'answer_one_points' => $mlw_original['answer_one_points'],
165
+ 'answer_two' => $mlw_original['answer_two'],
166
+ 'answer_two_points' => $mlw_original['answer_two_points'],
167
+ 'answer_three' => $mlw_original['answer_three'],
168
+ 'answer_three_points' => $mlw_original['answer_three_points'],
169
+ 'answer_four' => $mlw_original['answer_four'],
170
+ 'answer_four_points' => $mlw_original['answer_four_points'],
171
+ 'answer_five' => $mlw_original['answer_five'],
172
+ 'answer_five_points' => $mlw_original['answer_five_points'],
173
+ 'answer_six' => $mlw_original['answer_six'],
174
+ 'answer_six_points' => $mlw_original['answer_six_points'],
175
+ 'correct_answer' => $mlw_original['correct_answer'],
176
+ 'question_answer_info' => $mlw_original['question_answer_info'],
177
+ 'comments' => $mlw_original['comments'],
178
+ 'hints' => $mlw_original['hints'],
179
+ 'question_order' => $mlw_original['question_order'],
180
+ 'question_type_new' => $mlw_original['question_type_new'],
181
+ 'question_settings' => $mlw_original['question_settings'],
182
+ 'category' => $mlw_original['category'],
183
+ 'deleted' => $mlw_original['deleted']
184
+ ),
185
+ array(
186
+ '%d',
187
+ '%s',
188
+ '%s',
189
+ '%s',
190
+ '%d',
191
+ '%s',
192
+ '%d',
193
+ '%s',
194
+ '%d',
195
+ '%s',
196
+ '%d',
197
+ '%s',
198
+ '%d',
199
+ '%s',
200
+ '%d',
201
+ '%d',
202
+ '%s',
203
+ '%d',
204
+ '%s',
205
+ '%d',
206
+ '%d',
207
+ '%s',
208
+ '%s',
209
+ '%d'
210
+ )
211
+ );
212
+
213
+ if ($results != false)
214
+ {
215
+ $mlwQuizMasterNext->alertManager->newAlert(__('The question has been duplicated successfully.', 'quiz-master-next'), 'success');
216
+
217
+ //Insert Action Into Audit Trail
218
+ global $current_user;
219
+ get_currentuserinfo();
220
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
221
+ $insert = "INSERT INTO " . $table_name .
222
+ "(trail_id, action_user, action, time) " .
223
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Question Has Been Duplicated: ".$mlw_question_id."' , '" . date("h:i:s A m/d/Y") . "')";
224
+ $results = $wpdb->query( $insert );
225
+ }
226
+ else
227
+ {
228
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0019'), 'error');
229
+ }
230
+ }
231
+
232
+ //Submit new question into database
233
+ if ( isset($_POST["create_question"]) && $_POST["create_question"] == "confirmation")
234
+ {
235
+ //Variables from new question form
236
+ $question_name = trim(preg_replace('/\s+/',' ', nl2br(htmlspecialchars($_POST["question_name"], ENT_QUOTES))));
237
+ $question_answer_info = $_POST["correct_answer_info"];
238
+ $question_type = $_POST["question_type"];
239
+ $comments = htmlspecialchars($_POST["comments"], ENT_QUOTES);
240
+ $hint = htmlspecialchars($_POST["hint"], ENT_QUOTES);
241
+ $new_question_order = intval($_POST["new_question_order"]);
242
+ $mlw_answer_total = intval($_POST["new_question_answer_total"]);
243
+
244
+ if (isset($_POST['new_category']))
245
+ {
246
+ $qmn_category = $_POST["new_category"];
247
+ if ($qmn_category == 'new_category')
248
+ {
249
+ $qmn_category = $_POST["new_new_category"];
250
+ }
251
+ }
252
+ else
253
+ {
254
+ $qmn_category = '';
255
+ }
256
+ $mlw_settings = array();
257
+ $mlw_settings['required'] = intval($_POST["required"]);
258
+ $mlw_settings = serialize($mlw_settings);
259
+ $i = 1;
260
+ $mlw_qmn_new_answer_array = array();
261
+ while ($i <= $mlw_answer_total)
262
+ {
263
+ if ($_POST["answer_".$i] != "")
264
+ {
265
+ $mlw_qmn_correct = 0;
266
+ if (isset($_POST["answer_".$i."_correct"]) && $_POST["answer_".$i."_correct"] == 1)
267
+ {
268
+ $mlw_qmn_correct = 1;
269
+ }
270
+ $mlw_qmn_answer_each = array(htmlspecialchars(stripslashes($_POST["answer_".$i]), ENT_QUOTES), floatval($_POST["answer_".$i."_points"]), $mlw_qmn_correct);
271
+ $mlw_qmn_new_answer_array[] = $mlw_qmn_answer_each;
272
+ }
273
+ $i++;
274
+ }
275
+ $mlw_qmn_new_answer_array = serialize($mlw_qmn_new_answer_array);
276
+ $quiz_id = $_POST["quiz_id"];
277
+ $results = $wpdb->insert(
278
+ $wpdb->prefix."mlw_questions",
279
+ array(
280
+ 'quiz_id' => $quiz_id,
281
+ 'question_name' => $question_name,
282
+ 'answer_array' => $mlw_qmn_new_answer_array,
283
+ 'question_answer_info' => $question_answer_info,
284
+ 'comments' => $comments,
285
+ 'hints' => $hint,
286
+ 'question_order' => $new_question_order,
287
+ 'question_type_new' => $question_type,
288
+ 'question_settings' => $mlw_settings,
289
+ 'category' => $qmn_category,
290
+ 'deleted' => 0
291
+ ),
292
+ array(
293
+ '%d',
294
+ '%s',
295
+ '%s',
296
+ '%s',
297
+ '%d',
298
+ '%s',
299
+ '%d',
300
+ '%d',
301
+ '%s',
302
+ '%s',
303
+ '%d'
304
+ )
305
+ );
306
+ if ($results != false)
307
+ {
308
+ $mlwQuizMasterNext->alertManager->newAlert(__('The question has been created successfully.', 'quiz-master-next'), 'success');
309
+
310
+ //Insert Action Into Audit Trail
311
+ global $current_user;
312
+ get_currentuserinfo();
313
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
314
+ $insert = "INSERT INTO " . $table_name .
315
+ "(trail_id, action_user, action, time) " .
316
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Question Has Been Added: ".$question_name."' , '" . date("h:i:s A m/d/Y") . "')";
317
+ $results = $wpdb->query( $insert );
318
+ }
319
+ else
320
+ {
321
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0006'), 'error');
322
+ }
323
+ }
324
+
325
+ if (isset($_GET["quiz_id"]))
326
+ {
327
+ $table_name = $wpdb->prefix . "mlw_quizzes";
328
+ $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
329
+ }
330
+ $mlw_qmn_table_limit = 15;
331
+ $mlw_qmn_question_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(question_id) FROM " . $wpdb->prefix . "mlw_questions WHERE quiz_id=%d AND deleted='0'", $quiz_id ) );
332
+
333
+ if( isset($_GET{'mlw_question_page'} ) )
334
+ {
335
+ $mlw_qmn_question_page = $_GET{'mlw_question_page'} + 1;
336
+ $mlw_qmn_question_begin = $mlw_qmn_table_limit * $mlw_qmn_question_page ;
337
+ }
338
+ else
339
+ {
340
+ $mlw_qmn_question_page = 0;
341
+ $mlw_qmn_question_begin = 0;
342
+ }
343
+ $mlw_qmn_question_left = $mlw_qmn_question_count - ($mlw_qmn_question_page * $mlw_qmn_table_limit);
344
+
345
+ $mlw_question_data = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "mlw_questions WHERE quiz_id=%d AND deleted='0'
346
+ ORDER BY question_order ASC LIMIT %d, %d", $quiz_id, $mlw_qmn_question_begin, $mlw_qmn_table_limit ) );
347
+
348
+ //Load and prepare answer arrays
349
+ $mlw_qmn_answer_arrays = array();
350
+ foreach($mlw_question_data as $mlw_question_info) {
351
+ if (is_serialized($mlw_question_info->answer_array) && is_array(@unserialize($mlw_question_info->answer_array)))
352
+ {
353
+ $mlw_qmn_answer_array_each = @unserialize($mlw_question_info->answer_array);
354
+ $mlw_qmn_answer_arrays[$mlw_question_info->question_id] = $mlw_qmn_answer_array_each;
355
+ }
356
+ else
357
+ {
358
+ $mlw_answer_array_correct = array(0, 0, 0, 0, 0, 0);
359
+ $mlw_answer_array_correct[$mlw_question_info->correct_answer-1] = 1;
360
+ $mlw_qmn_answer_arrays[$mlw_question_info->question_id] = array(
361
+ array($mlw_question_info->answer_one, $mlw_question_info->answer_one_points, $mlw_answer_array_correct[0]),
362
+ array($mlw_question_info->answer_two, $mlw_question_info->answer_two_points, $mlw_answer_array_correct[1]),
363
+ array($mlw_question_info->answer_three, $mlw_question_info->answer_three_points, $mlw_answer_array_correct[2]),
364
+ array($mlw_question_info->answer_four, $mlw_question_info->answer_four_points, $mlw_answer_array_correct[3]),
365
+ array($mlw_question_info->answer_five, $mlw_question_info->answer_five_points, $mlw_answer_array_correct[4]),
366
+ array($mlw_question_info->answer_six, $mlw_question_info->answer_six_points, $mlw_answer_array_correct[5]));
367
+ }
368
+ }
369
+
370
+ //Load Categories
371
+ $qmn_quiz_categories = $wpdb->get_results( $wpdb->prepare( "SELECT category FROM " . $wpdb->prefix . "mlw_questions WHERE quiz_id=%d AND deleted='0'
372
+ GROUP BY category", $quiz_id ) );
373
+
374
+ //Load Question Types
375
+ $qmn_question_types = $mlwQuizMasterNext->pluginHelper->get_question_type_options();
376
+
377
+ $is_new_quiz = $wpdb->num_rows;
378
+ ?>
379
+ <script>
380
+ jQuery(function() {
381
+ jQuery('#new_question_dialog').dialog({
382
+ autoOpen: false,
383
+ show: 'blind',
384
+ width:800,
385
+ hide: 'explode',
386
+ buttons: {
387
+ Cancel: function() {
388
+ jQuery(this).dialog('close');
389
+ }
390
+ }
391
+ });
392
+
393
+ jQuery('#new_question_button').click(function() {
394
+ jQuery('#new_question_dialog').dialog('open');
395
+ document.getElementById("question_name").focus();
396
+ return false;
397
+ } );
398
+ jQuery('#new_question_button_two').click(function() {
399
+ jQuery('#new_question_dialog').dialog('open');
400
+ document.getElementById("question_name").focus();
401
+ return false;
402
+ } );
403
+ });
404
+ function deleteQuestion(id){
405
+ jQuery("#delete_dialog").dialog({
406
+ autoOpen: false,
407
+ show: 'blind',
408
+ hide: 'explode',
409
+ buttons: {
410
+ Cancel: function() {
411
+ jQuery(this).dialog('close');
412
+ }
413
+ }
414
+ });
415
+ jQuery("#delete_dialog").dialog('open');
416
+ var idHidden = document.getElementById("question_id");
417
+ idHidden.value = id;
418
+ };
419
+ function duplicateQuestion(id){
420
+ jQuery("#duplicate_dialog").dialog({
421
+ autoOpen: false,
422
+ show: 'blind',
423
+ hide: 'explode',
424
+ buttons: {
425
+ Cancel: function() {
426
+ jQuery(this).dialog('close');
427
+ }
428
+ }
429
+ });
430
+ jQuery("#duplicate_dialog").dialog('open');
431
+ var idHidden = document.getElementById("duplicate_question_id");
432
+ idHidden.value = id;
433
+ };
434
+ function editQuestion(id){
435
+ jQuery("#edit_question_dialog_"+id).dialog({
436
+ autoOpen: false,
437
+ show: 'blind',
438
+ width:800,
439
+ hide: 'explode',
440
+ buttons: {
441
+ Cancel: function() {
442
+ jQuery(this).dialog('close');
443
+ }
444
+ }
445
+ });
446
+ jQuery("#edit_question_dialog_"+id).dialog('open');
447
+ };
448
+ function mlw_add_new_question(id)
449
+ {
450
+ var total_answers = parseFloat(document.getElementById("question_"+id+"_answer_total").value);
451
+ total_answers = total_answers + 1;
452
+ document.getElementById("question_"+id+"_answer_total").value = total_answers;
453
+ jQuery("#question_"+id+"_answers").append("<tr valign='top'><td><span style='font-weight:bold;'><?php _e('Answer', 'quiz-master-next'); ?> "+total_answers+"</span></td><td><input type='text' name='edit_answer_"+total_answers+"' id='edit_answer_"+total_answers+"' style='border-color:#000000;color:#3300CC;cursor:hand;width: 250px;'/></td><td><input type='text' name='edit_answer_"+total_answers+"_points' id='edit_answer_"+total_answers+"_points' value=0 style='border-color:#000000;color:#3300CC; cursor:hand;'/></td><td><input type='checkbox' id='edit_answer_"+total_answers+"_correct' name='edit_answer_"+total_answers+"_correct' value=1 /></td></tr>");
454
+ }
455
+ function mlw_add_answer_to_new_question()
456
+ {
457
+ var total_answers = parseFloat(document.getElementById("new_question_answer_total").value);
458
+ total_answers = total_answers + 1;
459
+ document.getElementById("new_question_answer_total").value = total_answers;
460
+ jQuery("#new_question_answers").append("<tr valign='top'><td><span style='font-weight:bold;'><?php _e('Answer', 'quiz-master-next'); ?> "+total_answers+"</span></td><td><input type='text' name='answer_"+total_answers+"' id='answer_"+total_answers+"' style='border-color:#000000;color:#3300CC;cursor:hand;width: 250px;'/></td><td><input type='text' name='answer_"+total_answers+"_points' id='answer_"+total_answers+"_points' value=0 style='border-color:#000000;color:#3300CC; cursor:hand;'/></td><td><input type='checkbox' id='answer_"+total_answers+"_correct' name='answer_"+total_answers+"_correct' value=1 /></td></tr>");
461
+ }
462
+ </script>
463
+ <style>
464
+ .linkOptions
465
+ {
466
+ color: #0074a2 !important;
467
+ font-size: 14px !important;
468
+ }
469
+ .linkDelete
470
+ {
471
+ color: red !important;
472
+ font-size: 14px !important;
473
+ }
474
+ .linkOptions:hover,
475
+ .linkDelete:hover
476
+ {
477
+ background-color: black;
478
+ }
479
+ </style>
480
+ <button class="add-new-h2" id="new_question_button_two"><?php _e('Add Question', 'quiz-master-next'); ?></button>
481
+ <br />
482
+ <div class="tablenav top">
483
+ <div class="tablenav-pages">
484
+ <span class="displaying-num"><?php echo sprintf(_n('One question', '%s questions', $mlw_qmn_question_count, 'quiz-master-next'), number_format_i18n($mlw_qmn_question_count)); ?></span>
485
+ <span class="pagination-links">
486
+ <?php
487
+ $mlw_current_page = $mlw_qmn_question_page+1;
488
+ $mlw_total_pages = ceil($mlw_qmn_question_count/$mlw_qmn_table_limit);
489
+ if( $mlw_qmn_question_page > 0 )
490
+ {
491
+ $mlw_qmn_previous_page = $mlw_qmn_question_page - 2;
492
+ echo "<a class=\"prev-page\" href=\"?page=mlw_quiz_options&&mlw_question_page=$mlw_qmn_previous_page&&quiz_id=$quiz_id\"><</a>";
493
+ echo "<span class=\"paging-input\">$mlw_current_page of $mlw_total_pages</span>";
494
+ if( $mlw_qmn_question_left > $mlw_qmn_table_limit )
495
+ {
496
+ echo "<a class=\"next-page\" href=\"?page=mlw_quiz_options&&mlw_question_page=$mlw_qmn_question_page&&quiz_id=$quiz_id\">></a>";
497
+ }
498
+ else
499
+ {
500
+ echo "<a class=\"next-page disabled\" href=\"javascript:();\">></a>";
501
+ }
502
+ }
503
+ else if( $mlw_qmn_question_page == 0 )
504
+ {
505
+ echo "<a class=\"prev-page disabled\" title=\"Go to the previous page\" href=\"javascript:();\"><</a>";
506
+ echo "<span class=\"paging-input\">$mlw_current_page of $mlw_total_pages</span>";
507
+ if( $mlw_qmn_question_left > $mlw_qmn_table_limit )
508
+ {
509
+ echo "<a class=\"next-page\" href=\"?page=mlw_quiz_options&&mlw_question_page=$mlw_qmn_question_page&&quiz_id=$quiz_id\">></a>";
510
+ }
511
+ else
512
+ {
513
+ echo "<a class=\"next-page disabled\" href=\"javascript:();\">></a>";
514
+ }
515
+ }
516
+ else if( $mlw_qmn_question_left < $mlw_qmn_table_limit )
517
+ {
518
+ $mlw_qmn_previous_page = $mlw_qmn_question_page - 2;
519
+ echo "<a class=\"prev-page\" href=\"?page=mlw_quiz_options&&mlw_question_page=$mlw_qmn_previous_page&&quiz_id=$quiz_id\"><</a>";
520
+ echo "<span class=\"paging-input\">$mlw_current_page of $mlw_total_pages</span>";
521
+ echo "<a class=\"next-page disabled\" href=\"javascript:();\">></a>";
522
+ }
523
+ ?>
524
+ </span>
525
+ <br class="clear">
526
+ </div>
527
+ </div>
528
+ <?php
529
+ $alternate = "";
530
+ $question_list = "";
531
+ foreach($mlw_question_data as $mlw_question_info)
532
+ {
533
+ if (is_serialized($mlw_question_info->question_settings) && is_array(@unserialize($mlw_question_info->question_settings)))
534
+ {
535
+ $mlw_question_settings = @unserialize($mlw_question_info->question_settings);
536
+ }
537
+ else
538
+ {
539
+ $mlw_question_settings = array();
540
+ $mlw_question_settings['required'] = 1;
541
+ }
542
+ $mlw_question_type_text = "";
543
+ foreach($qmn_question_types as $type)
544
+ {
545
+ if ($type["slug"] == $mlw_question_info->question_type_new)
546
+ {
547
+ $mlw_question_type_text = $type["name"];
548
+ }
549
+ }
550
+ if($alternate) $alternate = "";
551
+ else $alternate = " class=\"alternate\"";
552
+ $question_list .= "<tr{$alternate}>";
553
+ $question_list .= "<td><span style='font-size:16px;'>" . $mlw_question_info->question_order . "</span></td>";
554
+ $question_list .= "<td><span style='font-size:16px;'>" . $mlw_question_type_text . "</span></td>";
555
+ $question_list .= "<td><span style='font-size:16px;'>" . $mlw_question_info->category . "</span></td>";
556
+ $question_list .= "<td class='post-title column-title'><span style='font-size:16px;'>" . $mlw_question_info->question_name ."</span><div class='row-actions'><a class='linkOptions' onclick=\"editQuestion('".$mlw_question_info->question_id."')\" href='#'>".__('Edit', 'quiz-master-next')."</a> | <a class='linkOptions' onclick=\"duplicateQuestion('".$mlw_question_info->question_id."')\" href='#'>".__('Duplicate', 'quiz-master-next')."</a>| <a class='linkDelete' onclick=\"deleteQuestion('".$mlw_question_info->question_id."')\" href='#'>".__('Delete', 'quiz-master-next')."</a></div></td>";
557
+ $question_list .= "</tr>";
558
+
559
+
560
+ $mlw_question_answer_array = $mlw_qmn_answer_arrays[$mlw_question_info->question_id];
561
+ ?>
562
+ <div id="edit_question_dialog_<?php echo $mlw_question_info->question_id; ?>" title="Edit Question" style="display:none;">
563
+ <form action='' method='post'>
564
+ <input type='hidden' name='edit_question' value='confirmation' />
565
+ <input type='hidden' id='edit_question_id' name='edit_question_id' value='<?php echo $mlw_question_info->question_id; ?>' />
566
+ <input type='hidden' name='quiz_id' value='<?php echo $quiz_id; ?>' />
567
+ <table class="wide" style="text-align: left; white-space: nowrap;" id="question_<?php echo $mlw_question_info->question_id; ?>_answers" name="question_<?php echo $mlw_question_info->question_id; ?>_answers">
568
+ <tr>
569
+ <td><span style='font-weight:bold;'><?php _e('Question', 'quiz-master-next'); ?></span></td>
570
+ <td colspan="3">
571
+ <textarea name="edit_question_name" id="edit_question_name" style="width: 500px; height: 150px;"><?php echo htmlspecialchars_decode($mlw_question_info->question_name, ENT_QUOTES); ?></textarea>
572
+ </td>
573
+ </tr>
574
+ <tr valign="top">
575
+ <td>&nbsp;</td>
576
+ <td>&nbsp;</td>
577
+ </tr>
578
+ <tr valign="top">
579
+ <td>&nbsp;</td>
580
+ <td><span style='font-weight:bold;'><?php _e('Answers', 'quiz-master-next'); ?></span></td>
581
+ <td><span style='font-weight:bold;'><?php _e('Points Worth', 'quiz-master-next'); ?></span></td>
582
+ <td><span style='font-weight:bold;'><?php _e('Correct Answer', 'quiz-master-next'); ?></span></td>
583
+ </tr>
584
+ <?php
585
+ $mlw_answer_total = 0;
586
+ foreach($mlw_question_answer_array as $mlw_question_answer_each)
587
+ {
588
+ $mlw_answer_total = $mlw_answer_total + 1;
589
+ ?>
590
+ <tr valign="top">
591
+ <td><span style='font-weight:bold;'><?php _e('Answer', 'quiz-master-next'); ?> <?php echo $mlw_answer_total; ?></span></td>
592
+ <td>
593
+ <input type="text" name="edit_answer_<?php echo $mlw_answer_total; ?>" id="edit_answer_<?php echo $mlw_answer_total; ?>" value="<?php echo esc_attr(htmlspecialchars_decode($mlw_question_answer_each[0], ENT_QUOTES)); ?>" style="border-color:#000000;
594
+ color:#3300CC;
595
+ cursor:hand;
596
+ width: 250px;"/>
597
+ </td>
598
+ <td>
599
+ <input type="text" name="edit_answer_<?php echo $mlw_answer_total; ?>_points" id="edit_answer_<?php echo $mlw_answer_total; ?>_points" value="<?php echo $mlw_question_answer_each[1]; ?>" style="border-color:#000000;
600
+ color:#3300CC;
601
+ cursor:hand;"/>
602
+ </td>
603
+ <td><input type="checkbox" id="edit_answer_<?php echo $mlw_answer_total; ?>_correct" name="edit_answer_<?php echo $mlw_answer_total; ?>_correct" <?php if ($mlw_question_answer_each[2] == 1) { echo 'checked="checked"'; } ?> value=1 /></td>
604
+ </tr>
605
+ <?php
606
+ }
607
+ ?>
608
+ </table>
609
+ <a href="#" class="button" id="new_answer_button" onclick="mlw_add_new_question(<?php echo $mlw_question_info->question_id; ?>);"><?php _e('Add New Answer!', 'quiz-master-next'); ?></a>
610
+ <br />
611
+ <br />
612
+ <table class="wide" style="text-align: left; white-space: nowrap;">
613
+ <tr>
614
+ <td><span style='font-weight:bold;'><?php _e('Correct Answer Info', 'quiz-master-next'); ?></span></td>
615
+ <td colspan="3"><input type="text" name="edit_correct_answer_info" id="edit_correct_answer_info" style="border-color:#000000;
616
+ color:#3300CC;
617
+ cursor:hand;
618
+ width:550px;" value="<?php echo esc_attr(htmlspecialchars_decode($mlw_question_info->question_answer_info, ENT_QUOTES)); ?>"/></td>
619
+ </tr>
620
+ <tr valign="top">
621
+ <td><span style='font-weight:bold;'><?php _e('Hint', 'quiz-master-next'); ?></span></td>
622
+ <td colspan="3">
623
+ <input type="text" name="edit_hint" id="edit_hint" style="border-color:#000000;
624
+ color:#3300CC;
625
+ cursor:hand;
626
+ width:550px;" value="<?php echo htmlspecialchars_decode($mlw_question_info->hints, ENT_QUOTES); ?>"/>
627
+ </td>
628
+ </tr>
629
+ <tr><td>&nbsp;</td></tr>
630
+ <tr><td>&nbsp;</td></tr>
631
+ <tr valign="top">
632
+ <td><span style='font-weight:bold;'><?php _e('Question Type', 'quiz-master-next'); ?></span></td>
633
+ <td colspan="3">
634
+ <select name="edit_question_type">
635
+ <?php
636
+ foreach($qmn_question_types as $type)
637
+ {
638
+ $selected_text ='';
639
+ if ($mlw_question_info->question_type_new == $type["slug"])
640
+ {
641
+ $selected_text = 'selected="selected"';
642
+ }
643
+ echo "<option value='".$type['slug']."' $selected_text>".$type['name']."</option>";
644
+ }
645
+ ?>
646
+ </select>
647
+ </td>
648
+ </tr>
649
+ <tr valign="top">
650
+ <td><span style='font-weight:bold;'><?php _e('Comment Field', 'quiz-master-next'); ?></span></td>
651
+ <td colspan="3">
652
+ <input type="radio" id="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio1" name="edit_comments" value=0 <?php if ($mlw_question_info->comments == 0) { echo 'checked="checked"'; } ?>/>
653
+ <label for="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio1"><?php _e('Small Text Field', 'quiz-master-next'); ?></label>
654
+ <input type="radio" id="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio3" name="edit_comments" value=2 <?php if ($mlw_question_info->comments == 2) { echo 'checked="checked"'; } ?>/>
655
+ <label for="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio3"><?php _e('Large Text Field', 'quiz-master-next'); ?></label>
656
+ <input type="radio" id="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio2" name="edit_comments" value=1 <?php if ($mlw_question_info->comments == 1) { echo 'checked="checked"'; } ?>/>
657
+ <label for="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio2"><?php _e('None', 'quiz-master-next'); ?></label>
658
+ </td>
659
+ </tr>
660
+ <tr valign="top">
661
+ <td><span style='font-weight:bold;'><?php _e('Question Order', 'quiz-master-next'); ?></span></td>
662
+ <td>
663
+ <input type="number" step="1" min="1" name="edit_question_order" value="<?php echo $mlw_question_info->question_order; ?>" id="edit_question_order" style="border-color:#000000;
664
+ color:#3300CC;
665
+ cursor:hand;"/>
666
+ </td>
667
+ </tr>
668
+ <tr valign="top">
669
+ <td><span style='font-weight:bold;'><?php _e('Required?', 'quiz-master-next'); ?></span></td>
670
+ <td colspan="3">
671
+ <select name="edit_required">
672
+ <option value="0" <?php if ($mlw_question_settings['required'] == 0) { echo 'selected="selected"'; } ?>><?php _e('Yes', 'quiz-master-next'); ?></option>
673
+ <option value="1" <?php if ($mlw_question_settings['required'] == 1) { echo 'selected="selected"'; } ?>><?php _e('No', 'quiz-master-next'); ?></option>
674
+ </select>
675
+ </td>
676
+ </tr>
677
+ <tr>
678
+ <td><span style="font-weight:bold;"><?php _e('Category', 'quiz-master-next'); ?></span></td>
679
+ <td colspan="3">
680
+ <?php
681
+ foreach($qmn_quiz_categories as $category)
682
+ {
683
+ if ($category->category != '')
684
+ {
685
+ ?>
686
+ <input type="radio" name="edit_category" <?php if ($category->category == $mlw_question_info->category) { echo "checked='checked' "; } ?>id="edit_category_<?php echo esc_attr($category->category); ?>" value="<?php echo esc_attr($category->category); ?>">
687
+ <label for="edit_category_<?php echo esc_attr($category->category); ?>"><?php echo $category->category; ?></label>
688
+ <br />
689
+ <?php
690
+ }
691
+ }
692
+ ?>
693
+ <input type="radio" name="edit_category" id="edit_category_new" value="new_category"><label for="edit_category_new">New: <input type='text' name='edit_new_category' value='' /></label>
694
+ </td>
695
+ </tr>
696
+ </table>
697
+ <p>*<?php _e('Required currently only works on open answer, number, accept, and captcha question types', 'quiz-master-next'); ?></p>
698
+ <input type="hidden" name="question_<?php echo $mlw_question_info->question_id; ?>_answer_total" id="question_<?php echo $mlw_question_info->question_id; ?>_answer_total" value="<?php echo $mlw_answer_total; ?>" />
699
+ <p class='submit'><input type='submit' class='button-primary' value='<?php _e('Edit Question', 'quiz-master-next'); ?>' /></p>
700
+ </form>
701
+ </div>
702
+
703
+ <?php
704
+ }
705
+ ?>
706
+ <table class=widefat>
707
+ <thead>
708
+ <tr>
709
+ <th><?php _e('Question Order', 'quiz-master-next'); ?></th>
710
+ <th><?php _e('Question Type', 'quiz-master-next'); ?></th>
711
+ <th><?php _e('Category', 'quiz-master-next'); ?></th>
712
+ <th><?php _e('Question', 'quiz-master-next'); ?></th>
713
+ </tr>
714
+ </thead>
715
+ <tbody id=the-list>
716
+ <?php echo $question_list; ?>
717
+ </tbody>
718
+ <tfoot>
719
+ <tr>
720
+ <th><?php _e('Question Order', 'quiz-master-next'); ?></th>
721
+ <th><?php _e('Question Type', 'quiz-master-next'); ?></th>
722
+ <th><?php _e('Category', 'quiz-master-next'); ?></th>
723
+ <th><?php _e('Question', 'quiz-master-next'); ?></th>
724
+ </tr>
725
+ </tfoot>
726
+ </table>
727
+ <button class="button" id="new_question_button"><?php _e('Add Question', 'quiz-master-next'); ?></button>
728
+ <div id="new_question_dialog" title="Create New Question" style="display:none;">
729
+
730
+ <?php
731
+ echo "<form action='' method='post'>";
732
+ echo "<input type='hidden' name='create_question' value='confirmation' />";
733
+ echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
734
+ ?>
735
+ <table class="wide" style="text-align: left; white-space: nowrap;" id="new_question_answers" name="new_question_answers">
736
+ <tr>
737
+ <td><span style='font-weight:bold;'><?php _e('Question', 'quiz-master-next'); ?></span></td>
738
+ <td colspan="3">
739
+ <textarea name="question_name" id="question_name" style="width: 500px; height: 150px;"></textarea>
740
+ </td>
741
+ </tr>
742
+ <tr valign="top">
743
+ <td>&nbsp;</td>
744
+ <td>&nbsp;</td>
745
+ </tr>
746
+ <tr valign="top">
747
+ <td>&nbsp;</td>
748
+ <td><span style='font-weight:bold;'><?php _e('Answers', 'quiz-master-next'); ?></span></td>
749
+ <td><span style='font-weight:bold;'><?php _e('Points Worth', 'quiz-master-next'); ?></span></td>
750
+ <td><span style='font-weight:bold;'><?php _e('Correct Answer', 'quiz-master-next'); ?></span></td>
751
+ </tr>
752
+ <?php
753
+ $mlw_answer_total = 0;
754
+ $mlw_answer_total = $mlw_answer_total + 1;
755
+ ?>
756
+ <tr valign="top">
757
+ <td><span style='font-weight:bold;'><?php _e('Answer', 'quiz-master-next'); ?> <?php echo $mlw_answer_total; ?></span></td>
758
+ <td>
759
+ <input type="text" name="answer_<?php echo $mlw_answer_total; ?>" id="answer_<?php echo $mlw_answer_total; ?>" value="" style="border-color:#000000;
760
+ color:#3300CC;
761
+ cursor:hand;
762
+ width: 250px;"/>
763
+ </td>
764
+ <td>
765
+ <input type="text" name="answer_<?php echo $mlw_answer_total; ?>_points" id="answer_<?php echo $mlw_answer_total; ?>_points" value=0 style="border-color:#000000;
766
+ color:#3300CC;
767
+ cursor:hand;"/>
768
+ </td>
769
+ <td><input type="checkbox" id="answer_<?php echo $mlw_answer_total; ?>_correct" name="answer_<?php echo $mlw_answer_total; ?>_correct" checked="checked" value=1 /></td>
770
+ </tr>
771
+ </table>
772
+ <a href="#" class="button" id="new_answer_button" onclick="mlw_add_answer_to_new_question();"><?php _e('Add New Answer!', 'quiz-master-next'); ?></a>
773
+ <br />
774
+ <br />
775
+ <table class="wide" style="text-align: left; white-space: nowrap;">
776
+ <tr>
777
+ <td><span style='font-weight:bold;'><?php _e('Correct Answer Info', 'quiz-master-next'); ?></span></td>
778
+ <td colspan="3"><input type="text" name="correct_answer_info" value="" id="correct_answer_info" style="border-color:#000000;
779
+ color:#3300CC;
780
+ cursor:hand;
781
+ width:550px;"/></td>
782
+ </tr>
783
+ <tr valign="top">
784
+ <td><span style='font-weight:bold;'><?php _e('Hint', 'quiz-master-next'); ?></span></td>
785
+ <td colspan="3">
786
+ <input type="text" name="hint" value="" id="hint" style="border-color:#000000;
787
+ color:#3300CC;
788
+ cursor:hand;
789
+ width:550px;"/>
790
+ </td>
791
+ </tr>
792
+ <tr><td>&nbsp;</td></tr>
793
+ <tr><td>&nbsp;</td></tr>
794
+ <tr valign="top">
795
+ <td><span style='font-weight:bold;'><?php _e('Question Type', 'quiz-master-next'); ?></span></td>
796
+ <td colspan="3">
797
+ <select name="question_type">
798
+ <?php
799
+ foreach($qmn_question_types as $type)
800
+ {
801
+ echo "<option value='".$type['slug']."'>".$type['name']."</option>";
802
+ }
803
+ ?>
804
+ </select>
805
+ </div></td>
806
+ </tr>
807
+ <tr valign="top">
808
+ <td><span style='font-weight:bold;'><?php _e('Comment Field', 'quiz-master-next'); ?></span></td>
809
+ <td colspan="3"><div id="comments">
810
+ <input type="radio" id="commentsRadio1" name="comments" value=0 /><label for="commentsRadio1"><?php _e('Small Text Field', 'quiz-master-next'); ?></label>
811
+ <input type="radio" id="commentsRadio3" name="comments" value=2 /><label for="commentsRadio3"><?php _e('Large Text Field', 'quiz-master-next'); ?></label>
812
+ <input type="radio" id="commentsRadio2" name="comments" checked="checked" value=1 /><label for="commentsRadio2"><?php _e('None', 'quiz-master-next'); ?></label>
813
+ </div></td>
814
+ </tr>
815
+ <tr valign="top">
816
+ <td><span style='font-weight:bold;'><?php _e('Question Order', 'quiz-master-next'); ?></span></td>
817
+ <td>
818
+ <input type="number" step="1" min="1" name="new_question_order" value="<?php echo $mlw_qmn_question_count+1; ?>" id="new_question_order" style="border-color:#000000;
819
+ color:#3300CC;
820
+ cursor:hand;"/>
821
+ </td>
822
+ </tr>
823
+ <tr valign="top">
824
+ <td><span style='font-weight:bold;'><?php _e('Required?', 'quiz-master-next'); ?></span></td>
825
+ <td colspan="3">
826
+ <select name="required">
827
+ <option value="0" selected="selected"><?php _e('Yes', 'quiz-master-next'); ?></option>
828
+ <option value="1"><?php _e('No', 'quiz-master-next'); ?></option>
829
+ </select>
830
+ </div></td>
831
+ </tr>
832
+ <tr>
833
+ <td><span style="font-weight:bold;"><?php _e('Category', 'quiz-master-next'); ?></span></td>
834
+ <td colspan="3">
835
+ <?php
836
+ foreach($qmn_quiz_categories as $category)
837
+ {
838
+ if ($category->category != '')
839
+ {
840
+ ?>
841
+ <input type="radio" name="new_category" id="new_category<?php echo esc_attr($category->category); ?>" value="<?php echo esc_attr($category->category); ?>">
842
+ <label for="new_category<?php echo esc_attr($category->category); ?>"><?php echo $category->category; ?></label>
843
+ <br />
844
+ <?php
845
+ }
846
+ }
847
+ ?>
848
+ <input type="radio" name="new_category" id="new_category_new" value="new_category"><label for="new_category_new">New: <input type='text' name='new_new_category' value='' /></label>
849
+ </td>
850
+ </tr>
851
+ </table>
852
+ <p>*<?php _e('Required currently only works on open answer, number, accept, and captcha question types', 'quiz-master-next'); ?></p>
853
+ <input type="hidden" name="new_question_answer_total" id="new_question_answer_total" value="<?php echo $mlw_answer_total; ?>" />
854
+ <p class='submit'><input type='submit' class='button-primary' value='<?php _e('Create Question', 'quiz-master-next'); ?>' /></p>
855
+ </form>
856
+ </div>
857
+ <!--Dialogs-->
858
+ <div id="delete_dialog" title="Delete Question?" style="display:none;">
859
+ <h3><b><?php _e('Are you sure you want to delete this question?', 'quiz-master-next'); ?></b></h3>
860
+ <form action='' method='post'>
861
+ <input type='hidden' name='delete_question' value='confirmation' />
862
+ <input type='hidden' id='question_id' name='question_id' value='' />
863
+ <input type='hidden' name='quiz_id' value='<?php echo $quiz_id; ?>' />
864
+ <p class='submit'><input type='submit' class='button-primary' value='<?php _e('Delete Question', 'quiz-master-next'); ?>' /></p>
865
+ </form>
866
+ </div>
867
+
868
+ <div id="duplicate_dialog" title="Duplicate Question?" style="display:none;">
869
+ <h3><b><?php _e('Are you sure you want to duplicate this question?', 'quiz-master-next'); ?></b></h3>
870
+ <form action='' method='post'>
871
+ <input type='hidden' name='duplicate_question' value='confirmation' />
872
+ <input type='hidden' id='duplicate_question_id' name='duplicate_question_id' value='' />
873
+ <input type='hidden' name='quiz_id' value='<?php echo $quiz_id; ?>' />
874
+ <p class='submit'><input type='submit' class='button-primary' value='<?php _e ('Duplicate Question', 'quiz-master-next'); ?>' /></p>
875
+ </form>
876
+ </div>
877
+ <?php
878
+ }
879
+ ?>
includes/qmn_options_results_page_tab.php ADDED
@@ -0,0 +1,266 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function qmn_settings_results_tab()
3
+ {
4
+ global $mlwQuizMasterNext;
5
+ $mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs(__("Results Pages", 'quiz-master-next'), 'mlw_options_results_tab_content');
6
+ }
7
+ add_action("plugins_loaded", 'qmn_settings_results_tab', 5);
8
+ function mlw_options_results_tab_content()
9
+ {
10
+ global $wpdb;
11
+ global $mlwQuizMasterNext;
12
+ $quiz_id = $_GET["quiz_id"];
13
+ //Check to add new results page
14
+ if (isset($_POST["mlw_add_landing_page"]) && $_POST["mlw_add_landing_page"] == "confirmation")
15
+ {
16
+ //Function variables
17
+ $mlw_qmn_landing_id = intval($_POST["mlw_add_landing_quiz_id"]);
18
+ $mlw_qmn_message_after = $wpdb->get_var( $wpdb->prepare( "SELECT message_after FROM ".$wpdb->prefix."mlw_quizzes WHERE quiz_id=%d", $mlw_qmn_landing_id ) );
19
+ //Load message_after and check if it is array already. If not, turn it into one
20
+ if (is_serialized($mlw_qmn_message_after) && is_array(@unserialize($mlw_qmn_message_after)))
21
+ {
22
+ $mlw_qmn_landing_array = @unserialize($mlw_qmn_message_after);
23
+ $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here');
24
+ array_unshift($mlw_qmn_landing_array , $mlw_new_landing_array);
25
+ $mlw_qmn_landing_array = serialize($mlw_qmn_landing_array);
26
+
27
+ }
28
+ else
29
+ {
30
+ $mlw_qmn_landing_array = array(array(0, 0, $mlw_qmn_message_after));
31
+ $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here');
32
+ array_unshift($mlw_qmn_landing_array , $mlw_new_landing_array);
33
+ $mlw_qmn_landing_array = serialize($mlw_qmn_landing_array);
34
+ }
35
+
36
+ //Update message_after with new array then check to see if worked
37
+ $mlw_new_landing_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET message_after=%s, last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_landing_array, $mlw_qmn_landing_id ) );
38
+ if ($mlw_new_landing_results != false)
39
+ {
40
+ $mlwQuizMasterNext->alertManager->newAlert(__('The results page has been added successfully.', 'quiz-master-next'), 'success');
41
+
42
+ //Insert Action Into Audit Trail
43
+ global $current_user;
44
+ get_currentuserinfo();
45
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
46
+ $insert = "INSERT INTO " . $table_name .
47
+ "(trail_id, action_user, action, time) " .
48
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'New Landing Page Has Been Created For Quiz Number ".$mlw_qmn_landing_id."' , '" . date("h:i:s A m/d/Y") . "')";
49
+ $results = $wpdb->query( $insert );
50
+ }
51
+ else
52
+ {
53
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0013'), 'error');
54
+ }
55
+ }
56
+
57
+ //Check to save landing pages
58
+ if (isset($_POST["mlw_save_landing_pages"]) && $_POST["mlw_save_landing_pages"] == "confirmation")
59
+ {
60
+ //Function Variables
61
+ $mlw_qmn_landing_id = intval($_POST["mlw_landing_quiz_id"]);
62
+ $mlw_qmn_landing_total = intval($_POST["mlw_landing_page_total"]);
63
+
64
+ //Create new array
65
+ $i = 1;
66
+ $mlw_qmn_new_landing_array = array();
67
+ while ($i <= $mlw_qmn_landing_total)
68
+ {
69
+ if ($_POST["message_after_".$i] != "Delete")
70
+ {
71
+ $mlw_qmn_landing_each = array(intval($_POST["message_after_begin_".$i]), intval($_POST["message_after_end_".$i]), htmlspecialchars(stripslashes($_POST["message_after_".$i]), ENT_QUOTES));
72
+ $mlw_qmn_new_landing_array[] = $mlw_qmn_landing_each;
73
+ }
74
+ $i++;
75
+ }
76
+ $mlw_qmn_new_landing_array = serialize($mlw_qmn_new_landing_array);
77
+ $mlw_new_landing_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET message_after='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_new_landing_array, $mlw_qmn_landing_id ) );
78
+ if ($mlw_new_landing_results != false)
79
+ {
80
+ $mlwQuizMasterNext->alertManager->newAlert(__('The results page has been saved successfully.', 'quiz-master-next'), 'success');
81
+
82
+ //Insert Action Into Audit Trail
83
+ global $current_user;
84
+ get_currentuserinfo();
85
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
86
+ $insert = "INSERT INTO " . $table_name .
87
+ "(trail_id, action_user, action, time) " .
88
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Landing Pages Have Been Saved For Quiz Number ".$mlw_qmn_landing_id."' , '" . date("h:i:s A m/d/Y") . "')";
89
+ $results = $wpdb->query( $insert );
90
+ }
91
+ else
92
+ {
93
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0014'), 'error');
94
+ }
95
+ }
96
+
97
+ if (isset($_GET["quiz_id"]))
98
+ {
99
+ $table_name = $wpdb->prefix . "mlw_quizzes";
100
+ $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
101
+ }
102
+
103
+ //Load Landing Pages
104
+ if (is_serialized($mlw_quiz_options->message_after) && is_array(@unserialize($mlw_quiz_options->message_after)))
105
+ {
106
+ $mlw_message_after_array = @unserialize($mlw_quiz_options->message_after);
107
+ }
108
+ else
109
+ {
110
+ $mlw_message_after_array = array(array(0, 0, $mlw_quiz_options->message_after));
111
+ }
112
+ ?>
113
+ <div id="tabs-6" class="mlw_tab_content">
114
+ <script>
115
+ var $j = jQuery.noConflict();
116
+ // increase the default animation speed to exaggerate the effect
117
+ $j.fx.speeds._default = 1000;
118
+ function delete_landing(id)
119
+ {
120
+ var qmn_results_editor = tinyMCE.get('message_after_'+id);
121
+ if (qmn_results_editor)
122
+ {
123
+ tinyMCE.get('message_after_'+id).setContent('Delete');
124
+ }
125
+ else
126
+ {
127
+ document.getElementById('message_after_'+id).value = "Delete";
128
+ }
129
+ document.mlw_quiz_save_landing_form.submit();
130
+ }
131
+ </script>
132
+ <h3>Template Variables</h3>
133
+ <table class="form-table">
134
+ <tr>
135
+ <td><strong>%POINT_SCORE%</strong> - <?php _e('Score for the quiz when using points', 'quiz-master-next'); ?></td>
136
+ <td><strong>%AVERAGE_POINT%</strong> - <?php _e('The average amount of points user had per question', 'quiz-master-next'); ?></td>
137
+ </tr>
138
+
139
+ <tr>
140
+ <td><strong>%AMOUNT_CORRECT%</strong> - <?php _e('The number of correct answers the user had', 'quiz-master-next'); ?></td>
141
+ <td><strong>%TOTAL_QUESTIONS%</strong> - <?php _e('The total number of questions in the quiz', 'quiz-master-next'); ?></td>
142
+ </tr>
143
+
144
+ <tr>
145
+ <td><strong>%CORRECT_SCORE%</strong> - <?php _e('Score for the quiz when using correct answers', 'quiz-master-next'); ?></td>
146
+ </tr>
147
+
148
+ <tr>
149
+ <td><strong>%USER_NAME%</strong> - <?php _e('The name the user entered before the quiz', 'quiz-master-next'); ?></td>
150
+ <td><strong>%USER_BUSINESS%</strong> - <?php _e('The business the user entered before the quiz', 'quiz-master-next'); ?></td>
151
+ </tr>
152
+
153
+ <tr>
154
+ <td><strong>%USER_PHONE%</strong> - <?php _e('The phone number the user entered before the quiz', 'quiz-master-next'); ?></td>
155
+ <td><strong>%USER_EMAIL%</strong> - <?php _e('The email the user entered before the quiz', 'quiz-master-next'); ?></td>
156
+ </tr>
157
+
158
+ <tr>
159
+ <td><strong>%QUIZ_NAME%</strong> - <?php _e('The name of the quiz', 'quiz-master-next'); ?></td>
160
+ <td><strong>%QUESTIONS_ANSWERS%</strong> - <?php _e('Shows the question, the answer the user provided, and the correct answer', 'quiz-master-next'); ?></td>
161
+ </tr>
162
+
163
+ <tr>
164
+ <td><strong>%COMMENT_SECTION%</strong> - <?php _e('The comments the user entered into comment box if enabled', 'quiz-master-next'); ?></td>
165
+ <td><strong>%TIMER%</strong> - <?php _e('The amount of time user spent of quiz', 'quiz-master-next'); ?></td>
166
+ </tr>
167
+ <tr>
168
+ <td><strong>%CERTIFICATE_LINK%</strong> - <?php _e('The link to the certificate after completing the quiz', 'quiz-master-next'); ?></td>
169
+ </tr>
170
+ <tr>
171
+ <td><strong>%CATEGORY_POINTS%%/CATEGORY_POINTS%</strong> - <?php _e('The amount of points a specific category earned.', 'quiz-master-next'); ?></td>
172
+ <td><strong>%CATEGORY_SCORE%%/CATEGORY_SCORE%</strong> - <?php _e('The score a specific category earned.', 'quiz-master-next'); ?></td>
173
+ </tr>
174
+ <tr>
175
+ <td><strong>Example: %CATEGORY_POINTS%Tech%/CATEGORY_POINTS%</strong></td>
176
+ <td><strong>Example: %CATEGORY_SCORE%Tech%/CATEGORY_SCORE%</strong></td>
177
+ </tr>
178
+ <tr>
179
+ <td><strong>%CATEGORY_AVERAGE_POINTS%</strong> - <?php _e('The average points from all categories.', 'quiz-master-next'); ?></td>
180
+ <td><strong>%CATEGORY_AVERAGE_SCORE%</strong> - <?php _e('The average score from all categories.', 'quiz-master-next'); ?></td>
181
+ </tr>
182
+ </table>
183
+ <button id="save_landing_button" class="button" onclick="javascript: document.mlw_quiz_save_landing_form.submit();"><?php _e('Save Results Pages', 'quiz-master-next'); ?></button>
184
+ <button id="new_landing_button" class="button" onclick="javascript: document.mlw_quiz_add_landing_form.submit();"><?php _e('Add New Results Page', 'quiz-master-next'); ?></button>
185
+ <form method="post" action="" name="mlw_quiz_save_landing_form" style=" display:inline!important;">
186
+ <table class="widefat">
187
+ <thead>
188
+ <tr>
189
+ <th>ID</th>
190
+ <th><?php _e('Score Greater Than Or Equal To', 'quiz-master-next'); ?></th>
191
+ <th><?php _e('Score Less Than Or Equal To', 'quiz-master-next'); ?></th>
192
+ <th><?php _e('Results Page Shown', 'quiz-master-next'); ?></th>
193
+ </tr>
194
+ </thead>
195
+ <tbody>
196
+ <?php
197
+ $mlw_each_count = 0;
198
+ $alternate = "";
199
+ foreach($mlw_message_after_array as $mlw_each)
200
+ {
201
+ if($alternate) $alternate = "";
202
+ else $alternate = " class=\"alternate\"";
203
+ $mlw_each_count += 1;
204
+ if ($mlw_each[0] == 0 && $mlw_each[1] == 0)
205
+ {
206
+ echo "<tr{$alternate}>";
207
+ echo "<td>";
208
+ echo "Default";
209
+ echo "</td>";
210
+ echo "<td>";
211
+ echo "<input type='hidden' id='message_after_begin_".$mlw_each_count."' name='message_after_begin_".$mlw_each_count."' value='0'/>-";
212
+ echo "</td>";
213
+ echo "<td>";
214
+ echo "<input type='hidden' id='message_after_end_".$mlw_each_count."' name='message_after_end_".$mlw_each_count."' value='0'/>-";
215
+ echo "</td>";
216
+ echo "<td>";
217
+ wp_editor( $mlw_each[2], "message_after_".$mlw_each_count );
218
+ //echo "<textarea cols='80' rows='15' id='message_after_".$mlw_each_count."' name='message_after_".$mlw_each_count."'>".$mlw_each[2]."</textarea>";
219
+ echo "</td>";
220
+ echo "</tr>";
221
+ break;
222
+ }
223
+ else
224
+ {
225
+ echo "<tr{$alternate}>";
226
+ echo "<td>";
227
+ echo $mlw_each_count."<div><span style='color:green;font-size:12px;'><a onclick=\"\$j('#trying_delete_".$mlw_each_count."').show();\">".__('Delete', 'quiz-master-next')."</a></span></div><div style=\"display: none;\" id='trying_delete_".$mlw_each_count."'>".__('Are you sure?', 'quiz-master-next')."<br /><a onclick=\"delete_landing(".$mlw_each_count.")\">".__('Yes', 'quiz-master-next')."</a>|<a onclick=\"\$j('#trying_delete_".$mlw_each_count."').hide();\">".__('No', 'quiz-master-next')."</a></div>";
228
+ echo "</td>";
229
+ echo "<td>";
230
+ echo "<input type='text' id='message_after_begin_".$mlw_each_count."' name='message_after_begin_".$mlw_each_count."' title='What score must the user score better than to see this page' value='".$mlw_each[0]."'/>";
231
+ echo "</td>";
232
+ echo "<td>";
233
+ echo "<input type='text' id='message_after_end_".$mlw_each_count."' name='message_after_end_".$mlw_each_count."' title='What score must the user score worse than to see this page' value='".$mlw_each[1]."' />";
234
+ echo "</td>";
235
+ echo "<td>";
236
+ wp_editor( $mlw_each[2], "message_after_".$mlw_each_count );
237
+ //echo "<textarea cols='80' rows='15' id='message_after_".$mlw_each_count."' title='What text will the user see when reaching this page' name='message_after_".$mlw_each_count."'>".$mlw_each[2]."</textarea>";
238
+ echo "</td>";
239
+ echo "</tr>";
240
+ }
241
+ }
242
+ ?>
243
+ </tbody>
244
+ <tfoot>
245
+ <tr>
246
+ <th>ID</th>
247
+ <th><?php _e('Score Greater Than Or Equal To', 'quiz-master-next'); ?></th>
248
+ <th><?php _e('Score Less Than Or Equal To', 'quiz-master-next'); ?></th>
249
+ <th><?php _e('Results Page Shown', 'quiz-master-next'); ?></th>
250
+ </tr>
251
+ </tfoot>
252
+ </table>
253
+ <input type='hidden' name='mlw_save_landing_pages' value='confirmation' />
254
+ <input type='hidden' name='mlw_landing_quiz_id' value='<?php echo $quiz_id; ?>' />
255
+ <input type='hidden' name='mlw_landing_page_total' value='<?php echo $mlw_each_count; ?>' />
256
+ <button id="save_landing_button" class="button" onclick="javascript: document.mlw_quiz_save_landing_form.submit();"><?php _e('Save Results Pages', 'quiz-master-next'); ?></button>
257
+ </form>
258
+ <form method="post" action="" name="mlw_quiz_add_landing_form" style=" display:inline!important;">
259
+ <input type='hidden' name='mlw_add_landing_page' value='confirmation' />
260
+ <input type='hidden' name='mlw_add_landing_quiz_id' value='<?php echo $quiz_id; ?>' />
261
+ <button id="new_landing_button" class="button" onclick="javascript: document.mlw_quiz_add_landing_form.submit();"><?php _e('Add New Results Page', 'quiz-master-next'); ?></button>
262
+ </form>
263
+ </div>
264
+ <?php
265
+ }
266
+ ?>
includes/qmn_options_style_tab.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function qmn_settings_style_tab()
3
+ {
4
+ global $mlwQuizMasterNext;
5
+ $mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs(__("Style", 'quiz-master-next'), 'mlw_options_styling_tab_content');
6
+ }
7
+ add_action("plugins_loaded", 'qmn_settings_style_tab', 5);
8
+
9
+ function mlw_options_styling_tab_content()
10
+ {
11
+ global $wpdb;
12
+ global $mlwQuizMasterNext;
13
+ $quiz_id = $_GET["quiz_id"];
14
+ if (isset($_POST["save_style_options"]) && $_POST["save_style_options"] == "confirmation")
15
+ {
16
+ //Function Variables
17
+ $mlw_qmn_style_id = intval($_POST["style_quiz_id"]);
18
+ $mlw_qmn_theme = $_POST["save_quiz_theme"];
19
+ $mlw_qmn_style = htmlspecialchars(stripslashes($_POST["quiz_css"]), ENT_QUOTES);
20
+
21
+ //Save the new css
22
+ $mlw_save_stle_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET quiz_stye='%s', theme_selected='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_style, $mlw_qmn_theme, $mlw_qmn_style_id ) );
23
+ if ($mlw_save_stle_results != false)
24
+ {
25
+ $mlwQuizMasterNext->alertManager->newAlert(__('The style has been saved successfully.', 'quiz-master-next'), 'success');
26
+
27
+ //Insert Action Into Audit Trail
28
+ global $current_user;
29
+ get_currentuserinfo();
30
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
31
+ $insert = "INSERT INTO " . $table_name .
32
+ "(trail_id, action_user, action, time) " .
33
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Styles Have Been Saved For Quiz Number ".$mlw_qmn_style_id."' , '" . date("h:i:s A m/d/Y") . "')";
34
+ $results = $wpdb->query( $insert );
35
+ }
36
+ else
37
+ {
38
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0015'), 'error');
39
+ }
40
+ }
41
+
42
+ if (isset($_GET["quiz_id"]))
43
+ {
44
+ $table_name = $wpdb->prefix . "mlw_quizzes";
45
+ $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
46
+ }
47
+ ?>
48
+ <div id="tabs-7" class="mlw_tab_content">
49
+ <script>
50
+ function mlw_qmn_theme(theme)
51
+ {
52
+ document.getElementById('save_quiz_theme').value = theme;
53
+ jQuery("div.mlw_qmn_themeBlockActive").toggleClass("mlw_qmn_themeBlockActive");
54
+ jQuery("#mlw_qmn_theme_block_"+theme).toggleClass("mlw_qmn_themeBlockActive");
55
+
56
+ }
57
+ </script>
58
+ <?php
59
+ echo "<form action='' method='post' name='quiz_style_form'>";
60
+ echo "<input type='hidden' name='save_style_options' value='confirmation' />";
61
+ echo "<input type='hidden' name='style_quiz_id' value='".$quiz_id."' />";
62
+ echo "<input type='hidden' name='save_quiz_theme' id='save_quiz_theme' value='".$mlw_quiz_options->theme_selected."' />";
63
+ ?>
64
+ <h3><?php _e('Quiz Styles', 'quiz-master-next'); ?></h3>
65
+ <p><?php _e('Choose your style:', 'quiz-master-next'); ?></p>
66
+ <style>
67
+ div.mlw_qmn_themeBlock
68
+ {
69
+ cursor: pointer;
70
+ position: relative;
71
+ height: 100px;
72
+ width: 100px;
73
+ background-color: #eee;
74
+ color: blue;
75
+ border: #ccc solid 1px;
76
+ border-radius: 4px;
77
+ padding: 5px 5px 5px 5px;
78
+ display: inline-block;
79
+ box-sizing: border-box;
80
+ margin: auto;
81
+ }
82
+ div.mlw_qmn_themeBlockActive
83
+ {
84
+ background-color: yellow;
85
+ }
86
+ </style>
87
+ <div onclick="mlw_qmn_theme('default');" id="mlw_qmn_theme_block_default" class="mlw_qmn_themeBlock <?php if ($mlw_quiz_options->theme_selected == 'default') {echo 'mlw_qmn_themeBlockActive';} ?>"><?php _e('Custom', 'quiz-master-next'); ?></div>
88
+ <?php do_action('mlw_qmn_quiz_themes'); ?>
89
+ <script>
90
+ mlw_qmn_theme('<?php echo $mlw_quiz_options->theme_selected; ?>');
91
+ </script>
92
+ <br /><br />
93
+ <button id="save_styles_button" class="button" onclick="javascript: document.quiz_style_form.submit();"><?php _e('Save Quiz Style', 'quiz-master-next'); ?></button>
94
+ <hr />
95
+ <h3><?php _e('Custom Style CSS', 'quiz-master-next'); ?></h3>
96
+ <p><?php _e('For detailed help and guidance along with a list of different classes used in this plugin, please visit the following link:', 'quiz-master-next'); ?>
97
+ <a target="_blank" href="http://mylocalwebstop.com/quiz-master-next-editing-quizs-style/">Style Guide</a></p>
98
+ <button id="save_styles_button" class="button" onclick="javascript: document.quiz_style_form.submit();">Save Quiz Style</button>
99
+
100
+ <table class="form-table">
101
+ <tr>
102
+ <td width="66%"><textarea style="width: 100%; height: 100%;" id="quiz_css" name="quiz_css"><?php echo $mlw_quiz_options->quiz_stye; ?></textarea>
103
+ </td>
104
+ <td width="30%">
105
+ <strong><?php _e('Default:', 'quiz-master-next'); ?></strong><br />
106
+ div.mlw_qmn_quiz input[type=radio],<br />
107
+ div.mlw_qmn_quiz input[type=submit],<br />
108
+ div.mlw_qmn_quiz label {<br />
109
+ cursor: pointer;<br />
110
+ }<br />
111
+ div.mlw_qmn_quiz input:not([type=submit]):focus,<br />
112
+ div.mlw_qmn_quiz textarea:focus {<br />
113
+ background: #eaeaea;<br />
114
+ }<br />
115
+ div.mlw_qmn_quiz {<br />
116
+ text-align: left;<br />
117
+ }<br />
118
+ div.quiz_section {<br />
119
+ <br />
120
+ }<br />
121
+ div.mlw_qmn_timer {<br />
122
+ position:fixed;<br />
123
+ top:200px;<br />
124
+ right:0px;<br />
125
+ width:130px;<br />
126
+ color:#00CCFF;<br />
127
+ border-radius: 15px;<br />
128
+ background:#000000;<br />
129
+ text-align: center;<br />
130
+ padding: 15px 15px 15px 15px<br />
131
+ }<br />
132
+ div.mlw_qmn_quiz input[type=submit],<br />
133
+ a.mlw_qmn_quiz_link<br />
134
+ {<br />
135
+ border-radius: 4px;<br />
136
+ position: relative;<br />
137
+ background-image: linear-gradient(#fff,#dedede);<br />
138
+ background-color: #eee;<br />
139
+ border: #ccc solid 1px;<br />
140
+ color: #333;<br />
141
+ text-shadow: 0 1px 0 rgba(255,255,255,.5);<br />
142
+ box-sizing: border-box;<br />
143
+ display: inline-block;<br />
144
+ padding: 5px 5px 5px 5px;<br />
145
+ margin: auto;<br />
146
+ }<br />
147
+ </td>
148
+ </tr>
149
+ </table>
150
+ <button id="save_styles_button" class="button" onclick="javascript: document.quiz_style_form.submit();"><?php _e('Save Quiz Style', 'quiz-master-next'); ?></button>
151
+ </form>
152
+ </div>
153
+ <?php
154
+ }
155
+ ?>
includes/qmn_options_text_tab.php ADDED
@@ -0,0 +1,312 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function qmn_settings_text_tab()
3
+ {
4
+ global $mlwQuizMasterNext;
5
+ $mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs(__("Text", 'quiz-master-next'), 'mlw_options_text_tab_content');
6
+ }
7
+ add_action("plugins_loaded", 'qmn_settings_text_tab', 5);
8
+
9
+ function mlw_options_text_tab_content()
10
+ {
11
+ global $wpdb;
12
+ global $mlwQuizMasterNext;
13
+ $quiz_id = $_GET["quiz_id"];
14
+ //Submit saved templates into database
15
+ if ( isset($_POST["save_templates"]) && $_POST["save_templates"] == "confirmation")
16
+ {
17
+ //Variables for save templates form
18
+ $mlw_before_message = htmlspecialchars($_POST["mlw_quiz_before_message"], ENT_QUOTES);
19
+ $mlw_qmn_message_end = htmlspecialchars($_POST["message_end_template"], ENT_QUOTES);
20
+ $mlw_user_tries_text = htmlspecialchars($_POST["mlw_quiz_total_user_tries_text"], ENT_QUOTES);
21
+ $mlw_submit_button_text = htmlspecialchars($_POST["mlw_submitText"], ENT_QUOTES);
22
+ $mlw_name_field_text = htmlspecialchars($_POST["mlw_nameText"], ENT_QUOTES);
23
+ $mlw_business_field_text = htmlspecialchars($_POST["mlw_businessText"], ENT_QUOTES);
24
+ $mlw_email_field_text = htmlspecialchars($_POST["mlw_emailText"], ENT_QUOTES);
25
+ $mlw_phone_field_text = htmlspecialchars($_POST["mlw_phoneText"], ENT_QUOTES);
26
+ $mlw_before_comments = htmlspecialchars($_POST["mlw_quiz_before_comments"], ENT_QUOTES);
27
+ $mlw_comment_field_text = htmlspecialchars($_POST["mlw_commentText"], ENT_QUOTES);
28
+ $mlw_require_log_in_text = htmlspecialchars($_POST["mlw_require_log_in_text"], ENT_QUOTES);
29
+ $mlw_scheduled_timeframe_text = htmlspecialchars($_POST["mlw_scheduled_timeframe_text"], ENT_QUOTES);
30
+ $mlw_limit_total_entries_text = htmlspecialchars($_POST["mlw_limit_total_entries_text"], ENT_QUOTES);
31
+ $mlw_qmn_pagination_field = serialize(array( $_POST["pagination_prev_text"], $_POST["pagination_next_text"] ));
32
+ $qmn_social_media_text = serialize(array('twitter' => $_POST["mlw_quiz_twitter_text_template"], 'facebook' => $_POST["mlw_quiz_facebook_text_template"]));
33
+ $mlw_email_from_text = $_POST["emailFromText"];
34
+ $mlw_question_answer_template = htmlspecialchars($_POST["mlw_quiz_question_answer_template"], ENT_QUOTES);
35
+ $quiz_id = $_POST["quiz_id"];
36
+
37
+ $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET message_before='".$mlw_before_message."', message_comment='".$mlw_before_comments."', message_end_template='".$mlw_qmn_message_end."', comment_field_text='".$mlw_comment_field_text."', email_from_text='".$mlw_email_from_text."', question_answer_template='".$mlw_question_answer_template."', submit_button_text='".$mlw_submit_button_text."', name_field_text='".$mlw_name_field_text."', business_field_text='".$mlw_business_field_text."', email_field_text='".$mlw_email_field_text."', phone_field_text='".$mlw_phone_field_text."', total_user_tries_text='".$mlw_user_tries_text."', social_media_text='".$qmn_social_media_text."', pagination_text='".$mlw_qmn_pagination_field."', require_log_in_text='".$mlw_require_log_in_text."', limit_total_entries_text='".$mlw_limit_total_entries_text."', last_activity='".date("Y-m-d H:i:s")."', scheduled_timeframe_text='".$mlw_scheduled_timeframe_text."' WHERE quiz_id=".$quiz_id;
38
+ $results = $wpdb->query( $update );
39
+ if ($results != false)
40
+ {
41
+ $mlwQuizMasterNext->alertManager->newAlert(__('The templates has been updated successfully.', 'quiz-master-next'), 'success');
42
+
43
+ //Insert Action Into Audit Trail
44
+ global $current_user;
45
+ get_currentuserinfo();
46
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
47
+ $insert = "INSERT INTO " . $table_name .
48
+ "(trail_id, action_user, action, time) " .
49
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Templates Have Been Edited For Quiz Number ".$quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
50
+ $results = $wpdb->query( $insert );
51
+ }
52
+ else
53
+ {
54
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0007'), 'error');
55
+ }
56
+ }
57
+
58
+ if (isset($_GET["quiz_id"]))
59
+ {
60
+ $table_name = $wpdb->prefix . "mlw_quizzes";
61
+ $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
62
+ }
63
+
64
+ //Load Pagination Text
65
+ $mlw_qmn_pagination_text = "";
66
+ if (is_serialized($mlw_quiz_options->pagination_text) && is_array(@unserialize($mlw_quiz_options->pagination_text)))
67
+ {
68
+ $mlw_qmn_pagination_text = @unserialize($mlw_quiz_options->pagination_text);
69
+ }
70
+ else
71
+ {
72
+ $mlw_qmn_pagination_text = array(__('Previous', 'quiz-master-next'), $mlw_quiz_options->pagination_text);
73
+ }
74
+
75
+ //Load Social Media Text
76
+ $qmn_social_media_text = "";
77
+ if (is_serialized($mlw_quiz_options->social_media_text) && is_array(@unserialize($mlw_quiz_options->social_media_text)))
78
+ {
79
+ $qmn_social_media_text = @unserialize($mlw_quiz_options->social_media_text);
80
+ }
81
+ else
82
+ {
83
+ $qmn_social_media_text = array(
84
+ 'twitter' => $mlw_quiz_options->social_media_text,
85
+ 'facebook' => $mlw_quiz_options->social_media_text
86
+ );
87
+ }
88
+ ?>
89
+ <div id="tabs-2" class="mlw_tab_content">
90
+ <h3 style="text-align: center;"><?php _e("Template Variables", 'quiz-master-next'); ?></h3>
91
+ <table class="form-table">
92
+ <tr>
93
+ <td><strong>%POINT_SCORE%</strong> - <?php _e("Total points user earned when taking quiz", 'quiz-master-next'); ?></td>
94
+ <td><strong>%AVERAGE_POINT%</strong> - <?php _e("The average amount of points user had per question", 'quiz-master-next'); ?></td>
95
+ </tr>
96
+
97
+ <tr>
98
+ <td><strong>%AMOUNT_CORRECT%</strong> - <?php _e("The number of correct answers the user had", 'quiz-master-next'); ?></td>
99
+ <td><strong>%TOTAL_QUESTIONS%</strong> - <?php _e("The total number of questions in the quiz", 'quiz-master-next'); ?></td>
100
+ </tr>
101
+
102
+ <tr>
103
+ <td><strong>%CORRECT_SCORE%</strong> - <?php _e("The percent score for the quiz showing percent of total quetions answered correctly", 'quiz-master-next'); ?></td>
104
+ </tr>
105
+
106
+ <tr>
107
+ <td><strong>%USER_NAME%</strong> - <?php _e("The name the user entered before the quiz", 'quiz-master-next'); ?></td>
108
+ <td><strong>%USER_BUSINESS%</strong> - <?php _e("The business the user entered before the quiz", 'quiz-master-next'); ?></td>
109
+ </tr>
110
+
111
+ <tr>
112
+ <td><strong>%USER_PHONE%</strong> - <?php _e("The phone number the user entered before the quiz", 'quiz-master-next'); ?></td>
113
+ <td><strong>%USER_EMAIL%</strong> - <?php _e("The email the user entered before the quiz", 'quiz-master-next'); ?></td>
114
+ </tr>
115
+
116
+ <tr>
117
+ <td><strong>%QUIZ_NAME%</strong> - <?php _e("The name of the quiz", 'quiz-master-next'); ?></td>
118
+ <td><strong>%QUESTIONS_ANSWERS%</strong> - <?php _e("Shows the question, the answer the user provided, and the correct answer", 'quiz-master-next'); ?></td>
119
+ </tr>
120
+
121
+ <tr>
122
+ <td><strong>%COMMENT_SECTION%</strong> - <?php _e("The comments the user entered into comment box if enabled", 'quiz-master-next'); ?></td>
123
+ <td><strong>%QUESTION%</strong> - <?php _e("The question that the user answered", 'quiz-master-next'); ?></td>
124
+ </tr>
125
+
126
+ <tr>
127
+ <td><strong>%USER_ANSWER%</strong> - <?php _e("The answer the user gave for the question", 'quiz-master-next'); ?></td>
128
+ <td><strong>%CORRECT_ANSWER%</strong> - <?php _e("The correct answer for the question", 'quiz-master-next'); ?></td>
129
+ </tr>
130
+
131
+ <tr>
132
+ <td><strong>%USER_COMMENTS%</strong> - <?php _e("The comments the user provided in the comment field for the question", 'quiz-master-next'); ?></td>
133
+ <td><strong>%CORRECT_ANSWER_INFO%</strong> - <?php _e("Reason why the correct answer is the correct answer", 'quiz-master-next'); ?></td>
134
+ </tr>
135
+ <tr>
136
+ <td><strong>%TIMER%</strong> - <?php _e("The amount of time user spent of quiz", 'quiz-master-next'); ?></td>
137
+ <td><strong>%CERTIFICATE_LINK%</strong> - <?php _e("The link to the certificate after completing the quiz", 'quiz-master-next'); ?></td>
138
+ </tr>
139
+ <tr>
140
+ <td><strong>%CURRENT_DATE%</strong> - <?php _e("The Current Date", 'quiz-master-next'); ?></td>
141
+ </tr>
142
+ </table>
143
+ <button id="save_template_button" class="button" onclick="javascript: document.quiz_template_form.submit();"><?php _e("Save Templates", 'quiz-master-next'); ?></button>
144
+ <?php
145
+ echo "<form action='' method='post' name='quiz_template_form'>";
146
+ echo "<input type='hidden' name='save_templates' value='confirmation' />";
147
+ echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
148
+ ?>
149
+ <h3 style="text-align: center;"><?php _e("Message Templates", 'quiz-master-next'); ?></h3>
150
+ <table class="form-table">
151
+ <tr>
152
+ <td width="30%">
153
+ <strong><?php _e("Message Displayed Before Quiz", 'quiz-master-next'); ?></strong>
154
+ <br />
155
+ <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
156
+ <p style="margin: 2px 0">- %QUIZ_NAME%</p>
157
+ <p style="margin: 2px 0">- %CURRENT_DATE%</p>
158
+ </td>
159
+ <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->message_before, ENT_QUOTES), 'mlw_quiz_before_message' ); ?></td>
160
+ </tr>
161
+ <tr>
162
+ <td width="30%">
163
+ <strong><?php _e("Message Displayed Before Comments Box If Enabled", 'quiz-master-next'); ?></strong>
164
+ <br />
165
+ <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
166
+ <p style="margin: 2px 0">- %QUIZ_NAME%</p>
167
+ <p style="margin: 2px 0">- %CURRENT_DATE%</p>
168
+ </td>
169
+ <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->message_comment, ENT_QUOTES), 'mlw_quiz_before_comments' ); ?></td>
170
+ </tr>
171
+ <tr>
172
+ <td width="30%">
173
+ <strong><?php _e("Message Displayed At End Of Quiz (Leave Blank To Omit Text Section)", 'quiz-master-next'); ?></strong>
174
+ <br />
175
+ <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
176
+ <p style="margin: 2px 0">- %QUIZ_NAME%</p>
177
+ <p style="margin: 2px 0">- %CURRENT_DATE%</p>
178
+ </td>
179
+ <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->message_end_template, ENT_QUOTES), 'message_end_template' ); ?></td>
180
+ </tr>
181
+ <tr>
182
+ <td width="30%">
183
+ <strong><?php _e("Message Displayed If User Has Tried Quiz Too Many Times", 'quiz-master-next'); ?></strong>
184
+ <br />
185
+ <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
186
+ <p style="margin: 2px 0">- %QUIZ_NAME%</p>
187
+ <p style="margin: 2px 0">- %CURRENT_DATE%</p>
188
+ </td>
189
+ <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->total_user_tries_text, ENT_QUOTES), 'mlw_quiz_total_user_tries_text' ); ?></td>
190
+ </tr>
191
+ <tr>
192
+ <td width="30%">
193
+ <strong><?php _e("Message Displayed If User Is Not Logged In And Quiz Requires Users To Be Logged In", 'quiz-master-next'); ?></strong>
194
+ <br />
195
+ <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
196
+ <p style="margin: 2px 0">- %QUIZ_NAME%</p>
197
+ <p style="margin: 2px 0">- %CURRENT_DATE%</p>
198
+ </td>
199
+ <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->require_log_in_text, ENT_QUOTES), 'mlw_require_log_in_text' ); ?></td>
200
+ </tr>
201
+ <tr>
202
+ <td width="30%">
203
+ <strong><?php _e("Message Displayed If Date Is Outside Scheduled Timeframe", 'quiz-master-next'); ?></strong>
204
+ <br />
205
+ <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
206
+ <p style="margin: 2px 0">- %QUIZ_NAME%</p>
207
+ <p style="margin: 2px 0">- %CURRENT_DATE%</p>
208
+ </td>
209
+ <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->scheduled_timeframe_text, ENT_QUOTES), 'mlw_scheduled_timeframe_text' ); ?></td>
210
+ </tr>
211
+ <tr>
212
+ <td width="30%">
213
+ <strong><?php _e("Message Displayed If The Limit Of Total Entries Has Been Reached", 'quiz-master-next'); ?></strong>
214
+ <br />
215
+ <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
216
+ <p style="margin: 2px 0">- %QUIZ_NAME%</p>
217
+ <p style="margin: 2px 0">- %CURRENT_DATE%</p>
218
+ </td>
219
+ <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->limit_total_entries_text, ENT_QUOTES), 'mlw_limit_total_entries_text' ); ?></td>
220
+ </tr>
221
+ <tr>
222
+ <td width="30%">
223
+ <strong><?php _e("%QUESTIONS_ANSWERS% Text", 'quiz-master-next'); ?></strong>
224
+ <br />
225
+ <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
226
+ <p style="margin: 2px 0">- %QUESTION%</p>
227
+ <p style="margin: 2px 0">- %USER_ANSWER%</p>
228
+ <p style="margin: 2px 0">- %CORRECT_ANSWER%</p>
229
+ <p style="margin: 2px 0">- %USER_COMMENTS%</p>
230
+ <p style="margin: 2px 0">- %CORRECT_ANSWER_INFO%</p>
231
+ </td>
232
+ <td><?php wp_editor( htmlspecialchars_decode($mlw_quiz_options->question_answer_template, ENT_QUOTES), 'mlw_quiz_question_answer_template' ); ?></td>
233
+ </tr>
234
+ <tr>
235
+ <td width="30%">
236
+ <strong><?php _e("Twitter Sharing Text", 'quiz-master-next'); ?></strong>
237
+ <br />
238
+ <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
239
+ <p style="margin: 2px 0">- %POINT_SCORE%</p>
240
+ <p style="margin: 2px 0">- %AVERAGE_POINT%</p>
241
+ <p style="margin: 2px 0">- %AMOUNT_CORRECT%</p>
242
+ <p style="margin: 2px 0">- %TOTAL_QUESTIONS%</p>
243
+ <p style="margin: 2px 0">- %CORRECT_SCORE%</p>
244
+ <p style="margin: 2px 0">- %QUIZ_NAME%</p>
245
+ <p style="margin: 2px 0">- %TIMER%</p>
246
+ <p style="margin: 2px 0">- %CURRENT_DATE%</p>
247
+ </td>
248
+ <td><?php wp_editor( htmlspecialchars_decode($qmn_social_media_text["twitter"], ENT_QUOTES), 'mlw_quiz_twitter_text_template' ); ?></td>
249
+ </td>
250
+ </tr>
251
+ <tr>
252
+ <td width="30%">
253
+ <strong><?php _e("Facebook Sharing Text", 'quiz-master-next'); ?></strong>
254
+ <br />
255
+ <p><?php _e("Allowed Variables:", 'quiz-master-next'); ?></p>
256
+ <p style="margin: 2px 0">- %POINT_SCORE%</p>
257
+ <p style="margin: 2px 0">- %AVERAGE_POINT%</p>
258
+ <p style="margin: 2px 0">- %AMOUNT_CORRECT%</p>
259
+ <p style="margin: 2px 0">- %TOTAL_QUESTIONS%</p>
260
+ <p style="margin: 2px 0">- %CORRECT_SCORE%</p>
261
+ <p style="margin: 2px 0">- %QUIZ_NAME%</p>
262
+ <p style="margin: 2px 0">- %TIMER%</p>
263
+ <p style="margin: 2px 0">- %CURRENT_DATE%</p>
264
+ </td>
265
+ <td><?php wp_editor( htmlspecialchars_decode($qmn_social_media_text["facebook"], ENT_QUOTES), 'mlw_quiz_facebook_text_template' ); ?></td>
266
+ </tr>
267
+ </table>
268
+ <h3 style="text-align: center;"><?php _e("Other Templates", 'quiz-master-next'); ?></h3>
269
+ <table class="form-table">
270
+ <tr valign="top">
271
+ <th scope="row"><label for="mlw_submitText"><?php _e("Text for submit button", 'quiz-master-next'); ?></label></th>
272
+ <td><input name="mlw_submitText" type="text" id="mlw_submitText" value="<?php echo $mlw_quiz_options->submit_button_text; ?>" class="regular-text" /></td>
273
+ </tr>
274
+ <tr valign="top">
275
+ <th scope="row"><label for="mlw_nameText"><?php _e("Text for name field", 'quiz-master-next'); ?></label></th>
276
+ <td><input name="mlw_nameText" type="text" id="mlw_nameText" value="<?php echo $mlw_quiz_options->name_field_text; ?>" class="regular-text" /></td>
277
+ </tr>
278
+ <tr valign="top">
279
+ <th scope="row"><label for="mlw_businessText"><?php _e("Text for business field", 'quiz-master-next'); ?></label></th>
280
+ <td><input name="mlw_businessText" type="text" id="mlw_businessText" value="<?php echo $mlw_quiz_options->business_field_text; ?>" class="regular-text" /></td>
281
+ </tr>
282
+ <tr valign="top">
283
+ <th scope="row"><label for="mlw_emailText"><?php _e("Text for email field", 'quiz-master-next'); ?></label></th>
284
+ <td><input name="mlw_emailText" type="text" id="mlw_emailText" value="<?php echo $mlw_quiz_options->email_field_text; ?>" class="regular-text" /></td>
285
+ </tr>
286
+ <tr valign="top">
287
+ <th scope="row"><label for="mlw_phoneText"><?php _e("Text for phone number field", 'quiz-master-next'); ?></label></th>
288
+ <td><input name="mlw_phoneText" type="text" id="mlw_phoneText" value="<?php echo $mlw_quiz_options->phone_field_text; ?>" class="regular-text" /></td>
289
+ </tr>
290
+ <tr valign="top">
291
+ <th scope="row"><label for="mlw_commentText"><?php _e("Text for comments field", 'quiz-master-next'); ?></label></th>
292
+ <td><input name="mlw_commentText" type="text" id="mlw_commentText" value="<?php echo $mlw_quiz_options->comment_field_text; ?>" class="regular-text" /></td>
293
+ </tr>
294
+ <tr valign="top">
295
+ <th scope="row"><label for="pagination_prev_text"><?php _e("Text for previous button", 'quiz-master-next'); ?></label></th>
296
+ <td><input name="pagination_prev_text" type="text" id="pagination_prev_text" value="<?php echo $mlw_qmn_pagination_text[0]; ?>" class="regular-text" /></td>
297
+ </tr>
298
+ <tr valign="top">
299
+ <th scope="row"><label for="pagination_next_text"><?php _e("Text for next button", 'quiz-master-next'); ?></label></th>
300
+ <td><input name="pagination_next_text" type="text" id="pagination_next_text" value="<?php echo $mlw_qmn_pagination_text[1]; ?>" class="regular-text" /></td>
301
+ </tr>
302
+ <tr valign="top">
303
+ <th scope="row"><label for="emailFromText"><?php _e("What is the From Name for the email sent to users and admin?", 'quiz-master-next'); ?></label></th>
304
+ <td><input name="emailFromText" type="text" id="emailFromText" value="<?php echo $mlw_quiz_options->email_from_text; ?>" class="regular-text" /></td>
305
+ </tr>
306
+ </table>
307
+ <button id="save_template_button" class="button" onclick="javascript: document.quiz_template_form.submit();"><?php _e("Save Templates", 'quiz-master-next'); ?></button>
308
+ <?php echo "</form>"; ?>
309
+ </div>
310
+ <?php
311
+ }
312
+ ?>
includes/qmn_options_tools_tab.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function qmn_settings_tools_tab()
3
+ {
4
+ global $mlwQuizMasterNext;
5
+ $mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs(__("Tools", 'quiz-master-next'), 'mlw_options_tools_tab_content');
6
+ }
7
+ add_action("plugins_loaded", 'qmn_settings_tools_tab', 5);
8
+ function mlw_options_tools_tab_content()
9
+ {
10
+ global $wpdb;
11
+ global $mlwQuizMasterNext;
12
+ $quiz_id = $_GET["quiz_id"];
13
+ //Update Quiz Table
14
+ if (isset($_POST["mlw_reset_quiz_stats"]) && $_POST["mlw_reset_quiz_stats"] == "confirmation")
15
+ {
16
+ //Variables from reset stats form
17
+ $mlw_reset_stats_quiz_id = $_POST["mlw_reset_quiz_id"];
18
+ $mlw_reset_update_sql = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET quiz_views=0, quiz_taken=0, last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$mlw_reset_stats_quiz_id;
19
+ $mlw_reset_sql_results = $wpdb->query( $mlw_reset_update_sql );
20
+ if ($mlw_reset_sql_results != false)
21
+ {
22
+ $mlwQuizMasterNext->alertManager->newAlert(__('The stats has been reset successfully.', 'quiz-master-next'), 'success');
23
+
24
+ //Insert Action Into Audit Trail
25
+ global $current_user;
26
+ get_currentuserinfo();
27
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
28
+ $insert = "INSERT INTO " . $table_name .
29
+ "(trail_id, action_user, action, time) " .
30
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Quiz Stats Have Been Reset For Quiz Number ".$mlw_leaderboard_quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
31
+ $results = $wpdb->query( $insert );
32
+ }
33
+ else
34
+ {
35
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0010'), 'error');
36
+ }
37
+ }
38
+
39
+ if (isset($_GET["quiz_id"]))
40
+ {
41
+ $table_name = $wpdb->prefix . "mlw_quizzes";
42
+ $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
43
+ }
44
+ ?>
45
+ <div id="tabs-8" class="mlw_tab_content">
46
+ <script type="text/javascript">
47
+ var $j = jQuery.noConflict();
48
+ // increase the default animation speed to exaggerate the effect
49
+ $j.fx.speeds._default = 1000;
50
+ $j(function() {
51
+ $j( "#tabs" ).tabs();
52
+ });
53
+ </script>
54
+ <script>
55
+ jQuery(function() {
56
+ jQuery('#mlw_reset_stats_dialog').dialog({
57
+ autoOpen: false,
58
+ show: 'blind',
59
+ width:700,
60
+ hide: 'explode',
61
+ buttons: {
62
+ Ok: function() {
63
+ jQuery(this).dialog('close');
64
+ }
65
+ }
66
+ });
67
+
68
+ jQuery('#mlw_reset_stats_button').click(function() {
69
+ jQuery('#mlw_reset_stats_dialog').dialog('open');
70
+ return false;
71
+ } );
72
+ });
73
+ </script>
74
+ <p><?php _e('Use this button to reset all the stats collected for this quiz (Quiz Views and Times Quiz Has Been Taken).', 'quiz-master-next'); ?></p>
75
+ <button class="button" id="mlw_reset_stats_button"><?php _e('Reset Quiz Views And Taken Stats', 'quiz-master-next'); ?></button>
76
+ <hr />
77
+ <h3>Addon Quiz Settings</h3>
78
+ <div id="tabs">
79
+ <ul>
80
+ <?php do_action('mlw_qmn_options_tab'); ?>
81
+ </ul>
82
+ <?php do_action('mlw_qmn_options_tab_content'); ?>
83
+ </div>
84
+ <?php do_action('mlw_qmn_quiz_tools'); ?>
85
+ <div id="mlw_reset_stats_dialog" title="Reset Stats For This Quiz" style="display:none;">
86
+ <p><?php _e('Are you sure you want to reset the stats to 0? All views and taken stats for this quiz will be reset. This is permanent and cannot be undone.', 'quiz-master-next'); ?></p>
87
+ <form action='' method='post'>
88
+ <input type='hidden' name='mlw_reset_quiz_stats' value='confirmation' />
89
+ <input type='hidden' name='mlw_reset_quiz_id' value='<?php echo $quiz_id; ?>' />
90
+ <p class='submit'><input type='submit' class='button-primary' value='<?php _e('Reset All Stats For Quiz', 'quiz-master-next'); ?>' /></p>
91
+ </form>
92
+ </div>
93
+ </div>
94
+ <?php
95
+ }
96
+ ?>
includes/qmn_question_types.php ADDED
@@ -0,0 +1,574 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ add_action("plugins_loaded", 'qmn_question_type_multiple_choice');
4
+ function qmn_question_type_multiple_choice()
5
+ {
6
+ global $mlwQuizMasterNext;
7
+ $mlwQuizMasterNext->pluginHelper->register_question_type(__("Multiple Choice", 'quiz-master-next'), 'qmn_multiple_choice_display', true, 'qmn_multiple_choice_review', 0);
8
+ }
9
+
10
+ function qmn_multiple_choice_display($id, $question, $answers)
11
+ {
12
+ $question_display = '';
13
+ global $mlwQuizMasterNext;
14
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
15
+ if ($required == 0) {$mlw_requireClass = "mlwRequiredRadio";} else {$mlw_requireClass = "";}
16
+ $question_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($question, ENT_QUOTES)."</span><br />";
17
+ $question_display .= "<div class='qmn_radio_answers $mlw_requireClass'>";
18
+ if (is_array($answers))
19
+ {
20
+ $mlw_answer_total = 0;
21
+ foreach($answers as $answer)
22
+ {
23
+ $mlw_answer_total++;
24
+ if ($answer[0] != "")
25
+ {
26
+ $question_display .= "<input type='radio' class='qmn_quiz_radio' name='question".$id."' id='question".$id."_".$mlw_answer_total."' value='".esc_attr($answer[0])."' /> <label for='question".$id."_".$mlw_answer_total."'>".htmlspecialchars_decode($answer[0], ENT_QUOTES)."</label>";
27
+ $question_display .= "<br />";
28
+ }
29
+ }
30
+ $question_display .= "<input type='radio' style='display: none;' name='question".$id."' id='question".$id."_none' checked='checked' value='No Answer Provided' />";
31
+ }
32
+ $question_display .= "</div>";
33
+ return $question_display;
34
+ }
35
+
36
+ function qmn_multiple_choice_review($id, $question, $answers)
37
+ {
38
+ $return_array = array(
39
+ 'points' => 0,
40
+ 'correct' => 'incorrect',
41
+ 'user_text' => '',
42
+ 'correct_text' => ''
43
+ );
44
+ if (isset($_POST["question".$id]))
45
+ {
46
+ $mlw_user_answer = $_POST["question".$id];
47
+ }
48
+ else
49
+ {
50
+ $mlw_user_answer = " ";
51
+ }
52
+ foreach($answers as $answer)
53
+ {
54
+ if (htmlspecialchars(stripslashes($mlw_user_answer), ENT_QUOTES) == esc_attr($answer[0]))
55
+ {
56
+ $return_array["points"] = $answer[1];
57
+ $return_array["user_text"] = strval(htmlspecialchars_decode($answer[0], ENT_QUOTES));
58
+ if ($answer[2] == 1)
59
+ {
60
+ $return_array["correct"] = "correct";
61
+ }
62
+ }
63
+ if ($answer[2] == 1)
64
+ {
65
+ $return_array["correct_text"] = htmlspecialchars_decode($answer[0], ENT_QUOTES);
66
+ }
67
+ }
68
+ return $return_array;
69
+ }
70
+
71
+ add_action("plugins_loaded", 'qmn_question_type_horizontal_multiple_choice');
72
+ function qmn_question_type_horizontal_multiple_choice()
73
+ {
74
+ global $mlwQuizMasterNext;
75
+ $mlwQuizMasterNext->pluginHelper->register_question_type(__("Horizontal Multiple Choice", 'quiz-master-next'), 'qmn_horizontal_multiple_choice_display', true, 'qmn_horizontal_multiple_choice_review', 1);
76
+ }
77
+
78
+ function qmn_horizontal_multiple_choice_display($id, $question, $answers)
79
+ {
80
+ $question_display = '';
81
+ global $mlwQuizMasterNext;
82
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
83
+ if ($required == 0) {$mlw_requireClass = "mlwRequiredRadio";} else {$mlw_requireClass = "";}
84
+ $question_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($question, ENT_QUOTES)."</span><br />";
85
+ $question_display .= "<div class='qmn_radio_answers $mlw_requireClass'>";
86
+ if (is_array($answers))
87
+ {
88
+ $mlw_answer_total = 0;
89
+ foreach($answers as $answer)
90
+ {
91
+ $mlw_answer_total++;
92
+ if ($answer[0] != "")
93
+ {
94
+ $question_display .= "<span class='mlw_horizontal_choice'><input type='radio' class='qmn_quiz_radio' name='question".$id."' id='question".$id."_".$mlw_answer_total."' value='".esc_attr($answer[0])."' /><label for='question".$id."_".$mlw_answer_total."'>".htmlspecialchars_decode($answer[0], ENT_QUOTES)."</label></span>";
95
+ }
96
+ }
97
+ $question_display .= "<input type='radio' style='display: none;' name='question".$id."' id='question".$id."_none' checked='checked' value='No Answer Provided' />";
98
+ }
99
+ $question_display .= "</div>";
100
+ $question_display .= "<br />";
101
+ return $question_display;
102
+ }
103
+
104
+ function qmn_horizontal_multiple_choice_review($id, $question, $answers)
105
+ {
106
+ $return_array = array(
107
+ 'points' => 0,
108
+ 'correct' => 'incorrect',
109
+ 'user_text' => '',
110
+ 'correct_text' => ''
111
+ );
112
+ if (isset($_POST["question".$id]))
113
+ {
114
+ $mlw_user_answer = $_POST["question".$id];
115
+ }
116
+ else
117
+ {
118
+ $mlw_user_answer = " ";
119
+ }
120
+ foreach($answers as $answer)
121
+ {
122
+ if (htmlspecialchars(stripslashes($mlw_user_answer), ENT_QUOTES) == esc_attr($answer[0]))
123
+ {
124
+ $return_array["points"] = $answer[1];
125
+ $return_array["user_text"] = strval(htmlspecialchars_decode($answer[0], ENT_QUOTES));
126
+ if ($answer[2] == 1)
127
+ {
128
+ $return_array["correct"] = "correct";
129
+ }
130
+ }
131
+ if ($answer[2] == 1)
132
+ {
133
+ $return_array["correct_text"] = htmlspecialchars_decode($answer[0], ENT_QUOTES);
134
+ }
135
+ }
136
+ return $return_array;
137
+ }
138
+
139
+ add_action("plugins_loaded", 'qmn_question_type_drop_down');
140
+ function qmn_question_type_drop_down()
141
+ {
142
+ global $mlwQuizMasterNext;
143
+ $mlwQuizMasterNext->pluginHelper->register_question_type(__("Drop Down", 'quiz-master-next'), 'qmn_drop_down_display', true, 'qmn_drop_down_review', 2);
144
+ }
145
+
146
+ function qmn_drop_down_display($id, $question, $answers)
147
+ {
148
+ $question_display = '';
149
+ global $mlwQuizMasterNext;
150
+ $question_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($question, ENT_QUOTES)."</span><br />";
151
+ $question_display .= "<select name='question".$id."'>";
152
+ if (is_array($answers))
153
+ {
154
+ $mlw_answer_total = 0;
155
+ foreach($answers as $answer)
156
+ {
157
+ $mlw_answer_total++;
158
+ if ($answer[0] != "")
159
+ {
160
+ $question_display .= "<option value='".esc_attr($answer[0])."'>".htmlspecialchars_decode($answer[0], ENT_QUOTES)."</option>";
161
+ }
162
+ }
163
+ }
164
+ $question_display .= "</select>";
165
+ $question_display .= "<br />";
166
+ return $question_display;
167
+ }
168
+
169
+ function qmn_drop_down_review($id, $question, $answers)
170
+ {
171
+ $return_array = array(
172
+ 'points' => 0,
173
+ 'correct' => 'incorrect',
174
+ 'user_text' => '',
175
+ 'correct_text' => ''
176
+ );
177
+ if (isset($_POST["question".$id]))
178
+ {
179
+ $mlw_user_answer = $_POST["question".$id];
180
+ }
181
+ else
182
+ {
183
+ $mlw_user_answer = " ";
184
+ }
185
+ foreach($answers as $answer)
186
+ {
187
+ if (htmlspecialchars(stripslashes($mlw_user_answer), ENT_QUOTES) == esc_attr($answer[0]))
188
+ {
189
+ $return_array["points"] = $answer[1];
190
+ $return_array["user_text"] = strval(htmlspecialchars_decode($answer[0], ENT_QUOTES));
191
+ if ($answer[2] == 1)
192
+ {
193
+ $return_array["correct"] = "correct";
194
+ }
195
+ }
196
+ if ($answer[2] == 1)
197
+ {
198
+ $return_array["correct_text"] = htmlspecialchars_decode($answer[0], ENT_QUOTES);
199
+ }
200
+ }
201
+ return $return_array;
202
+ }
203
+
204
+ add_action("plugins_loaded", 'qmn_question_type_small_open');
205
+ function qmn_question_type_small_open()
206
+ {
207
+ global $mlwQuizMasterNext;
208
+ $mlwQuizMasterNext->pluginHelper->register_question_type(__("Small Open Answer", 'quiz-master-next'), 'qmn_small_open_display', true, 'qmn_small_open_review', 3);
209
+ }
210
+
211
+ function qmn_small_open_display($id, $question, $answers)
212
+ {
213
+ $question_display = '';
214
+ global $mlwQuizMasterNext;
215
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
216
+ if ($required == 0) {$mlw_requireClass = "mlwRequiredText";} else {$mlw_requireClass = "";}
217
+ $question_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($question, ENT_QUOTES)."</span><br />";
218
+ $question_display .= "<input type='text' class='mlw_answer_open_text $mlw_requireClass' name='question".$id."' />";
219
+ $question_display .= "<br />";
220
+ return $question_display;
221
+ }
222
+
223
+ function qmn_small_open_review($id, $question, $answers)
224
+ {
225
+ $return_array = array(
226
+ 'points' => 0,
227
+ 'correct' => 'incorrect',
228
+ 'user_text' => '',
229
+ 'correct_text' => ''
230
+ );
231
+ if (isset($_POST["question".$id]))
232
+ {
233
+ $mlw_user_answer = $_POST["question".$id];
234
+ }
235
+ else
236
+ {
237
+ $mlw_user_answer = " ";
238
+ }
239
+ $return_array['user_text'] = strval(stripslashes(htmlspecialchars_decode($mlw_user_answer, ENT_QUOTES)));
240
+ foreach($answers as $answer)
241
+ {
242
+ $return_array['correct_text'] = strval(htmlspecialchars_decode($answer[0], ENT_QUOTES));
243
+ if (strtoupper($return_array['user_text']) == strtoupper($return_array['correct_text']))
244
+ {
245
+ $return_array['correct'] = "correct";
246
+ $return_array['points'] = $answer[1];
247
+ break;
248
+ }
249
+ }
250
+ return $return_array;
251
+ }
252
+
253
+ add_action("plugins_loaded", 'qmn_question_type_multiple_response');
254
+ function qmn_question_type_multiple_response()
255
+ {
256
+ global $mlwQuizMasterNext;
257
+ $mlwQuizMasterNext->pluginHelper->register_question_type(__("Multiple Response", 'quiz-master-next'), 'qmn_multiple_response_display', true, 'qmn_multiple_response_review', 4);
258
+ }
259
+
260
+ function qmn_multiple_response_display($id, $question, $answers)
261
+ {
262
+ $question_display = '';
263
+ global $mlwQuizMasterNext;
264
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
265
+ if ($required == 0) {$mlw_requireClass = "mlwRequiredCheck";} else {$mlw_requireClass = "";}
266
+ $question_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($question, ENT_QUOTES)."</span><br />";
267
+ $question_display .= "<div class='qmn_check_answers $mlw_requireClass'>";
268
+ if (is_array($answers))
269
+ {
270
+ $mlw_answer_total = 0;
271
+ foreach($answers as $answer)
272
+ {
273
+ $mlw_answer_total++;
274
+ if ($answer[0] != "")
275
+ {
276
+ $question_display .= "<input type='hidden' name='question".$id."' value='This value does not matter' />";
277
+ $question_display .= "<input type='checkbox' name='question".$id."_".$mlw_answer_total."' id='question".$id."_".$mlw_answer_total."' value='".esc_attr($answer[0])."' /> <label for='question".$id."_".$mlw_answer_total."'>".htmlspecialchars_decode($answer[0], ENT_QUOTES)."</label>";
278
+ $question_display .= "<br />";
279
+ }
280
+ }
281
+ }
282
+ $question_display .= "</div>";
283
+ return $question_display;
284
+ }
285
+
286
+ function qmn_multiple_response_review($id, $question, $answers)
287
+ {
288
+ $return_array = array(
289
+ 'points' => 0,
290
+ 'correct' => 'incorrect',
291
+ 'user_text' => '',
292
+ 'correct_text' => ''
293
+ );
294
+ $user_correct = 0;
295
+ $total_correct = 0;
296
+ $total_answers = count($answers);
297
+ foreach($answers as $answer)
298
+ {
299
+ for ($i = 1; $i <= $total_answers; $i++)
300
+ {
301
+ if (isset($_POST["question".$id."_".$i]) && htmlspecialchars(stripslashes($_POST["question".$id."_".$i]), ENT_QUOTES) == esc_attr($answer[0]))
302
+ {
303
+ $return_array["points"] = $answer[1];
304
+ $return_array["user_text"] .= strval(htmlspecialchars_decode($answer[0], ENT_QUOTES)).".";
305
+ if ($answer[2] == 1)
306
+ {
307
+ $user_correct += 1;
308
+ }
309
+ else
310
+ {
311
+ $user_correct = -1;
312
+ }
313
+ }
314
+ }
315
+ if ($answer[2] == 1)
316
+ {
317
+ $return_array["correct_text"] .= htmlspecialchars_decode($answer[0], ENT_QUOTES).".";
318
+ $total_correct++;
319
+ }
320
+ }
321
+ if ($user_correct == $total_correct)
322
+ {
323
+ $return_array["correct"] = "correct";
324
+ }
325
+ return $return_array;
326
+ }
327
+
328
+ add_action("plugins_loaded", 'qmn_question_type_large_open');
329
+ function qmn_question_type_large_open()
330
+ {
331
+ global $mlwQuizMasterNext;
332
+ $mlwQuizMasterNext->pluginHelper->register_question_type(__("Large Open Answer", 'quiz-master-next'), 'qmn_large_open_display', true, 'qmn_large_open_review', 5);
333
+ }
334
+
335
+ function qmn_large_open_display($id, $question, $answers)
336
+ {
337
+ $question_display = '';
338
+ global $mlwQuizMasterNext;
339
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
340
+ if ($required == 0) {$mlw_requireClass = "mlwRequiredText";} else {$mlw_requireClass = "";}
341
+ $question_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($question, ENT_QUOTES)."</span><br />";
342
+ $question_display .= "<textarea class='mlw_answer_open_text $mlw_requireClass' cols='70' rows='5' name='question".$id."' /></textarea>";
343
+ $question_display .= "<br />";
344
+ return $question_display;
345
+ }
346
+
347
+ function qmn_large_open_review($id, $question, $answers)
348
+ {
349
+ $return_array = array(
350
+ 'points' => 0,
351
+ 'correct' => 'incorrect',
352
+ 'user_text' => '',
353
+ 'correct_text' => ''
354
+ );
355
+ if (isset($_POST["question".$id]))
356
+ {
357
+ $mlw_user_answer = $_POST["question".$id];
358
+ }
359
+ else
360
+ {
361
+ $mlw_user_answer = " ";
362
+ }
363
+ $return_array['user_text'] = strval(stripslashes(htmlspecialchars_decode($mlw_user_answer, ENT_QUOTES)));
364
+ foreach($answers as $answer)
365
+ {
366
+ $return_array['correct_text'] = strval(htmlspecialchars_decode($answer[0], ENT_QUOTES));
367
+ if (strtoupper($return_array['user_text']) == strtoupper($return_array['correct_text']))
368
+ {
369
+ $return_array['correct'] = "correct";
370
+ $return_array['points'] = $answer[1];
371
+ break;
372
+ }
373
+ }
374
+ return $return_array;
375
+ }
376
+
377
+ add_action("plugins_loaded", 'qmn_question_type_text_block');
378
+ function qmn_question_type_text_block()
379
+ {
380
+ global $mlwQuizMasterNext;
381
+ $mlwQuizMasterNext->pluginHelper->register_question_type(__("Text Block", 'quiz-master-next'), 'qmn_text_block_display', false, null, 6);
382
+ }
383
+
384
+ function qmn_text_block_display($id, $question, $answers)
385
+ {
386
+ $question_display = '';
387
+ $question_display .= htmlspecialchars_decode($question, ENT_QUOTES);
388
+ $question_display .= "<br />";
389
+ return $question_display;
390
+ }
391
+
392
+ add_action("plugins_loaded", 'qmn_question_type_number');
393
+ function qmn_question_type_number()
394
+ {
395
+ global $mlwQuizMasterNext;
396
+ $mlwQuizMasterNext->pluginHelper->register_question_type(__("Number", 'quiz-master-next'), 'qmn_number_display', true, 'qmn_number_review', 7);
397
+ }
398
+
399
+ function qmn_number_display($id, $question, $answers)
400
+ {
401
+ $question_display = '';
402
+ global $mlwQuizMasterNext;
403
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
404
+ if ($required == 0) {$mlw_requireClass = "mlwRequiredNumber";} else {$mlw_requireClass = "";}
405
+ $question_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($question, ENT_QUOTES)."</span><br />";
406
+ $question_display .= "<input type='number' class='mlw_answer_number $mlw_requireClass' name='question".$id."' />";
407
+ $question_display .= "<br />";
408
+ return $question_display;
409
+ }
410
+
411
+ function qmn_number_review($id, $question, $answers)
412
+ {
413
+ $return_array = array(
414
+ 'points' => 0,
415
+ 'correct' => 'incorrect',
416
+ 'user_text' => '',
417
+ 'correct_text' => ''
418
+ );
419
+ if (isset($_POST["question".$id]))
420
+ {
421
+ $mlw_user_answer = $_POST["question".$id];
422
+ }
423
+ else
424
+ {
425
+ $mlw_user_answer = " ";
426
+ }
427
+ $return_array['user_text'] = strval(stripslashes(htmlspecialchars_decode($mlw_user_answer, ENT_QUOTES)));
428
+ foreach($answers as $answer)
429
+ {
430
+ $return_array['correct_text'] = strval(htmlspecialchars_decode($answer[0], ENT_QUOTES));
431
+ if (strtoupper($return_array['user_text']) == strtoupper($return_array['correct_text']))
432
+ {
433
+ $return_array['correct'] = "correct";
434
+ $return_array['points'] = $answer[1];
435
+ break;
436
+ }
437
+ }
438
+ return $return_array;
439
+ }
440
+
441
+ add_action("plugins_loaded", 'qmn_question_type_accept');
442
+ function qmn_question_type_accept()
443
+ {
444
+ global $mlwQuizMasterNext;
445
+ $mlwQuizMasterNext->pluginHelper->register_question_type(__("Accept", 'quiz-master-next'), 'qmn_accept_display', false, null, 8);
446
+ }
447
+
448
+ function qmn_accept_display($id, $question, $answers)
449
+ {
450
+ $question_display = '';
451
+ global $mlwQuizMasterNext;
452
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
453
+ if ($required == 0) {$mlw_requireClass = "mlwRequiredAccept";} else {$mlw_requireClass = "";}
454
+ $question_display .= "<input type='checkbox' id='mlwAcceptance' class='$mlw_requireClass ' />";
455
+ $question_display .= "<label for='mlwAcceptance'><span class='mlw_qmn_question'>".htmlspecialchars_decode($question, ENT_QUOTES)."</span></label>";
456
+ $question_display .= "<br />";
457
+ return $question_display;
458
+ }
459
+
460
+ add_action("plugins_loaded", 'qmn_question_type_captcha');
461
+ function qmn_question_type_captcha()
462
+ {
463
+ global $mlwQuizMasterNext;
464
+ $mlwQuizMasterNext->pluginHelper->register_question_type(__("Captcha", 'quiz-master-next'), 'qmn_captcha_display', false, null, 9);
465
+ }
466
+
467
+ function qmn_captcha_display($id, $question, $answers)
468
+ {
469
+ $question_display = '';
470
+ global $mlwQuizMasterNext;
471
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
472
+ if ($required == 0) {$mlw_requireClass = "mlwRequiredCaptcha";} else {$mlw_requireClass = "";}
473
+ $question_display .= "<div class='mlw_captchaWrap'>";
474
+ $question_display .= "<canvas alt='' id='mlw_captcha' class='mlw_captcha' width='100' height='50'></canvas>";
475
+ $question_display .= "</div>";
476
+ $question_display .= "<span class='mlw_qmn_question'>";
477
+ $question_display .= htmlspecialchars_decode($question, ENT_QUOTES)."</span><br />";
478
+ $question_display .= "<input type='text' class='mlw_answer_open_text $mlw_requireClass' id='mlw_captcha_text' name='mlw_user_captcha'/>";
479
+ $question_display .= "<input type='hidden' name='mlw_code_captcha' id='mlw_code_captcha' value='none' />";
480
+ $question_display .= "<br />";
481
+ $question_display .= "<script>
482
+ var mlw_code = '';
483
+ var mlw_chars = '0123456789ABCDEFGHIJKL!@#$%^&*()MNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
484
+ var mlw_code_length = 5;
485
+ for (var i=0; i<mlw_code_length; i++) {
486
+ var rnum = Math.floor(Math.random() * mlw_chars.length);
487
+ mlw_code += mlw_chars.substring(rnum,rnum+1);
488
+ }
489
+ var mlw_captchaCTX = document.getElementById('mlw_captcha').getContext('2d');
490
+ mlw_captchaCTX.font = 'normal 24px Verdana';
491
+ mlw_captchaCTX.strokeStyle = '#000000';
492
+ mlw_captchaCTX.clearRect(0,0,100,50);
493
+ mlw_captchaCTX.strokeText(mlw_code,10,30,70);
494
+ mlw_captchaCTX.textBaseline = 'middle';
495
+ document.getElementById('mlw_code_captcha').value = mlw_code;
496
+ </script>
497
+ ";
498
+ return $question_display;
499
+ }
500
+
501
+ add_action("plugins_loaded", 'qmn_question_type_horizontal_multiple_response');
502
+ function qmn_question_type_horizontal_multiple_response()
503
+ {
504
+ global $mlwQuizMasterNext;
505
+ $mlwQuizMasterNext->pluginHelper->register_question_type(__("Horizontal Multiple Response", 'quiz-master-next'), 'qmn_horizontal_multiple_response_display', true, 'qmn_horizontal_multiple_response_review', 10);
506
+ }
507
+
508
+ function qmn_horizontal_multiple_response_display($id, $question, $answers)
509
+ {
510
+ $question_display = '';
511
+ global $mlwQuizMasterNext;
512
+ $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
513
+ if ($required == 0) {$mlw_requireClass = "mlwRequiredCheck";} else {$mlw_requireClass = "";}
514
+ $question_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($question, ENT_QUOTES)."</span><br />";
515
+ $question_display .= "<div class='qmn_check_answers $mlw_requireClass'>";
516
+ if (is_array($answers))
517
+ {
518
+ $mlw_answer_total = 0;
519
+ foreach($answers as $answer)
520
+ {
521
+ $mlw_answer_total++;
522
+ if ($answer[0] != "")
523
+ {
524
+ $question_display .= "<input type='hidden' name='question".$id."' value='This value does not matter' />";
525
+ $question_display .= "<span class='mlw_horizontal_multiple'><input type='checkbox' name='question".$id."_".$mlw_answer_total."' id='question".$id."_".$mlw_answer_total."' value='".esc_attr($answer[0])."' /> <label for='question".$id."_".$mlw_answer_total."'>".htmlspecialchars_decode($answer[0], ENT_QUOTES)."&nbsp;</label></span>";
526
+ }
527
+ }
528
+ }
529
+ $question_display .= "</div>";
530
+ return $question_display;
531
+ }
532
+
533
+ function qmn_horizontal_multiple_response_review($id, $question, $answers)
534
+ {
535
+ $return_array = array(
536
+ 'points' => 0,
537
+ 'correct' => 'incorrect',
538
+ 'user_text' => '',
539
+ 'correct_text' => ''
540
+ );
541
+ $user_correct = 0;
542
+ $total_correct = 0;
543
+ $total_answers = count($answers);
544
+ foreach($answers as $answer)
545
+ {
546
+ for ($i = 1; $i <= $total_answers; $i++)
547
+ {
548
+ if (isset($_POST["question".$id."_".$i]) && htmlspecialchars(stripslashes($_POST["question".$id."_".$i]), ENT_QUOTES) == esc_attr($answer[0]))
549
+ {
550
+ $return_array["points"] = $answer[1];
551
+ $return_array["user_text"] .= strval(htmlspecialchars_decode($answer[0], ENT_QUOTES)).".";
552
+ if ($answer[2] == 1)
553
+ {
554
+ $user_correct += 1;
555
+ }
556
+ else
557
+ {
558
+ $user_correct = -1;
559
+ }
560
+ }
561
+ }
562
+ if ($answer[2] == 1)
563
+ {
564
+ $return_array["correct_text"] .= htmlspecialchars_decode($answer[0], ENT_QUOTES).".";
565
+ $total_correct++;
566
+ }
567
+ }
568
+ if ($user_correct == $total_correct)
569
+ {
570
+ $return_array["correct"] = "correct";
571
+ }
572
+ return $return_array;
573
+ }
574
+ ?>
includes/qmn_quiz.php ADDED
@@ -0,0 +1,1310 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This class generates the contents of the quiz shortcode
4
+ *
5
+ * @since 4.0.0
6
+ */
7
+ class QMNQuizManager
8
+ {
9
+ /**
10
+ * Main Construct Function
11
+ *
12
+ * Call functions within class
13
+ *
14
+ * @since 4.0.0
15
+ * @uses QMNQuizManager::add_hooks() Adds actions to hooks and filters
16
+ * @return void
17
+ */
18
+ public function __construct()
19
+ {
20
+ $this->add_hooks();
21
+ }
22
+
23
+ /**
24
+ * Add Hooks
25
+ *
26
+ * Adds functions to relavent hooks and filters
27
+ *
28
+ * @since 4.0.0
29
+ * @return void
30
+ */
31
+ public function add_hooks()
32
+ {
33
+ add_shortcode('mlw_quizmaster', array($this, 'display_shortcode'));
34
+ }
35
+
36
+ /**
37
+ * Generates Content For Quiz Shortcode
38
+ *
39
+ * Generates the content for the [mlw_quizmaster] shortcode
40
+ *
41
+ * @since 4.0.0
42
+ * @uses QMNQuizManager:load_quiz_options() Loads quiz
43
+ * @uses QMNQuizManager:load_questions() Loads questions
44
+ * @uses QMNQuizManager:create_answer_array() Prepares answers
45
+ * @uses QMNQuizManager:display_quiz() Generates and prepares quiz page
46
+ * @uses QMNQuizManager:display_results() Generates and prepares results page
47
+ * @return string The content for the shortcode
48
+ */
49
+ public function display_shortcode($atts)
50
+ {
51
+ extract(shortcode_atts(array(
52
+ 'quiz' => 0
53
+ ), $atts));
54
+
55
+ global $wpdb;
56
+ global $mlwQuizMasterNext;
57
+ global $qmn_allowed_visit;
58
+ $qmn_allowed_visit = true;
59
+ $mlwQuizMasterNext->quizCreator->set_id($quiz);
60
+ date_default_timezone_set(get_option('timezone_string'));
61
+ $return_display = '';
62
+ $qmn_quiz_options = $this->load_quiz_options($quiz);
63
+
64
+ $qmn_array_for_variables = array(
65
+ 'quiz_id' => $qmn_quiz_options->quiz_id,
66
+ 'quiz_name' => $qmn_quiz_options->quiz_name,
67
+ 'quiz_system' => $qmn_quiz_options->system
68
+ );
69
+
70
+ $return_display = apply_filters('qmn_begin_shortcode', $return_display, $qmn_quiz_options, $qmn_array_for_variables);
71
+
72
+ if ($qmn_allowed_visit && !isset($_POST["complete_quiz"]) && $qmn_quiz_options->quiz_name != '')
73
+ {
74
+ $qmn_quiz_questions = $this->load_questions($quiz, $qmn_quiz_options, true);
75
+ $qmn_quiz_answers = $this->create_answer_array($qmn_quiz_questions);
76
+ $return_display .= $this->display_quiz($qmn_quiz_options, $qmn_quiz_questions, $qmn_quiz_answers, $qmn_array_for_variables);
77
+ }
78
+ elseif (isset($_POST["complete_quiz"]) && $_POST["complete_quiz"] == "confirmation")
79
+ {
80
+ $qmn_quiz_questions = $this->load_questions($quiz, $qmn_quiz_options, false);
81
+ $qmn_quiz_answers = $this->create_answer_array($qmn_quiz_questions);
82
+ $return_display .= $this->display_results($qmn_quiz_options, $qmn_quiz_questions, $qmn_quiz_answers, $qmn_array_for_variables);
83
+ }
84
+ else
85
+ {
86
+ //return $return_display;
87
+ }
88
+
89
+ $return_display = apply_filters('qmn_end_shortcode', $return_display, $qmn_quiz_options, $qmn_array_for_variables);
90
+ return $return_display;
91
+ }
92
+
93
+ /**
94
+ * Loads Quiz
95
+ *
96
+ * Retrieves the quiz from the database
97
+ *
98
+ * @since 4.0.0
99
+ * @param int $quiz_id The id for the quiz
100
+ * @return array Columns for the row from the database of the quiz
101
+ */
102
+ public function load_quiz_options($quiz_id)
103
+ {
104
+ global $wpdb;
105
+ return $wpdb->get_row($wpdb->prepare('SELECT * FROM '.$wpdb->prefix.'mlw_quizzes WHERE quiz_id=%d AND deleted=0', $quiz_id));
106
+ }
107
+
108
+ /**
109
+ * Loads Questions
110
+ *
111
+ * Retrieves the questions from the database
112
+ *
113
+ * @since 4.0.0
114
+ * @param int $quiz_id The id for the quiz
115
+ * @param array $quiz_options The database row for the quiz
116
+ * @return array The questions for the quiz
117
+ */
118
+ public function load_questions($quiz_id, $quiz_options, $is_quiz_page)
119
+ {
120
+ global $wpdb;
121
+ $order_by_sql = "ORDER BY question_order ASC";
122
+ $limit_sql = '';
123
+ if ($quiz_options->randomness_order == 1 || $quiz_options->randomness_order == 2)
124
+ {
125
+ $order_by_sql = "ORDER BY rand()";
126
+ }
127
+ if ($is_quiz_page && $quiz_options->question_from_total != 0)
128
+ {
129
+ $limit_sql = " LIMIT ".$quiz_options->question_from_total;
130
+ }
131
+ return $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$wpdb->prefix."mlw_questions WHERE quiz_id=%d AND deleted=0 ".$order_by_sql.$limit_sql, $quiz_id));
132
+ }
133
+
134
+ /**
135
+ * Prepares Answers
136
+ *
137
+ * Prepares or creates the answer array for the quiz
138
+ *
139
+ * @since 4.0.0
140
+ * @param array $questions The questions for the quiz
141
+ * @return array The answers for the quiz
142
+ */
143
+ public function create_answer_array($questions)
144
+ {
145
+ //Load and prepare answer arrays
146
+ $mlw_qmn_answer_arrays = array();
147
+ foreach($questions as $mlw_question_info) {
148
+ if (is_serialized($mlw_question_info->answer_array) && is_array(@unserialize($mlw_question_info->answer_array)))
149
+ {
150
+ $mlw_qmn_answer_array_each = @unserialize($mlw_question_info->answer_array);
151
+ $mlw_qmn_answer_arrays[$mlw_question_info->question_id] = $mlw_qmn_answer_array_each;
152
+ }
153
+ else
154
+ {
155
+ $mlw_answer_array_correct = array(0, 0, 0, 0, 0, 0);
156
+ $mlw_answer_array_correct[$mlw_question_info->correct_answer-1] = 1;
157
+ $mlw_qmn_answer_arrays[$mlw_question_info->question_id] = array(
158
+ array($mlw_question_info->answer_one, $mlw_question_info->answer_one_points, $mlw_answer_array_correct[0]),
159
+ array($mlw_question_info->answer_two, $mlw_question_info->answer_two_points, $mlw_answer_array_correct[1]),
160
+ array($mlw_question_info->answer_three, $mlw_question_info->answer_three_points, $mlw_answer_array_correct[2]),
161
+ array($mlw_question_info->answer_four, $mlw_question_info->answer_four_points, $mlw_answer_array_correct[3]),
162
+ array($mlw_question_info->answer_five, $mlw_question_info->answer_five_points, $mlw_answer_array_correct[4]),
163
+ array($mlw_question_info->answer_six, $mlw_question_info->answer_six_points, $mlw_answer_array_correct[5]));
164
+ }
165
+ }
166
+ return $mlw_qmn_answer_arrays;
167
+ }
168
+
169
+ /**
170
+ * Generates Content Quiz Page
171
+ *
172
+ * Generates the content for the quiz page part of the shortcode
173
+ *
174
+ * @since 4.0.0
175
+ * @param array $qmn_quiz_options The database row of the quiz
176
+ * @param array $qmn_quiz_questions The questions of the quiz
177
+ * @param array $qmn_quiz_answers The answers of the quiz
178
+ * @param array $qmn_array_for_variables The array of results for the quiz
179
+ * @uses QMNQuizManager:display_begin_section() Creates display for beginning section
180
+ * @uses QMNQuizManager:display_questions() Creates display for questions
181
+ * @uses QMNQuizManager:display_comment_section() Creates display for comment section
182
+ * @uses QMNQuizManager:display_end_section() Creates display for end section
183
+ * @return string The content for the quiz page section
184
+ */
185
+ public function display_quiz($qmn_quiz_options, $qmn_quiz_questions, $qmn_quiz_answers, $qmn_array_for_variables)
186
+ {
187
+ global $qmn_allowed_visit;
188
+ $quiz_display = '';
189
+ $quiz_display = apply_filters('qmn_begin_quiz', $quiz_display, $qmn_quiz_options, $qmn_array_for_variables);
190
+ if (!$qmn_allowed_visit)
191
+ {
192
+ return $quiz_display;
193
+ }
194
+ wp_enqueue_script( 'json2' );
195
+ wp_enqueue_script( 'jquery' );
196
+ wp_enqueue_script( 'jquery-ui-core' );
197
+ wp_enqueue_script( 'jquery-effects-core' );
198
+ wp_enqueue_script( 'jquery-effects-slide' );
199
+ wp_enqueue_script( 'jquery-ui-dialog' );
200
+ wp_enqueue_script( 'jquery-ui-button' );
201
+ wp_enqueue_script( 'jquery-ui-tooltip' );
202
+ wp_enqueue_style( 'qmn_jquery_redmond_theme', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css' );
203
+
204
+ ?>
205
+ <script>
206
+ var email_error = '<?php _e('Not a valid e-mail address!', 'quiz-master-next'); ?>';
207
+ var number_error = '<?php _e('This field must be a number!', 'quiz-master-next'); ?>';
208
+ var incorrect_error = '<?php _e('The entered text is not correct!', 'quiz-master-next'); ?>';
209
+ var empty_error = '<?php _e('Please complete all required fields!', 'quiz-master-next'); ?>';
210
+ </script>
211
+ <?php
212
+ wp_enqueue_script( 'qmn_quiz', plugins_url( 'js/qmn_quiz.js' , __FILE__ ) );
213
+ wp_enqueue_script( 'math_jax', '//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' );
214
+
215
+ wp_enqueue_style( 'qmn_quiz_style', plugins_url( 'css/qmn_quiz.css' , __FILE__ ) );
216
+ if ($qmn_quiz_options->theme_selected == "default")
217
+ {
218
+ echo "<style type='text/css'>".$qmn_quiz_options->quiz_stye."</style>";
219
+ }
220
+ else
221
+ {
222
+ echo "<link type='text/css' href='".get_option('mlw_qmn_theme_'.$qmn_quiz_options->theme_selected)."' rel='stylesheet' />";
223
+ }
224
+
225
+ global $qmn_total_questions;
226
+ $qmn_total_questions = 0;
227
+ global $mlw_qmn_section_count;
228
+ $mlw_qmn_section_count = 1;
229
+
230
+ $quiz_display .= "<div class='mlw_qmn_quiz'>";
231
+ $quiz_display .= "<form name='quizForm' id='quizForm' action='' method='post' class='mlw_quiz_form' onsubmit='return mlw_validateForm()' novalidate >";
232
+ $quiz_display .= "<span id='mlw_top_of_quiz'></span>";
233
+ $quiz_display = apply_filters('qmn_begin_quiz_form', $quiz_display, $qmn_quiz_options, $qmn_array_for_variables);
234
+ $quiz_display .= $this->display_begin_section($qmn_quiz_options, $qmn_array_for_variables);
235
+ $quiz_display = apply_filters('qmn_begin_quiz_questions', $quiz_display, $qmn_quiz_options, $qmn_array_for_variables);
236
+ $quiz_display .= $this->display_questions($qmn_quiz_options, $qmn_quiz_questions, $qmn_quiz_answers);
237
+ $quiz_display = apply_filters('qmn_before_comment_section', $quiz_display, $qmn_quiz_options, $qmn_array_for_variables);
238
+ $quiz_display .= $this->display_comment_section($qmn_quiz_options, $qmn_array_for_variables);
239
+ $quiz_display = apply_filters('qmn_after_comment_section', $quiz_display, $qmn_quiz_options, $qmn_array_for_variables);
240
+ $quiz_display .= $this->display_end_section($qmn_quiz_options, $qmn_array_for_variables);
241
+ $quiz_display .= "<input type='hidden' name='total_questions' id='total_questions' value='".$qmn_total_questions."'/>";
242
+ $quiz_display .= "<input type='hidden' name='timer' id='timer' value='0'/>";
243
+ $quiz_display .= "<input type='hidden' name='complete_quiz' value='confirmation' />";
244
+ $quiz_display = apply_filters('qmn_end_quiz_form', $quiz_display, $qmn_quiz_options, $qmn_array_for_variables);
245
+ $quiz_display .= "</form>";
246
+ $quiz_display .= "</div>";
247
+
248
+ $quiz_display = apply_filters('qmn_end_quiz', $quiz_display, $qmn_quiz_options, $qmn_array_for_variables);
249
+ return $quiz_display;
250
+ }
251
+
252
+ /**
253
+ * Creates Display For Beginning Section
254
+ *
255
+ * Generates the content for the beginning section of the quiz page
256
+ *
257
+ * @since 4.0.0
258
+ * @param array $qmn_quiz_options The database row of the quiz
259
+ * @param array $qmn_array_for_variables The array of results for the quiz
260
+ * @return string The content for the beginning section
261
+ */
262
+ public function display_begin_section($qmn_quiz_options, $qmn_array_for_variables)
263
+ {
264
+ global $mlw_qmn_section_count;
265
+ $section_display = "<div class='quiz_section quiz_begin slide$mlw_qmn_section_count'>";
266
+
267
+ $message_before = htmlspecialchars_decode($qmn_quiz_options->message_before, ENT_QUOTES);
268
+ $message_before = apply_filters( 'mlw_qmn_template_variable_quiz_page', $message_before, $qmn_array_for_variables);
269
+
270
+ $section_display .= "<span class='mlw_qmn_message_before'>$message_before</span><br />";
271
+ $section_display .= "<span name='mlw_error_message' id='mlw_error_message' class='qmn_error'></span><br />";
272
+
273
+ if ($qmn_quiz_options->contact_info_location == 0)
274
+ {
275
+ $section_display .= mlwDisplayContactInfo($qmn_quiz_options);
276
+ }
277
+ $section_display .= "</div>";
278
+ return $section_display;
279
+ }
280
+
281
+ /**
282
+ * Creates Display For Questions
283
+ *
284
+ * Generates the content for the questions part of the quiz page
285
+ *
286
+ * @since 4.0.0
287
+ * @param array $qmn_quiz_options The database row of the quiz
288
+ * @param array $qmn_quiz_questions The questions of the quiz
289
+ * @param array $qmn_quiz_answers The answers of the quiz
290
+ * @uses QMNPluginHelper:display_question() Displays a question
291
+ * @return string The content for the questions section
292
+ */
293
+ public function display_questions($qmn_quiz_options, $qmn_quiz_questions, $qmn_quiz_answers)
294
+ {
295
+ $question_display = '';
296
+ global $mlwQuizMasterNext;
297
+ global $qmn_total_questions;
298
+ global $mlw_qmn_section_count;
299
+ $question_id_list = '';
300
+ foreach($qmn_quiz_questions as $mlw_question)
301
+ {
302
+ $question_id_list .= $mlw_question->question_id."Q";
303
+ $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
304
+ $question_display .= "<div class='quiz_section slide".$mlw_qmn_section_count."'>";
305
+
306
+ $question_display .= $mlwQuizMasterNext->pluginHelper->display_question($mlw_question->question_type_new, $mlw_question->question_id, $qmn_quiz_options);
307
+
308
+ if ($mlw_question->comments == 0)
309
+ {
310
+ $question_display .= "<input type='text' class='mlw_qmn_question_comment' x-webkit-speech id='mlwComment".$mlw_question->question_id."' name='mlwComment".$mlw_question->question_id."' value='".esc_attr(htmlspecialchars_decode($qmn_quiz_options->comment_field_text, ENT_QUOTES))."' onclick='clear_field(this)'/>";
311
+ $question_display .= "<br />";
312
+ }
313
+ if ($mlw_question->comments == 2)
314
+ {
315
+ $question_display .= "<textarea cols='70' rows='5' class='mlw_qmn_question_comment' id='mlwComment".$mlw_question->question_id."' name='mlwComment".$mlw_question->question_id."' onclick='clear_field(this)'>".htmlspecialchars_decode($qmn_quiz_options->comment_field_text, ENT_QUOTES)."</textarea>";
316
+ $question_display .= "<br />";
317
+ }
318
+ if ($mlw_question->hints != "")
319
+ {
320
+ $question_display .= "<span title=\"".htmlspecialchars_decode($mlw_question->hints, ENT_QUOTES)."\" class='mlw_qmn_hint_link'>".__('Hint', 'quiz-master-next')."</span>";
321
+ $question_display .= "<br /><br />";
322
+ }
323
+ $question_display .= "</div>";
324
+ if ( $qmn_quiz_options->pagination == 0) { $question_display .= "<br />"; }
325
+ }
326
+ $question_display .= "<input type='hidden' name='qmn_question_list' value='$question_id_list' />";
327
+ return $question_display;
328
+ }
329
+
330
+ /**
331
+ * Creates Display For Comment Section
332
+ *
333
+ * Generates the content for the comment section part of the quiz page
334
+ *
335
+ * @since 4.0.0
336
+ * @param array $qmn_quiz_options The database row of the quiz
337
+ * @param array $qmn_array_for_variables The array of results for the quiz
338
+ * @return string The content for the comment section
339
+ */
340
+ public function display_comment_section($qmn_quiz_options, $qmn_array_for_variables)
341
+ {
342
+ global $mlw_qmn_section_count;
343
+ $comment_display = '';
344
+ if ($qmn_quiz_options->comment_section == 0)
345
+ {
346
+ $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
347
+ $comment_display .= "<div class='quiz_section slide".$mlw_qmn_section_count."'>";
348
+ $message_comments = htmlspecialchars_decode($qmn_quiz_options->message_comment, ENT_QUOTES);
349
+ $message_comments = apply_filters( 'mlw_qmn_template_variable_quiz_page', $message_comments, $qmn_array_for_variables);
350
+ $comment_display .= "<label for='mlwQuizComments' class='mlw_qmn_comment_section_text'>$message_comments</label><br />";
351
+ $comment_display .= "<textarea cols='60' rows='10' id='mlwQuizComments' name='mlwQuizComments' ></textarea>";
352
+ $comment_display .= "</div>";
353
+ if ( $qmn_quiz_options->pagination == 0) { $comment_display .= "<br /><br />"; }
354
+ }
355
+ return $comment_display;
356
+ }
357
+
358
+ /**
359
+ * Creates Display For End Section Of Quiz Page
360
+ *
361
+ * Generates the content for the end section of the quiz page
362
+ *
363
+ * @since 4.0.0
364
+ * @param array $qmn_quiz_options The database row of the quiz
365
+ * @param array $qmn_array_for_variables The array of results for the quiz
366
+ * @return string The content for the end section
367
+ */
368
+ public function display_end_section($qmn_quiz_options, $qmn_array_for_variables)
369
+ {
370
+ global $mlw_qmn_section_count;
371
+ $section_display = '';
372
+ $section_display .= "<br />";
373
+ $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
374
+ $section_display .= "<div class='quiz_section slide$mlw_qmn_section_count quiz_end'>";
375
+ if ($qmn_quiz_options->message_end_template != '')
376
+ {
377
+ $message_end = htmlspecialchars_decode($qmn_quiz_options->message_end_template, ENT_QUOTES);
378
+ $message_end = apply_filters( 'mlw_qmn_template_variable_quiz_page', $message_end, $qmn_array_for_variables);
379
+ $section_display .= "<span class='mlw_qmn_message_end'>$message_end</span>";
380
+ $section_display .= "<br /><br />";
381
+ }
382
+ if ($qmn_quiz_options->contact_info_location == 1)
383
+ {
384
+ $section_display .= mlwDisplayContactInfo($qmn_quiz_options);
385
+ }
386
+
387
+ //Legacy Code
388
+ ob_start();
389
+ do_action('mlw_qmn_end_quiz_section');
390
+ $section_display .= ob_get_contents();
391
+ ob_end_clean();
392
+
393
+ $section_display .= "<input type='submit' value='".esc_attr(htmlspecialchars_decode($qmn_quiz_options->submit_button_text, ENT_QUOTES))."' />";
394
+ $section_display .= "<span name='mlw_error_message_bottom' id='mlw_error_message_bottom' class='qmn_error'></span><br />";
395
+ $section_display .= "</div>";
396
+
397
+ return $section_display;
398
+ }
399
+
400
+ /**
401
+ * Generates Content Results Page
402
+ *
403
+ * Generates the content for the results page part of the shortcode
404
+ *
405
+ * @since 4.0.0
406
+ * @param array $qmn_quiz_options The database row of the quiz
407
+ * @param array $qmn_quiz_questions The questions of the quiz
408
+ * @param array $qmn_quiz_answers The answers of the quiz
409
+ * @param array $qmn_array_for_variables The array of results for the quiz
410
+ * @uses QMNQuizManager:check_answers() Creates display for beginning section
411
+ * @uses QMNQuizManager:check_comment_section() Creates display for questions
412
+ * @uses QMNQuizManager:generate_certificate() Creates display for comment section
413
+ * @uses QMNQuizManager:display_results_text() Creates display for end section
414
+ * @uses QMNQuizManager:display_social() Creates display for comment section
415
+ * @uses QMNQuizManager:send_user_email() Creates display for end section
416
+ * @uses QMNQuizManager:send_admin_email() Creates display for end section
417
+ * @return string The content for the results page section
418
+ */
419
+ public function display_results($qmn_quiz_options, $qmn_quiz_questions, $qmn_quiz_answers, $qmn_array_for_variables)
420
+ {
421
+ global $qmn_allowed_visit;
422
+ $result_display = '';
423
+ $result_display = apply_filters('qmn_begin_results', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
424
+ if (!$qmn_allowed_visit)
425
+ {
426
+ return $result_display;
427
+ }
428
+ wp_enqueue_script( 'math_jax', '//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' );
429
+ wp_enqueue_style( 'qmn_quiz_style', plugins_url( 'css/qmn_quiz.css' , __FILE__ ) );
430
+ if ($qmn_quiz_options->theme_selected == "default")
431
+ {
432
+ echo "<style type='text/css'>".$qmn_quiz_options->quiz_stye."</style>";
433
+ }
434
+ else
435
+ {
436
+ echo "<link type='text/css' href='".get_option('mlw_qmn_theme_'.$qmn_quiz_options->theme_selected)."' rel='stylesheet' />";
437
+ }
438
+
439
+ $mlw_user_name = isset($_POST["mlwUserName"]) ? $_POST["mlwUserName"] : 'None';
440
+ $mlw_user_comp = isset($_POST["mlwUserComp"]) ? $_POST["mlwUserComp"] : 'None';
441
+ $mlw_user_email = isset($_POST["mlwUserEmail"]) ? $_POST["mlwUserEmail"] : 'None';
442
+ $mlw_user_phone = isset($_POST["mlwUserPhone"]) ? $_POST["mlwUserPhone"] : 'None';
443
+ $mlw_qmn_timer = isset($_POST["timer"]) ? $_POST["timer"] : 0;
444
+ $qmn_array_for_variables['user_name'] = $mlw_user_name;
445
+ $qmn_array_for_variables['user_business'] = $mlw_user_comp;
446
+ $qmn_array_for_variables['user_email'] = $mlw_user_email;
447
+ $qmn_array_for_variables['user_phone'] = $mlw_user_phone;
448
+ $qmn_array_for_variables['user_id'] = get_current_user_id();
449
+ $qmn_array_for_variables['timer'] = $mlw_qmn_timer;
450
+
451
+
452
+ $result_display .= "<div id='top_of_results'></div>";
453
+ $result_display .= "<script>
454
+ window.location.hash='top_of_results';
455
+ </script>";
456
+ ?>
457
+ <script type="text/javascript">
458
+ window.sessionStorage.setItem('mlw_time_quiz<?php echo $qmn_array_for_variables['quiz_id']; ?>', 'completed');
459
+ window.sessionStorage.setItem('mlw_started_quiz<?php echo $qmn_array_for_variables['quiz_id']; ?>', "no");
460
+ </script>
461
+ <?php
462
+ if (!isset($_POST["mlw_code_captcha"]) || (isset($_POST["mlw_code_captcha"]) && $_POST["mlw_user_captcha"] == $_POST["mlw_code_captcha"]))
463
+ {
464
+ $qmn_array_for_variables = array_merge($qmn_array_for_variables,$this->check_answers($qmn_quiz_questions, $qmn_quiz_answers, $qmn_quiz_options, $qmn_array_for_variables));
465
+ $result_display = apply_filters('qmn_after_check_answers', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
466
+ $qmn_array_for_variables['comments'] = $this->check_comment_section($qmn_quiz_options, $qmn_array_for_variables);
467
+ $result_display = apply_filters('qmn_after_check_comments', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
468
+ $qmn_array_for_variables['certificate_link'] = $this->generate_certificate($qmn_quiz_options, $qmn_array_for_variables);
469
+ $result_display = apply_filters('qmn_after_generate_certificate', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
470
+ $result_display .= $this->display_results_text($qmn_quiz_options, $qmn_array_for_variables);
471
+ $result_display = apply_filters('qmn_after_results_text', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
472
+ $result_display .= $this->display_social($qmn_quiz_options, $qmn_array_for_variables);
473
+ $result_display = apply_filters('qmn_after_social_media', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
474
+ $this->send_user_email($qmn_quiz_options, $qmn_array_for_variables);
475
+ $result_display = apply_filters('qmn_after_send_user_email', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
476
+ $this->send_admin_email($qmn_quiz_options, $qmn_array_for_variables);
477
+ $result_display = apply_filters('qmn_after_send_admin_email', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
478
+
479
+ //Save the results into database
480
+ $mlw_quiz_results_array = array( intval($qmn_array_for_variables['timer']), $qmn_array_for_variables['question_answers_array'], htmlspecialchars(stripslashes($qmn_array_for_variables['comments']), ENT_QUOTES));
481
+ $mlw_quiz_results = serialize($mlw_quiz_results_array);
482
+
483
+ global $wpdb;
484
+ $table_name = $wpdb->prefix . "mlw_results";
485
+ $results_insert = $wpdb->insert(
486
+ $table_name,
487
+ array(
488
+ 'quiz_id' => $qmn_array_for_variables['quiz_id'],
489
+ 'quiz_name' => $qmn_array_for_variables['quiz_name'],
490
+ 'quiz_system' => $qmn_array_for_variables['quiz_system'],
491
+ 'point_score' => $qmn_array_for_variables['total_points'],
492
+ 'correct_score' => $qmn_array_for_variables['total_score'],
493
+ 'correct' => $qmn_array_for_variables['total_correct'],
494
+ 'total' => $qmn_array_for_variables['total_questions'],
495
+ 'name' => $qmn_array_for_variables['user_name'],
496
+ 'business' => $qmn_array_for_variables['user_business'],
497
+ 'email' => $qmn_array_for_variables['user_email'],
498
+ 'phone' => $qmn_array_for_variables['user_phone'],
499
+ 'user' => $qmn_array_for_variables['user_id'],
500
+ 'time_taken' => date("h:i:s A m/d/Y"),
501
+ 'time_taken_real' => date("Y-m-d H:i:s"),
502
+ 'quiz_results' => $mlw_quiz_results,
503
+ 'deleted' => 0
504
+ ),
505
+ array(
506
+ '%d',
507
+ '%s',
508
+ '%d',
509
+ '%d',
510
+ '%d',
511
+ '%d',
512
+ '%d',
513
+ '%s',
514
+ '%s',
515
+ '%s',
516
+ '%s',
517
+ '%d',
518
+ '%s',
519
+ '%s',
520
+ '%s',
521
+ '%d'
522
+ )
523
+ );
524
+ $result_display = apply_filters('qmn_end_results', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
525
+ //Legacy Code
526
+ do_action('mlw_qmn_load_results_page', $wpdb->insert_id, $qmn_quiz_options->quiz_settings);
527
+ }
528
+ else
529
+ {
530
+ $result_display .= "Thank you.";
531
+ }
532
+ return $result_display;
533
+ }
534
+
535
+ /**
536
+ * Scores User Answers
537
+ *
538
+ * Calculates the users scores for the quiz
539
+ *
540
+ * @since 4.0.0
541
+ * @param array $qmn_quiz_options The database row of the quiz
542
+ * @param array $qmn_quiz_questions The questions of the quiz
543
+ * @param array $qmn_quiz_answers The answers of the quiz
544
+ * @param array $qmn_array_for_variables The array of results for the quiz
545
+ * @uses QMNPluginHelper:display_review() Scores the question
546
+ * @return array The results of the user's score
547
+ */
548
+ public function check_answers($qmn_quiz_questions, $qmn_quiz_answers, $qmn_quiz_options, $qmn_array_for_variables)
549
+ {
550
+ $mlw_points = 0;
551
+ $mlw_correct = 0;
552
+ $mlw_total_score = 0;
553
+ $mlw_question_answers = "";
554
+ global $mlwQuizMasterNext;
555
+ isset($_POST["total_questions"]) ? $mlw_total_questions = intval($_POST["total_questions"]) : $mlw_total_questions = 0;
556
+ isset($_POST["qmn_question_list"]) ? $question_list = explode('Q',$_POST["qmn_question_list"]) : $question_list = array();
557
+ $mlw_user_text = "";
558
+ $mlw_correct_text = "";
559
+ $qmn_correct = "incorrect";
560
+ $qmn_answer_points = 0;
561
+ $mlw_qmn_answer_array = array();
562
+ foreach($qmn_quiz_questions as $mlw_question)
563
+ {
564
+ foreach($question_list as $question_id)
565
+ {
566
+ if ($mlw_question->question_id == $question_id)
567
+ {
568
+ $mlw_user_text = "";
569
+ $mlw_correct_text = "";
570
+ $qmn_correct = "incorrect";
571
+ $qmn_answer_points = 0;
572
+
573
+ $results_array = $mlwQuizMasterNext->pluginHelper->display_review($mlw_question->question_type_new, $mlw_question->question_id);
574
+ if (!isset($results_array["null_review"]))
575
+ {
576
+ $mlw_points += $results_array["points"];
577
+ $qmn_answer_points += $results_array["points"];
578
+ if ($results_array["correct"] == "correct")
579
+ {
580
+ $mlw_correct += 1;
581
+ $qmn_correct = "correct";
582
+ }
583
+ $mlw_user_text = $results_array["user_text"];
584
+ $mlw_correct_text = $results_array["correct_text"];
585
+
586
+ if (isset($_POST["mlwComment".$mlw_question->question_id]))
587
+ {
588
+ $mlw_qm_question_comment = $_POST["mlwComment".$mlw_question->question_id];
589
+ }
590
+ else
591
+ {
592
+ $mlw_qm_question_comment = "";
593
+ }
594
+ $mlw_qmn_answer_array[] = apply_filters('qmn_answer_array', array($mlw_question->question_name, htmlspecialchars($mlw_user_text, ENT_QUOTES), htmlspecialchars($mlw_correct_text, ENT_QUOTES), htmlspecialchars(stripslashes($mlw_qm_question_comment), ENT_QUOTES), "correct" => $qmn_correct, "id" => $mlw_question->question_id, "points" => $qmn_answer_points, "category" => $mlw_question->category), $qmn_quiz_options, $qmn_array_for_variables);
595
+ }
596
+ break;
597
+ }
598
+ }
599
+ }
600
+
601
+ //Calculate Total Percent Score And Average Points Only If Total Questions Doesn't Equal Zero To Avoid Division By Zero Error
602
+ if ($mlw_total_questions != 0)
603
+ {
604
+ $mlw_total_score = round((($mlw_correct/$mlw_total_questions)*100), 2);
605
+ $mlw_average_points = round(($mlw_points/$mlw_total_questions), 2);
606
+ }
607
+ else
608
+ {
609
+ $mlw_total_score = 0;
610
+ $mlw_average_points = 0;
611
+ }
612
+
613
+ return array(
614
+ 'total_points' => $mlw_points,
615
+ 'total_score' => $mlw_total_score,
616
+ 'total_correct' => $mlw_correct,
617
+ 'total_questions' => $mlw_total_questions,
618
+ 'question_answers_display' => $mlw_question_answers,
619
+ 'question_answers_array' => $mlw_qmn_answer_array,
620
+ );
621
+ }
622
+
623
+ /**
624
+ * Retrieves User's Comments
625
+ *
626
+ * Checks to see if the user left a comment and returns the comment
627
+ *
628
+ * @since 4.0.0
629
+ * @param array $qmn_quiz_options The database row of the quiz
630
+ * @param array $qmn_array_for_variables The array of results for the quiz
631
+ * @return string The user's comments
632
+ */
633
+ public function check_comment_section($qmn_quiz_options, $qmn_array_for_variables)
634
+ {
635
+ $qmn_quiz_comments = "";
636
+ if (isset($_POST["mlwQuizComments"]))
637
+ {
638
+ $qmn_quiz_comments = $_POST["mlwQuizComments"];
639
+ }
640
+ return apply_filters('qmn_returned_comments', $qmn_quiz_comments, $qmn_quiz_options, $qmn_array_for_variables);
641
+ }
642
+
643
+ /**
644
+ * Generates Certificate
645
+ *
646
+ * Generates the certificate for the user using fpdf
647
+ *
648
+ * @since 4.0.0
649
+ * @param array $qmn_quiz_options The database row of the quiz
650
+ * @param array $qmn_array_for_variables The array of results for the quiz
651
+ * @return string The link to the certificate
652
+ */
653
+ public function generate_certificate($qmn_quiz_options, $qmn_array_for_variables)
654
+ {
655
+ $mlw_certificate_link = "";
656
+ if (is_serialized($qmn_quiz_options->certificate_template) && is_array(@unserialize($qmn_quiz_options->certificate_template)))
657
+ {
658
+ $mlw_certificate_options = unserialize($qmn_quiz_options->certificate_template);
659
+ }
660
+ else
661
+ {
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 = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message_certificate, $qmn_array_for_variables);
668
+ $mlw_message_certificate = str_replace( "\n" , "<br>", $mlw_message_certificate);
669
+ $mlw_plugindirpath = plugin_dir_path( __FILE__ );
670
+ $plugindirpath=plugin_dir_path( __FILE__ );
671
+ $mlw_qmn_certificate_file=<<<EOC
672
+ <?php
673
+ include("$plugindirpath/fpdf/WriteHTML.php");
674
+ \$pdf=new PDF_HTML();
675
+ \$pdf->AddPage('L');
676
+ EOC;
677
+ $mlw_qmn_certificate_file.=$mlw_certificate_options[3] != '' ? '$pdf->Image("'.$mlw_certificate_options[3].'",0,0,$pdf->w, $pdf->h);' : '';
678
+ $mlw_qmn_certificate_file.=<<<EOC
679
+ \$pdf->Ln(20);
680
+ \$pdf->SetFont('Arial','B',24);
681
+ \$pdf->MultiCell(280,20,'$mlw_certificate_options[0]',0,'C');
682
+ \$pdf->Ln(15);
683
+ \$pdf->SetFont('Arial','',16);
684
+ \$pdf->WriteHTML("<p align='center'>$mlw_message_certificate</p>");
685
+ EOC;
686
+ $mlw_qmn_certificate_file.=$mlw_certificate_options[2] != '' ? '$pdf->Image("'.$mlw_certificate_options[2].'",110,130);' : '';
687
+ $mlw_qmn_certificate_file.=<<<EOC
688
+ \$pdf->Output('mlw_qmn_certificate.pdf','D');
689
+ unlink(__FILE__);
690
+ EOC;
691
+ $mlw_qmn_certificate_filename = str_replace(home_url()."/", '', plugin_dir_url( __FILE__ ))."certificates/mlw_qmn_quiz".date("YmdHis").$qmn_array_for_variables['timer'].".php";
692
+ file_put_contents($mlw_qmn_certificate_filename, $mlw_qmn_certificate_file);
693
+ $mlw_qmn_certificate_filename = plugin_dir_url( __FILE__ )."certificates/mlw_qmn_quiz".date("YmdHis").$qmn_array_for_variables['timer'].".php";
694
+ $mlw_certificate_link = "<a href='".$mlw_qmn_certificate_filename."' class='qmn_certificate_link'>Download Certificate</a>";
695
+ }
696
+ return $mlw_certificate_link;
697
+ }
698
+
699
+ /**
700
+ * Displays Results Text
701
+ *
702
+ * Prepares and display text for the results page
703
+ *
704
+ * @since 4.0.0
705
+ * @param array $qmn_quiz_options The database row of the quiz
706
+ * @param array $qmn_array_for_variables The array of results for the quiz
707
+ * @return string The contents for the results text
708
+ */
709
+ public function display_results_text($qmn_quiz_options, $qmn_array_for_variables)
710
+ {
711
+ $results_text_display = '';
712
+ if (is_serialized($qmn_quiz_options->message_after) && is_array(@unserialize($qmn_quiz_options->message_after)))
713
+ {
714
+ $mlw_message_after_array = @unserialize($qmn_quiz_options->message_after);
715
+ //Cycle through landing pages
716
+ foreach($mlw_message_after_array as $mlw_each)
717
+ {
718
+ //Check to see if default
719
+ if ($mlw_each[0] == 0 && $mlw_each[1] == 0)
720
+ {
721
+ $mlw_message_after = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
722
+ $mlw_message_after = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message_after, $qmn_array_for_variables);
723
+ $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
724
+ $results_text_display .= $mlw_message_after;
725
+ break;
726
+ }
727
+ else
728
+ {
729
+ //Check to see if points fall in correct range
730
+ if ($qmn_quiz_options->system == 1 && $qmn_array_for_variables['total_points'] >= $mlw_each[0] && $qmn_array_for_variables['total_points'] <= $mlw_each[1])
731
+ {
732
+ $mlw_message_after = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
733
+ $mlw_message_after = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message_after, $qmn_array_for_variables);
734
+ $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
735
+ $results_text_display .= $mlw_message_after;
736
+ break;
737
+ }
738
+ //Check to see if score fall in correct range
739
+ if ($qmn_quiz_options->system == 0 && $qmn_array_for_variables['total_score'] >= $mlw_each[0] && $qmn_array_for_variables['total_score'] <= $mlw_each[1])
740
+ {
741
+ $mlw_message_after = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
742
+ $mlw_message_after = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message_after, $qmn_array_for_variables);
743
+ $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
744
+ $results_text_display .= $mlw_message_after;
745
+ break;
746
+ }
747
+ }
748
+ }
749
+ }
750
+ else
751
+ {
752
+ //Prepare the after quiz message
753
+ $mlw_message_after = htmlspecialchars_decode($qmn_quiz_options->message_after, ENT_QUOTES);
754
+ $mlw_message_after = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message_after, $qmn_array_for_variables);
755
+ $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
756
+ $results_text_display .= $mlw_message_after;
757
+ }
758
+ return do_shortcode( $results_text_display );
759
+ }
760
+
761
+ /**
762
+ * Display Social Media Buttons
763
+ *
764
+ * Prepares and displays social media buttons for sharing results
765
+ *
766
+ * @since 4.0.0
767
+ * @param array $qmn_quiz_options The database row of the quiz
768
+ * @param array $qmn_array_for_variables The array of results for the quiz
769
+ * @return string The content of the social media button section
770
+ */
771
+ public function display_social($qmn_quiz_options, $qmn_array_for_variables)
772
+ {
773
+ $social_display = '';
774
+ if ($qmn_quiz_options->social_media == 1)
775
+ {
776
+ wp_enqueue_script( 'qmn_quiz_social_share', plugins_url( 'js/qmn_social_share.js' , __FILE__ ) );
777
+
778
+ //Load Social Media Text
779
+ $qmn_social_media_text = "";
780
+ if (is_serialized($qmn_quiz_options->social_media_text) && is_array(@unserialize($qmn_quiz_options->social_media_text)))
781
+ {
782
+ $qmn_social_media_text = @unserialize($qmn_quiz_options->social_media_text);
783
+ }
784
+ else
785
+ {
786
+ $qmn_social_media_text = array(
787
+ 'twitter' => $qmn_quiz_options->social_media_text,
788
+ 'facebook' => $qmn_quiz_options->social_media_text
789
+ );
790
+ }
791
+ $qmn_social_media_text["twitter"] = apply_filters( 'mlw_qmn_template_variable_results_page', $qmn_social_media_text["twitter"], $qmn_array_for_variables);
792
+ $qmn_social_media_text["facebook"] = apply_filters( 'mlw_qmn_template_variable_results_page', $qmn_social_media_text["facebook"], $qmn_array_for_variables);
793
+ $social_display .= "<br />
794
+ <a class=\"mlw_qmn_quiz_link\" onclick=\"mlw_qmn_share('facebook', '".esc_js($qmn_social_media_text["facebook"])."', '".esc_js($qmn_quiz_options->quiz_name)."');\">Facebook</a>
795
+ <a class=\"mlw_qmn_quiz_link\" onclick=\"mlw_qmn_share('twitter', '".esc_js($qmn_social_media_text["twitter"])."', '".esc_js($qmn_quiz_options->quiz_name)."');\">Twitter</a>
796
+ <br />";
797
+ }
798
+ return apply_filters('qmn_returned_social_buttons', $social_display, $qmn_quiz_options, $qmn_array_for_variables);
799
+ }
800
+
801
+ /**
802
+ * Send User Email
803
+ *
804
+ * Prepares the email to the user and then sends the email
805
+ *
806
+ * @since 4.0.0
807
+ * @param array $qmn_quiz_options The database row of the quiz
808
+ * @param array $qmn_array_for_variables The array of results for the quiz
809
+ */
810
+ public function send_user_email($qmn_quiz_options, $qmn_array_for_variables)
811
+ {
812
+ add_filter( 'wp_mail_content_type', 'mlw_qmn_set_html_content_type' );
813
+ $mlw_message = "";
814
+ if ($qmn_quiz_options->send_user_email == "0")
815
+ {
816
+ if ($qmn_array_for_variables['user_email'] != "")
817
+ {
818
+ if (is_serialized($qmn_quiz_options->user_email_template) && is_array(@unserialize($qmn_quiz_options->user_email_template)))
819
+ {
820
+ $mlw_user_email_array = @unserialize($qmn_quiz_options->user_email_template);
821
+
822
+ //Cycle through landing pages
823
+ foreach($mlw_user_email_array as $mlw_each)
824
+ {
825
+
826
+ //Generate Email Subject
827
+ if (!isset($mlw_each[3]))
828
+ {
829
+ $mlw_each[3] = "Quiz Results For %QUIZ_NAME";
830
+ }
831
+ $mlw_each[3] = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_each[3], $qmn_array_for_variables);
832
+
833
+ //Check to see if default
834
+ if ($mlw_each[0] == 0 && $mlw_each[1] == 0)
835
+ {
836
+ $mlw_message = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
837
+ $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $qmn_array_for_variables);
838
+ $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
839
+ $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
840
+ $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
841
+ $mlw_headers = 'From: '.$qmn_quiz_options->email_from_text.' <'.$qmn_quiz_options->admin_email.'>' . "\r\n";
842
+ wp_mail($qmn_array_for_variables['user_email'], $mlw_each[3], $mlw_message, $mlw_headers);
843
+ break;
844
+ }
845
+ else
846
+ {
847
+ if ($qmn_quiz_options->system == 1 && $qmn_array_for_variables['total_points'] >= $mlw_each[0] && $qmn_array_for_variables['total_points'] <= $mlw_each[1])
848
+ {
849
+ $mlw_message = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
850
+ $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $qmn_array_for_variables);
851
+ $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
852
+ $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
853
+ $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
854
+ $mlw_headers = 'From: '.$qmn_quiz_options->email_from_text.' <'.$qmn_quiz_options->admin_email.'>' . "\r\n";
855
+ wp_mail($qmn_array_for_variables['user_email'], $mlw_each[3], $mlw_message, $mlw_headers);
856
+ break;
857
+ }
858
+
859
+ //Check to see if score fall in correct range
860
+ if ($qmn_quiz_options->system == 0 && $qmn_array_for_variables['total_score'] >= $mlw_each[0] && $qmn_array_for_variables['total_score'] <= $mlw_each[1])
861
+ {
862
+ $mlw_message = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
863
+ $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $qmn_array_for_variables);
864
+ $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
865
+ $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
866
+ $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
867
+ $mlw_headers = 'From: '.$qmn_quiz_options->email_from_text.' <'.$qmn_quiz_options->admin_email.'>' . "\r\n";
868
+ wp_mail($qmn_array_for_variables['user_email'], $mlw_each[3], $mlw_message, $mlw_headers);
869
+ break;
870
+ }
871
+ }
872
+ }
873
+ }
874
+ else
875
+ {
876
+ $mlw_message = htmlspecialchars_decode($qmn_quiz_options->user_email_template, ENT_QUOTES);
877
+ $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $qmn_array_for_variables);
878
+ $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
879
+ $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
880
+ $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
881
+ $mlw_headers = 'From: '.$qmn_quiz_options->email_from_text.' <'.$qmn_quiz_options->admin_email.'>' . "\r\n";
882
+ wp_mail($qmn_array_for_variables['user_email'], "Quiz Results For ".$qmn_quiz_options->quiz_name, $mlw_message, $mlw_headers);
883
+ }
884
+ }
885
+ }
886
+ remove_filter( 'wp_mail_content_type', 'mlw_qmn_set_html_content_type' );
887
+ }
888
+
889
+ /**
890
+ * Send Admin Email
891
+ *
892
+ * Prepares the email to the admin and then sends the email
893
+ *
894
+ * @since 4.0.0
895
+ * @param array $qmn_quiz_options The database row of the quiz
896
+ * @param arrar $qmn_array_for_variables The array of results for the quiz
897
+ */
898
+ public function send_admin_email($qmn_quiz_options, $qmn_array_for_variables)
899
+ {
900
+ //Switch email type to HTML
901
+ add_filter( 'wp_mail_content_type', 'mlw_qmn_set_html_content_type' );
902
+
903
+ $mlw_message = "";
904
+ if ($qmn_quiz_options->send_admin_email == "0")
905
+ {
906
+ if ($qmn_quiz_options->admin_email != "")
907
+ {
908
+ $mlw_message = "";
909
+ $mlw_subject = "";
910
+ if (is_serialized($qmn_quiz_options->admin_email_template) && is_array(@unserialize($qmn_quiz_options->admin_email_template)))
911
+ {
912
+ $mlw_admin_email_array = @unserialize($qmn_quiz_options->admin_email_template);
913
+
914
+ //Cycle through landing pages
915
+ foreach($mlw_admin_email_array as $mlw_each)
916
+ {
917
+
918
+ //Generate Email Subject
919
+ if (!isset($mlw_each["subject"]))
920
+ {
921
+ $mlw_each["subject"] = "Quiz Results For %QUIZ_NAME";
922
+ }
923
+ $mlw_each["subject"] = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_each["subject"], $qmn_array_for_variables);
924
+
925
+ //Check to see if default
926
+ if ($mlw_each["begin_score"] == 0 && $mlw_each["end_score"] == 0)
927
+ {
928
+ $mlw_message = htmlspecialchars_decode($mlw_each["message"], ENT_QUOTES);
929
+ $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $qmn_array_for_variables);
930
+ $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
931
+ $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
932
+ $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
933
+ $mlw_subject = $mlw_each["subject"];
934
+ break;
935
+ }
936
+ else
937
+ {
938
+ //Check to see if points fall in correct range
939
+ if ($qmn_quiz_options->system == 1 && $qmn_array_for_variables['total_points'] >= $mlw_each["begin_score"] && $qmn_array_for_variables['total_points'] <= $mlw_each["end_score"])
940
+ {
941
+ $mlw_message = htmlspecialchars_decode($mlw_each["message"], ENT_QUOTES);
942
+ $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $qmn_array_for_variables);
943
+ $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
944
+ $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
945
+ $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
946
+ $mlw_subject = $mlw_each["subject"];
947
+ break;
948
+ }
949
+
950
+ //Check to see if score fall in correct range
951
+ if ($qmn_quiz_options->system == 0 && $qmn_array_for_variables['total_score'] >= $mlw_each["begin_score"] && $qmn_array_for_variables['total_score'] <= $mlw_each["end_score"])
952
+ {
953
+ $mlw_message = htmlspecialchars_decode($mlw_each["message"], ENT_QUOTES);
954
+ $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $qmn_array_for_variables);
955
+ $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
956
+ $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
957
+ $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
958
+ $mlw_subject = $mlw_each["subject"];
959
+ break;
960
+ }
961
+ }
962
+ }
963
+ }
964
+ else
965
+ {
966
+ $mlw_message = htmlspecialchars_decode($qmn_quiz_options->admin_email_template, ENT_QUOTES);
967
+ $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $qmn_array_for_variables);
968
+ $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
969
+ $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
970
+ $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
971
+ $mlw_subject = "Quiz Results For ".$qmn_quiz_options->quiz_name;
972
+ }
973
+ }
974
+ if ( get_option('mlw_advert_shows') == 'true' ) {$mlw_message .= "<br>This email was generated by the Quiz Master Next script by Frank Corso";}
975
+ $mlw_headers = 'From: '.$qmn_quiz_options->email_from_text.' <'.$qmn_quiz_options->admin_email.'>' . "\r\n";
976
+ $mlw_qmn_admin_emails = explode(",", $qmn_quiz_options->admin_email);
977
+ foreach($mlw_qmn_admin_emails as $admin_email)
978
+ {
979
+ wp_mail($admin_email, $mlw_subject, $mlw_message, $mlw_headers);
980
+ }
981
+ }
982
+
983
+ //Remove HTML type for emails
984
+ remove_filter( 'wp_mail_content_type', 'mlw_qmn_set_html_content_type' );
985
+ }
986
+ }
987
+ $qmnQuizManager = new QMNQuizManager();
988
+
989
+ add_filter('qmn_begin_shortcode', 'qmn_require_login_check', 10, 3);
990
+ function qmn_require_login_check($display, $qmn_quiz_options, $qmn_array_for_variables)
991
+ {
992
+ global $qmn_allowed_visit;
993
+ if ( $qmn_quiz_options->require_log_in == 1 && !is_user_logged_in() )
994
+ {
995
+ $qmn_allowed_visit = false;
996
+ $mlw_message = htmlspecialchars_decode($qmn_quiz_options->require_log_in_text, ENT_QUOTES);
997
+ $mlw_message = apply_filters( 'mlw_qmn_template_variable_quiz_page', $mlw_message, $qmn_array_for_variables);
998
+ $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
999
+ $display .= $mlw_message;
1000
+ $display .= wp_login_form( array('echo' => false) );
1001
+ }
1002
+ return $display;
1003
+ }
1004
+
1005
+ add_filter('qmn_begin_shortcode', 'qmn_scheduled_timeframe_check', 10, 3);
1006
+ function qmn_scheduled_timeframe_check($display, $qmn_quiz_options, $qmn_array_for_variables)
1007
+ {
1008
+ global $qmn_allowed_visit;
1009
+ if (is_serialized($qmn_quiz_options->scheduled_timeframe) && is_array(@unserialize($qmn_quiz_options->scheduled_timeframe)))
1010
+ {
1011
+ $qmn_scheduled_timeframe = @unserialize($qmn_quiz_options->scheduled_timeframe);
1012
+ if ($qmn_scheduled_timeframe["start"] != '' && $qmn_scheduled_timeframe["end"] != '')
1013
+ {
1014
+ $qmn_scheduled_start = strtotime($qmn_scheduled_timeframe["start"]);
1015
+ $qmn_scheduled_end = strtotime($qmn_scheduled_timeframe["end"]) + 86399; ///Added seconds to bring time to 11:59:59 PM of given day
1016
+ if (time() < $qmn_scheduled_start | time() > $qmn_scheduled_end)
1017
+ {
1018
+ $qmn_allowed_visit = false;
1019
+ $mlw_message = htmlspecialchars_decode($qmn_quiz_options->scheduled_timeframe_text, ENT_QUOTES);
1020
+ $mlw_message = apply_filters( 'mlw_qmn_template_variable_quiz_page', $mlw_message, $qmn_array_for_variables);
1021
+ $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
1022
+ $display .= $mlw_message;
1023
+ }
1024
+ }
1025
+ }
1026
+ return $display;
1027
+ }
1028
+
1029
+ add_filter('qmn_begin_shortcode', 'qmn_total_user_tries_check', 10, 3);
1030
+ function qmn_total_user_tries_check($display, $qmn_quiz_options, $qmn_array_for_variables)
1031
+ {
1032
+ global $qmn_allowed_visit;
1033
+ if ( $qmn_quiz_options->total_user_tries != 0 && is_user_logged_in() )
1034
+ {
1035
+ global $wpdb;
1036
+ $current_user = wp_get_current_user();
1037
+ $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, $qmn_array_for_variables['quiz_id'] ) );
1038
+ if ($mlw_qmn_user_try_count >= $qmn_quiz_options->total_user_tries)
1039
+ {
1040
+ $qmn_allowed_visit = false;
1041
+ $mlw_message = htmlspecialchars_decode($qmn_quiz_options->total_user_tries_text, ENT_QUOTES);
1042
+ $mlw_message = apply_filters( 'mlw_qmn_template_variable_quiz_page', $mlw_message, $qmn_array_for_variables);
1043
+ $display .= $mlw_message;
1044
+ }
1045
+ }
1046
+ return $display;
1047
+ }
1048
+
1049
+ add_filter('qmn_begin_shortcode', 'qmn_quiz_name_check', 10, 3);
1050
+ function qmn_quiz_name_check($display, $qmn_quiz_options, $qmn_array_for_variables)
1051
+ {
1052
+ global $qmn_allowed_visit;
1053
+ if ($qmn_quiz_options->quiz_name == "")
1054
+ {
1055
+ $qmn_allowed_visit = false;
1056
+ $display .= __("It appears that this quiz is not set up correctly.", 'quiz-master-next');
1057
+ }
1058
+ return $display;
1059
+ }
1060
+
1061
+ add_filter('qmn_begin_quiz', 'qmn_total_tries_check', 10, 3);
1062
+ function qmn_total_tries_check($display, $qmn_quiz_options, $qmn_array_for_variables)
1063
+ {
1064
+ global $qmn_allowed_visit;
1065
+ if ( $qmn_quiz_options->limit_total_entries != 0 )
1066
+ {
1067
+ global $wpdb;
1068
+ $mlw_qmn_entries_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(quiz_id) FROM ".$wpdb->prefix."mlw_results WHERE deleted='0' AND quiz_id=%d", $qmn_array_for_variables['quiz_id'] ) );
1069
+ if ($mlw_qmn_entries_count >= $qmn_quiz_options->limit_total_entries)
1070
+ {
1071
+ $mlw_message = htmlspecialchars_decode($qmn_quiz_options->limit_total_entries_text, ENT_QUOTES);
1072
+ $mlw_message = apply_filters( 'mlw_qmn_template_variable_quiz_page', $mlw_message, $qmn_array_for_variables);
1073
+ $display .= $mlw_message;
1074
+ $qmn_allowed_visit = false;
1075
+ }
1076
+ }
1077
+ return $display;
1078
+ }
1079
+
1080
+ add_filter('qmn_begin_quiz', 'qmn_pagination_check', 10, 3);
1081
+ function qmn_pagination_check($display, $qmn_quiz_options, $qmn_array_for_variables)
1082
+ {
1083
+ if ($qmn_quiz_options->pagination != 0)
1084
+ {
1085
+ global $wpdb;
1086
+ $total_questions = 0;
1087
+ if ($qmn_quiz_options->question_from_total != 0)
1088
+ {
1089
+ $total_questions = $qmn_quiz_options->question_from_total;
1090
+ }
1091
+ else
1092
+ {
1093
+ $total_questions = $wpdb->get_var($wpdb->prepare("SELECT COUNT(quiz_id) FROM ".$wpdb->prefix."mlw_questions WHERE deleted=0 AND quiz_id=%d", $qmn_array_for_variables["quiz_id"]));
1094
+ }
1095
+ $display .= "<style>.quiz_section { display: none; }</style>";
1096
+ $mlw_qmn_section_limit = 2 + $total_questions;
1097
+ if ($qmn_quiz_options->comment_section == 0)
1098
+ {
1099
+ $mlw_qmn_section_limit = $mlw_qmn_section_limit + 1;
1100
+ }
1101
+
1102
+ //Gather text for pagination buttons
1103
+ $mlw_qmn_pagination_text = "";
1104
+ if (is_serialized($qmn_quiz_options->pagination_text) && is_array(@unserialize($qmn_quiz_options->pagination_text)))
1105
+ {
1106
+ $mlw_qmn_pagination_text = @unserialize($qmn_quiz_options->pagination_text);
1107
+ }
1108
+ else
1109
+ {
1110
+ $mlw_qmn_pagination_text = array(__('Previous', 'quiz-master-next'), $qmn_quiz_options->pagination_text);
1111
+ }
1112
+ ?>
1113
+ <script type="text/javascript">
1114
+ var qmn_pagination = <?php echo $qmn_quiz_options->pagination; ?>;
1115
+ var qmn_section_limit = <?php echo $mlw_qmn_section_limit; ?>;
1116
+ var qmn_pagination_previous_text = '<?php echo $mlw_qmn_pagination_text[0]; ?>';
1117
+ var qmn_pagination_next_text = '<?php echo $mlw_qmn_pagination_text[1]; ?>';
1118
+ </script>
1119
+ <?php
1120
+ wp_enqueue_script( 'qmn_quiz_pagination', plugins_url( 'js/qmn_pagination.js' , __FILE__ ) );
1121
+ }
1122
+ return $display;
1123
+ }
1124
+
1125
+ add_filter('qmn_begin_quiz', 'qmn_timer_check', 10, 3);
1126
+ function qmn_timer_check($display, $qmn_quiz_options, $qmn_array_for_variables)
1127
+ {
1128
+ global $qmn_allowed_visit;
1129
+ if ($qmn_allowed_visit && $qmn_quiz_options->timer_limit != 0)
1130
+ {
1131
+ ?>
1132
+ <div id="mlw_qmn_timer" class="mlw_qmn_timer"></div>
1133
+ <script type="text/javascript">
1134
+ var qmn_quiz_id = <?php echo $qmn_array_for_variables['quiz_id']; ?>;
1135
+ var qmn_timer_limit = <?php echo $qmn_quiz_options->timer_limit; ?>;
1136
+ </script>
1137
+ <?php
1138
+ wp_enqueue_script( 'qmn_quiz_timer', plugins_url( 'js/qmn_timer.js' , __FILE__ ) );
1139
+ }
1140
+ return $display;
1141
+ }
1142
+
1143
+ add_filter('qmn_begin_quiz', 'qmn_update_views', 10, 3);
1144
+ function qmn_update_views($display, $qmn_quiz_options, $qmn_array_for_variables)
1145
+ {
1146
+ global $wpdb;
1147
+ $mlw_views = $qmn_quiz_options->quiz_views;
1148
+ $mlw_views += 1;
1149
+ $results = $wpdb->update(
1150
+ $wpdb->prefix . "mlw_quizzes",
1151
+ array(
1152
+ 'quiz_views' => $mlw_views
1153
+ ),
1154
+ array( 'quiz_id' => $qmn_array_for_variables["quiz_id"] ),
1155
+ array(
1156
+ '%d'
1157
+ ),
1158
+ array( '%d' )
1159
+ );
1160
+ return $display;
1161
+ }
1162
+
1163
+ add_filter('qmn_begin_results', 'qmn_update_taken', 10, 3);
1164
+ function qmn_update_taken($display, $qmn_quiz_options, $qmn_array_for_variables)
1165
+ {
1166
+ global $wpdb;
1167
+ $mlw_taken = $qmn_quiz_options->quiz_taken;
1168
+ $mlw_taken += 1;
1169
+ $results = $wpdb->update(
1170
+ $wpdb->prefix . "mlw_quizzes",
1171
+ array(
1172
+ 'quiz_taken' => $mlw_taken
1173
+ ),
1174
+ array( 'quiz_id' => $qmn_array_for_variables["quiz_id"] ),
1175
+ array(
1176
+ '%d'
1177
+ ),
1178
+ array( '%d' )
1179
+ );
1180
+ return $display;
1181
+ }
1182
+
1183
+ /*
1184
+ This function displays fields to ask for contact information
1185
+ */
1186
+ function mlwDisplayContactInfo($mlw_quiz_options)
1187
+ {
1188
+ $mlw_contact_display = "";
1189
+ //Check to see if user is logged in, then ask for contact if not
1190
+ if ( is_user_logged_in() )
1191
+ {
1192
+ //If this quiz does not let user edit contact information we hide this section
1193
+ if ($mlw_quiz_options->loggedin_user_contact == 1)
1194
+ {
1195
+ $mlw_contact_display .= "<div style='display:none;'>";
1196
+ }
1197
+
1198
+ //Retrieve current user information and save into text fields for contact information
1199
+ $current_user = wp_get_current_user();
1200
+ if ($mlw_quiz_options->user_name != 2)
1201
+ {
1202
+ $mlw_contact_class = "class=\"\"";
1203
+ if ($mlw_quiz_options->user_name == 1)
1204
+ {
1205
+ $mlw_contact_class = "class=\"mlwRequiredText\"";
1206
+ }
1207
+ $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->name_field_text, ENT_QUOTES)."</span><br />";
1208
+ $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserName' value='".$current_user->display_name."' />";
1209
+ $mlw_contact_display .= "<br /><br />";
1210
+
1211
+ }
1212
+ if ($mlw_quiz_options->user_comp != 2)
1213
+ {
1214
+ $mlw_contact_class = "class=\"\"";
1215
+ if ($mlw_quiz_options->user_comp == 1)
1216
+ {
1217
+ $mlw_contact_class = "class=\"mlwRequiredText\"";
1218
+ }
1219
+ $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->business_field_text, ENT_QUOTES)."</span><br />";
1220
+ $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserComp' value='' />";
1221
+ $mlw_contact_display .= "<br /><br />";
1222
+ }
1223
+ if ($mlw_quiz_options->user_email != 2)
1224
+ {
1225
+ $mlw_contact_class = "class=\"mlwEmail\"";
1226
+ if ($mlw_quiz_options->user_email == 1)
1227
+ {
1228
+ $mlw_contact_class = "class=\"mlwEmail mlwRequiredText\"";
1229
+ }
1230
+ $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->email_field_text, ENT_QUOTES)."</span><br />";
1231
+ $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserEmail' value='".$current_user->user_email."' />";
1232
+ $mlw_contact_display .= "<br /><br />";
1233
+ }
1234
+ if ($mlw_quiz_options->user_phone != 2)
1235
+ {
1236
+ $mlw_contact_class = "class=\"\"";
1237
+ if ($mlw_quiz_options->user_phone == 1)
1238
+ {
1239
+ $mlw_contact_class = "class=\"mlwRequiredText\"";
1240
+ }
1241
+ $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->phone_field_text, ENT_QUOTES)."</span><br />";
1242
+ $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserPhone' value='' />";
1243
+ $mlw_contact_display .= "<br /><br />";
1244
+ }
1245
+
1246
+ //End of hidden section div
1247
+ if ($mlw_quiz_options->loggedin_user_contact == 1)
1248
+ {
1249
+ $mlw_contact_display .= "</div>";
1250
+ }
1251
+ }
1252
+ else
1253
+ {
1254
+ //See if the site wants to ask for any contact information, then ask for it
1255
+ if ($mlw_quiz_options->user_name != 2)
1256
+ {
1257
+ $mlw_contact_class = "class=\"\"";
1258
+ if ($mlw_quiz_options->user_name == 1)
1259
+ {
1260
+ $mlw_contact_class = "class=\"mlwRequiredText\"";
1261
+ }
1262
+ $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->name_field_text, ENT_QUOTES)."</span><br />";
1263
+ $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserName' value='' />";
1264
+ $mlw_contact_display .= "<br /><br />";
1265
+ }
1266
+ if ($mlw_quiz_options->user_comp != 2)
1267
+ {
1268
+ $mlw_contact_class = "class=\"\"";
1269
+ if ($mlw_quiz_options->user_comp == 1)
1270
+ {
1271
+ $mlw_contact_class = "class=\"mlwRequiredText\"";
1272
+ }
1273
+ $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->business_field_text, ENT_QUOTES)."</span><br />";
1274
+ $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserComp' value='' />";
1275
+ $mlw_contact_display .= "<br /><br />";
1276
+ }
1277
+ if ($mlw_quiz_options->user_email != 2)
1278
+ {
1279
+ $mlw_contact_class = "class=\"mlwEmail\"";
1280
+ if ($mlw_quiz_options->user_email == 1)
1281
+ {
1282
+ $mlw_contact_class = "class=\"mlwEmail mlwRequiredText\"";
1283
+ }
1284
+ $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->email_field_text, ENT_QUOTES)."</span><br />";
1285
+ $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserEmail' value='' />";
1286
+ $mlw_contact_display .= "<br /><br />";
1287
+ }
1288
+ if ($mlw_quiz_options->user_phone != 2)
1289
+ {
1290
+ $mlw_contact_class = "class=\"\"";
1291
+ if ($mlw_quiz_options->user_phone == 1)
1292
+ {
1293
+ $mlw_contact_class = "class=\"mlwRequiredText\"";
1294
+ }
1295
+ $mlw_contact_display .= "<span class='mlw_qmn_question'>".htmlspecialchars_decode($mlw_quiz_options->phone_field_text, ENT_QUOTES)."</span><br />";
1296
+ $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserPhone' value='' />";
1297
+ $mlw_contact_display .= "<br /><br />";
1298
+ }
1299
+ }
1300
+ return $mlw_contact_display;
1301
+ }
1302
+
1303
+ /*
1304
+ This function helps set the email type to HTML
1305
+ */
1306
+ function mlw_qmn_set_html_content_type() {
1307
+
1308
+ return 'text/html';
1309
+ }
1310
+ ?>
includes/qmn_quiz_admin.php ADDED
@@ -0,0 +1,368 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function mlw_generate_quiz_admin()
3
+ {
4
+ global $wpdb;
5
+ global $mlwQuizMasterNext;
6
+ $table_name = $wpdb->prefix . "mlw_quizzes";
7
+
8
+ //Create new quiz
9
+ if ( isset( $_POST["create_quiz"] ) && $_POST["create_quiz"] == "confirmation" )
10
+ {
11
+ $quiz_name = htmlspecialchars($_POST["quiz_name"], ENT_QUOTES);
12
+ $mlwQuizMasterNext->quizCreator->create_quiz($quiz_name);
13
+ }
14
+
15
+ //Delete quiz
16
+ if (isset( $_POST["delete_quiz"] ) && $_POST["delete_quiz"] == "confirmation")
17
+ {
18
+ $mlw_quiz_id = intval($_POST["quiz_id"]);
19
+ $quiz_name = $_POST["delete_quiz_name"];
20
+ $mlwQuizMasterNext->quizCreator->delete_quiz($mlw_quiz_id, $quiz_name);
21
+ }
22
+
23
+ //Edit Quiz Name
24
+ if (isset($_POST["quiz_name_editted"]) && $_POST["quiz_name_editted"] == "confirmation")
25
+ {
26
+ $mlw_edit_quiz_id = intval($_POST["edit_quiz_id"]);
27
+ $mlw_edit_quiz_name = htmlspecialchars($_POST["edit_quiz_name"], ENT_QUOTES);
28
+ $mlwQuizMasterNext->quizCreator->edit_quiz_name($mlw_edit_quiz_id, $mlw_edit_quiz_name);
29
+ }
30
+
31
+ //Duplicate Quiz
32
+ if (isset($_POST["duplicate_quiz"]) && $_POST["duplicate_quiz"] == "confirmation")
33
+ {
34
+ $mlw_duplicate_quiz_id = intval($_POST["duplicate_quiz_id"]);
35
+ $mlw_duplicate_quiz_name = htmlspecialchars($_POST["duplicate_new_quiz_name"], ENT_QUOTES);
36
+ $mlwQuizMasterNext->quizCreator->duplicate_quiz($mlw_duplicate_quiz_id, $mlw_duplicate_quiz_name, isset($_POST["duplicate_questions"]));
37
+ }
38
+
39
+ //Retrieve list of quizzes
40
+ global $wpdb;
41
+ $mlw_qmn_table_limit = 25;
42
+ $mlw_qmn_quiz_count = $wpdb->get_var( "SELECT COUNT(quiz_id) FROM " . $wpdb->prefix . "mlw_quizzes WHERE deleted='0'" );
43
+
44
+ if( isset($_GET{'mlw_quiz_page'} ) )
45
+ {
46
+ $mlw_qmn_quiz_page = $_GET{'mlw_quiz_page'} + 1;
47
+ $mlw_qmn_quiz_begin = $mlw_qmn_table_limit * $mlw_qmn_quiz_page ;
48
+ }
49
+ else
50
+ {
51
+ $mlw_qmn_quiz_page = 0;
52
+ $mlw_qmn_quiz_begin = 0;
53
+ }
54
+ $mlw_qmn_quiz_left = $mlw_qmn_quiz_count - ($mlw_qmn_quiz_page * $mlw_qmn_table_limit);
55
+ $mlw_quiz_data = $wpdb->get_results( $wpdb->prepare( "SELECT quiz_id, quiz_name, quiz_views, quiz_taken, last_activity
56
+ FROM " . $wpdb->prefix . "mlw_quizzes WHERE deleted='0'
57
+ ORDER BY quiz_id DESC LIMIT %d, %d", $mlw_qmn_quiz_begin, $mlw_qmn_table_limit ) );
58
+ ?>
59
+ <!-- css -->
60
+ <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
61
+ <script type="text/javascript"
62
+ src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
63
+ </script>
64
+ <!-- jquery scripts -->
65
+ <?php
66
+ wp_enqueue_script( 'jquery' );
67
+ wp_enqueue_script( 'jquery-ui-core' );
68
+ wp_enqueue_script( 'jquery-ui-dialog' );
69
+ wp_enqueue_script( 'jquery-ui-button' );
70
+ wp_enqueue_script( 'jquery-effects-blind' );
71
+ wp_enqueue_script( 'jquery-effects-explode' );
72
+ ?>
73
+ <script type="text/javascript">
74
+ var $j = jQuery.noConflict();
75
+ // increase the default animation speed to exaggerate the effect
76
+ $j.fx.speeds._default = 1000;
77
+ $j(function() {
78
+ $j('#new_quiz_dialog').dialog({
79
+ autoOpen: false,
80
+ show: 'blind',
81
+ width:700,
82
+ hide: 'explode',
83
+ buttons: {
84
+ Cancel: function() {
85
+ $j(this).dialog('close');
86
+ }
87
+ }
88
+ });
89
+
90
+ $j('#new_quiz_button').click(function() {
91
+ $j('#new_quiz_dialog').dialog('open');
92
+ return false;
93
+ } );
94
+ $j('#new_quiz_button_two').click(function() {
95
+ $j('#new_quiz_dialog').dialog('open');
96
+ return false;
97
+ } );
98
+ });
99
+ function deleteQuiz(id,quizName){
100
+ $j("#delete_dialog").dialog({
101
+ autoOpen: false,
102
+ show: 'blind',
103
+ hide: 'explode',
104
+ buttons: {
105
+ Cancel: function() {
106
+ $j(this).dialog('close');
107
+ }
108
+ }
109
+ });
110
+ $j("#delete_dialog").dialog('open');
111
+ var idHidden = document.getElementById("quiz_id");
112
+ var idHiddenName = document.getElementById("delete_quiz_name");
113
+ idHidden.value = id;
114
+ idHiddenName.value = quizName;
115
+ };
116
+ function editQuizName(id, quizName){
117
+ $j("#edit_dialog").dialog({
118
+ autoOpen: false,
119
+ show: 'blind',
120
+ hide: 'explode',
121
+ buttons: {
122
+ Cancel: function() {
123
+ $j(this).dialog('close');
124
+ }
125
+ }
126
+ });
127
+ $j("#edit_dialog").dialog('open');
128
+ document.getElementById("edit_quiz_name").value = quizName;
129
+ document.getElementById("edit_quiz_id"). value = id;
130
+ }
131
+ function duplicateQuiz(id, quizName){
132
+ $j("#duplicate_dialog").dialog({
133
+ autoOpen: false,
134
+ show: 'blind',
135
+ hide: 'explode',
136
+ buttons: {
137
+ Cancel: function() {
138
+ $j(this).dialog('close');
139
+ }
140
+ }
141
+ });
142
+ $j("#duplicate_dialog").dialog('open');
143
+ document.getElementById("duplicate_quiz_id"). value = id;
144
+ }
145
+ </script>
146
+ <style type="text/css">
147
+ div.mlw_quiz_options input[type='text'] {
148
+ border-color:#000000;
149
+ color:#3300CC;
150
+ cursor:hand;
151
+ }
152
+ </style>
153
+ <style>
154
+ .linkOptions
155
+ {
156
+ font-size: 14px !important;
157
+ }
158
+ .linkDelete
159
+ {
160
+ color: red !important;
161
+ }
162
+ .linkOptions:hover
163
+ {
164
+ background-color: black;
165
+ }
166
+ </style>
167
+ <div class="wrap">
168
+ <div class='mlw_quiz_options'>
169
+ <h2><?php _e('Quizzes', 'quiz-master-next'); ?><a id="new_quiz_button" href="javascript:();" class="add-new-h2"><?php _e('Add New', 'quiz-master-next'); ?></a></h2>
170
+ <?php $mlwQuizMasterNext->alertManager->showAlerts(); ?>
171
+ <div style="width: 85%; float: left;">
172
+ <div class="tablenav top">
173
+ <div class="tablenav-pages">
174
+ <span class="displaying-num"><?php echo sprintf(_n('One quiz', '%s quizzes', $mlw_qmn_quiz_count, 'quiz-master-next'), number_format_i18n($mlw_qmn_quiz_count)); ?></span>
175
+ <span class="pagination-links">
176
+ <?php
177
+ $mlw_qmn_previous_page = 0;
178
+ $mlw_current_page = $mlw_qmn_quiz_page+1;
179
+ $mlw_total_pages = ceil($mlw_qmn_quiz_count/$mlw_qmn_table_limit);
180
+ if( $mlw_qmn_quiz_page > 0 )
181
+ {
182
+ $mlw_qmn_previous_page = $mlw_qmn_quiz_page - 2;
183
+ echo "<a class=\"prev-page\" title=\"Go to the previous page\" href=\"?page=quiz-master-next/mlw_quizmaster2.php&&mlw_quiz_page=$mlw_qmn_previous_page\"><</a>";
184
+ echo "<span class=\"paging-input\">$mlw_current_page of $mlw_total_pages</span>";
185
+ if( $mlw_qmn_quiz_left > $mlw_qmn_table_limit )
186
+ {
187
+ echo "<a class=\"next-page\" title=\"Go to the next page\" href=\"?page=quiz-master-next/mlw_quizmaster2.php&&mlw_quiz_page=$mlw_qmn_quiz_page\">></a>";
188
+ }
189
+ else
190
+ {
191
+ echo "<a class=\"next-page disabled\" title=\"Go to the next page\" href=\"?page=quiz-master-next/mlw_quizmaster2.php&&mlw_quiz_page=$mlw_qmn_quiz_page\">></a>";
192
+ }
193
+ }
194
+ else if( $mlw_qmn_quiz_page == 0 )
195
+ {
196
+ if( $mlw_qmn_quiz_left > $mlw_qmn_table_limit )
197
+ {
198
+ echo "<a class=\"prev-page disabled\" title=\"Go to the previous page\" href=\"?page=quiz-master-next/mlw_quizmaster2.php&&mlw_quiz_page=$mlw_qmn_previous_page\"><</a>";
199
+ echo "<span class=\"paging-input\">$mlw_current_page of $mlw_total_pages</span>";
200
+ echo "<a class=\"next-page\" title=\"Go to the next page\" href=\"?page=quiz-master-next/mlw_quizmaster2.php&&mlw_quiz_page=$mlw_qmn_quiz_page\">></a>";
201
+ }
202
+ }
203
+ else if( $mlw_qmn_quiz_left < $mlw_qmn_table_limit )
204
+ {
205
+ $mlw_qmn_previous_page = $mlw_qmn_quiz_page - 2;
206
+ echo "<a class=\"prev-page\" title=\"Go to the previous page\" href=\"?page=quiz-master-next/mlw_quizmaster2.php&&mlw_quiz_page=$mlw_qmn_previous_page\"><</a>";
207
+ echo "<span class=\"paging-input\">$mlw_current_page of $mlw_total_pages</span>";
208
+ echo "<a class=\"next-page disabled\" title=\"Go to the next page\" href=\"?page=quiz-master-next/mlw_quizmaster2.php&&mlw_quiz_page=$mlw_qmn_quiz_page\">></a>";
209
+ }
210
+ ?>
211
+ </span>
212
+ <br class="clear">
213
+ </div>
214
+ </div>
215
+ <table class="widefat">
216
+ <thead>
217
+ <tr>
218
+ <th>Quiz ID</th>
219
+ <th><?php _e('Quiz Name', 'quiz-master-next'); ?></th>
220
+ <th><?php _e('Quiz Shortcode', 'quiz-master-next'); ?></th>
221
+ <th><?php _e('Leaderboard Shortcode', 'quiz-master-next'); ?></th>
222
+ <th><?php _e('Quiz Views', 'quiz-master-next'); ?></th>
223
+ <th><?php _e('Quiz Taken', 'quiz-master-next'); ?></th>
224
+ <th><?php _e('Last Modified', 'quiz-master-next'); ?></th>
225
+ </tr>
226
+ </thead>
227
+ <tbody id="the-list">
228
+ <?php
229
+ $quotes_list = "";
230
+ $display = "";
231
+ $alternate = "";
232
+ foreach($mlw_quiz_data as $mlw_quiz_info) {
233
+ if($alternate) $alternate = "";
234
+ else $alternate = " class=\"alternate\"";
235
+ $quotes_list .= "<tr{$alternate}>";
236
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_id . "</span></td>";
237
+ $quotes_list .= "<td class='post-title column-title'><span style='font-size:16px;'>" . esc_html($mlw_quiz_info->quiz_name) ." </span><span style='color:green;font-size:12px;'><a onclick=\"editQuizName('".$mlw_quiz_info->quiz_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='javascript:();'>(".__('Edit Name', 'quiz-master-next').")</a></span>";
238
+ $quotes_list .= "<div class=\"row-actions\">
239
+ <a class='linkOptions' href='admin.php?page=mlw_quiz_options&&quiz_id=".$mlw_quiz_info->quiz_id."'>".__('Edit', 'quiz-master-next')."</a>
240
+ | <a class='linkOptions' href='admin.php?page=mlw_quiz_results&&quiz_id=".$mlw_quiz_info->quiz_id."'>".__('Results', 'quiz-master-next')."</a>
241
+ | <a href='javascript:();' class='linkOptions' onclick=\"duplicateQuiz('".$mlw_quiz_info->quiz_id."','".esc_js($mlw_quiz_info->quiz_name)."')\">".__('Duplicate', 'quiz-master-next')."</a>
242
+ | <a class='linkOptions linkDelete' onclick=\"deleteQuiz('".$mlw_quiz_info->quiz_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='javascript:();'>".__('Delete', 'quiz-master-next')."</a>
243
+ </div></td>";
244
+ $quotes_list .= "<td><span style='font-size:16px;'>[mlw_quizmaster quiz=".$mlw_quiz_info->quiz_id."]</span></td>";
245
+ $quotes_list .= "<td><span style='font-size:16px;'>[mlw_quizmaster_leaderboard mlw_quiz=".$mlw_quiz_info->quiz_id."]</span></td>";
246
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_views . "</span></td>";
247
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_taken ."</span></td>";
248
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->last_activity ."</span></td>";
249
+ $quotes_list .= "</tr>";
250
+ }
251
+ echo $quotes_list; ?>
252
+ </tbody>
253
+ <tfoot>
254
+ <tr>
255
+ <th>Quiz ID</th>
256
+ <th><?php _e('Quiz Name', 'quiz-master-next'); ?></th>
257
+ <th><?php _e('Quiz Shortcode', 'quiz-master-next'); ?></th>
258
+ <th><?php _e('Leaderboard Shortcode', 'quiz-master-next'); ?></th>
259
+ <th><?php _e('Quiz Views', 'quiz-master-next'); ?></th>
260
+ <th><?php _e('Quiz Taken', 'quiz-master-next'); ?></th>
261
+ <th><?php _e('Last Modified', 'quiz-master-next'); ?></th>
262
+ </tr>
263
+ </tfoot>
264
+ </table>
265
+ </div>
266
+ <div style="width: 15%; float:right;">
267
+ <h3 style="text-align: center;">My Local Webstop News</h3>
268
+ <?php
269
+ $qmn_rss = array();
270
+ $qmn_feed = fetch_feed('http://mylocalwebstop.com/category/our-blog/feed');
271
+ if (!is_wp_error($qmn_feed)) {
272
+ $qmn_feed_items = $qmn_feed->get_items(0, 5);
273
+ foreach ($qmn_feed_items as $feed_item) {
274
+ $qmn_rss[] = array(
275
+ 'link' => $feed_item->get_link(),
276
+ 'title' => $feed_item->get_title(),
277
+ 'description' => $feed_item->get_description(),
278
+ 'date' => $feed_item->get_date( 'F j Y' ),
279
+ 'author' => $feed_item->get_author()->get_name()
280
+ );
281
+ }
282
+ }
283
+ foreach($qmn_rss as $item)
284
+ {
285
+ ?>
286
+ <h3><a target='_blank' href="<?php echo $item['link']; ?>"><?php echo $item['title']; ?></a></h3>
287
+ <p>By <?php echo $item['author']; ?> on <?php echo $item['date']; ?></p>
288
+ <div>
289
+ <?php echo $item['description']; ?>
290
+ </div>
291
+ <?php
292
+ }
293
+ ?>
294
+ </div>
295
+ <div style="clear: both;"></div>
296
+ <?php echo mlw_qmn_show_adverts(); ?>
297
+ <!--Dialogs-->
298
+
299
+ <!--New Quiz Dialog-->
300
+ <div id="new_quiz_dialog" title="Create New Quiz" style="display:none;">
301
+ <form action='' method='post'>
302
+ <input type='hidden' name='create_quiz' value='confirmation' />
303
+ <table class="wide" style="text-align: left; white-space: nowrap;">
304
+ <thead>
305
+
306
+ <tr valign="top">
307
+ <th scope="row">&nbsp;</th>
308
+ <td></td>
309
+ </tr>
310
+
311
+ <tr valign="top">
312
+ <th scope="row"><h3><?php _e('Create New Quiz', 'quiz-master-next'); ?></h3></th>
313
+ <td></td>
314
+ </tr>
315
+
316
+ <tr valign="top">
317
+ <th scope="row"><?php _e('Quiz Name', 'quiz-master-next'); ?></th>
318
+ <td>
319
+ <input type="text" name="quiz_name" value="" style="border-color:#000000;
320
+ color:#3300CC;
321
+ cursor:hand;"/>
322
+ </td>
323
+ </tr>
324
+ </thead>
325
+ </table>
326
+ <p class='submit'><input type='submit' class='button-primary' value='<?php _e('Create Quiz', 'quiz-master-next'); ?>' /></p>
327
+ </form>
328
+ </div>
329
+
330
+ <!--Edit Quiz Name Dialog-->
331
+ <div id="edit_dialog" title="Edit Quiz Name" style="display:none;">
332
+ <h3><?php _e('Quiz Name:', 'quiz-master-next'); ?></h3><br />
333
+ <form action='' method='post'>
334
+ <input type="text" id="edit_quiz_name" name="edit_quiz_name" />
335
+ <input type="hidden" id="edit_quiz_id" name="edit_quiz_id" />
336
+ <input type='hidden' name='quiz_name_editted' value='confirmation' />
337
+ <input type="submit" class="button-primary" value="Edit" />
338
+ </form>
339
+ </div>
340
+
341
+ <!--Duplicate Quiz Dialog-->
342
+ <div id="duplicate_dialog" title="Duplicate Quiz" style="display:none;">
343
+ <h3><?php _e('Duplicate this quiz?', 'quiz-master-next'); ?></h3><br />
344
+ <form action='' method='post'>
345
+ <label for="duplicate_questions"><?php _e('Duplicate questions with quiz', 'quiz-master-next'); ?></label><input type="checkbox" name="duplicate_questions" id="duplicate_questions"/><br />
346
+ <br />
347
+ <label for="duplicate_new_quiz_name"><?php _e('Name Of New Quiz:', 'quiz-master-next'); ?></label><input type="text" id="duplicate_new_quiz_name" name="duplicate_new_quiz_name" /><br />
348
+ <input type="hidden" id="duplicate_quiz_id" name="duplicate_quiz_id" />
349
+ <input type='hidden' name='duplicate_quiz' value='confirmation' />
350
+ <input type="submit" class="button-primary" value="<?php _e('Duplicate', 'quiz-master-next'); ?>" />
351
+ </form>
352
+ </div>
353
+
354
+ <!--Delete Quiz Dialog-->
355
+ <div id="delete_dialog" title="Delete Quiz?" style="display:none;">
356
+ <h3><b><?php _e('Are you sure you want to delete this quiz?', 'quiz-master-next'); ?></b></h3>
357
+ <form action='' method='post'>
358
+ <input type='hidden' name='delete_quiz' value='confirmation' />
359
+ <input type='hidden' id='quiz_id' name='quiz_id' value='' />
360
+ <input type='hidden' id='delete_quiz_name' name='delete_quiz_name' value='' />
361
+ <p class='submit'><input type='submit' class='button-primary' value='<?php _e('Delete Quiz', 'quiz-master-next'); ?>' /></p>
362
+ </form>
363
+ </div>
364
+ </div>
365
+ </div>
366
+ <?php
367
+ }
368
+ ?>
includes/{mlw_quiz_creator.php → qmn_quiz_creator.php} RENAMED
@@ -17,7 +17,7 @@ class QMNQuizCreator
17
  * @since 3.7.1
18
  */
19
  private $quiz_id;
20
-
21
  /**
22
  * If the quiz ID is set, store it as the class quiz ID
23
  *
@@ -30,32 +30,32 @@ class QMNQuizCreator
30
  $this->quiz_id = intval($_GET["quiz_id"]);
31
  }
32
  }
33
-
34
  /**
35
  * Sets quiz ID
36
- *
37
  * @since 3.8.1
38
  * @access public
39
- * @return void
40
  */
41
  public function set_id($quiz_id)
42
  {
43
  $this->quiz_id = intval($quiz_id);
44
  }
45
-
46
  /**
47
  * Retrieves setting store in quiz_settings
48
- *
49
  * @since 3.8.1
50
  * @access public
51
- * @return string The value of the setting
52
  */
53
  public function get_setting($setting_name)
54
  {
55
  global $wpdb;
56
  $qmn_settings_array = '';
57
  $qmn_quiz_settings = $wpdb->get_var( $wpdb->prepare( "SELECT quiz_settings FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=%d", $this->quiz_id ) );
58
- if (is_serialized($qmn_quiz_settings) && is_array(@unserialize($qmn_quiz_settings)))
59
  {
60
  $qmn_settings_array = @unserialize($qmn_quiz_settings);
61
  }
@@ -67,12 +67,12 @@ class QMNQuizCreator
67
  {
68
  return '';
69
  }
70
-
71
  }
72
-
73
  /**
74
  * Updates setting stored in quiz_settings
75
- *
76
  * @since 3.8.1
77
  * @access public
78
  * @return bool True if update was successful
@@ -82,22 +82,22 @@ class QMNQuizCreator
82
  global $wpdb;
83
  $qmn_settings_array = array();
84
  $qmn_quiz_settings = $wpdb->get_var( $wpdb->prepare( "SELECT quiz_settings FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=%d", $this->quiz_id ) );
85
- if (is_serialized($qmn_quiz_settings) && is_array(@unserialize($qmn_quiz_settings)))
86
  {
87
  $qmn_settings_array = @unserialize($qmn_quiz_settings);
88
  }
89
- $qmn_settings_array[$setting_name] = $setting_value;
90
  $qmn_serialized_array = serialize($qmn_settings_array);
91
- $results = $wpdb->update(
92
- $wpdb->prefix . "mlw_quizzes",
93
- array(
94
- 'quiz_settings' => $qmn_serialized_array
95
- ),
96
- array( 'quiz_id' => $this->quiz_id ),
97
- array(
98
  '%s'
99
  ),
100
- array( '%d' )
101
  );
102
  if ($results != false)
103
  {
@@ -108,10 +108,10 @@ class QMNQuizCreator
108
  return false;
109
  }
110
  }
111
-
112
  /**
113
  * Deletes setting stored in quiz_settings
114
- *
115
  * @since 3.8.1
116
  * @access public
117
  * @return void
@@ -121,7 +121,7 @@ class QMNQuizCreator
121
  global $wpdb;
122
  $qmn_settings_array = array();
123
  $qmn_quiz_settings = $wpdb->get_var( $wpdb->prepare( "SELECT quiz_settings FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=%d", $this->quiz_id ) );
124
- if (is_serialized($qmn_quiz_settings) && is_array(@unserialize($qmn_quiz_settings)))
125
  {
126
  $qmn_settings_array = @unserialize($qmn_quiz_settings);
127
  }
@@ -130,21 +130,21 @@ class QMNQuizCreator
130
  unset($qmn_settings_array[$setting_name]);
131
  }
132
  $qmn_serialized_array = serialize($qmn_settings_array);
133
- $results = $wpdb->update(
134
- $wpdb->prefix . "mlw_quizzes",
135
- array(
136
- 'quiz_settings' => $qmn_serialized_array
137
- ),
138
- array( 'quiz_id' => $this->quiz_id ),
139
- array(
140
  '%s'
141
  ),
142
- array( '%d' )
143
  );
144
  }
145
-
146
-
147
-
148
  /**
149
  * Creates a new quiz with the default settings
150
  *
@@ -176,7 +176,11 @@ class QMNQuizCreator
176
  text-align: left;
177
  }
178
  div.quiz_section {
179
-
 
 
 
 
180
  }
181
  div.mlw_qmn_timer {
182
  position:fixed;
@@ -212,54 +216,54 @@ class QMNQuizCreator
212
  }
213
  .mlw_qmn_comment_section_text
214
  {
215
- font-weight: bold;
216
  }";
217
  $mlw_question_answer_default = "%QUESTION%<br /> Answer Provided: %USER_ANSWER%<br /> Correct Answer: %CORRECT_ANSWER%<br /> Comments Entered: %USER_COMMENTS%<br />";
218
- $results = $wpdb->insert(
219
- $wpdb->prefix . "mlw_quizzes",
220
- array(
221
- 'quiz_name' => $quiz_name,
222
  'message_before' => 'Enter your text here',
223
- 'message_after' => 'Enter your text here',
224
  'message_comment' => 'Enter your text here',
225
- 'message_end_template' => '',
226
  'user_email_template' => 'Enter your text here',
227
- 'admin_email_template' => 'Enter your text here',
228
  'submit_button_text' => 'Submit Quiz',
229
- 'name_field_text' => 'Name',
230
  'business_field_text' => 'Business',
231
- 'email_field_text' => 'Email',
232
  'phone_field_text' => 'Phone Number',
233
- 'comment_field_text' => 'Comments',
234
  'email_from_text' => 'Wordpress',
235
- 'question_answer_template' => $mlw_question_answer_default,
236
  'leaderboard_template' => $mlw_leaderboard_default,
237
- 'system' => 0,
238
  'randomness_order' => 0,
239
- 'loggedin_user_contact' => 0,
240
  'show_score' => 0,
241
- 'send_user_email' => 0,
242
  'send_admin_email' => 0,
243
- 'contact_info_location' => 0,
244
  'user_name' => 0,
245
- 'user_comp' => 0,
246
  'user_email' => 0,
247
- 'user_phone' => 0,
248
  'admin_email' => get_option( 'admin_email', 'Enter email' ),
249
- 'comment_section' => 0,
250
  'question_from_total' => 0,
251
- 'total_user_tries' => 0,
252
  'total_user_tries_text' => 'Enter Your Text Here',
253
- 'certificate_template' => 'Enter Your Text Here!',
254
  'social_media' => 0,
255
- 'social_media_text' => 'I just scored %CORRECT_SCORE%% on %QUIZ_NAME%!',
256
  'pagination' => 0,
257
  'pagination_text' => 'Next',
258
- 'timer_limit' => 0,
259
  'quiz_stye' => $mlw_style_default,
260
- 'question_numbering' => 0,
261
  'quiz_settings' => '',
262
- 'theme_selected' => 'default',
263
  'last_activity' => date("Y-m-d H:i:s"),
264
  'require_log_in' => 0,
265
  'require_log_in_text' => 'Enter Your Text Here',
@@ -267,53 +271,53 @@ class QMNQuizCreator
267
  'limit_total_entries_text' => 'Enter Your Text Here',
268
  'scheduled_timeframe' => '',
269
  'scheduled_timeframe_text' => '',
270
- 'quiz_views' => 0,
271
  'quiz_taken' => 0,
272
  'deleted' => 0
273
- ),
274
- array(
275
- '%s',
276
  '%s',
277
- '%s',
278
  '%s',
279
- '%s',
280
  '%s',
281
- '%s',
282
  '%s',
283
- '%s',
284
  '%s',
285
- '%s',
286
  '%s',
287
- '%s',
288
  '%s',
289
- '%s',
290
  '%s',
291
- '%d',
 
 
 
 
 
 
 
 
 
292
  '%d',
293
- '%d',
294
  '%d',
295
- '%d',
296
  '%d',
297
- '%d',
298
  '%d',
299
- '%d',
300
  '%d',
301
- '%d',
 
 
 
 
 
 
 
302
  '%s',
303
- '%d',
304
  '%d',
305
- '%d',
306
  '%s',
307
- '%s',
308
  '%d',
309
- '%s',
310
  '%d',
311
  '%s',
312
- '%d',
313
  '%s',
314
- '%d',
315
  '%s',
316
- '%s',
317
  '%s',
318
  '%d',
319
  '%s',
@@ -321,14 +325,14 @@ class QMNQuizCreator
321
  '%s',
322
  '%s',
323
  '%s',
324
- '%d',
325
  '%d',
326
  '%d'
327
- )
328
  );
329
  if ($results != false)
330
  {
331
- $mlwQuizMasterNext->alertManager->newAlert('Your new quiz has been created successfully. To begin editing your quiz, click the Edit link on the new quiz.', 'success');
332
  //Insert Action Into Audit Trail
333
  global $current_user;
334
  get_currentuserinfo();
@@ -340,11 +344,11 @@ class QMNQuizCreator
340
  }
341
  else
342
  {
343
- $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0001.', 'error');
344
  }
345
  do_action('qmn_quiz_created', $wpdb->insert_id);
346
  }
347
-
348
  /**
349
  * Deletes a quiz with the given quiz_id
350
  *
@@ -356,32 +360,32 @@ class QMNQuizCreator
356
  {
357
  global $mlwQuizMasterNext;
358
  global $wpdb;
359
- $results = $wpdb->update(
360
- $wpdb->prefix . "mlw_quizzes",
361
- array(
362
- 'deleted' => 1
363
- ),
364
- array( 'quiz_id' => $quiz_id ),
365
- array(
366
  '%d'
367
- ),
368
- array( '%d' )
369
  );
370
- $delete_question_results = $wpdb->update(
371
- $wpdb->prefix . "mlw_questions",
372
- array(
373
- 'deleted' => 1
374
- ),
375
- array( 'quiz_id' => $quiz_id ),
376
- array(
377
  '%d'
378
- ),
379
- array( '%d' )
380
  );
381
  if ($results != false)
382
  {
383
- $mlwQuizMasterNext->alertManager->newAlert('Your quiz has been deleted successfully.', 'success');
384
-
385
  //Insert Action Into Audit Trail
386
  global $current_user;
387
  get_currentuserinfo();
@@ -393,11 +397,11 @@ class QMNQuizCreator
393
  }
394
  else
395
  {
396
- $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0002.', 'error');
397
  }
398
  do_action('qmn_quiz_deleted', $quiz_id);
399
  }
400
-
401
  /**
402
  * Edits the name of the quiz with the given ID
403
  *
@@ -409,21 +413,21 @@ class QMNQuizCreator
409
  {
410
  global $mlwQuizMasterNext;
411
  global $wpdb;
412
- $results = $wpdb->update(
413
- $wpdb->prefix . "mlw_quizzes",
414
- array(
415
- 'quiz_name' => $quiz_name
416
- ),
417
- array( 'quiz_id' => $quiz_id ),
418
- array(
419
  '%s'
420
- ),
421
- array( '%d' )
422
  );
423
  if ($results != false)
424
  {
425
- $mlwQuizMasterNext->alertManager->newAlert('Your quiz name has been updated successfully.', 'success');
426
-
427
  //Insert Action Into Audit Trail
428
  global $current_user;
429
  get_currentuserinfo();
@@ -435,11 +439,11 @@ class QMNQuizCreator
435
  }
436
  else
437
  {
438
- $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0003.', 'error');
439
  }
440
  do_action('qmn_quiz_name_edited', $quiz_id);
441
  }
442
-
443
  /**
444
  * Duplicates the quiz with the given ID and gives new quiz the given quiz name
445
  *
@@ -451,48 +455,48 @@ class QMNQuizCreator
451
  {
452
  global $mlwQuizMasterNext;
453
  global $wpdb;
454
-
455
  $table_name = $wpdb->prefix . "mlw_quizzes";
456
  $mlw_qmn_duplicate_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table_name WHERE quiz_id=%d", $quiz_id ) );
457
- $results = $wpdb->insert(
458
- $table_name,
459
- array(
460
  'quiz_name' => $quiz_name,
461
  'message_before' => $mlw_qmn_duplicate_data->message_before,
462
- 'message_after' => $mlw_qmn_duplicate_data->message_after,
463
  'message_comment' => $mlw_qmn_duplicate_data->message_comment,
464
  'message_end_template' => $mlw_qmn_duplicate_data->message_end_template,
465
- 'user_email_template' => $mlw_qmn_duplicate_data->user_email_template,
466
  'admin_email_template' => $mlw_qmn_duplicate_data->admin_email_template,
467
  'submit_button_text' => $mlw_qmn_duplicate_data->submit_button_text,
468
- 'name_field_text' => $mlw_qmn_duplicate_data->name_field_text,
469
  'business_field_text' => $mlw_qmn_duplicate_data->business_field_text,
470
  'email_field_text' => $mlw_qmn_duplicate_data->email_field_text,
471
- 'phone_field_text' => $mlw_qmn_duplicate_data->phone_field_text,
472
  'comment_field_text' => $mlw_qmn_duplicate_data->comment_field_text,
473
  'email_from_text' => $mlw_qmn_duplicate_data->email_from_text,
474
- 'question_answer_template' => $mlw_qmn_duplicate_data->question_answer_template,
475
  'leaderboard_template' => $mlw_qmn_duplicate_data->leaderboard_template,
476
  'system' => $mlw_qmn_duplicate_data->system,
477
- 'randomness_order' => $mlw_qmn_duplicate_data->randomness_order,
478
  'loggedin_user_contact' => $mlw_qmn_duplicate_data->loggedin_user_contact,
479
  'show_score' => $mlw_qmn_duplicate_data->show_score,
480
- 'send_user_email' => $mlw_qmn_duplicate_data->send_user_email,
481
  'send_admin_email' => $mlw_qmn_duplicate_data->send_admin_email,
482
  'contact_info_location' => $mlw_qmn_duplicate_data->contact_info_location,
483
- 'user_name' => $mlw_qmn_duplicate_data->user_name,
484
  'user_comp' => $mlw_qmn_duplicate_data->user_comp,
485
  'user_email' => $mlw_qmn_duplicate_data->user_email,
486
- 'user_phone' => $mlw_qmn_duplicate_data->user_phone,
487
  'admin_email' => get_option( 'admin_email', 'Enter email' ),
488
  'comment_section' => $mlw_qmn_duplicate_data->comment_section,
489
- 'question_from_total' => $mlw_qmn_duplicate_data->question_from_total,
490
  'total_user_tries' => $mlw_qmn_duplicate_data->total_user_tries,
491
  'total_user_tries_text' => $mlw_qmn_duplicate_data->total_user_tries_text,
492
- 'certificate_template' => $mlw_qmn_duplicate_data->certificate_template,
493
  'social_media' => $mlw_qmn_duplicate_data->social_media,
494
  'social_media_text' => $mlw_qmn_duplicate_data->social_media_text,
495
- 'pagination' => $mlw_qmn_duplicate_data->pagination,
496
  'pagination_text' => $mlw_qmn_duplicate_data->pagination_text,
497
  'timer_limit' => $mlw_qmn_duplicate_data->timer_limit,
498
  'quiz_stye' => $mlw_qmn_duplicate_data->quiz_stye,
@@ -507,28 +511,28 @@ class QMNQuizCreator
507
  'scheduled_timeframe' => $mlw_qmn_duplicate_data->scheduled_timeframe,
508
  'scheduled_timeframe_text' => $mlw_qmn_duplicate_data->scheduled_timeframe_text,
509
  'quiz_views' => 0,
510
- 'quiz_taken' => 0,
511
  'deleted' => 0
512
  ),
513
- array(
 
 
 
 
514
  '%s',
515
  '%s',
516
- '%s',
517
  '%s',
518
  '%s',
519
- '%s',
520
  '%s',
521
  '%s',
522
- '%s',
523
  '%s',
524
  '%s',
525
- '%s',
526
  '%s',
527
  '%s',
528
- '%s',
529
  '%s',
 
 
530
  '%d',
531
- '%d',
532
  '%d',
533
  '%d',
534
  '%d',
@@ -543,7 +547,7 @@ class QMNQuizCreator
543
  '%d',
544
  '%d',
545
  '%s',
546
- '%s',
547
  '%d',
548
  '%s',
549
  '%d',
@@ -568,8 +572,8 @@ class QMNQuizCreator
568
  $mlw_new_id = $wpdb->insert_id;
569
  if ($results != false)
570
  {
571
- $mlwQuizMasterNext->alertManager->newAlert('Your quiz has been duplicated successfully.', 'success');
572
-
573
  //Insert Action Into Audit Trail
574
  global $current_user;
575
  get_currentuserinfo();
@@ -581,7 +585,7 @@ class QMNQuizCreator
581
  }
582
  else
583
  {
584
- $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0011.', 'error');
585
  }
586
  if ($is_duplicating_questions)
587
  {
@@ -589,14 +593,14 @@ class QMNQuizCreator
589
  $mlw_current_questions = $wpdb->get_results("SELECT * FROM $table_name WHERE deleted=0 AND quiz_id=".$quiz_id);
590
  foreach ($mlw_current_questions as $mlw_question)
591
  {
592
- $question_results = $wpdb->insert(
593
- $table_name,
594
- array(
595
  'quiz_id' => $mlw_new_id,
596
  'question_name' => $mlw_question->question_name,
597
- 'answer_array' => $mlw_question->answer_array,
598
  'answer_one' => $mlw_question->answer_one,
599
- 'answer_one_points' => $mlw_question->answer_one_points,
600
  'answer_two' => $mlw_question->answer_two,
601
  'answer_two_points' => $mlw_question->answer_two_points,
602
  'answer_three' => $mlw_question->answer_three,
@@ -612,14 +616,15 @@ class QMNQuizCreator
612
  'comments' => $mlw_question->comments,
613
  'hints' => $mlw_question->hints,
614
  'question_order' => $mlw_question->question_order,
615
- 'question_type' => $mlw_question->question_type,
616
  'question_settings' => $mlw_question->question_settings,
 
617
  'deleted' => 0
618
- ),
619
- array(
620
  '%d',
621
  '%s',
622
- '%s',
623
  '%s',
624
  '%d',
625
  '%s',
@@ -639,12 +644,13 @@ class QMNQuizCreator
639
  '%d',
640
  '%d',
641
  '%s',
 
642
  '%d'
643
- )
644
  );
645
  if ($question_results == false)
646
  {
647
- $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0020.', 'error');
648
  }
649
  }
650
  }
17
  * @since 3.7.1
18
  */
19
  private $quiz_id;
20
+
21
  /**
22
  * If the quiz ID is set, store it as the class quiz ID
23
  *
30
  $this->quiz_id = intval($_GET["quiz_id"]);
31
  }
32
  }
33
+
34
  /**
35
  * Sets quiz ID
36
+ *
37
  * @since 3.8.1
38
  * @access public
39
+ * @return void
40
  */
41
  public function set_id($quiz_id)
42
  {
43
  $this->quiz_id = intval($quiz_id);
44
  }
45
+
46
  /**
47
  * Retrieves setting store in quiz_settings
48
+ *
49
  * @since 3.8.1
50
  * @access public
51
+ * @return string The value of the setting
52
  */
53
  public function get_setting($setting_name)
54
  {
55
  global $wpdb;
56
  $qmn_settings_array = '';
57
  $qmn_quiz_settings = $wpdb->get_var( $wpdb->prepare( "SELECT quiz_settings FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=%d", $this->quiz_id ) );
58
+ if (is_serialized($qmn_quiz_settings) && is_array(@unserialize($qmn_quiz_settings)))
59
  {
60
  $qmn_settings_array = @unserialize($qmn_quiz_settings);
61
  }
67
  {
68
  return '';
69
  }
70
+
71
  }
72
+
73
  /**
74
  * Updates setting stored in quiz_settings
75
+ *
76
  * @since 3.8.1
77
  * @access public
78
  * @return bool True if update was successful
82
  global $wpdb;
83
  $qmn_settings_array = array();
84
  $qmn_quiz_settings = $wpdb->get_var( $wpdb->prepare( "SELECT quiz_settings FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=%d", $this->quiz_id ) );
85
+ if (is_serialized($qmn_quiz_settings) && is_array(@unserialize($qmn_quiz_settings)))
86
  {
87
  $qmn_settings_array = @unserialize($qmn_quiz_settings);
88
  }
89
+ $qmn_settings_array[$setting_name] = $setting_value;
90
  $qmn_serialized_array = serialize($qmn_settings_array);
91
+ $results = $wpdb->update(
92
+ $wpdb->prefix . "mlw_quizzes",
93
+ array(
94
+ 'quiz_settings' => $qmn_serialized_array
95
+ ),
96
+ array( 'quiz_id' => $this->quiz_id ),
97
+ array(
98
  '%s'
99
  ),
100
+ array( '%d' )
101
  );
102
  if ($results != false)
103
  {
108
  return false;
109
  }
110
  }
111
+
112
  /**
113
  * Deletes setting stored in quiz_settings
114
+ *
115
  * @since 3.8.1
116
  * @access public
117
  * @return void
121
  global $wpdb;
122
  $qmn_settings_array = array();
123
  $qmn_quiz_settings = $wpdb->get_var( $wpdb->prepare( "SELECT quiz_settings FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=%d", $this->quiz_id ) );
124
+ if (is_serialized($qmn_quiz_settings) && is_array(@unserialize($qmn_quiz_settings)))
125
  {
126
  $qmn_settings_array = @unserialize($qmn_quiz_settings);
127
  }
130
  unset($qmn_settings_array[$setting_name]);
131
  }
132
  $qmn_serialized_array = serialize($qmn_settings_array);
133
+ $results = $wpdb->update(
134
+ $wpdb->prefix . "mlw_quizzes",
135
+ array(
136
+ 'quiz_settings' => $qmn_serialized_array
137
+ ),
138
+ array( 'quiz_id' => $this->quiz_id ),
139
+ array(
140
  '%s'
141
  ),
142
+ array( '%d' )
143
  );
144
  }
145
+
146
+
147
+
148
  /**
149
  * Creates a new quiz with the default settings
150
  *
176
  text-align: left;
177
  }
178
  div.quiz_section {
179
+
180
+ }
181
+ .mlw_horizontal_choice
182
+ {
183
+ margin-right: 20px;
184
  }
185
  div.mlw_qmn_timer {
186
  position:fixed;
216
  }
217
  .mlw_qmn_comment_section_text
218
  {
219
+ font-weight: bold;
220
  }";
221
  $mlw_question_answer_default = "%QUESTION%<br /> Answer Provided: %USER_ANSWER%<br /> Correct Answer: %CORRECT_ANSWER%<br /> Comments Entered: %USER_COMMENTS%<br />";
222
+ $results = $wpdb->insert(
223
+ $wpdb->prefix . "mlw_quizzes",
224
+ array(
225
+ 'quiz_name' => $quiz_name,
226
  'message_before' => 'Enter your text here',
227
+ 'message_after' => 'Enter your text here',
228
  'message_comment' => 'Enter your text here',
229
+ 'message_end_template' => '',
230
  'user_email_template' => 'Enter your text here',
231
+ 'admin_email_template' => 'Enter your text here',
232
  'submit_button_text' => 'Submit Quiz',
233
+ 'name_field_text' => 'Name',
234
  'business_field_text' => 'Business',
235
+ 'email_field_text' => 'Email',
236
  'phone_field_text' => 'Phone Number',
237
+ 'comment_field_text' => 'Comments',
238
  'email_from_text' => 'Wordpress',
239
+ 'question_answer_template' => $mlw_question_answer_default,
240
  'leaderboard_template' => $mlw_leaderboard_default,
241
+ 'system' => 0,
242
  'randomness_order' => 0,
243
+ 'loggedin_user_contact' => 0,
244
  'show_score' => 0,
245
+ 'send_user_email' => 0,
246
  'send_admin_email' => 0,
247
+ 'contact_info_location' => 0,
248
  'user_name' => 0,
249
+ 'user_comp' => 0,
250
  'user_email' => 0,
251
+ 'user_phone' => 0,
252
  'admin_email' => get_option( 'admin_email', 'Enter email' ),
253
+ 'comment_section' => 0,
254
  'question_from_total' => 0,
255
+ 'total_user_tries' => 0,
256
  'total_user_tries_text' => 'Enter Your Text Here',
257
+ 'certificate_template' => 'Enter Your Text Here!',
258
  'social_media' => 0,
259
+ 'social_media_text' => 'I just scored %CORRECT_SCORE%% on %QUIZ_NAME%!',
260
  'pagination' => 0,
261
  'pagination_text' => 'Next',
262
+ 'timer_limit' => 0,
263
  'quiz_stye' => $mlw_style_default,
264
+ 'question_numbering' => 0,
265
  'quiz_settings' => '',
266
+ 'theme_selected' => 'default',
267
  'last_activity' => date("Y-m-d H:i:s"),
268
  'require_log_in' => 0,
269
  'require_log_in_text' => 'Enter Your Text Here',
271
  'limit_total_entries_text' => 'Enter Your Text Here',
272
  'scheduled_timeframe' => '',
273
  'scheduled_timeframe_text' => '',
274
+ 'quiz_views' => 0,
275
  'quiz_taken' => 0,
276
  'deleted' => 0
277
+ ),
278
+ array(
279
+ '%s',
280
  '%s',
 
281
  '%s',
 
282
  '%s',
 
283
  '%s',
 
284
  '%s',
 
285
  '%s',
 
286
  '%s',
 
287
  '%s',
288
+ '%s',
289
+ '%s',
290
+ '%s',
291
+ '%s',
292
+ '%s',
293
+ '%s',
294
+ '%s',
295
+ '%d',
296
+ '%d',
297
+ '%d',
298
  '%d',
 
299
  '%d',
 
300
  '%d',
 
301
  '%d',
 
302
  '%d',
303
+ '%d',
304
+ '%d',
305
+ '%d',
306
+ '%s',
307
+ '%d',
308
+ '%d',
309
+ '%d',
310
+ '%s',
311
  '%s',
 
312
  '%d',
 
313
  '%s',
 
314
  '%d',
315
+ '%s',
316
  '%d',
317
  '%s',
318
+ '%d',
319
  '%s',
 
320
  '%s',
 
321
  '%s',
322
  '%d',
323
  '%s',
325
  '%s',
326
  '%s',
327
  '%s',
328
+ '%d',
329
  '%d',
330
  '%d'
331
+ )
332
  );
333
  if ($results != false)
334
  {
335
+ $mlwQuizMasterNext->alertManager->newAlert(__('Your new quiz has been created successfully. To begin editing your quiz, click the Edit link on the new quiz.', 'quiz-master-next'), 'success');
336
  //Insert Action Into Audit Trail
337
  global $current_user;
338
  get_currentuserinfo();
344
  }
345
  else
346
  {
347
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0001'), 'error');
348
  }
349
  do_action('qmn_quiz_created', $wpdb->insert_id);
350
  }
351
+
352
  /**
353
  * Deletes a quiz with the given quiz_id
354
  *
360
  {
361
  global $mlwQuizMasterNext;
362
  global $wpdb;
363
+ $results = $wpdb->update(
364
+ $wpdb->prefix . "mlw_quizzes",
365
+ array(
366
+ 'deleted' => 1
367
+ ),
368
+ array( 'quiz_id' => $quiz_id ),
369
+ array(
370
  '%d'
371
+ ),
372
+ array( '%d' )
373
  );
374
+ $delete_question_results = $wpdb->update(
375
+ $wpdb->prefix . "mlw_questions",
376
+ array(
377
+ 'deleted' => 1
378
+ ),
379
+ array( 'quiz_id' => $quiz_id ),
380
+ array(
381
  '%d'
382
+ ),
383
+ array( '%d' )
384
  );
385
  if ($results != false)
386
  {
387
+ $mlwQuizMasterNext->alertManager->newAlert(__('Your quiz has been deleted successfully.', 'quiz-master-next'), 'success');
388
+
389
  //Insert Action Into Audit Trail
390
  global $current_user;
391
  get_currentuserinfo();
397
  }
398
  else
399
  {
400
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0002'), 'error');
401
  }
402
  do_action('qmn_quiz_deleted', $quiz_id);
403
  }
404
+
405
  /**
406
  * Edits the name of the quiz with the given ID
407
  *
413
  {
414
  global $mlwQuizMasterNext;
415
  global $wpdb;
416
+ $results = $wpdb->update(
417
+ $wpdb->prefix . "mlw_quizzes",
418
+ array(
419
+ 'quiz_name' => $quiz_name
420
+ ),
421
+ array( 'quiz_id' => $quiz_id ),
422
+ array(
423
  '%s'
424
+ ),
425
+ array( '%d' )
426
  );
427
  if ($results != false)
428
  {
429
+ $mlwQuizMasterNext->alertManager->newAlert(__('Your quiz name has been updated successfully.', 'quiz-master-next'), 'success');
430
+
431
  //Insert Action Into Audit Trail
432
  global $current_user;
433
  get_currentuserinfo();
439
  }
440
  else
441
  {
442
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0003'), 'error');
443
  }
444
  do_action('qmn_quiz_name_edited', $quiz_id);
445
  }
446
+
447
  /**
448
  * Duplicates the quiz with the given ID and gives new quiz the given quiz name
449
  *
455
  {
456
  global $mlwQuizMasterNext;
457
  global $wpdb;
458
+
459
  $table_name = $wpdb->prefix . "mlw_quizzes";
460
  $mlw_qmn_duplicate_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table_name WHERE quiz_id=%d", $quiz_id ) );
461
+ $results = $wpdb->insert(
462
+ $table_name,
463
+ array(
464
  'quiz_name' => $quiz_name,
465
  'message_before' => $mlw_qmn_duplicate_data->message_before,
466
+ 'message_after' => $mlw_qmn_duplicate_data->message_after,
467
  'message_comment' => $mlw_qmn_duplicate_data->message_comment,
468
  'message_end_template' => $mlw_qmn_duplicate_data->message_end_template,
469
+ 'user_email_template' => $mlw_qmn_duplicate_data->user_email_template,
470
  'admin_email_template' => $mlw_qmn_duplicate_data->admin_email_template,
471
  'submit_button_text' => $mlw_qmn_duplicate_data->submit_button_text,
472
+ 'name_field_text' => $mlw_qmn_duplicate_data->name_field_text,
473
  'business_field_text' => $mlw_qmn_duplicate_data->business_field_text,
474
  'email_field_text' => $mlw_qmn_duplicate_data->email_field_text,
475
+ 'phone_field_text' => $mlw_qmn_duplicate_data->phone_field_text,
476
  'comment_field_text' => $mlw_qmn_duplicate_data->comment_field_text,
477
  'email_from_text' => $mlw_qmn_duplicate_data->email_from_text,
478
+ 'question_answer_template' => $mlw_qmn_duplicate_data->question_answer_template,
479
  'leaderboard_template' => $mlw_qmn_duplicate_data->leaderboard_template,
480
  'system' => $mlw_qmn_duplicate_data->system,
481
+ 'randomness_order' => $mlw_qmn_duplicate_data->randomness_order,
482
  'loggedin_user_contact' => $mlw_qmn_duplicate_data->loggedin_user_contact,
483
  'show_score' => $mlw_qmn_duplicate_data->show_score,
484
+ 'send_user_email' => $mlw_qmn_duplicate_data->send_user_email,
485
  'send_admin_email' => $mlw_qmn_duplicate_data->send_admin_email,
486
  'contact_info_location' => $mlw_qmn_duplicate_data->contact_info_location,
487
+ 'user_name' => $mlw_qmn_duplicate_data->user_name,
488
  'user_comp' => $mlw_qmn_duplicate_data->user_comp,
489
  'user_email' => $mlw_qmn_duplicate_data->user_email,
490
+ 'user_phone' => $mlw_qmn_duplicate_data->user_phone,
491
  'admin_email' => get_option( 'admin_email', 'Enter email' ),
492
  'comment_section' => $mlw_qmn_duplicate_data->comment_section,
493
+ 'question_from_total' => $mlw_qmn_duplicate_data->question_from_total,
494
  'total_user_tries' => $mlw_qmn_duplicate_data->total_user_tries,
495
  'total_user_tries_text' => $mlw_qmn_duplicate_data->total_user_tries_text,
496
+ 'certificate_template' => $mlw_qmn_duplicate_data->certificate_template,
497
  'social_media' => $mlw_qmn_duplicate_data->social_media,
498
  'social_media_text' => $mlw_qmn_duplicate_data->social_media_text,
499
+ 'pagination' => $mlw_qmn_duplicate_data->pagination,
500
  'pagination_text' => $mlw_qmn_duplicate_data->pagination_text,
501
  'timer_limit' => $mlw_qmn_duplicate_data->timer_limit,
502
  'quiz_stye' => $mlw_qmn_duplicate_data->quiz_stye,
511
  'scheduled_timeframe' => $mlw_qmn_duplicate_data->scheduled_timeframe,
512
  'scheduled_timeframe_text' => $mlw_qmn_duplicate_data->scheduled_timeframe_text,
513
  'quiz_views' => 0,
514
+ 'quiz_taken' => 0,
515
  'deleted' => 0
516
  ),
517
+ array(
518
+ '%s',
519
+ '%s',
520
+ '%s',
521
+ '%s',
522
  '%s',
523
  '%s',
 
524
  '%s',
525
  '%s',
 
526
  '%s',
527
  '%s',
 
528
  '%s',
529
  '%s',
 
530
  '%s',
531
  '%s',
 
532
  '%s',
533
+ '%s',
534
+ '%d',
535
  '%d',
 
536
  '%d',
537
  '%d',
538
  '%d',
547
  '%d',
548
  '%d',
549
  '%s',
550
+ '%s',
551
  '%d',
552
  '%s',
553
  '%d',
572
  $mlw_new_id = $wpdb->insert_id;
573
  if ($results != false)
574
  {
575
+ $mlwQuizMasterNext->alertManager->newAlert(__('Your quiz has been duplicated successfully.', 'quiz-master-next'), 'success');
576
+
577
  //Insert Action Into Audit Trail
578
  global $current_user;
579
  get_currentuserinfo();
585
  }
586
  else
587
  {
588
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0011'), 'error');
589
  }
590
  if ($is_duplicating_questions)
591
  {
593
  $mlw_current_questions = $wpdb->get_results("SELECT * FROM $table_name WHERE deleted=0 AND quiz_id=".$quiz_id);
594
  foreach ($mlw_current_questions as $mlw_question)
595
  {
596
+ $question_results = $wpdb->insert(
597
+ $table_name,
598
+ array(
599
  'quiz_id' => $mlw_new_id,
600
  'question_name' => $mlw_question->question_name,
601
+ 'answer_array' => $mlw_question->answer_array,
602
  'answer_one' => $mlw_question->answer_one,
603
+ 'answer_one_points' => $mlw_question->answer_one_points,
604
  'answer_two' => $mlw_question->answer_two,
605
  'answer_two_points' => $mlw_question->answer_two_points,
606
  'answer_three' => $mlw_question->answer_three,
616
  'comments' => $mlw_question->comments,
617
  'hints' => $mlw_question->hints,
618
  'question_order' => $mlw_question->question_order,
619
+ 'question_type_new' => $mlw_question->question_type_new,
620
  'question_settings' => $mlw_question->question_settings,
621
+ 'category' => $mlw_question->category,
622
  'deleted' => 0
623
+ ),
624
+ array(
625
  '%d',
626
  '%s',
627
+ '%s',
628
  '%s',
629
  '%d',
630
  '%s',
644
  '%d',
645
  '%d',
646
  '%s',
647
+ '%s',
648
  '%d'
649
+ )
650
  );
651
  if ($question_results == false)
652
  {
653
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0020'), 'error');
654
  }
655
  }
656
  }
includes/{mlw_quiz_install.php → qmn_quiz_install.php} RENAMED
@@ -8,7 +8,7 @@ function mlw_quiz_activate()
8
 
9
  $table_name = $wpdb->prefix . "mlw_quizzes";
10
 
11
- if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name)
12
 
13
  {
14
 
@@ -17,41 +17,41 @@ function mlw_quiz_activate()
17
  quiz_id mediumint(9) NOT NULL AUTO_INCREMENT,
18
 
19
  quiz_name TEXT NOT NULL,
20
-
21
  message_before TEXT NOT NULL,
22
-
23
  message_after TEXT NOT NULL,
24
-
25
  message_comment TEXT NOT NULL,
26
-
27
  message_end_template TEXT NOT NULL,
28
 
29
  user_email_template TEXT NOT NULL,
30
-
31
  admin_email_template TEXT NOT NULL,
32
-
33
  submit_button_text TEXT NOT NULL,
34
-
35
  name_field_text TEXT NOT NULL,
36
-
37
  business_field_text TEXT NOT NULL,
38
-
39
  email_field_text TEXT NOT NULL,
40
-
41
  phone_field_text TEXT NOT NULL,
42
-
43
  comment_field_text TEXT NOT NULL,
44
-
45
  email_from_text TEXT NOT NULL,
46
-
47
  question_answer_template TEXT NOT NULL,
48
-
49
  leaderboard_template TEXT NOT NULL,
50
 
51
  system INT NOT NULL,
52
-
53
  randomness_order INT NOT NULL,
54
-
55
  loggedin_user_contact INT NOT NULL,
56
 
57
  show_score INT NOT NULL,
@@ -59,7 +59,7 @@ function mlw_quiz_activate()
59
  send_user_email INT NOT NULL,
60
 
61
  send_admin_email INT NOT NULL,
62
-
63
  contact_info_location INT NOT NULL,
64
 
65
  user_name INT NOT NULL,
@@ -71,47 +71,47 @@ function mlw_quiz_activate()
71
  user_phone INT NOT NULL,
72
 
73
  admin_email TEXT NOT NULL,
74
-
75
  comment_section INT NOT NULL,
76
-
77
  question_from_total INT NOT NULL,
78
-
79
  total_user_tries INT NOT NULL,
80
-
81
  total_user_tries_text TEXT NOT NULL,
82
-
83
  certificate_template TEXT NOT NULL,
84
-
85
  social_media INT NOT NULL,
86
-
87
  social_media_text TEXT NOT NULL,
88
-
89
  pagination INT NOT NULL,
90
-
91
  pagination_text TEXT NOT NULL,
92
-
93
  timer_limit INT NOT NULL,
94
-
95
  quiz_stye TEXT NOT NULL,
96
-
97
  question_numbering INT NOT NULL,
98
-
99
  quiz_settings TEXT NOT NULL,
100
-
101
  theme_selected TEXT NOT NULL,
102
-
103
  last_activity DATETIME NOT NULL,
104
-
105
  require_log_in INT NOT NULL,
106
-
107
  require_log_in_text TEXT NOT NULL,
108
-
109
  limit_total_entries INT NOT NULL,
110
-
111
  limit_total_entries_text TEXT NOT NULL,
112
-
113
  scheduled_timeframe TEXT NOT NULL,
114
-
115
  scheduled_timeframe_text TEXT NOT NULL,
116
 
117
  quiz_views INT NOT NULL,
@@ -123,7 +123,7 @@ function mlw_quiz_activate()
123
  PRIMARY KEY (quiz_id)
124
 
125
  )
126
-
127
  CHARACTER SET utf8";
128
 
129
  $results = $wpdb->query( $sql );
@@ -135,7 +135,7 @@ function mlw_quiz_activate()
135
 
136
  $table_name = $wpdb->prefix . "mlw_questions";
137
 
138
- if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name)
139
 
140
  {
141
 
@@ -146,15 +146,15 @@ function mlw_quiz_activate()
146
  quiz_id INT NOT NULL,
147
 
148
  question_name TEXT NOT NULL,
149
-
150
  answer_array TEXT NOT NULL,
151
-
152
  answer_one TEXT NOT NULL,
153
-
154
  answer_one_points INT NOT NULL,
155
 
156
  answer_two TEXT NOT NULL,
157
-
158
  answer_two_points INT NOT NULL,
159
 
160
  answer_three TEXT NOT NULL,
@@ -174,25 +174,29 @@ function mlw_quiz_activate()
174
  answer_six_points INT NOT NULL,
175
 
176
  correct_answer INT NOT NULL,
177
-
178
  question_answer_info TEXT NOT NULL,
179
-
180
  comments INT NOT NULL,
181
-
182
  hints TEXT NOT NULL,
183
-
184
  question_order INT NOT NULL,
185
-
186
  question_type INT NOT NULL,
187
-
 
 
188
  question_settings TEXT NOT NULL,
189
 
 
 
190
  deleted INT NOT NULL,
191
 
192
  PRIMARY KEY (question_id)
193
 
194
  )
195
-
196
  CHARACTER SET utf8";
197
 
198
  $results = $wpdb->query( $sql );
@@ -200,12 +204,12 @@ function mlw_quiz_activate()
200
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
201
  dbDelta($sql);
202
  }
203
-
204
  global $wpdb;
205
 
206
  $table_name = $wpdb->prefix . "mlw_results";
207
 
208
- if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name)
209
 
210
  {
211
 
@@ -234,13 +238,13 @@ function mlw_quiz_activate()
234
  email TEXT NOT NULL,
235
 
236
  phone TEXT NOT NULL,
237
-
238
  user INT NOT NULL,
239
 
240
  time_taken TEXT NOT NULL,
241
-
242
  time_taken_real DATETIME NOT NULL,
243
-
244
  quiz_results TEXT NOT NULL,
245
 
246
  deleted INT NOT NULL,
@@ -248,7 +252,7 @@ function mlw_quiz_activate()
248
  PRIMARY KEY (result_id)
249
 
250
  )
251
-
252
  CHARACTER SET utf8";
253
 
254
  $results = $wpdb->query( $sql );
@@ -256,31 +260,31 @@ function mlw_quiz_activate()
256
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
257
  dbDelta($sql);
258
  }
259
-
260
  else
261
-
262
  {
263
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'time_taken_real'") != "time_taken_real")
264
  {
265
  $sql = "ALTER TABLE ".$table_name." ADD time_taken_real DATETIME NOT NULL AFTER time_taken";
266
-
267
  $results = $wpdb->query( $sql );
268
-
269
  $sql = "ALTER TABLE ".$table_name." ADD quiz_results TEXT NOT NULL AFTER time_taken_real";
270
-
271
  $results = $wpdb->query( $sql );
272
-
273
  $update_sql = "UPDATE ".$table_name." SET quiz_results='This quiz was taken before this plugin began saving answers.', hints=''";
274
-
275
  $results = $wpdb->query( $update_sql );
276
- }
277
  }
278
-
279
  global $wpdb;
280
 
281
  $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
282
 
283
- if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name)
284
 
285
  {
286
  //Creating the table ... fresh!
@@ -290,15 +294,15 @@ function mlw_quiz_activate()
290
  trail_id mediumint(9) NOT NULL AUTO_INCREMENT,
291
 
292
  action_user TEXT NOT NULL,
293
-
294
  action TEXT NOT NULL,
295
-
296
  time TEXT NOT NULL,
297
 
298
  PRIMARY KEY (trail_id)
299
 
300
  )
301
-
302
  CHARACTER SET utf8";
303
 
304
  $results = $wpdb->query( $sql );
8
 
9
  $table_name = $wpdb->prefix . "mlw_quizzes";
10
 
11
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name)
12
 
13
  {
14
 
17
  quiz_id mediumint(9) NOT NULL AUTO_INCREMENT,
18
 
19
  quiz_name TEXT NOT NULL,
20
+
21
  message_before TEXT NOT NULL,
22
+
23
  message_after TEXT NOT NULL,
24
+
25
  message_comment TEXT NOT NULL,
26
+
27
  message_end_template TEXT NOT NULL,
28
 
29
  user_email_template TEXT NOT NULL,
30
+
31
  admin_email_template TEXT NOT NULL,
32
+
33
  submit_button_text TEXT NOT NULL,
34
+
35
  name_field_text TEXT NOT NULL,
36
+
37
  business_field_text TEXT NOT NULL,
38
+
39
  email_field_text TEXT NOT NULL,
40
+
41
  phone_field_text TEXT NOT NULL,
42
+
43
  comment_field_text TEXT NOT NULL,
44
+
45
  email_from_text TEXT NOT NULL,
46
+
47
  question_answer_template TEXT NOT NULL,
48
+
49
  leaderboard_template TEXT NOT NULL,
50
 
51
  system INT NOT NULL,
52
+
53
  randomness_order INT NOT NULL,
54
+
55
  loggedin_user_contact INT NOT NULL,
56
 
57
  show_score INT NOT NULL,
59
  send_user_email INT NOT NULL,
60
 
61
  send_admin_email INT NOT NULL,
62
+
63
  contact_info_location INT NOT NULL,
64
 
65
  user_name INT NOT NULL,
71
  user_phone INT NOT NULL,
72
 
73
  admin_email TEXT NOT NULL,
74
+
75
  comment_section INT NOT NULL,
76
+
77
  question_from_total INT NOT NULL,
78
+
79
  total_user_tries INT NOT NULL,
80
+
81
  total_user_tries_text TEXT NOT NULL,
82
+
83
  certificate_template TEXT NOT NULL,
84
+
85
  social_media INT NOT NULL,
86
+
87
  social_media_text TEXT NOT NULL,
88
+
89
  pagination INT NOT NULL,
90
+
91
  pagination_text TEXT NOT NULL,
92
+
93
  timer_limit INT NOT NULL,
94
+
95
  quiz_stye TEXT NOT NULL,
96
+
97
  question_numbering INT NOT NULL,
98
+
99
  quiz_settings TEXT NOT NULL,
100
+
101
  theme_selected TEXT NOT NULL,
102
+
103
  last_activity DATETIME NOT NULL,
104
+
105
  require_log_in INT NOT NULL,
106
+
107
  require_log_in_text TEXT NOT NULL,
108
+
109
  limit_total_entries INT NOT NULL,
110
+
111
  limit_total_entries_text TEXT NOT NULL,
112
+
113
  scheduled_timeframe TEXT NOT NULL,
114
+
115
  scheduled_timeframe_text TEXT NOT NULL,
116
 
117
  quiz_views INT NOT NULL,
123
  PRIMARY KEY (quiz_id)
124
 
125
  )
126
+
127
  CHARACTER SET utf8";
128
 
129
  $results = $wpdb->query( $sql );
135
 
136
  $table_name = $wpdb->prefix . "mlw_questions";
137
 
138
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name)
139
 
140
  {
141
 
146
  quiz_id INT NOT NULL,
147
 
148
  question_name TEXT NOT NULL,
149
+
150
  answer_array TEXT NOT NULL,
151
+
152
  answer_one TEXT NOT NULL,
153
+
154
  answer_one_points INT NOT NULL,
155
 
156
  answer_two TEXT NOT NULL,
157
+
158
  answer_two_points INT NOT NULL,
159
 
160
  answer_three TEXT NOT NULL,
174
  answer_six_points INT NOT NULL,
175
 
176
  correct_answer INT NOT NULL,
177
+
178
  question_answer_info TEXT NOT NULL,
179
+
180
  comments INT NOT NULL,
181
+
182
  hints TEXT NOT NULL,
183
+
184
  question_order INT NOT NULL,
185
+
186
  question_type INT NOT NULL,
187
+
188
+ question_type_new TEXT NOT NULL,
189
+
190
  question_settings TEXT NOT NULL,
191
 
192
+ category TEXT NOT NULL,
193
+
194
  deleted INT NOT NULL,
195
 
196
  PRIMARY KEY (question_id)
197
 
198
  )
199
+
200
  CHARACTER SET utf8";
201
 
202
  $results = $wpdb->query( $sql );
204
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
205
  dbDelta($sql);
206
  }
207
+
208
  global $wpdb;
209
 
210
  $table_name = $wpdb->prefix . "mlw_results";
211
 
212
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name)
213
 
214
  {
215
 
238
  email TEXT NOT NULL,
239
 
240
  phone TEXT NOT NULL,
241
+
242
  user INT NOT NULL,
243
 
244
  time_taken TEXT NOT NULL,
245
+
246
  time_taken_real DATETIME NOT NULL,
247
+
248
  quiz_results TEXT NOT NULL,
249
 
250
  deleted INT NOT NULL,
252
  PRIMARY KEY (result_id)
253
 
254
  )
255
+
256
  CHARACTER SET utf8";
257
 
258
  $results = $wpdb->query( $sql );
260
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
261
  dbDelta($sql);
262
  }
263
+
264
  else
265
+
266
  {
267
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'time_taken_real'") != "time_taken_real")
268
  {
269
  $sql = "ALTER TABLE ".$table_name." ADD time_taken_real DATETIME NOT NULL AFTER time_taken";
270
+
271
  $results = $wpdb->query( $sql );
272
+
273
  $sql = "ALTER TABLE ".$table_name." ADD quiz_results TEXT NOT NULL AFTER time_taken_real";
274
+
275
  $results = $wpdb->query( $sql );
276
+
277
  $update_sql = "UPDATE ".$table_name." SET quiz_results='This quiz was taken before this plugin began saving answers.', hints=''";
278
+
279
  $results = $wpdb->query( $update_sql );
280
+ }
281
  }
282
+
283
  global $wpdb;
284
 
285
  $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
286
 
287
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name)
288
 
289
  {
290
  //Creating the table ... fresh!
294
  trail_id mediumint(9) NOT NULL AUTO_INCREMENT,
295
 
296
  action_user TEXT NOT NULL,
297
+
298
  action TEXT NOT NULL,
299
+
300
  time TEXT NOT NULL,
301
 
302
  PRIMARY KEY (trail_id)
303
 
304
  )
305
+
306
  CHARACTER SET utf8";
307
 
308
  $results = $wpdb->query( $sql );
includes/qmn_quiz_options.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ This page allows for the editing of quizzes selected from the quiz admin page.
4
+ */
5
+ /*
6
+ Copyright 2014, My Local Webstop (email : fpcorso@mylocalwebstop.com)
7
+ */
8
+
9
+ function mlw_generate_quiz_options()
10
+ {
11
+ global $wpdb;
12
+ global $mlwQuizMasterNext;
13
+ $tab_array = $mlwQuizMasterNext->pluginHelper->get_settings_tabs();
14
+ $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'questions';
15
+ $quiz_id = intval($_GET["quiz_id"]);
16
+ if (isset($_GET["quiz_id"]))
17
+ {
18
+ $table_name = $wpdb->prefix . "mlw_quizzes";
19
+ $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
20
+ }
21
+
22
+ ?>
23
+
24
+ <script type="text/javascript"
25
+ src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
26
+ </script>
27
+ <!-- css -->
28
+ <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
29
+ <!-- jquery scripts -->
30
+ <?php
31
+ wp_enqueue_script( 'jquery' );
32
+ wp_enqueue_script( 'jquery-ui-core' );
33
+ wp_enqueue_script( 'jquery-ui-dialog' );
34
+ wp_enqueue_script( 'jquery-ui-button' );
35
+ wp_enqueue_script( 'jquery-ui-datepicker' );
36
+ wp_enqueue_script( 'jquery-ui-tabs' );
37
+ wp_enqueue_script( 'jquery-effects-blind' );
38
+ wp_enqueue_script( 'jquery-effects-explode' );
39
+ ?>
40
+ <style>
41
+ .mlw_tab_content
42
+ {
43
+ padding: 20px 20px 20px 20px;
44
+ margin: 20px 20px 20px 20px;
45
+ }
46
+ </style>
47
+ <div class="wrap">
48
+ <div class='mlw_quiz_options'>
49
+ <h2><?php
50
+ /* translators: The %s corresponds to the name of the quiz */
51
+ echo sprintf(__('Quiz Settings For %s', 'quiz-master-next'), $mlw_quiz_options->quiz_name);
52
+ ?></h2>
53
+ <?php
54
+ ob_start();
55
+ if ($quiz_id != "")
56
+ {
57
+ ?>
58
+ <h2 class="nav-tab-wrapper">
59
+ <?php
60
+ foreach($tab_array as $tab)
61
+ {
62
+ $active_class = '';
63
+ if ($active_tab == $tab['slug'])
64
+ {
65
+ $active_class = 'nav-tab-active';
66
+ }
67
+ echo "<a href=\"?page=mlw_quiz_options&quiz_id=$quiz_id&tab=".$tab['slug']."\" class=\"nav-tab $active_class\">".$tab['title']."</a>";
68
+ }
69
+ ?>
70
+ </h2>
71
+ <div>
72
+ <br />
73
+ <br />
74
+ <?php
75
+ foreach($tab_array as $tab)
76
+ {
77
+ if ($active_tab == $tab['slug'])
78
+ {
79
+ call_user_func($tab['function']);
80
+ }
81
+ }
82
+ ?>
83
+ </div>
84
+ <?php
85
+ }
86
+ else
87
+ {
88
+ ?>
89
+ <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
90
+ <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
91
+ <strong><?php _e('Error!', 'quiz-master-next'); ?></strong> <?php _e('Please go to the quizzes page and click on the Edit link from the quiz you wish to edit.', 'quiz-master-next'); ?></p
92
+ </div>
93
+ <?php
94
+ }
95
+ $mlw_output = ob_get_contents();
96
+ ob_end_clean();
97
+ $mlwQuizMasterNext->alertManager->showAlerts();
98
+ echo mlw_qmn_show_adverts();
99
+ echo $mlw_output;
100
+ ?>
101
+ </div>
102
+ </div>
103
+ <?php
104
+ }
105
+ ?>
includes/qmn_results.php ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function mlw_generate_quiz_results()
4
+ {
5
+ global $wpdb;
6
+ global $mlwQuizMasterNext;
7
+
8
+ ///Delete Results Function
9
+ if (isset($_POST["delete_results"]) && $_POST["delete_results"] == "confirmation")
10
+ {
11
+ ///Variables from delete result form
12
+ $mlw_delete_results_confirmation = $_POST["delete_results"];
13
+ $mlw_delete_results_id = $_POST["result_id"];
14
+ $mlw_delete_results_name = $_POST["delete_quiz_name"];
15
+ $mlw_delete_results_update_sql = "UPDATE " . $wpdb->prefix . "mlw_results" . " SET deleted=1 WHERE result_id=".$mlw_delete_results_id;
16
+ $mlw_delete_results_results = $wpdb->query( $mlw_delete_results_update_sql );
17
+ if ($mlw_delete_results_results != false)
18
+ {
19
+ $mlwQuizMasterNext->alertManager->newAlert(__('Your results has been deleted successfully.','quiz-master-next'), 'success');
20
+
21
+ //Insert Action Into Audit Trail
22
+ global $current_user;
23
+ get_currentuserinfo();
24
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
25
+ $insert = "INSERT INTO " . $table_name .
26
+ "(trail_id, action_user, action, time) " .
27
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Results Has Been Deleted From: ".$mlw_delete_results_name."' , '" . date("h:i:s A m/d/Y") . "')";
28
+ $results = $wpdb->query( $insert );
29
+ }
30
+ else
31
+ {
32
+ $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0021'), 'error');
33
+ }
34
+ }
35
+
36
+ global $wpdb;
37
+ $mlw_qmn_table_limit = 30;
38
+ $mlw_qmn_results_count = $wpdb->get_var( "SELECT COUNT(result_id) FROM " . $wpdb->prefix . "mlw_results WHERE deleted='0'" );
39
+
40
+ if( isset($_GET['mlw_result_page'] ) )
41
+ {
42
+ $mlw_qmn_result_page = $_GET['mlw_result_page'] + 1;
43
+ $mlw_qmn_result_begin = $mlw_qmn_table_limit * $mlw_qmn_result_page ;
44
+ }
45
+ else
46
+ {
47
+ $mlw_qmn_result_page = 0;
48
+ $mlw_qmn_result_begin = 0;
49
+ }
50
+ $mlw_qmn_result_left = $mlw_qmn_results_count - ($mlw_qmn_result_page * $mlw_qmn_table_limit);
51
+ if (isset($_GET["quiz_id"]) && $_GET["quiz_id"] != "")
52
+ {
53
+ $mlw_quiz_data = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "mlw_results WHERE deleted='0' AND quiz_id=%d ORDER BY result_id DESC LIMIT %d, %d", intval($_GET["quiz_id"]), $mlw_qmn_result_begin, $mlw_qmn_table_limit ) );
54
+ }
55
+ else
56
+ {
57
+ $mlw_quiz_data = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "mlw_results WHERE deleted='0' ORDER BY result_id DESC LIMIT %d, %d", $mlw_qmn_result_begin, $mlw_qmn_table_limit ) );
58
+ }
59
+ ?>
60
+ <!-- css -->
61
+ <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
62
+ <!-- jquery scripts -->
63
+ <?php
64
+ wp_enqueue_script( 'jquery' );
65
+ wp_enqueue_script( 'jquery-ui-core' );
66
+ wp_enqueue_script( 'jquery-ui-dialog' );
67
+ wp_enqueue_script( 'jquery-ui-button' );
68
+ wp_enqueue_script( 'jquery-ui-accordion' );
69
+ wp_enqueue_script( 'jquery-ui-tooltip' );
70
+ wp_enqueue_script( 'jquery-ui-tabs' );
71
+ wp_enqueue_script( 'jquery-effects-blind' );
72
+ wp_enqueue_script( 'jquery-effects-explode' );
73
+ ?>
74
+ <!--<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
75
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>-->
76
+ <script type="text/javascript">
77
+ var $j = jQuery.noConflict();
78
+ // increase the default animation speed to exaggerate the effect
79
+ $j.fx.speeds._default = 1000;
80
+
81
+ $j(function() {
82
+ $j("button, #prev_page, #next_page").button();
83
+
84
+ });
85
+ function deleteResults(id,quizName){
86
+ $j("#delete_dialog").dialog({
87
+ autoOpen: false,
88
+ show: 'blind',
89
+ hide: 'explode',
90
+ buttons: {
91
+ Cancel: function() {
92
+ $j(this).dialog('close');
93
+ }
94
+ }
95
+ });
96
+ $j("#delete_dialog").dialog('open');
97
+ var idHidden = document.getElementById("result_id");
98
+ var idHiddenName = document.getElementById("delete_quiz_name");
99
+ idHidden.value = id;
100
+ idHiddenName.value = quizName;
101
+ };
102
+ </script>
103
+ <style>
104
+ label {
105
+ display: inline-block;
106
+ width: 5em;
107
+ }
108
+ </style>
109
+ <style type="text/css">
110
+ div.mlw_quiz_options input[type='text'] {
111
+ border-color:#000000;
112
+ color:#3300CC;
113
+ cursor:hand;
114
+ }
115
+ </style>
116
+ <div class="wrap">
117
+ <div class='mlw_quiz_options'>
118
+ <h2><?php _e('Quiz Results','quiz-master-next'); ?></h2>
119
+ <?php
120
+ $mlwQuizMasterNext->alertManager->showAlerts();
121
+
122
+ if( $mlw_qmn_result_page > 0 )
123
+ {
124
+ $mlw_qmn_previous_page = $mlw_qmn_result_page - 2;
125
+ echo "<a id=\"prev_page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_previous_page\">".sprintf(__('Previous %s Results','quiz-master-next'),$mlw_qmn_table_limit)."</a>";
126
+ if( $mlw_qmn_result_left > $mlw_qmn_table_limit )
127
+ {
128
+ echo "<a id=\"next_page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_result_page\">".sprintf(__('Next %s Results','quiz-master-next'),$mlw_qmn_table_limit)."</a>";
129
+ }
130
+ }
131
+ else if( $mlw_qmn_result_page == 0 )
132
+ {
133
+ if( $mlw_qmn_result_left > $mlw_qmn_table_limit )
134
+ {
135
+ echo "<a id=\"next_page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_result_page\">".sprintf(__('Next %s Results','quiz-master-next'),$mlw_qmn_table_limit)."</a>";
136
+ }
137
+ }
138
+ else if( $mlw_qmn_result_left < $mlw_qmn_table_limit )
139
+ {
140
+ $mlw_qmn_previous_page = $mlw_qmn_result_page - 2;
141
+ echo "<a id=\"prev_page\" href=\"?page=mlw_quiz_results&&mlw_result_page=$mlw_qmn_previous_page\">".sprintf(__('Previous %s Results','quiz-master-next'),$mlw_qmn_table_limit)."</a>";
142
+ }
143
+ ?>
144
+ <table class=widefat>
145
+ <thead>
146
+ <tr>
147
+ <th><?php _e('Actions','quiz-master-next'); ?></th>
148
+ <th><?php _e('Quiz Name','quiz-master-next'); ?></th>
149
+ <th><?php _e('Score','quiz-master-next'); ?></th>
150
+ <th><?php _e('Time To Complete','quiz-master-next'); ?></th>
151
+ <th><?php _e('Name','quiz-master-next'); ?></th>
152
+ <th><?php _e('Business','quiz-master-next'); ?></th>
153
+ <th><?php _e('Email','quiz-master-next'); ?></th>
154
+ <th><?php _e('Phone','quiz-master-next'); ?></th>
155
+ <th><?php _e('Time Taken','quiz-master-next'); ?></th>
156
+ </tr>
157
+ </thead>
158
+ <?php
159
+ $quotes_list = "";
160
+ $display = "";
161
+ $alternate = "";
162
+ foreach($mlw_quiz_data as $mlw_quiz_info) {
163
+ if($alternate) $alternate = "";
164
+ else $alternate = " class=\"alternate\"";
165
+ $mlw_complete_time = '';
166
+ $mlw_qmn_results_array = @unserialize($mlw_quiz_info->quiz_results);
167
+ if (is_array($mlw_qmn_results_array))
168
+ {
169
+ $mlw_complete_hours = floor($mlw_qmn_results_array[0] / 3600);
170
+ if ($mlw_complete_hours > 0)
171
+ {
172
+ $mlw_complete_time .= "$mlw_complete_hours hours ";
173
+ }
174
+ $mlw_complete_minutes = floor(($mlw_qmn_results_array[0] % 3600) / 60);
175
+ if ($mlw_complete_minutes > 0)
176
+ {
177
+ $mlw_complete_time .= "$mlw_complete_minutes minutes ";
178
+ }
179
+ $mlw_complete_seconds = $mlw_qmn_results_array[0] % 60;
180
+ $mlw_complete_time .= "$mlw_complete_seconds seconds";
181
+ }
182
+
183
+ $quotes_list .= "<tr{$alternate}>";
184
+ $quotes_list .= "<td><span style='color:green;font-size:16px;'><a href='admin.php?page=mlw_quiz_result_details&&result_id=".$mlw_quiz_info->result_id."'>View</a>|<a onclick=\"deleteResults('".$mlw_quiz_info->result_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='#'>Delete</a></span></td>";
185
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_name . "</span></td>";
186
+ if ($mlw_quiz_info->quiz_system == 0)
187
+ {
188
+ $quotes_list .= "<td class='post-title column-title'><span style='font-size:16px;'>" . $mlw_quiz_info->correct ." out of ".$mlw_quiz_info->total." or ".$mlw_quiz_info->correct_score."%</span></td>";
189
+ }
190
+ if ($mlw_quiz_info->quiz_system == 1)
191
+ {
192
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->point_score . " Points</span></td>";
193
+ }
194
+ if ($mlw_quiz_info->quiz_system == 2)
195
+ {
196
+ $quotes_list .= "<td><span style='font-size:16px;'>".__('Not Graded','quiz-master-next')."</span></td>";
197
+ }
198
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_complete_time ."</span></td>";
199
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->name ."</span></td>";
200
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->business ."</span></td>";
201
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->email ."</span></td>";
202
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->phone ."</span></td>";
203
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->time_taken ."</span></td>";
204
+ $quotes_list .= "</tr>";
205
+ }
206
+ $display .= "<tbody id=\"the-list\">{$quotes_list}</tbody>";
207
+ echo $display;
208
+ ?>
209
+ </table>
210
+
211
+ <?php echo mlw_qmn_show_adverts(); ?>
212
+
213
+ <div id="delete_dialog" title="Delete Results?" style="display:none;">
214
+ <h3><b><?php _e('Are you sure you want to delete these results?','quiz-master-next'); ?></b></h3>
215
+ <form action='' method='post'>
216
+ <input type='hidden' name='delete_results' value='confirmation' />
217
+ <input type='hidden' id='result_id' name='result_id' value='' />
218
+ <input type='hidden' id='delete_quiz_name' name='delete_quiz_name' value='' />
219
+ <p class='submit'><input type='submit' class='button-primary' value='<?php _e('Delete Results','quiz-master-next'); ?>' /></p>
220
+ </form>
221
+ </div>
222
+ </div>
223
+ </div>
224
+ <?php
225
+ }
226
+ ?>
includes/{mlw_results_details.php → qmn_results_details.php} RENAMED
@@ -2,7 +2,7 @@
2
  /*
3
  This page allows for the viewing of the quiz results.
4
  */
5
- /*
6
  Copyright 2013, My Local Webstop (email : fpcorso@mylocalwebstop.com)
7
  */
8
 
@@ -12,15 +12,15 @@ function mlw_generate_result_details()
12
  if ($mlw_result_id != "")
13
  {
14
  global $wpdb;
15
-
16
  //Check if user wants to create certificate
17
  if (isset($_POST["create_certificate"]) && $_POST["create_certificate"] == "confirmation")
18
  {
19
  $mlw_certificate_id = intval($_GET["result_id"]);
20
  $mlw_quiz_results = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM ".$wpdb->prefix."mlw_results WHERE result_id=%d", $mlw_certificate_id ) );
21
-
22
  $mlw_certificate_results = $wpdb->get_var( $wpdb->prepare( "SELECT certificate_template FROM ".$wpdb->prefix."mlw_quizzes WHERE quiz_id=%d", $mlw_quiz_results->quiz_id ) );
23
-
24
  //Prepare Certificate
25
  $mlw_certificate_options = unserialize($mlw_certificate_results);
26
  if (!is_array($mlw_certificate_options)) {
@@ -42,7 +42,7 @@ function mlw_generate_result_details()
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;
@@ -62,13 +62,13 @@ 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
-
68
-
69
  //Load Results
70
  $mlw_results_data = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "mlw_results WHERE result_id=".intval($mlw_result_id));
71
-
72
  ?>
73
  <!-- css -->
74
  <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
@@ -100,7 +100,7 @@ EOC;
100
  }
101
  }
102
  });
103
-
104
  $j('#opener').click(function() {
105
  $j('#dialog').dialog('open');
106
  return false;
@@ -118,39 +118,39 @@ EOC;
118
  <style type="text/css">
119
  div.mlw_quiz_options input[type='text'] {
120
  border-color:#000000;
121
- color:#3300CC;
122
  cursor:hand;
123
  }
124
  </style>
125
  <div class="wrap">
126
  <div class='mlw_quiz_options'>
127
- <h2>Quiz Results<a id="opener" href="">(?)</a></h2>
128
  <div id="tabs">
129
  <ul>
130
- <li><a href="#tabs-1">Quiz Results</a></li>
131
- <li><a href="#tabs-2">Quiz Tools</a></li>
132
  </ul>
133
  <div id="tabs-1">
134
- <h2>Quiz Results From <?php echo $mlw_results_data->quiz_name; ?></h2>
135
  <table>
136
  <tr>
137
- <td>Time Taken: </td>
138
  <td><?php echo $mlw_results_data->time_taken; ?></td>
139
  </tr>
140
  <tr>
141
- <td>Name Provided: </td>
142
  <td><?php echo $mlw_results_data->name; ?></td>
143
  </tr>
144
  <tr>
145
- <td>Business Provided: </td>
146
  <td><?php echo $mlw_results_data->business; ?></td>
147
  </tr>
148
  <tr>
149
- <td>Email Provided: </td>
150
  <td><?php echo $mlw_results_data->email; ?></td>
151
  </tr>
152
  <tr>
153
- <td>Phone Provided: </td>
154
  <td><?php echo $mlw_results_data->phone; ?></td>
155
  </tr>
156
  <tr>
@@ -161,14 +161,14 @@ EOC;
161
  if ($mlw_results_data->quiz_system == 0)
162
  {
163
  ?>
164
- <td>Score Received:</td>
165
  <td><?php echo $mlw_results_data->correct."/".$mlw_results_data->total." or ".$mlw_results_data->correct_score."%"; ?></td>
166
  <?php
167
  }
168
  else if ($mlw_results_data->quiz_system == 1)
169
- {
170
  ?>
171
- <td>Score Received:</td>
172
  <td><?php echo $mlw_results_data->point_score." Points"; ?></td>
173
  <?php
174
  }
@@ -177,7 +177,7 @@ EOC;
177
  </table>
178
  <br />
179
  <br />
180
- <h3>Answers Provided</h3>
181
  <?php
182
  $mlw_qmn_results_array = @unserialize($mlw_results_data->quiz_results);
183
  if (!is_array($mlw_qmn_results_array)) {
@@ -189,31 +189,34 @@ EOC;
189
  $mlw_complete_hours = floor($mlw_qmn_results_array[0] / 3600);
190
  if ($mlw_complete_hours > 0)
191
  {
192
- $mlw_complete_time .= "$mlw_complete_hours hours ";
193
  }
194
  $mlw_complete_minutes = floor(($mlw_qmn_results_array[0] % 3600) / 60);
195
  if ($mlw_complete_minutes > 0)
196
  {
197
- $mlw_complete_time .= "$mlw_complete_minutes minutes ";
198
  }
199
  $mlw_complete_seconds = $mlw_qmn_results_array[0] % 60;
200
- $mlw_complete_time .= "$mlw_complete_seconds seconds";
201
  ?>
202
- This quiz was completed in <?php echo $mlw_complete_time; ?>.<br />
 
 
 
203
  <br />
204
- The comments entered into the comment box (if enabled):<br />
205
  <?php echo $mlw_qmn_results_array[2]; ?><br />
206
  <br />
207
- The answers were as follows:<br />
208
  <br />
209
  <?php
210
  $mlw_qmn_answer_array = $mlw_qmn_results_array[1];
211
  foreach( $mlw_qmn_answer_array as $mlw_each )
212
  {
213
  echo htmlspecialchars_decode($mlw_each[0], ENT_QUOTES)."<br />";
214
- echo "Answer Provided: ".htmlspecialchars_decode($mlw_each[1], ENT_QUOTES)."<br />";
215
- echo "Correct Answer: ".htmlspecialchars_decode($mlw_each[2], ENT_QUOTES)."<br />";
216
- echo "Comments Entered: <br />".htmlspecialchars_decode($mlw_each[3], ENT_QUOTES)."<br />";
217
  echo "<br /><br />";
218
  }
219
  ?>
@@ -221,31 +224,23 @@ EOC;
221
  }
222
  ?>
223
  </div>
224
- <div id="tabs-2">
225
  <form action="" method="post" name="create_certificate_form">
226
  <input type="hidden" name="create_certificate" value="confirmation" />
227
- <input type="submit" value="Create Certificate" />
228
  </form>
229
  <?php
230
  if (isset($_POST["create_certificate"]) && $_POST["create_certificate"] == "confirmation")
231
  {
232
- echo "<a href='".$mlw_qmn_certificate_filename."' style='color: blue;'>Download Certificate Here</a><br />";
233
  }
234
  ?>
235
  </div>
236
-
237
-
238
- <div id="dialog" title="Help">
239
- <h3><b>Help</b></h3>
240
- <p>This page shows the results from the taken quiz.</p>
241
- <p>The top section shows the question, the user's answer, and the correct answer.</p>
242
- <p>The bottom section shows the text from the comment box if enabled.</p>
243
- </div>
244
  </div>
245
  <?php echo mlw_qmn_show_adverts(); ?>
246
  </div>
247
  </div>
248
-
249
  <?php
250
  }
251
  else
@@ -271,7 +266,7 @@ EOC;
271
  }
272
  }
273
  });
274
-
275
  $j('#opener').click(function() {
276
  $j('#dialog').dialog('open');
277
  return false;
@@ -282,7 +277,7 @@ EOC;
282
  });
283
  $j(function() {
284
  $j("button").button();
285
-
286
  });
287
  </script>
288
  <style>
@@ -294,22 +289,17 @@ EOC;
294
  <style type="text/css">
295
  div.mlw_quiz_options input[type='text'] {
296
  border-color:#000000;
297
- color:#3300CC;
298
  cursor:hand;
299
  }
300
  </style>
301
  <div class="wrap">
302
  <div class='mlw_quiz_options'>
303
- <h2>Quiz Results<a id="opener" href="">(?)</a></h2>
304
  <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
305
  <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
306
- <strong>Hey!</strong> Please go to the Quiz Results page and click on the View link from the result you wish to see.</p>
307
  </div>
308
- <div id="dialog" title="Help" style="display:none;">
309
- <h3><b>Help</b></h3>
310
- <p>You are getting this error page because this page could not find the results.</p>
311
- <p>You must go to the Quiz Results page and click on the result you want to see from that table.</p>
312
- </div>
313
  </div>
314
  </div>
315
  <?php
2
  /*
3
  This page allows for the viewing of the quiz results.
4
  */
5
+ /*
6
  Copyright 2013, My Local Webstop (email : fpcorso@mylocalwebstop.com)
7
  */
8
 
12
  if ($mlw_result_id != "")
13
  {
14
  global $wpdb;
15
+
16
  //Check if user wants to create certificate
17
  if (isset($_POST["create_certificate"]) && $_POST["create_certificate"] == "confirmation")
18
  {
19
  $mlw_certificate_id = intval($_GET["result_id"]);
20
  $mlw_quiz_results = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM ".$wpdb->prefix."mlw_results WHERE result_id=%d", $mlw_certificate_id ) );
21
+
22
  $mlw_certificate_results = $wpdb->get_var( $wpdb->prepare( "SELECT certificate_template FROM ".$wpdb->prefix."mlw_quizzes WHERE quiz_id=%d", $mlw_quiz_results->quiz_id ) );
23
+
24
  //Prepare Certificate
25
  $mlw_certificate_options = unserialize($mlw_certificate_results);
26
  if (!is_array($mlw_certificate_options)) {
42
  $plugindirpath=plugin_dir_path( __FILE__ );
43
  $mlw_qmn_certificate_file=<<<EOC
44
  <?php
45
+ include("$plugindirpath/fpdf/WriteHTML.php");
46
  \$pdf=new PDF_HTML();
47
  \$pdf->AddPage('L');
48
  EOC;
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
+
68
+
69
  //Load Results
70
  $mlw_results_data = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "mlw_results WHERE result_id=".intval($mlw_result_id));
71
+
72
  ?>
73
  <!-- css -->
74
  <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
100
  }
101
  }
102
  });
103
+
104
  $j('#opener').click(function() {
105
  $j('#dialog').dialog('open');
106
  return false;
118
  <style type="text/css">
119
  div.mlw_quiz_options input[type='text'] {
120
  border-color:#000000;
121
+ color:#3300CC;
122
  cursor:hand;
123
  }
124
  </style>
125
  <div class="wrap">
126
  <div class='mlw_quiz_options'>
127
+ <h2><?php _e('Quiz Results', 'quiz-master-next'); ?></h2>
128
  <div id="tabs">
129
  <ul>
130
+ <li><a href="#tabs-1"><?php _e('Quiz Results', 'quiz-master-next'); ?></a></li>
131
+ <li><a href="#tabs-2"><?php _e('Quiz Tools', 'quiz-master-next'); ?></a></li>
132
  </ul>
133
  <div id="tabs-1">
134
+ <h2><?php _e('Quiz Results', 'quiz-master-next'); ?>: <?php echo $mlw_results_data->quiz_name; ?></h2>
135
  <table>
136
  <tr>
137
+ <td><?php _e('Time Taken', 'quiz-master-next'); ?>: </td>
138
  <td><?php echo $mlw_results_data->time_taken; ?></td>
139
  </tr>
140
  <tr>
141
+ <td><?php _e('Name Provided', 'quiz-master-next'); ?>: </td>
142
  <td><?php echo $mlw_results_data->name; ?></td>
143
  </tr>
144
  <tr>
145
+ <td><?php _e('Business Provided', 'quiz-master-next'); ?>: </td>
146
  <td><?php echo $mlw_results_data->business; ?></td>
147
  </tr>
148
  <tr>
149
+ <td><?php _e('Email Provided', 'quiz-master-next'); ?>: </td>
150
  <td><?php echo $mlw_results_data->email; ?></td>
151
  </tr>
152
  <tr>
153
+ <td><?php _e('Phone Provided', 'quiz-master-next'); ?>: </td>
154
  <td><?php echo $mlw_results_data->phone; ?></td>
155
  </tr>
156
  <tr>
161
  if ($mlw_results_data->quiz_system == 0)
162
  {
163
  ?>
164
+ <td><?php _e('Score Received', 'quiz-master-next'); ?>:</td>
165
  <td><?php echo $mlw_results_data->correct."/".$mlw_results_data->total." or ".$mlw_results_data->correct_score."%"; ?></td>
166
  <?php
167
  }
168
  else if ($mlw_results_data->quiz_system == 1)
169
+ {
170
  ?>
171
+ <td><?php _e('Score Received', 'quiz-master-next'); ?>:</td>
172
  <td><?php echo $mlw_results_data->point_score." Points"; ?></td>
173
  <?php
174
  }
177
  </table>
178
  <br />
179
  <br />
180
+ <h3><?php _e('Answers Provided', 'quiz-master-next'); ?></h3>
181
  <?php
182
  $mlw_qmn_results_array = @unserialize($mlw_results_data->quiz_results);
183
  if (!is_array($mlw_qmn_results_array)) {
189
  $mlw_complete_hours = floor($mlw_qmn_results_array[0] / 3600);
190
  if ($mlw_complete_hours > 0)
191
  {
192
+ $mlw_complete_time .= "$mlw_complete_hours ".__('hours','quiz-master-next')." ";
193
  }
194
  $mlw_complete_minutes = floor(($mlw_qmn_results_array[0] % 3600) / 60);
195
  if ($mlw_complete_minutes > 0)
196
  {
197
+ $mlw_complete_time .= "$mlw_complete_minutes ".__('minutes','quiz-master-next')." ";
198
  }
199
  $mlw_complete_seconds = $mlw_qmn_results_array[0] % 60;
200
+ $mlw_complete_time .= "$mlw_complete_seconds ".__('seconds','quiz-master-next');
201
  ?>
202
+ <p><?php
203
+ /* translators: The %s will be replaces with the amount of time the user took on quiz. For example: 5 minutes 34 seconds */
204
+ echo sprintf(__('The user took %s to complete this quiz.','quiz-master-next'), $mlw_complete_time);
205
+ ?></p><br />
206
  <br />
207
+ <?php _e('The comments entered into the comment box (if enabled)', 'quiz-master-next'); ?>:<br />
208
  <?php echo $mlw_qmn_results_array[2]; ?><br />
209
  <br />
210
+ <p><?php _e('The answers were as follows', 'quiz-master-next'); ?>:</p>
211
  <br />
212
  <?php
213
  $mlw_qmn_answer_array = $mlw_qmn_results_array[1];
214
  foreach( $mlw_qmn_answer_array as $mlw_each )
215
  {
216
  echo htmlspecialchars_decode($mlw_each[0], ENT_QUOTES)."<br />";
217
+ echo __('Answer Provided: ','quiz-master-next').htmlspecialchars_decode($mlw_each[1], ENT_QUOTES)."<br />";
218
+ echo __("Correct Answer: ",'quiz-master-next').htmlspecialchars_decode($mlw_each[2], ENT_QUOTES)."<br />";
219
+ echo __("Comments Entered:" ,'quiz-master-next')."<br />".htmlspecialchars_decode($mlw_each[3], ENT_QUOTES)."<br />";
220
  echo "<br /><br />";
221
  }
222
  ?>
224
  }
225
  ?>
226
  </div>
227
+ <div id="tabs-2">
228
  <form action="" method="post" name="create_certificate_form">
229
  <input type="hidden" name="create_certificate" value="confirmation" />
230
+ <input type="submit" value="<?php _e('Create Certificate','quiz-master-next'); ?>" />
231
  </form>
232
  <?php
233
  if (isset($_POST["create_certificate"]) && $_POST["create_certificate"] == "confirmation")
234
  {
235
+ echo "<a href='".$mlw_qmn_certificate_filename."' style='color: blue;'>".__('Download Certificate Here','quiz-master-next')."</a><br />";
236
  }
237
  ?>
238
  </div>
 
 
 
 
 
 
 
 
239
  </div>
240
  <?php echo mlw_qmn_show_adverts(); ?>
241
  </div>
242
  </div>
243
+
244
  <?php
245
  }
246
  else
266
  }
267
  }
268
  });
269
+
270
  $j('#opener').click(function() {
271
  $j('#dialog').dialog('open');
272
  return false;
277
  });
278
  $j(function() {
279
  $j("button").button();
280
+
281
  });
282
  </script>
283
  <style>
289
  <style type="text/css">
290
  div.mlw_quiz_options input[type='text'] {
291
  border-color:#000000;
292
+ color:#3300CC;
293
  cursor:hand;
294
  }
295
  </style>
296
  <div class="wrap">
297
  <div class='mlw_quiz_options'>
298
+ <h2><?php _e('Quiz Results','quiz-master-next'); ?></h2>
299
  <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
300
  <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
301
+ <strong><?php _e('Error!','quiz-master-next'); ?></strong> <?php _e('Please go to the Quiz Results page and click on the View link from the result you wish to see.','quiz-master-next'); ?></p>
302
  </div>
 
 
 
 
 
303
  </div>
304
  </div>
305
  <?php
includes/qmn_template_variables.php ADDED
@@ -0,0 +1,322 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ Results Array For Reference:
5
+
6
+ $mlw_qmn_result_array = array(
7
+ 'quiz_id' => $mlw_quiz_id,
8
+ 'quiz_name' => $mlw_quiz_options->quiz_name,
9
+ 'quiz_system' => $mlw_quiz_options->system,
10
+ 'total_points' => $mlw_points,
11
+ 'total_score' => $mlw_total_score,
12
+ 'total_correct' => $mlw_correct,
13
+ 'total_questions' => $mlw_total_questions,
14
+ 'user_name' => $mlw_user_name,
15
+ 'user_business' => $mlw_user_comp,
16
+ 'user_email' => $mlw_user_email,
17
+ 'user_phone' => $mlw_user_phone,
18
+ 'user_id' => get_current_user_id(),
19
+ 'question_answers_display' => $mlw_question_answers,
20
+ 'question_answers_array' => $mlw_qmn_answer_array,
21
+ 'timer' => $mlw_qmn_timer,
22
+ 'comments' => $mlw_qm_quiz_comments,
23
+ 'certificate_link' => CERTIFICATE LINK
24
+ );
25
+
26
+ */
27
+ add_filter('mlw_qmn_template_variable_results_page', 'qmn_variable_category_points',10,2);
28
+ add_filter('mlw_qmn_template_variable_results_page', 'qmn_variable_category_score',10,2);
29
+ add_filter('mlw_qmn_template_variable_results_page', 'qmn_variable_category_average_score',10,2);
30
+ add_filter('mlw_qmn_template_variable_results_page', 'qmn_variable_category_average_points',10,2);
31
+ add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_point_score',10,2);
32
+ add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_average_point',10,2);
33
+ add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_amount_correct',10,2);
34
+ add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_total_questions',10,2);
35
+ add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_correct_score',10,2);
36
+ add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_quiz_name',10,2);
37
+ add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_user_name',10,2);
38
+ add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_user_business',10,2);
39
+ add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_user_phone',10,2);
40
+ add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_user_email',10,2);
41
+ add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_question_answers',10,2);
42
+ add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_comments',10,2);
43
+ add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_timer',10,2);
44
+ add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_date',10,2);
45
+ add_filter('mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_certificate_link',10,2);
46
+
47
+ add_filter('mlw_qmn_template_variable_quiz_page', 'mlw_qmn_variable_quiz_name',10,2);
48
+ add_filter('mlw_qmn_template_variable_quiz_page', 'mlw_qmn_variable_date',10,2);
49
+ add_filter('mlw_qmn_template_variable_quiz_page', 'mlw_qmn_variable_current_user',10,2);
50
+ function mlw_qmn_variable_point_score($content, $mlw_quiz_array)
51
+ {
52
+ $content = str_replace( "%POINT_SCORE%" , $mlw_quiz_array["total_points"], $content);
53
+ return $content;
54
+ }
55
+ function mlw_qmn_variable_average_point($content, $mlw_quiz_array)
56
+ {
57
+ $mlw_average_points = $mlw_quiz_array["total_points"]/$mlw_quiz_array["total_questions"];
58
+ $content = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $content);
59
+ return $content;
60
+ }
61
+ function mlw_qmn_variable_amount_correct($content, $mlw_quiz_array)
62
+ {
63
+ $content = str_replace( "%AMOUNT_CORRECT%" , $mlw_quiz_array["total_correct"], $content);
64
+ return $content;
65
+ }
66
+ function mlw_qmn_variable_total_questions($content, $mlw_quiz_array)
67
+ {
68
+ $content = str_replace( "%TOTAL_QUESTIONS%" , $mlw_quiz_array["total_questions"], $content);
69
+ return $content;
70
+ }
71
+ function mlw_qmn_variable_correct_score($content, $mlw_quiz_array)
72
+ {
73
+ $content = str_replace( "%CORRECT_SCORE%" , $mlw_quiz_array["total_score"], $content);
74
+ return $content;
75
+ }
76
+ function mlw_qmn_variable_quiz_name($content, $mlw_quiz_array)
77
+ {
78
+ $content = str_replace( "%QUIZ_NAME%" , $mlw_quiz_array["quiz_name"], $content);
79
+ return $content;
80
+ }
81
+ function mlw_qmn_variable_user_name($content, $mlw_quiz_array)
82
+ {
83
+ $content = str_replace( "%USER_NAME%" , $mlw_quiz_array["user_name"], $content);
84
+ return $content;
85
+ }
86
+ function mlw_qmn_variable_current_user($content, $mlw_quiz_array)
87
+ {
88
+ $current_user = wp_get_current_user();
89
+ $content = str_replace( "%USER_NAME%" , $current_user->display_name, $content);
90
+ return $content;
91
+ }
92
+ function mlw_qmn_variable_user_business($content, $mlw_quiz_array)
93
+ {
94
+ $content = str_replace( "%USER_BUSINESS%" , $mlw_quiz_array["user_business"], $content);
95
+ return $content;
96
+ }
97
+ function mlw_qmn_variable_user_phone($content, $mlw_quiz_array)
98
+ {
99
+ $content = str_replace( "%USER_PHONE%" , $mlw_quiz_array["user_phone"], $content);
100
+ return $content;
101
+ }
102
+ function mlw_qmn_variable_user_email($content, $mlw_quiz_array)
103
+ {
104
+ $content = str_replace( "%USER_EMAIL%" , $mlw_quiz_array["user_email"], $content);
105
+ return $content;
106
+ }
107
+ function mlw_qmn_variable_question_answers($content, $mlw_quiz_array)
108
+ {
109
+ while (strpos($content, '%QUESTIONS_ANSWERS%') != false)
110
+ {
111
+ global $wpdb;
112
+ $display = '';
113
+ $qmn_question_answer_template = $wpdb->get_var( $wpdb->prepare( "SELECT question_answer_template FROM " . $wpdb->prefix . "mlw_quizzes WHERE quiz_id=%d", $mlw_quiz_array['quiz_id'] ) );
114
+ $qmn_questions_sql = $wpdb->get_results( $wpdb->prepare( "SELECT question_id, question_answer_info FROM " . $wpdb->prefix . "mlw_questions WHERE quiz_id=%d AND deleted=0", $mlw_quiz_array['quiz_id'] ) );
115
+ $qmn_questions = array();
116
+ foreach($qmn_questions_sql as $question)
117
+ {
118
+ $qmn_questions[$question->question_id] = $question->question_answer_info;
119
+ }
120
+ foreach ($mlw_quiz_array['question_answers_array'] as $answer)
121
+ {
122
+ $mlw_question_answer_display = htmlspecialchars_decode($qmn_question_answer_template, ENT_QUOTES);
123
+ $mlw_question_answer_display = str_replace( "%QUESTION%" , htmlspecialchars_decode($answer[0], ENT_QUOTES), $mlw_question_answer_display);
124
+ $mlw_question_answer_display = str_replace( "%USER_ANSWER%" , $answer[1], $mlw_question_answer_display);
125
+ $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER%" , $answer[2], $mlw_question_answer_display);
126
+ $mlw_question_answer_display = str_replace( "%USER_COMMENTS%" , $answer[3], $mlw_question_answer_display);
127
+ $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER_INFO%" , htmlspecialchars_decode($qmn_questions[$answer['id']], ENT_QUOTES), $mlw_question_answer_display);
128
+ $display .= apply_filters('qmn_variable_question_answers', $mlw_question_answer_display, $mlw_quiz_array);
129
+ $display .= "<br />";
130
+ }
131
+ $content = str_replace( "%QUESTIONS_ANSWERS%" , $display, $content);
132
+ }
133
+ return $content;
134
+ }
135
+ function mlw_qmn_variable_comments($content, $mlw_quiz_array)
136
+ {
137
+ $content = str_replace( "%COMMENT_SECTION%" , $mlw_quiz_array["comments"], $content);
138
+ return $content;
139
+ }
140
+ function mlw_qmn_variable_timer($content, $mlw_quiz_array)
141
+ {
142
+ $content = str_replace( "%TIMER%" , $mlw_quiz_array["timer"], $content);
143
+ return $content;
144
+ }
145
+ function mlw_qmn_variable_date($content, $mlw_quiz_array)
146
+ {
147
+ $content = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $content);
148
+ return $content;
149
+ }
150
+ function mlw_qmn_variable_certificate_link($content, $mlw_quiz_array)
151
+ {
152
+ while (strpos($content, '%CERTIFICATE_LINK%') != false)
153
+ {
154
+ $content = str_replace( "%CERTIFICATE_LINK%" , $mlw_quiz_array["certificate_link"], $content);
155
+ }
156
+ return $content;
157
+ }
158
+
159
+ /*
160
+ * Replaces variable %CATEGORY_POINTS% with the points for that category
161
+ *
162
+ * Filter function that replaces variable %CATEGORY_POINTS% with the points from the category inside the variable tags. i.e. %CATEGORY_POINTS%category 1%/CATEGORY_POINTS%
163
+ *
164
+ * @since 4.0.0
165
+ * @param string $content The contents of the results page
166
+ * @param array $mlw_quiz_array The array of all the results from user taking the quiz
167
+ * @return string Returns the contents for the results page
168
+ */
169
+ function qmn_variable_category_points($content, $mlw_quiz_array)
170
+ {
171
+ $return_points = 0;
172
+ while (strpos($content, '%CATEGORY_POINTS%') != false)
173
+ {
174
+ $return_points = 0;
175
+ preg_match("~%CATEGORY_POINTS%(.*?)%/CATEGORY_POINTS%~i",$content,$answer_text);
176
+ foreach ($mlw_quiz_array['question_answers_array'] as $answer)
177
+ {
178
+ if ($answer["category"] == $answer_text[1])
179
+ {
180
+ $return_points += $answer["points"];
181
+ }
182
+ }
183
+ $content = str_replace( $answer_text[0] , $return_points, $content);
184
+ }
185
+ return $content;
186
+ }
187
+
188
+ /*
189
+ * Replaces variable %CATEGORY_SCORE% with the score for that category
190
+ *
191
+ * Filter function that replaces variable %CATEGORY_SCORE% with the score from the category inside the variable tags. i.e. %CATEGORY_SCORE%category 1%/CATEGORY_SCORE%
192
+ *
193
+ * @since 4.0.0
194
+ * @param string $content The contents of the results page
195
+ * @param array $mlw_quiz_array The array of all the results from user taking the quiz
196
+ * @return string Returns the contents for the results page
197
+ */
198
+ function qmn_variable_category_score($content, $mlw_quiz_array)
199
+ {
200
+ $return_score = 0;
201
+ $total_questions = 0;
202
+ $amount_correct = 0;
203
+ while (strpos($content, '%CATEGORY_SCORE%') != false)
204
+ {
205
+ $return_score = 0;
206
+ $total_questions = 0;
207
+ $amount_correct = 0;
208
+ preg_match("~%CATEGORY_SCORE%(.*?)%/CATEGORY_SCORE%~i",$content,$answer_text);
209
+ foreach ($mlw_quiz_array['question_answers_array'] as $answer)
210
+ {
211
+ if ($answer["category"] == $answer_text[1])
212
+ {
213
+ $total_questions += 1;
214
+ if ($answer["correct"] == 'correct')
215
+ {
216
+ $amount_correct += 1;
217
+ }
218
+ }
219
+ }
220
+ if ($total_questions != 0)
221
+ {
222
+ $return_score = round((($amount_correct/$total_questions)*100), 2);
223
+ }
224
+ else
225
+ {
226
+ $return_score = 0;
227
+ }
228
+
229
+ $content = str_replace( $answer_text[0] , $return_score, $content);
230
+ }
231
+ return $content;
232
+ }
233
+
234
+ /*
235
+ * Replaces variable %CATEGORY_AVERAGE_SCORE% with the average score for all categories
236
+ *
237
+ * Filter function that replaces variable %CATEGORY_AVERAGE_SCORE% with the score from all categories.
238
+ *
239
+ * @since 4.0.0
240
+ * @param string $content The contents of the results page
241
+ * @param array $mlw_quiz_array The array of all the results from user taking the quiz
242
+ * @return string Returns the contents for the results page
243
+ */
244
+ function qmn_variable_category_average_score($content, $mlw_quiz_array)
245
+ {
246
+ $return_score = 0;
247
+ $total_categories = 0;
248
+ $total_score = 0;
249
+ $category_scores = array();
250
+ while (strpos($content, '%CATEGORY_AVERAGE_SCORE%') != false)
251
+ {
252
+ foreach ($mlw_quiz_array['question_answers_array'] as $answer)
253
+ {
254
+ if (!isset($category_scores[$answer["category"]]['total_questions']))
255
+ {
256
+ $category_scores[$answer["category"]]['total_questions'] = 0;
257
+ }
258
+ if (!isset($category_scores[$answer["category"]]['amount_correct']))
259
+ {
260
+ $category_scores[$answer["category"]]['amount_correct'] = 0;
261
+ }
262
+ $category_scores[$answer["category"]]['total_questions'] += 1;
263
+ if ($answer["correct"] == 'correct')
264
+ {
265
+ $category_scores[$answer["category"]]['amount_correct'] += 1;
266
+ }
267
+ }
268
+ foreach($category_scores as $category)
269
+ {
270
+ $total_score += $category["amount_correct"]/$category["total_questions"];
271
+ $total_categories += 1;
272
+ }
273
+ if ($total_categories != 0)
274
+ {
275
+ $return_score = round((($total_score/$total_categories)*100), 2);
276
+ }
277
+ else
278
+ {
279
+ $return_score = 0;
280
+ }
281
+ $content = str_replace( "%CATEGORY_AVERAGE_SCORE%" , $return_score, $content);
282
+ }
283
+ return $content;
284
+ }
285
+
286
+ /*
287
+ * Replaces variable %CATEGORY_AVERAGE_POINTS% with the average points for all categories
288
+ *
289
+ * Filter function that replaces variable %CATEGORY_AVERAGE_POINTS% with the points from all categories.
290
+ *
291
+ * @since 4.0.0
292
+ * @param string $content The contents of the results page
293
+ * @param array $mlw_quiz_array The array of all the results from user taking the quiz
294
+ * @return string Returns the contents for the results page
295
+ */
296
+ function qmn_variable_category_average_points($content, $mlw_quiz_array)
297
+ {
298
+ $return_score = 0;
299
+ $total_categories = 0;
300
+ $total_points = 0;
301
+ $category_scores = array();
302
+ while (strpos($content, '%CATEGORY_AVERAGE_POINTS%') != false)
303
+ {
304
+ foreach ($mlw_quiz_array['question_answers_array'] as $answer)
305
+ {
306
+ if (!isset($category_scores[$answer["category"]]['points']))
307
+ {
308
+ $category_scores[$answer["category"]]['points'] = 0;
309
+ }
310
+ $category_scores[$answer["category"]]['points'] += $answer["points"];
311
+ }
312
+ foreach($category_scores as $category)
313
+ {
314
+ $total_points += $category["points"];
315
+ $total_categories += 1;
316
+ }
317
+ $return_score = $total_points/$total_categories;
318
+ $content = str_replace( '%CATEGORY_AVERAGE_POINTS%' , $return_score, $content);
319
+ }
320
+ return $content;
321
+ }
322
+ ?>
includes/{mlw_tools.php → qmn_tools.php} RENAMED
@@ -2,12 +2,12 @@
2
  /*
3
  This page creates the main dashboard for the Quiz Master Next plugin
4
  */
5
- /*
6
  Copyright 2013, My Local Webstop (email : fpcorso@mylocalwebstop.com)
7
  */
8
 
9
  function mlw_generate_quiz_tools(){
10
- add_meta_box("wpss_mrts", 'Audit Trail', "mlw_tools_box", "quiz_wpss");
11
  ?>
12
  <!-- css -->
13
  <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
@@ -29,32 +29,16 @@ function mlw_generate_quiz_tools(){
29
  var $j = jQuery.noConflict();
30
  // increase the default animation speed to exaggerate the effect
31
  $j.fx.speeds._default = 1000;
32
- $j(function() {
33
- $j('#dialog').dialog({
34
- autoOpen: false,
35
- show: 'blind',
36
- hide: 'explode',
37
- buttons: {
38
- Ok: function() {
39
- $j(this).dialog('close');
40
- }
41
- }
42
- });
43
-
44
- $j('#opener').click(function() {
45
- $j('#dialog').dialog('open');
46
- return false;
47
- } );
48
- });
49
  $j(function() {
50
  $j("button, #prev_page, #next_page").button();
51
-
52
  });
53
  </script>
54
  <style type="text/css">
55
  textarea{
56
  border-color:#000000;
57
- color:#3300CC;
58
  cursor:hand;
59
  }
60
  p em {
@@ -64,21 +48,15 @@ function mlw_generate_quiz_tools(){
64
  }
65
  </style>
66
  <div class="wrap">
67
- <h2>Quiz Master Next Tools<a id="opener" href="">(?)</a></h2>
68
-
69
  <div style="float:left; width:100%;" class="inner-sidebar1">
70
- <?php do_meta_boxes('quiz_wpss','advanced',''); ?>
71
  </div>
72
 
73
  <div style="clear:both"></div>
74
-
75
- <?php echo mlw_qmn_show_adverts(); ?>
76
 
77
- <div id="dialog" title="Help" style="display:none;">
78
- <h3><b>Help</b></h3>
79
- <p>This page is the tools for the Quiz Master Next.</p>
80
- <p>The first widget lists the audit trail.</p>
81
- </div>
82
 
83
  </div>
84
  <?php
@@ -87,9 +65,9 @@ function mlw_generate_quiz_tools(){
87
  function mlw_tools_box()
88
  {
89
  global $wpdb;
90
- $mlw_qmn_table_limit = 25;
91
  $mlw_qmn_audit_count = $wpdb->get_var( "SELECT COUNT(trail_id) FROM " . $wpdb->prefix . "mlw_qm_audit_trail" );
92
-
93
  if( isset($_GET{'mlw_audit_page'} ) )
94
  {
95
  $mlw_qmn_audit_page = $_GET{'mlw_audit_page'} + 1;
@@ -101,65 +79,59 @@ function mlw_tools_box()
101
  $mlw_qmn_audit_begin = 0;
102
  }
103
  $mlw_qmn_audit_left = $mlw_qmn_audit_count - ($mlw_qmn_audit_page * $mlw_qmn_table_limit);
104
-
105
- $audit_trails = $wpdb->get_results( $wpdb->prepare( "SELECT trail_id, action_user, action, time
106
- FROM " . $wpdb->prefix . "mlw_qm_audit_trail
107
  ORDER BY trail_id DESC LIMIT %d, %d", $mlw_qmn_audit_begin, $mlw_qmn_table_limit ) );
108
 
109
- $quotes_list = "";
110
- $display = "";
111
- $alternate = "";
112
- foreach($audit_trails as $quote_data) {
113
- if($alternate) $alternate = "";
114
- else $alternate = " class=\"alternate\"";
115
- $quotes_list .= "<tr{$alternate}>";
116
- $quotes_list .= "<td>" . $quote_data->trail_id . "</td>";
117
- $quotes_list .= "<td>" . $quote_data->action_user . "</td>";
118
- $quotes_list .= "<td>" . $quote_data->action ."</td>";
119
- $quotes_list .= "<td>" . $quote_data->time . "</td>";
120
- $quotes_list .= "</tr>";
121
- }
122
-
123
  if( $mlw_qmn_audit_page > 0 )
124
  {
125
- $mlw_qmn_previous_page = $mlw_qmn_audit_page - 2;
126
- $display .= "<a id=\"prev_page\" href=\"?page=mlw_quiz_tools&&mlw_audit_page=$mlw_qmn_previous_page\">Previous 25 Audits</a>";
127
- if( $mlw_qmn_audit_left > $mlw_qmn_table_limit )
128
- {
129
- $display .= "<a id=\"next_page\" href=\"?page=mlw_quiz_tools&&mlw_audit_page=$mlw_qmn_audit_page\">Next 25 Audits</a>";
130
- }
131
  }
132
  else if( $mlw_qmn_audit_page == 0 )
133
  {
134
  if( $mlw_qmn_audit_left > $mlw_qmn_table_limit )
135
  {
136
- $display .= "<a id=\"next_page\" href=\"?page=mlw_quiz_tools&&mlw_audit_page=$mlw_qmn_audit_page\">Next 25 Audits</a>";
137
  }
138
  }
139
  else if( $mlw_qmn_audit_left < $mlw_qmn_table_limit )
140
  {
141
  $mlw_qmn_previous_page = $mlw_qmn_audit_page - 2;
142
- $display .= "<a id=\"prev_page\" href=\"?page=mlw_quiz_tools&&mlw_audit_page=$mlw_qmn_previous_page\">Previous 25 Audits</a>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  }
144
- $display .= "<table class=\"widefat\">";
145
- $display .= "<thead><tr>
146
- <th>ID</th>
147
- <th>User</th>
148
- <th>Action</th>
149
- <th>Time</th>
150
- </tr></thead>";
151
- $display .= "<tbody id=\"the-list\">{$quotes_list}</tbody>";
152
- $display .= "</table>";
153
  ?>
154
- <div>
155
- <table width='100%'>
156
- <tr>
157
- <td align='left'>
158
- <?php echo $display; ?>
159
- </td>
160
- </tr>
161
  </table>
162
- </div>
163
  <?php
164
  }
165
- ?>
2
  /*
3
  This page creates the main dashboard for the Quiz Master Next plugin
4
  */
5
+ /*
6
  Copyright 2013, My Local Webstop (email : fpcorso@mylocalwebstop.com)
7
  */
8
 
9
  function mlw_generate_quiz_tools(){
10
+ add_meta_box("wpss_mrts", 'Audit Trail', "mlw_tools_box", "quiz_wpss");
11
  ?>
12
  <!-- css -->
13
  <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
29
  var $j = jQuery.noConflict();
30
  // increase the default animation speed to exaggerate the effect
31
  $j.fx.speeds._default = 1000;
32
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  $j(function() {
34
  $j("button, #prev_page, #next_page").button();
35
+
36
  });
37
  </script>
38
  <style type="text/css">
39
  textarea{
40
  border-color:#000000;
41
+ color:#3300CC;
42
  cursor:hand;
43
  }
44
  p em {
48
  }
49
  </style>
50
  <div class="wrap">
51
+ <h2><?php _e('Tools', 'quiz-master-next'); ?></h2>
52
+
53
  <div style="float:left; width:100%;" class="inner-sidebar1">
54
+ <?php do_meta_boxes('quiz_wpss','advanced',''); ?>
55
  </div>
56
 
57
  <div style="clear:both"></div>
 
 
58
 
59
+ <?php echo mlw_qmn_show_adverts(); ?>
 
 
 
 
60
 
61
  </div>
62
  <?php
65
  function mlw_tools_box()
66
  {
67
  global $wpdb;
68
+ $mlw_qmn_table_limit = 30;
69
  $mlw_qmn_audit_count = $wpdb->get_var( "SELECT COUNT(trail_id) FROM " . $wpdb->prefix . "mlw_qm_audit_trail" );
70
+
71
  if( isset($_GET{'mlw_audit_page'} ) )
72
  {
73
  $mlw_qmn_audit_page = $_GET{'mlw_audit_page'} + 1;
79
  $mlw_qmn_audit_begin = 0;
80
  }
81
  $mlw_qmn_audit_left = $mlw_qmn_audit_count - ($mlw_qmn_audit_page * $mlw_qmn_table_limit);
82
+
83
+ $audit_trails = $wpdb->get_results( $wpdb->prepare( "SELECT trail_id, action_user, action, time
84
+ FROM " . $wpdb->prefix . "mlw_qm_audit_trail
85
  ORDER BY trail_id DESC LIMIT %d, %d", $mlw_qmn_audit_begin, $mlw_qmn_table_limit ) );
86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  if( $mlw_qmn_audit_page > 0 )
88
  {
89
+ $mlw_qmn_previous_page = $mlw_qmn_audit_page - 2;
90
+ echo "<a id=\"prev_page\" href=\"?page=mlw_quiz_tools&&mlw_audit_page=$mlw_qmn_previous_page\">".sprintf(__('Previous %s Audits','quiz-master-next'),$mlw_qmn_table_limit)."</a>";
91
+ if( $mlw_qmn_audit_left > $mlw_qmn_table_limit )
92
+ {
93
+ echo "<a id=\"next_page\" href=\"?page=mlw_quiz_tools&&mlw_audit_page=$mlw_qmn_audit_page\">".sprintf(__('Next %s Audits','quiz-master-next'),$mlw_qmn_table_limit)."</a>";
94
+ }
95
  }
96
  else if( $mlw_qmn_audit_page == 0 )
97
  {
98
  if( $mlw_qmn_audit_left > $mlw_qmn_table_limit )
99
  {
100
+ echo "<a id=\"next_page\" href=\"?page=mlw_quiz_tools&&mlw_audit_page=$mlw_qmn_audit_page\">".sprintf(__('Next %s Audits','quiz-master-next'),$mlw_qmn_table_limit)."</a>";
101
  }
102
  }
103
  else if( $mlw_qmn_audit_left < $mlw_qmn_table_limit )
104
  {
105
  $mlw_qmn_previous_page = $mlw_qmn_audit_page - 2;
106
+ echo "<a id=\"prev_page\" href=\"?page=mlw_quiz_tools&&mlw_audit_page=$mlw_qmn_previous_page\">".sprintf(__('Previous %s Audits','quiz-master-next'),$mlw_qmn_table_limit)."</a>";
107
+ }
108
+ ?>
109
+ <table class=widefat>
110
+ <thead>
111
+ <tr>
112
+ <th>ID</th>
113
+ <th><?php _e('User','quiz-master-next'); ?></th>
114
+ <th><?php _e('Action','quiz-master-next'); ?></th>
115
+ <th><?php _e('Time','quiz-master-next'); ?></th>
116
+ </tr>
117
+ </thead>
118
+ <tbody id="the-list">
119
+
120
+ <?php
121
+ $alternate = "";
122
+ foreach($audit_trails as $quote_data) {
123
+ if($alternate) $alternate = "";
124
+ else $alternate = " class=\"alternate\"";
125
+ echo "<tr{$alternate}>";
126
+ echo "<td>" . $quote_data->trail_id . "</td>";
127
+ echo "<td>" . $quote_data->action_user . "</td>";
128
+ echo "<td>" . $quote_data->action ."</td>";
129
+ echo "<td>" . $quote_data->time . "</td>";
130
+ echo "</tr>";
131
  }
 
 
 
 
 
 
 
 
 
132
  ?>
133
+ </tbody>
 
 
 
 
 
 
134
  </table>
 
135
  <?php
136
  }
137
+ ?>
includes/{mlw_update.php → qmn_update.php} RENAMED
@@ -4,9 +4,8 @@ This is the update function for the plugin. When the plugin gets updated, the da
4
  */
5
  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 = "3.9.0";
10
  if ( ! get_option('mlw_quiz_master_version'))
11
  {
12
  add_option('mlw_quiz_master_version' , $data);
@@ -27,7 +26,7 @@ function mlw_quiz_update()
27
  $update_sql = "UPDATE ".$table_name." SET comment_field_text='Comments', comment_section=1, message_comment='Enter You Text Here'";
28
  $results = $wpdb->query( $update_sql );
29
  }
30
-
31
  //Update 0.9.2
32
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'leaderboard_template'") != "leaderboard_template")
33
  {
@@ -42,7 +41,7 @@ function mlw_quiz_update()
42
  $update_sql = "UPDATE ".$table_name." SET leaderboard_template='".$mlw_leaderboard_default."'";
43
  $results = $wpdb->query( $update_sql );
44
  }
45
-
46
  //Update 0.9.4
47
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'randomness_order'") != "randomness_order")
48
  {
@@ -51,7 +50,7 @@ function mlw_quiz_update()
51
  $update_sql = "UPDATE ".$table_name." SET randomness_order=0";
52
  $results = $wpdb->query( $update_sql );
53
  }
54
-
55
  //Update 0.9.5
56
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_answer_template'") != "question_answer_template")
57
  {
@@ -61,7 +60,7 @@ function mlw_quiz_update()
61
  $update_sql = "UPDATE ".$table_name." SET question_answer_template='".$mlw_question_answer_default."'";
62
  $results = $wpdb->query( $update_sql );
63
  }
64
-
65
  //Update 0.9.6
66
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'contact_info_location'") != "contact_info_location")
67
  {
@@ -70,7 +69,7 @@ function mlw_quiz_update()
70
  $update_sql = "UPDATE ".$table_name." SET contact_info_location=0";
71
  $results = $wpdb->query( $update_sql );
72
  }
73
-
74
  //Update 1.0
75
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'email_from_text'") != "email_from_text")
76
  {
@@ -79,7 +78,7 @@ function mlw_quiz_update()
79
  $update_sql = "UPDATE ".$table_name." SET email_from_text='Wordpress'";
80
  $results = $wpdb->query( $update_sql );
81
  }
82
-
83
  //Update 1.3.1
84
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'loggedin_user_contact'") != "loggedin_user_contact")
85
  {
@@ -88,7 +87,7 @@ function mlw_quiz_update()
88
  $update_sql = "UPDATE ".$table_name." SET loggedin_user_contact=0";
89
  $results = $wpdb->query( $update_sql );
90
  }
91
-
92
  //Update 1.5.1
93
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_from_total'") != "question_from_total")
94
  {
@@ -97,7 +96,7 @@ function mlw_quiz_update()
97
  $update_sql = "UPDATE ".$table_name." SET question_from_total=0";
98
  $results = $wpdb->query( $update_sql );
99
  }
100
-
101
  //Update 1.6.1
102
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'total_user_tries'") != "total_user_tries")
103
  {
@@ -113,7 +112,7 @@ function mlw_quiz_update()
113
  $update_sql = "UPDATE ".$table_name." SET total_user_tries_text='Enter Your Text Here'";
114
  $results = $wpdb->query( $update_sql );
115
  }
116
-
117
  //Update 1.8.1
118
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'message_end_template'") != "message_end_template")
119
  {
@@ -129,7 +128,7 @@ function mlw_quiz_update()
129
  $update_sql = "UPDATE ".$table_name." SET certificate_template='Enter your text here!'";
130
  $results = $wpdb->query( $update_sql );
131
  }
132
-
133
  //Update 1.9.1
134
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'social_media'") != "social_media")
135
  {
@@ -166,7 +165,7 @@ function mlw_quiz_update()
166
  $update_sql = "UPDATE ".$table_name." SET timer_limit=0";
167
  $results = $wpdb->query( $update_sql );
168
  }
169
-
170
  //Update 2.1.1
171
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'quiz_stye'") != "quiz_stye")
172
  {
@@ -186,7 +185,7 @@ function mlw_quiz_update()
186
  text-align: left;
187
  }
188
  div.quiz_section {
189
-
190
  }
191
  div.mlw_qmn_timer {
192
  position:fixed;
@@ -217,7 +216,7 @@ function mlw_quiz_update()
217
  $update_sql = "UPDATE ".$table_name." SET quiz_stye='".$mlw_style_default."'";
218
  $results = $wpdb->query( $update_sql );
219
  }
220
-
221
  //Update 2.2.1
222
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_numbering'") != "question_numbering")
223
  {
@@ -226,7 +225,7 @@ function mlw_quiz_update()
226
  $update_sql = "UPDATE ".$table_name." SET question_numbering='0'";
227
  $results = $wpdb->query( $update_sql );
228
  }
229
-
230
  //Update 2.8.1
231
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'quiz_settings'") != "quiz_settings")
232
  {
@@ -235,7 +234,7 @@ function mlw_quiz_update()
235
  $update_sql = "UPDATE ".$table_name." SET quiz_settings=''";
236
  $results = $wpdb->query( $update_sql );
237
  }
238
-
239
  //Update 3.0.1
240
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'theme_selected'") != "theme_selected")
241
  {
@@ -244,7 +243,7 @@ function mlw_quiz_update()
244
  $update_sql = "UPDATE ".$table_name." SET theme_selected='default'";
245
  $results = $wpdb->query( $update_sql );
246
  }
247
-
248
  //Update 3.3.1
249
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'last_activity'") != "last_activity")
250
  {
@@ -253,7 +252,7 @@ function mlw_quiz_update()
253
  $update_sql = "UPDATE ".$table_name." SET last_activity='".date("Y-m-d H:i:s")."'";
254
  $results = $wpdb->query( $update_sql );
255
  }
256
-
257
  //Update 3.5.1
258
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'require_log_in'") != "require_log_in")
259
  {
@@ -283,7 +282,7 @@ function mlw_quiz_update()
283
  $update_sql = "UPDATE ".$table_name." SET limit_total_entries_text='Enter Text Here'";
284
  $results = $wpdb->query( $update_sql );
285
  }
286
-
287
  //Update 3.7.1
288
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'scheduled_timeframe'") != "scheduled_timeframe")
289
  {
@@ -299,8 +298,8 @@ function mlw_quiz_update()
299
  $update_sql = "UPDATE ".$table_name." SET scheduled_timeframe_text='Enter Text Here'";
300
  $results = $wpdb->query( $update_sql );
301
  }
302
-
303
-
304
  global $wpdb;
305
  $table_name = $wpdb->prefix . "mlw_questions";
306
  //Update 0.5
@@ -313,7 +312,7 @@ function mlw_quiz_update()
313
  $update_sql = "UPDATE ".$table_name." SET comments=1, hints=''";
314
  $results = $wpdb->query( $update_sql );
315
  }
316
- //Update 0.8
317
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_order'") != "question_order")
318
  {
319
  $sql = "ALTER TABLE ".$table_name." ADD question_order INT NOT NULL AFTER hints";
@@ -321,7 +320,7 @@ function mlw_quiz_update()
321
  $update_sql = "UPDATE ".$table_name." SET question_order=0";
322
  $results = $wpdb->query( $update_sql );
323
  }
324
-
325
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_type'") != "question_type")
326
  {
327
  $sql = "ALTER TABLE ".$table_name." ADD question_type INT NOT NULL AFTER question_order";
@@ -329,7 +328,7 @@ function mlw_quiz_update()
329
  $update_sql = "UPDATE ".$table_name." SET question_type=0";
330
  $results = $wpdb->query( $update_sql );
331
  }
332
-
333
  //Update 1.1.1
334
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_answer_info'") != "question_answer_info")
335
  {
@@ -338,7 +337,7 @@ function mlw_quiz_update()
338
  $update_sql = "UPDATE ".$table_name." SET question_answer_info=''";
339
  $results = $wpdb->query( $update_sql );
340
  }
341
-
342
  //Update 2.5.1
343
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'answer_array'") != "answer_array")
344
  {
@@ -347,7 +346,7 @@ function mlw_quiz_update()
347
  $update_sql = "UPDATE ".$table_name." SET answer_array=''";
348
  $results = $wpdb->query( $update_sql );
349
  }
350
-
351
  //Update 3.1.1
352
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_settings'") != "question_settings")
353
  {
@@ -356,14 +355,32 @@ function mlw_quiz_update()
356
  $update_sql = "UPDATE ".$table_name." SET question_settings=''";
357
  $results = $wpdb->query( $update_sql );
358
  }
359
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
  //Update 2.6.1
361
  $results = $wpdb->query( "ALTER TABLE ".$wpdb->prefix . "mlw_qm_audit_trail CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;" );
362
  $results = $wpdb->query( "ALTER TABLE ".$wpdb->prefix . "mlw_questions CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci" );
363
  $results = $wpdb->query( "ALTER TABLE ".$wpdb->prefix . "mlw_quizzes CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci" );
364
  $results = $wpdb->query( "ALTER TABLE ".$wpdb->prefix . "mlw_results CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci" );
365
-
366
-
367
  global $wpdb;
368
  $table_name = $wpdb->prefix . "mlw_results";
369
  //Update 2.6.4
@@ -377,8 +394,8 @@ function mlw_quiz_update()
377
  update_option('mlw_quiz_master_version' , $data);
378
  if(!isset($_GET['activate-multi']))
379
  {
380
- wp_redirect( "admin.php?page=mlw_qmn_about" );
381
- exit;
382
  }
383
  }
384
  if ( ! get_option('mlw_advert_shows'))
4
  */
5
  function mlw_quiz_update()
6
  {
7
+ global $mlwQuizMasterNext;
8
+ $data = $mlwQuizMasterNext->version;
 
9
  if ( ! get_option('mlw_quiz_master_version'))
10
  {
11
  add_option('mlw_quiz_master_version' , $data);
26
  $update_sql = "UPDATE ".$table_name." SET comment_field_text='Comments', comment_section=1, message_comment='Enter You Text Here'";
27
  $results = $wpdb->query( $update_sql );
28
  }
29
+
30
  //Update 0.9.2
31
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'leaderboard_template'") != "leaderboard_template")
32
  {
41
  $update_sql = "UPDATE ".$table_name." SET leaderboard_template='".$mlw_leaderboard_default."'";
42
  $results = $wpdb->query( $update_sql );
43
  }
44
+
45
  //Update 0.9.4
46
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'randomness_order'") != "randomness_order")
47
  {
50
  $update_sql = "UPDATE ".$table_name." SET randomness_order=0";
51
  $results = $wpdb->query( $update_sql );
52
  }
53
+
54
  //Update 0.9.5
55
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_answer_template'") != "question_answer_template")
56
  {
60
  $update_sql = "UPDATE ".$table_name." SET question_answer_template='".$mlw_question_answer_default."'";
61
  $results = $wpdb->query( $update_sql );
62
  }
63
+
64
  //Update 0.9.6
65
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'contact_info_location'") != "contact_info_location")
66
  {
69
  $update_sql = "UPDATE ".$table_name." SET contact_info_location=0";
70
  $results = $wpdb->query( $update_sql );
71
  }
72
+
73
  //Update 1.0
74
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'email_from_text'") != "email_from_text")
75
  {
78
  $update_sql = "UPDATE ".$table_name." SET email_from_text='Wordpress'";
79
  $results = $wpdb->query( $update_sql );
80
  }
81
+
82
  //Update 1.3.1
83
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'loggedin_user_contact'") != "loggedin_user_contact")
84
  {
87
  $update_sql = "UPDATE ".$table_name." SET loggedin_user_contact=0";
88
  $results = $wpdb->query( $update_sql );
89
  }
90
+
91
  //Update 1.5.1
92
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_from_total'") != "question_from_total")
93
  {
96
  $update_sql = "UPDATE ".$table_name." SET question_from_total=0";
97
  $results = $wpdb->query( $update_sql );
98
  }
99
+
100
  //Update 1.6.1
101
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'total_user_tries'") != "total_user_tries")
102
  {
112
  $update_sql = "UPDATE ".$table_name." SET total_user_tries_text='Enter Your Text Here'";
113
  $results = $wpdb->query( $update_sql );
114
  }
115
+
116
  //Update 1.8.1
117
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'message_end_template'") != "message_end_template")
118
  {
128
  $update_sql = "UPDATE ".$table_name." SET certificate_template='Enter your text here!'";
129
  $results = $wpdb->query( $update_sql );
130
  }
131
+
132
  //Update 1.9.1
133
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'social_media'") != "social_media")
134
  {
165
  $update_sql = "UPDATE ".$table_name." SET timer_limit=0";
166
  $results = $wpdb->query( $update_sql );
167
  }
168
+
169
  //Update 2.1.1
170
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'quiz_stye'") != "quiz_stye")
171
  {
185
  text-align: left;
186
  }
187
  div.quiz_section {
188
+
189
  }
190
  div.mlw_qmn_timer {
191
  position:fixed;
216
  $update_sql = "UPDATE ".$table_name." SET quiz_stye='".$mlw_style_default."'";
217
  $results = $wpdb->query( $update_sql );
218
  }
219
+
220
  //Update 2.2.1
221
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_numbering'") != "question_numbering")
222
  {
225
  $update_sql = "UPDATE ".$table_name." SET question_numbering='0'";
226
  $results = $wpdb->query( $update_sql );
227
  }
228
+
229
  //Update 2.8.1
230
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'quiz_settings'") != "quiz_settings")
231
  {
234
  $update_sql = "UPDATE ".$table_name." SET quiz_settings=''";
235
  $results = $wpdb->query( $update_sql );
236
  }
237
+
238
  //Update 3.0.1
239
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'theme_selected'") != "theme_selected")
240
  {
243
  $update_sql = "UPDATE ".$table_name." SET theme_selected='default'";
244
  $results = $wpdb->query( $update_sql );
245
  }
246
+
247
  //Update 3.3.1
248
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'last_activity'") != "last_activity")
249
  {
252
  $update_sql = "UPDATE ".$table_name." SET last_activity='".date("Y-m-d H:i:s")."'";
253
  $results = $wpdb->query( $update_sql );
254
  }
255
+
256
  //Update 3.5.1
257
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'require_log_in'") != "require_log_in")
258
  {
282
  $update_sql = "UPDATE ".$table_name." SET limit_total_entries_text='Enter Text Here'";
283
  $results = $wpdb->query( $update_sql );
284
  }
285
+
286
  //Update 3.7.1
287
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'scheduled_timeframe'") != "scheduled_timeframe")
288
  {
298
  $update_sql = "UPDATE ".$table_name." SET scheduled_timeframe_text='Enter Text Here'";
299
  $results = $wpdb->query( $update_sql );
300
  }
301
+
302
+
303
  global $wpdb;
304
  $table_name = $wpdb->prefix . "mlw_questions";
305
  //Update 0.5
312
  $update_sql = "UPDATE ".$table_name." SET comments=1, hints=''";
313
  $results = $wpdb->query( $update_sql );
314
  }
315
+ //Update 0.8
316
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_order'") != "question_order")
317
  {
318
  $sql = "ALTER TABLE ".$table_name." ADD question_order INT NOT NULL AFTER hints";
320
  $update_sql = "UPDATE ".$table_name." SET question_order=0";
321
  $results = $wpdb->query( $update_sql );
322
  }
323
+
324
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_type'") != "question_type")
325
  {
326
  $sql = "ALTER TABLE ".$table_name." ADD question_type INT NOT NULL AFTER question_order";
328
  $update_sql = "UPDATE ".$table_name." SET question_type=0";
329
  $results = $wpdb->query( $update_sql );
330
  }
331
+
332
  //Update 1.1.1
333
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_answer_info'") != "question_answer_info")
334
  {
337
  $update_sql = "UPDATE ".$table_name." SET question_answer_info=''";
338
  $results = $wpdb->query( $update_sql );
339
  }
340
+
341
  //Update 2.5.1
342
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'answer_array'") != "answer_array")
343
  {
346
  $update_sql = "UPDATE ".$table_name." SET answer_array=''";
347
  $results = $wpdb->query( $update_sql );
348
  }
349
+
350
  //Update 3.1.1
351
  if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_settings'") != "question_settings")
352
  {
355
  $update_sql = "UPDATE ".$table_name." SET question_settings=''";
356
  $results = $wpdb->query( $update_sql );
357
  }
358
+
359
+ //Update 4.0.0
360
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'category'") != "category")
361
+ {
362
+ $sql = "ALTER TABLE ".$table_name." ADD category TEXT NOT NULL AFTER question_settings";
363
+ $results = $wpdb->query( $sql );
364
+ $update_sql = "UPDATE ".$table_name." SET category=''";
365
+ $results = $wpdb->query( $update_sql );
366
+ }
367
+
368
+ //Update 4.0.0
369
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_type_new'") != "question_type_new")
370
+ {
371
+ $sql = "ALTER TABLE ".$table_name." ADD question_type_new TEXT NOT NULL AFTER question_type";
372
+ $results = $wpdb->query( $sql );
373
+ $update_sql = "UPDATE ".$table_name." SET question_type_new=question_type";
374
+ $results = $wpdb->query( $update_sql );
375
+ }
376
+
377
  //Update 2.6.1
378
  $results = $wpdb->query( "ALTER TABLE ".$wpdb->prefix . "mlw_qm_audit_trail CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;" );
379
  $results = $wpdb->query( "ALTER TABLE ".$wpdb->prefix . "mlw_questions CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci" );
380
  $results = $wpdb->query( "ALTER TABLE ".$wpdb->prefix . "mlw_quizzes CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci" );
381
  $results = $wpdb->query( "ALTER TABLE ".$wpdb->prefix . "mlw_results CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci" );
382
+
383
+
384
  global $wpdb;
385
  $table_name = $wpdb->prefix . "mlw_results";
386
  //Update 2.6.4
394
  update_option('mlw_quiz_master_version' , $data);
395
  if(!isset($_GET['activate-multi']))
396
  {
397
+ wp_safe_redirect( admin_url( 'index.php?page=mlw_qmn_about' ) );
398
+ exit;
399
  }
400
  }
401
  if ( ! get_option('mlw_advert_shows'))
includes/{mlw_qmn_widgets.php → qmn_widgets.php} RENAMED
@@ -4,14 +4,14 @@ This is the file that contains all the widgets for the plugin
4
  */
5
 
6
  class Mlw_Qmn_Leaderboard_Widget extends WP_Widget {
7
-
8
  // constructor
9
  function Mlw_Qmn_Leaderboard_Widget() {
10
- parent::WP_Widget(false, $name = __('Quiz Master Next Leaderboard Widget', 'mlw_qmn_text_domain'));
11
  }
12
-
13
  // widget form creation
14
- function form($instance) {
15
  // Check values
16
  if( $instance) {
17
  $title = esc_attr($instance['title']);
@@ -22,16 +22,16 @@ class Mlw_Qmn_Leaderboard_Widget extends WP_Widget {
22
  }
23
  ?>
24
  <p>
25
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget Title', 'mlw_qmn_text_domain'); ?></label>
26
  <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
27
  </p>
28
  <p>
29
- <label for="<?php echo $this->get_field_id('quiz_id'); ?>"><?php _e('Quiz ID', 'mlw_qmn_text_domain'); ?></label>
30
  <input class="widefat" id="<?php echo $this->get_field_id('quiz_id'); ?>" name="<?php echo $this->get_field_name('quiz_id'); ?>" type="number" step="1" min="1" value="<?php echo $quiz_id; ?>" />
31
  </p>
32
  <?php
33
  }
34
-
35
  // widget update
36
  function update($new_instance, $old_instance) {
37
  $instance = $old_instance;
@@ -40,7 +40,7 @@ class Mlw_Qmn_Leaderboard_Widget extends WP_Widget {
40
  $instance['quiz_id'] = strip_tags($new_instance['quiz_id']);
41
  return $instance;
42
  }
43
-
44
  // widget display
45
  function widget($args, $instance) {
46
  extract( $args );
@@ -56,8 +56,8 @@ class Mlw_Qmn_Leaderboard_Widget extends WP_Widget {
56
  }
57
  $mlw_quiz_id = $quiz_id;
58
  $mlw_quiz_leaderboard_display = "";
59
-
60
-
61
  global $wpdb;
62
  $sql = "SELECT * FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=".$mlw_quiz_id." AND deleted='0'";
63
  $mlw_quiz_options = $wpdb->get_results($sql);
@@ -76,10 +76,10 @@ class Mlw_Qmn_Leaderboard_Widget extends WP_Widget {
76
  }
77
  $sql .= " LIMIT 10";
78
  $mlw_result_data = $wpdb->get_results($sql);
79
-
80
  $mlw_quiz_leaderboard_display = $mlw_quiz_options->leaderboard_template;
81
  $mlw_quiz_leaderboard_display = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_quiz_leaderboard_display);
82
-
83
  $leader_count = 0;
84
  foreach($mlw_result_data as $mlw_eaches) {
85
  $leader_count++;
@@ -116,10 +116,10 @@ class Mlw_Qmn_Leaderboard_Widget extends WP_Widget {
116
  $mlw_quiz_leaderboard_display = str_replace( "%THIRD_PLACE_SCORE%" , " ", $mlw_quiz_leaderboard_display);
117
  $mlw_quiz_leaderboard_display = str_replace( "%FOURTH_PLACE_SCORE%" , " ", $mlw_quiz_leaderboard_display);
118
  $mlw_quiz_leaderboard_display = str_replace( "%FIFTH_PLACE_SCORE%" , " ", $mlw_quiz_leaderboard_display);
119
-
120
  echo $mlw_quiz_leaderboard_display;
121
  echo '</div>';
122
  echo $after_widget;
123
  }
124
  }
125
- ?>
4
  */
5
 
6
  class Mlw_Qmn_Leaderboard_Widget extends WP_Widget {
7
+
8
  // constructor
9
  function Mlw_Qmn_Leaderboard_Widget() {
10
+ parent::WP_Widget(false, $name = __('Quiz Master Next Leaderboard Widget', 'quiz-master-next'));
11
  }
12
+
13
  // widget form creation
14
+ function form($instance) {
15
  // Check values
16
  if( $instance) {
17
  $title = esc_attr($instance['title']);
22
  }
23
  ?>
24
  <p>
25
+ <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget Title', 'quiz-master-next'); ?></label>
26
  <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
27
  </p>
28
  <p>
29
+ <label for="<?php echo $this->get_field_id('quiz_id'); ?>"><?php _e('Quiz ID', 'quiz-master-next'); ?></label>
30
  <input class="widefat" id="<?php echo $this->get_field_id('quiz_id'); ?>" name="<?php echo $this->get_field_name('quiz_id'); ?>" type="number" step="1" min="1" value="<?php echo $quiz_id; ?>" />
31
  </p>
32
  <?php
33
  }
34
+
35
  // widget update
36
  function update($new_instance, $old_instance) {
37
  $instance = $old_instance;
40
  $instance['quiz_id'] = strip_tags($new_instance['quiz_id']);
41
  return $instance;
42
  }
43
+
44
  // widget display
45
  function widget($args, $instance) {
46
  extract( $args );
56
  }
57
  $mlw_quiz_id = $quiz_id;
58
  $mlw_quiz_leaderboard_display = "";
59
+
60
+
61
  global $wpdb;
62
  $sql = "SELECT * FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=".$mlw_quiz_id." AND deleted='0'";
63
  $mlw_quiz_options = $wpdb->get_results($sql);
76
  }
77
  $sql .= " LIMIT 10";
78
  $mlw_result_data = $wpdb->get_results($sql);
79
+
80
  $mlw_quiz_leaderboard_display = $mlw_quiz_options->leaderboard_template;
81
  $mlw_quiz_leaderboard_display = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_quiz_leaderboard_display);
82
+
83
  $leader_count = 0;
84
  foreach($mlw_result_data as $mlw_eaches) {
85
  $leader_count++;
116
  $mlw_quiz_leaderboard_display = str_replace( "%THIRD_PLACE_SCORE%" , " ", $mlw_quiz_leaderboard_display);
117
  $mlw_quiz_leaderboard_display = str_replace( "%FOURTH_PLACE_SCORE%" , " ", $mlw_quiz_leaderboard_display);
118
  $mlw_quiz_leaderboard_display = str_replace( "%FIFTH_PLACE_SCORE%" , " ", $mlw_quiz_leaderboard_display);
119
+
120
  echo $mlw_quiz_leaderboard_display;
121
  echo '</div>';
122
  echo $after_widget;
123
  }
124
  }
125
+ ?>
languages/index.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+
5
+ ?>
languages/quiz-master-next.pot ADDED
@@ -0,0 +1,1491 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Quiz Master Next
2
+ # Copyright (C) 2015 ...
3
+ # This file is distributed under the GNU General Public License v2 or later.
4
+ msgid ""
5
+ msgstr ""
6
+ "Project-Id-Version: Quiz Master Next\n"
7
+ "Report-Msgid-Bugs-To: Frank Corso <fpcorso@mylocalwebstop.com>\n"
8
+ "POT-Creation-Date: 2015-01-13 11:37-0500\n"
9
+ "PO-Revision-Date: \n"
10
+ "Last-Translator: Your Name <you@example.com>\n"
11
+ "Language-Team: My Local Webstop <fpcorso@mylocalwebstop.com>\n"
12
+ "Language: en_US\n"
13
+ "MIME-Version: 1.0\n"
14
+ "Content-Type: text/plain; charset=UTF-8\n"
15
+ "Content-Transfer-Encoding: 8bit\n"
16
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
17
+ "X-Textdomain-Support: yesX-Generator: Poedit 1.6.4\n"
18
+ "X-Poedit-SourceCharset: UTF-8\n"
19
+ "X-Poedit-KeywordsList: __;_e;esc_html_e;esc_html_x:1,2c;esc_html__;"
20
+ "esc_attr_e;esc_attr_x:1,2c;esc_attr__;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;"
21
+ "_x:1,2c;_n:1,2;_n_noop:1,2;__ngettext:1,2;__ngettext_noop:1,2;_c,_nc:4c,1,2\n"
22
+ "X-Poedit-Basepath: ../\n"
23
+ "X-Generator: Poedit 1.7.3\n"
24
+ "X-Poedit-SearchPath-0: .\n"
25
+
26
+ #: includes/qmn_addons.php:43
27
+ msgid "These addons extend the functionality of Quiz Master Next"
28
+ msgstr ""
29
+
30
+ #: includes/qmn_addons.php:66
31
+ msgid "Browse All Addons"
32
+ msgstr ""
33
+
34
+ #: includes/qmn_addons.php:73
35
+ msgid "Featured Addons"
36
+ msgstr ""
37
+
38
+ #: includes/qmn_alerts.php:18
39
+ msgid "Success!"
40
+ msgstr ""
41
+
42
+ #: includes/qmn_alerts.php:22 includes/qmn_quiz_options.php:91
43
+ #: includes/qmn_results_details.php:301
44
+ msgid "Error!"
45
+ msgstr ""
46
+
47
+ #: includes/qmn_credits.php:85
48
+ msgid "Welcome To Quiz Master Next"
49
+ msgstr ""
50
+
51
+ #: includes/qmn_credits.php:86
52
+ msgid "Thank you for updating!"
53
+ msgstr ""
54
+
55
+ #: includes/qmn_credits.php:90
56
+ msgid "What's New!"
57
+ msgstr ""
58
+
59
+ #: includes/qmn_credits.php:92
60
+ msgid "Changelog"
61
+ msgstr ""
62
+
63
+ #: includes/qmn_credits.php:94
64
+ msgid "Requested Features"
65
+ msgstr ""
66
+
67
+ #: includes/qmn_dashboard.php:15
68
+ msgid "Quiz Daily Stats - Times Taken"
69
+ msgstr ""
70
+
71
+ #: includes/qmn_dashboard.php:16
72
+ msgid "Quiz Total Stats"
73
+ msgstr ""
74
+
75
+ #: includes/qmn_dashboard.php:17
76
+ msgid "Quiz Weekly Stats - Times Taken"
77
+ msgstr ""
78
+
79
+ #: includes/qmn_dashboard.php:18
80
+ msgid "Quiz Monthly Stats - Times Taken"
81
+ msgstr ""
82
+
83
+ #: includes/qmn_dashboard.php:19
84
+ msgid "Quiz Quarterly Stats - Times Taken"
85
+ msgstr ""
86
+
87
+ #: includes/qmn_dashboard.php:24
88
+ msgid "Quizzes Taken Today"
89
+ msgstr ""
90
+
91
+ #: includes/qmn_dashboard.php:25
92
+ msgid "Quizzes Taken Last 7 Days"
93
+ msgstr ""
94
+
95
+ #: includes/qmn_dashboard.php:26
96
+ msgid "Quizzes Taken Last 30 Days"
97
+ msgstr ""
98
+
99
+ #: includes/qmn_dashboard.php:27
100
+ msgid "Quizzes Taken Last 120 Days"
101
+ msgstr ""
102
+
103
+ #: includes/qmn_dashboard.php:53
104
+ msgid "Quiz Statistics"
105
+ msgstr ""
106
+
107
+ #: includes/qmn_dashboard.php:227
108
+ msgid "Total Created Quizzes"
109
+ msgstr ""
110
+
111
+ #: includes/qmn_dashboard.php:231
112
+ msgid "Total Deleted Quizzes"
113
+ msgstr ""
114
+
115
+ #: includes/qmn_dashboard.php:235
116
+ msgid "Total Active Quizzes"
117
+ msgstr ""
118
+
119
+ #: includes/qmn_dashboard.php:239
120
+ msgid "Total Created Questions"
121
+ msgstr ""
122
+
123
+ #: includes/qmn_dashboard.php:243
124
+ msgid "Total Times All Active Quizzes Have Been Viewed"
125
+ msgstr ""
126
+
127
+ #: includes/qmn_dashboard.php:247
128
+ msgid "Total Times All Active Quizzes Have Been Taken"
129
+ msgstr ""
130
+
131
+ #: includes/qmn_dashboard.php:251
132
+ msgid "Average Amount Each Active Quiz Has Been Viewed"
133
+ msgstr ""
134
+
135
+ #: includes/qmn_dashboard.php:255
136
+ msgid "Average Amount Each Active Quiz Has Been Taken"
137
+ msgstr ""
138
+
139
+ #: includes/qmn_dashboard.php:259
140
+ msgid "Quiz That Has Been Viewed The Most"
141
+ msgstr ""
142
+
143
+ #: includes/qmn_dashboard.php:263
144
+ msgid "Quiz That Has Been Taken The Most"
145
+ msgstr ""
146
+
147
+ #: includes/qmn_dashboard_widgets.php:8
148
+ msgid "Quiz Master Next Snapshot"
149
+ msgstr ""
150
+
151
+ #: includes/qmn_dashboard_widgets.php:127
152
+ msgid "quizzes taken today"
153
+ msgstr ""
154
+
155
+ #: includes/qmn_dashboard_widgets.php:146
156
+ msgid "quizzes taken last 7 days"
157
+ msgstr ""
158
+
159
+ #: includes/qmn_dashboard_widgets.php:165
160
+ msgid "total active quizzes"
161
+ msgstr ""
162
+
163
+ #: includes/qmn_dashboard_widgets.php:171
164
+ msgid "total active questions"
165
+ msgstr ""
166
+
167
+ #: includes/qmn_dashboard_widgets.php:177
168
+ msgid "most popular quiz"
169
+ msgstr ""
170
+
171
+ #: includes/qmn_dashboard_widgets.php:183
172
+ msgid "least popular quiz"
173
+ msgstr ""
174
+
175
+ #: includes/qmn_help.php:12
176
+ msgid "Need Help?"
177
+ msgstr ""
178
+
179
+ #: includes/qmn_help.php:13
180
+ msgid "Support"
181
+ msgstr ""
182
+
183
+ #: includes/qmn_help.php:14
184
+ msgid "System Info"
185
+ msgstr ""
186
+
187
+ #: includes/qmn_help.php:17
188
+ msgid "Help Page"
189
+ msgstr ""
190
+
191
+ #: includes/qmn_help.php:40
192
+ msgid "Need help with the plugin? Try any of the following:"
193
+ msgstr ""
194
+
195
+ #: includes/qmn_options_certificate_tab.php:5
196
+ msgid "Certificate (Beta)"
197
+ msgstr ""
198
+
199
+ #: includes/qmn_options_certificate_tab.php:31
200
+ msgid "The certificate has been updated successfully."
201
+ msgstr ""
202
+
203
+ #: includes/qmn_options_certificate_tab.php:44
204
+ #: includes/qmn_options_email_tab.php:54
205
+ #: includes/qmn_options_email_tab.php:113
206
+ #: includes/qmn_options_email_tab.php:176
207
+ #: includes/qmn_options_leaderboard_tab.php:37
208
+ #: includes/qmn_options_option_tab.php:55
209
+ #: includes/qmn_options_questions_tab.php:117
210
+ #: includes/qmn_options_questions_tab.php:144
211
+ #: includes/qmn_options_questions_tab.php:228
212
+ #: includes/qmn_options_questions_tab.php:321
213
+ #: includes/qmn_options_results_page_tab.php:53
214
+ #: includes/qmn_options_results_page_tab.php:93
215
+ #: includes/qmn_options_style_tab.php:38 includes/qmn_options_text_tab.php:54
216
+ #: includes/qmn_options_tools_tab.php:35 includes/qmn_quiz_creator.php:347
217
+ #: includes/qmn_quiz_creator.php:400 includes/qmn_quiz_creator.php:442
218
+ #: includes/qmn_quiz_creator.php:588 includes/qmn_quiz_creator.php:653
219
+ #: includes/qmn_results.php:32
220
+ #, php-format
221
+ msgid ""
222
+ "There has been an error in this action. Please share this with the "
223
+ "developer. Error Code: %s"
224
+ msgstr ""
225
+
226
+ #: includes/qmn_options_certificate_tab.php:60
227
+ msgid "Enter title here"
228
+ msgstr ""
229
+
230
+ #: includes/qmn_options_certificate_tab.php:60
231
+ #: includes/qmn_options_email_tab.php:72 includes/qmn_options_email_tab.php:90
232
+ msgid "Enter text here"
233
+ msgstr ""
234
+
235
+ #: includes/qmn_options_certificate_tab.php:69
236
+ msgid "Quiz Certificate (Beta)"
237
+ msgstr ""
238
+
239
+ #: includes/qmn_options_certificate_tab.php:70
240
+ msgid ""
241
+ "Enter in your text here to fill in the certificate for this quiz. Be sure to "
242
+ "enter in the link variable into the templates on the Quiz Text tab so the "
243
+ "user can access the certificate."
244
+ msgstr ""
245
+
246
+ #: includes/qmn_options_certificate_tab.php:71
247
+ msgid "These fields cannot contain HTML."
248
+ msgstr ""
249
+
250
+ #: includes/qmn_options_certificate_tab.php:72
251
+ #: includes/qmn_options_certificate_tab.php:128
252
+ msgid "Save Certificate Options"
253
+ msgstr ""
254
+
255
+ #: includes/qmn_options_certificate_tab.php:80
256
+ msgid "Enable Certificates For This Quiz?"
257
+ msgstr ""
258
+
259
+ #: includes/qmn_options_certificate_tab.php:82
260
+ #: includes/qmn_options_email_tab.php:296
261
+ #: includes/qmn_options_email_tab.php:303
262
+ #: includes/qmn_options_option_tab.php:101
263
+ #: includes/qmn_options_option_tab.php:162
264
+ #: includes/qmn_options_option_tab.php:169
265
+ #: includes/qmn_options_option_tab.php:177
266
+ #: includes/qmn_options_option_tab.php:185
267
+ #: includes/qmn_options_option_tab.php:193
268
+ #: includes/qmn_options_option_tab.php:201
269
+ #: includes/qmn_options_option_tab.php:208
270
+ #: includes/qmn_options_option_tab.php:215
271
+ #: includes/qmn_options_questions_tab.php:672
272
+ #: includes/qmn_options_questions_tab.php:827
273
+ #: includes/qmn_options_results_page_tab.php:227
274
+ msgid "Yes"
275
+ msgstr ""
276
+
277
+ #: includes/qmn_options_certificate_tab.php:83
278
+ #: includes/qmn_options_email_tab.php:297
279
+ #: includes/qmn_options_email_tab.php:304
280
+ #: includes/qmn_options_option_tab.php:102
281
+ #: includes/qmn_options_option_tab.php:149
282
+ #: includes/qmn_options_option_tab.php:163
283
+ #: includes/qmn_options_option_tab.php:171
284
+ #: includes/qmn_options_option_tab.php:179
285
+ #: includes/qmn_options_option_tab.php:187
286
+ #: includes/qmn_options_option_tab.php:195
287
+ #: includes/qmn_options_option_tab.php:202
288
+ #: includes/qmn_options_option_tab.php:209
289
+ #: includes/qmn_options_option_tab.php:216
290
+ #: includes/qmn_options_questions_tab.php:673
291
+ #: includes/qmn_options_questions_tab.php:828
292
+ #: includes/qmn_options_results_page_tab.php:227
293
+ msgid "No"
294
+ msgstr ""
295
+
296
+ #: includes/qmn_options_certificate_tab.php:88
297
+ msgid "Certificate Title"
298
+ msgstr ""
299
+
300
+ #: includes/qmn_options_certificate_tab.php:95
301
+ msgid "Message Displayed On Certificate"
302
+ msgstr ""
303
+
304
+ #: includes/qmn_options_certificate_tab.php:97
305
+ #: includes/qmn_options_leaderboard_tab.php:90
306
+ #: includes/qmn_options_text_tab.php:155 includes/qmn_options_text_tab.php:165
307
+ #: includes/qmn_options_text_tab.php:175 includes/qmn_options_text_tab.php:185
308
+ #: includes/qmn_options_text_tab.php:195 includes/qmn_options_text_tab.php:205
309
+ #: includes/qmn_options_text_tab.php:215 includes/qmn_options_text_tab.php:225
310
+ #: includes/qmn_options_text_tab.php:238 includes/qmn_options_text_tab.php:255
311
+ msgid "Allowed Variables:"
312
+ msgstr ""
313
+
314
+ #: includes/qmn_options_certificate_tab.php:115
315
+ msgid "URL To Logo (Must be JPG, JPEG, PNG or GIF)"
316
+ msgstr ""
317
+
318
+ #: includes/qmn_options_certificate_tab.php:122
319
+ msgid "URL To Background Img (Must be JPG, JPEG, PNG or GIF)"
320
+ msgstr ""
321
+
322
+ #: includes/qmn_options_email_tab.php:5
323
+ msgid "Emails"
324
+ msgstr ""
325
+
326
+ #: includes/qmn_options_email_tab.php:41
327
+ #: includes/qmn_options_email_tab.php:100
328
+ msgid "The email has been added successfully."
329
+ msgstr ""
330
+
331
+ #: includes/qmn_options_email_tab.php:163
332
+ msgid "The email has been updated successfully."
333
+ msgstr ""
334
+
335
+ #: includes/qmn_options_email_tab.php:229
336
+ #: includes/qmn_options_leaderboard_tab.php:48
337
+ #: includes/qmn_options_text_tab.php:90
338
+ msgid "Template Variables"
339
+ msgstr ""
340
+
341
+ #: includes/qmn_options_email_tab.php:232
342
+ #: includes/qmn_options_results_page_tab.php:135
343
+ msgid "Score for the quiz when using points"
344
+ msgstr ""
345
+
346
+ #: includes/qmn_options_email_tab.php:233
347
+ #: includes/qmn_options_results_page_tab.php:136
348
+ #: includes/qmn_options_text_tab.php:94
349
+ msgid "The average amount of points user had per question"
350
+ msgstr ""
351
+
352
+ #: includes/qmn_options_email_tab.php:237
353
+ #: includes/qmn_options_results_page_tab.php:140
354
+ #: includes/qmn_options_text_tab.php:98
355
+ msgid "The number of correct answers the user had"
356
+ msgstr ""
357
+
358
+ #: includes/qmn_options_email_tab.php:238
359
+ #: includes/qmn_options_results_page_tab.php:141
360
+ #: includes/qmn_options_text_tab.php:99
361
+ msgid "The total number of questions in the quiz"
362
+ msgstr ""
363
+
364
+ #: includes/qmn_options_email_tab.php:242
365
+ #: includes/qmn_options_results_page_tab.php:145
366
+ msgid "Score for the quiz when using correct answers"
367
+ msgstr ""
368
+
369
+ #: includes/qmn_options_email_tab.php:246
370
+ #: includes/qmn_options_results_page_tab.php:149
371
+ #: includes/qmn_options_text_tab.php:107
372
+ msgid "The name the user entered before the quiz"
373
+ msgstr ""
374
+
375
+ #: includes/qmn_options_email_tab.php:247
376
+ #: includes/qmn_options_results_page_tab.php:150
377
+ #: includes/qmn_options_text_tab.php:108
378
+ msgid "The business the user entered before the quiz"
379
+ msgstr ""
380
+
381
+ #: includes/qmn_options_email_tab.php:251
382
+ #: includes/qmn_options_results_page_tab.php:154
383
+ #: includes/qmn_options_text_tab.php:112
384
+ msgid "The phone number the user entered before the quiz"
385
+ msgstr ""
386
+
387
+ #: includes/qmn_options_email_tab.php:252
388
+ #: includes/qmn_options_results_page_tab.php:155
389
+ #: includes/qmn_options_text_tab.php:113
390
+ msgid "The email the user entered before the quiz"
391
+ msgstr ""
392
+
393
+ #: includes/qmn_options_email_tab.php:256
394
+ #: includes/qmn_options_leaderboard_tab.php:76
395
+ #: includes/qmn_options_results_page_tab.php:159
396
+ #: includes/qmn_options_text_tab.php:117
397
+ msgid "The name of the quiz"
398
+ msgstr ""
399
+
400
+ #: includes/qmn_options_email_tab.php:257
401
+ #: includes/qmn_options_results_page_tab.php:160
402
+ #: includes/qmn_options_text_tab.php:118
403
+ msgid ""
404
+ "Shows the question, the answer the user provided, and the correct answer"
405
+ msgstr ""
406
+
407
+ #: includes/qmn_options_email_tab.php:261
408
+ #: includes/qmn_options_results_page_tab.php:164
409
+ #: includes/qmn_options_text_tab.php:122
410
+ msgid "The comments the user entered into comment box if enabled"
411
+ msgstr ""
412
+
413
+ #: includes/qmn_options_email_tab.php:262
414
+ #: includes/qmn_options_results_page_tab.php:165
415
+ #: includes/qmn_options_text_tab.php:136
416
+ msgid "The amount of time user spent of quiz"
417
+ msgstr ""
418
+
419
+ #: includes/qmn_options_email_tab.php:265
420
+ #: includes/qmn_options_results_page_tab.php:168
421
+ #: includes/qmn_options_text_tab.php:137
422
+ msgid "The link to the certificate after completing the quiz"
423
+ msgstr ""
424
+
425
+ #: includes/qmn_options_email_tab.php:268
426
+ #: includes/qmn_options_results_page_tab.php:171
427
+ msgid "The amount of points a specific category earned."
428
+ msgstr ""
429
+
430
+ #: includes/qmn_options_email_tab.php:269
431
+ #: includes/qmn_options_results_page_tab.php:172
432
+ msgid "The score a specific category earned."
433
+ msgstr ""
434
+
435
+ #: includes/qmn_options_email_tab.php:276
436
+ #: includes/qmn_options_results_page_tab.php:179
437
+ msgid "The average points from all categories."
438
+ msgstr ""
439
+
440
+ #: includes/qmn_options_email_tab.php:277
441
+ #: includes/qmn_options_results_page_tab.php:180
442
+ msgid "The average score from all categories."
443
+ msgstr ""
444
+
445
+ #: includes/qmn_options_email_tab.php:290
446
+ #: includes/qmn_options_email_tab.php:485
447
+ msgid "Save Email Templates And Settings"
448
+ msgstr ""
449
+
450
+ #: includes/qmn_options_email_tab.php:294
451
+ msgid "Send user email upon completion?"
452
+ msgstr ""
453
+
454
+ #: includes/qmn_options_email_tab.php:301
455
+ msgid "Send admin email upon completion?"
456
+ msgstr ""
457
+
458
+ #: includes/qmn_options_email_tab.php:308
459
+ msgid ""
460
+ "What emails should we send the admin email to? Separate emails with a comma."
461
+ msgstr ""
462
+
463
+ #: includes/qmn_options_email_tab.php:314
464
+ msgid "Email Sent To User"
465
+ msgstr ""
466
+
467
+ #: includes/qmn_options_email_tab.php:315
468
+ #: includes/qmn_options_email_tab.php:393
469
+ msgid "Add New User Email"
470
+ msgstr ""
471
+
472
+ #: includes/qmn_options_email_tab.php:320
473
+ #: includes/qmn_options_email_tab.php:386
474
+ #: includes/qmn_options_email_tab.php:407
475
+ #: includes/qmn_options_email_tab.php:473
476
+ #: includes/qmn_options_results_page_tab.php:190
477
+ #: includes/qmn_options_results_page_tab.php:247
478
+ msgid "Score Greater Than Or Equal To"
479
+ msgstr ""
480
+
481
+ #: includes/qmn_options_email_tab.php:321
482
+ #: includes/qmn_options_email_tab.php:387
483
+ #: includes/qmn_options_email_tab.php:408
484
+ #: includes/qmn_options_email_tab.php:474
485
+ #: includes/qmn_options_results_page_tab.php:191
486
+ #: includes/qmn_options_results_page_tab.php:248
487
+ msgid "Score Less Than Or Equal To"
488
+ msgstr ""
489
+
490
+ #: includes/qmn_options_email_tab.php:322
491
+ #: includes/qmn_options_email_tab.php:388
492
+ #: includes/qmn_options_email_tab.php:409
493
+ #: includes/qmn_options_email_tab.php:475
494
+ msgid "Subject"
495
+ msgstr ""
496
+
497
+ #: includes/qmn_options_email_tab.php:323
498
+ #: includes/qmn_options_email_tab.php:389
499
+ #: includes/qmn_options_email_tab.php:410
500
+ #: includes/qmn_options_email_tab.php:476
501
+ msgid "Email To Send"
502
+ msgstr ""
503
+
504
+ #: includes/qmn_options_email_tab.php:401
505
+ msgid "Email Sent To Admin"
506
+ msgstr ""
507
+
508
+ #: includes/qmn_options_email_tab.php:402
509
+ #: includes/qmn_options_email_tab.php:480
510
+ msgid "Add New Admin Email"
511
+ msgstr ""
512
+
513
+ #: includes/qmn_options_leaderboard_tab.php:5
514
+ msgid "Leaderboard"
515
+ msgstr ""
516
+
517
+ #: includes/qmn_options_leaderboard_tab.php:24
518
+ msgid "The leaderboards has been updated successfully."
519
+ msgstr ""
520
+
521
+ #: includes/qmn_options_leaderboard_tab.php:51
522
+ msgid "The name of the user who is in first place"
523
+ msgstr ""
524
+
525
+ #: includes/qmn_options_leaderboard_tab.php:52
526
+ msgid "The score from the first place's quiz"
527
+ msgstr ""
528
+
529
+ #: includes/qmn_options_leaderboard_tab.php:56
530
+ msgid "The name of the user who is in second place"
531
+ msgstr ""
532
+
533
+ #: includes/qmn_options_leaderboard_tab.php:57
534
+ msgid "The score from the second place's quiz"
535
+ msgstr ""
536
+
537
+ #: includes/qmn_options_leaderboard_tab.php:61
538
+ msgid "The name of the user who is in third place"
539
+ msgstr ""
540
+
541
+ #: includes/qmn_options_leaderboard_tab.php:62
542
+ msgid "The score from the third place's quiz"
543
+ msgstr ""
544
+
545
+ #: includes/qmn_options_leaderboard_tab.php:66
546
+ msgid "The name of the user who is in fourth place"
547
+ msgstr ""
548
+
549
+ #: includes/qmn_options_leaderboard_tab.php:67
550
+ msgid "The score from the fourth place's quiz"
551
+ msgstr ""
552
+
553
+ #: includes/qmn_options_leaderboard_tab.php:71
554
+ msgid "The name of the user who is in fifth place"
555
+ msgstr ""
556
+
557
+ #: includes/qmn_options_leaderboard_tab.php:72
558
+ msgid "The score from the fifth place's quiz"
559
+ msgstr ""
560
+
561
+ #: includes/qmn_options_leaderboard_tab.php:79
562
+ #: includes/qmn_options_leaderboard_tab.php:107
563
+ msgid "Save Leaderboard Options"
564
+ msgstr ""
565
+
566
+ #: includes/qmn_options_leaderboard_tab.php:88
567
+ msgid "Leaderboard Template"
568
+ msgstr ""
569
+
570
+ #: includes/qmn_options_option_tab.php:5
571
+ msgid "Options"
572
+ msgstr ""
573
+
574
+ #: includes/qmn_options_option_tab.php:42
575
+ msgid "The options has been updated successfully."
576
+ msgstr ""
577
+
578
+ #: includes/qmn_options_option_tab.php:83
579
+ #: includes/qmn_options_option_tab.php:220
580
+ msgid "Save Options"
581
+ msgstr ""
582
+
583
+ #: includes/qmn_options_option_tab.php:91
584
+ msgid "Which system is this quiz graded on?"
585
+ msgstr ""
586
+
587
+ #: includes/qmn_options_option_tab.php:93
588
+ msgid "Correct/Incorrect"
589
+ msgstr ""
590
+
591
+ #: includes/qmn_options_option_tab.php:94
592
+ msgid "Points"
593
+ msgstr ""
594
+
595
+ #: includes/qmn_options_option_tab.php:95 includes/qmn_results.php:196
596
+ msgid "Not Graded"
597
+ msgstr ""
598
+
599
+ #: includes/qmn_options_option_tab.php:99
600
+ msgid "Should the user be required to be logged in to take this quiz?"
601
+ msgstr ""
602
+
603
+ #: includes/qmn_options_option_tab.php:106
604
+ msgid ""
605
+ "How many questions per page would you like? (Leave 0 for all questions on "
606
+ "one page)"
607
+ msgstr ""
608
+
609
+ #: includes/qmn_options_option_tab.php:112
610
+ msgid ""
611
+ "How many minutes does the user have to finish the quiz? (Leave 0 for no time "
612
+ "limit)"
613
+ msgstr ""
614
+
615
+ #: includes/qmn_options_option_tab.php:118
616
+ msgid ""
617
+ "How many times can a user take this quiz? (Leave 0 for as many times as the "
618
+ "user wants to. Currently only works for registered users)"
619
+ msgstr ""
620
+
621
+ #: includes/qmn_options_option_tab.php:124
622
+ msgid ""
623
+ "How many total entries can this quiz have? (Leave 0 for unlimited entries"
624
+ msgstr ""
625
+
626
+ #: includes/qmn_options_option_tab.php:130
627
+ msgid ""
628
+ "How many questions should be loaded for quiz? (Leave 0 to load all questions)"
629
+ msgstr ""
630
+
631
+ #: includes/qmn_options_option_tab.php:136
632
+ msgid ""
633
+ "What time-frame should the user be able to access the quiz? (Leave blank if "
634
+ "the user can access anytime)"
635
+ msgstr ""
636
+
637
+ #: includes/qmn_options_option_tab.php:138
638
+ msgid "start date"
639
+ msgstr ""
640
+
641
+ #: includes/qmn_options_option_tab.php:141
642
+ msgid "end date"
643
+ msgstr ""
644
+
645
+ #: includes/qmn_options_option_tab.php:145
646
+ msgid ""
647
+ "Are the questions random? (Question Order will not apply if this is yes)"
648
+ msgstr ""
649
+
650
+ #: includes/qmn_options_option_tab.php:147
651
+ msgid "Random Questions"
652
+ msgstr ""
653
+
654
+ #: includes/qmn_options_option_tab.php:148
655
+ msgid "Random Questions And Answers"
656
+ msgstr ""
657
+
658
+ #: includes/qmn_options_option_tab.php:153
659
+ msgid ""
660
+ "Would you like to ask for the contact information at the beginning or at the "
661
+ "end of the quiz?"
662
+ msgstr ""
663
+
664
+ #: includes/qmn_options_option_tab.php:155
665
+ msgid "Beginning"
666
+ msgstr ""
667
+
668
+ #: includes/qmn_options_option_tab.php:156
669
+ msgid "End"
670
+ msgstr ""
671
+
672
+ #: includes/qmn_options_option_tab.php:160
673
+ msgid ""
674
+ "If a logged-in user takes the quiz, would you like them to be able to edit "
675
+ "contact information? If set to no, the fields will not show up for logged in "
676
+ "users; however, the users information will be saved for the fields."
677
+ msgstr ""
678
+
679
+ #: includes/qmn_options_option_tab.php:167
680
+ msgid "Should we ask for users name?"
681
+ msgstr ""
682
+
683
+ #: includes/qmn_options_option_tab.php:170
684
+ #: includes/qmn_options_option_tab.php:178
685
+ #: includes/qmn_options_option_tab.php:186
686
+ #: includes/qmn_options_option_tab.php:194
687
+ msgid "Require"
688
+ msgstr ""
689
+
690
+ #: includes/qmn_options_option_tab.php:175
691
+ msgid "Should we ask for users business?"
692
+ msgstr ""
693
+
694
+ #: includes/qmn_options_option_tab.php:183
695
+ msgid "Should we ask for users email?"
696
+ msgstr ""
697
+
698
+ #: includes/qmn_options_option_tab.php:191
699
+ msgid "Should we ask for users phone number?"
700
+ msgstr ""
701
+
702
+ #: includes/qmn_options_option_tab.php:199
703
+ msgid "Would you like a place for the user to enter comments?"
704
+ msgstr ""
705
+
706
+ #: includes/qmn_options_option_tab.php:206
707
+ msgid "Show question number on quiz?"
708
+ msgstr ""
709
+
710
+ #: includes/qmn_options_option_tab.php:213
711
+ msgid "Show social media sharing buttons? (Twitter & Facebook)"
712
+ msgstr ""
713
+
714
+ #: includes/qmn_options_preview_tab.php:5
715
+ msgid "Preview"
716
+ msgstr ""
717
+
718
+ #: includes/qmn_options_questions_tab.php:5
719
+ msgid "Questions"
720
+ msgstr ""
721
+
722
+ #: includes/qmn_options_questions_tab.php:104
723
+ msgid "The question has been updated successfully."
724
+ msgstr ""
725
+
726
+ #: includes/qmn_options_questions_tab.php:131
727
+ msgid "The question has been deleted successfully."
728
+ msgstr ""
729
+
730
+ #: includes/qmn_options_questions_tab.php:215
731
+ msgid "The question has been duplicated successfully."
732
+ msgstr ""
733
+
734
+ #: includes/qmn_options_questions_tab.php:308
735
+ msgid "The question has been created successfully."
736
+ msgstr ""
737
+
738
+ #: includes/qmn_options_questions_tab.php:453
739
+ #: includes/qmn_options_questions_tab.php:460
740
+ #: includes/qmn_options_questions_tab.php:591
741
+ #: includes/qmn_options_questions_tab.php:757
742
+ msgid "Answer"
743
+ msgstr ""
744
+
745
+ #: includes/qmn_options_questions_tab.php:480
746
+ #: includes/qmn_options_questions_tab.php:727
747
+ msgid "Add Question"
748
+ msgstr ""
749
+
750
+ #: includes/qmn_options_questions_tab.php:484
751
+ #, php-format
752
+ msgid "One question"
753
+ msgid_plural "%s questions"
754
+ msgstr[0] ""
755
+ msgstr[1] ""
756
+
757
+ #: includes/qmn_options_questions_tab.php:556 includes/qmn_quiz_admin.php:239
758
+ msgid "Edit"
759
+ msgstr ""
760
+
761
+ #: includes/qmn_options_questions_tab.php:556 includes/qmn_quiz_admin.php:241
762
+ #: includes/qmn_quiz_admin.php:350
763
+ msgid "Duplicate"
764
+ msgstr ""
765
+
766
+ #: includes/qmn_options_questions_tab.php:556
767
+ #: includes/qmn_options_results_page_tab.php:227
768
+ #: includes/qmn_quiz_admin.php:242
769
+ msgid "Delete"
770
+ msgstr ""
771
+
772
+ #: includes/qmn_options_questions_tab.php:569
773
+ #: includes/qmn_options_questions_tab.php:712
774
+ #: includes/qmn_options_questions_tab.php:723
775
+ #: includes/qmn_options_questions_tab.php:737
776
+ msgid "Question"
777
+ msgstr ""
778
+
779
+ #: includes/qmn_options_questions_tab.php:580
780
+ #: includes/qmn_options_questions_tab.php:748
781
+ msgid "Answers"
782
+ msgstr ""
783
+
784
+ #: includes/qmn_options_questions_tab.php:581
785
+ #: includes/qmn_options_questions_tab.php:749
786
+ msgid "Points Worth"
787
+ msgstr ""
788
+
789
+ #: includes/qmn_options_questions_tab.php:582
790
+ #: includes/qmn_options_questions_tab.php:750
791
+ msgid "Correct Answer"
792
+ msgstr ""
793
+
794
+ #: includes/qmn_options_questions_tab.php:609
795
+ #: includes/qmn_options_questions_tab.php:772
796
+ msgid "Add New Answer!"
797
+ msgstr ""
798
+
799
+ #: includes/qmn_options_questions_tab.php:614
800
+ #: includes/qmn_options_questions_tab.php:777
801
+ msgid "Correct Answer Info"
802
+ msgstr ""
803
+
804
+ #: includes/qmn_options_questions_tab.php:621
805
+ #: includes/qmn_options_questions_tab.php:784 includes/qmn_quiz.php:320
806
+ msgid "Hint"
807
+ msgstr ""
808
+
809
+ #: includes/qmn_options_questions_tab.php:632
810
+ #: includes/qmn_options_questions_tab.php:710
811
+ #: includes/qmn_options_questions_tab.php:721
812
+ #: includes/qmn_options_questions_tab.php:795
813
+ msgid "Question Type"
814
+ msgstr ""
815
+
816
+ #: includes/qmn_options_questions_tab.php:650
817
+ #: includes/qmn_options_questions_tab.php:808
818
+ msgid "Comment Field"
819
+ msgstr ""
820
+
821
+ #: includes/qmn_options_questions_tab.php:653
822
+ #: includes/qmn_options_questions_tab.php:810
823
+ msgid "Small Text Field"
824
+ msgstr ""
825
+
826
+ #: includes/qmn_options_questions_tab.php:655
827
+ #: includes/qmn_options_questions_tab.php:811
828
+ msgid "Large Text Field"
829
+ msgstr ""
830
+
831
+ #: includes/qmn_options_questions_tab.php:657
832
+ #: includes/qmn_options_questions_tab.php:812
833
+ msgid "None"
834
+ msgstr ""
835
+
836
+ #: includes/qmn_options_questions_tab.php:661
837
+ #: includes/qmn_options_questions_tab.php:709
838
+ #: includes/qmn_options_questions_tab.php:720
839
+ #: includes/qmn_options_questions_tab.php:816
840
+ msgid "Question Order"
841
+ msgstr ""
842
+
843
+ #: includes/qmn_options_questions_tab.php:669
844
+ #: includes/qmn_options_questions_tab.php:824
845
+ msgid "Required?"
846
+ msgstr ""
847
+
848
+ #: includes/qmn_options_questions_tab.php:678
849
+ #: includes/qmn_options_questions_tab.php:711
850
+ #: includes/qmn_options_questions_tab.php:722
851
+ #: includes/qmn_options_questions_tab.php:833
852
+ msgid "Category"
853
+ msgstr ""
854
+
855
+ #: includes/qmn_options_questions_tab.php:697
856
+ #: includes/qmn_options_questions_tab.php:852
857
+ msgid ""
858
+ "Required currently only works on open answer, number, accept, and captcha "
859
+ "question types"
860
+ msgstr ""
861
+
862
+ #: includes/qmn_options_questions_tab.php:699
863
+ msgid "Edit Question"
864
+ msgstr ""
865
+
866
+ #: includes/qmn_options_questions_tab.php:854
867
+ msgid "Create Question"
868
+ msgstr ""
869
+
870
+ #: includes/qmn_options_questions_tab.php:859
871
+ msgid "Are you sure you want to delete this question?"
872
+ msgstr ""
873
+
874
+ #: includes/qmn_options_questions_tab.php:864
875
+ msgid "Delete Question"
876
+ msgstr ""
877
+
878
+ #: includes/qmn_options_questions_tab.php:869
879
+ msgid "Are you sure you want to duplicate this question?"
880
+ msgstr ""
881
+
882
+ #: includes/qmn_options_questions_tab.php:874
883
+ msgid "Duplicate Question"
884
+ msgstr ""
885
+
886
+ #: includes/qmn_options_results_page_tab.php:5
887
+ msgid "Results Pages"
888
+ msgstr ""
889
+
890
+ #: includes/qmn_options_results_page_tab.php:40
891
+ msgid "The results page has been added successfully."
892
+ msgstr ""
893
+
894
+ #: includes/qmn_options_results_page_tab.php:80
895
+ msgid "The results page has been saved successfully."
896
+ msgstr ""
897
+
898
+ #: includes/qmn_options_results_page_tab.php:183
899
+ #: includes/qmn_options_results_page_tab.php:256
900
+ msgid "Save Results Pages"
901
+ msgstr ""
902
+
903
+ #: includes/qmn_options_results_page_tab.php:184
904
+ #: includes/qmn_options_results_page_tab.php:261
905
+ msgid "Add New Results Page"
906
+ msgstr ""
907
+
908
+ #: includes/qmn_options_results_page_tab.php:192
909
+ #: includes/qmn_options_results_page_tab.php:249
910
+ msgid "Results Page Shown"
911
+ msgstr ""
912
+
913
+ #: includes/qmn_options_results_page_tab.php:227
914
+ msgid "Are you sure?"
915
+ msgstr ""
916
+
917
+ #: includes/qmn_options_style_tab.php:5
918
+ msgid "Style"
919
+ msgstr ""
920
+
921
+ #: includes/qmn_options_style_tab.php:25
922
+ msgid "The style has been saved successfully."
923
+ msgstr ""
924
+
925
+ #: includes/qmn_options_style_tab.php:64
926
+ msgid "Quiz Styles"
927
+ msgstr ""
928
+
929
+ #: includes/qmn_options_style_tab.php:65
930
+ msgid "Choose your style:"
931
+ msgstr ""
932
+
933
+ #: includes/qmn_options_style_tab.php:87
934
+ msgid "Custom"
935
+ msgstr ""
936
+
937
+ #: includes/qmn_options_style_tab.php:93
938
+ #: includes/qmn_options_style_tab.php:150
939
+ msgid "Save Quiz Style"
940
+ msgstr ""
941
+
942
+ #: includes/qmn_options_style_tab.php:95
943
+ msgid "Custom Style CSS"
944
+ msgstr ""
945
+
946
+ #: includes/qmn_options_style_tab.php:96
947
+ msgid ""
948
+ "For detailed help and guidance along with a list of different classes used "
949
+ "in this plugin, please visit the following link:"
950
+ msgstr ""
951
+
952
+ #: includes/qmn_options_style_tab.php:105
953
+ msgid "Default:"
954
+ msgstr ""
955
+
956
+ #: includes/qmn_options_text_tab.php:5
957
+ msgid "Text"
958
+ msgstr ""
959
+
960
+ #: includes/qmn_options_text_tab.php:41
961
+ msgid "The templates has been updated successfully."
962
+ msgstr ""
963
+
964
+ #: includes/qmn_options_text_tab.php:72 includes/qmn_quiz.php:1110
965
+ msgid "Previous"
966
+ msgstr ""
967
+
968
+ #: includes/qmn_options_text_tab.php:93
969
+ msgid "Total points user earned when taking quiz"
970
+ msgstr ""
971
+
972
+ #: includes/qmn_options_text_tab.php:103
973
+ msgid ""
974
+ "The percent score for the quiz showing percent of total quetions answered "
975
+ "correctly"
976
+ msgstr ""
977
+
978
+ #: includes/qmn_options_text_tab.php:123
979
+ msgid "The question that the user answered"
980
+ msgstr ""
981
+
982
+ #: includes/qmn_options_text_tab.php:127
983
+ msgid "The answer the user gave for the question"
984
+ msgstr ""
985
+
986
+ #: includes/qmn_options_text_tab.php:128
987
+ msgid "The correct answer for the question"
988
+ msgstr ""
989
+
990
+ #: includes/qmn_options_text_tab.php:132
991
+ msgid "The comments the user provided in the comment field for the question"
992
+ msgstr ""
993
+
994
+ #: includes/qmn_options_text_tab.php:133
995
+ msgid "Reason why the correct answer is the correct answer"
996
+ msgstr ""
997
+
998
+ #: includes/qmn_options_text_tab.php:140
999
+ msgid "The Current Date"
1000
+ msgstr ""
1001
+
1002
+ #: includes/qmn_options_text_tab.php:143 includes/qmn_options_text_tab.php:307
1003
+ msgid "Save Templates"
1004
+ msgstr ""
1005
+
1006
+ #: includes/qmn_options_text_tab.php:149
1007
+ msgid "Message Templates"
1008
+ msgstr ""
1009
+
1010
+ #: includes/qmn_options_text_tab.php:153
1011
+ msgid "Message Displayed Before Quiz"
1012
+ msgstr ""
1013
+
1014
+ #: includes/qmn_options_text_tab.php:163
1015
+ msgid "Message Displayed Before Comments Box If Enabled"
1016
+ msgstr ""
1017
+
1018
+ #: includes/qmn_options_text_tab.php:173
1019
+ msgid "Message Displayed At End Of Quiz (Leave Blank To Omit Text Section)"
1020
+ msgstr ""
1021
+
1022
+ #: includes/qmn_options_text_tab.php:183
1023
+ msgid "Message Displayed If User Has Tried Quiz Too Many Times"
1024
+ msgstr ""
1025
+
1026
+ #: includes/qmn_options_text_tab.php:193
1027
+ msgid ""
1028
+ "Message Displayed If User Is Not Logged In And Quiz Requires Users To Be "
1029
+ "Logged In"
1030
+ msgstr ""
1031
+
1032
+ #: includes/qmn_options_text_tab.php:203
1033
+ msgid "Message Displayed If Date Is Outside Scheduled Timeframe"
1034
+ msgstr ""
1035
+
1036
+ #: includes/qmn_options_text_tab.php:213
1037
+ msgid "Message Displayed If The Limit Of Total Entries Has Been Reached"
1038
+ msgstr ""
1039
+
1040
+ #: includes/qmn_options_text_tab.php:223
1041
+ msgid "%QUESTIONS_ANSWERS% Text"
1042
+ msgstr ""
1043
+
1044
+ #: includes/qmn_options_text_tab.php:236
1045
+ msgid "Twitter Sharing Text"
1046
+ msgstr ""
1047
+
1048
+ #: includes/qmn_options_text_tab.php:253
1049
+ msgid "Facebook Sharing Text"
1050
+ msgstr ""
1051
+
1052
+ #: includes/qmn_options_text_tab.php:268
1053
+ msgid "Other Templates"
1054
+ msgstr ""
1055
+
1056
+ #: includes/qmn_options_text_tab.php:271
1057
+ msgid "Text for submit button"
1058
+ msgstr ""
1059
+
1060
+ #: includes/qmn_options_text_tab.php:275
1061
+ msgid "Text for name field"
1062
+ msgstr ""
1063
+
1064
+ #: includes/qmn_options_text_tab.php:279
1065
+ msgid "Text for business field"
1066
+ msgstr ""
1067
+
1068
+ #: includes/qmn_options_text_tab.php:283
1069
+ msgid "Text for email field"
1070
+ msgstr ""
1071
+
1072
+ #: includes/qmn_options_text_tab.php:287
1073
+ msgid "Text for phone number field"
1074
+ msgstr ""
1075
+
1076
+ #: includes/qmn_options_text_tab.php:291
1077
+ msgid "Text for comments field"
1078
+ msgstr ""
1079
+
1080
+ #: includes/qmn_options_text_tab.php:295
1081
+ msgid "Text for previous button"
1082
+ msgstr ""
1083
+
1084
+ #: includes/qmn_options_text_tab.php:299
1085
+ msgid "Text for next button"
1086
+ msgstr ""
1087
+
1088
+ #: includes/qmn_options_text_tab.php:303
1089
+ msgid "What is the From Name for the email sent to users and admin?"
1090
+ msgstr ""
1091
+
1092
+ #: includes/qmn_options_tools_tab.php:5 includes/qmn_tools.php:51
1093
+ #: mlw_quizmaster2.php:161
1094
+ msgid "Tools"
1095
+ msgstr ""
1096
+
1097
+ #: includes/qmn_options_tools_tab.php:22
1098
+ msgid "The stats has been reset successfully."
1099
+ msgstr ""
1100
+
1101
+ #: includes/qmn_options_tools_tab.php:74
1102
+ msgid ""
1103
+ "Use this button to reset all the stats collected for this quiz (Quiz Views "
1104
+ "and Times Quiz Has Been Taken)."
1105
+ msgstr ""
1106
+
1107
+ #: includes/qmn_options_tools_tab.php:75
1108
+ msgid "Reset Quiz Views And Taken Stats"
1109
+ msgstr ""
1110
+
1111
+ #: includes/qmn_options_tools_tab.php:86
1112
+ msgid ""
1113
+ "Are you sure you want to reset the stats to 0? All views and taken stats for "
1114
+ "this quiz will be reset. This is permanent and cannot be undone."
1115
+ msgstr ""
1116
+
1117
+ #: includes/qmn_options_tools_tab.php:90
1118
+ msgid "Reset All Stats For Quiz"
1119
+ msgstr ""
1120
+
1121
+ #: includes/qmn_question_types.php:7
1122
+ msgid "Multiple Choice"
1123
+ msgstr ""
1124
+
1125
+ #: includes/qmn_question_types.php:75
1126
+ msgid "Horizontal Multiple Choice"
1127
+ msgstr ""
1128
+
1129
+ #: includes/qmn_question_types.php:143
1130
+ msgid "Drop Down"
1131
+ msgstr ""
1132
+
1133
+ #: includes/qmn_question_types.php:208
1134
+ msgid "Small Open Answer"
1135
+ msgstr ""
1136
+
1137
+ #: includes/qmn_question_types.php:257
1138
+ msgid "Multiple Response"
1139
+ msgstr ""
1140
+
1141
+ #: includes/qmn_question_types.php:332
1142
+ msgid "Large Open Answer"
1143
+ msgstr ""
1144
+
1145
+ #: includes/qmn_question_types.php:381
1146
+ msgid "Text Block"
1147
+ msgstr ""
1148
+
1149
+ #: includes/qmn_question_types.php:396
1150
+ msgid "Number"
1151
+ msgstr ""
1152
+
1153
+ #: includes/qmn_question_types.php:445
1154
+ msgid "Accept"
1155
+ msgstr ""
1156
+
1157
+ #: includes/qmn_question_types.php:464
1158
+ msgid "Captcha"
1159
+ msgstr ""
1160
+
1161
+ #: includes/qmn_question_types.php:505
1162
+ msgid "Horizontal Multiple Response"
1163
+ msgstr ""
1164
+
1165
+ #: includes/qmn_quiz.php:206
1166
+ msgid "Not a valid e-mail address!"
1167
+ msgstr ""
1168
+
1169
+ #: includes/qmn_quiz.php:207
1170
+ msgid "This field must be a number!"
1171
+ msgstr ""
1172
+
1173
+ #: includes/qmn_quiz.php:208
1174
+ msgid "The entered text is not correct!"
1175
+ msgstr ""
1176
+
1177
+ #: includes/qmn_quiz.php:209
1178
+ msgid "Please complete all required fields!"
1179
+ msgstr ""
1180
+
1181
+ #: includes/qmn_quiz.php:1056
1182
+ msgid "It appears that this quiz is not set up correctly."
1183
+ msgstr ""
1184
+
1185
+ #: includes/qmn_quiz_admin.php:169 mlw_quizmaster2.php:156
1186
+ msgid "Quizzes"
1187
+ msgstr ""
1188
+
1189
+ #: includes/qmn_quiz_admin.php:169
1190
+ msgid "Add New"
1191
+ msgstr ""
1192
+
1193
+ #: includes/qmn_quiz_admin.php:174
1194
+ #, php-format
1195
+ msgid "One quiz"
1196
+ msgid_plural "%s quizzes"
1197
+ msgstr[0] ""
1198
+ msgstr[1] ""
1199
+
1200
+ #: includes/qmn_quiz_admin.php:219 includes/qmn_quiz_admin.php:256
1201
+ #: includes/qmn_quiz_admin.php:317 includes/qmn_results.php:148
1202
+ msgid "Quiz Name"
1203
+ msgstr ""
1204
+
1205
+ #: includes/qmn_quiz_admin.php:220 includes/qmn_quiz_admin.php:257
1206
+ msgid "Quiz Shortcode"
1207
+ msgstr ""
1208
+
1209
+ #: includes/qmn_quiz_admin.php:221 includes/qmn_quiz_admin.php:258
1210
+ msgid "Leaderboard Shortcode"
1211
+ msgstr ""
1212
+
1213
+ #: includes/qmn_quiz_admin.php:222 includes/qmn_quiz_admin.php:259
1214
+ msgid "Quiz Views"
1215
+ msgstr ""
1216
+
1217
+ #: includes/qmn_quiz_admin.php:223 includes/qmn_quiz_admin.php:260
1218
+ msgid "Quiz Taken"
1219
+ msgstr ""
1220
+
1221
+ #: includes/qmn_quiz_admin.php:224 includes/qmn_quiz_admin.php:261
1222
+ msgid "Last Modified"
1223
+ msgstr ""
1224
+
1225
+ #: includes/qmn_quiz_admin.php:237
1226
+ msgid "Edit Name"
1227
+ msgstr ""
1228
+
1229
+ #: includes/qmn_quiz_admin.php:240
1230
+ msgid "Results"
1231
+ msgstr ""
1232
+
1233
+ #: includes/qmn_quiz_admin.php:312
1234
+ msgid "Create New Quiz"
1235
+ msgstr ""
1236
+
1237
+ #: includes/qmn_quiz_admin.php:326
1238
+ msgid "Create Quiz"
1239
+ msgstr ""
1240
+
1241
+ #: includes/qmn_quiz_admin.php:332
1242
+ msgid "Quiz Name:"
1243
+ msgstr ""
1244
+
1245
+ #: includes/qmn_quiz_admin.php:343
1246
+ msgid "Duplicate this quiz?"
1247
+ msgstr ""
1248
+
1249
+ #: includes/qmn_quiz_admin.php:345
1250
+ msgid "Duplicate questions with quiz"
1251
+ msgstr ""
1252
+
1253
+ #: includes/qmn_quiz_admin.php:347
1254
+ msgid "Name Of New Quiz:"
1255
+ msgstr ""
1256
+
1257
+ #: includes/qmn_quiz_admin.php:356
1258
+ msgid "Are you sure you want to delete this quiz?"
1259
+ msgstr ""
1260
+
1261
+ #: includes/qmn_quiz_admin.php:361
1262
+ msgid "Delete Quiz"
1263
+ msgstr ""
1264
+
1265
+ #: includes/qmn_quiz_creator.php:335
1266
+ msgid ""
1267
+ "Your new quiz has been created successfully. To begin editing your quiz, "
1268
+ "click the Edit link on the new quiz."
1269
+ msgstr ""
1270
+
1271
+ #: includes/qmn_quiz_creator.php:387
1272
+ msgid "Your quiz has been deleted successfully."
1273
+ msgstr ""
1274
+
1275
+ #: includes/qmn_quiz_creator.php:429
1276
+ msgid "Your quiz name has been updated successfully."
1277
+ msgstr ""
1278
+
1279
+ #: includes/qmn_quiz_creator.php:575
1280
+ msgid "Your quiz has been duplicated successfully."
1281
+ msgstr ""
1282
+
1283
+ #. translators: The %s corresponds to the name of the quiz
1284
+ #: includes/qmn_quiz_options.php:51
1285
+ #, php-format
1286
+ msgid "Quiz Settings For %s"
1287
+ msgstr ""
1288
+
1289
+ #: includes/qmn_quiz_options.php:91
1290
+ msgid ""
1291
+ "Please go to the quizzes page and click on the Edit link from the quiz you "
1292
+ "wish to edit."
1293
+ msgstr ""
1294
+
1295
+ #: includes/qmn_results.php:19
1296
+ msgid "Your results has been deleted successfully."
1297
+ msgstr ""
1298
+
1299
+ #: includes/qmn_results.php:118 includes/qmn_results_details.php:127
1300
+ #: includes/qmn_results_details.php:130 includes/qmn_results_details.php:134
1301
+ #: includes/qmn_results_details.php:298 mlw_quizmaster2.php:158
1302
+ msgid "Quiz Results"
1303
+ msgstr ""
1304
+
1305
+ #: includes/qmn_results.php:125 includes/qmn_results.php:141
1306
+ #, php-format
1307
+ msgid "Previous %s Results"
1308
+ msgstr ""
1309
+
1310
+ #: includes/qmn_results.php:128 includes/qmn_results.php:135
1311
+ #, php-format
1312
+ msgid "Next %s Results"
1313
+ msgstr ""
1314
+
1315
+ #: includes/qmn_results.php:147
1316
+ msgid "Actions"
1317
+ msgstr ""
1318
+
1319
+ #: includes/qmn_results.php:149
1320
+ msgid "Score"
1321
+ msgstr ""
1322
+
1323
+ #: includes/qmn_results.php:150
1324
+ msgid "Time To Complete"
1325
+ msgstr ""
1326
+
1327
+ #: includes/qmn_results.php:151
1328
+ msgid "Name"
1329
+ msgstr ""
1330
+
1331
+ #: includes/qmn_results.php:152
1332
+ msgid "Business"
1333
+ msgstr ""
1334
+
1335
+ #: includes/qmn_results.php:153
1336
+ msgid "Email"
1337
+ msgstr ""
1338
+
1339
+ #: includes/qmn_results.php:154
1340
+ msgid "Phone"
1341
+ msgstr ""
1342
+
1343
+ #: includes/qmn_results.php:155 includes/qmn_results_details.php:137
1344
+ msgid "Time Taken"
1345
+ msgstr ""
1346
+
1347
+ #: includes/qmn_results.php:214
1348
+ msgid "Are you sure you want to delete these results?"
1349
+ msgstr ""
1350
+
1351
+ #: includes/qmn_results.php:219
1352
+ msgid "Delete Results"
1353
+ msgstr ""
1354
+
1355
+ #: includes/qmn_results_details.php:131
1356
+ msgid "Quiz Tools"
1357
+ msgstr ""
1358
+
1359
+ #: includes/qmn_results_details.php:141
1360
+ msgid "Name Provided"
1361
+ msgstr ""
1362
+
1363
+ #: includes/qmn_results_details.php:145
1364
+ msgid "Business Provided"
1365
+ msgstr ""
1366
+
1367
+ #: includes/qmn_results_details.php:149
1368
+ msgid "Email Provided"
1369
+ msgstr ""
1370
+
1371
+ #: includes/qmn_results_details.php:153
1372
+ msgid "Phone Provided"
1373
+ msgstr ""
1374
+
1375
+ #: includes/qmn_results_details.php:164 includes/qmn_results_details.php:171
1376
+ msgid "Score Received"
1377
+ msgstr ""
1378
+
1379
+ #: includes/qmn_results_details.php:180
1380
+ msgid "Answers Provided"
1381
+ msgstr ""
1382
+
1383
+ #: includes/qmn_results_details.php:192
1384
+ msgid "hours"
1385
+ msgstr ""
1386
+
1387
+ #: includes/qmn_results_details.php:197
1388
+ msgid "minutes"
1389
+ msgstr ""
1390
+
1391
+ #: includes/qmn_results_details.php:200
1392
+ msgid "seconds"
1393
+ msgstr ""
1394
+
1395
+ #. translators: The %s will be replaces with the amount of time the user took on quiz. For example: 5 minutes 34 seconds
1396
+ #: includes/qmn_results_details.php:204
1397
+ #, php-format
1398
+ msgid "The user took %s to complete this quiz."
1399
+ msgstr ""
1400
+
1401
+ #: includes/qmn_results_details.php:207
1402
+ msgid "The comments entered into the comment box (if enabled)"
1403
+ msgstr ""
1404
+
1405
+ #: includes/qmn_results_details.php:210
1406
+ msgid "The answers were as follows"
1407
+ msgstr ""
1408
+
1409
+ #: includes/qmn_results_details.php:217
1410
+ msgid "Answer Provided: "
1411
+ msgstr ""
1412
+
1413
+ #: includes/qmn_results_details.php:218
1414
+ msgid "Correct Answer: "
1415
+ msgstr ""
1416
+
1417
+ #: includes/qmn_results_details.php:219
1418
+ msgid "Comments Entered:"
1419
+ msgstr ""
1420
+
1421
+ #: includes/qmn_results_details.php:230
1422
+ msgid "Create Certificate"
1423
+ msgstr ""
1424
+
1425
+ #: includes/qmn_results_details.php:235
1426
+ msgid "Download Certificate Here"
1427
+ msgstr ""
1428
+
1429
+ #: includes/qmn_results_details.php:301
1430
+ msgid ""
1431
+ "Please go to the Quiz Results page and click on the View link from the "
1432
+ "result you wish to see."
1433
+ msgstr ""
1434
+
1435
+ #: includes/qmn_tools.php:90 includes/qmn_tools.php:106
1436
+ #, php-format
1437
+ msgid "Previous %s Audits"
1438
+ msgstr ""
1439
+
1440
+ #: includes/qmn_tools.php:93 includes/qmn_tools.php:100
1441
+ #, php-format
1442
+ msgid "Next %s Audits"
1443
+ msgstr ""
1444
+
1445
+ #: includes/qmn_tools.php:113
1446
+ msgid "User"
1447
+ msgstr ""
1448
+
1449
+ #: includes/qmn_tools.php:114
1450
+ msgid "Action"
1451
+ msgstr ""
1452
+
1453
+ #: includes/qmn_tools.php:115
1454
+ msgid "Time"
1455
+ msgstr ""
1456
+
1457
+ #: includes/qmn_widgets.php:10
1458
+ msgid "Quiz Master Next Leaderboard Widget"
1459
+ msgstr ""
1460
+
1461
+ #: includes/qmn_widgets.php:25
1462
+ msgid "Widget Title"
1463
+ msgstr ""
1464
+
1465
+ #: includes/qmn_widgets.php:29
1466
+ msgid "Quiz ID"
1467
+ msgstr ""
1468
+
1469
+ #: mlw_quizmaster2.php:157
1470
+ msgid "Quiz Settings"
1471
+ msgstr ""
1472
+
1473
+ #: mlw_quizmaster2.php:159
1474
+ msgid "Quiz Result Details"
1475
+ msgstr ""
1476
+
1477
+ #: mlw_quizmaster2.php:160
1478
+ msgid "Stats"
1479
+ msgstr ""
1480
+
1481
+ #: mlw_quizmaster2.php:162
1482
+ msgid "Help"
1483
+ msgstr ""
1484
+
1485
+ #: mlw_quizmaster2.php:163
1486
+ msgid "Addon Settings"
1487
+ msgstr ""
1488
+
1489
+ #: mlw_quizmaster2.php:166 mlw_quizmaster2.php:167
1490
+ msgid "QMN About"
1491
+ msgstr ""
mlw_quizmaster2.php CHANGED
@@ -1,23 +1,22 @@
1
  <?php
2
-
3
- /*
4
- Plugin Name: Quiz Master Next
5
- Description: Use this plugin to add multiple quizzes, tests, or surveys to your website.
6
- Version: 3.9.0
7
- Author: Frank Corso
8
- Author URI: http://www.mylocalwebstop.com/
9
- Plugin URI: http://www.mylocalwebstop.com/
10
- */
11
-
12
- /*
13
- Copyright 2014, My Local Webstop (email : fpcorso@mylocalwebstop.com)
14
-
15
- Disclaimer of Warranties.
16
-
17
- The plugin is provided "as is". My Local Webstop and its suppliers and licensors hereby disclaim all warranties of any kind,
18
- express or implied, including, without limitation, the warranties of merchantability, fitness for a particular purpose and non-infringement.
19
- Neither My Local Webstop nor its suppliers and licensors, makes any warranty that the plugin will be error free or that access thereto will be continuous or uninterrupted.
20
- You understand that you install, operate, and unistall the plugin at your own discretion and risk.
21
  */
22
 
23
  /**
@@ -29,6 +28,14 @@ You understand that you install, operate, and unistall the plugin at your own di
29
  */
30
  class MLWQuizMasterNext
31
  {
 
 
 
 
 
 
 
 
32
  /**
33
  * QMN Alert Manager Object
34
  *
@@ -36,7 +43,15 @@ class MLWQuizMasterNext
36
  * @since 3.7.1
37
  */
38
  public $alertManager;
39
-
 
 
 
 
 
 
 
 
40
  /**
41
  * QMN Quiz Creator Object
42
  *
@@ -44,7 +59,7 @@ class MLWQuizMasterNext
44
  * @since 3.7.1
45
  */
46
  public $quizCreator;
47
-
48
  /**
49
  * Main Construct Function
50
  *
@@ -55,12 +70,12 @@ class MLWQuizMasterNext
55
  * @uses MLWQuizMasterNext::add_hooks() Adds actions to hooks and filters
56
  * @return void
57
  */
58
- public function __construct()
59
  {
60
  $this->load_dependencies();
61
  $this->add_hooks();
62
  }
63
-
64
  /**
65
  * Load File Dependencies
66
  *
@@ -69,33 +84,48 @@ class MLWQuizMasterNext
69
  */
70
  private function load_dependencies()
71
  {
72
- include("includes/mlw_quiz.php");
73
- include("includes/mlw_dashboard.php");
74
- include("includes/mlw_quiz_admin.php");
75
- include("includes/mlw_quiz_options.php");
76
- include("includes/mlw_quiz_install.php");
77
- include("includes/mlw_results.php");
78
- include("includes/mlw_results_details.php");
79
- include("includes/mlw_tools.php");
80
- include("includes/mlw_leaderboard.php");
81
- include("includes/mlw_update.php");
82
- include("includes/mlw_qmn_widgets.php");
83
- include("includes/mlw_qmn_credits.php");
84
- include("includes/mlw_template_variables.php");
85
- include("includes/mlw_adverts.php");
86
- include("includes/mlw_help.php");
87
  include("includes/qmn_dashboard_widgets.php");
88
-
89
- include("includes/mlw_alerts.php");
 
 
 
 
 
 
 
 
 
 
 
 
90
  $this->alertManager = new MlwQmnAlertManager();
91
-
92
- include("includes/mlw_quiz_creator.php");
93
  $this->quizCreator = new QMNQuizCreator();
 
 
 
94
  }
95
-
96
  /**
97
  * Add Hooks
98
- *
99
  * Adds functions to relavent hooks and filters
100
  *
101
  * @since 3.6.1
@@ -104,16 +134,16 @@ class MLWQuizMasterNext
104
  private function add_hooks()
105
  {
106
  add_action('admin_menu', array( $this, 'setup_admin_menu'));
 
107
  add_action('admin_init', 'mlw_quiz_update');
108
  add_action('widgets_init', create_function('', 'return register_widget("Mlw_Qmn_Leaderboard_Widget");'));
109
- add_shortcode('mlw_quizmaster', 'mlw_quiz_shortcode');
110
  add_shortcode('mlw_quizmaster_leaderboard', 'mlw_quiz_leaderboard_shortcode');
111
  add_action('plugins_loaded', array( $this, 'setup_translations'));
112
  }
113
-
114
  /**
115
  * Setup Admin Menu
116
- *
117
  * Creates the admin menu and pages for the plugin and attaches functions to them
118
  *
119
  * @since 3.6.1
@@ -123,17 +153,30 @@ class MLWQuizMasterNext
123
  {
124
  if (function_exists('add_menu_page'))
125
  {
126
- add_menu_page('Quiz Master Next', 'Quizzes', 'moderate_comments', __FILE__, 'mlw_generate_quiz_admin', 'dashicons-feedback');
127
- add_submenu_page(__FILE__, 'Quiz Settings', 'Quiz Settings', 'moderate_comments', 'mlw_quiz_options', 'mlw_generate_quiz_options');
128
- add_submenu_page(__FILE__, 'Quiz Results', 'Quiz Results', 'moderate_comments', 'mlw_quiz_results', 'mlw_generate_quiz_results');
129
- add_submenu_page(__FILE__, 'Quiz Result Details', 'Quiz Result Details', 'moderate_comments', 'mlw_quiz_result_details', 'mlw_generate_result_details');
130
- add_submenu_page(__FILE__, 'QMN Stats', 'QMN Stats', 'moderate_comments', 'mlw_quiz_stats', 'mlw_generate_quiz_dashboard');
131
- add_submenu_page(__FILE__, 'QMN Tools', 'QMN Tools', 'manage_options', 'mlw_quiz_tools', 'mlw_generate_quiz_tools');
132
- add_submenu_page(__FILE__, 'QMN Help', 'QMN Help', 'moderate_comments', 'mlw_quiz_help', 'mlw_generate_help_page');
133
- add_submenu_page(__FILE__, 'QMN About', 'QMN About', 'manage_options', 'mlw_qmn_about', 'mlw_generate_about_page');
 
 
 
 
 
 
 
 
134
  }
135
  }
136
-
 
 
 
 
 
137
  /**
138
  * Loads the plugin language files
139
  *
@@ -142,7 +185,7 @@ class MLWQuizMasterNext
142
  */
143
  public function setup_translations()
144
  {
145
- load_plugin_textdomain( 'mlw_qmn_text_domain', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
146
  }
147
  }
148
 
1
  <?php
2
+ /**
3
+ * Plugin Name: Quiz Master Next
4
+ * Description: Use this plugin to add multiple quizzes, tests, or surveys to your website.
5
+ * Version: 4.0.0
6
+ * Author: Frank Corso
7
+ * Author URI: http://www.mylocalwebstop.com/
8
+ * Plugin URI: http://www.mylocalwebstop.com/
9
+ * Text Domain: quiz-master-next
10
+ * Domain Path: /languages
11
+ *
12
+ * Disclaimer of Warranties
13
+ * The plugin is provided "as is". My Local Webstop and its suppliers and licensors hereby disclaim all warranties of any kind,
14
+ * express or implied, including, without limitation, the warranties of merchantability, fitness for a particular purpose and non-infringement.
15
+ * Neither My Local Webstop nor its suppliers and licensors, makes any warranty that the plugin will be error free or that access thereto will be continuous or uninterrupted.
16
+ * You understand that you install, operate, and unistall the plugin at your own discretion and risk.
17
+ *
18
+ * @author Frank Corso
19
+ * @version 4.0.0
 
20
  */
21
 
22
  /**
28
  */
29
  class MLWQuizMasterNext
30
  {
31
+ /**
32
+ * QMN Version Number
33
+ *
34
+ * @var string
35
+ * @since 4.0.0
36
+ */
37
+ public $version = '4.0.0';
38
+
39
  /**
40
  * QMN Alert Manager Object
41
  *
43
  * @since 3.7.1
44
  */
45
  public $alertManager;
46
+
47
+ /**
48
+ * QMN Plugin Helper Object
49
+ *
50
+ * @var object
51
+ * @since 4.0.0
52
+ */
53
+ public $pluginHelper;
54
+
55
  /**
56
  * QMN Quiz Creator Object
57
  *
59
  * @since 3.7.1
60
  */
61
  public $quizCreator;
62
+
63
  /**
64
  * Main Construct Function
65
  *
70
  * @uses MLWQuizMasterNext::add_hooks() Adds actions to hooks and filters
71
  * @return void
72
  */
73
+ public function __construct()
74
  {
75
  $this->load_dependencies();
76
  $this->add_hooks();
77
  }
78
+
79
  /**
80
  * Load File Dependencies
81
  *
84
  */
85
  private function load_dependencies()
86
  {
87
+ include("includes/qmn_quiz.php");
88
+ include("includes/qmn_dashboard.php");
89
+ include("includes/qmn_quiz_admin.php");
90
+ include("includes/qmn_quiz_options.php");
91
+ include("includes/qmn_quiz_install.php");
92
+ include("includes/qmn_results.php");
93
+ include("includes/qmn_results_details.php");
94
+ include("includes/qmn_tools.php");
95
+ include("includes/qmn_leaderboard.php");
96
+ include("includes/qmn_update.php");
97
+ include("includes/qmn_widgets.php");
98
+ include("includes/qmn_credits.php");
99
+ include("includes/qmn_template_variables.php");
100
+ include("includes/qmn_adverts.php");
101
+ include("includes/qmn_help.php");
102
  include("includes/qmn_dashboard_widgets.php");
103
+ include("includes/qmn_options_questions_tab.php");
104
+ include("includes/qmn_options_text_tab.php");
105
+ include("includes/qmn_options_option_tab.php");
106
+ include("includes/qmn_options_leaderboard_tab.php");
107
+ include("includes/qmn_options_certificate_tab.php");
108
+ include("includes/qmn_options_email_tab.php");
109
+ include("includes/qmn_options_results_page_tab.php");
110
+ include("includes/qmn_options_style_tab.php");
111
+ include("includes/qmn_options_tools_tab.php");
112
+ include("includes/qmn_options_preview_tab.php");
113
+ include("includes/qmn_addons.php");
114
+ include("includes/qmn_question_types.php");
115
+
116
+ include("includes/qmn_alerts.php");
117
  $this->alertManager = new MlwQmnAlertManager();
118
+
119
+ include("includes/qmn_quiz_creator.php");
120
  $this->quizCreator = new QMNQuizCreator();
121
+
122
+ include("includes/qmn_helper.php");
123
+ $this->pluginHelper = new QMNPluginHelper();
124
  }
125
+
126
  /**
127
  * Add Hooks
128
+ *
129
  * Adds functions to relavent hooks and filters
130
  *
131
  * @since 3.6.1
134
  private function add_hooks()
135
  {
136
  add_action('admin_menu', array( $this, 'setup_admin_menu'));
137
+ add_action('admin_head', array( $this, 'admin_head'));
138
  add_action('admin_init', 'mlw_quiz_update');
139
  add_action('widgets_init', create_function('', 'return register_widget("Mlw_Qmn_Leaderboard_Widget");'));
 
140
  add_shortcode('mlw_quizmaster_leaderboard', 'mlw_quiz_leaderboard_shortcode');
141
  add_action('plugins_loaded', array( $this, 'setup_translations'));
142
  }
143
+
144
  /**
145
  * Setup Admin Menu
146
+ *
147
  * Creates the admin menu and pages for the plugin and attaches functions to them
148
  *
149
  * @since 3.6.1
153
  {
154
  if (function_exists('add_menu_page'))
155
  {
156
+ add_menu_page('Quiz Master Next', __('Quizzes', 'quiz-master-next'), 'moderate_comments', __FILE__, 'mlw_generate_quiz_admin', 'dashicons-feedback');
157
+ add_submenu_page(__FILE__, __('Quiz Settings', 'quiz-master-next'), __('Quiz Settings', 'quiz-master-next'), 'moderate_comments', 'mlw_quiz_options', 'mlw_generate_quiz_options');
158
+ add_submenu_page(__FILE__, __('Quiz Results', 'quiz-master-next'), __('Quiz Results', 'quiz-master-next'), 'moderate_comments', 'mlw_quiz_results', 'mlw_generate_quiz_results');
159
+ add_submenu_page(__FILE__, __('Quiz Result Details', 'quiz-master-next'), __('Quiz Result Details', 'quiz-master-next'), 'moderate_comments', 'mlw_quiz_result_details', 'mlw_generate_result_details');
160
+ add_submenu_page(__FILE__, __('Stats', 'quiz-master-next'), __('Stats', 'quiz-master-next'), 'moderate_comments', 'mlw_quiz_stats', 'mlw_generate_quiz_dashboard');
161
+ add_submenu_page(__FILE__, __('Tools', 'quiz-master-next'), __('Tools', 'quiz-master-next'), 'manage_options', 'mlw_quiz_tools', 'mlw_generate_quiz_tools');
162
+ add_submenu_page(__FILE__, __('Help', 'quiz-master-next'), __('Help', 'quiz-master-next'), 'moderate_comments', 'mlw_quiz_help', 'mlw_generate_help_page');
163
+ add_submenu_page(__FILE__, __('Addon Settings', 'quiz-master-next'), __('Addon Settings', 'quiz-master-next'), 'manage_options', 'qmn_addons', 'qmn_addons_page');
164
+
165
+ add_dashboard_page(
166
+ __( 'QMN About', 'quiz' ),
167
+ __( 'QMN About', 'quiz' ),
168
+ 'manage_options',
169
+ 'mlw_qmn_about',
170
+ 'mlw_generate_about_page'
171
+ );
172
  }
173
  }
174
+
175
+ public function admin_head()
176
+ {
177
+ remove_submenu_page( 'index.php', 'mlw_qmn_about' );
178
+ }
179
+
180
  /**
181
  * Loads the plugin language files
182
  *
185
  */
186
  public function setup_translations()
187
  {
188
+ load_plugin_textdomain( 'quiz-master-next', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
189
  }
190
  }
191
 
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, exam, survey, contact, form, email, answer, question
5
  Requires at least: 3.8.1
6
  Tested up to: 4.1
7
- Stable tag: 3.9.0
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.
@@ -34,11 +34,14 @@ Your quiz can be graded with an incorrect/correct system or a points-based syste
34
  = Useful For Businesses =
35
  The plugin features useful **statistics** that show how many times each quiz has been viewed and taken and plots the data on several different **graphs** so you can see how the quizzes are doing at a glance. Also, the plugin includes an **audit trail** that logs every action done on the admin side so you can keep up with who is doing what!
36
 
 
 
 
37
  = Saves The Results For Later Use =
38
  The plugin will **save** the results, the user's answers, the user's comments, and more!
39
 
40
  = Math Formulas =
41
- You can use Tex or LaTex in questions, answers, and text fields for your quiz. For assistance with LaTex, review this tutorial: [LaTeX](http://www.andy-roberts.net/writing/latex/mathematics_1)
42
 
43
  = Schedule Time That Quiz Is Active =
44
  You can set up the quiz to only be active between two days. Utilize this for quizzes/surveys that are only active until a certain date.
@@ -48,6 +51,7 @@ You can set up the quiz to only be active between two days. Utilize this for qui
48
  * Allow the user to share the results on *social networks*
49
  * Show all questions on one page or have only one question per page
50
  * Require user to be logged in
 
51
  * Limit amount of total entries to quiz or survey
52
  * Allows for you to create **certificates** for the user
53
  * Can set amount of tries a user has to take the quiz
@@ -106,7 +110,7 @@ Feel free to use the widget on the help page within the plugin or from the conta
106
  == Screenshots ==
107
 
108
  1. Quiz Admin Page (With Advertisement Be Gone Add-On)
109
- 2. Quiz Options Page (With Advertisement Be Gone Add-On)
110
  3. Quiz Dashboard Page (With Advertisement Be Gone Add-On)
111
  4. Example Quiz
112
  5. Example Survey
@@ -116,6 +120,21 @@ Feel free to use the widget on the help page within the plugin or from the conta
116
 
117
  == Changelog ==
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  = 3.9.0 (December 30, 2014) =
120
  * Added Wp Editor To Text Tab
121
  * Added Weekly Stats To Snapshot Widget
@@ -432,8 +451,8 @@ Feel free to use the widget on the help page within the plugin or from the conta
432
  * Added Ability To Reset Quiz Stats On Each Quiz
433
  * Added Ability To Delete Results
434
  * Minor Design Changes
435
- * Minor Bug Fixes
436
-
437
  = 0.9.7 (January 24, 2014) =
438
  * Started Setting Plugin Up For Translations
439
  * Relocated Widgets From Help Page To Quiz Dashboard Page
@@ -498,14 +517,14 @@ Feel free to use the widget on the help page within the plugin or from the conta
498
  * Started Work On Weekly Stat Widget
499
  * Tweaked Some Design Throughout Admin Side
500
  * Minor Bug Fixes
501
-
502
  = 0.8.2 (December 10, 2013) =
503
  * Fixed Disappearing Question Bug Completely
504
  * Updated Update Process
505
-
506
  = 0.8.1 (December 9, 2013) =
507
  * Fixed Disappearing Question Bug
508
-
509
  = 0.8 (December 1, 2013) =
510
  * Added Spam Prevention Techniques To Backend
511
  * Added Ability To Reorder Questions
@@ -515,7 +534,7 @@ Feel free to use the widget on the help page within the plugin or from the conta
515
  = 0.7.2 (November 24, 2013) =
516
  * Bug Fixes
517
  * Added New Section On How-To Page
518
-
519
  = 0.7.1 (November 19, 2013) =
520
  * Changed Design For How-To Page
521
  * Added New Section In How-To Page
@@ -525,46 +544,46 @@ Feel free to use the widget on the help page within the plugin or from the conta
525
  * Bug Fixes
526
  * Begun Work On New How-To Page
527
  * Continued Redesigning Plugin Dashboard
528
-
529
  = 0.6.2 (November 10, 2013) =
530
  * Bug Fixes
531
  * Added More Stats
532
  * Started Redesigning Plugin Dashboard
533
-
534
  = 0.6.1 (November 2, 2013) =
535
  * Bug Fixes
536
-
537
  = 0.6 (October 19, 2013) =
538
  * Started Developing Quiz Leaderboards
539
  * Added Ability To Save User Answers And Comments
540
  * Added More Statistics To Quiz Dashboard
541
  * Bug Fixes
542
-
543
  = 0.5.3 (October 11, 2013) =
544
  * Bug Fixes
545
  * Started Redesigning Quiz Look
546
 
547
  = 0.5.2 (September 29, 2013) =
548
  * Bug Fixes
549
-
550
  = 0.5.1 (September 22, 2013) =
551
  * Added More Statistics To Quiz Dashboard
552
  * Bug Fixes
553
-
554
  = 0.5 (September 18, 2013) =
555
  * Created New Tools Page And Moved Audit Trail To It
556
  * Added Ability For Comment Section At End Of Quiz
557
  * Added Ability To Have Hints
558
  * Added Option To Have Comment Boxes On Questions
559
  * Added More Statistics To Main Page
560
-
561
  = 0.4.1 (September 15, 2013) =
562
  * Bug Fixes
563
 
564
  = 0.4 (September 13, 2013) =
565
  * Add The Ability To Require Contact Information
566
  * Add Email Validating To Email Field
567
-
568
  = 0.3.1 (September 13, 2013) =
569
  * Bug Fixes
570
 
@@ -588,6 +607,9 @@ Feel free to use the widget on the help page within the plugin or from the conta
588
 
589
  == Upgrade Notice ==
590
 
 
 
 
591
  = 3.9.0 =
592
  Upgrade for new editors on text tab and many more changes.
593
 
4
  Tags: quiz, test, score, exam, survey, contact, form, email, answer, question
5
  Requires at least: 3.8.1
6
  Tested up to: 4.1
7
+ Stable tag: 4.0.0
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.
34
  = Useful For Businesses =
35
  The plugin features useful **statistics** that show how many times each quiz has been viewed and taken and plots the data on several different **graphs** so you can see how the quizzes are doing at a glance. Also, the plugin includes an **audit trail** that logs every action done on the admin side so you can keep up with who is doing what!
36
 
37
+ = Categories =
38
+ You can assign categories to your questions. You can then show the user their score in a **particular** category or an average score of the categories.
39
+
40
  = Saves The Results For Later Use =
41
  The plugin will **save** the results, the user's answers, the user's comments, and more!
42
 
43
  = Math Formulas =
44
+ You can use Tex or LaTex in questions, answers, and text fields for your quiz. For assistance with LaTex, review this tutorial: [LaTeX](http://www.andy-roberts.net/writing/latex/mathematics_1)
45
 
46
  = Schedule Time That Quiz Is Active =
47
  You can set up the quiz to only be active between two days. Utilize this for quizzes/surveys that are only active until a certain date.
51
  * Allow the user to share the results on *social networks*
52
  * Show all questions on one page or have only one question per page
53
  * Require user to be logged in
54
+ * **Require** certain or all questions to be answered
55
  * Limit amount of total entries to quiz or survey
56
  * Allows for you to create **certificates** for the user
57
  * Can set amount of tries a user has to take the quiz
110
  == Screenshots ==
111
 
112
  1. Quiz Admin Page (With Advertisement Be Gone Add-On)
113
+ 2. Quiz Settings Page (With Advertisement Be Gone Add-On)
114
  3. Quiz Dashboard Page (With Advertisement Be Gone Add-On)
115
  4. Example Quiz
116
  5. Example Survey
120
 
121
  == Changelog ==
122
 
123
+ = 4.0.0 (January 14, 2015) =
124
+ * Added Ability To Add Categories To Your Quizzes
125
+ * Added Multiple Choice And Multiple Response To Required System
126
+ * Added Wp Editor To Results Pages
127
+ * Added Shortcode Capability To Results Pages
128
+ * Added Translation Capabilities
129
+ * Created New Addon Settings Page
130
+ * Design Changes To Quiz Settings Page
131
+ * In Code: Added 20 New Filters And Hooks
132
+ * In Code: Turned Question Types Into Extendable Functions For Creating Own Question Types
133
+ * In Code: Created New Plugin Helper Class For Extending Plugin
134
+ * In Code: Rewrote 75% of quiz shortcode file. Now With New Quiz Manager Class
135
+ * In Code: Re-organized File/Directory Structure
136
+ * In Code: Separated Quiz Settings Functions Into Own Files
137
+
138
  = 3.9.0 (December 30, 2014) =
139
  * Added Wp Editor To Text Tab
140
  * Added Weekly Stats To Snapshot Widget
451
  * Added Ability To Reset Quiz Stats On Each Quiz
452
  * Added Ability To Delete Results
453
  * Minor Design Changes
454
+ * Minor Bug Fixes
455
+
456
  = 0.9.7 (January 24, 2014) =
457
  * Started Setting Plugin Up For Translations
458
  * Relocated Widgets From Help Page To Quiz Dashboard Page
517
  * Started Work On Weekly Stat Widget
518
  * Tweaked Some Design Throughout Admin Side
519
  * Minor Bug Fixes
520
+
521
  = 0.8.2 (December 10, 2013) =
522
  * Fixed Disappearing Question Bug Completely
523
  * Updated Update Process
524
+
525
  = 0.8.1 (December 9, 2013) =
526
  * Fixed Disappearing Question Bug
527
+
528
  = 0.8 (December 1, 2013) =
529
  * Added Spam Prevention Techniques To Backend
530
  * Added Ability To Reorder Questions
534
  = 0.7.2 (November 24, 2013) =
535
  * Bug Fixes
536
  * Added New Section On How-To Page
537
+
538
  = 0.7.1 (November 19, 2013) =
539
  * Changed Design For How-To Page
540
  * Added New Section In How-To Page
544
  * Bug Fixes
545
  * Begun Work On New How-To Page
546
  * Continued Redesigning Plugin Dashboard
547
+
548
  = 0.6.2 (November 10, 2013) =
549
  * Bug Fixes
550
  * Added More Stats
551
  * Started Redesigning Plugin Dashboard
552
+
553
  = 0.6.1 (November 2, 2013) =
554
  * Bug Fixes
555
+
556
  = 0.6 (October 19, 2013) =
557
  * Started Developing Quiz Leaderboards
558
  * Added Ability To Save User Answers And Comments
559
  * Added More Statistics To Quiz Dashboard
560
  * Bug Fixes
561
+
562
  = 0.5.3 (October 11, 2013) =
563
  * Bug Fixes
564
  * Started Redesigning Quiz Look
565
 
566
  = 0.5.2 (September 29, 2013) =
567
  * Bug Fixes
568
+
569
  = 0.5.1 (September 22, 2013) =
570
  * Added More Statistics To Quiz Dashboard
571
  * Bug Fixes
572
+
573
  = 0.5 (September 18, 2013) =
574
  * Created New Tools Page And Moved Audit Trail To It
575
  * Added Ability For Comment Section At End Of Quiz
576
  * Added Ability To Have Hints
577
  * Added Option To Have Comment Boxes On Questions
578
  * Added More Statistics To Main Page
579
+
580
  = 0.4.1 (September 15, 2013) =
581
  * Bug Fixes
582
 
583
  = 0.4 (September 13, 2013) =
584
  * Add The Ability To Require Contact Information
585
  * Add Email Validating To Email Field
586
+
587
  = 0.3.1 (September 13, 2013) =
588
  * Bug Fixes
589
 
607
 
608
  == Upgrade Notice ==
609
 
610
+ = 4.0.0 =
611
+ Upgrade for categories, new editor for results pages, shortcode capability on results pages, enhanced required question system, and more.
612
+
613
  = 3.9.0 =
614
  Upgrade for new editors on text tab and many more changes.
615