Index: trunk/extensions/Survey/Survey.settings.php |
— | — | @@ -24,7 +24,8 @@ |
25 | 25 | 'defaultUserType' => Survey::$USER_ALL, |
26 | 26 | 'defaultNamespaces' => array(), |
27 | 27 | 'defaultRatio' => 100, |
28 | | - 'defaultExpiry' => 60 * 60 * 24 * 30 |
| 28 | + 'defaultExpiry' => 60 * 60 * 24 * 30, |
| 29 | + 'defaultMinPages' => 0 |
29 | 30 | ); |
30 | 31 | } |
31 | 32 | |
Index: trunk/extensions/Survey/Survey.sql |
— | — | @@ -11,10 +11,11 @@ |
12 | 12 | survey_header TEXT NOT NULL, -- Text to display above the survey |
13 | 13 | survey_footer TEXT NOT NULL, -- Text to display below the survey |
14 | 14 | survey_thanks TEXT NOT NULL, -- Text to display after survey submission |
15 | | - survey_user_type TINYINT NOT NULL default '0', -- Type of users that can participate in the survey |
| 15 | + survey_user_type TINYINT unsigned NOT NULL default '0', -- Type of users that can participate in the survey |
16 | 16 | survey_namespaces BLOB NOT NULL, -- Namespaces on which the survey can be displayed |
17 | 17 | survey_ratio TINYINT unsigned NOT NULL, -- Percentage of users to show the survey to |
18 | 18 | survey_expiry INT unsigned NOT NULL, -- Coockie expiry time for the survey |
| 19 | + survey_min_pages TINYINT unsigned NOT NULL -- Min amount of pages the user needs to view before getting the survey |
19 | 20 | ) /*$wgDBTableOptions*/; |
20 | 21 | |
21 | 22 | -- Questions |
— | — | @@ -23,7 +24,7 @@ |
24 | 25 | question_survey_id SMALLINT unsigned NOT NULL, -- Foreign key: surveys.survey_id |
25 | 26 | question_text TEXT NOT NULL, |
26 | 27 | question_type INT(2) unsigned NOT NULL, |
27 | | - question_required INT(2) unsigned NOT NULL, |
| 28 | + question_required TINYINT NOT NULL, |
28 | 29 | question_answers BLOB NOT NULL, |
29 | 30 | question_removed TINYINT NOT NULL default '0' |
30 | 31 | ) /*$wgDBTableOptions*/; |
Index: trunk/extensions/Survey/Survey.i18n.php |
— | — | @@ -44,6 +44,14 @@ |
45 | 45 | 'survey-question-type-textarea' => 'Multi-line text field', |
46 | 46 | 'survey-question-type-check' => 'Checkbox', |
47 | 47 | |
| 48 | + // User types |
| 49 | + 'survey-user-type-all' => 'Everyone', |
| 50 | + 'survey-user-type-loggedin' => 'Logged in users', |
| 51 | + 'survey-user-type-confirmed' => 'Confirmed users', |
| 52 | + 'survey-user-type-editor' => 'Editors', |
| 53 | + 'survey-user-type-anon' => 'Anonymous users', |
| 54 | + |
| 55 | + // Navigation |
48 | 56 | 'survey-navigation-edit' => '[[Special:Survey/$1|Edit this survey]]', |
49 | 57 | 'survey-navigation-take' => '[[Special:TakeSurvey/$1|Take this survey]]', |
50 | 58 | 'survey-navigation-list' => '[[Special:Surveys|Surveys list]]', |
— | — | @@ -66,11 +74,7 @@ |
67 | 75 | 'surveys-special-confirm-delete' => 'Are you sure you want to delete this survey?', |
68 | 76 | 'surveys-special-delete-failed' => 'Failed to delete survey.', |
69 | 77 | 'survey-special-label-usertype' => 'Users that should get the survey', |
70 | | - 'survey-user-type-all' => 'Everyone', |
71 | | - 'survey-user-type-loggedin' => 'Logged in users', |
72 | | - 'survey-user-type-confirmed' => 'Confirmed users', |
73 | | - 'survey-user-type-editor' => 'Editors', |
74 | | - 'survey-user-type-anon' => 'Anonymous users', |
| 78 | + 'survey-special-label-minpages' => 'Minimun amount of pages the user needs to visit before getting the survey', |
75 | 79 | |
76 | 80 | // Special:TakeSurvey |
77 | 81 | 'surveys-takesurvey-loading' => 'Loading survey...', |
Index: trunk/extensions/Survey/specials/SpecialSurvey.php |
— | — | @@ -86,7 +86,7 @@ |
87 | 87 | |
88 | 88 | $survey->setField( 'enabled', $wgRequest->getCheck( 'survey-enabled' ) ); |
89 | 89 | |
90 | | - foreach ( array( 'user_type', 'ratio' ) as $field ) { |
| 90 | + foreach ( array( 'user_type', 'ratio', 'min_pages' ) as $field ) { |
91 | 91 | $survey->setField( $field, $wgRequest->getInt( 'survey-' . $field ) ); |
92 | 92 | } |
93 | 93 | |
— | — | @@ -169,6 +169,15 @@ |
170 | 170 | ); |
171 | 171 | } |
172 | 172 | |
| 173 | + protected function getNumericalOptions( array $numbers ) { |
| 174 | + $lang = $this->getLang(); |
| 175 | + |
| 176 | + return array_flip( array_map( |
| 177 | + function( $n ) use( $lang ) { return $lang->formatNum( $n ); }, |
| 178 | + array_combine( $numbers, $numbers ) |
| 179 | + ) ); |
| 180 | + } |
| 181 | + |
173 | 182 | /** |
174 | 183 | * Show the survey. |
175 | 184 | * |
— | — | @@ -231,23 +240,25 @@ |
232 | 241 | ), |
233 | 242 | ); |
234 | 243 | |
235 | | - $nrs = array_merge( array( 0.01, 0.1 ), range( 1, 100 ) ); |
236 | | - |
237 | | - $lang = $this->getLang(); |
238 | | - |
239 | 244 | $fields[] = array( |
240 | 245 | 'type' => 'select', |
241 | 246 | 'default' => $survey->getField( 'ratio' ), |
242 | 247 | 'label-message' => 'survey-special-label-ratio', |
243 | 248 | 'id' => 'survey-ratio', |
244 | 249 | 'name' => 'survey-ratio', |
245 | | - 'options' => array_flip( array_map( |
246 | | - function( $n ) use( $lang ) { return $lang->formatNum( $n ); }, |
247 | | - array_combine( $nrs, $nrs ) |
248 | | - ) ), |
| 250 | + 'options' => $this->getNumericalOptions( array_merge( array( 0.01, 0.1 ), range( 1, 100 ) ) ), |
249 | 251 | ); |
250 | 252 | |
251 | 253 | $fields[] = array( |
| 254 | + 'type' => 'select', |
| 255 | + 'default' => $survey->getField( 'min_pages' ), |
| 256 | + 'label-message' => 'survey-special-label-minpages', |
| 257 | + 'id' => 'survey-min_pages', |
| 258 | + 'name' => 'survey-min_pages', |
| 259 | + 'options' => $this->getNumericalOptions( range( 0, 250 ) ), |
| 260 | + ); |
| 261 | + |
| 262 | + $fields[] = array( |
252 | 263 | 'type' => 'text', |
253 | 264 | 'default' => $survey->getField( 'header' ), |
254 | 265 | 'label-message' => 'survey-special-label-header', |
Index: trunk/extensions/Survey/includes/Survey.class.php |
— | — | @@ -46,7 +46,8 @@ |
47 | 47 | 'user_type' => 'int', |
48 | 48 | 'namespaces' => 'array', |
49 | 49 | 'ratio' => 'int', |
50 | | - 'expiry' => 'int' |
| 50 | + 'expiry' => 'int', |
| 51 | + 'min_pages' => 'int' |
51 | 52 | ); |
52 | 53 | } |
53 | 54 | |
— | — | @@ -70,6 +71,7 @@ |
71 | 72 | 'namespaces' => SurveySettings::get( 'defaultNamespaces' ), |
72 | 73 | 'ratio' => SurveySettings::get( 'defaultRatio' ), |
73 | 74 | 'expiry' => SurveySettings::get( 'defaultExpiry' ), |
| 75 | + 'min_pages' => SurveySettings::get( 'defaultMinPages' ), |
74 | 76 | ); |
75 | 77 | } |
76 | 78 | |