AndyRussG has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/109462


Change subject: Only add students to Special:Students
......................................................................

Only add students to Special:Students

Only add students, and not other roles, to the Students table and
the list of students on Special:Student. This only applies to new
user particpations in courses.

bug: 44110
Change-Id: I2d76d44862e6f82996f1c9140b7a48a93c169803
---
M includes/rows/Course.php
1 file changed, 12 insertions(+), 7 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/EducationProgram 
refs/changes/62/109462/1

diff --git a/includes/rows/Course.php b/includes/rows/Course.php
index cf0c3d5..d80b164 100644
--- a/includes/rows/Course.php
+++ b/includes/rows/Course.php
@@ -609,13 +609,18 @@
                        }
 
                        if ( $success ) {
-                               foreach ( $usersToAddIds as $userId ) {
-                                       /**
-                                        * @var RoleObject $person
-                                        */
-                                       $person = Student::newFromUserId( 
$userId, true, 'id' );
-                                       $person->onEnrolled( $this->getId(), 
$role );
-                                       $person->save();
+
+                               // If we are enrolling students, then add them 
to the Students
+                               // table. There are tables for other roles, but 
of them, only
+                               // the tables for volunteers are used, and it's 
not necessary
+                               // for those tables to be filled automatically.
+                               if ( $role === 'student' ) {
+
+                                       foreach ( $usersToAddIds as $userId ) {
+                                               $student = 
Student::newFromUserId( $userId, true, 'id' );
+                                               $student->onEnrolled( 
$this->getId(), $role );
+                                               $student->save();
+                                       }
                                }
 
                                // If we have a value for $addedUserIds, pass in

-- 
To view, visit https://gerrit.wikimedia.org/r/109462
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2d76d44862e6f82996f1c9140b7a48a93c169803
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/EducationProgram
Gerrit-Branch: master
Gerrit-Owner: AndyRussG <andrew.green...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to