Index: trunk/extensions/EducationProgram/sql/EducationProgram.sql |
— | — | @@ -10,6 +10,7 @@ |
11 | 11 | org_city VARCHAR(255) NOT NULL, -- Name of the city where the org is located |
12 | 12 | org_country VARCHAR(255) NOT NULL, -- Name of the country where the org is located |
13 | 13 | |
| 14 | + -- Summary fields - cahing data or computations on data stored elswhere |
14 | 15 | org_active TINYINT unsigned NOT NULL, -- If the org has any active courses |
15 | 16 | org_courses SMALLINT unsigned NOT NULL, -- Amount of courses |
16 | 17 | org_instructors SMALLINT unsigned NOT NULL, -- Amount of instructors |
— | — | @@ -48,6 +49,7 @@ |
49 | 50 | course_term VARCHAR(255) NOT NULL, -- Academic term |
50 | 51 | course_lang VARCHAR(10) NOT NULL, -- Language (code) |
51 | 52 | |
| 53 | + -- Summary fields - cahing data or computations on data stored elswhere |
52 | 54 | course_students SMALLINT unsigned NOT NULL -- Amount of students |
53 | 55 | ) /*$wgDBTableOptions*/; |
54 | 56 | |
— | — | @@ -134,13 +136,14 @@ |
135 | 137 | |
136 | 138 | |
137 | 139 | |
138 | | -CREATE TABLE IF NOT EXISTS /*_*/ep_cas_per_org ( |
139 | | - cpo_ca_id INT unsigned NOT NULL, -- Foreign key on ep_cas.ca_id |
140 | | - cpo_org_id INT unsigned NOT NULL -- Foreign key on ep_orgs.org_id |
| 140 | +-- Links the campus ambassadors with all their courses. |
| 141 | +-- The is secondary storage for queries. The canonical data is in ep_course.campus_ambs |
| 142 | +CREATE TABLE IF NOT EXISTS /*_*/ep_cas_per_course ( |
| 143 | + cpc_ca_id INT unsigned NOT NULL, -- Foreign key on ep_cas.ca_id |
| 144 | + cpc_course_id INT unsigned NOT NULL -- Foreign key on ep_course.course_id |
141 | 145 | ) /*$wgDBTableOptions*/; |
142 | 146 | |
143 | | -CREATE UNIQUE INDEX /*i*/ep_cas_per_org ON /*_*/ep_cas_per_org (cpo_ca_id, cpo_org_id); |
| 147 | +CREATE UNIQUE INDEX /*i*/ep_cas_per_course ON /*_*/ep_cas_per_course (cpc_ca_id, cpc_course_id); |
144 | 148 | |
145 | 149 | |
146 | 150 | |
— | — | @@ -157,6 +160,17 @@ |
158 | 161 | |
159 | 162 | |
160 | 163 | |
| 164 | +-- Links the online ambassadors with all their courses. |
| 165 | +-- The is secondary storage for queries. The canonical data is in ep_course.online_ambs |
| 166 | +CREATE TABLE IF NOT EXISTS /*_*/ep_oas_per_course ( |
| 167 | + opc_oa_id INT unsigned NOT NULL, -- Foreign key on ep_oas.oa_id |
| 168 | + opc_course_id INT unsigned NOT NULL -- Foreign key on ep_course.course_id |
| 169 | +) /*$wgDBTableOptions*/; |
| 170 | + |
| 171 | +CREATE UNIQUE INDEX /*i*/ep_oas_per_course ON /*_*/ep_oas_per_course (opc_oa_id, opc_course_id); |
| 172 | + |
| 173 | + |
| 174 | + |
161 | 175 | -- Revision table, holding blobs of various types of objects, such as orgs or students. |
162 | 176 | -- This is somewhat based on the (core) revision table and is meant to serve |
163 | 177 | -- as a prototype for a more general system to store this kind of data in a visioned fashion. |
Index: trunk/extensions/EducationProgram/sql/AddAmbassadorLinks.sql |
— | — | @@ -0,0 +1,22 @@ |
| 2 | +-- MySQL for the Education Program extension. |
| 3 | +-- Licence: GNU GPL v3+ |
| 4 | +-- Author: Jeroen De Dauw < jeroendedauw@gmail.com > |
| 5 | + |
| 6 | + |
| 7 | +-- Links the campus ambassadors with all their courses. |
| 8 | +-- The is secondary storage for queries. The canonical data is in ep_course.campus_ambs |
| 9 | +CREATE TABLE IF NOT EXISTS /*_*/ep_cas_per_course ( |
| 10 | + cpc_ca_id INT unsigned NOT NULL, -- Foreign key on ep_cas.ca_id |
| 11 | + cpc_course_id INT unsigned NOT NULL -- Foreign key on ep_course.course_id |
| 12 | +) /*$wgDBTableOptions*/; |
| 13 | + |
| 14 | +CREATE UNIQUE INDEX /*i*/ep_cas_per_course ON /*_*/ep_cas_per_course (cpc_ca_id, cpc_course_id); |
| 15 | + |
| 16 | +-- Links the online ambassadors with all their courses. |
| 17 | +-- The is secondary storage for queries. The canonical data is in ep_course.online_ambs |
| 18 | +CREATE TABLE IF NOT EXISTS /*_*/ep_oas_per_course ( |
| 19 | + opc_oa_id INT unsigned NOT NULL, -- Foreign key on ep_oas.oa_id |
| 20 | + opc_course_id INT unsigned NOT NULL -- Foreign key on ep_course.course_id |
| 21 | +) /*$wgDBTableOptions*/; |
| 22 | + |
| 23 | +CREATE UNIQUE INDEX /*i*/ep_oas_per_course ON /*_*/ep_oas_per_course (opc_oa_id, opc_course_id); |
\ No newline at end of file |
Property changes on: trunk/extensions/EducationProgram/sql/AddAmbassadorLinks.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 24 | + native |
Index: trunk/extensions/EducationProgram/specials/SpecialMyCourses.php |
— | — | @@ -70,8 +70,18 @@ |
71 | 71 | |
72 | 72 | protected function displayCourses() { |
73 | 73 | $this->displayEnrollment(); |
74 | | - $this->displayMentorship(); |
75 | | - $this->displayInstructorship(); |
| 74 | + |
| 75 | + if ( $this->getUser()->isAllowed( 'ep-instructor' ) ) { |
| 76 | + $this->displayInstructorship(); |
| 77 | + } |
| 78 | + |
| 79 | + if ( $this->getUser()->isAllowed( 'ep-online' ) ) { |
| 80 | + $this->displayOnlineMentorship(); |
| 81 | + } |
| 82 | + |
| 83 | + if ( $this->getUser()->isAllowed( 'ep-campus' ) ) { |
| 84 | + $this->displayCampusMentorship(); |
| 85 | + } |
76 | 86 | } |
77 | 87 | |
78 | 88 | protected function displayEnrollment() { |
— | — | @@ -116,10 +126,14 @@ |
117 | 127 | } |
118 | 128 | } |
119 | 129 | |
120 | | - protected function displayMentorship() { |
| 130 | + protected function displayOnlineMentorship() { |
121 | 131 | |
122 | 132 | } |
123 | 133 | |
| 134 | + protected function displayCampusMentorship() { |
| 135 | + |
| 136 | + } |
| 137 | + |
124 | 138 | protected function displayInstructorship() { |
125 | 139 | |
126 | 140 | } |
Index: trunk/extensions/EducationProgram/includes/EPCourse.php |
— | — | @@ -266,11 +266,13 @@ |
267 | 267 | $success = parent::removeFromDB(); |
268 | 268 | |
269 | 269 | if ( $success && $this->updateSummaries ) { |
270 | | - EPOrg::updateSummaryFields( array( 'courses', 'students', 'active' ), array( 'id' => $orgId ) ); |
| 270 | + EPOrg::updateSummaryFields( array( 'courses', 'students', 'active', 'instructors', 'oas', 'cas' ), array( 'id' => $orgId ) ); |
271 | 271 | } |
272 | 272 | |
273 | 273 | if ( $success ) { |
274 | 274 | $success = wfGetDB( DB_MASTER )->delete( 'ep_students_per_course', array( 'spc_course_id' => $id ) ) && $success; |
| 275 | + $success = wfGetDB( DB_MASTER )->delete( 'ep_cas_per_course', array( 'cpc_course_id' => $id ) ) && $success; |
| 276 | + $success = wfGetDB( DB_MASTER )->delete( 'ep_oas_per_course', array( 'opc_course_id' => $id ) ) && $success; |
275 | 277 | } |
276 | 278 | |
277 | 279 | return $success; |
— | — | @@ -282,16 +284,34 @@ |
283 | 285 | */ |
284 | 286 | protected function updateInDB() { |
285 | 287 | if ( $this->updateSummaries ) { |
286 | | - $oldOrgId = $this->hasField( 'org_id' ) ? self::selectFieldsRow( 'org_id', array( 'id' => $this->getId() ) ) : false; |
| 288 | + $currentFields = array(); |
| 289 | + |
| 290 | + foreach ( array( 'org_id', 'online_ambs', 'campus_ambs' ) as $field ) { |
| 291 | + if ( $this->hasField( $field ) ) { |
| 292 | + $currentFields[] = $field; |
| 293 | + } |
| 294 | + } |
| 295 | + |
| 296 | + if ( count( $currentFields ) > 0 ) { |
| 297 | + $currentFields = self::selectFieldsRow( $currentFields, array( 'id' => $this->getId() ) ); |
| 298 | + } |
287 | 299 | } |
288 | 300 | |
289 | 301 | $success = parent::updateInDB(); |
290 | 302 | |
291 | 303 | if ( $this->updateSummaries && $success ) { |
292 | | - if ( $oldOrgId !== false && $oldOrgId !== $this->getField( 'org_id' ) ) { |
| 304 | + if ( array_key_exists( 'org_id', $currentFields ) && $currentFields['org_id'] !== $this->getField( 'org_id' ) ) { |
293 | 305 | $conds = array( 'id' => array( $oldOrgId, $this->getField( 'org_id' ) ) ); |
294 | | - EPOrg::updateSummaryFields( array( 'courses', 'students', 'active' ), $conds ); |
| 306 | + EPOrg::updateSummaryFields( array( 'courses', 'students', 'active', 'instructors', 'oas', 'cas' ), $conds ); |
295 | 307 | } |
| 308 | + |
| 309 | + foreach ( array( 'oas', 'cas' ) as $ambs ) { |
| 310 | + $field = $ambs === 'oas' ? 'online_ambs' : 'campus_ambs'; |
| 311 | + |
| 312 | + if ( array_key_exists( $field, $currentFields ) && $currentFields[$field] !== $this->getField( $field ) ) { |
| 313 | + // TODO |
| 314 | + } |
| 315 | + } |
296 | 316 | } |
297 | 317 | |
298 | 318 | return $success; |
Index: trunk/extensions/EducationProgram/EducationProgram.hooks.php |
— | — | @@ -29,13 +29,12 @@ |
30 | 30 | dirname( __FILE__ ) . '/sql/EducationProgram.sql' |
31 | 31 | ); |
32 | 32 | |
33 | | -// $updater->addExtensionUpdate( array( |
34 | | -// 'addField', |
35 | | -// 'ep_courses', |
36 | | -// 'course_name', |
37 | | -// dirname( __FILE__ ) . '/sql/AddExtraFields.sql', |
38 | | -// true |
39 | | -// ) ); |
| 33 | + $updater->addExtensionUpdate( array( |
| 34 | + 'addTable', |
| 35 | + 'ep_oas_per_course', |
| 36 | + dirname( __FILE__ ) . '/sql/AddAmbassadorLinks.sql', |
| 37 | + true |
| 38 | + ) ); |
40 | 39 | |
41 | 40 | return true; |
42 | 41 | } |