Is there a limit to the maximum number of students enrolled in a course? (through all possible enrolment methods)

Is there a limit to the maximum number of students enrolled in a course? (through all possible enrolment methods)

by sadaf sadafian -
Number of replies: 2
hi. 
i have some teachers and course that i want prevent teacher can enroll user more than i set as a moodle admin for his course . not different between self-enrollment method or manual method or any other methods. i understand each enrollment method has "max enrolled user" setting but my mean about all enrollment method limitation. i can write any local plugin for this propose but can any one give me any clue to use what event api? it seems there is no "on before user enrol " event.
Average of ratings: -
In reply to sadaf sadafian

Re: Is there a limit to the maximum number of students enrolled in a course? (through all possible enrolment methods)

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Not every enrolment method has a 'max enroled user' setting. So limiting all enrolment methods will not be that easy.

One sample is the enrolment on payment: what will your plugin do if 2 users pay at the same time for the last seat? You will have to implement a refund for the person who lost.
Another sample is the enrolment on course completion: you promise your students that if they complete Course A, they will be enrolled in Course B. But then your local plugin pops up and shows that the user completed the course but the maximum is reached, so the student cannot access Course B.
Have also a look at the Cohort enrolment method, how will you implement a maximum when this maximum should be defined in the cohort?

There is indeed not a "before user enrol event", first the enrolment record is created and next the user_enroled is fired. So you could modify the core code to implement such an event. but I have the impression this method will add more frustration than functionality, if students take the step to access a course, you should encourage them, not show some discouraging message like "Maximum number of students reached".

Why do you not remove the enrol permissions (for each method) for these teachers?
In reply to Renaat Debleu

Re: Is there a limit to the maximum number of students enrolled in a course? (through all possible enrolment methods)

by sadaf sadafian -
thank you @Renaat
->same pay: The probability of this happening in most moodels is very low
other problem such as cohort and complete courseA ... also can handled by error message to contact with admin.
core modifying: it is failed after update moodle and i need every time i want update change that code and it is not standard.
Why do you not remove the enrol permissions (for each method) for these teachers? -> i need prevent teacher to add more than specific number of student for some course in any way. each of my course category assign to one departmant and each of them has some student that must not more than defined user to defined course. in anyway manual ,payment, self enrolment or any other enolment method.Course A must have for example 40 user in the maximum.
do you understand is it possible use overwrite any moodle function to add "before user enrol event"?