Anyone got a query or easy way to set self-enrolment as the first option for existing courses. Was using the auto enrol plugin v2.6 but not available for v3 and since the upgrade a lot of existing courses no longer have a enrolment method set only new courses get it set as default
I'm not sure about doing this with SQL alone but it should be fairly easy to write a CLI script to add it.
You can get a list of all the courses that don't have the enrolment plugin by something like this:
SELECT c.id FROM mdl_course c LEFT JOIN mdl_enrol e ON c.id = e.courseid AND e.enrol = 'self' WHERE e.id IS NULL AND c.id <> :siteid
Then loop through the courses and use $plugin->add_default_instance($courseid) to add it (where $plugin = enrol_get_plugin('self'));