Index: trunk/extensions/Survey/Survey.php |
— | — | @@ -150,7 +150,8 @@ |
151 | 151 | 'survey-special-label-type', |
152 | 152 | 'survey-special-label-text', |
153 | 153 | 'survey-special-label-addquestion', |
154 | | - 'survey-special-label-button', |
| 154 | + 'survey-special-label-add-first', |
| 155 | + 'survey-special-label-add-another', |
155 | 156 | 'survey-special-remove', |
156 | 157 | 'survey-special-remove-confirm', |
157 | 158 | 'survey-special-label-answers' |
Index: trunk/extensions/Survey/Survey.sql |
— | — | @@ -5,13 +5,16 @@ |
6 | 6 | -- Surveys |
7 | 7 | CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/surveys ( |
8 | 8 | survey_id SMALLINT unsigned NOT NULL auto_increment PRIMARY KEY, |
9 | | - survey_name VARCHAR(255) NOT NULL, |
10 | | - survey_enabled TINYINT NOT NULL default '0', |
11 | | - survey_header TEXT NOT NULL, |
12 | | - survey_footer TEXT NOT NULL, |
13 | | - survey_thanks TEXT NOT NULL, |
14 | | - survey_user_type TINYINT NOT NULL default '0', |
15 | | - survey_namespaces BLOB NOT NULL |
| 9 | + survey_name VARCHAR(255) NOT NULL, -- String indentifier for the survey |
| 10 | + survey_title VARCHAR(255) NOT NULL, -- Title of the survey |
| 11 | + survey_enabled TINYINT NOT NULL default '0', -- If the survey can be taken by users |
| 12 | + survey_header TEXT NOT NULL, -- Text to display above the survey |
| 13 | + survey_footer TEXT NOT NULL, -- Text to display below the survey |
| 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 |
| 16 | + survey_namespaces BLOB NOT NULL, -- Namespaces on which the survey can be displayed |
| 17 | + survey_ratio TINYINT unsigned NOT NULL, -- Percentage of users to show the survey to |
| 18 | + survey_expiry INT unsigned NOT NULL -- Coockie expiry time for the survey |
16 | 19 | ) /*$wgDBTableOptions*/; |
17 | 20 | |
18 | 21 | -- Questions |
Index: trunk/extensions/Survey/Survey.i18n.php |
— | — | @@ -50,7 +50,7 @@ |
51 | 51 | |
52 | 52 | // Special:Surveys |
53 | 53 | 'surveys-special-addnew' => 'Add a new survey', |
54 | | - 'surveys-special-namedoc' => 'Enter the name for the new survey.', |
| 54 | + 'surveys-special-namedoc' => 'Enter a name for the new survey that will be used as simple identifier. For example: editor-motivation.', |
55 | 55 | 'surveys-special-newname' => 'New survey name:', |
56 | 56 | 'surveys-special-add' => 'Add survey', |
57 | 57 | 'surveys-special-existing' => 'Existing surveys', |
— | — | @@ -97,8 +97,10 @@ |
98 | 98 | // Special:Survey |
99 | 99 | 'surveys-special-unknown-name' => 'There is no survey with the requested name.', |
100 | 100 | 'survey-special-label-name' => 'Survey name', |
| 101 | + 'survey-special-label-title' => 'Survey title', |
101 | 102 | 'survey-special-label-enabled' => 'Survey enabled', |
102 | | - 'survey-special-label-button' => 'Add question', |
| 103 | + 'survey-special-label-add-first' => 'Add question', |
| 104 | + 'survey-special-label-add-another' => 'Add another question', |
103 | 105 | 'survey-special-label-addquestion' => 'New question', |
104 | 106 | 'survey-special-label-add' => 'New question name', |
105 | 107 | 'survey-question-label-nr' => 'Question #$1', |
Index: trunk/extensions/Survey/specials/SpecialSurvey.php |
— | — | @@ -73,13 +73,16 @@ |
74 | 74 | $survey = Survey::newFromId( $wgRequest->getInt( 'survey-id' ), null, false ); |
75 | 75 | } |
76 | 76 | |
77 | | - foreach ( array( 'name', 'header', 'footer', 'thanks' ) as $field ) { |
| 77 | + foreach ( array( 'name', 'title', 'header', 'footer', 'thanks' ) as $field ) { |
78 | 78 | $survey->setField( $field, $wgRequest->getText( 'survey-' . $field ) ); |
79 | 79 | } |
80 | 80 | |
81 | 81 | $survey->setField( 'enabled', $wgRequest->getCheck( 'survey-enabled' ) ); |
82 | | - $survey->setField( 'user_type', $wgRequest->getInt( 'survey-user_type' ) ); |
83 | 82 | |
| 83 | + foreach ( array( 'user_type' ) as $field ) { |
| 84 | + $survey->setField( $field, $wgRequest->getInt( 'survey-' . $field ) ); |
| 85 | + } |
| 86 | + |
84 | 87 | $survey->setQuestions( $this->getSubmittedQuestions() ); |
85 | 88 | |
86 | 89 | $survey->writeToDB(); |
— | — | @@ -175,15 +178,23 @@ |
176 | 179 | ); |
177 | 180 | |
178 | 181 | $fields[] = array( |
179 | | - 'type' => 'text', |
| 182 | + 'class' => 'SurveyNameField', |
180 | 183 | 'default' => $survey->getField( 'name' ), |
181 | 184 | 'label-message' => 'survey-special-label-name', |
182 | 185 | 'id' => 'survey-name', |
183 | 186 | 'name' => 'survey-name', |
184 | | - //'disabled' => true |
| 187 | + 'style' => 'font-weight: bold;' |
185 | 188 | ); |
186 | 189 | |
187 | 190 | $fields[] = array( |
| 191 | + 'type' => 'text', |
| 192 | + 'default' => $survey->getField( 'title' ), |
| 193 | + 'label-message' => 'survey-special-label-title', |
| 194 | + 'id' => 'survey-title', |
| 195 | + 'name' => 'survey-title', |
| 196 | + ); |
| 197 | + |
| 198 | + $fields[] = array( |
188 | 199 | 'type' => 'check', |
189 | 200 | 'default' => $survey->getField( 'enabled' ) ? '1' : '0', |
190 | 201 | 'label-message' => 'survey-special-label-enabled', |
— | — | @@ -284,4 +295,20 @@ |
285 | 296 | ); |
286 | 297 | } |
287 | 298 | |
| 299 | +} |
| 300 | + |
| 301 | +class SurveyNameField extends HTMLFormField { |
| 302 | + |
| 303 | + public function getInputHTML( $value ) { |
| 304 | + return Html::element( |
| 305 | + 'span', |
| 306 | + array( |
| 307 | + 'id' => $this->mParams['id'], |
| 308 | + 'name' => $this->mParams['name'], |
| 309 | + 'style' => $this->mParams['style'] |
| 310 | + ), |
| 311 | + $value |
| 312 | + ); |
| 313 | + } |
| 314 | + |
288 | 315 | } |
\ No newline at end of file |
Index: trunk/extensions/Survey/includes/Survey.class.php |
— | — | @@ -38,12 +38,15 @@ |
39 | 39 | return array( |
40 | 40 | 'id' => 'id', |
41 | 41 | 'name' => 'str', |
| 42 | + 'title' => 'str', |
42 | 43 | 'enabled' => 'bool', |
43 | 44 | 'header' => 'str', |
44 | 45 | 'footer' => 'str', |
45 | 46 | 'thanks' => 'str', |
46 | 47 | 'user_type' => 'int', |
47 | | - 'namespaces' => 'array' |
| 48 | + 'namespaces' => 'array', |
| 49 | + 'ratio' => 'int', |
| 50 | + 'expiry' => 'int' |
48 | 51 | ); |
49 | 52 | } |
50 | 53 | |
— | — | @@ -58,12 +61,15 @@ |
59 | 62 | public static function getDefaults() { |
60 | 63 | return array( |
61 | 64 | 'name' => '', |
| 65 | + 'title' => '', |
62 | 66 | 'enabled' => '0', |
63 | 67 | 'header' => 'Thank you for taking this short survey. Please fill out the following questions:', |
64 | 68 | 'footer' => '', |
65 | 69 | 'thanks' => 'Thank you for your responses.', |
66 | 70 | 'user_type' => self::$USER_ALL, |
67 | 71 | 'namespaces' => array(), |
| 72 | + 'ratio' => 100, |
| 73 | + 'expiry' => 60 * 60 * 24 * 30 |
68 | 74 | ); |
69 | 75 | } |
70 | 76 | |
— | — | @@ -288,7 +294,7 @@ |
289 | 295 | foreach ( $submissionsForSurvey as $nr => $submission ) { |
290 | 296 | $sucecss = $dbw->delete( |
291 | 297 | 'survey_answers', |
292 | | - array( 'answer_submission_id' => $submission->getId() ) |
| 298 | + array( 'answer_submission_id' => $submission->id ) |
293 | 299 | ) && $sucecss; |
294 | 300 | |
295 | 301 | if ( $nr % 500 == 0 ) { |
Index: trunk/extensions/Survey/resources/ext.survey.special.survey.js |
— | — | @@ -70,21 +70,25 @@ |
71 | 71 | $table.append( $tr ); |
72 | 72 | |
73 | 73 | $tr.append( $( '<td />' ).attr( { 'class': 'mw-label question-label' } ).html( |
74 | | - $( '<label />' ).text( mw.msg( 'survey-special-label-addquestion' ) ) |
| 74 | + '' //$( '<label />' ).text( mw.msg( 'survey-special-label-addquestion' ) ) |
75 | 75 | ) ); |
76 | 76 | |
77 | 77 | $tr.append( $( '<td />' ).attr( { 'class': 'mw-input' } ).html( |
78 | | - getQuestionInput( { 'id': 'new', 'answers': [], 'type': 0 } ) |
79 | | - ).append( $( '<button />' ).button( { 'label': mw.msg( 'survey-special-label-button' ) } ) |
80 | | - .click( function() { onAddQuestionRequest(); return false; } ) |
| 78 | + '' //getQuestionInput( { 'id': 'new', 'answers': [], 'type': 0 } ) |
| 79 | + ).append( $( '<button />' ).button( { 'label': mw.msg( 'survey-special-label-add-first' ) } ) |
| 80 | + .click( function() { |
| 81 | + $( this ).button( { 'label': mw.msg( 'survey-special-label-add-another' ) } ); |
| 82 | + onAddQuestionRequest(); |
| 83 | + return false; |
| 84 | + } ) |
81 | 85 | ) ); |
82 | | - |
83 | | - $( '#survey-question-text-new' ).keypress( function( event ) { |
84 | | - if ( event.which == '13' ) { |
85 | | - event.preventDefault(); |
86 | | - onAddQuestionRequest(); |
87 | | - } |
88 | | - } ); |
| 86 | +// |
| 87 | +// $( '#survey-question-text-new' ).keypress( function( event ) { |
| 88 | +// if ( event.which == '13' ) { |
| 89 | +// event.preventDefault(); |
| 90 | +// onAddQuestionRequest(); |
| 91 | +// } |
| 92 | +// } ); |
89 | 93 | }; |
90 | 94 | |
91 | 95 | function addQuestion( question ) { |
— | — | @@ -187,13 +191,13 @@ |
188 | 192 | |
189 | 193 | function onAddQuestionRequest() { |
190 | 194 | addQuestion( { |
191 | | - 'text': $( '#survey-question-text-new' ).val(), |
192 | | - 'required': !!$( '#survey-question-required-new' ).attr( 'checked' ), |
193 | | - 'type': $( '#survey-question-type-new' ).val(), |
194 | | - 'id': 'new-' + newQuestionNr++, |
195 | | - 'answers': $( '#survey-question-answers-new' ).val().split( '\n' ) |
| 195 | + 'text': '', // $( '#survey-question-text-new' ).val(), |
| 196 | + 'required': false, //!!$( '#survey-question-required-new' ).attr( 'checked' ), |
| 197 | + 'type': 0, // $( '#survey-question-type-new' ).val(), |
| 198 | + 'id': 'new-' + ++newQuestionNr, |
| 199 | + 'answers': [] //$( '#survey-question-answers-new' ).val().split( '\n' ) |
196 | 200 | } ); |
197 | | - $( '#survey-question-text-new' ).focus().select(); |
| 201 | + $( '#survey-question-text-new-' + newQuestionNr ).focus().select(); |
198 | 202 | $( 'html' ).animate( { scrollTop: $( document ).height() }, 'fast' ); |
199 | 203 | }; |
200 | 204 | |