<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/35/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Koning</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/35/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Koning"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/35/en/Special:Contributions/Koning"/>
	<updated>2026-04-22T22:47:13Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/35/en/index.php?title=Development:Modules&amp;diff=61034</id>
		<title>Development:Modules</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/35/en/index.php?title=Development:Modules&amp;diff=61034"/>
		<updated>2009-08-06T17:19:59Z</updated>

		<summary type="html">&lt;p&gt;Koning: /* Activity modules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Activity modules === &lt;br /&gt;
&lt;br /&gt;
Activity modules reside in the &#039;&#039;&#039;/mod&#039;&#039;&#039; directory. Each module is in a separate subdirectory and consists of the following mandatory elements (plus extra scripts unique to each module):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;mod_form.php&#039;&#039; - a form to set up or update an instance of this module&lt;br /&gt;
* &#039;&#039;version.php&#039;&#039; - defines some meta-info&lt;br /&gt;
* &#039;&#039;icon.gif&#039;&#039; - a 16x16 icon for the module&lt;br /&gt;
* &#039;&#039;db/install.xml&#039;&#039; - defines the structure of db tables for all database types. Is used during module installation&lt;br /&gt;
* &#039;&#039;db/upgrade.php&#039;&#039; - defines changes in the structure of db tables. Is used during module upgrade&lt;br /&gt;
* &#039;&#039;db/access.php&#039;&#039; - defines module capabilities&lt;br /&gt;
* &#039;&#039;index.php&#039;&#039; - a page to list all instances in a course&lt;br /&gt;
* &#039;&#039;view.php&#039;&#039; - a page to view a particular instance&lt;br /&gt;
* &#039;&#039;lib.php&#039;&#039; - any/all functions defined by the module should be in here. If the module name is called &#039;&#039;&#039;widget&#039;&#039;&#039;, then the required functions include:&lt;br /&gt;
:* widget_install() - will be called during the installation of the module&lt;br /&gt;
:* widget_add_instance() - code to add a new instance of widget&lt;br /&gt;
:* widget_update_instance() - code to update an existing instance&lt;br /&gt;
:* widget_delete_instance() - code to delete an instance&lt;br /&gt;
:* widget_user_outline() - given an instance, return a summary of a user&#039;s contribution&lt;br /&gt;
:* widget_user_complete() - given an instance, print details of a user&#039;s contribution&lt;br /&gt;
:* widget_get_view_actions() / widget_get_view_actions() - Used by the participation report (course/report/participation/index.php) to classify actions in the logs table.&lt;br /&gt;
:* Other functions available but not required are:&lt;br /&gt;
:** widget_delete_course() - code to clean up anything that would be leftover after all instances are deleted&lt;br /&gt;
:** widget_process_options() - code to pre-process the form data from module settings&lt;br /&gt;
:** [[Development:Implementing Reset course functionality in a module|widget_reset_course_form() and widget_delete_userdata()]] - used to implement [[Reset course]] feature.&lt;br /&gt;
:* To avoid possible conflict, any module functions should be named starting with widget_ and any constants you define should start with WIDGET_&lt;br /&gt;
* &#039;&#039;backuplib.php&#039;&#039; and &#039;&#039;restorelib.php&#039;&#039; (optional)&lt;br /&gt;
* &#039;&#039;settings.php&#039;&#039; or &#039;&#039;settingstree.php&#039;&#039; - (optional) a definition of an admin settings page for this module. mod/assignment/settings.php is a good simple example. mod/quiz/settingstree.php is a more complex example.&lt;br /&gt;
* &#039;&#039;defaults.php&#039;&#039; - lets you easily define default values for your configuration variables. It is included by upgrade_activity_modules in lib/adminlib.php. It should define an array $defaults. These values are then loaded into the config table. Alternatively, if you set $defaults[&#039;_use_config_plugins&#039;] to true, the values are instead loaded into the config_plugins table, which is better practice. See mod/quiz/defaults.php for an example. (This apparently only works with moodle 2.x branch.)&lt;br /&gt;
* &#039;&#039;lang/en_utf8/widget.php&#039;&#039; - (optional) Lastly, each module will have some language files that contain strings for that module.&lt;br /&gt;
&lt;br /&gt;
=== IMPORTANT: ===&lt;br /&gt;
* When creating a new module, the new name of the module must not contain numbers or other special characters!&lt;br /&gt;
&lt;br /&gt;
* You need a &#039;&#039;data base table&#039;&#039; with the same name as your module. This table must have at least three fields: &lt;br /&gt;
*# id &lt;br /&gt;
*# course &lt;br /&gt;
*# name&lt;br /&gt;
&lt;br /&gt;
* You should also make sure that your activity module provides appropriate support for groups and meta-courses. &lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Development:Blocks]]&lt;br /&gt;
* [[Development:Backup]]&lt;br /&gt;
* Tracker issue [http://tracker.moodle.org/browse/CONTRIB-52 CONTRIB-52 Improvements to make NEWMODULE really useful] - including download link for new module template supporting roles, formslib etc. (unfinished) &lt;br /&gt;
* http://download.moodle.org/plugins16/mod/NEWMODULE.zip - new module template for versions of Moodle prior to 1.7. Please follow the README instructions inside the zip.&lt;br /&gt;
* [[Development:NEWMODULE_Documentation]]&lt;br /&gt;
&lt;br /&gt;
Using Moodle forum discussions:&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=66165 A new resource type: where do I put the language strings?]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=65986 New Module Template Code for Moodle 1.7]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=90154 LEGACY roles and capabilities]&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer|Modules]]&lt;br /&gt;
[[Category:Modules]]&lt;br /&gt;
[[Category:Tutorial]]&lt;br /&gt;
&lt;br /&gt;
[[es:Módulos de actividades (desarrollador)]]&lt;br /&gt;
[[fr:Modules (développeur)]]&lt;br /&gt;
[[ja:モジュール (開発者)]]&lt;br /&gt;
[[zh:开发:模块_(开发者)]]&lt;br /&gt;
[[de:Entwickler:Module]]&lt;/div&gt;</summary>
		<author><name>Koning</name></author>
	</entry>
</feed>