AutoEnrol for Moodle 2.7

There’s been lots of questions and interest in AutoEnrol ever since Moodle 2.6 came out. I’ve now got some time to put together an updated version and there are a few new functions in Moodle which I want to take advantage of in the next release. My plan is to release an updated version with Moodle 2.7 compatibility in the next few weeks.

As for the longer term picture with AutoEnrol, I originally developed the plugin because I felt cohorts did not offer a flexible enough mechanism for getting users onto a course quickly. Since then cohort functionality and efficiency has improved greatly, and I am wondering whether it would be better to build a mechanism for dynamically populating cohorts so that they can be added to a course.

I’m keen to hear thoughts on this and will probably fire up a discussion on the Moodle forums soon. If you have any thoughts you would like to share now please do leave a comment for me here!

Backwards compatible collapsible forms

If you are lucky enough to be running Moodle 2.5 the chances are you will have encountered the wonderful new collapsible forms. I’m really excited to get these onto our production server as they remove the user fear factor which can result from displaying a form with too many options

Collapsible Form Sections

If you are coding a new Moodle form and you want to take advantage of this, the sections can be collapsed or expanded like this:

$mform->addElement('header', 'generalsection', 'General Header');
$mform->setExpanded('generalsection', false);

Great! But what about if you want this form to work with Moodle 2.4 or earlier? The best solution to this is just to check that the setExpanded method exists within the mform class, and then to wrap your code with an if statement.

$mform->addElement('header', 'generalsection', 'General Header');
if(method_exists($mform, 'setExpanded')){

Hope that helps someone out there!