-
Bug
-
Resolution: Fixed
-
Minor
-
1.9.13
-
Any
-
MOODLE_19_STABLE
-
MOODLE_19_STABLE
-
Replication instructions:
- Set the $CFG->longtimenosee setting (any value)
- Create a meta course and at least one child course
- Add a 'welcome' message to the meta course
- Enrol a user onto one of the child courses
- Run cron to update the user's enrolment into the meta course
- Wait $CFG->longtimenosee days (or manually change the table mdl_user_lastaccess, so that the record for that user and the metacourse has a timeaccess more than $CFG->longtimenosee days ago)
Expected result: nothing happens, as the user is still enroled in the child course, so should stay enroled in the meta course as well.
Actual result: every time admin/cron.php runs, there is a 20% chance the user will be unenroled from the meta course (as they have not visited it recently enough), they will then immediately be enroled back into it again (as they are still enroled in the child course), at which point they will receive a welcome message. The user will keep receiving 'welcome' emails multiple times an hour until they visit the meta course and reset the 'timeaccess' value.
Proposed solution:
In cron.php - check to see if the course is a metacourse before unenroling after $CFG->longtimenosee (the user will already be automatially unenroled, once they have been unenroled from the child courses, so we should not have to worry that they will never leave the meta course)
$rs = get_recordset_sql ("SELECT id, userid, courseid
|
FROM {$CFG->prefix}user_lastaccess
|
WHERE courseid != ".SITEID."
|
AND timeaccess < $cuttime ");
|
Should become:
$rs = get_recordset_sql ("SELECT la.id, la.userid, la.courseid
|
FROM {$CFG->prefix}user_lastaccess la
|
JOIN {$CFG->prefix}course c
|
ON c.id = la.courseid
|
WHERE la.courseid != ".SITEID."
|
AND la.timeaccess < $cuttime
|
AND c.metacourse = 0");
|
An alternative solution might be to update the 'timeaccess' field in the metacourse when the child course is visited.
I have not fully investigated, but I suspect that M2.0 may have the same problem.