Creating a fake enrolment plugin

Creating a fake enrolment plugin

by Jamie Nicholls -
Number of replies: 2

Hi all,

I'm fairly new too Moodle so not 100% sure if this is a good question or not.

I have created a 'fake' enrolment plugin so I was able to add custom fields to the course 'Edit settings' page without modifying core code. Everything is working fine apart from I can't get the custom fields to show up on older courses. The function course_edit_form is what I'm using to get the fields to display and I have managed to make it work with old courses by adding some code in course_updated function which creates instance of the plugin when the user updates the page. 

Is there a function that will check if an instant exists, and add it if it doesn't exist so that the fields will show in all courses once a user clicks on "Edit settings" of a course?

Average of ratings: -
In reply to Jamie Nicholls

Re: Creating a fake enrolment plugin

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Couldn't you just write an install / upgrade script (in the db/ sub directory of your plugin) to loop through all courses on the site and add the enrolment plugin?