r113975 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113974‎ | r113975 | r113976 >
Date:23:21, 15 March 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Follow up to r113967;
Modified paths:
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPStudent.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPStudentPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPStudents.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialEnroll.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialStudentActivity.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/specials/SpecialEnroll.php
@@ -241,22 +241,14 @@
242242
243243 if ( !$hadStudent ) {
244244 $student = EPStudents::singleton()->newFromArray( array( 'user_id' => $this->getUser()->getId() ), true );
245 - $fields['first_enroll'] = wfTimestamp( TS_MW );
246245 }
247246
248247 $student->setFields( $fields );
249248
250249 $success = $student->save();
251250
252 - if ( $success ) {
253 - $success = $student->associateWithCourses( array( $course ) ) && $success;
 251+ $success = $success && $student->associateWithCourses( array( $course ) );
254252
255 - if ( !$hadStudent ) {
256 - $this->getUser()->setOption( 'ep_showtoplink', true );
257 - $this->getUser()->saveSettings();
258 - }
259 - }
260 -
261253 return $success;
262254 }
263255
Index: trunk/extensions/EducationProgram/specials/SpecialStudentActivity.php
@@ -97,9 +97,9 @@
9898 public function __construct( IContextSource $context, array $conds = array() ) {
9999 $this->mDefaultDirection = true;
100100
101 -// $conds[] = 'last_active > ' . wfGetDB( DB_SLAVE )->addQuotes(
102 -// wfTimestamp( TS_MW, time() - ( EPSettings::get( 'recentActivityLimit' ) ) )
103 -// );
 101+ $conds[] = 'last_active > ' . wfGetDB( DB_SLAVE )->addQuotes(
 102+ wfTimestamp( TS_MW, time() - ( EPSettings::get( 'recentActivityLimit' ) ) )
 103+ );
104104
105105 parent::__construct( $context, $conds, EPStudents::singleton() );
106106 }
Index: trunk/extensions/EducationProgram/includes/EPStudentPager.php
@@ -55,7 +55,7 @@
5656 'user_id',
5757 'first_enroll',
5858 'last_active',
59 - 'active_enroll',
 59+ //'active_enroll',
6060 );
6161 }
6262
Index: trunk/extensions/EducationProgram/includes/EPStudents.php
@@ -55,7 +55,9 @@
5656
5757 'user_id' => 'int',
5858 'first_enroll' => 'str', // TS_MW
59 -
 59+ 'first_course' => 'int',
 60+ 'last_enroll' => 'str', // TS_MW
 61+ 'last_course' => 'int',
6062 'last_active' => 'str', // TS_MW
6163 'active_enroll' => 'bool',
6264 );
Index: trunk/extensions/EducationProgram/includes/EPStudent.php
@@ -72,4 +72,24 @@
7373 $this->setFields( $fields );
7474 }
7575
 76+ /**
 77+ * Should be called whenever a user is enrolled as student.
 78+ *
 79+ * @since 0.1
 80+ *
 81+ * @param integer $courseId
 82+ */
 83+ public function onEnrolled( $courseId ) {
 84+ if ( !$this->hasField( 'first_course' ) ) {
 85+ $this->setField( 'first_course', $courseId );
 86+ $this->setField( 'first_enroll', wfTimestampNow() );
 87+ }
 88+
 89+ $this->setField( 'last_course', $courseId );
 90+ $this->setField( 'last_enroll', wfTimestampNow() );
 91+
 92+ $this->getUser()->setOption( 'ep_showtoplink', true );
 93+ $this->getUser()->saveSettings();
 94+ }
 95+
7696 }
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -590,6 +590,14 @@
591591 $this->enableLogging();
592592 }
593593
 594+ if ( $success && $role === 'student' ) {
 595+ foreach ( $addedUsers as $userId ) {
 596+ $student = EPStudent::newFromUserId( $userId, true, 'id' );
 597+ $student->onEnrolled( $this->getId() );
 598+ $student->save();
 599+ }
 600+ }
 601+
594602 if ( $success && !is_null( $revAction ) ) {
595603 $action = count( $addedUsers ) == 1 && $revAction->getUser()->getId() === $addedUsers[0] ? 'selfadd' : 'add';
596604 $this->logRoleChange( $action, $role, $addedUsers, $revAction->getComment() );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r113967work on adding special:StudentActivityjeroendedauw22:51, 15 March 2012

Status & tagging log