Development:New enrolments in 2.0
Note: This page is a work-in-progress. Feedback and suggested improvements are welcome. Please join the discussion on moodle.org or use the page comments.
Template:Infobox Project Template:Moodle 2.0
Overview
The major difference from 1.6-1.9 enrolments is that the course enrolment information is stored again in a separate database table course_participants. The enrolment related information was move from course table to new enrol table which holds plugin instances. The old enrolment plugins need to be completely rewritten. Course category enrolments via role assignments is not possible any more, existing category enrolments are migrated to new cohorts and cohort enrolment plugin.
The benefits are:
- we can use SQL to find enrolled users in any course extremely quickly (much better performance)
- multiple enrolment plugins per course are full supported (includes more instances of the same type)
- new enrolment overview interface
- user enrolments may be suspended and reactivated
- plugin may prevent users to change/break enrolment synchronised with external systems
- finer access control, more flexible/configurable course settings UI
- no hardcoded enrolment behaviour - it is possible to completely replace guest access, self enrolments, etc. with custom plugins
Database structure changes
New course_participants table
New table which stores users participating in courses (aka enroled users). It can be used directly in SQL joins.
Field | Type | Default | Description |
---|---|---|---|
id | int(10) | auto-incrementing | |
status | int(10) | 0 | 0 means active enrolment, 1 means suspended, anything else means inactive (user can not access course) and is defined by plugin |
enrolid | int(10) | foreign key, references enrol.id | |
userid | int(10) | foreign key, references user.id | |
timestart | int(10) | 0 | time stamp, start of active participation period |
timeend | int(10) | 0 | time stamp, end of active participation period |
modifierid | int(10) | last user who modified enrolment, references user.id | |
timemodified | int(10) | timestamp, last modification |
New enrol table
Stores information about enrolment plugins used in course, includes plugin configuration data and instance status. The optional fields have plugin specific meanings, plugins may define other tables related via the enrol.id if necessary.
Field | Type | Default | Description |
---|---|---|---|
id | int(10) | auto-incrementing | |
enrol | char(20) | enrolment plugin name | |
status | int(10) | 0 | 0 means active plugin, anything else means inactive (user can not access course) and is defined by plugin |
courseid | int(10) | foreign key, references course.id | |
sortorder | int(10) | order of instances in course | |
name | char(255) | optional plugin instance name, useful when multiple instances of the same plugin used in course | |
enrolperiod | int(10) | 0 | optional default enrolment period, in seconds |
enrolstartdate | int(10) | 0 | timestamp, optional default enrolment start date |
enrolenddate | int(10) | 0 | timestamp, optional default enrolment end date |
expirynotify | int(1) | 0 | optional flag |
expirythreshold | int(10) | 0 | timestamp, optional |
notifyall | int(1) | 0 | optional flag |
password | char(255) | optional enrolment password | |
cost | char(20) | optional cost field | |
currency | char(3) | optional currency field | |
roleid | int(10) | general optional field | |
customint1 | int(10) | general optional field | |
customint2 | int(10) | general optional field | |
customint3 | int(10) | general optional field | |
customint4 | int(10) | general optional field | |
customchar1 | char(255) | general optional field | |
customchar2 | char(255) | general optional field | |
customdec1 | decimal | general optional field | |
customdec2 | decimal | general optional field | |
customtext1 | text | general optional field | |
customtext2 | text | general optional field | |
timecreated | int(10) | timestamp, date when instance created | |
timemodified | int(10) | timestamp, date when instance last modified |