Updated for moodle 2.6 and higher
moodle 2.7 compatibility