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:

  1. 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.

  2. 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.

  3. 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.

This entry was posted in Work and tagged , . Bookmark the permalink.

4 Responses to Making Moodle Courses Not Enrollable

  1. Carl Walker says:

    Hi Rosalyn,

    This is great and may save us a lot of work!

    Could you tell me who wrote your integration piece between Banner and Moodle?

    We have Moodle 1.9.2 (hopefully going to 1.9.5 very soon) and are using code created by Eric Merrill. We have not poked around in this code, but we thought that it was possibly his code that was making all our courses enrollable and I thought you might have some insight.

    Thank you for any assistance you can provide!

    Carl Walker

  2. Carl Walker says:

    Hi again Rosalyn,

    I thought of one more thing to bug you about :)

    We have over 1700 courses that were created with the enrollable setting turned on before we noticed it and now need to turn it off. Our Moodle host told us that we would have to go to the settings for each course and manually change the setting for all 1700! Similar to what you said, that is not a solution, that is a nightmare! Your first option is what we need to comb through the database and change that setting. If you have a script that could do that recursively and you would not mind sharing, it would save us a tremendous amount of work!

    Thanks again!

    Carl

  3. Rosalyn Metz says:

    @Carl Walker
    Hi Carl,

    We are using the code developed by Eric Merrill. We are VERY happy with it and can’t thank Eric enough for creating it.

    Also note that I removed the update. I think I had played with some other settings and that was why I couldn’t get LMB to enroll people.

    Lastly I don’t have a script. But if you wanted to you could create a MySQL query that would change all of your courses to not enrollable.

    Hope this helps.

  4. Hi Rosalyn,
    Found this link over at the Moodle.org forums.

    This worked perfectly for me. Thanks!

    Cheers,
    -n

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>