https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112246
Revision: 112246
Author: jeroendedauw
Date: 2012-02-23 21:47:53 +0000 (Thu, 23 Feb 2012)
Log Message:
-----------
work on course listing for instructors on special mycourses
Modified Paths:
--------------
trunk/extensions/EducationProgram/actions/EPDeleteAction.php
trunk/extensions/EducationProgram/resources/ep.formpage.js
trunk/extensions/EducationProgram/specials/SpecialMyCourses.php
Modified: trunk/extensions/EducationProgram/actions/EPDeleteAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EPDeleteAction.php
2012-02-23 21:42:51 UTC (rev 112245)
+++ trunk/extensions/EducationProgram/actions/EPDeleteAction.php
2012-02-23 21:47:53 UTC (rev 112246)
@@ -32,6 +32,7 @@
protected function __construct( Page $page, IContextSource $context =
null, DBTable $table ) {
$this->table = $table;
parent::__construct( $page, $context );
+ $this->getOutput()->addModules( 'ep.formpage' );
}
/**
@@ -111,6 +112,7 @@
$out->addElement(
'button',
array(
+ 'id' => 'cancelDelete',
'class' => 'ep-delete-cancel',
'target-url' =>
$this->getTitle()->getLocalURL(),
),
Modified: trunk/extensions/EducationProgram/resources/ep.formpage.js
===================================================================
--- trunk/extensions/EducationProgram/resources/ep.formpage.js 2012-02-23
21:42:51 UTC (rev 112245)
+++ trunk/extensions/EducationProgram/resources/ep.formpage.js 2012-02-23
21:47:53 UTC (rev 112246)
@@ -12,11 +12,13 @@
$( '#bodyContent' ).find( '[type="submit"]' ).button();
- $( '#cancelEdit' ).click( function( event ) {
+ $( '#cancelEdit, #cancelDelete' ).click( function( event ) {
window.location = $( this ).attr( 'target-url' );
event.preventDefault();
} );
+ $( '#cancelDelete' ).button();
+
} );
})( window.jQuery, window.mediaWiki );
\ No newline at end of file
Modified: trunk/extensions/EducationProgram/specials/SpecialMyCourses.php
===================================================================
--- trunk/extensions/EducationProgram/specials/SpecialMyCourses.php
2012-02-23 21:42:51 UTC (rev 112245)
+++ trunk/extensions/EducationProgram/specials/SpecialMyCourses.php
2012-02-23 21:47:53 UTC (rev 112246)
@@ -156,17 +156,24 @@
*/
protected function displayRoleAssociation( $class ) {
$ambassador = $class::newFromUser( $this->getUser() );
-
- $courseIds = array_map(
- function( EPCourse $course ) {
- return $course->getId();
- },
- $ambassador->getCourses( 'id' )
- );
-
- if ( count( $courseIds ) > 0 ) {
+ $courses = $ambassador->getCourses( array( 'id', 'name' ) );
+
+ if ( count( $courses ) > 0 ) {
$this->getOutput()->addElement( 'h2', array(), wfMsg(
'ep-mycourses-courses-' . strtolower( $class ) ) );
- EPCourse::displayPager( $this->getContext(), array(
'id' => $courseIds ), true, $class );
+
+ if ( $class == 'EPInstructor' ) {
+ $this->displayCourseTables( $courses );
+ }
+ else {
+ $courseIds = array_map(
+ function( EPCourse $course ) {
+ return $course->getId();
+ },
+ $courses
+ );
+
+ EPCourse::displayPager( $this->getContext(),
array( 'id' => $courseIds ), true, $class );
+ }
}
else {
$this->getOutput()->addWikiMsg(
'ep-mycourses-nocourses-' . strtolower( $class ) );
@@ -174,6 +181,35 @@
}
/**
+ * Display a list of courses, each as a h3 section with the
student/article table in it.
+ *
+ * @param array $courses
+ */
+ protected function displayCourseTables( array $courses ) {
+ $out = $this->getOutput();
+
+ foreach ( $courses as /* EPCourse */ $course ) {
+ $out->addElement( 'h3', array(), $course->getField(
'name' ) );
+
+ $pager = new EPArticleTable(
+ $this->getContext(),
+ array( 'id' => $this->getUser()->getId() ),
+ array( 'course_id' => $course->getId() )
+ );
+
+ if ( $pager->getNumRows() ) {
+ $out->addHTML(
+ $pager->getFilterControl() .
+ $pager->getNavigationBar() .
+ $pager->getBody() .
+ $pager->getNavigationBar() .
+ $pager->getMultipleItemControl()
+ );
+ }
+ }
+ }
+
+ /**
* Display enrollment info for a single course.
*
* @since 0.1
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs