** Totara 30 Day Free Trial- Access Now! **

Course prerequisites in Moodle 2

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:

https://github.com/enovation/moodle (you can clone git://github.com/enovation/moodle.git)

(The branch with the course prerequisite code is called course_prerequisites)

June 27, 2011 In: Blog Written by: smcguinness


  • June 27, 2011

    It it really necessary to do this by changing core code?

    I feel it should be possible to do this using an enrolment plugin. Base it on enrol/self, but with some extra configuration options so it becomes “Students may enrol themselves in this course, but only after these other courses have been completed.”

  • smcguinness
    June 30, 2011

    Hey Tim, that’s a great idea. I will look into that and post an update

  • July 1, 2011

    I hope this feature appears on the road map.

    As a temp measure I created a resource that only displayed when the course was completed. It was the enrolment key for the subsequent course. Superificial I know, but from a none coder like myself, a temporary solution.

  • Itay ophir
    July 9, 2011

    great idea and I know for sure many higher Ed noodle sites will need this.
    I also like Tim’s idea to add this as a plugin.

    please post when you have an update.


Leave a Reply