Index: trunk/extensions/EducationProgram/sql/EducationProgram.sql |
— | — | @@ -56,13 +56,16 @@ |
57 | 57 | term_description TEXT NOT NULL, -- Description of the term |
58 | 58 | term_online_ambs BLOB NOT NULL, -- List of associated online abmassadors |
59 | 59 | term_campus_ambs BLOB NOT NULL, -- List of associated campus abmassadors |
60 | | - term_token VARCHAR(255) NOT NULL -- Token needed to enroll |
| 60 | + term_token VARCHAR(255) NOT NULL, -- Token needed to enroll |
| 61 | + |
| 62 | + term_students SMALLINT unsigned NOT NULL -- Amount of students |
61 | 63 | ) /*$wgDBTableOptions*/; |
62 | 64 | |
63 | 65 | CREATE INDEX /*i*/ep_term_year ON /*_*/ep_terms (term_year); |
64 | 66 | CREATE INDEX /*i*/ep_term_start ON /*_*/ep_terms (term_start); |
65 | 67 | CREATE INDEX /*i*/ep_term_end ON /*_*/ep_terms (term_end); |
66 | 68 | CREATE UNIQUE INDEX /*i*/ep_trem_period ON /*_*/ep_terms (term_org_id, term_start, term_start); |
| 69 | +CREATE INDEX /*i*/ep_term_students ON /*_*/ep_terms (term_students); |
67 | 70 | |
68 | 71 | -- Students. In essence this is an extension to the user table. |
69 | 72 | CREATE TABLE IF NOT EXISTS /*_*/ep_students ( |
Index: trunk/extensions/EducationProgram/sql/AddStudentsField.sql |
— | — | @@ -0,0 +1,8 @@ |
| 2 | +-- SQL for the Education Program extension. |
| 3 | +-- Adds additional fields. |
| 4 | +-- Licence: GNU GPL v3+ |
| 5 | +-- Author: Jeroen De Dauw < jeroendedauw@gmail.com > |
| 6 | + |
| 7 | +ALTER TABLE /*_*/ep_terms ADD COLUMN term_students SMALLINT unsigned NOT NULL default 0; |
| 8 | + |
| 9 | +CREATE INDEX /*i*/ep_term_students ON /*_*/ep_terms (term_students); |
\ No newline at end of file |
Property changes on: trunk/extensions/EducationProgram/sql/AddStudentsField.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 10 | + native |
Index: trunk/extensions/EducationProgram/includes/EPStudent.php |
— | — | @@ -93,6 +93,7 @@ |
94 | 94 | foreach ( $terms as /* EPTerm */ $term ) { |
95 | 95 | EPCourse::updateSummaryFields( 'students', array( 'id' => $term->getField( 'course_id' ) ) ); |
96 | 96 | EPOrg::updateSummaryFields( 'students', array( 'id' => $term->getField( 'org_id' ) ) ); |
| 97 | + EPTerm::updateSummaryFields( 'students', array( 'id' => $this->getId() ) ); |
97 | 98 | } |
98 | 99 | |
99 | 100 | return $success; |
Index: trunk/extensions/EducationProgram/includes/EPTermPager.php |
— | — | @@ -34,6 +34,7 @@ |
35 | 35 | 'year', |
36 | 36 | 'start', |
37 | 37 | 'end', |
| 38 | + 'students', |
38 | 39 | ); |
39 | 40 | } |
40 | 41 | |
— | — | @@ -81,6 +82,9 @@ |
82 | 83 | break; |
83 | 84 | case '_status': |
84 | 85 | $value = htmlspecialchars( EPTerm::getStatusMessage( $this->currentObject->getStatus() ) ); |
| 86 | + case 'students': |
| 87 | + $value = htmlspecialchars( $this->getLanguage()->formatNum( $value ) ); |
| 88 | + break; |
85 | 89 | } |
86 | 90 | |
87 | 91 | return $value; |
— | — | @@ -96,6 +100,7 @@ |
97 | 101 | 'year', |
98 | 102 | 'start', |
99 | 103 | 'end', |
| 104 | + 'students', |
100 | 105 | ); |
101 | 106 | } |
102 | 107 | |
Index: trunk/extensions/EducationProgram/includes/EPTerm.php |
— | — | @@ -91,6 +91,8 @@ |
92 | 92 | 'end' => 'str', // TS_MW |
93 | 93 | 'description' => 'str', |
94 | 94 | 'token' => 'str', |
| 95 | + |
| 96 | + 'students' => 'int', |
95 | 97 | ); |
96 | 98 | } |
97 | 99 | |
— | — | @@ -105,6 +107,8 @@ |
106 | 108 | 'end' => wfTimestamp( TS_MW ), |
107 | 109 | 'description' => '', |
108 | 110 | 'token' => '', |
| 111 | + |
| 112 | + 'students' => 0, |
109 | 113 | ); |
110 | 114 | } |
111 | 115 | |
— | — | @@ -168,7 +172,7 @@ |
169 | 173 | */ |
170 | 174 | public function loadSummaryFields( $summaryFields = null ) { |
171 | 175 | if ( is_null( $summaryFields ) ) { |
172 | | - $summaryFields = array( 'org_id' ); |
| 176 | + $summaryFields = array( 'org_id', 'students' ); |
173 | 177 | } |
174 | 178 | else { |
175 | 179 | $summaryFields = (array)$summaryFields; |
— | — | @@ -179,7 +183,17 @@ |
180 | 184 | if ( in_array( 'org_id', $summaryFields ) ) { |
181 | 185 | $fields['org_id'] = $this->getCourse( 'org_id' )->getField( 'org_id' ); |
182 | 186 | } |
| 187 | + |
| 188 | + if ( in_array( 'students', $summaryFields ) ) { |
| 189 | + $fields['students'] = wfGetDB( DB_SLAVE )->select( |
| 190 | + 'ep_students_per_term', |
| 191 | + 'COUNT(*) AS rowcount', |
| 192 | + array( 'spt_term_id' => $this->getId() ) |
| 193 | + ); |
183 | 194 | |
| 195 | + $fields['students'] = $fields['students']->fetchObject()->rowcount; |
| 196 | + } |
| 197 | + |
184 | 198 | $this->setFields( $fields ); |
185 | 199 | } |
186 | 200 | |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -205,6 +205,7 @@ |
206 | 206 | 'eptermpager-filter-org-id' => 'Institution', |
207 | 207 | 'eptermpager-header-status' => 'Status', |
208 | 208 | 'eptermpager-filter-status' => 'Status', |
| 209 | + 'eptermpager-header-students' => 'Students', |
209 | 210 | |
210 | 211 | // Student pager |
211 | 212 | 'epstudentpager-header-user-id' => 'User', |
Index: trunk/extensions/EducationProgram/EducationProgram.hooks.php |
— | — | @@ -52,6 +52,14 @@ |
53 | 53 | dirname( __FILE__ ) . '/sql/AddMentorFields.sql', |
54 | 54 | true |
55 | 55 | ) ); |
| 56 | + |
| 57 | + $updater->addExtensionUpdate( array( |
| 58 | + 'addField', |
| 59 | + 'ep_terms', |
| 60 | + 'term_students', |
| 61 | + dirname( __FILE__ ) . '/sql/AddStudentsField.sql', |
| 62 | + true |
| 63 | + ) ); |
56 | 64 | |
57 | 65 | return true; |
58 | 66 | } |