Index: trunk/extensions/QPoll/i18n/qp.i18n.php |
— | — | @@ -123,6 +123,7 @@ |
124 | 124 | 'qp_error_unique' => 'Question of type unique() has more proposals than possible answers defined: Impossible to complete.', |
125 | 125 | 'qp_error_no_more_attempts' => 'You have reached maximal number of submitting attempts for this poll.', |
126 | 126 | 'qp_error_interpretation_no_return' => 'Interpretation script returned no result.', |
| 127 | + 'qp_error_structured_interpretation_is_too_long' => 'Structured interpretation is too long to be stored in database. Please correct your interpretation script.', |
127 | 128 | 'qp_error_no_json_decode' => 'Interpretation of poll answers requires json_decode() PHP function.', |
128 | 129 | 'qp_error_eval_missed_lang_attr' => 'XML attribute "lang" is required to choose proper interpretation language.', |
129 | 130 | 'qp_error_eval_mix_languages' => 'Single interpretation script cannot mix different interpretation languages: "$1", "$2".', |
— | — | @@ -2634,6 +2635,7 @@ |
2635 | 2636 | 'qp_error_unique' => 'Опрос, имеющий тип unique(), не должен иметь больше ответов чем вопросов', |
2636 | 2637 | 'qp_error_no_more_attempts' => 'Исчерпано количество попыток ответа на данный опрос', |
2637 | 2638 | 'qp_error_interpretation_no_return' => 'Скрипт интерпретации не вернул результат', |
| 2639 | + 'qp_error_structured_interpretation_is_too_long' => 'Структурированная интерпретация слишком длинна для хранения в базе данных. Пожалуйста скорректируйте Ваш скрипт интерпретации.', |
2638 | 2640 | ); |
2639 | 2641 | |
2640 | 2642 | /** Rusyn (Русиньскый) |
Index: trunk/extensions/QPoll/maintenance/qp_schemaupdater.php |
— | — | @@ -103,8 +103,8 @@ |
104 | 104 | 'qp_poll_desc' => array( 'interpretation_namespace', 'interpretation_title' ), |
105 | 105 | 'qp_users_polls' => array( 'attempts', 'short_interpretation', 'long_interpretation' ) |
106 | 106 | ), |
107 | | - 'qpoll_serialized_interpretation.src' => array( |
108 | | - 'qp_users_polls' => array( 'serialized_interpretation' ) |
| 107 | + 'qpoll_structured_interpretation.src' => array( |
| 108 | + 'qp_users_polls' => array( 'structured_interpretation' ) |
109 | 109 | ) |
110 | 110 | ); |
111 | 111 | |
Index: trunk/extensions/QPoll/qp_interpret.php |
— | — | @@ -137,11 +137,22 @@ |
138 | 138 | if ( $interpResult->isError() ) { |
139 | 139 | return $interpResult->setDefaultErrorMessage(); |
140 | 140 | } |
141 | | - if ( !isset( $result['short'] ) || !isset( $result['long'] ) ) { |
| 141 | + $interpCount = 0; |
| 142 | + foreach ( qp_Setup::$show_interpretation as $interpType => $show ) { |
| 143 | + if ( isset( $result[$interpType] ) ) { |
| 144 | + $interpCount++; |
| 145 | + } |
| 146 | + } |
| 147 | + if ( $interpCount == 0 ) { |
142 | 148 | return $interpResult->setError( wfMsg( 'qp_error_interpretation_no_return' ) ); |
143 | 149 | } |
144 | | - $interpResult->short = (string) $result['short']; |
145 | | - $interpResult->long = (string) $result['long']; |
| 150 | + $interpResult->structured = serialize( isset( $result['structured'] ) ? $result['structured'] : null ); |
| 151 | + if ( strlen( $interpResult->structured ) > qp_Setup::$structured_interpretation_max_length ) { |
| 152 | + unset( $interpResult->structured ); |
| 153 | + return $interpResult->setError( wfMsg( 'qp_error_structured_interpretation_is_too_long' ) ); |
| 154 | + } |
| 155 | + $interpResult->short = isset( $result['short'] ) ? strval( $result['short'] ) : ''; |
| 156 | + $interpResult->long = isset( $result['long'] ) ? strval( $result['long'] ) : ''; |
146 | 157 | return $interpResult; |
147 | 158 | } |
148 | 159 | |
Index: trunk/extensions/QPoll/archives/qpoll_serialized_interpretation.src |
— | — | @@ -1,3 +0,0 @@ |
2 | | -ALTER TABLE /*$wgDBprefix*/qp_users_polls |
3 | | - ADD COLUMN serialized_interpretation text NOT NULL default ''; |
Index: trunk/extensions/QPoll/archives/qpoll_structured_interpretation.src |
— | — | @@ -0,0 +1,3 @@ |
| 2 | +-- fields to store the interpretation results |
| 3 | +ALTER TABLE /*$wgDBprefix*/qp_users_polls |
| 4 | + ADD COLUMN structured_interpretation text NOT NULL default ''; |
Index: trunk/extensions/QPoll/qp_user.php |
— | — | @@ -202,11 +202,13 @@ |
203 | 203 | # it is important only for question type="text", where |
204 | 204 | # proposal text contains serialized array of proposal parts and category fields |
205 | 205 | public static $proposal_max_length = 768; |
206 | | - # whether to show short, long, serialized interpretation results to end user |
| 206 | + # not larger than DB field size, otherwise serialization will be invalid |
| 207 | + public static $structured_interpretation_max_length = 65535; |
| 208 | + # whether to show short, long, structured interpretation results to end user |
207 | 209 | public static $show_interpretation = array( |
208 | 210 | 'short' => false, |
209 | 211 | 'long' => true, |
210 | | - 'serialized' => false |
| 212 | + 'structured' => false |
211 | 213 | ); |
212 | 214 | /* end of default configuration settings */ |
213 | 215 | |
Index: trunk/extensions/QPoll/qp_pollstore.php |
— | — | @@ -16,9 +16,10 @@ |
17 | 17 | # by default, it is public (displayed everywhere) |
18 | 18 | # blank value means long answer is unavailable |
19 | 19 | var $long = ''; |
20 | | - # serialized answer. one dimensional array with numeric keys and scalar values. |
| 20 | + # structured answer. scalar value or an associative array. |
| 21 | + # objects are not allowed. |
21 | 22 | # it is exported to XLS voices and can be analyzed by external tools. |
22 | | - var $serialized = ''; |
| 23 | + var $structured = null; |
23 | 24 | # error message. non-blank value indicates interpretation script error |
24 | 25 | # either due to incorrect script code, or a script-generated one |
25 | 26 | var $error = ''; |