Permalink
Browse files

Fixing a problem reported about self enrolment in child courses and n…

…ot being able to access the parent without logging in and out again at http://moodle.org/mod/forum/post.php?reply=185699
  • Loading branch information...
1 parent f0172f5 commit 4c6dc44de13958b87b891b087040f42988e76621 mjollnir_ committed Feb 23, 2006
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/moodlelib.php
View
8 lib/moodlelib.php
@@ -2573,7 +2573,7 @@ function set_login_session_preferences() {
*/
function enrol_student($userid, $courseid, $timestart=0, $timeend=0, $enrol='manual') {
- global $CFG;
+ global $CFG, $USER;
if (!$course = get_record('course', 'id', $courseid)) { // Check course
return false;
@@ -2585,6 +2585,12 @@ function enrol_student($userid, $courseid, $timestart=0, $timeend=0, $enrol='man
if ($parents = get_records('course_meta','child_course',$courseid)) {
foreach ($parents as $parent) {
enrol_student($userid, $parent->parent_course,$timestart,$timeend,'metacourse');
+ // if we're enrolling ourselves in the child course, add the parent courses to USER too
+ // otherwise they'll have to logout and in again to get it
+ // http://moodle.org/mod/forum/post.php?reply=185699
+ if (!empty($USER) && $userid == $USER->id) {
+ $USER->student[$parent->parent_course] = true;
+ }
}
}

0 comments on commit 4c6dc44

Please sign in to comment.