Permalink
Browse files

Fixed remove_teacher, so that a removed teacher is also removed from any

groups they belong to.
  • Loading branch information...
mchurch
mchurch committed Sep 14, 2004
1 parent 908b8b9 commit 5ec9237d2b6490e9ffb26c39657461561a8f790d
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/moodlelib.php
View
@@ -965,6 +965,17 @@ function remove_teacher($userid, $courseid=0) {
delete_records("forum_subscriptions", "forum", $forum->id, "userid", $userid);
}
}
+
+ /// Next if the teacher is not registered as a student, but is
+ /// a member of a group, remove them from the group.
+ if (!isstudent($courseid, $userid)) {
+ if ($groups = get_groups($courseid, $userid)) {
+ foreach ($groups as $group) {
+ delete_records("groups_members", "groupid", $group->id, "userid", $userid);
+ }
+ }
+ }
+
return delete_records("user_teachers", "userid", $userid, "course", $courseid);
} else {
delete_records("forum_subscriptions", "userid", $userid);

0 comments on commit 5ec9237

Please sign in to comment.