enrol API: Updated documentation
[moodle.git] / enrol / README.txt
CommitLineData
b8e13a57 1ENROLMENT MODULES
2-----------------
3
4(Yes, that's the correct English spelling ;-) )
5
63aea881 6enrol.class.php contains a simple 'factory' method that
7will instantiate your class when called. For an example
8of a complete class, take a look at the 'manual' class.
b8e13a57 9
63aea881 10Each plugin is in a subfolder here.
b8e13a57 11
63aea881 12Except for the configuration methods, most methods
13defined in the API are optional -- callers will use
14method_exists() to determine whether your plugin offers
15the functionality they are after.
16
17
18Mandatory methods
19-----------------
20
21 config_form
22 process_config
23
24
25Login-time methods
26------------------
27
28 get_student_courses
29 get_teacher_courses
30
31You probably will want to offer at least get_student_courses().
32
33These methods are triggered when a user logs in successfully,
34and they are expected to populate $USER->student and
35$USER->teacher arrays and maintain (add/delete) entries from
36user_students and user_teachers.
37
38These methods are relevant for most plugins, and are the main
39interest for plugins that work with a read-only backend such
40as LDAP or a database. You probably will want to offer at
41least get_student_courses().
42
43Note that with the multi-enrol infrastructure two things have
44changed. We now have an 'enrol' field in those tables, and
45each plugin must maintain only its own enrolment records.
46Conversely, the $USER->student and ->teacher arrays have the
47enrolment type as value, like
48
49 $USER->student = array ( $courseid => $plugintype );
50
51Interactive enrolment methods
52-----------------------------
53
54 print_entry()
55 check_entry()
56 check_group_entry()
57 get_access_icons()
58
59These methods are for enrolment plugins that allow for user
60driven enrolment. These methods are relevant for plugins
61that implement payment gateways (credit card, paypal),
62as well as "magic password" schemes.
63
64Only one interactive enrolment method can be active for
65a given course. The site default can be set from
66Admin->Enrolment, and then individual courses can be
67set to specific interactive enrolment methods.
68
69
70Cron
71----
72
73If your class offers a cron() method, it will be invoked by
74the standard Moodle cron every 5 minutes. Note that if the
75tasks are not lightweight you must control how frequently they
76execute, perhaps offering a config option.
77
78For really heavy cron processing, an alternative is to have
79a separate script to be called separately. Currently the LDAP
80and DB plugins have external scripts.
81
82
83Guilty Parties
84--------------
b8e13a57 85
86Martin Dougiamas and Shane Elliott, Moodle.com
63aea881 87Martin Langhoff and Patrick Li, Catalyst IT
b8e13a57 88