- Moodle 3.x Developer's Guide
- Ian Wild
- 441字
- 2021-07-02 21:34:42
Enrolment
Course enrolment can only take place if there is a user to enrol. The standard plugins are listed when, from the Site administration menu, you click on Plugins, then Enrolments, and finally select Manage enrol plugins. The available course enrolment plugins are displayed on the Manage enrol plugins page:

Check out the documentation on enrolment plugins at https://docs.moodle.org/dev/Enrolment_plugins. The best way of understanding the operation of enrolment plugins is by going back to the Moodle source in Eclipse in lib/enrollib.php. Take a look in enrollib.php for the enrol_plugin class declaration:

The first thing to notice is that enrolment plugins belong to courses and not to the system as a whole--this makes sense as this allows us to enroll users on a variety of courses by a variety of means. Also note that we can enable more than one enrolment plugin per course. For information on configuring course enrolment, see https://docs.moodle.org/31/en/Course_enrolment.
Users are enrolled on courses and allocated different roles (as in real life, it is the role a user is allocated that defines exactly what they are able to do--that is, users with the editing teacher role can edit the course and users with the student role can't), but note that enrolling and allocating roles are two separate processes in Moodle.
You will see from the documentation that enrolment plugins also need to handle the following:
- Suspended and expired users
- Self-enrolment (where a user enrolls themselves onto a course)
- Payment gateways
As with authentication, the enrolment process can be hooked: Events are fired at each stage of the enrolment process that our enrolment plugin can listen out for and, when it hears a specific type of event, it can perform some kind of event-specific task.
Now navigate through Eclipse PHP Explorer to the self-enrolment plugin located in /enrol/self:

Clearly one of the more obvious differences between an authentication and an enrolment plugin is the amount of complexity: There are far more PHP scripts to an enrolment plugin compared to an authentication plugin. The cli folder contains a cron script that calls the sync() function that, depending on the type of enrolment plugin, will allow us to set up timed synchronization of enrolments to, say, an external database during some quiet period. You will also see that the db folder contains scripts not only for upgrading, but also for installing. It also contains a script to manage access to enrolment functionality based on the capabilities of a user's role (access.php). There will be a deeper exploration of enrolment plugins, as well as development of our own, in Chapter 6, Managing Users - Letting in the Crowds.
- Web程序設計及應用
- Windows系統(tǒng)管理與服務配置
- SEO智慧
- C++ 從入門到項目實踐(超值版)
- Learning ELK Stack
- MongoDB權(quán)威指南(第3版)
- Python深度學習:模型、方法與實現(xiàn)
- 響應式架構(gòu):消息模式Actor實現(xiàn)與Scala、Akka應用集成
- 持續(xù)輕量級Java EE開發(fā):編寫可測試的代碼
- 案例式C語言程序設計實驗指導
- 從零開始學Selenium自動化測試:基于Python:視頻教學版
- Python全棧開發(fā):基礎入門
- Scrapy網(wǎng)絡爬蟲實戰(zhàn)
- Learning Alfresco Web Scripts
- 每個人的Python:數(shù)學、算法和游戲編程訓練營