r111909 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111908‎ | r111909 | r111910 >
Date:03:26, 20 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
various small fixes
Modified paths:
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPPageObject.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPRoleObject.php (modified) (history)
  • /trunk/extensions/EducationProgram/maintenance/importWEPData.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialStudent.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/maintenance/importWEPData.php
@@ -72,9 +72,9 @@
7373 $courseIds = $this->insertCourses( $courses, $orgs );
7474 echo "Inserted courses\n";
7575
76 -// echo "Inserting students ...\n";
77 -// $this->insertStudents( $students, $courseIds );
78 -// echo "Inserted students\n";
 76+ echo "Inserting students ...\n";
 77+ $this->insertStudents( $students, $courseIds );
 78+ echo "Inserted students\n";
7979
8080 echo "Import completed!\n\n";
8181 }
@@ -131,6 +131,8 @@
132132 try{
133133 $course->save();
134134 $courseIds[$name] = $course->getId();
 135+ $name = str_replace( '_', ' ', $name );
 136+ echo "Inserted course '$name'.\n";
135137 }
136138 catch ( Exception $ex ) {
137139 echo "Failed to insert course '$name'.\n";
@@ -193,7 +195,7 @@
194196 }
195197
196198 if ( $student->associateWithCourses( $courses ) ) {
197 - echo "Imported student $name\n";
 199+ echo "Inserted student '$name'\t\t and associated with courses: " . str_replace( '_', ' ', implode( ', ', $courseNames ) ) . "\n";
198200 }
199201 else {
200202 echo "Failed to insert student '$name'. (failed to associate courses)\n";
Index: trunk/extensions/EducationProgram/specials/SpecialStudent.php
@@ -40,7 +40,7 @@
4141 else {
4242 $this->displayNavigation();
4343
44 - $student = EPStudent::selectRow( null, array( 'id' => $this->subPage ) );
 44+ $student = EPStudents::singleton()->selectRow( null, array( 'id' => $this->subPage ) );
4545
4646 if ( $student === false ) {
4747 $out->addWikiMsg( 'ep-student-none', $this->subPage );
@@ -50,8 +50,6 @@
5151
5252 $this->displaySummary( $student );
5353
54 - $out->addElement( 'h2', array(), wfMsg( 'ep-student-courses' ) );
55 -
5654 $courseIds = array_map(
5755 function( EPCourse $course ) {
5856 return $course->getId();
@@ -59,7 +57,13 @@
6058 $student->getCourses( 'id' )
6159 );
6260
63 - EPCourse::displayPager( $this->getContext(), array( 'id' => $courseIds ) );
 61+ if ( count( $courseIds ) > 0 ) {
 62+ $out->addElement( 'h2', array(), wfMsg( 'ep-student-courses' ) );
 63+ EPCourse::displayPager( $this->getContext(), array( 'id' => $courseIds ) );
 64+ }
 65+ else {
 66+ // TODO
 67+ }
6468 }
6569 }
6670 }
Index: trunk/extensions/EducationProgram/includes/EPRoleObject.php
@@ -142,7 +142,7 @@
143143 foreach ( $courses as /* EPCourse */ $course ) {
144144 $courseIds[] = $course->getId();
145145 $course->setUpdateSummaries( false );
146 - $course->enlistUsers( $this->getField( 'user_id' ), $this->getRoleName() );
 146+ $success = $course->enlistUsers( $this->getField( 'user_id' ), $this->getRoleName() ) && $success;
147147 $course->setUpdateSummaries( true );
148148 }
149149
Index: trunk/extensions/EducationProgram/includes/EPPageObject.php
@@ -65,5 +65,17 @@
6666 return $this->table->getLogInfoForTitle( $this->getTitle() );
6767 }
6868 }
 69+
 70+ /**
 71+ * (non-PHPdoc)
 72+ * @see DBDataObject::setField()
 73+ */
 74+ public function setField( $name, $value ) {
 75+ if ( $name === $this->table->getIdentifierField() ) {
 76+ $value = str_replace( '_', ' ', $value );
 77+ }
 78+
 79+ parent::setField( $name, $value );
 80+ }
6981
7082 }
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -535,6 +535,9 @@
536536 if ( $name === 'instructors' ) {
537537 $this->instructors = false;
538538 }
 539+ elseif ( $name === 'mc' ) {
 540+ $value = str_replace( '_', ' ', $value );
 541+ }
539542
540543 parent::setField( $name, $value );
541544 }

Status & tagging log