r109991 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109990‎ | r109991 | r109992 >
Date:03:05, 25 January 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
follow up r109985 r109989; updated messages and field names
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/EducationProgram.php (modified) (history)
  • /trunk/extensions/EducationProgram/api/ApiInstructor.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCoursePager.php (modified) (history)
  • /trunk/extensions/EducationProgram/resources/ep.instructor.js (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialEditCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialEnroll.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialMyCourses.php (modified) (history)
  • /trunk/extensions/EducationProgram/sql/EducationProgram.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/sql/EducationProgram.sql
@@ -29,7 +29,7 @@
3030
3131
3232
 33+-- Courses.
3334 CREATE TABLE IF NOT EXISTS /*_*/ep_courses (
3435 course_id INT unsigned NOT NULL auto_increment PRIMARY KEY,
3536
Index: trunk/extensions/EducationProgram/specials/SpecialMyCourses.php
@@ -74,7 +74,7 @@
7575 if ( $course !== false ) {
7676 $this->showSuccess( wfMessage(
7777 'ep-mycourses-enrolled',
78 - $course->getMasterCourse()->getField( 'name' ),
 78+ $course->getField( 'name' ),
7979 $course->getOrg()->getField( 'name' )
8080 ) );
8181 }
@@ -126,8 +126,8 @@
127127 $fields = array();
128128
129129 $fields[] = Linker::link(
130 - $this->getTitle( $course->getMasterCourse()->getField( 'name' ) ),
131 - '<b>' . htmlspecialchars( $course->getMasterCourse()->getField( 'name' ) ) . '</b>'
 130+ $this->getTitle( $course->getField( 'name' ) ),
 131+ '<b>' . htmlspecialchars( $course->getField( 'name' ) ) . '</b>'
132132 );
133133
134134 $fields[] = Linker::link(
@@ -158,9 +158,8 @@
159159 $out = $this->getOutput();
160160
161161 $course = EPCourse::selectRow( null, array( 'name' => $courseName ) );
162 - $terms = $student->getCourses( null, array( 'course_id' => $course->getId() ) );
163162
164 - if ( $course !== false && count( $terms ) > 0 ) {
 163+ if ( $course !== false ) {
165164 $out->addWikiMsg( 'ep-mycourses-show-all' );
166165
167166 $out->setPageTitle( wfMsgExt(
@@ -170,7 +169,7 @@
171170 $course->getOrg( 'name' )->getField( 'name' )
172171 ) );
173172
174 - $this->displayCourseSummary( $course, $terms );
 173+ $this->displayCourseSummary( $course );
175174 }
176175 else {
177176 $this->showError( wfMessage( 'ep-mycourses-no-such-course', $courseName ) );
@@ -183,20 +182,19 @@
184183 *
185184 * @since 0.1
186185 *
187 - * @param EPCourse $masterCourse
188 - * @param array $courses
 186+ * @param EPCourse $course
189187 */
190 - protected function displayCourseSummary( EPCourse $masterCourse, array /* of EPCourse */ $courses ) {
 188+ protected function displayCourseSummary( EPCourse $course ) {
191189 $info = array();
192190
193 - $info['name'] = $masterCourse->getField( 'name' );
194 - $info['org'] = EPOrg::selectFieldsRow( 'name', array( 'id' => $masterCourse->getField( 'org_id' ) ) );
 191+ $info['name'] = $course->getField( 'name' );
 192+ $info['org'] = EPOrg::selectFieldsRow( 'name', array( 'id' => $course->getField( 'org_id' ) ) );
195193
196194 foreach ( $info as &$inf ) {
197195 $inf = htmlspecialchars( $inf );
198196 }
199197
200 - $this->displaySummary( $masterCourse, false, $info );
 198+ $this->displaySummary( $course, false, $info );
201199 }
202200
203201 /**
Index: trunk/extensions/EducationProgram/specials/SpecialEnroll.php
@@ -168,7 +168,7 @@
169169 $this->getOutput()->setPageTitle( wfMsgExt(
170170 'ep-enroll-title',
171171 'parsemag',
172 - $course->getMasterCourse( 'name' )->getField( 'name' ),
 172+ $course->getField( 'name' ),
173173 $course->getOrg( 'name' )->getField( 'name' )
174174 ) );
175175 }
Index: trunk/extensions/EducationProgram/specials/SpecialEditCourse.php
@@ -34,13 +34,13 @@
3535
3636 $orgOptions = EPOrg::getOrgOptions();
3737
38 - $fields['mc_id'] = array (
 38+ $fields['org_id'] = array (
3939 'type' => 'select',
40 - 'label-message' => 'ep-course-edit-mastercourse',
 40+ 'label-message' => 'ep-course-edit-org',
4141 'required' => true,
4242 'options' => $orgOptions,
4343 'validation-callback' => function ( $value, array $alldata = null ) use ( $orgOptions ) {
44 - return in_array( (int)$value, array_values( $orgOptions ) ) ? true : wfMsg( 'ep-course-invalid-course' );
 44+ return in_array( (int)$value, array_values( $orgOptions ) ) ? true : wfMsg( 'ep-course-invalid-org' );
4545 },
4646 );
4747
Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php
@@ -111,9 +111,9 @@
112112 public function getFieldNames() {
113113 $fields = parent::getFieldNames();
114114
115 - if ( array_key_exists( 'mc_id', $this->conds ) && array_key_exists( 'org_id', $fields ) ) {
116 - unset( $fields['org_id'] );
117 - }
 115+// if ( array_key_exists( 'mc_id', $this->conds ) && array_key_exists( 'org_id', $fields ) ) {
 116+// unset( $fields['org_id'] );
 117+// }
118118
119119 $fields = wfArrayInsertAfter( $fields, array( '_status' => 'status' ), 'students' );
120120
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -214,10 +214,6 @@
215215 * @see EPDBObject::insertIntoDB()
216216 */
217217 protected function insertIntoDB() {
218 - if ( !$this->hasField( 'org_id' ) ) {
219 - $this->setField( 'org_id', $this->getMasterCourse( 'org_id' )->getField( 'org_id' ) );
220 - }
221 -
222218 $success = parent::insertIntoDB();
223219
224220 if ( $success && $this->updateSummaries ) {
@@ -235,9 +231,8 @@
236232 $id = $this->getId();
237233
238234 if ( $this->updateSummaries ) {
239 - $this->loadFields( array( 'org_id', 'mc_id' ) );
 235+ $this->loadFields( array( 'org_id' ) );
240236 $orgId = $this->getField( 'org_id' );
241 - $courseId = $this->getField( 'mc_id' );
242237 }
243238
244239 $success = parent::removeFromDB();
@@ -349,7 +344,7 @@
350345
351346 $out->addHTML( Html::element( 'p', array(), wfMsg( 'ep-courses-namedoc' ) ) );
352347
353 - $out->addHTML( Html::element( 'label', array( 'for' => 'newmc' ), wfMsg( 'ep-courses-neworg' ) ) );
 348+ $out->addHTML( Html::element( 'label', array( 'for' => 'neworg' ), wfMsg( 'ep-courses-neworg' ) ) );
354349
355350 $select = new XmlSelect(
356351 'neworg',
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -74,10 +74,6 @@
7575 'logentry-course-remove' => '$1 removed course $3',
7676 'logentry-course-update' => '$1 updated course $3',
7777
78 - 'logentry-mc-add' => '$1 created master course $3',
79 - 'logentry-mc-remove' => '$1 removed master course $3',
80 - 'logentry-mc-update' => '$1 updated master course $3',
81 -
8278 'logentry-instructor-add' => '$1 {{GENDER:$2|added}} {{PLURAL:$4|instructor|instructors}} $5 to course $3',
8379 'logentry-instructor-remove' => '$1 {{GENDER:$2|removed}} {{PLURAL:$4|instructor|instructors}} $5 from course $3',
8480 'logentry-instructor-selfadd' => '$1 {{GENDER:$2|added himself|added herself}} as instructor to course $3',
@@ -104,7 +100,7 @@
105101 'right-ep-enroll' => 'Enroll in Education Program courses',
106102 'right-ep-online' => 'Add or remove online ambassadors to courses',
107103 'right-ep-campus' => 'Add or remove campus ambassadors to courses',
108 - 'right-ep-instructor' => 'Add or remove instructors to master courses',
 104+ 'right-ep-instructor' => 'Add or remove instructors to courses',
109105
110106 // Actions
111107 'action-ep-org' => 'manage institutions',
@@ -114,7 +110,7 @@
115111 'action-ep-enroll' => 'enroll in courses',
116112 'action-ep-online' => 'add or remove online ambassadors to courses',
117113 'action-ep-campus' => 'add or remove campus ambassadors to courses',
118 - 'action-ep-instructor' => 'add or remove instructors to master courses',
 114+ 'action-ep-instructor' => 'add or remove instructors to courses',
119115
120116 // Groups
121117 'group-epadmin' => 'Education program admins',
@@ -210,16 +206,15 @@
211207
212208 // Course pager
213209 'epcoursepager-header-id' => 'Id',
214 - 'epcoursepager-header-mc-id' => 'Master course',
215210 'epcoursepager-header-term' => 'Term',
216211 'epcoursepager-header-start' => 'Start',
 212+ 'epcoursepager-header-org-id' => 'Institution',
217213 'epcoursepager-header-end' => 'End',
218 - 'epcoursepager-filter-mc-id' => 'Master course',
 214+ 'epcoursepager-header-status' => 'Status',
 215+ 'epcoursepager-header-students' => 'Students',
219216 'epcoursepager-filter-term' => 'Term',
220217 'epcoursepager-filter-org-id' => 'Institution',
221 - 'epcoursepager-header-status' => 'Status',
222218 'epcoursepager-filter-status' => 'Status',
223 - 'epcoursepager-header-students' => 'Students',
224219
225220 // Student pager
226221 'epstudentpager-header-user-id' => 'User',
@@ -251,13 +246,13 @@
252247 'editcourse-add-legend' => 'Add course',
253248 'editcourse-edit-legend' => 'Edit course',
254249 'ep-course-edit-term' => 'Term',
255 - 'ep-course-edit-mastercourse' => 'Master course',
 250+ 'ep-course-edit-org' => 'Institution',
256251 'ep-course-edit-start' => 'Start date',
257252 'ep-course-edit-end' => 'End date',
258253 'ep-course-edit-token' => 'Enrollment token',
259254 'ep-course-edit-description' => 'Description',
260255
261 - 'ep-course-invalid-mastercourse' => 'This master course does not exist.',
 256+ 'ep-course-invalid-org' => 'This institution does not exist.',
262257 'ep-course-invalid-token' => 'The token needs to be at least contain $1 {{PLURAL:$1|character|characters}}.',
263258 'ep-course-invalid-description' => 'The description needs to be at least contain $1 {{PLURAL:$1|character|characters}}.',
264259
@@ -278,7 +273,7 @@
279274 'specialinstitution-summary-courses' => 'Course count',
280275 'specialinstitution-summary-students' => 'Student count',
281276 'ep-institution-nav-edit' => 'Edit this institution',
282 - 'ep-institution-add-mc' => 'Add a master course',
 277+ 'ep-institution-add-course' => 'Add a course',
283278 'ep-institution-inactive' => 'Inactive',
284279 'ep-institution-active' => 'Active',
285280
@@ -288,7 +283,6 @@
289284 'ep-course-none' => 'There is no course with id "$1". See [[Special:Courses|here]] for a list of courses.',
290285 'ep-course-create' => 'There is no course with id "$1", but you can create a new one.',
291286 'specialcourse-summary-org' => 'Institution',
292 - 'specialcourse-summary-mastercourse' => 'Master course',
293287 'specialcourse-summary-term' => 'Term',
294288 'specialcourse-summary-start' => 'Start',
295289 'specialcourse-summary-end' => 'End',
@@ -350,27 +344,27 @@
351345 'ep-mycourses-not-a-student' => 'You are not enrolled in any [[Special:Courses|courses]].',
352346
353347 // ep.instructor
354 - 'ep-instructor-remove-title' => 'Remove instructor from master course',
 348+ 'ep-instructor-remove-title' => 'Remove instructor from course',
355349 'ep-instructor-remove-button' => 'Remove instructor',
356350 'ep-instructor-removing' => 'Removing...',
357 - 'ep-instructor-removal-success' => 'This instructor has been successfully removed from this master course.',
 351+ 'ep-instructor-removal-success' => 'This instructor has been successfully removed from this course.',
358352 'ep-instructor-close-button' => 'Close',
359353 'ep-instructor-remove-retry' => 'Retry',
360 - 'ep-instructor-remove-failed' => 'Something went wrong - could not remove the instructor from the master course.',
 354+ 'ep-instructor-remove-failed' => 'Something went wrong - could not remove the instructor from the course.',
361355 'ep-instructor-cancel-button' => 'Cancel',
362 - 'ep-instructor-remove-text' => 'You are about to remove $2 (Username: $1) as {{GENDER:$1|instructor}} from master course $3. Please enter a brief summary with the reason for this removal.',
 356+ 'ep-instructor-remove-text' => 'You are about to remove $2 (Username: $1) as {{GENDER:$1|instructor}} from course $3. Please enter a brief summary with the reason for this removal.',
363357 'ep-instructor-adding' => 'Adding...',
364 - 'ep-instructor-addittion-success' => '$1 has been successfully added as {{GENDER:$1|instructor}} for master course $2!',
365 - 'ep-instructor-addittion-self-success' => 'You have been successfully added as {{GENDER:$1|instructor}} for master course $2!',
 358+ 'ep-instructor-addittion-success' => '$1 has been successfully added as {{GENDER:$1|instructor}} for course $2!',
 359+ 'ep-instructor-addittion-self-success' => 'You have been successfully added as {{GENDER:$1|instructor}} for course $2!',
366360 'ep-instructor-add-close-button' => 'Close',
367361 'ep-instructor-add-retry' => 'Retry',
368 - 'ep-instructor-addittion-failed' => 'Something went wrong - could not add the instructor to the master course.',
369 - 'ep-instructor-add-title' => 'Add an instructor to the master course',
370 - 'ep-instructor-add-self-title' => 'Become an {{GENDER:$1|instructor}} for this master course',
 362+ 'ep-instructor-addittion-failed' => 'Something went wrong - could not add the instructor to the course.',
 363+ 'ep-instructor-add-title' => 'Add an instructor to the course',
 364+ 'ep-instructor-add-self-title' => 'Become an {{GENDER:$1|instructor}} for this course',
371365 'ep-instructor-add-button' => 'Add instructor',
372366 'ep-instructor-add-self-button' => 'Become {{GENDER:$1|instructor}}',
373 - 'ep-instructor-add-text' => 'You are adding an instructor for master course $1. Enter the username of the instructor and a brief description why this person is being added.',
374 - 'ep-instructor-add-self-text' => 'You are adding yourself as {{GENDER:$1|instructor}} for master course $1. Please add a brief description why you are doing so.',
 367+ 'ep-instructor-add-text' => 'You are adding an instructor for course $1. Enter the username of the instructor and a brief description why this person is being added.',
 368+ 'ep-instructor-add-self-text' => 'You are adding yourself as {{GENDER:$1|instructor}} for course $1. Please add a brief description why you are doing so.',
375369 'ep-instructor-add-cancel-button' => 'Cancel',
376370 'ep-instructor-summary-input' => 'Summary',
377371 'ep-instructor-name-input' => 'User name',
Index: trunk/extensions/EducationProgram/EducationProgram.php
@@ -9,7 +9,6 @@
1010 *
1111 * The source code makes use of a number of terms different from but corresponding to those in the UI:
1212 * * Org instead of Institution
13 - * * MC for master course
1413 * * CA for campus ambassador
1514 * * OA for online ambassador
1615 *
@@ -270,7 +269,6 @@
271270
272271 $wgGroupPermissions['epinstructor']['ep-org'] = true;
273272 $wgGroupPermissions['epinstructor']['ep-course'] = true;
274 -$wgGroupPermissions['epinstructor']['ep-mc'] = true;
275273 $wgGroupPermissions['epinstructor']['ep-token'] = true;
276274 $wgGroupPermissions['epinstructor']['ep-remstudent'] = true;
277275 $wgGroupPermissions['epinstructor']['ep-online'] = true;
@@ -383,7 +381,7 @@
384382 'ep-instructor-add-cancel-button',
385383 'ep-instructor-summary-input',
386384 'ep-instructor-name-input',
387 - 'ep-mc-no-instructors',
 385+ 'ep-course-no-instructors',
388386 ),
389387 );
390388
Index: trunk/extensions/EducationProgram/api/ApiInstructor.php
@@ -37,9 +37,9 @@
3838 $this->dieUsageMsg( array( 'badaccess-groups' ) );
3939 }
4040
41 - $masterCourse = EPCourse::selectRow( array( 'id', 'name', 'instructors' ), array( 'id' => $params['mcid'] ) );
 41+ $course = EPCourse::selectRow( array( 'id', 'name', 'instructors' ), array( 'id' => $params['orgid'] ) );
4242
43 - if ( $masterCourse === false ) {
 43+ if ( $course === false ) {
4444 $this->dieUsage( wfMsg( 'ep-addinstructor-invalid-course' ), 'invalid-course' );
4545 }
4646
@@ -47,10 +47,10 @@
4848
4949 switch ( $params['subaction'] ) {
5050 case 'add':
51 - $success = $masterCourse->addInstructors( array( $userId ), $params['reason'] );
 51+ $success = $course->addInstructors( array( $userId ), $params['reason'] );
5252 break;
5353 case 'remove':
54 - $success = $masterCourse->removeInstructors( array( $userId ), $params['reason'] );
 54+ $success = $course->removeInstructors( array( $userId ), $params['reason'] );
5555 break;
5656 }
5757
@@ -116,7 +116,7 @@
117117 ApiBase::PARAM_TYPE => 'integer',
118118 ApiBase::PARAM_REQUIRED => false,
119119 ),
120 - 'mcid' => array(
 120+ 'courseid' => array(
121121 ApiBase::PARAM_TYPE => 'integer',
122122 ApiBase::PARAM_REQUIRED => true,
123123 ),
@@ -132,7 +132,7 @@
133133 public function getParamDescription() {
134134 return array(
135135 'subaction' => 'Specifies what you want to do with the instructor',
136 - 'mcid' => 'The ID of the master course to/from which the instructor should be added/removed',
 136+ 'courseid' => 'The ID of the course to/from which the instructor should be added/removed',
137137 'username' => 'Name of the user to associate as instructor',
138138 'userid' => 'Id of the user to associate as instructor',
139139 'reason' => 'Message with the reason for this change for nthe log',
@@ -142,7 +142,7 @@
143143
144144 public function getDescription() {
145145 return array(
146 - 'API module for associating/disassociating a user as instructor with/from a master course.'
 146+ 'API module for associating/disassociating a user as instructor with/from a course.'
147147 );
148148 }
149149
@@ -150,7 +150,7 @@
151151 return array_merge( parent::getPossibleErrors(), array(
152152 array( 'code' => 'username-xor-userid', 'info' => 'You need to either provide the username or the userid parameter' ),
153153 array( 'code' => 'invalid-user', 'info' => 'An invalid user name or id was provided' ),
154 - array( 'code' => 'invalid-course', 'info' => 'There is no master course with the provided ID' ),
 154+ array( 'code' => 'invalid-course', 'info' => 'There is no course with the provided ID' ),
155155 ) );
156156 }
157157
Index: trunk/extensions/EducationProgram/resources/ep.instructor.js
@@ -14,8 +14,8 @@
1515
1616 $( '.ep-instructor-remove' ).click( function( event ) {
1717 var $this = $( this ),
18 - mcId = $this.attr( 'data-mcid' ),
19 - mcName = $this.attr( 'data-mcname' ),
 18+ courseId = $this.attr( 'data-courseid' ),
 19+ courseName = $this.attr( 'data-mcname' ),
2020 userId = $this.attr( 'data-userid' ),
2121 userName = $this.attr( 'data-username' ),
2222 bestName = $this.attr( 'data-bestname' ),
@@ -29,7 +29,7 @@
3030 $remove.button( 'option', 'label', ep.msg( 'ep-instructor-removing' ) );
3131
3232 ep.api.removeInstructor( {
33 - 'mcid': mcId,
 33+ 'courseid': courseId,
3434 'userid': userId,
3535 'reason': summaryInput.val()
3636 } ).done( function() {
@@ -81,7 +81,7 @@
8282 'ep-instructor-remove-text',
8383 mw.html.escape( userName ),
8484 '<b>' + mw.html.escape( bestName ) + '</b>',
85 - '<b>' + mw.html.escape( mcName ) + '</b>'
 85+ '<b>' + mw.html.escape( courseName ) + '</b>'
8686 ) );
8787
8888 //$dialog.append( $( '<p>' ).msg( 'ep-instructor-remove-title' ) );
@@ -101,8 +101,8 @@
102102 $( '.ep-add-instructor' ).click( function( event ) {
103103 var $this = $( this ), _this = this;
104104
105 - this.mcId = $this.attr( 'data-mcid' );
106 - this.mcName = $this.attr( 'data-mcname' );
 105+ this.courseId = $this.attr( 'data-courseid' );
 106+ this.courseName = $this.attr( 'data-mcname' );
107107 this.selfMode = $this.attr( 'data-mode' ) === 'self';
108108 this.$dialog = null;
109109
@@ -134,14 +134,14 @@
135135 $add.button( 'option', 'label', ep.msg( 'ep-instructor-adding' ) );
136136
137137 ep.api.addInstructor( {
138 - 'mcid': _this.mcId,
 138+ 'courseid': _this.courseId,
139139 'username': _this.getName(),
140140 'reason': _this.summaryInput.val()
141141 } ).done( function() {
142142 _this.$dialog.text( ep.msg(
143143 _this.selfMode ? 'ep-instructor-addittion-self-success' : 'ep-instructor-addittion-success',
144144 _this.getName(),
145 - _this.mcName
 145+ _this.courseName
146146 ) );
147147
148148 $add.remove();
@@ -149,11 +149,11 @@
150150 $cancel.focus();
151151
152152 // TODO: link name to user page and show control links
153 - $ul = $( '#ep-mc-instructors' ).find( 'ul' );
 153+ $ul = $( '#ep-course-instructors' ).find( 'ul' );
154154
155155 if ( $ul.length < 1 ) {
156156 $ul = $( '<ul>' );
157 - $( '#ep-mc-instructors' ).html( $ul );
 157+ $( '#ep-course-instructors' ).html( $ul );
158158 }
159159
160160 $ul.append( $( '<li>' ).text( _this.getName() ) )
@@ -187,7 +187,7 @@
188188
189189 this.$dialog.append( $( '<p>' ).text( gM(
190190 this.selfMode ? 'ep-instructor-add-self-text' : 'ep-instructor-add-text',
191 - this.mcName,
 191+ this.courseName,
192192 this.getName()
193193 ) ) );
194194

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r109985merge master courses with coursesjeroendedauw02:22, 25 January 2012
r109989follow up to r109985; fixed stuff I missed initially and replaced year field ...jeroendedauw02:47, 25 January 2012

Status & tagging log