https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112258
Revision: 112258
Author: jeroendedauw
Date: 2012-02-23 22:58:41 +0000 (Thu, 23 Feb 2012)
Log Message:
-----------
work on single course display for students on special:mycourses
Modified Paths:
--------------
trunk/extensions/EducationProgram/EducationProgram.i18n.php
trunk/extensions/EducationProgram/actions/EPAddArticleAction.php
trunk/extensions/EducationProgram/includes/EPArticleTable.php
trunk/extensions/EducationProgram/specials/SpecialMyCourses.php
Modified: trunk/extensions/EducationProgram/EducationProgram.i18n.php
===================================================================
--- trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-02-23
22:58:11 UTC (rev 112257)
+++ trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-02-23
22:58:41 UTC (rev 112258)
@@ -534,7 +534,8 @@
'ep-mycourses-nocourses-epca' => 'There are no courses you are Campus
Ambassador for yet.',
'ep-mycourses-nocourses-epoa' => 'There are no courses you are Online
Ambassador for yet.',
'ep-mycourses-nocourses-epinstructor' => 'There are no courses you are
Instructor for yet.',
- 'ep-mycourses-enrolledin' => 'You are currently enrolled in $1.',
+ 'ep-mycourses-enrolledin' => 'You are currently enrolled in course $1
at institution $2.',
+ 'ep-mycourses-articletable' => 'These are the articles you are working
on and their reviewers:',
// ep.enlist instructor
'ep-instructor-remove-title' => 'Remove instructor from course',
Modified: trunk/extensions/EducationProgram/actions/EPAddArticleAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EPAddArticleAction.php
2012-02-23 22:58:11 UTC (rev 112257)
+++ trunk/extensions/EducationProgram/actions/EPAddArticleAction.php
2012-02-23 22:58:41 UTC (rev 112258)
@@ -57,7 +57,17 @@
}
}
- $this->getOutput()->redirect( $this->getTitle()->getLocalURL()
);
+ $returnTo = null;
+
+ if ( $req->getCheck( 'returnto' ) ) {
+ $returnTo = Title::newFromText( $req->getText(
'returnto' ) );
+ }
+
+ if ( is_null( $returnTo ) ) {
+ $returnTo = $this->getTitle()->getLocalURL();
+ }
+
+ $this->getOutput()->redirect( $returnTo->getLocalURL() );
return '';
}
Modified: trunk/extensions/EducationProgram/includes/EPArticleTable.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPArticleTable.php
2012-02-23 22:58:11 UTC (rev 112257)
+++ trunk/extensions/EducationProgram/includes/EPArticleTable.php
2012-02-23 22:58:41 UTC (rev 112258)
@@ -40,6 +40,14 @@
protected $courseName = false;
/**
+ * Show the students column or not.
+ *
+ * @since 0.1
+ * @var boolean
+ */
+ protected $showStudents = true;
+
+ /**
* Constructor.
*
* @param IContextSource $context
@@ -53,6 +61,17 @@
// when MW 1.19 becomes min, we want to pass an IContextSource
$context here.
parent::__construct( $context, $conds, EPStudents::singleton()
);
}
+
+ /**
+ * Set if the student column should be shown or not.
+ *
+ * @since 0.1
+ *
+ * @param boolean $showStudents
+ */
+ public function setShowStudents( $showStudents ) {
+ $this->showStudents = $showStudents;
+ }
public function getBody() {
$this->getOutput()->addModules( 'ep.articletable' );
@@ -64,10 +83,13 @@
* @see EPPager::getFields()
*/
public function getFields() {
- return array(
- 'id',
- 'user_id',
- );
+ $fields = array( 'id' );
+
+ if ( $this->showStudents ) {
+ $fields[] = 'user_id';
+ }
+
+ return $fields;
}
/**
@@ -113,7 +135,9 @@
$rowCount++;
}
- $html .= $this->getUserCell( $student->getField( 'user_id' ),
max( 1, $rowCount ) );
+ if ( $this->showStudents ) {
+ $html .= $this->getUserCell( $student->getField(
'user_id' ), max( 1, $rowCount ) );
+ }
$this->addNonStudentHTML( $html, $articles,
$showArticleAdittion );
@@ -377,11 +401,18 @@
protected function getArticleAdittionControl( $courseId ) {
$html = '';
+ $courseName = EPCourses::singleton()->selectFieldsRow( 'name',
array( 'id' => $courseId ) );
+ $query = array( 'action' => 'epaddarticle' );
+
+ if ( $this->getTitle()->getNamespace() !== EP_NS_COURSE ) {
+ $query['returnto'] = $this->getTitle()->getFullText();
+ }
+
$html .= Html::openElement(
'form',
array(
'method' => 'post',
- 'action' => $this->getTitle()->getLocalURL(
array( 'action' => 'epaddarticle' ) ),
+ 'action' => EPCourses::getTitleFor( $courseName
)->getLocalURL( $query ),
)
);
@@ -466,7 +497,10 @@
unset( $fields['id'] );
- $fields['user_id'] = 'student';
+ if ( $this->showStudents ) {
+ $fields['user_id'] = 'student';
+ }
+
$fields['_articles'] = 'articles';
$fields['_reviewers'] = 'reviewers';
Modified: trunk/extensions/EducationProgram/specials/SpecialMyCourses.php
===================================================================
--- trunk/extensions/EducationProgram/specials/SpecialMyCourses.php
2012-02-23 22:58:11 UTC (rev 112257)
+++ trunk/extensions/EducationProgram/specials/SpecialMyCourses.php
2012-02-23 22:58:41 UTC (rev 112258)
@@ -221,7 +221,36 @@
$out->addElement( 'h2', array(), wfMsg(
'ep-mycourses-course-enrollment' ) );
- $out->addHTML( $this->msg( 'ep-mycourses-enrolledin',
Message::rawParam( $course->getLink() ) )->text() );
+ $out->addHTML( $this->msg(
+ 'ep-mycourses-enrolledin',
+ array(
+ Message::rawParam( $course->getLink() ),
+ Message::rawParam( $course->getOrg()->getLink()
)
+ )
+ )->text() );
+
+ $out->addWikiMsg( 'ep-mycourses-articletable' );
+
+ $pager = new EPArticleTable(
+ $this->getContext(),
+ array( 'id' => $this->getUser()->getId() ),
+ array(
+ 'course_id' => $course->getId(),
+ 'user_id' => $this->getUser()->getId(),
+ )
+ );
+
+ $pager->setShowStudents( false );
+
+ if ( $pager->getNumRows() ) {
+ $out->addHTML(
+ $pager->getFilterControl() .
+ $pager->getNavigationBar() .
+ $pager->getBody() .
+ $pager->getNavigationBar() .
+ $pager->getMultipleItemControl()
+ );
+ }
}
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs