r107763 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107762‎ | r107763 | r107764 >
Date:01:46, 1 January 2012
Author:jeroendedauw
Status:deferred
Tags:educationprogram 
Comment:
work on mycourses
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialMyCourses.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/specials/SpecialMyCourses.php
@@ -54,8 +54,8 @@
5555 }
5656
5757 /**
 58+ * Display the courses this student is linked to.
5859 *
59 - *
6060 * @since 0.1
6161 *
6262 * @param EPStudent $student
@@ -95,8 +95,8 @@
9696 }
9797
9898 /**
 99+ * Display the provided courses in a table.
99100 *
100 - *
101101 * @since 0.1
102102 *
103103 * @param array $courses
@@ -121,9 +121,16 @@
122122 foreach ( $courses as /* EPCourse */ $course ) {
123123 $fields = array();
124124
125 - $fields[] = $course->getField( 'name' );
126 - $fields[] = $course->getOrg()->getField( 'name' );
 125+ $fields[] = Linker::link(
 126+ $this->getTitle( $course->getField( 'name' ) ),
 127+ '<b>' . htmlspecialchars( $course->getField( 'name' ) ) . '</b>'
 128+ );
127129
 130+ $fields[] = Linker::link(
 131+ SpecialPage::getTitleFor( 'Institution', $course->getOrg()->getField( 'name' ) ),
 132+ htmlspecialchars( $course->getOrg()->getField( 'name' ) )
 133+ );
 134+
128135 foreach ( $fields as &$field ) {
129136 $field = Html::rawElement( 'td', array(), $field );
130137 }
@@ -136,19 +143,32 @@
137144 }
138145
139146 /**
 147+ * Display info for a single course.
140148 *
141 - *
142149 * @since 0.1
143150 *
144151 * @param EPStudent $student
145152 * @param string $courseName
146153 */
147154 protected function displayCourse( EPStudent $student, $courseName ) {
 155+ $out = $this->getOutput();
 156+
148157 $course = EPCourse::selectRow( null, array( 'name' => $courseName ) );
149158
150 - if ( $student->hasTerm( array( ) ) ) {
151 - // TODO
 159+ if ( $course !== false && $student->hasTerm( array( 'course_id' => $course->getId() ) ) ) {
 160+ $out->addWikiMsg( 'ep-mycourses-show-all' );
 161+
 162+ $out->setPageTitle( wfMsgExt(
 163+ 'ep-mycourses-course-title',
 164+ 'parsemag',
 165+ $courseName,
 166+ $course->getOrg( 'name' )->getField( 'name' )
 167+ ) );
152168 }
 169+ else {
 170+ $this->showError( wfMessage( 'ep-mycourses-no-such-course', $courseName ) );
 171+ $this->displayCourses( $student );
 172+ }
153173 }
154174
155175 }
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -221,6 +221,9 @@
222222 'ep-mycourses-passed' => 'Passed courses',
223223 'ep-mycourses-header-name' => 'Name',
224224 'ep-mycourses-header-institution' => 'Institution',
 225+ 'ep-mycourses-show-all' => 'This page shows one of the courses you are enrolled in. You can also view all [[Special:MyCourses|your courses]].',
 226+ 'ep-mycourses-no-such-course' => 'You are not enrolled in any course with name "$1". The courses you are enrolled in are listed below.',
 227+ 'ep-mycourses-course-title' => 'My courses: $1 at $2',
225228
226229 // Navigation links
227230 'ep-nav-orgs' => 'Institution list',

Status & tagging log