Add field to course settings in Moodle 2.X
We need to add several attributes to a course (duration, credits etc.). These items need to be stored as data so that they can be exposed via a custom report that has already been created.
What is the best practice for adding a field/setting/attribute to all courses created in Moodle 2.X such as "duration"? The answer may be best practice is to not do this or there may be a process programmatically to add attributes that we have yet to discover in the documentation.
Note: this is not a duplicate of Add a custom field to course Moodle
This previous question was posted at a time when Moodle 1.9 was still relevant, the question as it pertains to Moodle 2.X was not addressed.
Custom fields for courses were added to Totara - a distribution of Moodle.
They are very similar to the user profile fields.
You will need to extract the code from various places though.
The main code for the custom fields is in
The data definition in here - look for course_info_field and course_info_data
Also look elsewhere in the source for course_info_field and course_info_data to see where it has been integrated.