-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
2.1.3
-
MOODLE_21_STABLE
Courses on a client's site were created without the LMB enrollment method. This causes errors with the LMB plugin when enrollments are processed.
Root cause: The LMB enrollment method is added to the course at the final step of the "create course shell" function. If there is an error creating the enrollment method OR if the course was not created via the LMB plugin, the state is now unrecoverable because the enrollment method is not added to the course in subsequent processing.
Solution: The "process enrollments" function should check to see if the LMB enrollment method exists in the course, adding it if it does not.
Workaround (query to fix missing enrollment methods):
INSERT INT mdl_enrol (enrol, status, courseid, enrolstartdate, enrolenddate, timemodified, timecreated, sortorder)
SELECT
'lmb' AS enrol
, 0 AS status
, c.id AS courseid
, 0 AS enrolstartdate
, 0 AS enrolenddate
, UNIX_TIMESTAMP(NOW()) AS timemodified
, UNIX_TIMESTAMP(NOW()) AS timecreated
, t.sortorder
FROM mdl_course c
LEFT JOIN mdl_enrol e
ON (c.id = e.courseid AND e.enrol = 'lmb')
LEFT JOIN (SELECT courseid, (COALESCE(MAX(sortorder), -1) + 1) AS sortorder FROM mdl_enrol GROUP BY courseid) t
ON (c.id = t.courseid)
WHERE e.id IS NULL
AND c.format != 'site'