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

Version Description

(December 26, 2018) = * Adds new Gutenberg blocks * Fixes undefined access at delete_question static function (Thanks bpanatta!

Download this release

Release Info

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

Code changes from version 6.0.4 to 6.1.0

blocks/block.js ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ var el = wp.element.createElement,
3
+ registerBlockType = wp.blocks.registerBlockType,
4
+ ServerSideRender = wp.components.ServerSideRender,
5
+ TextControl = wp.components.TextControl,
6
+ InspectorControls = wp.editor.InspectorControls;
7
+
8
+ /*
9
+ * Registers the main QSM block
10
+ */
11
+ registerBlockType( 'qsm/main-block', {
12
+ title: 'QSM Block',
13
+ icon: 'feedback',
14
+ category: 'widgets',
15
+
16
+ edit: function( props ) {
17
+ return [
18
+ /*
19
+ * The ServerSideRender element uses the REST API to automatically call
20
+ * php_block_render() in your PHP code whenever it needs to get an updated
21
+ * view of the block.
22
+ */
23
+ el( ServerSideRender, {
24
+ block: 'qsm/main-block',
25
+ attributes: props.attributes,
26
+ } ),
27
+
28
+ el( InspectorControls, {},
29
+ el( TextControl, {
30
+ label: 'Quiz/Survey ID',
31
+ value: props.attributes.quiz,
32
+ onChange: ( value ) => { props.setAttributes( { quiz: value } ); },
33
+ } )
34
+ ),
35
+ ];
36
+ },
37
+
38
+ // We're going to be rendering in PHP, so save() can just return null.
39
+ save: function() {
40
+ return null;
41
+ },
42
+ } );
blocks/block.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Converts our main shortcode to a simple Gutenberg block.
4
+ * Uses ServerSideRender for now. Need to create a better block soon.
5
+ *
6
+ * Heavily built upon the GPL demo block: https://gist.github.com/pento/cf38fd73ce0f13fcf0f0ae7d6c4b685d
7
+ *
8
+ * @package QSM
9
+ */
10
+
11
+ /**
12
+ * Register our block.
13
+ */
14
+ function qsm_block_init() {
15
+ // Register our block editor script.
16
+ wp_register_script(
17
+ 'qsm-quiz-block',
18
+ plugins_url( 'block.js', __FILE__ ),
19
+ array( 'wp-blocks', 'wp-element', 'wp-components', 'wp-editor' )
20
+ );
21
+ // Register our block, and explicitly define the attributes we accept.
22
+ register_block_type( 'qsm/main-block', array(
23
+ 'attributes' => array(
24
+ 'quiz' => array(
25
+ 'type' => 'string',
26
+ ),
27
+ ),
28
+ 'editor_script' => 'qsm-quiz-block',
29
+ 'render_callback' => 'qsm_block_render',
30
+ ) );
31
+ }
32
+ add_action( 'init', 'qsm_block_init' );
33
+
34
+ /**
35
+ * The block renderer.
36
+ *
37
+ * This simply calls our main shortcode renderer.
38
+ *
39
+ * @param array $attributes The attributes that were set on the block.
40
+ */
41
+ function qsm_block_render( $attributes ) {
42
+ global $qmnQuizManager;
43
+ return $qmnQuizManager->display_shortcode( $attributes );
44
+ }
blocks/index.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ // Silence is golden...
3
+ ?>
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: 6.0.4
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 6.0.4
13
  * @package QSM
14
  */
15
 
@@ -33,7 +33,7 @@ class MLWQuizMasterNext {
33
  * @var string
34
  * @since 4.0.0
35
  */
36
- public $version = '6.0.4';
37
 
38
  /**
39
  * QSM Alert Manager Object
@@ -149,6 +149,7 @@ class MLWQuizMasterNext {
149
  include 'php/question-types.php';
150
  include 'php/default-templates.php';
151
  include 'php/shortcodes.php';
 
152
 
153
  include 'php/classes/class-qmn-alert-manager.php';
154
  $this->alertManager = new MlwQmnAlertManager();
2
  /**
3
  * Plugin Name: Quiz And Survey Master
4
  * Description: Easily and quickly add quizzes and surveys to your website.
5
+ * Version: 6.1.0
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 6.1.0
13
  * @package QSM
14
  */
15
 
33
  * @var string
34
  * @since 4.0.0
35
  */
36
+ public $version = '6.1.0';
37
 
38
  /**
39
  * QSM Alert Manager Object
149
  include 'php/question-types.php';
150
  include 'php/default-templates.php';
151
  include 'php/shortcodes.php';
152
+ include 'blocks/block.php';
153
 
154
  include 'php/classes/class-qmn-alert-manager.php';
155
  $this->alertManager = new MlwQmnAlertManager();
php/classes/class-qmn-plugin-helper.php CHANGED
@@ -80,12 +80,25 @@ class QMNPluginHelper {
80
 
81
  /**
82
  * Calls all class functions to initialize quiz
 
 
 
83
  */
84
  public function prepare_quiz( $quiz_id ) {
85
  $quiz_id = intval( $quiz_id );
 
 
 
 
 
 
 
 
86
  global $mlwQuizMasterNext;
87
  $mlwQuizMasterNext->quizCreator->set_id( $quiz_id );
88
- $mlwQuizMasterNext->quiz_settings->prepare_quiz( intval( $quiz_id ) );
 
 
89
  }
90
 
91
  /**
80
 
81
  /**
82
  * Calls all class functions to initialize quiz
83
+ *
84
+ * @param int $quiz_id The ID of the quiz or survey to load.
85
+ * @return bool True or False if ID is valid.
86
  */
87
  public function prepare_quiz( $quiz_id ) {
88
  $quiz_id = intval( $quiz_id );
89
+
90
+ // Tries to load quiz name to ensure this is a valid ID.
91
+ global $wpdb;
92
+ $quiz_name = $wpdb->get_var( $wpdb->prepare( "SELECT quiz_name FROM {$wpdb->prefix}mlw_quizzes WHERE quiz_id=%d LIMIT 1", $quiz_id ) );
93
+ if ( is_null( $quiz_name ) ) {
94
+ return false;
95
+ }
96
+
97
  global $mlwQuizMasterNext;
98
  $mlwQuizMasterNext->quizCreator->set_id( $quiz_id );
99
+ $mlwQuizMasterNext->quiz_settings->prepare_quiz( $quiz_id );
100
+
101
+ return True;
102
  }
103
 
104
  /**
php/classes/class-qmn-quiz-manager.php CHANGED
@@ -71,7 +71,10 @@ class QMNQuizManager {
71
  global $qmn_json_data;
72
  $qmn_json_data = array();
73
  $qmn_allowed_visit = true;
74
- $mlwQuizMasterNext->pluginHelper->prepare_quiz( $quiz );
 
 
 
75
  $question_amount = intval( $question_amount );
76
 
77
  // Legacy variable.
@@ -1472,6 +1475,7 @@ class QMNQuizManager {
1472
  return $ip;
1473
  }
1474
  }
 
1475
  $qmnQuizManager = new QMNQuizManager();
1476
 
1477
  add_filter('qmn_begin_shortcode', 'qmn_require_login_check', 10, 3);
71
  global $qmn_json_data;
72
  $qmn_json_data = array();
73
  $qmn_allowed_visit = true;
74
+ $success = $mlwQuizMasterNext->pluginHelper->prepare_quiz( $quiz );
75
+ if ( false === $success ) {
76
+ return __( 'It appears that this quiz is not set up correctly', 'quiz-master-next' );
77
+ }
78
  $question_amount = intval( $question_amount );
79
 
80
  // Legacy variable.
1475
  return $ip;
1476
  }
1477
  }
1478
+ global $qmnQuizManager;
1479
  $qmnQuizManager = new QMNQuizManager();
1480
 
1481
  add_filter('qmn_begin_shortcode', 'qmn_require_login_check', 10, 3);
php/classes/class-qsm-questions.php CHANGED
@@ -194,6 +194,8 @@ class QSM_Questions {
194
  * @return bool True if successful
195
  */
196
  public static function delete_question( $question_id ) {
 
 
197
  $results = $wpdb->update(
198
  $wpdb->prefix . 'mlw_questions',
199
  array(
194
  * @return bool True if successful
195
  */
196
  public static function delete_question( $question_id ) {
197
+ global $wpdb;
198
+
199
  $results = $wpdb->update(
200
  $wpdb->prefix . 'mlw_questions',
201
  array(
php/classes/class-qsm-settings.php CHANGED
@@ -248,7 +248,11 @@ class QSM_Quiz_Settings {
248
  $settings_array = array();
249
 
250
  // Loads the settings from the database
251
- $settings = $wpdb->get_var( $wpdb->prepare( "SELECT quiz_settings FROM {$wpdb->prefix}mlw_quizzes WHERE quiz_id=%d", $this->quiz_id ) );
 
 
 
 
252
 
253
  // Unserializes array
254
  if ( is_serialized( $settings ) && is_array( @unserialize( $settings ) ) ) {
248
  $settings_array = array();
249
 
250
  // Loads the settings from the database
251
+ $settings = $wpdb->get_var( $wpdb->prepare( "SELECT quiz_settings FROM {$wpdb->prefix}mlw_quizzes WHERE quiz_id=%d", $this->quiz_id ) );
252
+
253
+ if ( is_null( $settings ) ) {
254
+ return;
255
+ }
256
 
257
  // Unserializes array
258
  if ( is_serialized( $settings ) && is_array( @unserialize( $settings ) ) ) {
php/classes/index.php CHANGED
@@ -1,4 +1,3 @@
1
  <?php
2
-
3
- die("Error: Unauthorized Access");
4
  ?>
1
  <?php
2
+ // Silence is golden...
 
3
  ?>
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Quiz And Survey Master (Formerly Quiz Master Next) ===
2
  Contributors: fpcorso
3
  Tags: quiz, survey, lead, test, score, exam, questionnaire, question
4
- Requires at least: 4.8
5
- Tested up to: 4.9
6
  Requires PHP: 5.4
7
- Stable tag: 6.0.4
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -111,6 +111,10 @@ This is usually a theme conflict. You can [checkout out our common conflict solu
111
 
112
  == Changelog ==
113
 
 
 
 
 
114
  = 6.0.4 (October 2, 2018) =
115
  * Changes links from old documentation to newer documentation
116
 
1
  === Quiz And Survey Master (Formerly Quiz Master Next) ===
2
  Contributors: fpcorso
3
  Tags: quiz, survey, lead, test, score, exam, questionnaire, question
4
+ Requires at least: 4.9
5
+ Tested up to: 5.0.2
6
  Requires PHP: 5.4
7
+ Stable tag: 6.1.0
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
111
 
112
  == Changelog ==
113
 
114
+ = 6.1.0 (December 26, 2018) =
115
+ * Adds new Gutenberg blocks
116
+ * Fixes undefined access at delete_question static function (Thanks [bpanatta](https://github.com/fpcorso/quiz_master_next/pull/746)!
117
+
118
  = 6.0.4 (October 2, 2018) =
119
  * Changes links from old documentation to newer documentation
120