Wp-Pro-Quiz - Version 0.21

Version Description

Download this release

Release Info

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

Code changes from version 0.20 to 0.21

lib/helper/WpProQuiz_Helper_Upgrade.php CHANGED
@@ -6,6 +6,10 @@ class WpProQuiz_Helper_Upgrade {
6
  WpProQuiz_Helper_Upgrade::updateDb();
7
 
8
  $oldVersion = get_option('wpProQuiz_version');
 
 
 
 
9
 
10
  switch($oldVersion) {
11
  case '0.17':
@@ -13,6 +17,7 @@ class WpProQuiz_Helper_Upgrade {
13
  WpProQuiz_Helper_Upgrade::updateV19();
14
  case '0.19':
15
  WpProQuiz_Helper_Upgrade::updateV20();
 
16
  break;
17
  default:
18
  WpProQuiz_Helper_Upgrade::install();
@@ -66,7 +71,7 @@ class WpProQuiz_Helper_Upgrade {
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
 
@@ -84,12 +89,55 @@ class WpProQuiz_Helper_Upgrade {
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
  }
6
  WpProQuiz_Helper_Upgrade::updateDb();
7
 
8
  $oldVersion = get_option('wpProQuiz_version');
9
+
10
+ if($oldVersion == '0.20') {
11
+ WpProQuiz_Helper_Upgrade::updateV21();
12
+ }
13
 
14
  switch($oldVersion) {
15
  case '0.17':
17
  WpProQuiz_Helper_Upgrade::updateV19();
18
  case '0.19':
19
  WpProQuiz_Helper_Upgrade::updateV20();
20
+ case '0.20':
21
  break;
22
  default:
23
  WpProQuiz_Helper_Upgrade::install();
71
 
72
  $results = $wpdb->get_results("
73
  SELECT id, answer_data
74
+ FROM {$wpdb->prefix}wp_pro_quiz_question
75
  WHERE answer_type = 'cloze_answer' AND answer_points_activated = 1", ARRAY_A);
76
 
77
 
89
  $points += $match;
90
  }
91
  }
92
+
93
  $wpdb->update($wpdb->prefix.'wp_pro_quiz_question', array('points' => $points), array('id' => $row['id']));
94
  }
95
  }
96
  }
97
 
98
+ private static function updateV21() {
99
+ global $wpdb;
100
+
101
+ $results = $wpdb->get_results("
102
+ SELECT id, answer_data, answer_type, answer_points_activated, points
103
+ FROM {$wpdb->prefix}wp_pro_quiz_question", ARRAY_A);
104
+
105
+ foreach($results as $row) {
106
+ if($row['points'])
107
+ continue;
108
+
109
+ if(WpProQuiz_Helper_Until::saveUnserialize($row['answer_data'], $into)) {
110
+
111
+ $points = 0;
112
+
113
+ if($row['answer_points_activated']) {
114
+ $dPoints = 0;
115
+
116
+ foreach($into as $c) {
117
+ if($row['answer_type'] == 'cloze_answer') {
118
+ preg_match_all('#\{(.*?)(?:\|(\d+))?(?:[\s]+)?\}#im', $c->getAnswer(), $matches);
119
+
120
+ foreach($matches[2] as $match) {
121
+ if(empty($match))
122
+ $match = 1;
123
+
124
+ $dPoints += $match;
125
+ }
126
+ } else {
127
+ $dPoints += $c->getPoints();
128
+ }
129
+ }
130
+
131
+ $points = $dPoints;
132
+ } else {
133
+ $points = 1;
134
+ }
135
+
136
+ $wpdb->update($wpdb->prefix.'wp_pro_quiz_question', array('points' => $points), array('id' => $row['id']));
137
+ }
138
+ }
139
+ }
140
+
141
  public static function deinstall() {
142
 
143
  }
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.20
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -196,4 +196,7 @@ http://www.it-gecko.de/wp-pro-quiz-quiz-plugin-fuer-wordpress.html (scroll to "D
196
  = 0.20 =
197
  * Bugfix: in "Cloze": not correctly points calculated
198
  * Bugfix: "Number answers" option broken. all answers are numbered
199
- * Bugfix: Database
 
 
 
4
  Tags: quiz, test, answer, question, learning
5
  Requires at least: 3.3
6
  Tested up to: 3.5.1
7
+ Stable tag: 0.21
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
196
  = 0.20 =
197
  * Bugfix: in "Cloze": not correctly points calculated
198
  * Bugfix: "Number answers" option broken. all answers are numbered
199
+ * Bugfix: Database
200
+
201
+ = 0.21 =
202
+ * Hard fail in version 0.21 (all question points reset)
wp-pro-quiz.php CHANGED
@@ -3,12 +3,14 @@
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__));
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.21
7
  Author: Julius Fischer
8
  Author URI: http://www.it-gecko.de
9
+ Text Domain: wp-pro-quiz
10
+ Domain Path: /languages
11
  */
12
 
13
+ define('WPPROQUIZ_VERSION', '0.21');
14
 
15
  define('WPPROQUIZ_PATH', dirname(__FILE__));
16
  define('WPPROQUIZ_URL', plugins_url('', __FILE__));