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

Version Description

(May 10, 2016) = * Closed Enhancement: Create new audit trail class - Issue #425 * Closed Enhancement: Raise minimum WordPress version to 4.1 - Issue #423 * Closed Enhancement: WordPress Compatibility with 4.5.2 - Issue #422 * Closed Enhancement: Move installation process into new QSM_Install class - Issue #416 * Closed Enhancement: Update links for plugin on Plugins page - Issue #415 * Closed Bug: Activating plugin on fresh install causes unexpected output warning - Issue #414 * Closed User Request: Shortcode parameter to override amount of questions - Issue #345 * Closed Enhancement: Limit per user - upgrade to include non-logged in users - Issue #301

Download this release

Release Info

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

Code changes from version 4.7.0 to 4.7.1

CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
 
 
 
 
 
 
 
 
1
  = 4.6.6 (January 11, 2016) =
2
  * Fixes bug preventing some users to not be able to submit quiz
3
  * Fixes bug causing undefined titles for some users
@@ -21,7 +29,7 @@
21
 
22
  = 4.6.2 (October 21, 2015) =
23
  * Bug fix for browsers with JavaScript turned off
24
-
25
  = 4.6.1 (October 20, 2015) =
26
  * Bug fix for rare bug preventing IE usage on a small number of sites
27
 
1
+ = 4.6.7 (January 22, 2016) =
2
+ * Fixes bug causing multiple response to be on a single line for some users
3
+ * Fixes bug causing the incorrect/correct CSS class from being not added on results page correctly
4
+ * Fixes bug causing unexpected output error when activating plugin
5
+ * Changes comment section to default to off in newer quizzes
6
+ * Adds link to online academy to help page
7
+ * Cleans up installation function code
8
+
9
  = 4.6.6 (January 11, 2016) =
10
  * Fixes bug preventing some users to not be able to submit quiz
11
  * Fixes bug causing undefined titles for some users
29
 
30
  = 4.6.2 (October 21, 2015) =
31
  * Bug fix for browsers with JavaScript turned off
32
+
33
  = 4.6.1 (October 20, 2015) =
34
  * Bug fix for rare bug preventing IE usage on a small number of sites
35
 
ISSUE_TEMPLATE.md ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Please provide the following information when creating your issues:
2
+
3
+ ## General description
4
+ If this is a bug, give a general description of what you are experiencing. If this is a feature request, include what the feature your are requesting.
5
+
6
+ ## Expected behavior
7
+ If you are reporting a bug, please describe what you are expecting the plugin to do. If this is a feature request, delete this section.
8
+
9
+ ## Actual behavior
10
+ If you are reporting a bug, please describe what you are experiencing. If this is a feature request, delete this section.
11
+
12
+ ## Steps to reproduce the behavior
13
+ If you are reporting a bug, describe the exact steps you are taking that results in the behavior described above. If this is a feature request, delete this section.
14
+
15
+ ## Feature request
16
+ If you are reporting a bug, delete this section. If you are requesting a feature, please explain what you would like to have in the plugin. Please include examples of other systems/software that may have similar features as well as the exact way you would use this feature.
mlw_quizmaster2.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: Quiz And Survey Master
4
  * Description: Easily and quickly add quizzes and surveys to your website.
5
- * Version: 4.7.0
6
  * Author: Frank Corso
7
  * Author URI: http://www.quizandsurveymaster.com/
8
  * Plugin URI: http://www.quizandsurveymaster.com/
@@ -10,9 +10,11 @@
10
  * Domain Path: /languages
11
  *
12
  * @author Frank Corso
13
- * @version 4.7.0
14
  */
15
  if ( ! defined( 'ABSPATH' ) ) exit;
 
 
16
  /**
17
  * This class is the main class of the plugin
18
  *
@@ -28,7 +30,7 @@ class MLWQuizMasterNext
28
  * @var string
29
  * @since 4.0.0
30
  */
31
- public $version = '4.7.0';
32
 
33
  /**
34
  * QMN Alert Manager Object
@@ -62,6 +64,14 @@ class MLWQuizMasterNext
62
  */
63
  public $log_manager;
64
 
 
 
 
 
 
 
 
 
65
  /**
66
  * Main Construct Function
67
  *
@@ -72,8 +82,7 @@ class MLWQuizMasterNext
72
  * @uses MLWQuizMasterNext::add_hooks() Adds actions to hooks and filters
73
  * @return void
74
  */
75
- public function __construct()
76
- {
77
  $this->load_dependencies();
78
  $this->add_hooks();
79
  }
@@ -87,11 +96,14 @@ class MLWQuizMasterNext
87
  private function load_dependencies()
88
  {
89
 
90
- include("php/install.php");
91
 
92
  include("php/class-qmn-log-manager.php");
93
  $this->log_manager = new QMN_Log_Manager;
94
 
 
 
 
95
  if ( is_admin() ) {
96
  include("php/stats-page.php");
97
  include("php/quizzes-page.php");
@@ -121,7 +133,6 @@ class MLWQuizMasterNext
121
  include("php/class-qmn-quiz-manager.php");
122
 
123
  include("php/leaderboard-shortcode.php");
124
- include("php/updates.php");
125
  include("php/widgets.php");
126
  include("php/template-variables.php");
127
  include("php/adverts-generate.php");
@@ -150,7 +161,6 @@ class MLWQuizMasterNext
150
  {
151
  add_action('admin_menu', array( $this, 'setup_admin_menu'));
152
  add_action('admin_head', array( $this, 'admin_head'), 900);
153
- add_action('admin_init', 'mlw_quiz_update');
154
  add_action('widgets_init', create_function('', 'return register_widget("Mlw_Qmn_Leaderboard_Widget");'));
155
  add_shortcode('mlw_quizmaster_leaderboard', 'mlw_quiz_leaderboard_shortcode');
156
  add_action('plugins_loaded', array( $this, 'setup_translations'));
@@ -273,5 +283,5 @@ class MLWQuizMasterNext
273
  }
274
 
275
  $mlwQuizMasterNext = new MLWQuizMasterNext();
276
- register_activation_hook( __FILE__, 'mlw_quiz_activate');
277
  ?>
2
  /**
3
  * Plugin Name: Quiz And Survey Master
4
  * Description: Easily and quickly add quizzes and surveys to your website.
5
+ * Version: 4.7.1
6
  * Author: Frank Corso
7
  * Author URI: http://www.quizandsurveymaster.com/
8
  * Plugin URI: http://www.quizandsurveymaster.com/
10
  * Domain Path: /languages
11
  *
12
  * @author Frank Corso
13
+ * @version 4.7.1
14
  */
15
  if ( ! defined( 'ABSPATH' ) ) exit;
16
+
17
+ define( 'QSM_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
18
  /**
19
  * This class is the main class of the plugin
20
  *
30
  * @var string
31
  * @since 4.0.0
32
  */
33
+ public $version = '4.7.1';
34
 
35
  /**
36
  * QMN Alert Manager Object
64
  */
65
  public $log_manager;
66
 
67
+ /**
68
+ * QSM Audit Manager Object
69
+ *
70
+ * @var object
71
+ * @since 4.7.1
72
+ */
73
+ public $audit_manager;
74
+
75
  /**
76
  * Main Construct Function
77
  *
82
  * @uses MLWQuizMasterNext::add_hooks() Adds actions to hooks and filters
83
  * @return void
84
  */
85
+ public function __construct() {
 
86
  $this->load_dependencies();
87
  $this->add_hooks();
88
  }
96
  private function load_dependencies()
97
  {
98
 
99
+ include("php/class-qsm-install.php");
100
 
101
  include("php/class-qmn-log-manager.php");
102
  $this->log_manager = new QMN_Log_Manager;
103
 
104
+ include( "php/class-qsm-audit.php" );
105
+ $this->audit_manager = new QSM_Audit();
106
+
107
  if ( is_admin() ) {
108
  include("php/stats-page.php");
109
  include("php/quizzes-page.php");
133
  include("php/class-qmn-quiz-manager.php");
134
 
135
  include("php/leaderboard-shortcode.php");
 
136
  include("php/widgets.php");
137
  include("php/template-variables.php");
138
  include("php/adverts-generate.php");
161
  {
162
  add_action('admin_menu', array( $this, 'setup_admin_menu'));
163
  add_action('admin_head', array( $this, 'admin_head'), 900);
 
164
  add_action('widgets_init', create_function('', 'return register_widget("Mlw_Qmn_Leaderboard_Widget");'));
165
  add_shortcode('mlw_quizmaster_leaderboard', 'mlw_quiz_leaderboard_shortcode');
166
  add_action('plugins_loaded', array( $this, 'setup_translations'));
283
  }
284
 
285
  $mlwQuizMasterNext = new MLWQuizMasterNext();
286
+ register_activation_hook( __FILE__, array( 'QSM_Install', 'install' ) );
287
  ?>
php/about-page.php CHANGED
@@ -59,7 +59,7 @@ function mlw_generate_about_page()
59
  </div>
60
  <div id="mlw_quiz_changelog" class="qmn_tab" style="display: none;">
61
  <h2>Changelog</h2>
62
- <?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 15 ); ?>
63
  </div>
64
  <div id="qmn_contributors" class="qmn_tab" style="display:none;">
65
  <h2>GitHub Contributors</h2>
59
  </div>
60
  <div id="mlw_quiz_changelog" class="qmn_tab" style="display: none;">
61
  <h2>Changelog</h2>
62
+ <?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 21 ); ?>
63
  </div>
64
  <div id="qmn_contributors" class="qmn_tab" style="display:none;">
65
  <h2>GitHub Contributors</h2>
php/admin-results-page.php CHANGED
@@ -32,26 +32,9 @@ function mlw_generate_quiz_results()
32
  ),
33
  array( '%d' )
34
  );
35
- if ( $results )
36
- {
37
  $mlwQuizMasterNext->alertManager->newAlert(__('Your results has been deleted successfully.','quiz-master-next'), 'success');
38
-
39
- //Insert Action Into Audit Trail
40
- global $current_user;
41
- get_currentuserinfo();
42
- $wpdb->insert(
43
- $wpdb->prefix . "mlw_qm_audit_trail",
44
- array(
45
- 'action_user' => $current_user->display_name,
46
- 'action' => "Results Has Been Deleted From: $mlw_delete_results_name",
47
- 'time' => date("h:i:s A m/d/Y")
48
- ),
49
- array(
50
- '%s',
51
- '%s',
52
- '%s'
53
- )
54
- );
55
  }
56
  else
57
  {
@@ -80,22 +63,8 @@ function mlw_generate_quiz_results()
80
  array( '%d' )
81
  );
82
  }
83
- //Insert Action Into Audit Trail
84
- global $current_user;
85
- get_currentuserinfo();
86
- $wpdb->insert(
87
- $wpdb->prefix . "mlw_qm_audit_trail",
88
- array(
89
- 'action_user' => $current_user->display_name,
90
- 'action' => "Results Have Been Bulk Deleted",
91
- 'time' => date("h:i:s A m/d/Y")
92
- ),
93
- array(
94
- '%s',
95
- '%s',
96
- '%s'
97
- )
98
- );
99
  }
100
  }
101
 
32
  ),
33
  array( '%d' )
34
  );
35
+ if ( $results ) {
 
36
  $mlwQuizMasterNext->alertManager->newAlert(__('Your results has been deleted successfully.','quiz-master-next'), 'success');
37
+ $mlwQuizMasterNext->audit_manager->new_audit( "Results Has Been Deleted From: $mlw_delete_results_name" );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  }
39
  else
40
  {
63
  array( '%d' )
64
  );
65
  }
66
+
67
+ $mlwQuizMasterNext->audit_manager->new_audit( "Results Have Been Bulk Deleted" );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  }
69
  }
70
 
php/class-qmn-quiz-creator.php CHANGED
@@ -371,8 +371,7 @@ class QMNQuizCreator
371
  if ($results != false)
372
  {
373
  $new_quiz = $wpdb->insert_id;
374
- global $current_user;
375
- get_currentuserinfo();
376
  $quiz_post = array(
377
  'post_title' => $quiz_name,
378
  'post_content' => "[mlw_quizmaster quiz=$new_quiz]",
@@ -384,22 +383,7 @@ class QMNQuizCreator
384
  add_post_meta( $quiz_post_id, 'quiz_id', $new_quiz );
385
 
386
  $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');
387
- //Insert Action Into Audit Trail
388
- global $current_user;
389
- get_currentuserinfo();
390
- $wpdb->insert(
391
- $wpdb->prefix . "mlw_qm_audit_trail",
392
- array(
393
- 'action_user' => $current_user->display_name,
394
- 'action' => "New Quiz Has Been Created: $quiz_name",
395
- 'time' => date("h:i:s A m/d/Y")
396
- ),
397
- array(
398
- '%s',
399
- '%s',
400
- '%s'
401
- )
402
- );
403
  do_action('qmn_quiz_created', $new_quiz);
404
  }
405
  else
@@ -459,23 +443,7 @@ class QMNQuizCreator
459
  }
460
  wp_reset_postdata();
461
  $mlwQuizMasterNext->alertManager->newAlert(__('Your quiz has been deleted successfully.', 'quiz-master-next'), 'success');
462
-
463
- //Insert Action Into Audit Trail
464
- global $current_user;
465
- get_currentuserinfo();
466
- $wpdb->insert(
467
- $wpdb->prefix . "mlw_qm_audit_trail",
468
- array(
469
- 'action_user' => $current_user->display_name,
470
- 'action' => "Quiz Has Been Deleted: $quiz_name",
471
- 'time' => date("h:i:s A m/d/Y")
472
- ),
473
- array(
474
- '%s',
475
- '%s',
476
- '%s'
477
- )
478
- );
479
  }
480
  else
481
  {
@@ -507,26 +475,9 @@ class QMNQuizCreator
507
  ),
508
  array( '%d' )
509
  );
510
- if ($results != false)
511
- {
512
  $mlwQuizMasterNext->alertManager->newAlert(__('Your quiz name has been updated successfully.', 'quiz-master-next'), 'success');
513
-
514
- //Insert Action Into Audit Trail
515
- global $current_user;
516
- get_currentuserinfo();
517
- $wpdb->insert(
518
- $wpdb->prefix . "mlw_qm_audit_trail",
519
- array(
520
- 'action_user' => $current_user->display_name,
521
- 'action' => "Quiz Name Has Been Edited: $quiz_name",
522
- 'time' => date("h:i:s A m/d/Y")
523
- ),
524
- array(
525
- '%s',
526
- '%s',
527
- '%s'
528
- )
529
- );
530
  }
531
  else
532
  {
@@ -662,10 +613,8 @@ class QMNQuizCreator
662
  )
663
  );
664
  $mlw_new_id = $wpdb->insert_id;
665
- if ($results != false)
666
- {
667
- global $current_user;
668
- get_currentuserinfo();
669
  $quiz_post = array(
670
  'post_title' => $quiz_name,
671
  'post_content' => "[mlw_quizmaster quiz=$mlw_new_id]",
@@ -676,23 +625,7 @@ class QMNQuizCreator
676
  $quiz_post_id = wp_insert_post( $quiz_post );
677
  add_post_meta( $quiz_post_id, 'quiz_id', $mlw_new_id );
678
  $mlwQuizMasterNext->alertManager->newAlert(__('Your quiz has been duplicated successfully.', 'quiz-master-next'), 'success');
679
-
680
- //Insert Action Into Audit Trail
681
- global $current_user;
682
- get_currentuserinfo();
683
- $wpdb->insert(
684
- $wpdb->prefix . "mlw_qm_audit_trail",
685
- array(
686
- 'action_user' => $current_user->display_name,
687
- 'action' => "New Quiz Has Been Created: $quiz_name",
688
- 'time' => date("h:i:s A m/d/Y")
689
- ),
690
- array(
691
- '%s',
692
- '%s',
693
- '%s'
694
- )
695
- );
696
  do_action('qmn_quiz_duplicated', $quiz_id, $mlw_new_id);
697
  }
698
  else
371
  if ($results != false)
372
  {
373
  $new_quiz = $wpdb->insert_id;
374
+ $current_user = wp_get_current_user();
 
375
  $quiz_post = array(
376
  'post_title' => $quiz_name,
377
  'post_content' => "[mlw_quizmaster quiz=$new_quiz]",
383
  add_post_meta( $quiz_post_id, 'quiz_id', $new_quiz );
384
 
385
  $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');
386
+ $mlwQuizMasterNext->audit_manager->new_audit( "New Quiz Has Been Created: $quiz_name" );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
387
  do_action('qmn_quiz_created', $new_quiz);
388
  }
389
  else
443
  }
444
  wp_reset_postdata();
445
  $mlwQuizMasterNext->alertManager->newAlert(__('Your quiz has been deleted successfully.', 'quiz-master-next'), 'success');
446
+ $mlwQuizMasterNext->audit_manager->new_audit( "Quiz Has Been Deleted: $quiz_name" );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
447
  }
448
  else
449
  {
475
  ),
476
  array( '%d' )
477
  );
478
+ if ( false != $results ) {
 
479
  $mlwQuizMasterNext->alertManager->newAlert(__('Your quiz name has been updated successfully.', 'quiz-master-next'), 'success');
480
+ $mlwQuizMasterNext->audit_manager->new_audit( "Quiz Name Has Been Edited: $quiz_name" );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
481
  }
482
  else
483
  {
613
  )
614
  );
615
  $mlw_new_id = $wpdb->insert_id;
616
+ if ( false != $results ) {
617
+ $current_user = wp_get_current_user();
 
 
618
  $quiz_post = array(
619
  'post_title' => $quiz_name,
620
  'post_content' => "[mlw_quizmaster quiz=$mlw_new_id]",
625
  $quiz_post_id = wp_insert_post( $quiz_post );
626
  add_post_meta( $quiz_post_id, 'quiz_id', $mlw_new_id );
627
  $mlwQuizMasterNext->alertManager->newAlert(__('Your quiz has been duplicated successfully.', 'quiz-master-next'), 'success');
628
+ $mlwQuizMasterNext->audit_manager->new_audit( "New Quiz Has Been Created: $quiz_name" );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
629
  do_action('qmn_quiz_duplicated', $quiz_id, $mlw_new_id);
630
  }
631
  else
php/class-qmn-quiz-manager.php CHANGED
@@ -52,7 +52,8 @@ class QMNQuizManager
52
  public function display_shortcode($atts)
53
  {
54
  extract(shortcode_atts(array(
55
- 'quiz' => 0
 
56
  ), $atts));
57
 
58
  global $wpdb;
@@ -62,6 +63,7 @@ class QMNQuizManager
62
  $qmn_json_data = array();
63
  $qmn_allowed_visit = true;
64
  $mlwQuizMasterNext->quizCreator->set_id($quiz);
 
65
 
66
  //Legacy variable
67
  global $mlw_qmn_quiz;
@@ -109,6 +111,12 @@ class QMNQuizManager
109
  'quiz_system' => $qmn_quiz_options->system
110
  );
111
 
 
 
 
 
 
 
112
  echo "<script>
113
  if (window.qmn_quiz_data === undefined) {
114
  window.qmn_quiz_data = new Object();
@@ -125,7 +133,7 @@ class QMNQuizManager
125
  //Check if we should be showing quiz or results page
126
  if ($qmn_allowed_visit && !isset($_POST["complete_quiz"]) && $qmn_quiz_options->quiz_name != '')
127
  {
128
- $qmn_quiz_questions = $this->load_questions($quiz, $qmn_quiz_options, true);
129
  $qmn_quiz_answers = $this->create_answer_array($qmn_quiz_questions);
130
  $return_display .= $this->display_quiz($qmn_quiz_options, $qmn_quiz_questions, $qmn_quiz_answers, $qmn_array_for_variables);
131
  }
@@ -173,22 +181,33 @@ class QMNQuizManager
173
  * @since 4.0.0
174
  * @param int $quiz_id The id for the quiz
175
  * @param array $quiz_options The database row for the quiz
 
 
176
  * @return array The questions for the quiz
177
  */
178
- public function load_questions($quiz_id, $quiz_options, $is_quiz_page)
179
- {
 
180
  global $wpdb;
181
  $order_by_sql = "ORDER BY question_order ASC";
182
  $limit_sql = '';
183
- if ($quiz_options->randomness_order == 1 || $quiz_options->randomness_order == 2)
184
- {
 
185
  $order_by_sql = "ORDER BY rand()";
186
  }
187
- if ($is_quiz_page && $quiz_options->question_from_total != 0)
188
- {
189
- $limit_sql = " LIMIT ".$quiz_options->question_from_total;
 
 
 
 
 
190
  }
191
- 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));
 
 
192
  }
193
 
194
  /**
@@ -534,6 +553,13 @@ class QMNQuizManager
534
  {
535
  global $qmn_allowed_visit;
536
  $result_display = '';
 
 
 
 
 
 
 
537
  $result_display = apply_filters('qmn_begin_results', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
538
  if (!$qmn_allowed_visit)
539
  {
@@ -596,6 +622,7 @@ class QMNQuizManager
596
  'email' => $qmn_array_for_variables['user_email'],
597
  'phone' => $qmn_array_for_variables['user_phone'],
598
  'user' => $qmn_array_for_variables['user_id'],
 
599
  'time_taken' => $qmn_array_for_variables['time_taken'],
600
  'time_taken_real' => date( "Y-m-d H:i:s", strtotime( $qmn_array_for_variables['time_taken'] ) ),
601
  'quiz_results' => $mlw_quiz_results,
@@ -617,6 +644,7 @@ class QMNQuizManager
617
  '%s',
618
  '%s',
619
  '%s',
 
620
  '%d'
621
  )
622
  );
@@ -1204,19 +1232,40 @@ function qmn_scheduled_timeframe_check($display, $qmn_quiz_options, $qmn_array_f
1204
  }
1205
 
1206
  add_filter('qmn_begin_shortcode', 'qmn_total_user_tries_check', 10, 3);
1207
- function qmn_total_user_tries_check($display, $qmn_quiz_options, $qmn_array_for_variables)
1208
- {
 
 
 
 
 
 
 
 
 
 
1209
  global $qmn_allowed_visit;
1210
- if ( $qmn_quiz_options->total_user_tries != 0 && is_user_logged_in() )
1211
- {
 
1212
  global $wpdb;
1213
- $current_user = wp_get_current_user();
1214
- $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'] ) );
1215
- if ($mlw_qmn_user_try_count >= $qmn_quiz_options->total_user_tries)
1216
- {
 
 
 
 
 
 
 
 
 
 
1217
  $qmn_allowed_visit = false;
1218
- $mlw_message = wpautop(htmlspecialchars_decode($qmn_quiz_options->total_user_tries_text, ENT_QUOTES));
1219
- $mlw_message = apply_filters( 'mlw_qmn_template_variable_quiz_page', $mlw_message, $qmn_array_for_variables);
1220
  $display .= $mlw_message;
1221
  }
1222
  }
52
  public function display_shortcode($atts)
53
  {
54
  extract(shortcode_atts(array(
55
+ 'quiz' => 0,
56
+ 'question_amount' => 0
57
  ), $atts));
58
 
59
  global $wpdb;
63
  $qmn_json_data = array();
64
  $qmn_allowed_visit = true;
65
  $mlwQuizMasterNext->quizCreator->set_id($quiz);
66
+ $question_amount = intval( $question_amount );
67
 
68
  //Legacy variable
69
  global $mlw_qmn_quiz;
111
  'quiz_system' => $qmn_quiz_options->system
112
  );
113
 
114
+ if ( $_SERVER["REMOTE_ADDR"] ) {
115
+ $qmn_array_for_variables['user_ip'] = $_SERVER["REMOTE_ADDR"];
116
+ } else {
117
+ $qmn_array_for_variables['user_ip'] = "Unknown";
118
+ }
119
+
120
  echo "<script>
121
  if (window.qmn_quiz_data === undefined) {
122
  window.qmn_quiz_data = new Object();
133
  //Check if we should be showing quiz or results page
134
  if ($qmn_allowed_visit && !isset($_POST["complete_quiz"]) && $qmn_quiz_options->quiz_name != '')
135
  {
136
+ $qmn_quiz_questions = $this->load_questions( $quiz, $qmn_quiz_options, true, $question_amount );
137
  $qmn_quiz_answers = $this->create_answer_array($qmn_quiz_questions);
138
  $return_display .= $this->display_quiz($qmn_quiz_options, $qmn_quiz_questions, $qmn_quiz_answers, $qmn_array_for_variables);
139
  }
181
  * @since 4.0.0
182
  * @param int $quiz_id The id for the quiz
183
  * @param array $quiz_options The database row for the quiz
184
+ * @param bool $is_quiz_page If the page being loaded is the quiz page or not
185
+ * @param int $question_amount The amount of questions entered using the shortcode attribute
186
  * @return array The questions for the quiz
187
  */
188
+ public function load_questions( $quiz_id, $quiz_options, $is_quiz_page, $question_amount ) {
189
+
190
+ // Prepare variables
191
  global $wpdb;
192
  $order_by_sql = "ORDER BY question_order ASC";
193
  $limit_sql = '';
194
+
195
+ // Checks if the questions should be randomized
196
+ if ( $quiz_options->randomness_order == 1 || $quiz_options->randomness_order == 2 ) {
197
  $order_by_sql = "ORDER BY rand()";
198
  }
199
+
200
+ // Check if we should load all questions or only a selcted amount
201
+ if ($is_quiz_page && ( $quiz_options->question_from_total != 0 || $question_amount !== 0 ) ) {
202
+ if ( $question_amount !== 0 ) {
203
+ $limit_sql = " LIMIT $question_amount";
204
+ } else {
205
+ $limit_sql = " LIMIT " . intval( $quiz_options->question_from_total );
206
+ }
207
  }
208
+
209
+ // Returns an array of all the loaded questions
210
+ 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 ) );
211
  }
212
 
213
  /**
553
  {
554
  global $qmn_allowed_visit;
555
  $result_display = '';
556
+
557
+ if ( $_SERVER["REMOTE_ADDR"] ) {
558
+ $qmn_array_for_variables['user_ip'] = $_SERVER["REMOTE_ADDR"];
559
+ } else {
560
+ $qmn_array_for_variables['user_ip'] = "Unknown";
561
+ }
562
+
563
  $result_display = apply_filters('qmn_begin_results', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
564
  if (!$qmn_allowed_visit)
565
  {
622
  'email' => $qmn_array_for_variables['user_email'],
623
  'phone' => $qmn_array_for_variables['user_phone'],
624
  'user' => $qmn_array_for_variables['user_id'],
625
+ 'user_ip' => $qmn_array_for_variables['user_ip'],
626
  'time_taken' => $qmn_array_for_variables['time_taken'],
627
  'time_taken_real' => date( "Y-m-d H:i:s", strtotime( $qmn_array_for_variables['time_taken'] ) ),
628
  'quiz_results' => $mlw_quiz_results,
644
  '%s',
645
  '%s',
646
  '%s',
647
+ '%s',
648
  '%d'
649
  )
650
  );
1232
  }
1233
 
1234
  add_filter('qmn_begin_shortcode', 'qmn_total_user_tries_check', 10, 3);
1235
+
1236
+ /**
1237
+ * Checks if user has already reach the user limit of the quiz
1238
+ *
1239
+ * @since 4.8.0
1240
+ * @param string $display The HTML displayed for the quiz
1241
+ * @param array $qmn_quiz_options The settings for the quiz
1242
+ * @param array $qmn_array_for_variables The array of data by the quiz
1243
+ * @return string The altered HTML display for the quiz
1244
+ */
1245
+ function qmn_total_user_tries_check( $display, $qmn_quiz_options, $qmn_array_for_variables ) {
1246
+
1247
  global $qmn_allowed_visit;
1248
+ if ( $qmn_quiz_options->total_user_tries != 0 ) {
1249
+
1250
+ // Prepares the variables
1251
  global $wpdb;
1252
+ $mlw_qmn_user_try_count = 0;
1253
+
1254
+ // Checks if the user is logged in. If so, check by user id. If not, check by IP.
1255
+ if ( is_user_logged_in() ) {
1256
+ $current_user = wp_get_current_user();
1257
+ $mlw_qmn_user_try_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_results WHERE user=%d AND deleted='0' AND quiz_id=%d", $current_user->ID, $qmn_array_for_variables['quiz_id'] ) );
1258
+ } else {
1259
+ $mlw_qmn_user_try_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_results WHERE user_ip='%s' AND deleted='0' AND quiz_id=%d", $qmn_array_for_variables['user_ip'], $qmn_array_for_variables['quiz_id'] ) );
1260
+ }
1261
+
1262
+ // If user has already reached the limit for this quiz
1263
+ if ( $mlw_qmn_user_try_count >= $qmn_quiz_options->total_user_tries ) {
1264
+
1265
+ // Stops the quiz and prepares entered text
1266
  $qmn_allowed_visit = false;
1267
+ $mlw_message = wpautop( htmlspecialchars_decode( $qmn_quiz_options->total_user_tries_text, ENT_QUOTES ) );
1268
+ $mlw_message = apply_filters( 'mlw_qmn_template_variable_quiz_page', $mlw_message, $qmn_array_for_variables );
1269
  $display .= $mlw_message;
1270
  }
1271
  }
php/class-qmn-review-message.php CHANGED
@@ -22,9 +22,18 @@ class QMN_Review_Message {
22
  * @since 4.5.0
23
  */
24
  function __construct() {
25
- $this->check_message_display();
26
  }
27
 
 
 
 
 
 
 
 
 
 
28
  /**
29
  * Checks if message should be displayed
30
  *
22
  * @since 4.5.0
23
  */
24
  function __construct() {
25
+ $this->add_hooks();
26
  }
27
 
28
+ /**
29
+ * Adds check message to admin_init hook
30
+ *
31
+ * @since 4.8.0
32
+ */
33
+ public function add_hooks() {
34
+ add_action( 'admin_init', array( $this, 'check_message_display' ) );
35
+ }
36
+
37
  /**
38
  * Checks if message should be displayed
39
  *
php/class-qmn-tracking.php CHANGED
@@ -164,7 +164,7 @@ class QMNTracking
164
  $data['current_version'] = get_option('mlw_quiz_master_version');
165
 
166
  $data['quiz_options'] = $wpdb->get_results( "SELECT quiz_name, system, randomness_order, loggedin_user_contact, show_score, send_user_email, send_admin_email, contact_info_location, user_name, user_comp,
167
- user_email, user_phone, comment_section, question_from_total, total_user_tries, pagination, timer_limit, question_numbering, last_activity, require_log_in, limit_total_entries, disable_answer_onselect, ajax_show_correct, quiz_views, quiz_taken FROM ".$wpdb->prefix."mlw_quizzes WHERE deleted=0" );
168
 
169
 
170
  $this->data = $data;
164
  $data['current_version'] = get_option('mlw_quiz_master_version');
165
 
166
  $data['quiz_options'] = $wpdb->get_results( "SELECT quiz_name, system, randomness_order, loggedin_user_contact, show_score, send_user_email, send_admin_email, contact_info_location, user_name, user_comp,
167
+ user_email, user_phone, comment_section, question_from_total, total_user_tries, certificate_template, pagination, timer_limit, question_numbering, theme_selected, last_activity, require_log_in, limit_total_entries, disable_answer_onselect, ajax_show_correct, quiz_views, quiz_taken FROM ".$wpdb->prefix."mlw_quizzes WHERE deleted=0" );
168
 
169
 
170
  $this->data = $data;
php/class-qsm-audit.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ /**
6
+ * This class handles the audit trail of the plugin
7
+ */
8
+ class QSM_Audit {
9
+
10
+ /**
11
+ * Adds new audit to Audit Trail table
12
+ *
13
+ * @since 4.7.1
14
+ * @param string $action The action that is to be saved into the audit trail
15
+ * @return bool Returns true if successfull and false if fails
16
+ */
17
+ public function new_audit( $action, $user = null ) {
18
+
19
+ // Sanitizes action just in case 3rd party uses this funtion
20
+ $action = sanitize_text_field( $action );
21
+
22
+ // Retrieves current user's data
23
+ if ( is_null( $user ) ) {
24
+ $current_user = wp_get_current_user();
25
+ } else {
26
+ $current_user = $user;
27
+ }
28
+
29
+ // Returns if the current user is not valid
30
+ if ( ! ( $current_user instanceof WP_User ) ) {
31
+ return false;
32
+ }
33
+
34
+ global $wpdb;
35
+
36
+ // Inserts new audit into table
37
+ $inserted = $wpdb->insert(
38
+ $wpdb->prefix . "mlw_qm_audit_trail",
39
+ array(
40
+ 'action_user' => $current_user->display_name,
41
+ 'action' => $action,
42
+ 'time' => date("h:i:s A m/d/Y")
43
+ ),
44
+ array(
45
+ '%s',
46
+ '%s',
47
+ '%s'
48
+ )
49
+ );
50
+
51
+ // If the insert returns false, then return false
52
+ if ( false === $inserted ) {
53
+ return false;
54
+ }
55
+
56
+ return true;
57
+ }
58
+ }
59
+ ?>
php/class-qsm-install.php ADDED
@@ -0,0 +1,657 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ /**
6
+ * Class that handles installation, updates, and plugin row meta
7
+ *
8
+ * @since 4.7.1
9
+ */
10
+ class QSM_Install {
11
+
12
+ /**
13
+ * Main Constructor
14
+ *
15
+ * @uses QSM_Install::add_hooks
16
+ * @since 4.7.1
17
+ */
18
+ function __construct() {
19
+ $this->add_hooks();
20
+ }
21
+
22
+ /**
23
+ * Adds the various class functions to hooks and filters
24
+ *
25
+ * @since 4.7.1
26
+ */
27
+ public function add_hooks() {
28
+ add_action( 'admin_init', array( $this, 'update' ) );
29
+ add_filter( 'plugin_action_links_' . QSM_PLUGIN_BASENAME, array( $this, 'plugin_action_links' ) );
30
+ add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
31
+ }
32
+
33
+ /**
34
+ * Installs the plugin and its database tables
35
+ *
36
+ * @since 4.7.1
37
+ */
38
+ public static function install() {
39
+
40
+ global $wpdb;
41
+ $charset_collate = $wpdb->get_charset_collate();
42
+
43
+ $quiz_table_name = $wpdb->prefix . "mlw_quizzes";
44
+ $question_table_name = $wpdb->prefix . "mlw_questions";
45
+ $results_table_name = $wpdb->prefix . "mlw_results";
46
+ $audit_table_name = $wpdb->prefix . "mlw_qm_audit_trail";
47
+
48
+ if( $wpdb->get_var( "SHOW TABLES LIKE '$quiz_table_name'" ) != $quiz_table_name ) {
49
+ $sql = "CREATE TABLE $quiz_table_name (
50
+ quiz_id mediumint(9) NOT NULL AUTO_INCREMENT,
51
+ quiz_name TEXT NOT NULL,
52
+ message_before TEXT NOT NULL,
53
+ message_after TEXT NOT NULL,
54
+ message_comment TEXT NOT NULL,
55
+ message_end_template TEXT NOT NULL,
56
+ user_email_template TEXT NOT NULL,
57
+ admin_email_template TEXT NOT NULL,
58
+ submit_button_text TEXT NOT NULL,
59
+ name_field_text TEXT NOT NULL,
60
+ business_field_text TEXT NOT NULL,
61
+ email_field_text TEXT NOT NULL,
62
+ phone_field_text TEXT NOT NULL,
63
+ comment_field_text TEXT NOT NULL,
64
+ email_from_text TEXT NOT NULL,
65
+ question_answer_template TEXT NOT NULL,
66
+ leaderboard_template TEXT NOT NULL,
67
+ system INT NOT NULL,
68
+ randomness_order INT NOT NULL,
69
+ loggedin_user_contact INT NOT NULL,
70
+ show_score INT NOT NULL,
71
+ send_user_email INT NOT NULL,
72
+ send_admin_email INT NOT NULL,
73
+ contact_info_location INT NOT NULL,
74
+ user_name INT NOT NULL,
75
+ user_comp INT NOT NULL,
76
+ user_email INT NOT NULL,
77
+ user_phone INT NOT NULL,
78
+ admin_email TEXT NOT NULL,
79
+ comment_section INT NOT NULL,
80
+ question_from_total INT NOT NULL,
81
+ total_user_tries INT NOT NULL,
82
+ total_user_tries_text TEXT NOT NULL,
83
+ certificate_template TEXT NOT NULL,
84
+ social_media INT NOT NULL,
85
+ social_media_text TEXT NOT NULL,
86
+ pagination INT NOT NULL,
87
+ pagination_text TEXT NOT NULL,
88
+ timer_limit INT NOT NULL,
89
+ quiz_stye TEXT NOT NULL,
90
+ question_numbering INT NOT NULL,
91
+ quiz_settings TEXT NOT NULL,
92
+ theme_selected TEXT NOT NULL,
93
+ last_activity DATETIME NOT NULL,
94
+ require_log_in INT NOT NULL,
95
+ require_log_in_text TEXT NOT NULL,
96
+ limit_total_entries INT NOT NULL,
97
+ limit_total_entries_text TEXT NOT NULL,
98
+ scheduled_timeframe TEXT NOT NULL,
99
+ scheduled_timeframe_text TEXT NOT NULL,
100
+ disable_answer_onselect INT NOT NULL,
101
+ ajax_show_correct INT NOT NULL,
102
+ quiz_views INT NOT NULL,
103
+ quiz_taken INT NOT NULL,
104
+ deleted INT NOT NULL,
105
+ PRIMARY KEY (quiz_id)
106
+ ) $charset_collate;";
107
+
108
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
109
+ dbDelta( $sql );
110
+ }
111
+
112
+ if( $wpdb->get_var( "SHOW TABLES LIKE '$question_table_name'" ) != $question_table_name ) {
113
+ $sql = "CREATE TABLE $question_table_name (
114
+ question_id mediumint(9) NOT NULL AUTO_INCREMENT,
115
+ quiz_id INT NOT NULL,
116
+ question_name TEXT NOT NULL,
117
+ answer_array TEXT NOT NULL,
118
+ answer_one TEXT NOT NULL,
119
+ answer_one_points INT NOT NULL,
120
+ answer_two TEXT NOT NULL,
121
+ answer_two_points INT NOT NULL,
122
+ answer_three TEXT NOT NULL,
123
+ answer_three_points INT NOT NULL,
124
+ answer_four TEXT NOT NULL,
125
+ answer_four_points INT NOT NULL,
126
+ answer_five TEXT NOT NULL,
127
+ answer_five_points INT NOT NULL,
128
+ answer_six TEXT NOT NULL,
129
+ answer_six_points INT NOT NULL,
130
+ correct_answer INT NOT NULL,
131
+ question_answer_info TEXT NOT NULL,
132
+ comments INT NOT NULL,
133
+ hints TEXT NOT NULL,
134
+ question_order INT NOT NULL,
135
+ question_type INT NOT NULL,
136
+ question_type_new TEXT NOT NULL,
137
+ question_settings TEXT NOT NULL,
138
+ category TEXT NOT NULL,
139
+ deleted INT NOT NULL,
140
+ PRIMARY KEY (question_id)
141
+ ) $charset_collate;";
142
+
143
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
144
+ dbDelta( $sql );
145
+ }
146
+
147
+ if( $wpdb->get_var( "SHOW TABLES LIKE '$results_table_name'" ) != $results_table_name ) {
148
+ $sql = "CREATE TABLE $results_table_name (
149
+ result_id mediumint(9) NOT NULL AUTO_INCREMENT,
150
+ quiz_id INT NOT NULL,
151
+ quiz_name TEXT NOT NULL,
152
+ quiz_system INT NOT NULL,
153
+ point_score INT NOT NULL,
154
+ correct_score INT NOT NULL,
155
+ correct INT NOT NULL,
156
+ total INT NOT NULL,
157
+ name TEXT NOT NULL,
158
+ business TEXT NOT NULL,
159
+ email TEXT NOT NULL,
160
+ phone TEXT NOT NULL,
161
+ user INT NOT NULL,
162
+ user_ip TEXT NOT NULL,
163
+ time_taken TEXT NOT NULL,
164
+ time_taken_real DATETIME NOT NULL,
165
+ quiz_results TEXT NOT NULL,
166
+ deleted INT NOT NULL,
167
+ PRIMARY KEY (result_id)
168
+ ) $charset_collate;";
169
+
170
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
171
+ dbDelta( $sql );
172
+ }
173
+
174
+ if( $wpdb->get_var( "SHOW TABLES LIKE '$audit_table_name'" ) != $audit_table_name ) {
175
+ $sql = "CREATE TABLE $audit_table_name (
176
+ trail_id mediumint(9) NOT NULL AUTO_INCREMENT,
177
+ action_user TEXT NOT NULL,
178
+ action TEXT NOT NULL,
179
+ time TEXT NOT NULL,
180
+ PRIMARY KEY (trail_id)
181
+ ) $charset_collate;";
182
+
183
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
184
+ dbDelta( $sql );
185
+ }
186
+ }
187
+
188
+ /**
189
+ * Updates the plugin
190
+ *
191
+ * @since 4.7.1
192
+ */
193
+ public function update() {
194
+ global $mlwQuizMasterNext;
195
+ $data = $mlwQuizMasterNext->version;
196
+ if ( ! get_option('qmn_original_version'))
197
+ {
198
+ add_option('qmn_original_version' , $data);
199
+ }
200
+ if ( ! get_option('mlw_quiz_master_version'))
201
+ {
202
+ add_option('mlw_quiz_master_version' , $data);
203
+ }
204
+ elseif (get_option('mlw_quiz_master_version') != $data)
205
+ {
206
+ global $wpdb;
207
+ $table_name = $wpdb->prefix . "mlw_quizzes";
208
+ //Update 0.5
209
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'comment_section'") != "comment_section")
210
+ {
211
+ $sql = "ALTER TABLE ".$table_name." ADD comment_field_text TEXT NOT NULL AFTER phone_field_text";
212
+ $results = $wpdb->query( $sql );
213
+ $sql = "ALTER TABLE ".$table_name." ADD comment_section INT NOT NULL AFTER admin_email";
214
+ $results = $wpdb->query( $sql );
215
+ $sql = "ALTER TABLE ".$table_name." ADD message_comment TEXT NOT NULL AFTER message_after";
216
+ $results = $wpdb->query( $sql );
217
+ $update_sql = "UPDATE ".$table_name." SET comment_field_text='Comments', comment_section=1, message_comment='Enter You Text Here'";
218
+ $results = $wpdb->query( $update_sql );
219
+ }
220
+
221
+ //Update 0.9.2
222
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'leaderboard_template'") != "leaderboard_template")
223
+ {
224
+ $sql = "ALTER TABLE ".$table_name." ADD leaderboard_template TEXT NOT NULL AFTER comment_field_text";
225
+ $results = $wpdb->query( $sql );
226
+ $mlw_leaderboard_default = "<h3>Leaderboard for %QUIZ_NAME%</h3>
227
+ 1. %FIRST_PLACE_NAME%-%FIRST_PLACE_SCORE%<br />
228
+ 2. %SECOND_PLACE_NAME%-%SECOND_PLACE_SCORE%<br />
229
+ 3. %THIRD_PLACE_NAME%-%THIRD_PLACE_SCORE%<br />
230
+ 4. %FOURTH_PLACE_NAME%-%FOURTH_PLACE_SCORE%<br />
231
+ 5. %FIFTH_PLACE_NAME%-%FIFTH_PLACE_SCORE%<br />";
232
+ $update_sql = "UPDATE ".$table_name." SET leaderboard_template='".$mlw_leaderboard_default."'";
233
+ $results = $wpdb->query( $update_sql );
234
+ }
235
+
236
+ //Update 0.9.4
237
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'randomness_order'") != "randomness_order")
238
+ {
239
+ $sql = "ALTER TABLE ".$table_name." ADD randomness_order INT NOT NULL AFTER system";
240
+ $results = $wpdb->query( $sql );
241
+ $update_sql = "UPDATE ".$table_name." SET randomness_order=0";
242
+ $results = $wpdb->query( $update_sql );
243
+ }
244
+
245
+ //Update 0.9.5
246
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_answer_template'") != "question_answer_template")
247
+ {
248
+ $sql = "ALTER TABLE ".$table_name." ADD question_answer_template TEXT NOT NULL AFTER comment_field_text";
249
+ $results = $wpdb->query( $sql );
250
+ $mlw_question_answer_default = "%QUESTION%<br /> Answer Provided: %USER_ANSWER%<br /> Correct Answer: %CORRECT_ANSWER%<br /> Comments Entered: %USER_COMMENTS%<br />";
251
+ $update_sql = "UPDATE ".$table_name." SET question_answer_template='".$mlw_question_answer_default."'";
252
+ $results = $wpdb->query( $update_sql );
253
+ }
254
+
255
+ //Update 0.9.6
256
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'contact_info_location'") != "contact_info_location")
257
+ {
258
+ $sql = "ALTER TABLE ".$table_name." ADD contact_info_location INT NOT NULL AFTER send_admin_email";
259
+ $results = $wpdb->query( $sql );
260
+ $update_sql = "UPDATE ".$table_name." SET contact_info_location=0";
261
+ $results = $wpdb->query( $update_sql );
262
+ }
263
+
264
+ //Update 1.0
265
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'email_from_text'") != "email_from_text")
266
+ {
267
+ $sql = "ALTER TABLE ".$table_name." ADD email_from_text TEXT NOT NULL AFTER comment_field_text";
268
+ $results = $wpdb->query( $sql );
269
+ $update_sql = "UPDATE ".$table_name." SET email_from_text='Wordpress'";
270
+ $results = $wpdb->query( $update_sql );
271
+ }
272
+
273
+ //Update 1.3.1
274
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'loggedin_user_contact'") != "loggedin_user_contact")
275
+ {
276
+ $sql = "ALTER TABLE ".$table_name." ADD loggedin_user_contact INT NOT NULL AFTER randomness_order";
277
+ $results = $wpdb->query( $sql );
278
+ $update_sql = "UPDATE ".$table_name." SET loggedin_user_contact=0";
279
+ $results = $wpdb->query( $update_sql );
280
+ }
281
+
282
+ //Update 1.5.1
283
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_from_total'") != "question_from_total")
284
+ {
285
+ $sql = "ALTER TABLE ".$table_name." ADD question_from_total INT NOT NULL AFTER comment_section";
286
+ $results = $wpdb->query( $sql );
287
+ $update_sql = "UPDATE ".$table_name." SET question_from_total=0";
288
+ $results = $wpdb->query( $update_sql );
289
+ }
290
+
291
+ //Update 1.6.1
292
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'total_user_tries'") != "total_user_tries")
293
+ {
294
+ $sql = "ALTER TABLE ".$table_name." ADD total_user_tries INT NOT NULL AFTER question_from_total";
295
+ $results = $wpdb->query( $sql );
296
+ $update_sql = "UPDATE ".$table_name." SET total_user_tries=0";
297
+ $results = $wpdb->query( $update_sql );
298
+ }
299
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'total_user_tries_text'") != "total_user_tries_text")
300
+ {
301
+ $sql = "ALTER TABLE ".$table_name." ADD total_user_tries_text TEXT NOT NULL AFTER total_user_tries";
302
+ $results = $wpdb->query( $sql );
303
+ $update_sql = "UPDATE ".$table_name." SET total_user_tries_text='Enter Your Text Here'";
304
+ $results = $wpdb->query( $update_sql );
305
+ }
306
+
307
+ //Update 1.8.1
308
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'message_end_template'") != "message_end_template")
309
+ {
310
+ $sql = "ALTER TABLE ".$table_name." ADD message_end_template TEXT NOT NULL AFTER message_comment";
311
+ $results = $wpdb->query( $sql );
312
+ $update_sql = "UPDATE ".$table_name." SET message_end_template=''";
313
+ $results = $wpdb->query( $update_sql );
314
+ }
315
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'certificate_template'") != "certificate_template")
316
+ {
317
+ $sql = "ALTER TABLE ".$table_name." ADD certificate_template TEXT NOT NULL AFTER total_user_tries_text";
318
+ $results = $wpdb->query( $sql );
319
+ $update_sql = "UPDATE ".$table_name." SET certificate_template='Enter your text here!'";
320
+ $results = $wpdb->query( $update_sql );
321
+ }
322
+
323
+ //Update 1.9.1
324
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'social_media'") != "social_media")
325
+ {
326
+ $sql = "ALTER TABLE ".$table_name." ADD social_media INT NOT NULL AFTER certificate_template";
327
+ $results = $wpdb->query( $sql );
328
+ $update_sql = "UPDATE ".$table_name." SET social_media='0'";
329
+ $results = $wpdb->query( $update_sql );
330
+ }
331
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'social_media_text'") != "social_media_text")
332
+ {
333
+ $sql = "ALTER TABLE ".$table_name." ADD social_media_text TEXT NOT NULL AFTER social_media";
334
+ $results = $wpdb->query( $sql );
335
+ $update_sql = "UPDATE ".$table_name." SET social_media_text='I just score a %CORRECT_SCORE%% on %QUIZ_NAME%!'";
336
+ $results = $wpdb->query( $update_sql );
337
+ }
338
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'pagination'") != "pagination")
339
+ {
340
+ $sql = "ALTER TABLE ".$table_name." ADD pagination INT NOT NULL AFTER social_media_text";
341
+ $results = $wpdb->query( $sql );
342
+ $update_sql = "UPDATE ".$table_name." SET pagination=0";
343
+ $results = $wpdb->query( $update_sql );
344
+ }
345
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'pagination_text'") != "pagination_text")
346
+ {
347
+ $sql = "ALTER TABLE ".$table_name." ADD pagination_text TEXT NOT NULL AFTER pagination";
348
+ $results = $wpdb->query( $sql );
349
+ $update_sql = "UPDATE ".$table_name." SET pagination_text='Next'";
350
+ $results = $wpdb->query( $update_sql );
351
+ }
352
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'timer_limit'") != "timer_limit")
353
+ {
354
+ $sql = "ALTER TABLE ".$table_name." ADD timer_limit INT NOT NULL AFTER pagination_text";
355
+ $results = $wpdb->query( $sql );
356
+ $update_sql = "UPDATE ".$table_name." SET timer_limit=0";
357
+ $results = $wpdb->query( $update_sql );
358
+ }
359
+
360
+ //Update 2.1.1
361
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'quiz_stye'") != "quiz_stye")
362
+ {
363
+ $sql = "ALTER TABLE ".$table_name." ADD quiz_stye TEXT NOT NULL AFTER timer_limit";
364
+ $results = $wpdb->query( $sql );
365
+ $mlw_style_default = "
366
+ div.mlw_qmn_quiz input[type=radio],
367
+ div.mlw_qmn_quiz input[type=submit],
368
+ div.mlw_qmn_quiz label {
369
+ cursor: pointer;
370
+ }
371
+ div.mlw_qmn_quiz input:not([type=submit]):focus,
372
+ div.mlw_qmn_quiz textarea:focus {
373
+ background: #eaeaea;
374
+ }
375
+ div.mlw_qmn_quiz {
376
+ text-align: left;
377
+ }
378
+ div.quiz_section {
379
+
380
+ }
381
+ div.mlw_qmn_timer {
382
+ position:fixed;
383
+ top:200px;
384
+ right:0px;
385
+ width:130px;
386
+ color:#00CCFF;
387
+ border-radius: 15px;
388
+ background:#000000;
389
+ text-align: center;
390
+ padding: 15px 15px 15px 15px
391
+ }
392
+ div.mlw_qmn_quiz input[type=submit],
393
+ a.mlw_qmn_quiz_link
394
+ {
395
+ border-radius: 4px;
396
+ position: relative;
397
+ background-image: linear-gradient(#fff,#dedede);
398
+ background-color: #eee;
399
+ border: #ccc solid 1px;
400
+ color: #333;
401
+ text-shadow: 0 1px 0 rgba(255,255,255,.5);
402
+ box-sizing: border-box;
403
+ display: inline-block;
404
+ padding: 5px 5px 5px 5px;
405
+ margin: auto;
406
+ }";
407
+ $update_sql = "UPDATE ".$table_name." SET quiz_stye='".$mlw_style_default."'";
408
+ $results = $wpdb->query( $update_sql );
409
+ }
410
+
411
+ //Update 2.2.1
412
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_numbering'") != "question_numbering")
413
+ {
414
+ $sql = "ALTER TABLE ".$table_name." ADD question_numbering INT NOT NULL AFTER quiz_stye";
415
+ $results = $wpdb->query( $sql );
416
+ $update_sql = "UPDATE ".$table_name." SET question_numbering='0'";
417
+ $results = $wpdb->query( $update_sql );
418
+ }
419
+
420
+ //Update 2.8.1
421
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'quiz_settings'") != "quiz_settings")
422
+ {
423
+ $sql = "ALTER TABLE ".$table_name." ADD quiz_settings TEXT NOT NULL AFTER question_numbering";
424
+ $results = $wpdb->query( $sql );
425
+ $update_sql = "UPDATE ".$table_name." SET quiz_settings=''";
426
+ $results = $wpdb->query( $update_sql );
427
+ }
428
+
429
+ //Update 3.0.1
430
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'theme_selected'") != "theme_selected")
431
+ {
432
+ $sql = "ALTER TABLE ".$table_name." ADD theme_selected TEXT NOT NULL AFTER quiz_settings";
433
+ $results = $wpdb->query( $sql );
434
+ $update_sql = "UPDATE ".$table_name." SET theme_selected='default'";
435
+ $results = $wpdb->query( $update_sql );
436
+ }
437
+
438
+ //Update 3.3.1
439
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'last_activity'") != "last_activity")
440
+ {
441
+ $sql = "ALTER TABLE ".$table_name." ADD last_activity DATETIME NOT NULL AFTER theme_selected";
442
+ $results = $wpdb->query( $sql );
443
+ $update_sql = "UPDATE ".$table_name." SET last_activity='".date("Y-m-d H:i:s")."'";
444
+ $results = $wpdb->query( $update_sql );
445
+ }
446
+
447
+ //Update 3.5.1
448
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'require_log_in'") != "require_log_in")
449
+ {
450
+ $sql = "ALTER TABLE ".$table_name." ADD require_log_in INT NOT NULL AFTER last_activity";
451
+ $results = $wpdb->query( $sql );
452
+ $update_sql = "UPDATE ".$table_name." SET require_log_in='0'";
453
+ $results = $wpdb->query( $update_sql );
454
+ }
455
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'require_log_in_text'") != "require_log_in_text")
456
+ {
457
+ $sql = "ALTER TABLE ".$table_name." ADD require_log_in_text TEXT NOT NULL AFTER require_log_in";
458
+ $results = $wpdb->query( $sql );
459
+ $update_sql = "UPDATE ".$table_name." SET require_log_in_text='Enter Text Here'";
460
+ $results = $wpdb->query( $update_sql );
461
+ }
462
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'limit_total_entries'") != "limit_total_entries")
463
+ {
464
+ $sql = "ALTER TABLE ".$table_name." ADD limit_total_entries INT NOT NULL AFTER require_log_in_text";
465
+ $results = $wpdb->query( $sql );
466
+ $update_sql = "UPDATE ".$table_name." SET limit_total_entries='0'";
467
+ $results = $wpdb->query( $update_sql );
468
+ }
469
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'limit_total_entries_text'") != "limit_total_entries_text")
470
+ {
471
+ $sql = "ALTER TABLE ".$table_name." ADD limit_total_entries_text TEXT NOT NULL AFTER limit_total_entries";
472
+ $results = $wpdb->query( $sql );
473
+ $update_sql = "UPDATE ".$table_name." SET limit_total_entries_text='Enter Text Here'";
474
+ $results = $wpdb->query( $update_sql );
475
+ }
476
+
477
+ //Update 3.7.1
478
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'scheduled_timeframe'") != "scheduled_timeframe")
479
+ {
480
+ $sql = "ALTER TABLE ".$table_name." ADD scheduled_timeframe TEXT NOT NULL AFTER limit_total_entries_text";
481
+ $results = $wpdb->query( $sql );
482
+ $update_sql = "UPDATE ".$table_name." SET scheduled_timeframe=''";
483
+ $results = $wpdb->query( $update_sql );
484
+ }
485
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'scheduled_timeframe_text'") != "scheduled_timeframe_text")
486
+ {
487
+ $sql = "ALTER TABLE ".$table_name." ADD scheduled_timeframe_text TEXT NOT NULL AFTER scheduled_timeframe";
488
+ $results = $wpdb->query( $sql );
489
+ $update_sql = "UPDATE ".$table_name." SET scheduled_timeframe_text='Enter Text Here'";
490
+ $results = $wpdb->query( $update_sql );
491
+ }
492
+
493
+ //Update 4.3.0
494
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'disable_answer_onselect'") != "disable_answer_onselect")
495
+ {
496
+ $sql = "ALTER TABLE ".$table_name." ADD disable_answer_onselect INT NOT NULL AFTER scheduled_timeframe_text";
497
+ $results = $wpdb->query( $sql );
498
+ $update_sql = "UPDATE ".$table_name." SET disable_answer_onselect=0";
499
+ $results = $wpdb->query( $update_sql );
500
+ }
501
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'ajax_show_correct'") != "ajax_show_correct")
502
+ {
503
+ $sql = "ALTER TABLE ".$table_name." ADD ajax_show_correct INT NOT NULL AFTER disable_answer_onselect";
504
+ $results = $wpdb->query( $sql );
505
+ $update_sql = "UPDATE ".$table_name." SET ajax_show_correct=0";
506
+ $results = $wpdb->query( $update_sql );
507
+ }
508
+
509
+ global $wpdb;
510
+ $table_name = $wpdb->prefix . "mlw_questions";
511
+ //Update 0.5
512
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'comments'") != "comments")
513
+ {
514
+ $sql = "ALTER TABLE ".$table_name." ADD comments INT NOT NULL AFTER correct_answer";
515
+ $results = $wpdb->query( $sql );
516
+ $sql = "ALTER TABLE ".$table_name." ADD hints TEXT NOT NULL AFTER comments";
517
+ $results = $wpdb->query( $sql );
518
+ $update_sql = "UPDATE ".$table_name." SET comments=1, hints=''";
519
+ $results = $wpdb->query( $update_sql );
520
+ }
521
+ //Update 0.8
522
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_order'") != "question_order")
523
+ {
524
+ $sql = "ALTER TABLE ".$table_name." ADD question_order INT NOT NULL AFTER hints";
525
+ $results = $wpdb->query( $sql );
526
+ $update_sql = "UPDATE ".$table_name." SET question_order=0";
527
+ $results = $wpdb->query( $update_sql );
528
+ }
529
+
530
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_type'") != "question_type")
531
+ {
532
+ $sql = "ALTER TABLE ".$table_name." ADD question_type INT NOT NULL AFTER question_order";
533
+ $results = $wpdb->query( $sql );
534
+ $update_sql = "UPDATE ".$table_name." SET question_type=0";
535
+ $results = $wpdb->query( $update_sql );
536
+ }
537
+
538
+ //Update 1.1.1
539
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_answer_info'") != "question_answer_info")
540
+ {
541
+ $sql = "ALTER TABLE ".$table_name." ADD question_answer_info TEXT NOT NULL AFTER correct_answer";
542
+ $results = $wpdb->query( $sql );
543
+ $update_sql = "UPDATE ".$table_name." SET question_answer_info=''";
544
+ $results = $wpdb->query( $update_sql );
545
+ }
546
+
547
+ //Update 2.5.1
548
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'answer_array'") != "answer_array")
549
+ {
550
+ $sql = "ALTER TABLE ".$table_name." ADD answer_array TEXT NOT NULL AFTER question_name";
551
+ $results = $wpdb->query( $sql );
552
+ $update_sql = "UPDATE ".$table_name." SET answer_array=''";
553
+ $results = $wpdb->query( $update_sql );
554
+ }
555
+
556
+ //Update 3.1.1
557
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_settings'") != "question_settings")
558
+ {
559
+ $sql = "ALTER TABLE ".$table_name." ADD question_settings TEXT NOT NULL AFTER question_type";
560
+ $results = $wpdb->query( $sql );
561
+ $update_sql = "UPDATE ".$table_name." SET question_settings=''";
562
+ $results = $wpdb->query( $update_sql );
563
+ }
564
+
565
+ //Update 4.0.0
566
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'category'") != "category")
567
+ {
568
+ $sql = "ALTER TABLE ".$table_name." ADD category TEXT NOT NULL AFTER question_settings";
569
+ $results = $wpdb->query( $sql );
570
+ $update_sql = "UPDATE ".$table_name." SET category=''";
571
+ $results = $wpdb->query( $update_sql );
572
+ }
573
+
574
+ //Update 4.0.0
575
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_type_new'") != "question_type_new")
576
+ {
577
+ $sql = "ALTER TABLE ".$table_name." ADD question_type_new TEXT NOT NULL AFTER question_type";
578
+ $results = $wpdb->query( $sql );
579
+ $update_sql = "UPDATE ".$table_name." SET question_type_new=question_type";
580
+ $results = $wpdb->query( $update_sql );
581
+ }
582
+
583
+ //Update 2.6.1
584
+ $results = $wpdb->query( "ALTER TABLE ".$wpdb->prefix . "mlw_qm_audit_trail CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;" );
585
+ $results = $wpdb->query( "ALTER TABLE ".$wpdb->prefix . "mlw_questions CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci" );
586
+ $results = $wpdb->query( "ALTER TABLE ".$wpdb->prefix . "mlw_quizzes CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci" );
587
+ $results = $wpdb->query( "ALTER TABLE ".$wpdb->prefix . "mlw_results CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci" );
588
+
589
+
590
+ global $wpdb;
591
+ $table_name = $wpdb->prefix . "mlw_results";
592
+ //Update 2.6.4
593
+ if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'user'") != "user")
594
+ {
595
+ $sql = "ALTER TABLE ".$table_name." ADD user INT NOT NULL AFTER phone";
596
+ $results = $wpdb->query( $sql );
597
+ $update_sql = "UPDATE ".$table_name." SET user=0";
598
+ $results = $wpdb->query( $update_sql );
599
+ }
600
+
601
+ // Update 4.8.0
602
+ if( $wpdb->get_var( "SHOW COLUMNS FROM $table_name LIKE 'user_ip'" ) != "user_ip" ) {
603
+ $sql = "ALTER TABLE $table_name ADD user_ip TEXT NOT NULL AFTER user";
604
+ $results = $wpdb->query( $sql );
605
+ $update_sql = "UPDATE $table_name SET user_ip='Unknown'";
606
+ $results = $wpdb->query( $update_sql );
607
+ }
608
+
609
+
610
+ update_option('mlw_quiz_master_version' , $data);
611
+ if(!isset($_GET['activate-multi']))
612
+ {
613
+ wp_safe_redirect( admin_url( 'index.php?page=mlw_qmn_about' ) );
614
+ exit;
615
+ }
616
+ }
617
+ if ( ! get_option('mlw_advert_shows'))
618
+ {
619
+ add_option('mlw_advert_shows' , 'true');
620
+ }
621
+ }
622
+
623
+ /**
624
+ * Adds new links to the plugin action links
625
+ *
626
+ * @since 4.7.1
627
+ */
628
+ public function plugin_action_links( $links ) {
629
+ $action_links = array(
630
+ 'settings' => '<a href="' . admin_url( 'admin.php?page=' . QSM_PLUGIN_BASENAME ) . '" title="' . esc_attr( __( 'Quizzes/Surveys', 'quiz-master-next' ) ) . '">' . __( 'Quizzes/Surveys', 'quiz-master-next' ) . '</a>',
631
+ );
632
+ return array_merge( $action_links, $links );
633
+ }
634
+
635
+ /**
636
+ * Adds new links to the plugin row meta
637
+ *
638
+ * @since 4.7.1
639
+ */
640
+ public function plugin_row_meta( $links, $file ) {
641
+ if ( $file == QSM_PLUGIN_BASENAME ) {
642
+ $row_meta = array(
643
+ 'docs' => '<a href="' . esc_url( 'http://quizandsurveymaster.com/documentation/?utm_source=plugin-row-meta&utm_medium=plugin&utm_campaign=qsm_plugin&utm_content=documentation' ) . '" title="' . esc_attr( __( 'View Documentation', 'quiz-master-next' ) ) . '">' . __( 'Documentation', 'quiz-master-next' ) . '</a>',
644
+ 'academy' => '<a href="' . esc_url( 'http://quizandsurveymaster.com/online-academy/?utm_source=plugin-row-meta&utm_medium=plugin&utm_campaign=qsm_plugin&utm_content=online_academy' ) . '" title="' . esc_attr( __( 'Watch Online Academy Videos', 'quiz-master-next' ) ) . '">' . __( 'Online Academy', 'quiz-master-next' ) . '</a>',
645
+ 'support' => '<a href="' . admin_url( 'admin.php?page=mlw_quiz_help' ) . '" title="' . esc_attr( __( 'Create Support Ticket', 'quiz-master-next' ) ) . '">' . __( 'Support', 'quiz-master-next' ) . '</a>',
646
+ );
647
+ return array_merge( $links, $row_meta );
648
+ }
649
+
650
+ return (array) $links;
651
+
652
+ }
653
+ }
654
+
655
+ $qsm_install = new QSM_Install();
656
+
657
+ ?>
php/install.php DELETED
@@ -1,157 +0,0 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit;
3
- /**
4
- * This is the install file for QMN. It installs all neccessary databases, pages, etc.
5
- *
6
- * @return void
7
- * @since 4.4.0
8
- */
9
- function mlw_quiz_activate()
10
- {
11
- global $wpdb;
12
- $charset_collate = $wpdb->get_charset_collate();
13
-
14
- $quiz_table_name = $wpdb->prefix . "mlw_quizzes";
15
- $question_table_name = $wpdb->prefix . "mlw_questions";
16
- $results_table_name = $wpdb->prefix . "mlw_results";
17
- $audit_table_name = $wpdb->prefix . "mlw_qm_audit_trail";
18
-
19
- if( $wpdb->get_var( "SHOW TABLES LIKE '$quiz_table_name'" ) != $quiz_table_name ) {
20
- $sql = "CREATE TABLE $quiz_table_name (
21
- quiz_id mediumint(9) NOT NULL AUTO_INCREMENT,
22
- quiz_name TEXT NOT NULL,
23
- message_before TEXT NOT NULL,
24
- message_after TEXT NOT NULL,
25
- message_comment TEXT NOT NULL,
26
- message_end_template TEXT NOT NULL,
27
- user_email_template TEXT NOT NULL,
28
- admin_email_template TEXT NOT NULL,
29
- submit_button_text TEXT NOT NULL,
30
- name_field_text TEXT NOT NULL,
31
- business_field_text TEXT NOT NULL,
32
- email_field_text TEXT NOT NULL,
33
- phone_field_text TEXT NOT NULL,
34
- comment_field_text TEXT NOT NULL,
35
- email_from_text TEXT NOT NULL,
36
- question_answer_template TEXT NOT NULL,
37
- leaderboard_template TEXT NOT NULL,
38
- system INT NOT NULL,
39
- randomness_order INT NOT NULL,
40
- loggedin_user_contact INT NOT NULL,
41
- show_score INT NOT NULL,
42
- send_user_email INT NOT NULL,
43
- send_admin_email INT NOT NULL,
44
- contact_info_location INT NOT NULL,
45
- user_name INT NOT NULL,
46
- user_comp INT NOT NULL,
47
- user_email INT NOT NULL,
48
- user_phone INT NOT NULL,
49
- admin_email TEXT NOT NULL,
50
- comment_section INT NOT NULL,
51
- question_from_total INT NOT NULL,
52
- total_user_tries INT NOT NULL,
53
- total_user_tries_text TEXT NOT NULL,
54
- certificate_template TEXT NOT NULL,
55
- social_media INT NOT NULL,
56
- social_media_text TEXT NOT NULL,
57
- pagination INT NOT NULL,
58
- pagination_text TEXT NOT NULL,
59
- timer_limit INT NOT NULL,
60
- quiz_stye TEXT NOT NULL,
61
- question_numbering INT NOT NULL,
62
- quiz_settings TEXT NOT NULL,
63
- theme_selected TEXT NOT NULL,
64
- last_activity DATETIME NOT NULL,
65
- require_log_in INT NOT NULL,
66
- require_log_in_text TEXT NOT NULL,
67
- limit_total_entries INT NOT NULL,
68
- limit_total_entries_text TEXT NOT NULL,
69
- scheduled_timeframe TEXT NOT NULL,
70
- scheduled_timeframe_text TEXT NOT NULL,
71
- disable_answer_onselect INT NOT NULL,
72
- ajax_show_correct INT NOT NULL,
73
- quiz_views INT NOT NULL,
74
- quiz_taken INT NOT NULL,
75
- deleted INT NOT NULL,
76
- PRIMARY KEY (quiz_id)
77
- ) $charset_collate;";
78
-
79
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
80
- dbDelta( $sql );
81
- }
82
-
83
- if( $wpdb->get_var( "SHOW TABLES LIKE '$question_table_name'" ) != $question_table_name ) {
84
- $sql = "CREATE TABLE $question_table_name (
85
- question_id mediumint(9) NOT NULL AUTO_INCREMENT,
86
- quiz_id INT NOT NULL,
87
- question_name TEXT NOT NULL,
88
- answer_array TEXT NOT NULL,
89
- answer_one TEXT NOT NULL,
90
- answer_one_points INT NOT NULL,
91
- answer_two TEXT NOT NULL,
92
- answer_two_points INT NOT NULL,
93
- answer_three TEXT NOT NULL,
94
- answer_three_points INT NOT NULL,
95
- answer_four TEXT NOT NULL,
96
- answer_four_points INT NOT NULL,
97
- answer_five TEXT NOT NULL,
98
- answer_five_points INT NOT NULL,
99
- answer_six TEXT NOT NULL,
100
- answer_six_points INT NOT NULL,
101
- correct_answer INT NOT NULL,
102
- question_answer_info TEXT NOT NULL,
103
- comments INT NOT NULL,
104
- hints TEXT NOT NULL,
105
- question_order INT NOT NULL,
106
- question_type INT NOT NULL,
107
- question_type_new TEXT NOT NULL,
108
- question_settings TEXT NOT NULL,
109
- category TEXT NOT NULL,
110
- deleted INT NOT NULL,
111
- PRIMARY KEY (question_id)
112
- ) $charset_collate;";
113
-
114
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
115
- dbDelta( $sql );
116
- }
117
-
118
- if( $wpdb->get_var( "SHOW TABLES LIKE '$results_table_name'" ) != $results_table_name ) {
119
- $sql = "CREATE TABLE $results_table_name (
120
- result_id mediumint(9) NOT NULL AUTO_INCREMENT,
121
- quiz_id INT NOT NULL,
122
- quiz_name TEXT NOT NULL,
123
- quiz_system INT NOT NULL,
124
- point_score INT NOT NULL,
125
- correct_score INT NOT NULL,
126
- correct INT NOT NULL,
127
- total INT NOT NULL,
128
- name TEXT NOT NULL,
129
- business TEXT NOT NULL,
130
- email TEXT NOT NULL,
131
- phone TEXT NOT NULL,
132
- user INT NOT NULL,
133
- time_taken TEXT NOT NULL,
134
- time_taken_real DATETIME NOT NULL,
135
- quiz_results TEXT NOT NULL,
136
- deleted INT NOT NULL,
137
- PRIMARY KEY (result_id)
138
- ) $charset_collate;";
139
-
140
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
141
- dbDelta( $sql );
142
- }
143
-
144
- if( $wpdb->get_var( "SHOW TABLES LIKE '$audit_table_name'" ) != $audit_table_name ) {
145
- $sql = "CREATE TABLE $audit_table_name (
146
- trail_id mediumint(9) NOT NULL AUTO_INCREMENT,
147
- action_user TEXT NOT NULL,
148
- action TEXT NOT NULL,
149
- time TEXT NOT NULL,
150
- PRIMARY KEY (trail_id)
151
- ) $charset_collate;";
152
-
153
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
154
- dbDelta( $sql );
155
- }
156
- }
157
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
php/options-page-certificate-tab.php CHANGED
@@ -60,23 +60,7 @@ function mlw_options_certificate_tab_content()
60
  if ( $update_results ) {
61
 
62
  $mlwQuizMasterNext->alertManager->newAlert(__('The certificate has been updated successfully.', 'quiz-master-next'), 'success');
63
-
64
- //Insert Action Into Audit Trail
65
- global $current_user;
66
- get_currentuserinfo();
67
- $wpdb->insert(
68
- $wpdb->prefix . "mlw_qm_audit_trail",
69
- array(
70
- 'action_user' => $current_user->display_name,
71
- 'action' => "Certificate Options Have Been Edited For Quiz Number $mlw_certificate_id",
72
- 'time' => date("h:i:s A m/d/Y")
73
- ),
74
- array(
75
- '%s',
76
- '%s',
77
- '%s'
78
- )
79
- );
80
  } else {
81
  $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');
82
  $mlwQuizMasterNext->log_manager->add("Error 0012", $wpdb->last_error.' from '.$wpdb->last_query, 0, 'error');
60
  if ( $update_results ) {
61
 
62
  $mlwQuizMasterNext->alertManager->newAlert(__('The certificate has been updated successfully.', 'quiz-master-next'), 'success');
63
+ $mlwQuizMasterNext->audit_manager->new_audit( "Certificate Options Have Been Edited For Quiz Number $mlw_certificate_id" );