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

Version Description

(January 2, 2018) = * Closed Bug: Quizzes/Surveys table not working on certain installs - (Issue #598)

Download this release

Release Info

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

Code changes from version 5.1.6 to 5.1.7

css/qsm-admin.css CHANGED
@@ -227,3 +227,26 @@ Help Page
227
  .quiz_email_support label {
228
  font-weight: bold;
229
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  .quiz_email_support label {
228
  font-weight: bold;
229
  }
230
+
231
+
232
+ /********************
233
+ Misc.
234
+ *********************/
235
+
236
+ .qsm-info-box {
237
+ display: block;
238
+ text-align:center;
239
+ background: #0d97d8;
240
+ border: 5px solid #1DD969;
241
+ color: #000;
242
+ font-weight: bold;
243
+ font-size: 14px;
244
+ }
245
+
246
+ .qsm-info-box p {
247
+ font-size: 14px;
248
+ }
249
+
250
+ .qsm-info-box a {
251
+ color: yellow;
252
+ }
js/qsm-admin.js CHANGED
@@ -12,13 +12,13 @@ var QSMQuizzesSurveys;
12
  });
13
  $( '#the-list tr' ).filter( ':even' ).addClass( 'alternate' );
14
  } else {
15
- var template = _.template( $( '#no-quiz-info-tmpl' ).html() );
16
  $( '.qsm-quizzes-page-content' ).hide();
17
  $( '#new_quiz_button' ).parent().after( template() );
18
  }
19
  },
20
  addQuizRow: function( quizData ) {
21
- var template = _.template( $( '#quiz-row-tmpl' ).html() );
22
  var values = {
23
  'id': quizData.id,
24
  'name': quizData.name,
12
  });
13
  $( '#the-list tr' ).filter( ':even' ).addClass( 'alternate' );
14
  } else {
15
+ var template = wp.template( 'no-quiz' );
16
  $( '.qsm-quizzes-page-content' ).hide();
17
  $( '#new_quiz_button' ).parent().after( template() );
18
  }
19
  },
20
  addQuizRow: function( quizData ) {
21
+ var template = wp.template( 'quiz-row' );
22
  var values = {
23
  'id': quizData.id,
24
  'name': quizData.name,
mlw_quizmaster2.php CHANGED
@@ -2,14 +2,14 @@
2
  /**
3
  * Plugin Name: Quiz And Survey Master
4
  * Description: Easily and quickly add quizzes and surveys to your website.
5
- * Version: 5.1.6
6
  * Author: Frank Corso
7
  * Author URI: https://www.quizandsurveymaster.com/
8
  * Plugin URI: https://www.quizandsurveymaster.com/
9
  * Text Domain: quiz-master-next
10
  *
11
  * @author Frank Corso
12
- * @version 5.1.6
13
  */
14
 
15
  if ( ! defined( 'ABSPATH' ) ) exit;
@@ -30,7 +30,7 @@ class MLWQuizMasterNext {
30
  * @var string
31
  * @since 4.0.0
32
  */
33
- public $version = '5.1.6';
34
 
35
  /**
36
  * QSM Alert Manager Object
2
  /**
3
  * Plugin Name: Quiz And Survey Master
4
  * Description: Easily and quickly add quizzes and surveys to your website.
5
+ * Version: 5.1.7
6
  * Author: Frank Corso
7
  * Author URI: https://www.quizandsurveymaster.com/
8
  * Plugin URI: https://www.quizandsurveymaster.com/
9
  * Text Domain: quiz-master-next
10
  *
11
  * @author Frank Corso
12
+ * @version 5.1.7
13
  */
14
 
15
  if ( ! defined( 'ABSPATH' ) ) exit;
30
  * @var string
31
  * @since 4.0.0
32
  */
33
+ public $version = '5.1.7';
34
 
35
  /**
36
  * QSM Alert Manager Object
php/about-page.php CHANGED
@@ -54,6 +54,7 @@ function mlw_generate_about_page() {
54
  </div>
55
  <div class="qsm-tab-content tab-2" style="display: none;">
56
  <h2>Changelog</h2>
 
57
  <?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 45 ); ?>
58
  <?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 44 ); ?>
59
  <?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 43 ); ?>
54
  </div>
55
  <div class="qsm-tab-content tab-2" style="display: none;">
56
  <h2>Changelog</h2>
57
+ <?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 47 ); ?>
58
  <?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 45 ); ?>
59
  <?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 44 ); ?>
60
  <?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 43 ); ?>
php/adverts-generate.php CHANGED
@@ -35,8 +35,7 @@ function mlw_qmn_show_adverts() {
35
  }
36
  $mlw_advert .= "
37
  <style>
38
- div.help_decide
39
- {
40
  display: block;
41
  text-align:center;
42
  background: #0d97d8;
@@ -44,8 +43,10 @@ function mlw_qmn_show_adverts() {
44
  color: #000;
45
  font-weight: bold;
46
  }
47
- div.help_decide a
48
- {
 
 
49
  color: yellow;
50
  }
51
  </style>";
35
  }
36
  $mlw_advert .= "
37
  <style>
38
+ div.help_decide {
 
39
  display: block;
40
  text-align:center;
41
  background: #0d97d8;
43
  color: #000;
44
  font-weight: bold;
45
  }
46
+ div.help_decide p {
47
+ font-size: 14px;
48
+ }
49
+ div.help_decide a {
50
  color: yellow;
51
  }
52
  </style>";
php/class-qmn-quiz-creator.php CHANGED
@@ -316,7 +316,7 @@ class QMNQuizCreator
316
  'question_numbering' => 0,
317
  'quiz_settings' => '',
318
  'theme_selected' => 'primary',
319
- 'last_activity' => date("Y-m-d H:i:s"),
320
  'require_log_in' => 0,
321
  'require_log_in_text' => 'This quiz is for logged in users only.',
322
  'limit_total_entries' => 0,
316
  'question_numbering' => 0,
317
  'quiz_settings' => '',
318
  'theme_selected' => 'primary',
319
+ 'last_activity' => current_time( 'mysql' ),
320
  'require_log_in' => 0,
321
  'require_log_in_text' => 'This quiz is for logged in users only.',
322
  'limit_total_entries' => 0,
php/class-qsm-fields.php CHANGED
@@ -57,12 +57,11 @@ class QSM_Fields {
57
 
58
  // Update the settings and show alert based on outcome
59
  $results = $mlwQuizMasterNext->pluginHelper->update_quiz_setting( $section, $settings_array );
60
- if ( false != $results ) {
61
- $mlwQuizMasterNext->alertManager->newAlert(__('The settings has been updated successfully.', 'quiz-master-next'), 'success');
62
- $mlwQuizMasterNext->audit_manager->new_audit( "Settings Have Been Edited" );
63
  } else {
64
- $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');
65
- $mlwQuizMasterNext->log_manager->add("Error 0008", $wpdb->last_error.' from '.$wpdb->last_query, 0, 'error');
66
  }
67
  }
68
 
57
 
58
  // Update the settings and show alert based on outcome
59
  $results = $mlwQuizMasterNext->pluginHelper->update_quiz_setting( $section, $settings_array );
60
+ if ( false !== $results ) {
61
+ $mlwQuizMasterNext->alertManager->newAlert( __( 'The settings has been updated successfully.', 'quiz-master-next' ), 'success' );
62
+ $mlwQuizMasterNext->audit_manager->new_audit( 'Settings Have Been Edited' );
63
  } else {
64
+ $mlwQuizMasterNext->alertManager->newAlert( __( 'There was an error when updating the settings. Please try again.', 'quiz-master-next' ), 'error');
 
65
  }
66
  }
67
 
php/class-qsm-settings.php CHANGED
@@ -174,65 +174,68 @@ class QSM_Quiz_Settings {
174
  }
175
  }
176
 
177
- /**
178
- * Updates a settings value, adding it if it didn't already exist
179
- *
180
- * @since 5.0.0
181
- * @param string $setting The name of the setting whose value we need to retrieve
182
- * @param mixed $value The value that needs to be stored for the setting
183
- * @return bool True if successful or false if fails
184
- */
185
- public function update_setting( $setting, $value ) {
186
-
187
- global $mlwQuizMasterNext;
188
-
189
- // Return if empty
190
- if ( empty( $setting ) ) {
191
- return false;
192
- }
193
-
194
- // Check if ID is not set, for backwards compatibility
195
- if ( ! $this->quiz_id ) {
196
- $quiz_id = $mlwQuizMasterNext->quizCreator->get_id();
197
-
198
- // If get_id doesn't work, return false
199
- if ( ! $quiz_id ) {
200
- return false;
201
- } else {
202
- $this->prepare_quiz( $quiz_id );
203
- }
204
- }
205
-
206
- $old_value = $this->get_setting( $setting );
207
 
208
- // If the old value and new value are the same, return false
209
- if ( $value === $old_value ) {
210
- return false;
211
- }
 
 
 
 
 
 
 
 
212
 
213
- // Try to serialize the value
214
- $serialized_value = maybe_serialize( $value );
215
 
216
- // Set the new value
217
- $this->settings[ $setting ] = $serialized_value;
 
 
218
 
219
- // Update the database
220
- global $wpdb;
221
- $serialized_settings = serialize( $this->settings );
222
- $results = $wpdb->update(
223
- $wpdb->prefix . "mlw_quizzes",
224
- array( 'quiz_settings' => $serialized_settings ),
225
- array( 'quiz_id' => $this->quiz_id ),
226
- array( '%s' ),
227
- array( '%d' )
228
- );
229
-
230
- if ( ! $results ) {
231
- return false;
232
- } else {
233
- return true;
234
- }
235
- }
 
 
 
 
 
 
 
236
 
237
  /**
238
  * Loads the settings for the quiz
174
  }
175
  }
176
 
177
+ /**
178
+ * Updates a settings value, adding it if it didn't already exist
179
+ *
180
+ * @since 5.0.0
181
+ * @param string $setting The name of the setting whose value we need to retrieve.
182
+ * @param mixed $value The value that needs to be stored for the setting.
183
+ * @return bool True if successful or false if fails
184
+ */
185
+ public function update_setting( $setting, $value ) {
186
+
187
+ global $mlwQuizMasterNext;
188
+
189
+ // Return if empty.
190
+ if ( empty( $setting ) ) {
191
+ $mlwQuizMasterNext->log_manager->add( 'Error when updating setting', 'Setting was empty with value equal to ' . print_r( $value, true ), 0, 'error' );
192
+ return false;
193
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
194
 
195
+ // Check if ID is not set, for backwards compatibility.
196
+ if ( ! $this->quiz_id ) {
197
+ $quiz_id = $mlwQuizMasterNext->quizCreator->get_id();
198
+
199
+ // If get_id doesn't work, return false.
200
+ if ( ! $quiz_id ) {
201
+ $mlwQuizMasterNext->log_manager->add( 'Error when updating setting', 'Quiz ID was not found', 0, 'error' );
202
+ return false;
203
+ } else {
204
+ $this->prepare_quiz( $quiz_id );
205
+ }
206
+ }
207
 
208
+ $old_value = $this->get_setting( $setting );
 
209
 
210
+ // If the old value and new value are the same, return false.
211
+ if ( $value === $old_value ) {
212
+ return true;
213
+ }
214
 
215
+ // Try to serialize the value.
216
+ $serialized_value = maybe_serialize( $value );
217
+
218
+ // Set the new value.
219
+ $this->settings[ $setting ] = $serialized_value;
220
+
221
+ // Update the database.
222
+ global $wpdb;
223
+ $serialized_settings = serialize( $this->settings );
224
+ $results = $wpdb->update(
225
+ $wpdb->prefix . 'mlw_quizzes',
226
+ array( 'quiz_settings' => $serialized_settings ),
227
+ array( 'quiz_id' => $this->quiz_id ),
228
+ array( '%s' ),
229
+ array( '%d' )
230
+ );
231
+
232
+ if ( false === $results ) {
233
+ $mlwQuizMasterNext->log_manager->add( 'Error when updating setting', $wpdb->last_error . ' from ' . $wpdb->last_query, 0, 'error' );
234
+ return false;
235
+ } else {
236
+ return true;
237
+ }
238
+ }
239
 
240
  /**
241
  * Loads the settings for the quiz
php/quizzes-page.php CHANGED
@@ -1,4 +1,10 @@
1
  <?php
 
 
 
 
 
 
2
  if ( ! defined( 'ABSPATH' ) ) exit;
3
 
4
  /**
@@ -8,61 +14,65 @@ if ( ! defined( 'ABSPATH' ) ) exit;
8
  */
9
  function qsm_generate_quizzes_surveys_page() {
10
 
11
- // Only let admins and editors see this page
12
  if ( ! current_user_can( 'moderate_comments' ) ) {
13
  return;
14
  }
15
 
16
- // Retrieve our globals
17
  global $wpdb;
18
  global $mlwQuizMasterNext;
19
 
20
- // Enqueue our styles and scripts
21
- wp_enqueue_style( 'qsm_admin_style', plugins_url( '../css/qsm-admin.css' , __FILE__ ) );
22
- wp_enqueue_script( 'qsm_admin_script', plugins_url( '../js/qsm-admin.js' , __FILE__ ), array( 'underscore', 'jquery-ui-core', 'jquery-ui-dialog', 'jquery-ui-button' ), $mlwQuizMasterNext->version );
23
  wp_enqueue_style( 'qsm_jquery_redmond_theme', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css' );
24
 
25
- // Create new quiz
26
  if ( isset( $_POST['qsm_new_quiz_nonce'] ) && wp_verify_nonce( $_POST['qsm_new_quiz_nonce'], 'qsm_new_quiz' ) ) {
27
- $quiz_name = htmlspecialchars( stripslashes( $_POST["quiz_name"] ), ENT_QUOTES );
28
  $mlwQuizMasterNext->quizCreator->create_quiz( $quiz_name );
29
  }
30
 
31
- // Delete quiz
32
  if ( isset( $_POST['qsm_delete_quiz_nonce'] ) && wp_verify_nonce( $_POST['qsm_delete_quiz_nonce'], 'qsm_delete_quiz' ) ) {
33
- $quiz_id = intval( $_POST["delete_quiz_id"] );
34
- $quiz_name = sanitize_text_field( $_POST["delete_quiz_name"] );
35
  $mlwQuizMasterNext->quizCreator->delete_quiz( $quiz_id, $quiz_name );
36
  }
37
 
38
- // Edit Quiz Name
39
  if ( isset( $_POST['qsm_edit_name_quiz_nonce'] ) && wp_verify_nonce( $_POST['qsm_edit_name_quiz_nonce'], 'qsm_edit_name_quiz' ) ) {
40
- $quiz_id = intval( $_POST["edit_quiz_id"] );
41
- $quiz_name = htmlspecialchars( stripslashes( $_POST["edit_quiz_name"] ), ENT_QUOTES );
42
  $mlwQuizMasterNext->quizCreator->edit_quiz_name( $quiz_id, $quiz_name );
43
  }
44
 
45
- // Duplicate Quiz
46
  if ( isset( $_POST['qsm_duplicate_quiz_nonce'] ) && wp_verify_nonce( $_POST['qsm_duplicate_quiz_nonce'], 'qsm_duplicate_quiz' ) ) {
47
- $quiz_id = intval( $_POST["duplicate_quiz_id"] );
48
- $quiz_name = htmlspecialchars( $_POST["duplicate_new_quiz_name"], ENT_QUOTES );
49
- $mlwQuizMasterNext->quizCreator->duplicate_quiz( $quiz_id, $quiz_name, isset( $_POST["duplicate_questions"] ) );
50
  }
51
 
52
- // Load our quizzes
53
  $quizzes = $mlwQuizMasterNext->pluginHelper->get_quizzes();
54
-
55
- // Load quiz posts
56
  $post_to_quiz_array = array();
57
- $my_query = new WP_Query( array( 'post_type' => 'quiz', 'posts_per_page' => -1, 'post_status' => 'publish' ) );
 
 
 
 
58
  if ( $my_query->have_posts() ) {
59
- while ( $my_query->have_posts() ) {
60
- $my_query->the_post();
61
  $post_to_quiz_array[ get_post_meta( get_the_ID(), 'quiz_id', true ) ] = array(
62
  'link' => get_permalink(),
63
- 'id' => get_the_ID()
64
  );
65
- }
66
  }
67
  wp_reset_postdata();
68
 
@@ -70,31 +80,31 @@ function qsm_generate_quizzes_surveys_page() {
70
  foreach ( $quizzes as $quiz ) {
71
  if ( ! isset( $post_to_quiz_array[ $quiz->quiz_id ] ) ) {
72
  $current_user = wp_get_current_user();
73
- $quiz_post = array(
74
- 'post_title' => $quiz->quiz_name,
75
- 'post_content' => "[qsm quiz={$quiz->quiz_id}]",
76
- 'post_status' => 'publish',
77
- 'post_author' => $current_user->ID,
78
- 'post_type' => 'quiz'
79
  );
80
  $quiz_post_id = wp_insert_post( $quiz_post );
81
  add_post_meta( $quiz_post_id, 'quiz_id', $quiz->quiz_id );
82
  $post_to_quiz_array[ $quiz->quiz_id ] = array(
83
  'link' => get_permalink( $quiz_post_id ),
84
- 'id' => $quiz_post_id
85
  );
86
  }
87
 
88
- $activity_date = date_i18n( get_option( 'date_format' ), strtotime( $quiz->last_activity ) );
89
- $activity_time = date( "h:i:s A", strtotime( $quiz->last_activity ) );
90
  $quiz_json_array[] = array(
91
- 'id' => $quiz->quiz_id,
92
- 'name' => esc_html( $quiz->quiz_name ),
93
- 'link' => $post_to_quiz_array[ $quiz->quiz_id ]['link'],
94
- 'postID' => $post_to_quiz_array[ $quiz->quiz_id ]['id'],
95
- 'views' => $quiz->quiz_views,
96
- 'taken' => $quiz->quiz_taken,
97
- 'lastActivity' => $activity_date . ' ' . $activity_time
98
  );
99
  }
100
  $total_count = count( $quiz_json_array );
@@ -103,6 +113,15 @@ function qsm_generate_quizzes_surveys_page() {
103
  <div class="wrap qsm-quizes-page">
104
  <h1><?php _e( 'Quizzes/Surveys', 'quiz-master-next' ); ?><a id="new_quiz_button" href="#" class="add-new-h2"><?php _e( 'Add New', 'quiz-master-next' ); ?></a></h1>
105
  <?php $mlwQuizMasterNext->alertManager->showAlerts(); ?>
 
 
 
 
 
 
 
 
 
106
  <div class="qsm-quizzes-page-content">
107
  <div class="<?php if ( 'false' != get_option( 'mlw_advert_shows' ) ) { echo 'qsm-quiz-page-wrapper-with-ads'; } else { echo 'qsm-quiz-page-wrapper'; } ?>">
108
  <p class="search-box">
@@ -160,24 +179,24 @@ function qsm_generate_quizzes_surveys_page() {
160
  if ( ! is_wp_error( $qmn_feed ) ) {
161
  $qmn_feed_items = $qmn_feed->get_items( 0, 5 );
162
  foreach ( $qmn_feed_items as $feed_item ) {
163
- $qmn_rss[] = array(
164
- 'link' => $feed_item->get_link(),
165
- 'title' => $feed_item->get_title(),
166
- 'description' => $feed_item->get_description(),
167
- 'date' => $feed_item->get_date( 'F j Y' ),
168
- 'author' => $feed_item->get_author()->get_name()
169
- );
170
  }
171
  }
172
- foreach( $qmn_rss as $item ) {
173
  ?>
174
  <div class="qsm-news-ads-widget">
175
- <h3><?php echo $item['title']; ?></h3>
176
- <p>By <?php echo $item['author']; ?></p>
177
  <div>
178
- <?php echo $item['description']; ?>
179
  </div>
180
- <a target='_blank' href="<?php echo $item['link']; ?>" class="button-primary"><?php _e( 'Read More' ); ?></a>
181
  </div>
182
  <?php
183
  }
@@ -191,7 +210,7 @@ function qsm_generate_quizzes_surveys_page() {
191
  <!--New Quiz Dialog-->
192
  <div id="new_quiz_dialog" title="<?php _e( 'Create New Quiz Or Survey', 'quiz-master-next' ); ?>" style="display:none;">
193
  <form action="" method="post" class="qsm-dialog-form">
194
- <?php wp_nonce_field( 'qsm_new_quiz','qsm_new_quiz_nonce' ); ?>
195
  <h3><?php _e( 'Create New Quiz Or Survey', 'quiz-master-next' ); ?></h3>
196
  <label><?php _e( 'Name', 'quiz-master-next' ); ?></label><input type="text" name="quiz_name" value="" />
197
  <p class='submit'><input type='submit' class='button-primary' value='<?php _e( 'Create', 'quiz-master-next' ); ?>' /></p>
@@ -204,7 +223,7 @@ function qsm_generate_quizzes_surveys_page() {
204
  <label><?php _e( 'Name', 'quiz-master-next' ); ?></label>
205
  <input type="text" id="edit_quiz_name" name="edit_quiz_name" />
206
  <input type="hidden" id="edit_quiz_id" name="edit_quiz_id" />
207
- <?php wp_nonce_field( 'qsm_edit_name_quiz','qsm_edit_name_quiz_nonce' ); ?>
208
  <p class='submit'><input type='submit' class='button-primary' value='<?php _e( 'Edit', 'quiz-master-next' ); ?>' /></p>
209
  </form>
210
  </div>
@@ -216,7 +235,7 @@ function qsm_generate_quizzes_surveys_page() {
216
  <br />
217
  <label for="duplicate_new_quiz_name"><?php _e( 'Name Of New Quiz Or Survey:', 'quiz-master-next' ); ?></label><input type="text" id="duplicate_new_quiz_name" name="duplicate_new_quiz_name" />
218
  <input type="hidden" id="duplicate_quiz_id" name="duplicate_quiz_id" />
219
- <?php wp_nonce_field( 'qsm_duplicate_quiz','qsm_duplicate_quiz_nonce' ); ?>
220
  <p class='submit'><input type='submit' class='button-primary' value='<?php _e( 'Duplicate', 'quiz-master-next' ); ?>' /></p>
221
  </form>
222
  </div>
@@ -225,7 +244,7 @@ function qsm_generate_quizzes_surveys_page() {
225
  <div id="delete_dialog" title="<?php _e( 'Delete', 'quiz-master-next' ); ?>" style="display:none;">
226
  <form action='' method='post' class="qsm-dialog-form">
227
  <h3><b><?php _e( 'Are you sure you want to delete this quiz or survey?', 'quiz-master-next' ); ?></b></h3>
228
- <?php wp_nonce_field( 'qsm_delete_quiz','qsm_delete_quiz_nonce' ); ?>
229
  <input type='hidden' id='delete_quiz_id' name='delete_quiz_id' value='' />
230
  <input type='hidden' id='delete_quiz_name' name='delete_quiz_name' value='' />
231
  <p class='submit'><input type='submit' class='button-primary' value='<?php _e( 'Delete', 'quiz-master-next' ); ?>' /></p>
@@ -233,35 +252,35 @@ function qsm_generate_quizzes_surveys_page() {
233
  </div>
234
 
235
  <!-- Templates -->
236
- <script type="text/template" id="no-quiz-info-tmpl">
237
  <h2><?php _e( 'You do not have any quizzes or surveys. Click "Add New" to get started.', 'quiz-master-next' ); ?></h2>
238
- <h2>Is this your first time using this plugin? Check out our <a href="https://quizandsurveymaster.com/documentation/?utm_source=qsm-quizzes-page&utm_medium=plugin&utm_campaign=qsm_plugin&utm_content=documentation" target="_blank">Documentation</a> or watch our Getting Started Video below</h2>
239
- <iframe width="560" height="315" src="https://www.youtube.com/embed/n8xfNk490Wg" frameborder="0" allowfullscreen></iframe>
240
  </script>
241
 
242
- <script type="text/template" id="quiz-row-tmpl">
243
- <tr class="qsm-quiz-row" data-id="<%= id %>">
244
  <td class="post-title column-title">
245
- <span class="qsm-quiz-name"><%= name %></span> <a class="qsm-edit-name" href="#"><?php _e( 'Edit Name', 'quiz-master-next' ); ?></a>
246
  <div class="row-actions">
247
- <a class="qsm-action-link" href="admin.php?page=mlw_quiz_options&&quiz_id=<%= id %>"><?php _e( 'Edit', 'quiz-master-next' ); ?></a> |
248
- <a class="qsm-action-link" href="admin.php?page=mlw_quiz_results&&quiz_id=<%= id %>"><?php _e( 'Results', 'quiz-master-next' ); ?></a> |
249
  <a class="qsm-action-link qsm-action-link-duplicate" href="#"><?php _e( 'Duplicate', 'quiz-master-next' ); ?></a> |
250
  <a class="qsm-action-link qsm-action-link-delete" href="#"><?php _e( 'Delete', 'quiz-master-next' ); ?></a>
251
  </div>
252
  </td>
253
  <td>
254
- <a href="<%= link %>"><?php _e( 'View Quiz/Survey', 'quiz-master-next' ); ?></a>
255
  <div class="row-actions">
256
- <a class="qsm-action-link" href="post.php?post=<%= postID %>&action=edit"><?php _e( 'Edit Post Settings', 'quiz-master-next' ); ?></a>
257
  </div>
258
  </td>
259
- <td>[qsm quiz=<%= id %>]</td>
260
- <td>[qsm_link id=<%= id %>]<?php _e( 'Click here', 'quiz-master-next' ); ?>[/qsm_link]</td>
261
- <td><%= views %></td>
262
- <td><%= taken %></td>
263
- <td><%= lastActivity %></td>
264
- </tr>
265
  </script>
266
  </div>
267
  <?php
1
  <?php
2
+ /**
3
+ * This file handles the contents on the "Quizzes/Surveys" page.
4
+ *
5
+ * @package QSM
6
+ */
7
+
8
  if ( ! defined( 'ABSPATH' ) ) exit;
9
 
10
  /**
14
  */
15
  function qsm_generate_quizzes_surveys_page() {
16
 
17
+ // Only let admins and editors see this page.
18
  if ( ! current_user_can( 'moderate_comments' ) ) {
19
  return;
20
  }
21
 
22
+ // Retrieve our globals.
23
  global $wpdb;
24
  global $mlwQuizMasterNext;
25
 
26
+ // Enqueue our styles and scripts.
27
+ wp_enqueue_style( 'qsm_admin_style', plugins_url( '../css/qsm-admin.css', __FILE__ ) );
28
+ wp_enqueue_script( 'qsm_admin_script', plugins_url( '../js/qsm-admin.js', __FILE__ ), array( 'wp-util', 'underscore', 'jquery-ui-core', 'jquery-ui-dialog', 'jquery-ui-button' ), $mlwQuizMasterNext->version );
29
  wp_enqueue_style( 'qsm_jquery_redmond_theme', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css' );
30
 
31
+ // Create new quiz.
32
  if ( isset( $_POST['qsm_new_quiz_nonce'] ) && wp_verify_nonce( $_POST['qsm_new_quiz_nonce'], 'qsm_new_quiz' ) ) {
33
+ $quiz_name = htmlspecialchars( stripslashes( $_POST['quiz_name'] ), ENT_QUOTES );
34
  $mlwQuizMasterNext->quizCreator->create_quiz( $quiz_name );
35
  }
36
 
37
+ // Delete quiz.
38
  if ( isset( $_POST['qsm_delete_quiz_nonce'] ) && wp_verify_nonce( $_POST['qsm_delete_quiz_nonce'], 'qsm_delete_quiz' ) ) {
39
+ $quiz_id = intval( $_POST['delete_quiz_id'] );
40
+ $quiz_name = sanitize_text_field( $_POST['delete_quiz_name'] );
41
  $mlwQuizMasterNext->quizCreator->delete_quiz( $quiz_id, $quiz_name );
42
  }
43
 
44
+ // Edit Quiz Name.
45
  if ( isset( $_POST['qsm_edit_name_quiz_nonce'] ) && wp_verify_nonce( $_POST['qsm_edit_name_quiz_nonce'], 'qsm_edit_name_quiz' ) ) {
46
+ $quiz_id = intval( $_POST['edit_quiz_id'] );
47
+ $quiz_name = htmlspecialchars( stripslashes( $_POST['edit_quiz_name'] ), ENT_QUOTES );
48
  $mlwQuizMasterNext->quizCreator->edit_quiz_name( $quiz_id, $quiz_name );
49
  }
50
 
51
+ // Duplicate Quiz.
52
  if ( isset( $_POST['qsm_duplicate_quiz_nonce'] ) && wp_verify_nonce( $_POST['qsm_duplicate_quiz_nonce'], 'qsm_duplicate_quiz' ) ) {
53
+ $quiz_id = intval( $_POST['duplicate_quiz_id'] );
54
+ $quiz_name = htmlspecialchars( $_POST['duplicate_new_quiz_name'], ENT_QUOTES );
55
+ $mlwQuizMasterNext->quizCreator->duplicate_quiz( $quiz_id, $quiz_name, isset( $_POST['duplicate_questions'] ) );
56
  }
57
 
58
+ // Load our quizzes.
59
  $quizzes = $mlwQuizMasterNext->pluginHelper->get_quizzes();
60
+
61
+ // Load quiz posts.
62
  $post_to_quiz_array = array();
63
+ $my_query = new WP_Query( array(
64
+ 'post_type' => 'quiz',
65
+ 'posts_per_page' => -1,
66
+ 'post_status' => 'publish',
67
+ ));
68
  if ( $my_query->have_posts() ) {
69
+ while ( $my_query->have_posts() ) {
70
+ $my_query->the_post();
71
  $post_to_quiz_array[ get_post_meta( get_the_ID(), 'quiz_id', true ) ] = array(
72
  'link' => get_permalink(),
73
+ 'id' => get_the_ID(),
74
  );
75
+ }
76
  }
77
  wp_reset_postdata();
78
 
80
  foreach ( $quizzes as $quiz ) {
81
  if ( ! isset( $post_to_quiz_array[ $quiz->quiz_id ] ) ) {
82
  $current_user = wp_get_current_user();
83
+ $quiz_post = array(
84
+ 'post_title' => $quiz->quiz_name,
85
+ 'post_content' => "[qsm quiz={$quiz->quiz_id}]",
86
+ 'post_status' => 'publish',
87
+ 'post_author' => $current_user->ID,
88
+ 'post_type' => 'quiz',
89
  );
90
  $quiz_post_id = wp_insert_post( $quiz_post );
91
  add_post_meta( $quiz_post_id, 'quiz_id', $quiz->quiz_id );
92
  $post_to_quiz_array[ $quiz->quiz_id ] = array(
93
  'link' => get_permalink( $quiz_post_id ),
94
+ 'id' => $quiz_post_id,
95
  );
96
  }
97
 
98
+ $activity_date = date_i18n( get_option( 'date_format' ), strtotime( $quiz->last_activity ) );
99
+ $activity_time = date( 'h:i:s A', strtotime( $quiz->last_activity ) );
100
  $quiz_json_array[] = array(
101
+ 'id' => $quiz->quiz_id,
102
+ 'name' => esc_html( $quiz->quiz_name ),
103
+ 'link' => $post_to_quiz_array[ $quiz->quiz_id ]['link'],
104
+ 'postID' => $post_to_quiz_array[ $quiz->quiz_id ]['id'],
105
+ 'views' => $quiz->quiz_views,
106
+ 'taken' => $quiz->quiz_taken,
107
+ 'lastActivity' => $activity_date . ' ' . $activity_time,
108
  );
109
  }
110
  $total_count = count( $quiz_json_array );
113
  <div class="wrap qsm-quizes-page">
114
  <h1><?php _e( 'Quizzes/Surveys', 'quiz-master-next' ); ?><a id="new_quiz_button" href="#" class="add-new-h2"><?php _e( 'Add New', 'quiz-master-next' ); ?></a></h1>
115
  <?php $mlwQuizMasterNext->alertManager->showAlerts(); ?>
116
+ <?php
117
+ if ( version_compare( PHP_VERSION, '5.4.0', '<' ) ) {
118
+ ?>
119
+ <div class="qsm-info-box">
120
+ <p>Your site is using PHP version <?php echo esc_html( PHP_VERSION ); ?>! Starting in QSM 6.0, your version of PHP will no longer be supported. <a href="http://bit.ly/2lyrrm8" target="_blank">Click here to learn more about QSM's minimum PHP version change.</a></p>
121
+ </div>
122
+ <?php
123
+ }
124
+ ?>
125
  <div class="qsm-quizzes-page-content">
126
  <div class="<?php if ( 'false' != get_option( 'mlw_advert_shows' ) ) { echo 'qsm-quiz-page-wrapper-with-ads'; } else { echo 'qsm-quiz-page-wrapper'; } ?>">
127
  <p class="search-box">
179
  if ( ! is_wp_error( $qmn_feed ) ) {
180
  $qmn_feed_items = $qmn_feed->get_items( 0, 5 );
181
  foreach ( $qmn_feed_items as $feed_item ) {
182
+ $qmn_rss[] = array(
183
+ 'link' => $feed_item->get_link(),
184
+ 'title' => $feed_item->get_title(),
185
+ 'description' => $feed_item->get_description(),
186
+ 'date' => $feed_item->get_date( 'F j Y' ),
187
+ 'author' => $feed_item->get_author()->get_name(),
188
+ );
189
  }
190
  }
191
+ foreach ( $qmn_rss as $item ) {
192
  ?>
193
  <div class="qsm-news-ads-widget">
194
+ <h3><?php echo esc_html( $item['title'] ); ?></h3>
195
+ <p>By <?php echo esc_html( $item['author'] ); ?></p>
196
  <div>
197
+ <?php echo esc_html( $item['description'] ); ?>
198
  </div>
199
+ <a target='_blank' href="<?php echo esc_attr( $item['link'] ); ?>" class="button-primary"><?php _e( 'Read More', 'quiz-master-next' ); ?></a>
200
  </div>
201
  <?php
202
  }
210
  <!--New Quiz Dialog-->
211
  <div id="new_quiz_dialog" title="<?php _e( 'Create New Quiz Or Survey', 'quiz-master-next' ); ?>" style="display:none;">
212
  <form action="" method="post" class="qsm-dialog-form">
213
+ <?php wp_nonce_field( 'qsm_new_quiz', 'qsm_new_quiz_nonce' ); ?>
214
  <h3><?php _e( 'Create New Quiz Or Survey', 'quiz-master-next' ); ?></h3>
215
  <label><?php _e( 'Name', 'quiz-master-next' ); ?></label><input type="text" name="quiz_name" value="" />
216
  <p class='submit'><input type='submit' class='button-primary' value='<?php _e( 'Create', 'quiz-master-next' ); ?>' /></p>
223
  <label><?php _e( 'Name', 'quiz-master-next' ); ?></label>
224
  <input type="text" id="edit_quiz_name" name="edit_quiz_name" />
225
  <input type="hidden" id="edit_quiz_id" name="edit_quiz_id" />
226
+ <?php wp_nonce_field( 'qsm_edit_name_quiz', 'qsm_edit_name_quiz_nonce' ); ?>
227
  <p class='submit'><input type='submit' class='button-primary' value='<?php _e( 'Edit', 'quiz-master-next' ); ?>' /></p>
228
  </form>
229
  </div>
235
  <br />
236
  <label for="duplicate_new_quiz_name"><?php _e( 'Name Of New Quiz Or Survey:', 'quiz-master-next' ); ?></label><input type="text" id="duplicate_new_quiz_name" name="duplicate_new_quiz_name" />
237
  <input type="hidden" id="duplicate_quiz_id" name="duplicate_quiz_id" />
238
+ <?php wp_nonce_field( 'qsm_duplicate_quiz', 'qsm_duplicate_quiz_nonce' ); ?>
239
  <p class='submit'><input type='submit' class='button-primary' value='<?php _e( 'Duplicate', 'quiz-master-next' ); ?>' /></p>
240
  </form>
241
  </div>
244
  <div id="delete_dialog" title="<?php _e( 'Delete', 'quiz-master-next' ); ?>" style="display:none;">
245
  <form action='' method='post' class="qsm-dialog-form">
246
  <h3><b><?php _e( 'Are you sure you want to delete this quiz or survey?', 'quiz-master-next' ); ?></b></h3>
247
+ <?php wp_nonce_field( 'qsm_delete_quiz', 'qsm_delete_quiz_nonce' ); ?>
248
  <input type='hidden' id='delete_quiz_id' name='delete_quiz_id' value='' />
249
  <input type='hidden' id='delete_quiz_name' name='delete_quiz_name' value='' />
250
  <p class='submit'><input type='submit' class='button-primary' value='<?php _e( 'Delete', 'quiz-master-next' ); ?>' /></p>
252
  </div>
253
 
254
  <!-- Templates -->
255
+ <script type="text/template" id="tmpl-no-quiz">
256
  <h2><?php _e( 'You do not have any quizzes or surveys. Click "Add New" to get started.', 'quiz-master-next' ); ?></h2>
257
+ <h2>Is this your first time using this plugin? Check out our <a href="https://quizandsurveymaster.com/documentation/?utm_source=qsm-quizzes-page&utm_medium=plugin&utm_campaign=qsm_plugin&utm_content=documentation" target="_blank">Documentation</a> or watch our Getting Started Video below</h2>
258
+ <iframe width="560" height="315" src="https://www.youtube.com/embed/n8xfNk490Wg" frameborder="0" allowfullscreen></iframe>
259
  </script>
260
 
261
+ <script type="text/template" id="tmpl-quiz-row">
262
+ <tr class="qsm-quiz-row" data-id="{{ data.id }}">
263
  <td class="post-title column-title">
264
+ <span class="qsm-quiz-name">{{ data.name }}</span> <a class="qsm-edit-name" href="#"><?php _e( 'Edit Name', 'quiz-master-next' ); ?></a>
265
  <div class="row-actions">
266
+ <a class="qsm-action-link" href="admin.php?page=mlw_quiz_options&&quiz_id={{ data.id }}"><?php _e( 'Edit', 'quiz-master-next' ); ?></a> |
267
+ <a class="qsm-action-link" href="admin.php?page=mlw_quiz_results&&quiz_id={{ data.id }}"><?php _e( 'Results', 'quiz-master-next' ); ?></a> |
268
  <a class="qsm-action-link qsm-action-link-duplicate" href="#"><?php _e( 'Duplicate', 'quiz-master-next' ); ?></a> |
269
  <a class="qsm-action-link qsm-action-link-delete" href="#"><?php _e( 'Delete', 'quiz-master-next' ); ?></a>
270
  </div>
271
  </td>
272
  <td>
273
+ <a href="{{ data.link }}"><?php _e( 'View Quiz/Survey', 'quiz-master-next' ); ?></a>
274
  <div class="row-actions">
275
+ <a class="qsm-action-link" href="post.php?post={{ data.postID }}&action=edit"><?php _e( 'Edit Post Settings', 'quiz-master-next' ); ?></a>
276
  </div>
277
  </td>
278
+ <td>[qsm quiz={{ data.id }}]</td>
279
+ <td>[qsm_link id={{ data.id }}]<?php _e( 'Click here', 'quiz-master-next' ); ?>[/qsm_link]</td>
280
+ <td>{{ data.views }}</td>
281
+ <td>{{ data.taken }}</td>
282
+ <td>{{ data.lastActivity }}</td>
283
+ </tr>
284
  </script>
285
  </div>
286
  <?php
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: quiz, survey, lead, test, score, exam, questionnaire, answer, question
4
  Requires at least: 4.8
5
  Tested up to: 4.9
6
  Requires PHP: 5.2
7
- Stable tag: 5.1.6
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -110,6 +110,9 @@ This is usually a theme conflict. You can [checkout out our common conflict solu
110
 
111
  == Changelog ==
112
 
 
 
 
113
  = 5.1.6 (December 25, 2017) =
114
  * Closed Bug: Timezone ID '' is invalid - ([Issue #606](https://github.com/fpcorso/quiz_master_next/issues/606))
115
  * Closed Bug: Required contact fields not working correctly when the loggedin_user_contact option is set to no - ([Issue #603](https://github.com/fpcorso/quiz_master_next/issues/603))
4
  Requires at least: 4.8
5
  Tested up to: 4.9
6
  Requires PHP: 5.2
7
+ Stable tag: 5.1.7
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
110
 
111
  == Changelog ==
112
 
113
+ = 5.1.7 (January 2, 2018) =
114
+ * Closed Bug: Quizzes/Surveys table not working on certain installs - ([Issue #598](https://github.com/fpcorso/quiz_master_next/issues/598))
115
+
116
  = 5.1.6 (December 25, 2017) =
117
  * Closed Bug: Timezone ID '' is invalid - ([Issue #606](https://github.com/fpcorso/quiz_master_next/issues/606))
118
  * Closed Bug: Required contact fields not working correctly when the loggedin_user_contact option is set to no - ([Issue #603](https://github.com/fpcorso/quiz_master_next/issues/603))