Permalink
Browse files

Metacourse unenrolling: fixes bug #4541

  • Loading branch information...
1 parent 2f816b5 commit 1e751f6b7724db05c48c617747cca3964089ba5a mjollnir_ committed Jan 10, 2006
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/moodlelib.php
View
@@ -2617,6 +2617,7 @@ function enrol_student($userid, $courseid, $timestart=0, $timeend=0, $enrol='man
* @return boolean
*/
function unenrol_student($userid, $courseid=0) {
+ global $CFG;
if ($courseid) {
/// First delete any crucial stuff that might still send mail
@@ -2630,10 +2631,14 @@ function unenrol_student($userid, $courseid=0) {
delete_records('groups_members', 'groupid', $group->id, 'userid', $userid);
}
}
- // enrol the student in any parent meta courses...
+ // unenrol the student from any parent meta courses...
if ($parents = get_records('course_meta','child_course',$courseid)) {
foreach ($parents as $parent) {
- unenrol_student($userid, $parent->parent_course);
+ if (!record_exists_sql('SELECT us.id FROM '.$CFG->prefix.'user_students us, '
+ .$CFG->prefix.'course_meta cm WHERE cm.child_course = us.course
+ AND us.userid = '.$userid .' AND us.course != '.$courseid)) {
+ unenrol_student($userid, $parent->parent_course);
+ }
}
}
return delete_records('user_students', 'userid', $userid, 'course', $courseid);

0 comments on commit 1e751f6

Please sign in to comment.