Note: You are currently viewing documentation for Moodle 3.7. Up-to-date documentation for the latest stable version of Moodle may be available here: Modules.

Development:Modules: Difference between revisions

From MoodleDocs
m (category, formatting)
Line 1: Line 1:
These are by far the most important modules, and reside in the 'mod' directory. There are seven default modules: assignment, choice, forum, quiz, resource, and survey. Each module is in a separate subdirectory and consists of the following mandatory elements (plus extra scripts unique to each module):
'''Activity modules''' reside in the 'mod' directory. Each module is in a separate subdirectory and consists of the following mandatory elements (plus extra scripts unique to each module):


* mod.html: a form to set up or update an instance of this module
* ''mod.html'' - a form to set up or update an instance of this module
* version.php: defines some meta-info and provides upgrading code
* ''version.php'' - defines some meta-info and provides upgrading code
* icon.gif: a 16x16 icon for the module
* ''icon.gif'' - a 16x16 icon for the module
* db/: SQL dumps of all the required db tables and data (for each database type)
* ''db/'' - SQL dumps of all the required db tables and data (for each database type)
* index.php: a page to list all instances in a course
* ''index.php'' - a page to list all instances in a course
* view.php: a page to view a particular instance
* ''view.php'' - a page to view a particular instance
* lib.php: any/all functions defined by the module should be in here. If the modulename if called widget, then the required functions include:
* ''lib.php'' - any/all functions defined by the module should be in here. If the modulename if called widget, then the required functions include:
:* widget_add_instance() - code to add a new instance of widget
:* widget_add_instance() - code to add a new instance of widget
:* widget_update_instance() - code to update an existing instance
:* widget_update_instance() - code to update an existing instance
Line 14: Line 14:
:* widget_user_complete() - given an instance, print details of a user's contribution
:* widget_user_complete() - given an instance, print details of a user's contribution
:* To avoid possible conflict, any module functions should be named starting with widget_ and any constants you define should start with WIDGET_
:* To avoid possible conflict, any module functions should be named starting with widget_ and any constants you define should start with WIDGET_
* Lastly, each module will have some language files that contain strings for that module. See below.
* Lastly, each module will have some language files that contain strings for that module.


The easiest way to start a new learning activity module is to use the template in mod/newmodule_template.zip. Unzip it and follow the README inside.
The easiest way to start a new activity module is to use the template in ''mod/newmodule_template.zip''. Unzip it and follow the README inside.


You might also like to post first in the Activities modules forum on Using Moodle.
You may also like to browse the [http://moodle.org/course/view.php?id=5 Activity modules forum] on Using Moodle.
 
[[Category:Developer]]

Revision as of 15:33, 9 January 2006

Activity modules reside in the 'mod' directory. Each module is in a separate subdirectory and consists of the following mandatory elements (plus extra scripts unique to each module):

  • mod.html - a form to set up or update an instance of this module
  • version.php - defines some meta-info and provides upgrading code
  • icon.gif - a 16x16 icon for the module
  • db/ - SQL dumps of all the required db tables and data (for each database type)
  • index.php - a page to list all instances in a course
  • view.php - a page to view a particular instance
  • lib.php - any/all functions defined by the module should be in here. If the modulename if called widget, then the required functions include:
  • widget_add_instance() - code to add a new instance of widget
  • widget_update_instance() - code to update an existing instance
  • widget_delete_instance() - code to delete an instance
  • widget_user_outline() - given an instance, return a summary of a user's contribution
  • widget_user_complete() - given an instance, print details of a user's contribution
  • To avoid possible conflict, any module functions should be named starting with widget_ and any constants you define should start with WIDGET_
  • Lastly, each module will have some language files that contain strings for that module.

The easiest way to start a new activity module is to use the template in mod/newmodule_template.zip. Unzip it and follow the README inside.

You may also like to browse the Activity modules forum on Using Moodle.