Limiting enrolements in a course?

Limiting enrolements in a course?

by John Moon -
Number of replies: 107
Hi Eeveryone,

Is there a block developed that allows you to limit the number of enrolements in a course?

For example, I have 10 places available in a course, as soon as those places are taken, I want anyone else who wants to enrole for that date to be "locked out" and advised that there are no more places available, and to enrole in the next available course.

Ideally the block would also show how many places are still available, and also allow the admin to set the number of places for a course.

Hope someone out there in "Moodle Land" either has the answer or has the necessary skill to build such a block smile

Thanks
JM
Average of ratings: -
In reply to John Moon

Re: Limiting enrolements in a course?

by Just H -
Hi John

Not sure if there is such a thing but I believe people have been setting a course up with a password (key) and using the choice module or block for "registration". Once all places have been filled, email the students with the password to get into the course.

Have never tried it but would be a good workaround I think, in the same choice you can list multiple courses/start dates similar to a year/term schedule.

Worth having a look.

Regards
Harry
In reply to Just H

Re: Limiting enrolements in a course?

by John Moon -
Thanks for the quick response Harry.

I'll give it a shot, it would still be good if this could be done without the use of a registration key though.

JM

In reply to John Moon

Re: Limiting enrolements in a course?

by Martín Langhoff -
No, but in 1.6 using interactive enrolment plugins (such as manual enrolment) you can indicate that the course is no longer enrollable -- but it is still available to enrolled students. You can make this date-based.

If you _really_ need this to be integrated, you could write a custom enrolment plugin. Just clone 'manual' and count existing enrolments before you allow a new student in.

In 1.5 the only mechanism is to use an enrolment key.
In reply to John Moon

Re: Limiting enrolements in a course?

by Joseph Spilatore -

Hello Jon,

Our organiztion needed to automatically limit students enrolled in each course  by setting maximum seats. We coded something that may work for you.A teacher or admin can set the maximum number of seats available for each course on the edit course page. The solution is not a block but it has solved our problem. The attached Zip has all the files nessecary. If you are going to use it, please make sure you test it on your development server.

In reply to Joseph Spilatore

Re: Limiting enrolements in a course?

by John Moon -

Fantastic!  I'll give it a shot.

 

And yes, I have a test server that I use before publishing anything, I'll let you know how i go!

Many thanks smile

JM

In reply to Joseph Spilatore

Re: Limiting enrolements in a course?

by John Moon -

Hi Joseph,

 

Unfortunately I get the following error:

Fatal error: Cannot redeclare make_upload_directory() (previously declared in C:\Program Files\xampp\htdocs\moodlenew\lib\setuplib.php:42) in C:\Program Files\xampp\htdocs\moodlenew\lib\moodlelib.php on line 2069

Because i can't code in PHP I'm lost as to what I can do.

My version of Moodle is 1.6.1

 

...JM

In reply to John Moon

Re: Limiting enrolements in a course?

by John Moon -

Hi Folks,

It looks like Joseph's solution is designed to work on an earlier version, as I'm running 1.6, and I'm not a PHP coder, would anyone out there who has the skill care to take a crack at it using Joseph's scripts as a base? (Joseph is not a PHP coder either).

I believe if this can be done it would be a great idea and is a far more efficient way of limiting class size than issuing keys.

Hoping you can help!

JM

 

In reply to John Moon

Re: Limiting enrolements in a course?

by Ken Wilson -
John

Challenge accepted - but I have a small database with just 1500 students and 160 courses. Are you OK to test the code on your non-production system?

Ken
In reply to Ken Wilson

Re: Limiting enrolements in a course?

by John Moon -

Hi Ken!

Absolutely!

Ready to go whenevery you are smile

Many Thanks!

 

JM

In reply to John Moon

Re: Limiting enrolements in a course?

by Ken Wilson -
OK. Initial attempt attached. Please read the README.txt and make sure you backup the 6 files as shown in there. The language files assume English_utf8, and the changes are documented, but let me know if anything needs adding.

Let me know how it goes.

Ken
In reply to Ken Wilson

Re: Limiting enrolements in a course?

by N Hansen -
Ken-I'm going to try this out. I have read your readme file, and I have to say this is the best written readme file I have seen here at Moodle. I really appreciate the list of changes because I may already have hacked versions of these files and it is easier for me to make the changes myself manually than to overwrite the files.
In reply to Ken Wilson

Re: Limiting enrolements in a course?

by N Hansen -
I've installed this and it seems to work on 1.6 (with a few patched files so it is somewhere between 1.6 and 1.6.1). I think it would be nice if somewhere on the enrollment page the student could see how many spaces are left in the course (perhaps with a threshold limit of how low it should be set at), kind of like the Amazon.com way of showing how many books are still in stock. I've got paid courses with a limited number of spaces and students may be hesitant to enroll but if they see how few spaces are left they might be more motivated to act.

It also might be nice if there was a way for the teacher to manually enroll a student even if the limit has been reached. Is that what the "enforce limit" on your todo list means?
In reply to N Hansen

Re: Limiting enrolements in a course?

by John Moon -

Hi Nicole!

To get around the manual enrollment is quite easy, just edit the course and change the number for enrollees.  I was able to add an additional user that way.

Yes it would be a *nice to have* if you could also set a minimum number as well as an email notification sent to the facilitator/teacher that the ceiling limit has been hit...... but I ain't gonna quibble *grin*.

Ken, if you could add those it would be fantastic, but if you can't then I'm happy anyway.

 

JM

In reply to Ken Wilson

Re: Limiting enrolements in a course?

by John Moon -

Hi Ken,

You are a bloody marvel mate!

Works just fine for me.

I'm almost prepared to say I hope England beats us in the Ashes later in the year, but..... I really can't bring myself to say that *grin*.

Well done! 

In reply to John Moon

Re: Limiting enrolements in a course?

by Ken Wilson -
Thanks for the positive feedback and the list of improvements. Attached is the next version with the number of places displayed to students. I've spent this week testing this with manual interactive enrolment and PayPal enrolment, but would be interested in any other enrolment methods.

There is still some work to be done, especially in the waiting list and emailing to teachers areas, and I'll be transferring any further uploads to the Enrolment forum (as this is not a block smile) in this thread http://moodle.org/mod/forum/discuss.php?d=31392.

-- Ken





In reply to Ken Wilson

Re: Limiting enrolements in a course?

by Ken Wilson -
Apologies for the last attachment as it was missing one important file. The correct one is attached.

-- Ken
In reply to Ken Wilson

Re: Limiting enrolements in a course?

by siva manukonda -

Ken...you rocks!!!

I am cracking my head for last few days on this issue and luckily find this thread. It solved my enrolment issues. Instructions are simple and stright forward.

Great work. Keep going.

-Siva

 

In reply to Ken Wilson

Re: Limiting enrolements in a course?

by Timothy Takemoto -
Superb! Thank you very much Joseph and Ken Wilson. And thanks to John Moon for publicizing it on the enrolments plugins forum!

This will allow preregistration of students - to keep the numbers even between classes and also get them to learn the basics of moodle even before term begins.

I would very much like to see this in Moodle proper. What is the licence on this? I am going to ask at moodle.com for a quote to ask how much it would be to integrate this code. Please feel free of course to charge moodle.com for your code, if appropriate, so desired.

Tim
In reply to Timothy Takemoto

Re: Limiting enrolements in a course?

by Sascha Stonefield -
Hi everybody,

first of all thanks for your work on this.

Now, since we are on 1.7, my question would be how to implement this on the new version.

tried both on my test system, which made me copy the backup files back afterwards. (Of course I did a backup...wink )

Will you update the hack ? Or is it the only option to put in the phpcode into the approptiate files manually...?

Thanks in advance,
Sascha
In reply to Ken Wilson

Re: Limiting enrolements in a course?

by Timothy Takemoto -

I think that I will use this for preregistration as of next term.

In order to use this for preregistration, the only feature that seems to be missing is the ability to set a limit on the number of courses that students can enrol on within a category. As it stands students can preregister on multiple courses.

But on second thoughts I doubt if this will work with student self enrolment using an enrolment key. Full enrolment into the class should only occur when the student turns up to the class and recieves an enrolment key. This means that preregistration needs to be a a sort of temporary enrolment, and I don't think that Ken's hack will acheive this.

But on third thoughts I see that I had seen this difficult before and worked out a way around it. I am using "redirect courses" to mother courses. These redirect courses are just as their name suggests, a course that merely redirects to another central content containing course. These redirect courses can be used to provide the limbo preregistration with the final registration to the content-containing "mother course" taking place with the student gets the enrolment code.

In view of the chaos we are having with some classes with three students and some with 60 (class limit 30) I wish I had implemented preregistration for this term.

Tim



In reply to Ken Wilson

Re: Limiting enrolements in a course?

by Frank von Danwitz -
Hi Ken,

I have tried your max_enrol... script on moodle 1.6.4 with an interesting result: course creators can`t edit their courses if they logout and log in a few minutes later. If the admin create a course and and put a trainer into the course, there is no effect - it works. So, do you have an idea about this problem (with the course creators)?
In reply to Joseph Spilatore

Re: Limiting enrolements in a course?

by N Hansen -
Joseph-What do students see/get told when the course reaches its maximum enrollment? Are manual enrollments still possible?
In reply to N Hansen

Re: Limiting enrolements in a course?

by Joseph Spilatore -

/// 20050330 check if course is full
    if ($course->maxstudents > 0 and $course->numstudents >= $course->maxstudents) {
      $message = get_string('enrolcoursefull', '', $course);
      print_header();
      notice($message, $CFG->wwwroot);
    }

    if (! $site = get_site()) {
        error("Could not find a site!");
    }

    check_for_restricted_user($USER->username);

    $enrol = new enrolment_plugin();

In reply to Joseph Spilatore

Re: Limiting enrolements in a course?

by Mark Manoukian -

Anybody try this in 1.7 yet?

-mark

In reply to Mark Manoukian

Re: Limiting enrolements in a course?

by Jesse Demarco -
I have been trying to get this to work in 1.7. There are many function changes in moodlelib.php from 1.6 to 1.7.

Any advice for how to get around these invalid function calls in moodlelib.php would be appreciated. I have a complete list of function names and line numbers if anyone would like to help debug.
In reply to Jesse Demarco

Re: Limiting enrolements in a course?

by Jit San Chia -
I have just tried in 1.7.1+
It works fine : ) Thanks a lot Ken. Fantastic readme file.
I simply followed step by step part (C) of readme.
Omitted step (6) : no more such function (enrol_student) in moodlelib.php in version 1.7.1
Also omitted step (10): no more such file (student.html) in course directory in this version.
Despite the 2 omissions, it still works as it should.
What does step (10) do Ken? Where is that supposed to appear in the earlier version?

In reply to Jit San Chia

Re: Limiting enrolements in a course?

by Jit San Chia -

Found out what step (10) does: shows max enrolment and available places left in assign students list. That is handled by admin/roles/assign.html in version 1.7.1+

Added the code snipplet into the file according to the readme, plus a if clause so that the 2 pieces of data only appears when assigning students, and not when assigning other roles to the same course.

Works well. Thanks again : )

In reply to Jit San Chia

Re: Limiting enrolements in a course?

by Jit San Chia -

Found out what step (10) does: shows max enrolment and available places left in assign students list. That is handled by admin/roles/assign.html in version 1.7.1+

Added the code snipplet into the file according to the readme, plus a if clause so that the 2 pieces of data only appears when assigning students, and not when assigning other roles to the same course.

Works well. Thanks again : )

In reply to Jit San Chia

Re: Limiting enrolements in a course?

by Richard Cory -
Is there another piece of code that non-programmers need .... "plus a if clause so that the 2 pieces of data only appears when assigning students, and not when assigning other roles to the same course."

thanks
RC
In reply to Richard Cory

Re: Limiting enrolements in a course?

by Jit San Chia -
Please see the attached text file. Hope that is helpful. Forgive me if it's too long winded. big grin

By the way, it works wonderfully in 1.8 as well.
In reply to Jit San Chia

Re: Limiting enrolements in a course?

by Anne Tan -
Hi all,

I am using Moodle 1.8, and am trying to use this plugin. I am currently following the instructions from readme section C.

Edit.html does not exist anymore. What do I do with the supplied code in step 2?

And, edit.php does not have the functions as in the 1.6 version. so, again, what do I do with the supplied code, in step 3?

Thanks if someone could help. I am a php idiot, and my team is trying to implement a course administration system from the school.

Thanks to all in advance
Anne
In reply to Anne Tan

Re: Limiting enrolements in a course?

by Linda Le -

BUMP

I need some assistance on 1.8 as well. (like above post)

In reply to Linda Le

Re: Limiting enrolements in a course?

by Steven Chen -

Ken, is there some way you can please look into this?

I was hoping this feature can be added into new 1.82 version, now it seems the upgrade I made from 1.72 isn't that worthy , giving the fact that your code only works for 1.72 or prior.

Thanks, --S

In reply to Steven Chen

Re: Limiting enrolements in a course?

by Glenn Specht -
I am a new user... testing to see if the software will work for me.

I installed this "hack" on my test download ( v1.8.?)...it broke it very badly. smile

I have learned a lot about moodle today.

I hope this feature gets fixed... for now I will just go and start over ( easier then backtracking on the "hack")
In reply to Glenn Specht

Re: Limiting enrolements in a course?

by Steven Chen -

Max number for each course is so important to me, so I end up downgrade back to 1.65. Everything seems to be working so far! Hope Ken see this post and thank Ken for the good job and may you please modify it so it fits 1.82?

cheers,

steven

In reply to Steven Chen

Re: Limiting enrolements in a course?

by Winston D'Souza -

Hi Steven,

Did you manage to get this to work for version 1.8?

If so, could you point me in the directions where I can obtain this patch to get it to work for me.

Many thanks

Winston

In reply to Jit San Chia

Re: Limiting enrolements in a course?

by Winston D'Souza -

Jit,

Could you send me the link for this html file, so I could modify the same for my 1.8 version.

Also besides updating this file, what other files did you need to modify / update?

Many thanks,

Winston

In reply to Winston D'Souza

Re: Limiting enrolements in a course?

by Kishore K -
It will be very helpful if someone puts the code that works well in moodle 1.8.
Many of the files specified in the readme are absent in 1.8.
Thanks,
Kishore.
In reply to Kishore K

Re: Limiting enrolements in a course?

by Kishore K -
Did it myselfsmile
For moodle 1.8, you don't have to use edit.html. Instead, modify the file moodle/course/edit_form.php:

$mform->addElement('text', 'enrolmax', get_string('enrolmax'), 'size="4"');
$mform->setHelpButton('enrolmax', array('enrolmax', get_string('enrolmax')), true);
$mform->setDefault('enrolmax', '');

This will create a label and textbox to add the maximum number of students.
Please read posts by Ken and Jit San Chia.

regards,
Deepu.
Average of ratings: Useful (1)
In reply to Kishore K

Re: Limiting enrolements in a course?

by Luis de Vasconcelos -

Deepu,

Thanks for this, but I'm still a bit lost... Could you describe the whole process that you followed to get this working in Moodle 1.8.

Thanks.

In reply to Luis de Vasconcelos

Re: Limiting enrolements in a course?

by Alan Barrett -

I have modified the approach above to work with Moodle version 2007021532 (1.8.3 +). All the files required are in the attached zip.

I have tested this and it seems to work correctly.

Average of ratings: Useful (1)
In reply to Alan Barrett

Re: Limiting enrolements in a course?

by Alan Barrett -

I did not mention it, but be sure to backup before making changes!

I paste here the modified help, as it has some different behaviour (in particular a limit of zero is no limit)...

<h1>Maximum number of enrolled students</h1>

<p>This setting specifies the maximum number of students

that are allowed to be enrolled on the course.</p>

<p>The number of available places will be displayed when a student

tries to enrol on a course.</p>

<p>When the number of students on a course reaches the

maximum limit, no student will be able to enrol on a course

(although an administrator will be able to assign a student).</p>

<p>Note that if the maximum number of students is zero,

there is no limit.</p>

Average of ratings: Useful (1)
In reply to Alan Barrett

Re: Limiting enrolements in a course?

by Luis de Vasconcelos -

Alan,

I've got it working on v1.8.3. THANKS!

I do however get an error message on the enrol.php page (see screenshot below):

Notice: Use of undefined constant availableenrolments - assumed 'availableenrolments' in D:\Moodle\course\lib.php on line 1842

I've set the max enrolments value in the course to 3 and there is already one student enrolled in the course (so there are 2 available places).

What could be causing this error?

I changed this line in your code:
        print_string(availableenrolments);

to this:
        print_string('availableenrolments');

and the error goes away. I added the quotes around availableenrolments. Is this correct?

Thanks

Attachment Error.jpg
In reply to Luis de Vasconcelos

Re: Limiting enrolements in a course?

by Alan Barrett -

Yes the fix you made is correct. You should also change line 1847 in same file (5 lines further down) to print_string('availableenrolmentsnone');

i.e. add quotes in the same way as you did.

I did not notice this error because I have display_errors = Off in my php.ini file and the action that PHP takes (adding quotes) is the correct thing to do.

I will add an updated zip file later in the day with these two small changes made.

Alan

Average of ratings: Useful (1)
In reply to Alan Barrett

Re: Limiting enrolements in a course?

by Alan Barrett -

Here is the updated zip file with the two changes made to lib.php (still matched to Moodle version 2007021532 (1.8.3 +)).

Alan.

Average of ratings: Useful (1)
In reply to Alan Barrett

Re: Limiting enrolements in a course?

by Jason Hollowell -
Picture of Particularly helpful Moodlers
I had installed Maximum_Enrolments on 1.8.3+ and it worked fine but when I upgraded to 1.8.4+ there was a problem with the language file (Moodle.php). The symptoms were a little strange:

Double brackets around the text that is included in the "Save and display" and "Save and return to course" that appears at the bottom of the page whenever a standard activity is added (Database, Forum, Assignment etc.).

There must have been some slight changes made to the Moodle.php file found in the language folder (en_utf8) for 1.8.4+ from 1.8.3+

I pulled the lines from the moodle.php file included in the Maximum Enrollments package and pasted them into the new 1.8.4+ moodle.php file and the problem disappeared. I'm assuming this the correct approach to remedy this problem and posting the package here for 1.8.4+

Jason

P.S. I made a note of the changes in the readme file.
Average of ratings: Useful (1)
In reply to Jason Hollowell

Re: Limiting enrolements in a course?

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Jason and Alan,

Please could one of you add your Maximum Enrolments code to the modules and plugins database so that people can find it more easily.
In reply to Helen Foster

Re: Limiting enrolements in a course?

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Jason or Alan,

Thanks for your contribution of the Maximum Enrolments code. Whichever one of you will be maintaining the code, the procedure that I would like to suggest following is:

  1. Create an issue in the tracker (under CONTRIB) to create a new block. You can upload the latest zip file there. That will allow me to add the files to CVS CONTRIB where it can be maintained. It also allows me to create a component in the tracker so that bug reports, suggestions, improvements, etc. can be tracked.
  2. Apply for access to the submitted code, by going to the Moodle Developers link on the Moodle.org front page and complete the form. Then we can review the request for CVS access and approve it.
  3. Then add the entry to the Modules and Plugins database with links to CVS and the downloads. Moodle can then automatically create zip files nightly which will facilitate users getting the latest code.
In the past, putting code out on the forums in zip files has created some confusion as to which is the latest code so hopefully we can avoid this, reduce time spent on administrative type stuff, and maximize our development efforts. I hope that by following this procedure will help those contributing code to learn the practices used by developers, provide them with the tools that the developers use to manage their workload (like the tracker), and allow for the code to be more easily maintained, reviewed and distributed to other Moodlers.

Please do not hesitate to let me know if you have any questions in getting things setup.

Peace - Anthony
In reply to Anthony Borrow

Re: Limiting enrolements in a course?

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Anthony, Helen, and Alan,

I apologize for maybe 'jumping the gun' by posting the zipped max enrollments package. To be honest, I was excited that I was able to get it repaired for myself and even more excited about the idea of contributing as I'm using on the receiving end of things.

As much as I'd love to be a 'code maintainer' I don't have the skills yet to take on such a task and more importantly, the max enrollments package is not my creation so it would not be appropriate for me to 'take it over' even if I had the technological skill to do so.

I am however, a little curious about the procedure that you have outlined for contributing and developing code. I understand the need for an organized approach and for maintaining a certain level of control over the access rights of those allowed to contribute formally. The downside I'm wondering about though, is that if the process is too 'narrowing' in that it limits the number of people involved in contribution and development, the evolution of the overall Moodle package may be stifled as a result. I know there has to be a balance somewhere and I certainly don't know where that is but it is nice to know that as I slowly learn my way around the inner workings of Moodle (and php) I can fairly easily contribute through the forums (on a very small scale smile).

I guess I'm just trying to figure out how I could have made a contribution such as the one I thought I was making by posting the max enroll package given the fact that I'm not advanced enough to be a formally registered contributor? I suppose I could have e-mailed the package to the maintainer (Alan?) but then that puts an extra burden on him (however small it might be).

Don't get me wrong, I'm not upset nor are my feelings hurt. I just wanted to 'think out loud' a little and get a little feedback on my thinking. smile

Jason
In reply to Jason Hollowell

Re: Limiting enrolements in a course?

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Jason - Absolutely no need to apologize as we are just beginning to work out the best way to encourage folks to share code. My intent was to share that procedure with everyone and explain how I envision that procedure be helpful. I'm excited that you were able to find a fix and were willing to share it. The procedure for formally contributing and maintaining code is actually meant to help train folks to become long term Moodle contributors. For those who find it too complex and simply want to share a zip file through the forums that is fine. It is not intended to stifle or limit who contributes but rather to help them to learn how to contribute in a way that is consistent with the way that Moodle developers work. My hope would be that it will help foster more developers. Feel free to learn at your own pace and know that as your skills grow, that you have folks willing to help you learn how to use CVS, the tracker, etc. Typically the way that folks report problems with code is through the tracker. They create an issue in the tracker which is usually automatically assigned to the maintainer of that part of the code. The maintainer can then evaluate the issue and make the needed changes. Sometimes, folks like yourself already have a solution and they are able to share that which makes the maintainer's job all the more easy. The advantage to CVS is that the code remains in one place and everyone can easily figure out what the latest or current version is which leads to less time on maintenance and hopefully more time for development. Feel free to think out loud, ask questions, etc. We're all in this together! Peace - Anthony
In reply to Anthony Borrow

Re: Limiting enrolements in a course?

by Bruce Schmoetzer -
This is a great hack that I have been using since Ken Wilson first created it for v1.6. In fact, I modified it for v1.8.0 for my own needs. I had every intention of updating the documentation and contributing to this thread. However, life and work got in the way. Which is good, since Alan & Jason's revisions are MUCH better than mine.

A tracker issue (MDL-6394) was opened for this back in 2006 and is still Open. I have taken it upon myself to post the 1.8.4+ and 1.9 files to the tracker for further review and (hopefully) inclusion in a future release. If you would like to see this feature included sooner (rather than later) I suggest going to the issue and Voting for it. Voting does require you to have an (free) account in the Tracker.

A minor problem that I have run into:
In moodle v1.8.4+ (2007021541) it does not display the number of Available Places remaining in a course on the All Courses page or on the Available Courses list on the Front Page. The code (Moodle_Maximum_Enrolments_1.8.4_Folder.zip) appears to be correct in the function print_course($course) in the moodle/course/lib.php file. However, it is significantly different enough from Ken's original code that I am having trouble debugging this issue. Any thoughts?

The same is true for the moodle 1.9+ version as well. In addition, I discovered that something must have changed from the 19_Release to the latest 19_Stable version (Moodle 1.9 + (Build: 20080329) because the moodle/course/lib.php in the Moodle_Maximum_Enrolments_1.9_Beta_4_22_Jan.zip file broke my 1.9+ (test!) installation. I had to manually update the 1.9+ moodle/course/lib.php with Alan's revision using copy and paste. I have attached that revision to this post for anyone who might need it.

I could really use either the 1.8.4+ or 1.9+ fix asap as summer teacher workshops will be opening for enrollment soon.

THX!

-Bruce

In reply to Bruce Schmoetzer

Re: Limiting enrolements in a course?

by Bruce Schmoetzer -
Found the issue with 1.8.4+ and 1.9+ moodle/course/lib.php code that was not allowing moodle to display the Available Places quantity. It appears that:
if (!empty($course->enrolmax))
is returning <empty> and thus is skipping past the code that calculates & displays the Available Places. So, I merged and modified Ken Wilson's original code with Alan's & Jason's updates and it works just fine. I added some code to display "Available places: Unlimited" when enrolmax=0.

I have attached the 1.8.4+ zip file with this. In addition, I left both Ken's and Alan/Jason's code in the lib.php files so that others can see what I did and can try their hand at making it better. I will make another post with the 1.9+ files.

THX!

-Bruce

Average of ratings: Useful (1)
In reply to Bruce Schmoetzer

Re: Limiting enrolements in a course?

by Bruce Schmoetzer -
Here is the 1.9+ set of files.

THX!

-Bruce

Average of ratings: Useful (1)
In reply to Bruce Schmoetzer

Re: Limiting enrolements in a course?

by Heather Valli -

This looks like a very useful plugin! I've tried to install it according to the readme file in the zip, copying the folder over and so on. It doesn't seem to be showing up. I'm working with the Moodle 1.9 + (Build: 20080514) version. I've been looking in the admin courses enrolments settings and in the individual course settings, and I'm just not seeing where to set the max enrolments. Is there another place I should be looking, please?

Thanks,

-Heather

In reply to Heather Valli

Re: Limiting enrolements in a course?

by Alan Barrett -

The setting should be in Courses... Add/edit courses... (select a course from a course category)... Settings

Two groups below entrolments there should be a group called "Enrolment - Limit total number of students for course" with a setting of "Maximum enrolled students" and a help button.

Hopefully this is what you need. If there is some other problem, I will try and resolve for you.

I have a 20080514 version of the patch which is specifically for your build in case there is any problem using the latest patch. When you went to http://your-site/admin/ it should have installed properly even though the versions are somewhat different.

... In fact it might be better to use this older patch version to avoid any compatibility or upgrade problems now or at a later stage. If you want to message me your e-mail address I will e-mail it to you, it is very small but this forum only supports 100k max file attachments.

    Alan

In reply to Alan Barrett

Re: Limiting enrolements in a course?

by Heather Valli -
Thank you, Alan.

When I followed your suggested path (Courses . . . Settings) I did find a reference to Max Enrolment, but it looks like this:

enrolmaxheader
I'm thinking that working with your older patch version would be a good idea. Thank you so much for offering it! My email address is:

hvalli at intrahealth dot org.

Thanks again for your help with this.

Heather
In reply to Heather Valli

Re: Limiting enrolements in a course?

by Alan Barrett -

The stuff means that Moodle cannot find the text resource. That might mean that you are not using English as your language (I only provided English resources). Alternatively you did not copy the new lang/en_utf8/moodle.php which contains the updated text resources. Can you tell me which is the case (or if I have missed some other option)?

The help file (indicated by the question mark) is there however.

I will send the old patch to you by e-mail.

I will also (but not now) update the README instructions which I see are deficient.

    Alan.

In reply to Anthony Borrow

Re: Limiting enrolements in a course?

by Alan Barrett -

Helen, Anthony,

Sorry I did not reply to your suggestions on the correct process to follow since your 7th February post. For some reason I am not getting e-mailed when there is a post to the forum. I will try to make some time to look at what needs to be done (if not already done by someone else).

Alan.

P.S. I wonder is my e-mail provider blocking mails from moodle.org for some reason?

In reply to Alan Barrett

Re: Limiting enrolements in a course?

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Alan - I do not see anything on the Moodle.org site that would cause you not to receive emails. It appears that you are in fact subscribed to the Blocks forum and that your email address in enabled in your profile. Might they be going into a junk bin or trash? Peace - Anthony
In reply to Anthony Borrow

Re: Limiting enrolements in a course?

by Alan Barrett -

I am happy to maintain the code. But I would like to point out that it is not a stand-alone "block". Because the code has to prevent users for joining a course when it is full it must be integrated into existing code. I don't know of any way of making it a clean separate block (although it is possible that some but not all of the code dependencies could be moved into a separate block). Ideally the functionality should be integrated into core Moodle.

Pending that, I am happy to follow your process. However I wonder how you can, as you say, "automatically create zip files nightly" because of the need to modify core code. However I can upload the .zip to work with the latest Moodle.

Any comments/suggestions?

By the way I have changed to a secondary e-mail address so I can receive notifications. The ISP can only change the SPAM block if they get an example of a bounced mail (assuming that it IS being bounced). Unless there is someway that you can find an example of a bounce to alanbarrett AT ireland DOT com and send to alanabarrett0 AT gmail DOT com, I will just have to continue using my secondary e-mail. By the way, I don't think Moodle Tracker is bouncing (even though it is from moodle.org, it may be from a different IP address).

Alan.

Average of ratings: Useful (1)
In reply to Alan Barrett

Re: Limiting enrolements in a course?

by Alan Barrett -

I have now finished a 1.9 + version with a clean installation and upgrade process and it is in the CONTRIB CVS and the Modules and plugins database at: http://moodle.org/mod/data/view.php?d=13&rid=1241

This will be maintained for Moodle 1.9 weekly builds.

Also to answer Alex Elab's question. I believe it already does what you want. It is not dependent on enrolment type.

Alan.

Average of ratings: Useful (1)
In reply to Alan Barrett

Re: Limiting enrolements in a course?

by Alan Barrett -

I note that the Modules and Plugins database requires approval, so the link above is not visible yet. Pending that, the code is in http://download.moodle.org/patches/max_enrolment.zip See the README.txt for instructions.

Alan.

In reply to Alan Barrett

Re: Limiting enrolements in a course?

by Jamie Tinley -
Are there any plans to include a waiting list function so that when a student or teacher unenrolls, a new place is available and the next student on the waiting list is emailed and/enrolled in the course? That would make it perfect.

Thanks - my only other solution for waiting list is to improvise using the examination module which has waiting lists. I would have to name each exam as a 'course' and have them enroll in the real course and if not, 'enrol' in the 'exam' aka course waiting list (in a general course with no limit on enrollment). confusing and not pretty. Thanks for all your hard work.

Jamie Tinley
In reply to Alan Barrett

Re: Limiting enrolements in a course?

by Luis de Vasconcelos -

NICE WORK Alan! Thanks.

What are the database changes that this "hack" makes? Can you add the details of these database changes to the Readme.txt file?

Thanks.

In reply to Alan Barrett

Re: Limiting enrolements in a course?

by Alex Elab -
Hello,
I wanted to expand the function. What do I have to change in the code so that the available number of seats can be displayed for every course. Also in the courses for which no key / password is required.

Thanks for the help
In reply to Alan Barrett

Re: Limiting enrolements in a course?

by Luis de Vasconcelos -

Thanks Alan. I've installed it and it seems to be working properly on Moodle 1.8.3 +. I will test further...

I'm curious though, will your block work with Moodle version 1.8.2?

In reply to Luis de Vasconcelos

Re: Limiting enrolements in a course?

by Alan Barrett -

The code will probably work with 1.8.2 but I do not have a copy of 1.8.2 to verify that the relevent files are the same between 1.8.2 and 1.8.3. If the PHP files are different between the two versions then cutting and pasteing in my code will almost certainly work as long as the 1.8.2/1.8.3 changes are not in the same place as my changes.

Note that code is not a 'block', just a set of code changes.

Alan.

In reply to Alan Barrett

Re: Limiting enrolements in a course? V1.9

by Alan Barrett -

I have been asked to provide a version for Moodle 1.9 . Attached is a zip file (Moodle Maximum Enrolments 1.9 Beta 4 22 Jan.zip) for that version. It is a cut and paste of the changes for 1.8.3 into the the 1.9 files. IT HAS NOT BEEN TESTED on 1.9 . I would appreciate feedback from the person who requested it about whether it works.

Alan.

In reply to Alan Barrett

Re: Limiting enrolements in a course? V1.9

by avi levi -

it looks OK.

i didn't see any bugs yet

In reply to avi levi

Re: Limiting enrolements in a course? V1.9

by Alex Elab -
Hello,
I wanted to expand the function. What do I have to change in the code so that the available number of seats can be displayed for every course. Also in the courses for which no key / password is required.

Thanks for the help
In reply to Alex Elab

Re: Limiting enrolements in a course? V1.9

by nutan kale -

Alex,

did you find out about the extending max enrollment i.e showing available number of seats ???

In reply to Alan Barrett

Re: Limiting enrolements in a course? V1.9

by Alan Barrett -

Posting this for "Frederico Guimarães" as he cannot post...

Frederico Guimarães [Thu, 20:23]: Hi Alan,

I'm trying to use the "Moodle Maximum Enrolments 1.9 Beta 4 22 Jan", with the recent released Moodle 1.9, but I'm with a problem. After applying the patch, Moodle only show the "header" of the page (the title of the site, the login information and the language selector, with a rule under).

Did anyone reported the same problem? I tried to put this information on the discussion page (
http://moodle.org/mod/foru/discuss.php?d=50063), but I don't have permission to this. So would you like to put this message there, as

Best regards,

In reply to Alan Barrett

Re: Limiting enrolements in a course? V1.9

by lsa bug -
I had a similar experience trying to get this module working. I overwrote the lib, lang, course, and admin directories with the ones in the module but when I went to my moodle 1.9 (fresh install-latest version) it was a blank page. I don't think it automatically updated the database. I ended up deleting these and restoring the originals.
In reply to lsa bug

Limiting enrolements in a course? V1.9

by netsparx itservices -
Hi Everyone,

Need help-I am using 1.9.3 and i tried uploading this plugin but seems to be difficult...can somebody help me on this?
I am getting this error....
Fatal error: Cannot redeclare update_category_button() (previously declared in C:\xampp\htdocs\moodle\lib\weblib.php:5186) in C:\xampp\htdocs\moodle\course\lib.php on line 1928

Would be kind if somebody could help me on this...
In reply to netsparx itservices

Re: Limiting enrolements in a course? V1.9

by Alan Barrett -

This is likely caused because your max_enrol patch version does not match the Moodle version. In particular there have been recent changes to lib.php.

The version of max_enrol at http://download.moodle.org/download.php/patches/max_enrolment.zip matches this weeks build of Moodle 1.9.3 (built late Tuesday/early Wednesday). You can either download the current Moodle 1.9.3 weekly build and the current max_enrol build and everything "should" be OK. Or if you tell me which weekly build you downloaded (date is in version.php or if you know the exact date when you downloaded)... I will send you a matching max_enrol.

I believe this should sort things out. Please let me know how you get on or if you need me to send you a dated max_enrol build.

    Alan.

In reply to Alan Barrett

Re: Limiting enrolements in a course? V1.9

by netsparx itservices -
Hi Alan,

Thanks for the quick reply and also your kind help, i uploaded the plugin it works well..i had to also take help of Moodle_Maximum_Enrolments_1.9+_Beta_4_30_Mar ( got it from earlier posts)
Would need another help from you, Is there any plugin, wherein we could apply credits for these enrollments.
For instance, If a admin has affiliate role for whom he sells the course.Payment would be basically like $50 = 20 credits. and number of credits equalls to number of student enrollments allowed...
Is there any plugin which would support credit system( or something that satisfies the above senanrio) within Moodle??
Does this make sense?
Solution for this would be a gr8 help! smile
In reply to netsparx itservices

Re: Limiting enrolements in a course? V1.9

by Alan Barrett -

There is a Moodle table "enrol_paypal" in the database that records every Paypal payment. So it would be easy enough to write an SQL query that extracts all Paypal payments (along with the cost from the Moodle "course" table) and give a total which could be converted to credits. Do all credits go to the same person? If not how would you determine who the credits go to?

If you wish I could send you a php file with the correct SQL to total and display the cost paid via Paypal.

However, I may not have understood what you want, and the above might not be suitable. Would a count of students who have paid for each course  me more useful, or total of students, whether or not they have paid?

    Alan.

In reply to Alan Barrett

Re: Limiting enrolements in a course? V1.9

by Gani Sait -
Hi Alan,

I have installed this patch and it is working
fine. But there is one problem.

1)As a admin i can assign more than the specified user (as you mentioned)

2) I have created a new role called course manager and i have given a permission to assign roles and create,edit,delete user.

Now the issue is as a course manager now he can assign more than the specified users ???

Is it possible to restrict only admin can assign more than the specified no.of users?

If you could give a fix that would be really great!


Note:- This course manager can only add,edit,delete users but he cant alter any course settings.

Thanks,
Gani
In reply to Gani Sait

Re: Limiting enrolements in a course? V1.9

by Alan Barrett -

It would be possible, which some amount of work, to add a patch that would check that the limit is not exceeded when the course manager is assigning roles. However the number of free places is displayed when assigning student roles, surely the course manager is a trusted person if he or she can delete users. Can he or she not just check the display so that students do not exceed the specified number?

Alan.

In reply to Alan Barrett

Re: Limiting enrolements in a course? V1.9

by Gani Sait -
Hi Alen,

Thanks for the info.
I have just added some patch and its working fine.

Regards,
Gani
In reply to lsa bug

Re: Limiting enrolements in a course? V1.9

by Iuri Jacob -
I had this same problem. So looked out for the Alan´s modifications (line by line) and applied it directly on the 1.9.3. For my best surprise, it worked!

If someone is still having problem with this patch for Moodle 1.9.3 (Build 20081015) I suggest you to try my version of patch.

Another suggestion is to backup the original files before the replacement, so you can restore your moodle to the "status quo" if it stop working.

All code credits for Alan, of course!

Regards,
Iuri

PS: The file is in RAR format with the highest compression due to the attachment size limit policy of the forum.
In reply to Iuri Jacob

Re: Limiting enrolements in a course? V1.9

by Iuri Jacob -
This is the same as my last implementation (the reply above), but for the Moodle 1.9.3+ (Build 20081210). It's tested and it's working.

Regards,
Iuri

In reply to Iuri Jacob

Re: Limiting enrolements in a course? V1.9

by Alan Barrett -

That's great. If other people need a version of the max_enrolment patch to match any weekly build during the past year, I can probably provide them with one.

Alan.

In reply to Alan Barrett

Atbilde: Re: Limiting enrolements in a course? V1.9

by ibkk sia -
Pls help!

After uploading files to website and going to the URL http://your-site/admin/ me show only blank page un site not working overall. Moodle 1.9.3 (Build: 20081015).

Thanks advance

Ibkk
In reply to ibkk sia

Re: Atbilde: Re: Limiting enrolements in a course? V1.9

by Alan Barrett -

Send me your e-mail address to alanabarrett0 AT gmail.com and I will mail back the 20081015 build of the patch.

    Alan.

In reply to Alan Barrett

Re: Atbilde: Re: Limiting enrolements in a course? V1.9

by Greg Lind -
I applied the patch to 1.8.8 via cut and paste since I wasn't sure the files would be identical. Everything functions as I expected.

However, I get double brackets around the display (see attached photo).

Originally it printed availableenrolments : unlimited

I changed that to Spaces Available.

However, I still get the double brackets. Any suggestions of what I did wrong or how I might make the brackets go away?

Thanks.
Attachment Picture_3.png
In reply to Greg Lind

Re: Atbilde: Re: Limiting enrolements in a course? V1.9

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
This is what happens when the language strings cannot be found in the language pack.
Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Atbilde: Re: Limiting enrolements in a course? V1.9

by Greg Lind -
Thanks! That's what I needed and it makes sense now. I'll change my strings back to the way they were and take care of things in the language pack.
In reply to Alan Barrett

Re: Atbilde: Re: Limiting enrolements in a course? V1.9

by Manfred Burkardt -
Hye,

I would like to install the limit enrollment patch on my 1.9.4 (28th of january 2009) moodle installation.
Is there a version of the patch for this moodle version?
How could I get a copy?

Thank you,
Manfred
In reply to Manfred Burkardt

Re: Atbilde: Re: Limiting enrolements in a course? V1.9

by Alan Barrett -

Please e-mail me at alanabarrett0 AT gmail.com and I will send you the version you want (20090128).

Alan.

In reply to Alan Barrett

Re: Atbilde: Re: Limiting enrolements in a course? V1.9

by Manfred Burkardt -
Thank you very much Alan.

As usual the patch works perfect for me.

I made a translation to catalan and spanish of the relevant part of moodle.php file.

To use the spanish version just paste at the end of lang/es_utf8/moodle.php :

$string['availableenrolments'] = 'Plazas disponibles'; // ALAN
$string['availableenrolmentsnone'] = 'No quedan plazas'; // ALAN
$string['availableenrolmentsunlimited'] = 'Illimitadas'; // ALAN
$string['enrolcoursefull'] = 'Perdón, el número de inscripciones en este curso ha llegado a su limite. El curso esta lleno.'; // ALAN
$string['enrolmax'] = 'Máximo alumnos inscritos'; // ALAN
$string['enrolmaxerror'] = 'Máximo alumnos inscritos tiene que ser un numer no negativo sin espacios'; // ALAN
$string['enrolmaxheader'] = 'Inscripciones - Limite número de alumnos'; // ALAN
$string['enrolmaxshort'] = 'Máximo alumnos'; // ALAN

To use the catalan version just paste at the end of lang/ca_utf8/moodle.php :

$string['availableenrolments'] = 'Plaçes disponibles'; // ALAN
$string['availableenrolmentsnone'] = 'No queden places'; // ALAN
$string['availableenrolmentsunlimited'] = 'Illimitades'; // ALAN
$string['enrolcoursefull'] = 'Disculpeu, el nombre d\'inscripcions en aquest curs ha arribat al seu limit. El curs està ple.'; // ALAN
$string['enrolmax'] = 'Màxim alumnes inscrits'; // ALAN
$string['enrolmaxerror'] = 'Màxim alumnes inscrits ha de ser un nombre no negatiu sense espais'; // ALAN
$string['enrolmaxheader'] = 'Inscripcions - Limit nombre d\'alumnes'; // ALAN
$string['enrolmaxshort'] = 'Màxim alumnes'; // ALAN


In reply to Manfred Burkardt

Re: Atbilde: Re: Limiting enrolements in a course? V1.9

by Alan Barrett -

Thanks I will add these translations to the max_enrolment patch.

Alan.

In reply to Alan Barrett

Re: Atbilde: Re: Limiting enrolements in a course? V1.9

by Kevin Lau -
Has anyone be able to get the block to work with 1.9.5? I can't seem to get it to give the options when I create a course.
In reply to Kevin Lau

Re: Atbilde: Re: Limiting enrolements in a course? V1.9

by Alan Barrett -
 As long as you took 1.9.5 weekly and the same weekly Enrollment Max patch it should work (if you need an older patch, I can send to you). When you go to your course and settings you should see

"Enrolment - Limit number of students

Maximum enrolled students"

Enter a non zero number for this and the patch should work. If this form element does not show, maybe you did not go to Site administration/Notifications to trigger install of the patch?

I am willing to help further to get it working.

Alan.

In reply to Alan Barrett

Re: Atbilde: Re: Limiting enrolements in a course? V1.9

by Ovidiu Marinescu-Paninopol -

Hi,

Can you help me with the patch for 1.9.5 version (build 20090805) I downloaded latest version and didn't work. Nothing was changed into tables.

BR,

Ovidiu

In reply to Ovidiu Marinescu-Paninopol

Re: Atbilde: Re: Limiting enrolements in a course? V1.9

by Alan Barrett -

If you were to give me admin access to you site, maybe I could figure out what is wrong.

Also, I think, it might be necessary to have Linux command line access (if it is a Linux system).

It is hard to be more specific when it just "didn't work". It should work as long as you have a matching version of the patch copied into all the right places and also go to notifications to enable it.

My e-mail is alanabarrett0 AT gmail.com

    Alan.

In reply to Alan Barrett

Max_enrolement also visible in long courselists

by Martin Mandausch -
Dear Alan,

thanks for mailing me the patch - it works perfectly!

I have a little suggestion: I copied the added code from /course/lib.php also to /course/info.php

Now, the information about the max number of enrolments or the availiable places left is also diplayed in the pop-up, that comes up by clicking on the info-button, that you can see, if you have many courses in this list. Maybe you want to add this little feature to your patch.

Best regards from Germany
Martin
In reply to Martin Mandausch

Re: Max_enrolement also visible in long courselists

by Alan Barrett -
Thanks! If you attach the info.php file you edited, I will see can I add it when I get some time.

Alan.
In reply to Alan Barrett

Re: Limiting Enrollments in a Course V1.96+

by Ryan Wick -
Hello, I was wondering if there is a version for the newest build (1.96). Limiting the enrollments in courses would be a great deal of help to us!

Thanks!
In reply to Ryan Wick

Re: Limiting Enrollments in a Course V1.96+

by Alan Barrett -

The version on the Moodle site is always kept up to date (by me) for the newest weekly build. So if you download the Weekly Moodle 1.9.6+ and at the same time a max_enrolment build (http://download.moodle.org/download.php/patches/max_enrolment.zip), they will match.

I also have older builds if you need them.

Alan.

Average of ratings: Useful (1)
In reply to Alan Barrett

Re: Limiting Enrollments in a Course V1.96+

by Ryan Wick -
Thanks, Alan! I moved the files before I installed Moodle 1.96 Weekly and everything worked out fine! Everyone here (especially my scheduling guy) really appreciates the help!
In reply to Alan Barrett

Limiting Enrollments in a Course V1.9.10+

by Jim Cook -

Alan,

I am running the very latest Moodle build - 1.9.10+ (20101117).  I am not sure what version of your hack I have.  The Course folder is dated 10/20/2010.  All seem to install correctly, however when I am in the Edit Course screen I see at the very top of my form "Enrolment file register/enrol.php does not exist".  It appears it is looking for something in a register folder (that I can't find) and I can not find where /register/enrol.php is in any file.  I think it is an easy fix.  can you help?

Thanks

Jim

In reply to Alan Barrett

Re: max_enrolment - bacup/ restore and students role

by Paweł Suwiński -

Hi

I have made small improvement by adding enrolmax course parameter to global backup/ restore mechanism and by unifying  student role definition: CONTRIB-367.

In reply to Alan Barrett

Re: Limiting Enrollments in a Course V1.96+

by Ali Rajabpour Sanati -

hello and thank you for providing new version of this useful patch.

i am trying to install this patch on moodle 2.2+, how can i do that? i will very appreciate your help...

thank you in advanced