Moodle 2 has a great new feature called conditional activities. This allows you define an activity which must be completed prior to a student being allowed access to another activity. You won’t see the conditional activity options as standard, you first have to enabled them at site, course, or activity level.
The assumption people have when they read about this is that it can work on a course level. Users would like to define a course which must be completed before a student can enter another course. When you go looking for this you find a feature which you would expect does exactly what you are looking for, but it works a different way.
The way it works as standard in Moodle (2.0.3+) is that when a teacher sets up courses A and B, such that course A is a prerequisite to course B, the student can have access to both courses A and B – and access is not restricted to B but rather, in the completion process, course B cannot be marked as completed by the student unless course A is completed.
You could consider the term prerequisite has been used confusingly in this scenario because it doesn’t function as a prerequisite to access a course as access but a prerequisite to completion of a course.
One way to implement a feature which does prevent access to course B until course A is completed would be to add new course settings which are similar to the conditional activity settings for activities. You could then define a prerequisite course which should be completed before entry to the course would be permitted.
You would then need to modify the course login process to check if the student has met the prerequisite course requirements, and alert them if they are prevented access to the course. Simple!
I have created a proof of concept implementation which is made up of some new core files (a core lib file and language file), a new block and patches to lib/moodlelib.php, course/lib.php & course/edit_form.php
I have tried to keep the patches to a minimum, so each patch is only a few lines long. This code requires a new databases table but I didn’t want to patch the Moodle database scripts, so instead the block will handle the creation of the database table.
You can download a version of Moodle 2 with course prerequisites from our git repositories at:
(The branch with the course prerequisite code is called course_prerequisites)