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.

Answers


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

https://github.com/moodlehq/totara/tree/t2-release-2.5/totara/customfields

The data definition in here - look for course_info_field and course_info_data

https://github.com/moodlehq/totara/blob/t2-release-2.5/totara/core/db/install.xml

Also look elsewhere in the source for course_info_field and course_info_data to see where it has been integrated.


Need Your Help

How do you populate an x86 XMM register with 4 identical floats from another XMM register entry?

c++ c x86 inline-assembly sse

I'm trying to implement some inline assembler (in C/C++ code) to take advantage of SSE. I'd like to copy and duplicate values (from an XMM register, or from memory) to another XMM register. For exa...

Need to loop through two loops and use delayed iterations in the inner loop

javascript jquery

What I'm trying to do is build a way to loop through two for loops, but the inner loop needs to have a delay on each iteration, but it can't be a queued animation.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.