r112258 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112257‎ | r112258 | r112259 >
Date:22:58, 23 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on single course display for students on special:mycourses
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/actions/EPAddArticleAction.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPArticleTable.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialMyCourses.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/actions/EPAddArticleAction.php
@@ -57,7 +57,17 @@
5858 }
5959 }
6060
61 - $this->getOutput()->redirect( $this->getTitle()->getLocalURL() );
 61+ $returnTo = null;
 62+
 63+ if ( $req->getCheck( 'returnto' ) ) {
 64+ $returnTo = Title::newFromText( $req->getText( 'returnto' ) );
 65+ }
 66+
 67+ if ( is_null( $returnTo ) ) {
 68+ $returnTo = $this->getTitle()->getLocalURL();
 69+ }
 70+
 71+ $this->getOutput()->redirect( $returnTo->getLocalURL() );
6272 return '';
6373 }
6474
Index: trunk/extensions/EducationProgram/specials/SpecialMyCourses.php
@@ -221,7 +221,36 @@
222222
223223 $out->addElement( 'h2', array(), wfMsg( 'ep-mycourses-course-enrollment' ) );
224224
225 - $out->addHTML( $this->msg( 'ep-mycourses-enrolledin', Message::rawParam( $course->getLink() ) )->text() );
 225+ $out->addHTML( $this->msg(
 226+ 'ep-mycourses-enrolledin',
 227+ array(
 228+ Message::rawParam( $course->getLink() ),
 229+ Message::rawParam( $course->getOrg()->getLink() )
 230+ )
 231+ )->text() );
 232+
 233+ $out->addWikiMsg( 'ep-mycourses-articletable' );
 234+
 235+ $pager = new EPArticleTable(
 236+ $this->getContext(),
 237+ array( 'id' => $this->getUser()->getId() ),
 238+ array(
 239+ 'course_id' => $course->getId(),
 240+ 'user_id' => $this->getUser()->getId(),
 241+ )
 242+ );
 243+
 244+ $pager->setShowStudents( false );
 245+
 246+ if ( $pager->getNumRows() ) {
 247+ $out->addHTML(
 248+ $pager->getFilterControl() .
 249+ $pager->getNavigationBar() .
 250+ $pager->getBody() .
 251+ $pager->getNavigationBar() .
 252+ $pager->getMultipleItemControl()
 253+ );
 254+ }
226255 }
227256
228257 }
Index: trunk/extensions/EducationProgram/includes/EPArticleTable.php
@@ -40,6 +40,14 @@
4141 protected $courseName = false;
4242
4343 /**
 44+ * Show the students column or not.
 45+ *
 46+ * @since 0.1
 47+ * @var boolean
 48+ */
 49+ protected $showStudents = true;
 50+
 51+ /**
4452 * Constructor.
4553 *
4654 * @param IContextSource $context
@@ -53,6 +61,17 @@
5462 // when MW 1.19 becomes min, we want to pass an IContextSource $context here.
5563 parent::__construct( $context, $conds, EPStudents::singleton() );
5664 }
 65+
 66+ /**
 67+ * Set if the student column should be shown or not.
 68+ *
 69+ * @since 0.1
 70+ *
 71+ * @param boolean $showStudents
 72+ */
 73+ public function setShowStudents( $showStudents ) {
 74+ $this->showStudents = $showStudents;
 75+ }
5776
5877 public function getBody() {
5978 $this->getOutput()->addModules( 'ep.articletable' );
@@ -64,10 +83,13 @@
6584 * @see EPPager::getFields()
6685 */
6786 public function getFields() {
68 - return array(
69 - 'id',
70 - 'user_id',
71 - );
 87+ $fields = array( 'id' );
 88+
 89+ if ( $this->showStudents ) {
 90+ $fields[] = 'user_id';
 91+ }
 92+
 93+ return $fields;
7294 }
7395
7496 /**
@@ -113,7 +135,9 @@
114136 $rowCount++;
115137 }
116138
117 - $html .= $this->getUserCell( $student->getField( 'user_id' ), max( 1, $rowCount ) );
 139+ if ( $this->showStudents ) {
 140+ $html .= $this->getUserCell( $student->getField( 'user_id' ), max( 1, $rowCount ) );
 141+ }
118142
119143 $this->addNonStudentHTML( $html, $articles, $showArticleAdittion );
120144
@@ -377,11 +401,18 @@
378402 protected function getArticleAdittionControl( $courseId ) {
379403 $html = '';
380404
 405+ $courseName = EPCourses::singleton()->selectFieldsRow( 'name', array( 'id' => $courseId ) );
 406+ $query = array( 'action' => 'epaddarticle' );
 407+
 408+ if ( $this->getTitle()->getNamespace() !== EP_NS_COURSE ) {
 409+ $query['returnto'] = $this->getTitle()->getFullText();
 410+ }
 411+
381412 $html .= Html::openElement(
382413 'form',
383414 array(
384415 'method' => 'post',
385 - 'action' => $this->getTitle()->getLocalURL( array( 'action' => 'epaddarticle' ) ),
 416+ 'action' => EPCourses::getTitleFor( $courseName )->getLocalURL( $query ),
386417 )
387418 );
388419
@@ -466,7 +497,10 @@
467498
468499 unset( $fields['id'] );
469500
470 - $fields['user_id'] = 'student';
 501+ if ( $this->showStudents ) {
 502+ $fields['user_id'] = 'student';
 503+ }
 504+
471505 $fields['_articles'] = 'articles';
472506 $fields['_reviewers'] = 'reviewers';
473507
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -534,7 +534,8 @@
535535 'ep-mycourses-nocourses-epca' => 'There are no courses you are Campus Ambassador for yet.',
536536 'ep-mycourses-nocourses-epoa' => 'There are no courses you are Online Ambassador for yet.',
537537 'ep-mycourses-nocourses-epinstructor' => 'There are no courses you are Instructor for yet.',
538 - 'ep-mycourses-enrolledin' => 'You are currently enrolled in $1.',
 538+ 'ep-mycourses-enrolledin' => 'You are currently enrolled in course $1 at institution $2.',
 539+ 'ep-mycourses-articletable' => 'These are the articles you are working on and their reviewers:',
539540
540541 // ep.enlist instructor
541542 'ep-instructor-remove-title' => 'Remove instructor from course',

Status & tagging log