- 1 Help for new coders
- 2 I can't use one of the available plug-in points to make my change. What alternative is there?
- 3 Moodle's database
- 4 How to get/set information when writing new Moodle code
- 5 What is 'HEAD'?
- 6 How do I migrate code to Moodle 2.0?
- 7 See also
Help for new coders
Where can I start?
Where can "newbies" to Moodle get help?
The General developer forum! Feel free to ask any question, no matter how basic or advanced. Many people ask different levels of question every day, and the community is generally welcoming and quick to respond.
How do I create a patch?
How do I create a new module or plugin?
- NEWMODULE Documentation
- Authentication plugins
- full list of plugin types.
- Also have a look at the Moodle Developer Courses.
- Moodle 1.9 Extension Development - Customize and extend Moodle using its robust plug-in systems by Jonathan Moore, Michael Churchward - highly recommended
Is there any information on backup and restore?
I can't use one of the available plug-in points to make my change. What alternative is there?
See Local customisation.
Where can I see a schema for the structure of the Moodle database?
Database_schema_introduction gives a high level overview of the database schema.
Because of Moodle's modular nature, there is no single, detailed representation of the full database schema. Instead, the tables for each part of Moodle are defined in a database-neutral XML format, see XMLDB, in each part of Moodle. Look for files called install.xml in folders called db throughout the code. Alternatively, from Moodle 2.0 onwards, go to Administration -> Development -> XMLDB editor, and use the [Doc] links to see automatically generated documentation built form the comments in the install.xml files.
See also Database FAQ.
How to get/set information when writing new Moodle code
How do I find out the currently-logged-on user?
The global object $USER, which contains the numeric $USER->id among other things.
How do I find out the current course?
The global object $COURSE, which contains the numeric $COURSE->id
How do I insert/retrieve records in the database, without creating my own database connections?
You use the $DB object, as described in the Data manipulation API documentation.
How do I get/set configuration settings?
- config table
To get config values you would typically access the global $CFG object directly, which is automatically created by the core Moodle scripts. To set these "main" config values use set_config($name, $value). The values are stored in the Moodle "config" database table, but these functions take care of cacheing on your behalf, so you should always use these rather than fetching the records directly.
- config_plugin table
There is also a second table of config settings specifically for plugins ("config_plugin"). These are not automatically loaded into the $CFG object, so to fetch these you would use get_config($plugin, $name). To set them use set_config($name, $value, $plugin).
On top of those global configuration values, individual blocks may also have configuration "object" associated with it (the data is serialized and stored in the "block_instance" table). Within blocks, this data is automatically loaded into the config attribute of the block.
What is 'HEAD'?
HEAD is version control jargon for the latest version, so at the moment it means Moodle 2.0 dev version. (After the Moodle 2.0 stable branch is made, HEAD will mean 2.1 dev). Look for example, at the links at the top of http://cvs.moodle.org/moodle/README.txt?view=log&pathrev=MOODLE_19_STABLE You can get it from http://download.moodle.org/ and install it if you want to play.
How do I migrate code to Moodle 2.0?
Using Moodle forum discussions: