Plugin contribution

Revision as of 08:32, 6 March 2009 by Daniele Cordella (talk | contribs) (How to submit code)

Jump to: navigation, search

This page describes the various ways to share and work collaboratively on contributed code.

  1. Submit code in the Moodle Tracker under CONTRIB.
  2. Work with submitted code in Moodle's CVS server
  3. Document features and install instructions in Moodle Docs
  4. Share and distribute code in the Modules and Plugins database
  5. Talk and support code in the Using Moodle forums
  6. Maintain and further develop code with the Moodle Tracker

The Frequently asked question

Question: I have written a new block, activity, patch or theme to share with the Moodle community. What is the process for contributing the code?

Answer: First, thank you for your generosity and desire to share your work with the rest of the Moodle community. Code contributions are highly valued and Moodle wants to encourage creativity and generosity in keeping with its constructivist tradition and pedagogical approach. To support this, there are several tools will support your contribution by allowing the code to be more easily found, tested, used, maintained, documented, and evaluated by fellow Moodlers and developers. Learning to use the various tools common among Moodle developers will help you to efficiently and effectively develop, share and maintain the contributed code.

How to submit code

You have created some code that you would like to contribute to the Moodle community. The first step is to create a login in Tracker. You should create a new issue as a "non- core contributed module" project and a "New Feature" issue type. Here is a link to tracker with those fields filled in.

Your issue will be a request that the code be evaluated and uploaded into CVS. Provide a clear description of what the code does and the functionality that it adds to Moodle. Attach the contributed code as a zip (or tar.gz) file to the tracker issue. At that point, the Contrib Coordinator will work directly with the code contributor to help evaluate the code, work on resolving any questions/issues found, etc.

How to work with code in CVS

Once the code has been added to the CONTRIB section of Moodle's CVS, the contributor will request CVS write access via and thus be able to make changes to the contributed code.

Contributors are encouraged to maintain a branch for each major Moodle release (i.e. 1.8, 1.9, etc.). The HEAD branch should be used as the development branch. Once CVS write access is approved, the maintainer will be able to make whatever changes are needed to maintain the code.

That being said, contributors are encouraged to associate each change made to an issue in the tracker. This is accomplished automatically by beginning the CVS commit comment with the issue number. By doing so, the contributor helps to document the reason for the change in the code back to the issue requesting for a change. More information on working with CVS is available at: CVS (developer).

Tip: Eclipse is an example of an Integrated Development Environment (IDE) that integrates and facilitates many of the common CVS tasks involved in working with Moodle CVS. Instructions for setting up and using Eclipse are available at: Eclipse. Experienced developers are free to use the tools they are most comfortable/productive with.

How to provide documentation

Having great code available to the community is wonderful. It is also important to educate users about how to use the code with documentation in Moodle Docs. See guidelines for contributors for more help.

A documentation page for a contributed module should have some basic elements. A brief introduction of what the code does, a "Features" heading, perhaps a "Installation", "Tips and tricks" and "See also" headings, all with content of course. Sometimes a screenshot is worth 1000 words. In the "See also" put a link to the Modules and Plug database, with a note that this is the place to download versions, and the forum where questions can be answered at

Other information might include: Languages Supported, Known Issues, Supported Versions (for Moodle 1.8, 1.9), and maybe which are being actively supported. We suggest placing
[[Category:Contributed code]]
at the bottom of the page.

Share code with modules and plugins database

Now you have a place for users to get your code, how will they know it exists? Moodle users can easily find information about contributed code in the Modules and Plugins database. When you add an entry to this database, remember that it is searchable by any field. Every field is not required, but providing as much information as possible will help people who would like to find, read about, and then install your contribution. In particular, the name of the module and the description of its function are important. Screen shots are helpful (but please, not larger than 350px wide!). Links to discussion (on or other forum) and documentation (link to your page in the Moodle docs or another location) should be included if possible.

If you are maintaining your code using Moodle's CVS server, a zip file of your code is automatically created and stored on Moodle's download server ( Therefore, the download link for most contributed code will be a link to Moodle's download server. If you host your code on a site other than Moodle's download server, please ensure that the download link goes directly to the file and that the file is in a standard archive format (i.e. preferably a zip file). This makes it easier for users to locate the file quickly and helps to standardize installation of the code.

Users may leave comments on your entry, so please check it periodically for questions and bug reports. If you include contact information or a link to a discussion, your users may be able to contact you more directly. The comments are not emailed automatically.

Keep in mind that entries added to the Modules and Plugins database require approval by a moderator before they will be visible to other Moodle users.

Support code and get feedback with forums

As users become familiar with the contributed code, discussions about the code are likely to emerge. We strongly urge you to place links to at least one forum at in your Modules and Plugins entry as well as in MoodleDocs.

It is important to respond to users who have questions about how to use the code, suggestions for how to make it better, etc. If it looks like there is sufficient need for some contributed code to have its own forum, please create a request via the tracker in the MDL-SITE section. Moodle has included many contributed code projects and ideas into its core.

Maintain and refine code with Tracker

In order to facilitate keeping track of feature requests, bugs, and other code issues, the contributor may request that a component be created in the CONTRIB section of the Moodle tracker. (This is the section where you initially made the request to have code included in

The contributor can be added to the group of CONTRIB developers in the tracker to manage the issues assigned to them and better coordinate with other developers. Users of the contributed code can then add issues which can be assigned directly to the maintainer. The tracker helps to manage the work flow involved in fixing bugs, working through feature requests, and maintaining the code. When committing changes, maintainers are strongly encouraged to begin the commit comment with a tracker number.

We strongly encourage users to involve themselves in the process of creating a useful issue in tracker. For the developer and code contributor, describing the fix can help clarify the need for the code change. Further, it helps to establish good documentation about how the code developed. Others will be able to identify the issues addressed and understand why a particular decision was made.


It is hoped that following this procedure, will help guide contributors of code in the process of learning the tools and skills used by the Moodle developers. Learning to submit code by using the tracker, work the code with CVS, support the code by providing documentation, share code in Modules and Plugins, maintain the code by using the tracker, and evolve the code by using the forums will assist you in successfully contributing to the Moodle community and working with Moodle's developers.

Throughout this process, the CONTRIB Coordinator is here to encourage and support those contributing code to the Moodle community and fostering the development of tomorrow's Moodle developers.

Eventually, the community may wish for the code to become part of the Moodle core. By following the steps above, the developers will be able to evaluate the merit of the contributed code, understand how users have used the code, see the issues that have emerged and thus have more information to make an informed decision about whether or not to incorporate the contributed code into core.

Most common recommendations for contributed code

There are several small issues that the CONTRIB Coordinator will typically check for when reviewing the code prior to committing to the CVS server. These issues help to ensure consistency and quality of code. Any suggestions made by the CONTRIB Coordinator should be considered recommendations aimed to help folks new to the Moodle community collaborate in a way consistent with standard practices within the Moodle community. The suggestions are meant to help avoid potential issues and facilitate the acceptance of your code.

  1. Does the file structure conform to Moodle standards? - Generally speaking, each file should have an appropriate extension (i.e. php, html, css, txt, etc.). To avoid issues with case sensitivity, folders and files are normally lower case; however, there are exceptions to this. Another common recommendation is to place the lang folder within the block or module rather than asking the user to copy files into the main lang folder. Changes made in the get_string function for Moodle 1.9 and onward make it possible to do this which goes a long way in keeping things modular.
  2. Does the code work without any obvious errors - The CONTRIB Coordinator will try to install the block or module on a fresh Moodle installation and report back any errors. This testing is done with Debugging set to show All PHP notices and errors (not developer mode). The most common notices have to do with attempting to use a variable that has not been initialized or checked for existence.
  3. Does the code use the config_plugins table? - Contributed blocks and modules are encouraged to make use of the config_plugins table rather than the config table. Maintainers are encouraged to read the documentation provided for the get_config and set_config functions in the /lib/moodlelib.php file to help ensure that the footprint for the global $CFG variable does not become bloated.
  4. Does the code follow the Coding Guidelines? - The CONTRIB Coordinator will look at the code for general readability and point out any obvious deviations from the Coding Guidelines. While not all code needs to conform with each and every guideline, maintainers are encouraged to follow those guidelines as closely as possible.

See also