Wp-Pro-Quiz - Version 0.20

Version Description

  • Bugfix: in "Cloze": not correctly points calculated
  • Bugfix: "Number answers" option broken. all answers are numbered
  • Bugfix: Database
Download this release

Release Info

Developer xeno010
Plugin Icon 128x128 Wp-Pro-Quiz
Version 0.20
Comparing to
See all releases

Code changes from version 0.19 to 0.20

lib/helper/WpProQuiz_Helper_DbUpgrade.php CHANGED
@@ -52,107 +52,114 @@ class WpProQuiz_Helper_DbUpgrade {
52
 
53
  $this->_wpdb->query('
54
  CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_master` (
55
- `id` int(11) NOT NULL AUTO_INCREMENT,
56
- `name` varchar(200) NOT NULL,
57
- `text` text NOT NULL,
58
- `result_text` text NOT NULL,
59
- `result_grade_enabled` tinyint(1) NOT NULL,
60
- `title_hidden` tinyint(1) NOT NULL,
61
- `btn_restart_quiz_hidden` tinyint(1) NOT NULL,
62
- `btn_view_question_hidden` tinyint(1) NOT NULL,
63
- `question_random` tinyint(1) NOT NULL,
64
- `answer_random` tinyint(1) NOT NULL,
65
- `check_answer` tinyint(1) NOT NULL,
66
- `back_button` tinyint(1) NOT NULL,
67
- `time_limit` int(11) NOT NULL,
68
- `statistics_on` tinyint(1) NOT NULL,
69
- `statistics_ip_lock` int(10) unsigned NOT NULL,
70
- `show_points` tinyint(1) NOT NULL,
71
- `quiz_run_once` tinyint(1) NOT NULL,
72
- `quiz_run_once_type` tinyint(4) NOT NULL,
73
- `quiz_run_once_cookie` tinyint(1) NOT NULL,
74
- `quiz_run_once_time` int(10) unsigned NOT NULL,
75
- `question_on_single_page` tinyint(1) NOT NULL,
76
- `numbered_answer` tinyint(1) NOT NULL,
77
- `hide_answer_message_box` tinyint(1) NOT NULL,
78
- `disabled_answer_mark` tinyint(1) NOT NULL,
79
- `show_max_question` tinyint(1) NOT NULL,
80
- `show_max_question_value` int(10) unsigned NOT NULL,
81
- `show_max_question_percent` tinyint(1) NOT NULL,
82
- PRIMARY KEY (`id`)
 
 
 
 
83
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
84
  ');
85
 
86
  $this->_wpdb->query('
87
  CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_question` (
88
- `id` int(11) NOT NULL AUTO_INCREMENT,
89
- `quiz_id` int(11) NOT NULL,
90
- `sort` tinyint(3) unsigned NOT NULL,
91
- `title` varchar(200) NOT NULL,
92
- `points` int(11) NOT NULL,
93
- `question` text NOT NULL,
94
- `correct_msg` text NOT NULL,
95
- `incorrect_msg` text NOT NULL,
96
- `correct_same_text` tinyint(1) NOT NULL,
97
- `correct_count` int(10) unsigned NOT NULL,
98
- `incorrect_count` int(10) unsigned NOT NULL,
99
- `tip_enabled` tinyint(1) NOT NULL,
100
- `tip_msg` text NOT NULL,
101
- `tip_count` int(11) NOT NULL,
102
- `answer_type` varchar(50) NOT NULL,
103
- `answer_json` text NOT NULL,
104
- `points_per_answer` tinyint(1) NOT NULL,
105
- `points_answer` int(10) unsigned NOT NULL,
106
- `show_points_in_box` tinyint(1) NOT NULL,
107
- PRIMARY KEY (`id`),
108
- KEY `quiz_id` (`quiz_id`)
 
 
109
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
110
  ');
111
 
112
  $this->_wpdb->query('
113
  CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_lock` (
114
- `quiz_id` int(11) NOT NULL,
115
- `lock_ip` varchar(100) NOT NULL,
116
- `user_id` bigint(20) unsigned NOT NULL,
117
- `lock_type` tinyint(3) unsigned NOT NULL,
118
- `lock_date` int(11) NOT NULL,
119
- PRIMARY KEY (`quiz_id`,`lock_ip`,`user_id`,`lock_type`)
120
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
121
  ');
122
 
123
  $this->_wpdb->query('
124
  CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_statistic` (
125
- `quiz_id` int(11) NOT NULL,
126
- `question_id` int(11) NOT NULL,
127
- `user_id` bigint(20) unsigned NOT NULL,
128
- `correct_count` int(10) unsigned NOT NULL,
129
- `incorrect_count` int(10) unsigned NOT NULL,
130
- `hint_count` int(10) unsigned NOT NULL,
131
- `correct_answer_count` int(10) unsigned NOT NULL,
132
- PRIMARY KEY (`quiz_id`,`question_id`,`user_id`)
 
133
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
134
  ');
135
 
136
  $this->_wpdb->query('
137
  CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_prerequisite` (
138
- `prerequisite_quiz_id` int(11) NOT NULL,
139
- `quiz_id` int(11) NOT NULL,
140
- PRIMARY KEY (`prerequisite_quiz_id`,`quiz_id`)
141
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
142
  ');
143
 
144
  $this->_wpdb->query('
145
  CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_toplist` (
146
- `toplist_id` int(11) NOT NULL AUTO_INCREMENT,
147
- `quiz_id` int(11) NOT NULL,
148
- `date` int(10) unsigned NOT NULL,
149
- `user_id` bigint(20) unsigned NOT NULL,
150
- `name` varchar(30) NOT NULL,
151
- `email` varchar(200) NOT NULL,
152
- `points` int(10) unsigned NOT NULL,
153
- `result` float unsigned NOT NULL,
154
- `ip` varchar(100) NOT NULL,
155
- PRIMARY KEY (`toplist_id`,`quiz_id`)
156
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
157
  ');
158
  }
52
 
53
  $this->_wpdb->query('
54
  CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_master` (
55
+ `id` int(11) NOT NULL AUTO_INCREMENT,
56
+ `name` varchar(200) NOT NULL,
57
+ `text` text NOT NULL,
58
+ `result_text` text NOT NULL,
59
+ `result_grade_enabled` tinyint(1) NOT NULL,
60
+ `title_hidden` tinyint(1) NOT NULL,
61
+ `btn_restart_quiz_hidden` tinyint(1) NOT NULL,
62
+ `btn_view_question_hidden` tinyint(1) NOT NULL,
63
+ `question_random` tinyint(1) NOT NULL,
64
+ `answer_random` tinyint(1) NOT NULL,
65
+ `check_answer` tinyint(1) NOT NULL,
66
+ `back_button` tinyint(1) NOT NULL,
67
+ `time_limit` int(11) NOT NULL,
68
+ `statistics_on` tinyint(1) NOT NULL,
69
+ `statistics_ip_lock` int(10) unsigned NOT NULL,
70
+ `show_points` tinyint(1) NOT NULL,
71
+ `quiz_run_once` tinyint(1) NOT NULL,
72
+ `quiz_run_once_type` tinyint(4) NOT NULL,
73
+ `quiz_run_once_cookie` tinyint(1) NOT NULL,
74
+ `quiz_run_once_time` int(10) unsigned NOT NULL,
75
+ `question_on_single_page` tinyint(1) NOT NULL,
76
+ `numbered_answer` tinyint(1) NOT NULL,
77
+ `hide_answer_message_box` tinyint(1) NOT NULL,
78
+ `disabled_answer_mark` tinyint(1) NOT NULL,
79
+ `show_max_question` tinyint(1) NOT NULL,
80
+ `show_max_question_value` int(10) unsigned NOT NULL,
81
+ `show_max_question_percent` tinyint(1) NOT NULL,
82
+ `toplist_activated` tinyint(1) NOT NULL,
83
+ `toplist_data` text NOT NULL,
84
+ `show_average_result` tinyint(1) NOT NULL,
85
+ `prerequisite` tinyint(1) NOT NULL,
86
+ PRIMARY KEY (`id`)
87
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
88
  ');
89
 
90
  $this->_wpdb->query('
91
  CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_question` (
92
+ `id` int(11) NOT NULL AUTO_INCREMENT,
93
+ `quiz_id` int(11) NOT NULL,
94
+ `sort` smallint(5) unsigned NOT NULL,
95
+ `title` varchar(200) NOT NULL,
96
+ `points` int(11) NOT NULL,
97
+ `question` text NOT NULL,
98
+ `correct_msg` text NOT NULL,
99
+ `incorrect_msg` text NOT NULL,
100
+ `correct_same_text` tinyint(1) NOT NULL,
101
+ `correct_count` int(10) unsigned NOT NULL,
102
+ `incorrect_count` int(10) unsigned NOT NULL,
103
+ `tip_enabled` tinyint(1) NOT NULL,
104
+ `tip_msg` text NOT NULL,
105
+ `tip_count` int(11) NOT NULL,
106
+ `answer_type` varchar(50) NOT NULL,
107
+ `answer_json` text NOT NULL,
108
+ `points_per_answer` tinyint(1) NOT NULL,
109
+ `points_answer` int(10) unsigned NOT NULL,
110
+ `show_points_in_box` tinyint(1) NOT NULL,
111
+ `answer_points_activated` tinyint(1) NOT NULL,
112
+ `answer_data` longtext NOT NULL,
113
+ PRIMARY KEY (`id`),
114
+ KEY `quiz_id` (`quiz_id`)
115
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
116
  ');
117
 
118
  $this->_wpdb->query('
119
  CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_lock` (
120
+ `quiz_id` int(11) NOT NULL,
121
+ `lock_ip` varchar(100) NOT NULL,
122
+ `user_id` bigint(20) unsigned NOT NULL,
123
+ `lock_type` tinyint(3) unsigned NOT NULL,
124
+ `lock_date` int(11) NOT NULL,
125
+ PRIMARY KEY (`quiz_id`,`lock_ip`,`user_id`,`lock_type`)
126
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
127
  ');
128
 
129
  $this->_wpdb->query('
130
  CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_statistic` (
131
+ `quiz_id` int(11) NOT NULL,
132
+ `question_id` int(11) NOT NULL,
133
+ `user_id` bigint(20) unsigned NOT NULL,
134
+ `correct_count` int(10) unsigned NOT NULL,
135
+ `incorrect_count` int(10) unsigned NOT NULL,
136
+ `hint_count` int(10) unsigned NOT NULL,
137
+ `correct_answer_count` int(10) unsigned NOT NULL,
138
+ `points` int(10) unsigned NOT NULL,
139
+ PRIMARY KEY (`quiz_id`,`question_id`,`user_id`)
140
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
141
  ');
142
 
143
  $this->_wpdb->query('
144
  CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_prerequisite` (
145
+ `prerequisite_quiz_id` int(11) NOT NULL,
146
+ `quiz_id` int(11) NOT NULL,
147
+ PRIMARY KEY (`prerequisite_quiz_id`,`quiz_id`)
148
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
149
  ');
150
 
151
  $this->_wpdb->query('
152
  CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_toplist` (
153
+ `toplist_id` int(11) NOT NULL AUTO_INCREMENT,
154
+ `quiz_id` int(11) NOT NULL,
155
+ `date` int(10) unsigned NOT NULL,
156
+ `user_id` bigint(20) unsigned NOT NULL,
157
+ `name` varchar(30) NOT NULL,
158
+ `email` varchar(200) NOT NULL,
159
+ `points` int(10) unsigned NOT NULL,
160
+ `result` float unsigned NOT NULL,
161
+ `ip` varchar(100) NOT NULL,
162
+ PRIMARY KEY (`toplist_id`,`quiz_id`)
163
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
164
  ');
165
  }
lib/helper/WpProQuiz_Helper_Upgrade.php CHANGED
@@ -11,6 +11,8 @@ class WpProQuiz_Helper_Upgrade {
11
  case '0.17':
12
  case '0.18':
13
  WpProQuiz_Helper_Upgrade::updateV19();
 
 
14
  break;
15
  default:
16
  WpProQuiz_Helper_Upgrade::install();
@@ -59,6 +61,35 @@ class WpProQuiz_Helper_Upgrade {
59
  update_option('wpProQuiz_dbVersion', $v);
60
  }
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  public static function deinstall() {
63
 
64
  }
11
  case '0.17':
12
  case '0.18':
13
  WpProQuiz_Helper_Upgrade::updateV19();
14
+ case '0.19':
15
+ WpProQuiz_Helper_Upgrade::updateV20();
16
  break;
17
  default:
18
  WpProQuiz_Helper_Upgrade::install();
61
  update_option('wpProQuiz_dbVersion', $v);
62
  }
63
 
64
+ private static function updateV20() {
65
+ global $wpdb;
66
+
67
+ $results = $wpdb->get_results("
68
+ SELECT id, answer_data
69
+ FROM {$wpdb->prefix}wp_pro_quiz_question`
70
+ WHERE answer_type = 'cloze_answer' AND answer_points_activated = 1", ARRAY_A);
71
+
72
+
73
+ foreach($results as $row) {
74
+ if(WpProQuiz_Helper_Until::saveUnserialize($row['answer_data'], $into)) {
75
+ $points = 0;
76
+
77
+ foreach($into as $c) {
78
+ preg_match_all('#\{(.*?)(?:\|(\d+))?(?:[\s]+)?\}#im', $c->getAnswer(), $matches);
79
+
80
+ foreach($matches[2] as $match) {
81
+ if(empty($match))
82
+ $match = 1;
83
+
84
+ $points += $match;
85
+ }
86
+ }
87
+
88
+ $wpdb->update($wpdb->prefix.'wp_pro_quiz_question', array('points' => $points), array('id' => $row['id']));
89
+ }
90
+ }
91
+ }
92
+
93
  public static function deinstall() {
94
 
95
  }
lib/view/WpProQuiz_View_FrontQuiz.php CHANGED
@@ -208,7 +208,7 @@ class WpProQuiz_View_FrontQuiz extends WpProQuiz_View_View {
208
 
209
  <?php if($question->getAnswerType() === 'single' || $question->getAnswerType() === 'multiple') { ?>
210
  <?php $json[$question->getId()]['correct'][] = (int)$v->isCorrect(); ?>
211
- <span <?php $this->quiz->isNumberedAnswer() ? '' : 'style="display:none;"'?>></span>
212
  <label>
213
  <input class="wpProQuiz_questionInput" type="<?php echo $question->getAnswerType() === 'single' ? 'radio' : 'checkbox'; ?>" name="question_<?php echo $this->quiz->getId(); ?>_<?php echo $question->getId(); ?>" value="<?php echo ($answer_index+1); ?>"> <?php echo $answer_text; ?>
214
  </label>
@@ -366,7 +366,6 @@ $bo |= ((int)$this->quiz->isDisabledAnswerMark()) << 2;
366
  $bo |= ((int)($this->quiz->isQuizRunOnce() || $this->quiz->isPrerequisite())) << 3;
367
  $bo |= ((int)$preview) << 4;
368
  $bo |= ((int)get_option('wpProQuiz_corsActivated')) << 5;
369
-
370
  ?>
371
 
372
  <script type="text/javascript">
208
 
209
  <?php if($question->getAnswerType() === 'single' || $question->getAnswerType() === 'multiple') { ?>
210
  <?php $json[$question->getId()]['correct'][] = (int)$v->isCorrect(); ?>
211
+ <span <?php echo $this->quiz->isNumberedAnswer() ? '' : 'style="display:none;"'?>></span>
212
  <label>
213
  <input class="wpProQuiz_questionInput" type="<?php echo $question->getAnswerType() === 'single' ? 'radio' : 'checkbox'; ?>" name="question_<?php echo $this->quiz->getId(); ?>_<?php echo $question->getId(); ?>" value="<?php echo ($answer_index+1); ?>"> <?php echo $answer_text; ?>
214
  </label>
366
  $bo |= ((int)($this->quiz->isQuizRunOnce() || $this->quiz->isPrerequisite())) << 3;
367
  $bo |= ((int)$preview) << 4;
368
  $bo |= ((int)get_option('wpProQuiz_corsActivated')) << 5;
 
369
  ?>
370
 
371
  <script type="text/javascript">
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: quiz, test, answer, question, learning
5
  Requires at least: 3.3
6
  Tested up to: 3.5.1
7
- Stable tag: 0.19
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -192,3 +192,8 @@ http://www.it-gecko.de/wp-pro-quiz-quiz-plugin-fuer-wordpress.html (scroll to "D
192
  * Cloze: different points can be assigned for every gap
193
  * Very many internal changes
194
  * several bugfixes
 
 
 
 
 
4
  Tags: quiz, test, answer, question, learning
5
  Requires at least: 3.3
6
  Tested up to: 3.5.1
7
+ Stable tag: 0.20
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
192
  * Cloze: different points can be assigned for every gap
193
  * Very many internal changes
194
  * several bugfixes
195
+
196
+ = 0.20 =
197
+ * Bugfix: in "Cloze": not correctly points calculated
198
+ * Bugfix: "Number answers" option broken. all answers are numbered
199
+ * Bugfix: Database
wp-pro-quiz.php CHANGED
@@ -3,12 +3,12 @@
3
  Plugin Name: WP-Pro-Quiz
4
  Plugin URI: http://wordpress.org/extend/plugins/wp-pro-quiz
5
  Description: A powerful and beautiful quiz plugin for WordPress.
6
- Version: 0.19
7
  Author: Julius Fischer
8
  Author URI: http://www.it-gecko.de
9
  */
10
 
11
- define('WPPROQUIZ_VERSION', '0.19');
12
 
13
  define('WPPROQUIZ_PATH', dirname(__FILE__));
14
  define('WPPROQUIZ_URL', plugins_url('', __FILE__));
3
  Plugin Name: WP-Pro-Quiz
4
  Plugin URI: http://wordpress.org/extend/plugins/wp-pro-quiz
5
  Description: A powerful and beautiful quiz plugin for WordPress.
6
+ Version: 0.20
7
  Author: Julius Fischer
8
  Author URI: http://www.it-gecko.de
9
  */
10
 
11
+ define('WPPROQUIZ_VERSION', '0.20');
12
 
13
  define('WPPROQUIZ_PATH', dirname(__FILE__));
14
  define('WPPROQUIZ_URL', plugins_url('', __FILE__));