Making Moodle Courses Not Enrollable
What?!? Rosalyn what the heck are you talking about.
I know, I know, my blog’s tag cloud is becoming Moodle heavy. Its true. But the boss man thinks that students shouldn’t be able to enroll themselves into any Moodle class at the drop of a hat. Sadly this makes sense (professors can be very protective of their class information because often times it informs their research). Sigh. So I’m off to make this happen.
So I’ve come up with a few ideas:
- I can just run a MySQL query every month:
update course set enrollable = 0;While yes this will work, how much of a pain will that be. I guess I could create a little script to do it for me. But honestly that’s not a solution that’s a patch.
- I can try going into moodle/course/edit_form.php and find the line:
$mform->setDefault('enrollable', 1);And change it to:
$mform->setDefault('enrollable', 0);Wow Rosalyn you’re genius! Yeah, no, I’m not I just found that in the Moodle Enrollment Plugins forum. A guy named Michael Skwara came up with it. So I tried it out. Unfortunately it doesn’t effect (or is that affect) courses I create using the LMB Enrollment Plugin. You can still enroll yourself into those. Darn it! Foiled again.
- Just change the database schema (oh yeah rosalyn…like that’s just so easy). I took a look in MySQL and the default for that column is set to 1, so if I set it to 0 perhaps that will make all new courses created with LMB default to not enrollable. Of course I’m assuming that LMB doesn’t really update things like the enrollable field in the course table (I mean where would it get that information). So I set about testing my theory.
First things first, I asked in the forum I referenced above if anyone saw a problem with what I was about to do before I did it. One of the Moodlers, Iñaki Arenaza, said that there shouldn’t be any problem with this. Which is what I suspected, unless of course Moodle goes crazy and revamps their DB schema…which would cause me other headaches.So on to my next portion of the testing, does LMB update the field enrollable or does it just leave it alone. So I installed a fresh Moodle (including the LMB plugin). From there I logged into the MySQL and changed the default value for the column enrollable by running the query:alter table course alter column enrollable set default 0;Your query might be different if you are using a prefix for your Moodle tables. I then ran an import using the LMB plug in. After that had finished I logged in using LDAP and tried to enroll myself in a course. And lo and behold I received the message:
This course is not enrollable at the moment.
SUCCESS! So students who aren’t attached to the course in Banner, can’t attach themselves to the course in Moodle. Professors however can still go in and add students (or delete students) from a course the way they did before.
So that’s my foyer into the world of altering the Moodle database schema in order to make the boss man happy. My next step is to upgrade Moodle so I can take advantage of the fun new features.
UPDATE
I noticed a few people have visited this post recently. While this fixed worked for me I recommend that you TEST IT OUT FIRST.