Index: trunk/extensions/EducationProgram/specials/SpecialTerms.php |
— | — | @@ -1,46 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Page listing all courses in a pager with filter control. |
6 | | - * Also has a form for adding new items for those with matching privileges. |
7 | | - * |
8 | | - * @since 0.1 |
9 | | - * |
10 | | - * @file SpecialCourses.php |
11 | | - * @ingroup EducationProgram |
12 | | - * |
13 | | - * @licence GNU GPL v3 or later |
14 | | - * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
15 | | - */ |
16 | | -class SpecialCourses extends SpecialEPPage { |
17 | | - |
18 | | - /** |
19 | | - * Constructor. |
20 | | - * |
21 | | - * @since 0.1 |
22 | | - */ |
23 | | - public function __construct() { |
24 | | - parent::__construct( 'Courses' ); |
25 | | - } |
26 | | - |
27 | | - /** |
28 | | - * Main method. |
29 | | - * |
30 | | - * @since 0.1 |
31 | | - * |
32 | | - * @param string|null $subPage |
33 | | - */ |
34 | | - public function execute( $subPage ) { |
35 | | - parent::execute( $subPage ); |
36 | | - |
37 | | - if ( $this->subPage === '' ) { |
38 | | - $this->displayNavigation(); |
39 | | - EPCourse::displayAddNewRegion( $this->getContext() ); |
40 | | - EPCourse::displayPager( $this->getContext() ); |
41 | | - } |
42 | | - else { |
43 | | - $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Course', $this->subPage )->getLocalURL() ); |
44 | | - } |
45 | | - } |
46 | | - |
47 | | -} |
Index: trunk/extensions/EducationProgram/specials/SpecialTerm.php |
— | — | @@ -1,132 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Shows the info for a single course, with management and |
6 | | - * enrollment controls depending on the user and his rights. |
7 | | - * |
8 | | - * @since 0.1 |
9 | | - * |
10 | | - * @file SpecialCourse.php |
11 | | - * @ingroup EducationProgram |
12 | | - * |
13 | | - * @licence GNU GPL v3 or later |
14 | | - * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
15 | | - */ |
16 | | -class SpecialCourse extends SpecialEPPage { |
17 | | - |
18 | | - /** |
19 | | - * Constructor. |
20 | | - * |
21 | | - * @since 0.1 |
22 | | - */ |
23 | | - public function __construct() { |
24 | | - parent::__construct( 'Course' ); |
25 | | - } |
26 | | - |
27 | | - /** |
28 | | - * Main method. |
29 | | - * |
30 | | - * @since 0.1 |
31 | | - * |
32 | | - * @param string $subPage |
33 | | - */ |
34 | | - public function execute( $subPage ) { |
35 | | - parent::execute( $subPage ); |
36 | | - |
37 | | - $out = $this->getOutput(); |
38 | | - |
39 | | - if ( trim( $subPage ) === '' ) { |
40 | | - $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Courses' )->getLocalURL() ); |
41 | | - } |
42 | | - else { |
43 | | - $out->setPageTitle( wfMsgExt( 'ep-course-title', 'parsemag', $this->subPage ) ); |
44 | | - |
45 | | - $course = EPCourse::selectRow( null, array( 'id' => $this->subPage ) ); |
46 | | - |
47 | | - if ( $course === false ) { |
48 | | - $this->displayNavigation(); |
49 | | - |
50 | | - if ( $this->getUser()->isAllowed( 'ep-term' ) ) { |
51 | | - $out->addWikiMsg( 'ep-course-create', $this->subPage ); |
52 | | - EPCourse::displayAddNewRegion( $this->getContext(), array( 'id' => $this->subPage ) ); |
53 | | - } |
54 | | - else { |
55 | | - $out->addWikiMsg( 'ep-course-none', $this->subPage ); |
56 | | - } |
57 | | - } |
58 | | - else { |
59 | | - $links = array(); |
60 | | - |
61 | | - if ( $this->getUser()->isAllowed( 'ep-course' ) ) { |
62 | | - $links[wfMsg( 'ep-course-nav-edit' )] = |
63 | | - array( SpecialPage::getTitleFor( 'EditCourse', $this->subPage ) ) |
64 | | - + Linker::tooltipAndAccesskeyAttribs( 'ep-edit-course' ); |
65 | | - } |
66 | | - |
67 | | - $this->displayNavigation( $links ); |
68 | | - |
69 | | - $this->displaySummary( $course ); |
70 | | - |
71 | | - $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-description' ) ) ); |
72 | | - |
73 | | - $out->addHTML( $this->getOutput()->parse( $course->getField( 'description' ) ) ); |
74 | | - |
75 | | - $studentIds = array_map( |
76 | | - function( EPStudent $student ) { |
77 | | - return $student->getId(); |
78 | | - }, |
79 | | - $course->getStudents( 'id' ) |
80 | | - ); |
81 | | - |
82 | | - if ( count( $studentIds ) > 0 ) { |
83 | | - $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-students' ) ) ); |
84 | | - EPStudent::displayPager( $this->getContext(), array( 'id' => $studentIds ) ); |
85 | | - } |
86 | | - else { |
87 | | - // TODO |
88 | | - } |
89 | | - } |
90 | | - } |
91 | | - } |
92 | | - |
93 | | - /** |
94 | | - * Gets the summary data. |
95 | | - * |
96 | | - * @since 0.1 |
97 | | - * |
98 | | - * @param EPCourse $course |
99 | | - * |
100 | | - * @return array |
101 | | - */ |
102 | | - protected function getSummaryData( EPDBObject $course ) { |
103 | | - $stats = array(); |
104 | | - |
105 | | - $org = EPOrg::selectFieldsRow( 'name', array( 'id' => $course->getField( 'org_id' ) ) ); |
106 | | - |
107 | | - $stats['org'] = Linker::linkKnown( |
108 | | - SpecialPage::getTitleFor( 'Institution', $org ), |
109 | | - htmlspecialchars( $org ) |
110 | | - ); |
111 | | - |
112 | | - $course = EPCourse::selectFieldsRow( 'name', array( 'id' => $course->getField( 'course_id' ) ) ); |
113 | | - |
114 | | - $stats['course'] = Linker::linkKnown( |
115 | | - SpecialPage::getTitleFor( 'Course', $course ), |
116 | | - htmlspecialchars( $course ) |
117 | | - ); |
118 | | - |
119 | | - $stats['year'] = htmlspecialchars( $this->getLanguage()->formatNum( $course->getField( 'year' ), true ) ); |
120 | | - $stats['start'] = htmlspecialchars( $this->getLanguage()->timeanddate( $course->getField( 'start' ), true ) ); |
121 | | - $stats['end'] = htmlspecialchars( $this->getLanguage()->timeanddate( $course->getField( 'end' ), true ) ); |
122 | | - |
123 | | - if ( $this->getUser()->isAllowed( 'ep-token' ) ) { |
124 | | - $stats['token'] = Linker::linkKnown( |
125 | | - SpecialPage::getTitleFor( 'Enroll', $course->getId() . '/' . $course->getField( 'token' ) ), |
126 | | - htmlspecialchars( $course->getField( 'token' ) ) |
127 | | - ); |
128 | | - } |
129 | | - |
130 | | - return $stats; |
131 | | - } |
132 | | - |
133 | | -} |
Index: trunk/extensions/EducationProgram/specials/SpecialInstitution.php |
— | — | @@ -100,8 +100,8 @@ |
101 | 101 | |
102 | 102 | $stats['status'] = wfMsgHtml( $org->getField( 'active' ) ? 'ep-institution-active' : 'ep-institution-inactive' ); |
103 | 103 | |
| 104 | + $stats['mcs'] = $this->getLanguage()->formatNum( $org->getField( 'mcs' ) ); |
104 | 105 | $stats['courses'] = $this->getLanguage()->formatNum( $org->getField( 'courses' ) ); |
105 | | - $stats['terms'] = $this->getLanguage()->formatNum( $org->getField( 'terms' ) ); |
106 | 106 | $stats['students'] = $this->getLanguage()->formatNum( $org->getField( 'students' ) ); |
107 | 107 | |
108 | 108 | foreach ( $stats as &$stat ) { |
— | — | @@ -117,10 +117,10 @@ |
118 | 118 | ); |
119 | 119 | } |
120 | 120 | |
121 | | - if ( $org->getField( 'terms' ) > 0 ) { |
122 | | - $stats['terms'] = Linker::linkKnown( |
123 | | - SpecialPage::getTitleFor( 'Terms' ), |
124 | | - $stats['terms'], |
| 121 | + if ( $org->getField( 'mcs' ) > 0 ) { |
| 122 | + $stats['mcs'] = Linker::linkKnown( |
| 123 | + SpecialPage::getTitleFor( 'MasterCourses' ), |
| 124 | + $stats['mcs'], |
125 | 125 | array(), |
126 | 126 | array( 'org_id' => $org->getId() ) |
127 | 127 | ); |
Index: trunk/extensions/EducationProgram/specials/SpecialMyCourses.php |
— | — | @@ -69,19 +69,19 @@ |
70 | 70 | |
71 | 71 | if ( $student->hasTerm() ) { |
72 | 72 | if ( $this->getRequest()->getCheck( 'enrolled' ) ) { |
73 | | - $term = EPTerm::selectRow( null, array( 'id' => $this->getRequest()->getInt( 'enrolled' ) ) ); |
| 73 | + $course = EPCourse::selectRow( null, array( 'id' => $this->getRequest()->getInt( 'enrolled' ) ) ); |
74 | 74 | |
75 | | - if ( $term !== false ) { |
| 75 | + if ( $course !== false ) { |
76 | 76 | $this->showSuccess( wfMessage( |
77 | 77 | 'ep-mycourses-enrolled', |
78 | | - $term->getCourse()->getField( 'name' ), |
79 | | - $term->getOrg()->getField( 'name' ) |
| 78 | + $course->getMasterCourse()->getField( 'name' ), |
| 79 | + $course->getOrg()->getField( 'name' ) |
80 | 80 | ) ); |
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | | - $currentCourses = $student->getCurrentCourses(); |
85 | | - $passedCourses = $student->getPassedCourses(); |
| 84 | + $currentCourses = $student->getCurrentMasterCourses(); |
| 85 | + $passedCourses = $student->getPassedMasterCourses(); |
86 | 86 | |
87 | 87 | if ( count( $currentCourses ) > 0 ) { |
88 | 88 | $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-mycourses-current' ) ) ); |
— | — | @@ -105,7 +105,7 @@ |
106 | 106 | * |
107 | 107 | * @param array $courses |
108 | 108 | */ |
109 | | - protected function displayCoursesList( array /* of EPCourse */ $courses ) { |
| 109 | + protected function displayCoursesList( array /* of EPMC */ $courses ) { |
110 | 110 | $out = $this->getOutput(); |
111 | 111 | |
112 | 112 | $out->addHTML( Xml::openElement( |
— | — | @@ -122,7 +122,7 @@ |
123 | 123 | |
124 | 124 | $out->addHTML( '<tbody>' ); |
125 | 125 | |
126 | | - foreach ( $courses as /* EPCourse */ $course ) { |
| 126 | + foreach ( $courses as /* EPMC */ $course ) { |
127 | 127 | $fields = array(); |
128 | 128 | |
129 | 129 | $fields[] = Linker::link( |
— | — | @@ -183,20 +183,20 @@ |
184 | 184 | * |
185 | 185 | * @since 0.1 |
186 | 186 | * |
187 | | - * @param EPCourse $course |
188 | | - * @param array $terms |
| 187 | + * @param EPCourse $masterCourse |
| 188 | + * @param array $courses |
189 | 189 | */ |
190 | | - protected function displayCourseSummary( EPCourse $course, array /* of EPTerm */ $terms ) { |
| 190 | + protected function displayCourseSummary( EPCourse $masterCourse, array /* of EPCourse */ $courses ) { |
191 | 191 | $info = array(); |
192 | 192 | |
193 | | - $info['name'] = $course->getField( 'name' ); |
194 | | - $info['org'] = EPOrg::selectFieldsRow( 'name', array( 'id' => $course->getField( 'org_id' ) ) ); |
| 193 | + $info['name'] = $masterCourse->getField( 'name' ); |
| 194 | + $info['org'] = EPOrg::selectFieldsRow( 'name', array( 'id' => $masterCourse->getField( 'org_id' ) ) ); |
195 | 195 | |
196 | 196 | foreach ( $info as &$inf ) { |
197 | 197 | $inf = htmlspecialchars( $inf ); |
198 | 198 | } |
199 | 199 | |
200 | | - $this->displaySummary( $course, false, $info ); |
| 200 | + $this->displaySummary( $masterCourse, false, $info ); |
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
Index: trunk/extensions/EducationProgram/specials/SpecialEnroll.php |
— | — | @@ -1,8 +1,8 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
| 5 | + * Enrollment page for students. |
5 | 6 | * |
6 | | - * |
7 | 7 | * @since 0.1 |
8 | 8 | * |
9 | 9 | * @file SpecialEnroll.php |
— | — | @@ -15,9 +15,9 @@ |
16 | 16 | |
17 | 17 | /** |
18 | 18 | * @since 0.1 |
19 | | - * @var EPTerm |
| 19 | + * @var EPCourse |
20 | 20 | */ |
21 | | - protected $term; |
| 21 | + protected $course; |
22 | 22 | |
23 | 23 | /** |
24 | 24 | * Constructor. |
— | — | @@ -45,14 +45,14 @@ |
46 | 46 | $this->showWarning( wfMessage( $args[0] === '' ? 'ep-enroll-no-id' : 'ep-enroll-invalid-id' ) ); |
47 | 47 | } |
48 | 48 | else { |
49 | | - $term = EPTerm::selectRow( null, array( 'id' => $args[0] ) ); |
| 49 | + $course = EPCourse::selectRow( null, array( 'id' => $args[0] ) ); |
50 | 50 | |
51 | | - if ( $term === false ) { |
| 51 | + if ( $course === false ) { |
52 | 52 | $this->showWarning( wfMessage( 'ep-enroll-invalid-id' ) ); |
53 | 53 | } |
54 | | - elseif ( $term->getStatus() === 'current' ) { |
| 54 | + elseif ( $course->getStatus() === 'current' ) { |
55 | 55 | $token = ''; |
56 | | - $tokenIsValid = $term->getField( 'token' ) === ''; |
| 56 | + $tokenIsValid = $course->getField( 'token' ) === ''; |
57 | 57 | |
58 | 58 | if ( !$tokenIsValid ) { |
59 | 59 | if ( count( $args ) === 2 ) { |
— | — | @@ -62,11 +62,11 @@ |
63 | 63 | $token = $this->getRequest()->getText( 'wptoken' ); |
64 | 64 | } |
65 | 65 | |
66 | | - $tokenIsValid = $term->getField( 'token' ) === $token; |
| 66 | + $tokenIsValid = $course->getField( 'token' ) === $token; |
67 | 67 | } |
68 | 68 | |
69 | 69 | if ( $tokenIsValid ) { |
70 | | - $this->showEnrollmentView( $term ); |
| 70 | + $this->showEnrollmentView( $course ); |
71 | 71 | } |
72 | 72 | else { |
73 | 73 | if ( $token !== '' ) { |
— | — | @@ -77,23 +77,23 @@ |
78 | 78 | } |
79 | 79 | } |
80 | 80 | else { |
81 | | - $this->showWarning( wfMessage( 'ep-enroll-term-' . $term->getStatus() ) ); |
| 81 | + $this->showWarning( wfMessage( 'ep-enroll-course-' . $course->getStatus() ) ); |
82 | 82 | } |
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
87 | | - * Shows the actuall enrollment view. |
| 87 | + * Shows the actual enrollment view. |
88 | 88 | * Should only be called after everything checks out, ie the user can enroll in the term. |
89 | 89 | * |
90 | 90 | * @since 0.1 |
91 | 91 | * |
92 | | - * @param EPTerm $term |
| 92 | + * @param EPCourse $course |
93 | 93 | */ |
94 | | - protected function showEnrollmentView( EPTerm $term ) { |
95 | | - $this->term = $term; |
| 94 | + protected function showEnrollmentView( EPCourse $course ) { |
| 95 | + $this->course = $course; |
96 | 96 | |
97 | | - $this->setPageTitle( $term ); |
| 97 | + $this->setPageTitle( $course ); |
98 | 98 | |
99 | 99 | if ( $this->getUser()->isLoggedIn() ) { |
100 | 100 | if ( $this->getUser()->isAllowed( 'ep-enroll' ) ) { |
— | — | @@ -101,11 +101,11 @@ |
102 | 102 | $hasFields = trim( $user->getRealName() ) !== '' && $user->getOption( 'gender' ) !== 'unknown'; |
103 | 103 | |
104 | 104 | if ( $hasFields ) { |
105 | | - $this->doEnroll( $term ); |
| 105 | + $this->doEnroll( $course ); |
106 | 106 | $this->onSuccess(); |
107 | 107 | } |
108 | 108 | else { |
109 | | - $this->showEnrollmentForm( $term ); |
| 109 | + $this->showEnrollmentForm( $course ); |
110 | 110 | } |
111 | 111 | } |
112 | 112 | else { |
— | — | @@ -155,14 +155,14 @@ |
156 | 156 | * |
157 | 157 | * @since 0.1 |
158 | 158 | * |
159 | | - * @param EPTerm $term |
| 159 | + * @param EPCourse $course |
160 | 160 | */ |
161 | | - protected function setPageTitle( EPTerm $term ) { |
| 161 | + protected function setPageTitle( EPCourse $course ) { |
162 | 162 | $this->getOutput()->setPageTitle( wfMsgExt( |
163 | 163 | 'ep-enroll-title', |
164 | 164 | 'parsemag', |
165 | | - $term->getCourse( 'name' )->getField( 'name' ), |
166 | | - $term->getOrg( 'name' )->getField( 'name' ) |
| 165 | + $course->getMasterCourse( 'name' )->getField( 'name' ), |
| 166 | + $course->getOrg( 'name' )->getField( 'name' ) |
167 | 167 | ) ); |
168 | 168 | } |
169 | 169 | |
— | — | @@ -207,11 +207,11 @@ |
208 | 208 | * |
209 | 209 | * @since 0.1 |
210 | 210 | * |
211 | | - * @param EPTerm $term |
| 211 | + * @param EPCourse $course |
212 | 212 | * |
213 | 213 | * @return boolean Success indicator |
214 | 214 | */ |
215 | | - protected function doEnroll( EPTerm $term ) { |
| 215 | + protected function doEnroll( EPCourse $course ) { |
216 | 216 | $student = EPStudent::newFromUser( $this->getUser(), array( 'id' ) ); |
217 | 217 | $hadStudent = $student !== false; |
218 | 218 | |
— | — | @@ -229,7 +229,7 @@ |
230 | 230 | $success = $student->writeToDB(); |
231 | 231 | |
232 | 232 | if ( $success ) { |
233 | | - $success = $student->associateWithTerms( array( $term ) ) && $success; |
| 233 | + $success = $student->associateWithCourses( array( $course ) ) && $success; |
234 | 234 | |
235 | 235 | if ( !$hadStudent ) { |
236 | 236 | $this->getUser()->setOption( 'ep_showtoplink', true ); |
— | — | @@ -245,9 +245,9 @@ |
246 | 246 | * |
247 | 247 | * @since 0.1 |
248 | 248 | * |
249 | | - * @param EPTerm $term |
| 249 | + * @param EPCourse $course |
250 | 250 | */ |
251 | | - protected function showEnrollmentForm( EPTerm $term ) { |
| 251 | + protected function showEnrollmentForm( EPCourse $course ) { |
252 | 252 | $this->getOutput()->addWikiMsg( 'ep-enroll-header' ); |
253 | 253 | |
254 | 254 | $form = new HTMLForm( $this->getFormFields(), $this->getContext() ); |
Index: trunk/extensions/EducationProgram/specials/SpecialCourse.php |
— | — | @@ -0,0 +1,132 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Shows the info for a single course, with management and |
| 6 | + * enrollment controls depending on the user and his rights. |
| 7 | + * |
| 8 | + * @since 0.1 |
| 9 | + * |
| 10 | + * @file SpecialCourse.php |
| 11 | + * @ingroup EducationProgram |
| 12 | + * |
| 13 | + * @licence GNU GPL v3 or later |
| 14 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 15 | + */ |
| 16 | +class SpecialCourse extends SpecialEPPage { |
| 17 | + |
| 18 | + /** |
| 19 | + * Constructor. |
| 20 | + * |
| 21 | + * @since 0.1 |
| 22 | + */ |
| 23 | + public function __construct() { |
| 24 | + parent::__construct( 'Course' ); |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * Main method. |
| 29 | + * |
| 30 | + * @since 0.1 |
| 31 | + * |
| 32 | + * @param string $subPage |
| 33 | + */ |
| 34 | + public function execute( $subPage ) { |
| 35 | + parent::execute( $subPage ); |
| 36 | + |
| 37 | + $out = $this->getOutput(); |
| 38 | + |
| 39 | + if ( trim( $subPage ) === '' ) { |
| 40 | + $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Courses' )->getLocalURL() ); |
| 41 | + } |
| 42 | + else { |
| 43 | + $out->setPageTitle( wfMsgExt( 'ep-course-title', 'parsemag', $this->subPage ) ); |
| 44 | + |
| 45 | + $course = EPCourse::selectRow( null, array( 'id' => $this->subPage ) ); |
| 46 | + |
| 47 | + if ( $course === false ) { |
| 48 | + $this->displayNavigation(); |
| 49 | + |
| 50 | + if ( $this->getUser()->isAllowed( 'ep-term' ) ) { |
| 51 | + $out->addWikiMsg( 'ep-course-create', $this->subPage ); |
| 52 | + EPCourse::displayAddNewRegion( $this->getContext(), array( 'id' => $this->subPage ) ); |
| 53 | + } |
| 54 | + else { |
| 55 | + $out->addWikiMsg( 'ep-course-none', $this->subPage ); |
| 56 | + } |
| 57 | + } |
| 58 | + else { |
| 59 | + $links = array(); |
| 60 | + |
| 61 | + if ( $this->getUser()->isAllowed( 'ep-course' ) ) { |
| 62 | + $links[wfMsg( 'ep-course-nav-edit' )] = |
| 63 | + array( SpecialPage::getTitleFor( 'EditCourse', $this->subPage ) ) |
| 64 | + + Linker::tooltipAndAccesskeyAttribs( 'ep-edit-course' ); |
| 65 | + } |
| 66 | + |
| 67 | + $this->displayNavigation( $links ); |
| 68 | + |
| 69 | + $this->displaySummary( $course ); |
| 70 | + |
| 71 | + $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-description' ) ) ); |
| 72 | + |
| 73 | + $out->addHTML( $this->getOutput()->parse( $course->getField( 'description' ) ) ); |
| 74 | + |
| 75 | + $studentIds = array_map( |
| 76 | + function( EPStudent $student ) { |
| 77 | + return $student->getId(); |
| 78 | + }, |
| 79 | + $course->getStudents( 'id' ) |
| 80 | + ); |
| 81 | + |
| 82 | + if ( count( $studentIds ) > 0 ) { |
| 83 | + $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-students' ) ) ); |
| 84 | + EPStudent::displayPager( $this->getContext(), array( 'id' => $studentIds ) ); |
| 85 | + } |
| 86 | + else { |
| 87 | + // TODO |
| 88 | + } |
| 89 | + } |
| 90 | + } |
| 91 | + } |
| 92 | + |
| 93 | + /** |
| 94 | + * Gets the summary data. |
| 95 | + * |
| 96 | + * @since 0.1 |
| 97 | + * |
| 98 | + * @param EPCourse $course |
| 99 | + * |
| 100 | + * @return array |
| 101 | + */ |
| 102 | + protected function getSummaryData( EPDBObject $course ) { |
| 103 | + $stats = array(); |
| 104 | + |
| 105 | + $org = EPOrg::selectFieldsRow( 'name', array( 'id' => $course->getField( 'org_id' ) ) ); |
| 106 | + |
| 107 | + $stats['org'] = Linker::linkKnown( |
| 108 | + SpecialPage::getTitleFor( 'Institution', $org ), |
| 109 | + htmlspecialchars( $org ) |
| 110 | + ); |
| 111 | + |
| 112 | + $course = EPCourse::selectFieldsRow( 'name', array( 'id' => $course->getField( 'course_id' ) ) ); |
| 113 | + |
| 114 | + $stats['course'] = Linker::linkKnown( |
| 115 | + SpecialPage::getTitleFor( 'Course', $course ), |
| 116 | + htmlspecialchars( $course ) |
| 117 | + ); |
| 118 | + |
| 119 | + $stats['year'] = htmlspecialchars( $this->getLanguage()->formatNum( $course->getField( 'year' ), true ) ); |
| 120 | + $stats['start'] = htmlspecialchars( $this->getLanguage()->timeanddate( $course->getField( 'start' ), true ) ); |
| 121 | + $stats['end'] = htmlspecialchars( $this->getLanguage()->timeanddate( $course->getField( 'end' ), true ) ); |
| 122 | + |
| 123 | + if ( $this->getUser()->isAllowed( 'ep-token' ) ) { |
| 124 | + $stats['token'] = Linker::linkKnown( |
| 125 | + SpecialPage::getTitleFor( 'Enroll', $course->getId() . '/' . $course->getField( 'token' ) ), |
| 126 | + htmlspecialchars( $course->getField( 'token' ) ) |
| 127 | + ); |
| 128 | + } |
| 129 | + |
| 130 | + return $stats; |
| 131 | + } |
| 132 | + |
| 133 | +} |
Property changes on: trunk/extensions/EducationProgram/specials/SpecialCourse.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 134 | + native |
Index: trunk/extensions/EducationProgram/specials/SpecialEPPage.php |
— | — | @@ -168,8 +168,8 @@ |
169 | 169 | protected function getDefaultNavigationItems() { |
170 | 170 | $items = array( |
171 | 171 | wfMsg( 'ep-nav-orgs' ) => SpecialPage::getTitleFor( 'Institutions' ), |
| 172 | + wfMsg( 'ep-nav-mcs' ) => SpecialPage::getTitleFor( 'MasterCourses' ), |
172 | 173 | wfMsg( 'ep-nav-courses' ) => SpecialPage::getTitleFor( 'Courses' ), |
173 | | - wfMsg( 'ep-nav-terms' ) => SpecialPage::getTitleFor( 'Terms' ), |
174 | 174 | ); |
175 | 175 | |
176 | 176 | $items[wfMsg( 'ep-nav-students' )] = SpecialPage::getTitleFor( 'Students' ); |
Index: trunk/extensions/EducationProgram/specials/SpecialEditTerm.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | * @since 0.1 |
21 | 21 | */ |
22 | 22 | public function __construct() { |
23 | | - parent::__construct( 'EditTerm', 'ep-term', 'EPTerm', 'Terms' ); |
| 23 | + parent::__construct( 'EditCourse', 'ep-term', 'EPCourse', 'Courses' ); |
24 | 24 | |
25 | 25 | $this->getOutput()->addModules( 'ep.datepicker' ); |
26 | 26 | } |
Index: trunk/extensions/EducationProgram/specials/SpecialCourses.php |
— | — | @@ -0,0 +1,46 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Page listing all courses in a pager with filter control. |
| 6 | + * Also has a form for adding new items for those with matching privileges. |
| 7 | + * |
| 8 | + * @since 0.1 |
| 9 | + * |
| 10 | + * @file SpecialCourses.php |
| 11 | + * @ingroup EducationProgram |
| 12 | + * |
| 13 | + * @licence GNU GPL v3 or later |
| 14 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 15 | + */ |
| 16 | +class SpecialCourses extends SpecialEPPage { |
| 17 | + |
| 18 | + /** |
| 19 | + * Constructor. |
| 20 | + * |
| 21 | + * @since 0.1 |
| 22 | + */ |
| 23 | + public function __construct() { |
| 24 | + parent::__construct( 'Courses' ); |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * Main method. |
| 29 | + * |
| 30 | + * @since 0.1 |
| 31 | + * |
| 32 | + * @param string|null $subPage |
| 33 | + */ |
| 34 | + public function execute( $subPage ) { |
| 35 | + parent::execute( $subPage ); |
| 36 | + |
| 37 | + if ( $this->subPage === '' ) { |
| 38 | + $this->displayNavigation(); |
| 39 | + EPCourse::displayAddNewRegion( $this->getContext() ); |
| 40 | + EPCourse::displayPager( $this->getContext() ); |
| 41 | + } |
| 42 | + else { |
| 43 | + $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Course', $this->subPage )->getLocalURL() ); |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | +} |
Property changes on: trunk/extensions/EducationProgram/specials/SpecialCourses.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 48 | + native |
Index: trunk/extensions/EducationProgram/specials/SpecialStudent.php |
— | — | @@ -52,14 +52,14 @@ |
53 | 53 | |
54 | 54 | $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-student-terms' ) ) ); |
55 | 55 | |
56 | | - $termIds = array_map( |
57 | | - function( EPTerm $term ) { |
58 | | - return $term->getId(); |
| 56 | + $courseIds = array_map( |
| 57 | + function( EPCourse $course ) { |
| 58 | + return $course->getId(); |
59 | 59 | }, |
60 | | - $student->getTerms( 'id' ) |
| 60 | + $student->getCourses( 'id' ) |
61 | 61 | ); |
62 | 62 | |
63 | | - EPTerm::displayPager( $this->getContext(), array( 'id' => $termIds ) ); |
| 63 | + EPCourse::displayPager( $this->getContext(), array( 'id' => $courseIds ) ); |
64 | 64 | } |
65 | 65 | } |
66 | 66 | } |
Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
5 | | - * Term pager, primarily for Special:Terms. |
| 5 | + * Course pager. |
6 | 6 | * |
7 | 7 | * @since 0.1 |
8 | 8 | * |
— | — | @@ -81,7 +81,7 @@ |
82 | 82 | $value = htmlspecialchars( $this->getLanguage()->date( $value ) ); |
83 | 83 | break; |
84 | 84 | case '_status': |
85 | | - $value = htmlspecialchars( EPTerm::getStatusMessage( $this->currentObject->getStatus() ) ); |
| 85 | + $value = htmlspecialchars( EPCourse::getStatusMessage( $this->currentObject->getStatus() ) ); |
86 | 86 | case 'students': |
87 | 87 | $value = htmlspecialchars( $this->getLanguage()->formatNum( $value ) ); |
88 | 88 | break; |
— | — | @@ -132,7 +132,7 @@ |
133 | 133 | 'type' => 'select', |
134 | 134 | 'options' => array_merge( |
135 | 135 | array( '' => '' ), |
136 | | - EPMC::getCourseOptions( EPMC::select( array( 'name', 'id' ) ) ) |
| 136 | + EPMC::getMasterCourseOptions( EPMC::select( array( 'name', 'id' ) ) ) |
137 | 137 | ), |
138 | 138 | 'value' => '', |
139 | 139 | 'datatype' => 'int', |
Index: trunk/extensions/EducationProgram/includes/EPStudent.php |
— | — | @@ -71,7 +71,7 @@ |
72 | 72 | * |
73 | 73 | * @return bool |
74 | 74 | */ |
75 | | - public function associateWithTerms( array /* of EPCourse */ $courses ) { |
| 75 | + public function associateWithCourses( array /* of EPCourse */ $courses ) { |
76 | 76 | $dbw = wfGetDB( DB_MASTER ); |
77 | 77 | |
78 | 78 | $success = true; |
— | — | @@ -202,7 +202,7 @@ |
203 | 203 | protected function doGetCourses( $fields, array $conditions ) { |
204 | 204 | $conditions[] = array( array( 'ep_students', 'id' ), $this->getId() ); |
205 | 205 | |
206 | | - return EPTerm::select( |
| 206 | + return EPCourse::select( |
207 | 207 | $fields, |
208 | 208 | $conditions, |
209 | 209 | array(), |
Index: trunk/extensions/EducationProgram/includes/EPMC.php |
— | — | @@ -81,7 +81,7 @@ |
82 | 82 | $fields = array(); |
83 | 83 | |
84 | 84 | if ( in_array( 'students', $summaryFields ) ) { |
85 | | - $termIds = EPTerm::selectFields( 'id', array( 'course_id' => $this->getId() ) ); |
| 85 | + $termIds = EPCourse::selectFields( 'id', array( 'mc_id' => $this->getId() ) ); |
86 | 86 | |
87 | 87 | if ( count( $termIds ) > 0 ) { |
88 | 88 | $fields['students'] = wfGetDB( DB_SLAVE )->select( |
— | — | @@ -100,8 +100,8 @@ |
101 | 101 | if ( in_array( 'active', $summaryFields ) ) { |
102 | 102 | $now = wfGetDB( DB_SLAVE )->addQuotes( wfTimestampNow() ); |
103 | 103 | |
104 | | - $fields['active'] = EPTerm::has( array( |
105 | | - 'course_id' => $this->getId(), |
| 104 | + $fields['active'] = EPCourse::has( array( |
| 105 | + 'mc_id' => $this->getId(), |
106 | 106 | 'end >= ' . $now, |
107 | 107 | 'start <= ' . $now, |
108 | 108 | ) ); |
— | — | @@ -125,14 +125,14 @@ |
126 | 126 | $success = parent::removeFromDB(); |
127 | 127 | |
128 | 128 | if ( $success ) { |
129 | | - foreach ( EPTerm::select( 'id', array( 'course_id' => $id ) ) as /* EPTerm */ $term ) { |
130 | | - $term->setUpdateSummaries( false ); |
131 | | - $success = $term->removeFromDB() && $success; |
| 129 | + foreach ( EPCourse::select( 'id', array( 'mc_id' => $id ) ) as /* EPCourse */ $course ) { |
| 130 | + $course->setUpdateSummaries( false ); |
| 131 | + $success = $course->removeFromDB() && $success; |
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
135 | 135 | if ( $this->updateSummaries && $orgId !== false ) { |
136 | | - EPOrg::updateSummaryFields( array( 'terms', 'students', 'courses', 'active' ), array( 'id' => $orgId ) ); |
| 136 | + EPCourse::updateSummaryFields( array( 'mcs', 'students', 'courses', 'active' ), array( 'id' => $orgId ) ); |
137 | 137 | } |
138 | 138 | |
139 | 139 | return $success; |
— | — | @@ -163,8 +163,8 @@ |
164 | 164 | |
165 | 165 | if ( $this->updateSummaries && $success && $oldOrgId !== false && $oldOrgId !== $this->getField( 'org_id' ) ) { |
166 | 166 | $conds = array( 'id' => array( $oldOrgId, $this->getField( 'org_id' ) ) ); |
167 | | - EPTerm::updateSummaryFields( 'org_id', array( 'course_id' => $this->getId() ) ); |
168 | | - EPOrg::updateSummaryFields( array( 'terms', 'students', 'courses', 'active' ), $conds ); |
| 167 | + EPCourse::updateSummaryFields( 'org_id', array( 'mc_id' => $this->getId() ) ); |
| 168 | + EPOrg::updateSummaryFields( array( 'mcs', 'students', 'courses', 'active' ), $conds ); |
169 | 169 | } |
170 | 170 | |
171 | 171 | return $success; |
Index: trunk/extensions/EducationProgram/includes/EPCourse.php |
— | — | @@ -324,7 +324,7 @@ |
325 | 325 | * @param array $conditions |
326 | 326 | */ |
327 | 327 | public static function displayPager( IContextSource $context, array $conditions = array() ) { |
328 | | - $pager = new EPTermPager( $context, $conditions ); |
| 328 | + $pager = new EPCoursePager( $context, $conditions ); |
329 | 329 | |
330 | 330 | if ( $pager->getNumRows() ) { |
331 | 331 | $context->getOutput()->addHTML( |
— | — | @@ -410,7 +410,7 @@ |
411 | 411 | */ |
412 | 412 | public static function displayAddNewRegion( IContextSource $context, array $args = array() ) { |
413 | 413 | if ( EPCourse::has() ) { |
414 | | - EPTerm::displayAddNewControl( $context, $args ); |
| 414 | + EPCourse::displayAddNewControl( $context, $args ); |
415 | 415 | } |
416 | 416 | elseif ( $context->getUser()->isAllowed( 'ep-course' ) ) { |
417 | 417 | $context->getOutput()->addWikiMsg( 'ep-terms-addcoursefirst' ); |
Index: trunk/extensions/EducationProgram/EducationProgram.php |
— | — | @@ -75,8 +75,6 @@ |
76 | 76 | $wgAutoloadClasses['EPPager'] = dirname( __FILE__ ) . '/includes/EPPager.php'; |
77 | 77 | $wgAutoloadClasses['EPStudent'] = dirname( __FILE__ ) . '/includes/EPStudent.php'; |
78 | 78 | $wgAutoloadClasses['EPStudentPager'] = dirname( __FILE__ ) . '/includes/EPStudentPager.php'; |
79 | | -$wgAutoloadClasses['EPTerm'] = dirname( __FILE__ ) . '/includes/EPTerm.php'; |
80 | | -$wgAutoloadClasses['EPTermPager'] = dirname( __FILE__ ) . '/includes/EPTermPager.php'; |
81 | 79 | $wgAutoloadClasses['EPUtils'] = dirname( __FILE__ ) . '/includes/EPUtils.php'; |
82 | 80 | $wgAutoloadClasses['EPOA'] = dirname( __FILE__ ) . '/includes/EPOA.php'; |
83 | 81 | $wgAutoloadClasses['EPOAPager'] = dirname( __FILE__ ) . '/includes/EPOAPager.php'; |