<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Trick</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Trick"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/Special:Contributions/Trick"/>
	<updated>2026-04-23T14:55:10Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Activity_modules&amp;diff=736</id>
		<title>Activity modules</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Activity_modules&amp;diff=736"/>
		<updated>2009-06-03T18:25:44Z</updated>

		<summary type="html">&lt;p&gt;Trick: /* Activity modules */ backwards slash&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;
:** [[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.&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;
* [[Blocks]]&lt;br /&gt;
* [[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;
* [[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: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>Trick</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Development:Developer_FAQ&amp;diff=29779</id>
		<title>Development:Developer FAQ</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Development:Developer_FAQ&amp;diff=29779"/>
		<updated>2009-06-02T23:45:25Z</updated>

		<summary type="html">&lt;p&gt;Trick: block instance config&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Help for new coders==&lt;br /&gt;
&lt;br /&gt;
===Where can I start?===&lt;br /&gt;
&lt;br /&gt;
See [[Development:Finding your way into the Moodle code]].&lt;br /&gt;
&lt;br /&gt;
===Where can &amp;quot;newbies&amp;quot; to Moodle get help?===&lt;br /&gt;
&lt;br /&gt;
The [http://moodle.org/mod/forum/view.php?f=33 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.&lt;br /&gt;
&lt;br /&gt;
===How do I create a patch?===&lt;br /&gt;
&lt;br /&gt;
See [[Development:How to create a patch]].&lt;br /&gt;
&lt;br /&gt;
===Is there any information on creating a new module or plugin?===&lt;br /&gt;
&lt;br /&gt;
See [[Development:Modules]], [[Development:Blocks]] and [[Development:Authentication plugins]], or the [[Development:Developer_documentation#Make_a_new_plugin|full list of plugin types]].&lt;br /&gt;
&lt;br /&gt;
===Is there any information on backup and restore?===&lt;br /&gt;
&lt;br /&gt;
See [[Development:Backup]].&lt;br /&gt;
&lt;br /&gt;
==I can&#039;t use one of the available plug-in points to make my change. What alternative is there?==&lt;br /&gt;
&lt;br /&gt;
See [[Development:Local customisation]].&lt;br /&gt;
&lt;br /&gt;
==Moodle&#039;s database==&lt;br /&gt;
&lt;br /&gt;
===Where can I see a schema for the structure of the Moodle database?===&lt;br /&gt;
&lt;br /&gt;
[[Development:Database_schema_introduction]] gives a high level overview of the database schema.&lt;br /&gt;
&lt;br /&gt;
Because of Moodle&#039;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 -&amp;gt; Development -&amp;gt; XMLDB editor, and use the [Doc] links to see automatically generated documentation built form the comments in the install.xml files.&lt;br /&gt;
&lt;br /&gt;
==How to get/set information when writing new Moodle code==&lt;br /&gt;
&lt;br /&gt;
===How do I find out the currently-logged-on user?===&lt;br /&gt;
&lt;br /&gt;
The global object $USER, which contains the numeric $USER-&amp;gt;id among other things.&lt;br /&gt;
&lt;br /&gt;
===How do I find out the current course?===&lt;br /&gt;
The global object $COURSE, which contains the numeric $COURSE-&amp;gt;id&lt;br /&gt;
&lt;br /&gt;
===How do I insert/retrieve records in the database, without creating my own database connections?===&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;datalib&amp;quot; functions, such as insert_record() or get_record(). Since Moodle 1.7 these are found in lib/dmllib.php. Using these functions helps with database abstraction (e.g. running on either MySQL or Postgres) as well as maintaining a single database connection. Moodle uses ADODB for database abstraction.&lt;br /&gt;
&lt;br /&gt;
Look at [http://phpdocs.moodle.org/19/moodlecore/_lib---datalib.php.html  the documentation for datalib.php] for the list of functions and details of use.&lt;br /&gt;
&lt;br /&gt;
===How do I get/set configuration settings?===&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;main&amp;quot; config values use set_config($name, $value). The values are stored in the Moodle &amp;quot;config&amp;quot; database table, but these functions take care of cacheing on your behalf, so you should always use these rather than fetching the records directly.&lt;br /&gt;
&lt;br /&gt;
There is also a second table of config settings specifically for plugins (&amp;quot;config_plugin&amp;quot;). 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).&lt;br /&gt;
&lt;br /&gt;
On top of those global configuration values, individual blocks may also have configuration &amp;quot;object&amp;quot; associated with it (the data is serialized and stored in the &amp;quot;block_instance&amp;quot; table). Within blocks, this data is automatically loaded into the &amp;lt;tt&amp;gt;config&amp;lt;/tt&amp;gt; attribute of the block.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[[Contributed code FAQ]]&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/view.php?f=33 General developer forum]&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=55719 How does date / time in DB convert to real Date / Time?] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[Category: Developer]]&lt;br /&gt;
[[Category: FAQ]]&lt;br /&gt;
&lt;br /&gt;
[[es:FAQ Desarrollador]]&lt;br /&gt;
[[fr:FAQ de développement]]&lt;br /&gt;
[[pl:Developer FAQ]]&lt;/div&gt;</summary>
		<author><name>Trick</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Developer_FAQ&amp;diff=3366</id>
		<title>Developer FAQ</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Developer_FAQ&amp;diff=3366"/>
		<updated>2009-06-02T23:45:25Z</updated>

		<summary type="html">&lt;p&gt;Trick: block instance config&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Help for new coders==&lt;br /&gt;
&lt;br /&gt;
===Where can I start?===&lt;br /&gt;
&lt;br /&gt;
See [[Finding your way into the Moodle code]].&lt;br /&gt;
&lt;br /&gt;
===Where can &amp;quot;newbies&amp;quot; to Moodle get help?===&lt;br /&gt;
&lt;br /&gt;
The [http://moodle.org/mod/forum/view.php?f=33 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.&lt;br /&gt;
&lt;br /&gt;
===How do I create a patch?===&lt;br /&gt;
&lt;br /&gt;
See [[How to create a patch]].&lt;br /&gt;
&lt;br /&gt;
===Is there any information on creating a new module or plugin?===&lt;br /&gt;
&lt;br /&gt;
See [[Modules]], [[Blocks]] and [[Authentication plugins]], or the [[Developer_documentation#Make_a_new_plugin|full list of plugin types]].&lt;br /&gt;
&lt;br /&gt;
===Is there any information on backup and restore?===&lt;br /&gt;
&lt;br /&gt;
See [[Backup]].&lt;br /&gt;
&lt;br /&gt;
==I can&#039;t use one of the available plug-in points to make my change. What alternative is there?==&lt;br /&gt;
&lt;br /&gt;
See [[Local customisation]].&lt;br /&gt;
&lt;br /&gt;
==Moodle&#039;s database==&lt;br /&gt;
&lt;br /&gt;
===Where can I see a schema for the structure of the Moodle database?===&lt;br /&gt;
&lt;br /&gt;
[[Database_schema_introduction]] gives a high level overview of the database schema.&lt;br /&gt;
&lt;br /&gt;
Because of Moodle&#039;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 -&amp;gt; Development -&amp;gt; XMLDB editor, and use the [Doc] links to see automatically generated documentation built form the comments in the install.xml files.&lt;br /&gt;
&lt;br /&gt;
==How to get/set information when writing new Moodle code==&lt;br /&gt;
&lt;br /&gt;
===How do I find out the currently-logged-on user?===&lt;br /&gt;
&lt;br /&gt;
The global object $USER, which contains the numeric $USER-&amp;gt;id among other things.&lt;br /&gt;
&lt;br /&gt;
===How do I find out the current course?===&lt;br /&gt;
The global object $COURSE, which contains the numeric $COURSE-&amp;gt;id&lt;br /&gt;
&lt;br /&gt;
===How do I insert/retrieve records in the database, without creating my own database connections?===&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;datalib&amp;quot; functions, such as insert_record() or get_record(). Since Moodle 1.7 these are found in lib/dmllib.php. Using these functions helps with database abstraction (e.g. running on either MySQL or Postgres) as well as maintaining a single database connection. Moodle uses ADODB for database abstraction.&lt;br /&gt;
&lt;br /&gt;
Look at [http://phpdocs.moodle.org/19/moodlecore/_lib---datalib.php.html  the documentation for datalib.php] for the list of functions and details of use.&lt;br /&gt;
&lt;br /&gt;
===How do I get/set configuration settings?===&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;main&amp;quot; config values use set_config($name, $value). The values are stored in the Moodle &amp;quot;config&amp;quot; database table, but these functions take care of cacheing on your behalf, so you should always use these rather than fetching the records directly.&lt;br /&gt;
&lt;br /&gt;
There is also a second table of config settings specifically for plugins (&amp;quot;config_plugin&amp;quot;). 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).&lt;br /&gt;
&lt;br /&gt;
On top of those global configuration values, individual blocks may also have configuration &amp;quot;object&amp;quot; associated with it (the data is serialized and stored in the &amp;quot;block_instance&amp;quot; table). Within blocks, this data is automatically loaded into the &amp;lt;tt&amp;gt;config&amp;lt;/tt&amp;gt; attribute of the block.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[[Contributed code FAQ]]&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/view.php?f=33 General developer forum]&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=55719 How does date / time in DB convert to real Date / Time?] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[Category: Developer]]&lt;br /&gt;
[[Category: FAQ]]&lt;br /&gt;
&lt;br /&gt;
[[es:FAQ Desarrollador]]&lt;br /&gt;
[[fr:FAQ de développement]]&lt;br /&gt;
[[pl:Developer FAQ]]&lt;/div&gt;</summary>
		<author><name>Trick</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Talk:Navigation_2.0&amp;diff=28005</id>
		<title>Talk:Navigation 2.0</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Talk:Navigation_2.0&amp;diff=28005"/>
		<updated>2009-05-26T20:30:22Z</updated>

		<summary type="html">&lt;p&gt;Trick: added tracker link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Navigation menu ==&lt;br /&gt;
&lt;br /&gt;
I&#039;m the lead developer of the [[YUI menu]]. IMHO, it&#039;s the closest contender as far as actual written code goes. That&#039;s why I wrote it in the first place, because nothing else would work for us.&lt;br /&gt;
&lt;br /&gt;
That said, the YUI menu as it is right now probably isn&#039;t good enough. Here are some caveats:&lt;br /&gt;
&lt;br /&gt;
* At the moment, the code isn&#039;t bad, but it could be better. Some of this is due to compensating for stuff that should really be elsewhere. I&#039;m currently working on a rewrite that will fix some of that.&lt;br /&gt;
* YUI&#039;s treeview has no form of non-javascript fallback and it uses HTML tables like there&#039;s no tomorrow. If we want accessibility (and I know I do), I&#039;ll have to throw out YUI all together and either find something else or write something myself.&lt;br /&gt;
&lt;br /&gt;
I&#039;m willing and able to do make these changes if it will help. See MDL-19300. -[[User:Alan Trick|Alan Trick]] 20:25, 26 May 2009 (UTC)&lt;/div&gt;</summary>
		<author><name>Trick</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Talk:Navigation_2.0&amp;diff=28004</id>
		<title>Talk:Navigation 2.0</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Talk:Navigation_2.0&amp;diff=28004"/>
		<updated>2009-05-26T20:25:35Z</updated>

		<summary type="html">&lt;p&gt;Trick: Navigation menu&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Navigation menu ==&lt;br /&gt;
&lt;br /&gt;
I&#039;m the lead developer of the [[YUI menu]]. IMHO, it&#039;s the closest contender as far as actual written code goes. That&#039;s why I wrote it in the first place, because nothing else would work for us.&lt;br /&gt;
&lt;br /&gt;
That said, the YUI menu as it is right now probably isn&#039;t good enough. Here are some caveats:&lt;br /&gt;
&lt;br /&gt;
* At the moment, the code isn&#039;t bad, but it could be better. Some of this is due to compensating for stuff that should really be elsewhere. I&#039;m currently working on a rewrite that will fix some of that.&lt;br /&gt;
* YUI&#039;s treeview has no form of non-javascript fallback and it uses HTML tables like there&#039;s no tomorrow. If we want accessibility (and I know I do), I&#039;ll have to throw out YUI all together and either find something else or write something myself.&lt;br /&gt;
&lt;br /&gt;
I&#039;m willing and able to do make these changes if it will help. -[[User:Alan Trick|Alan Trick]] 20:25, 26 May 2009 (UTC)&lt;/div&gt;</summary>
		<author><name>Trick</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Coding_style&amp;diff=11672</id>
		<title>Coding style</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Coding_style&amp;diff=11672"/>
		<updated>2009-05-19T17:30:04Z</updated>

		<summary type="html">&lt;p&gt;Trick: /* String concatenation */ removed non-standard MySQL code.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
===Scope===&lt;br /&gt;
&lt;br /&gt;
This document describes &#039;&#039;&#039;style&#039;&#039;&#039; guidelines for developers working on or with Moodle code.  It talks purely about the mechanics of code layout and the choices we have made for Moodle.&lt;br /&gt;
&lt;br /&gt;
For details about using the Moodle API to get things done, see the [[Coding|coding guidelines]].&lt;br /&gt;
&lt;br /&gt;
===Goals===&lt;br /&gt;
&lt;br /&gt;
Consistent coding style is important in any development project, and particularly when many developers are involved.  A standard style helps to ensure that the code is easier to read and understand, which helps overall quality.&lt;br /&gt;
&lt;br /&gt;
Abstract goals we strive for:&lt;br /&gt;
&lt;br /&gt;
* simplicity&lt;br /&gt;
* readability&lt;br /&gt;
* tool friendliness, such as use of method signatures, constants, and patterns that support IDE tools and auto-completion of method, class, and constant names.&lt;br /&gt;
&lt;br /&gt;
When considering the goals above, each situation requires an examination of the circumstances and balancing of various trade-offs.&lt;br /&gt;
&lt;br /&gt;
Note that much of the existing Moodle code may not follow all of these guidelines - we continue to upgrade this code when we see it.&lt;br /&gt;
&lt;br /&gt;
==File Formatting==&lt;br /&gt;
&lt;br /&gt;
===PHP tags===&lt;br /&gt;
&lt;br /&gt;
Always use &amp;quot;long&amp;quot; php tags.  However, to avoid whitespace problems, DO NOT include the closing tag at the very end of the file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
include(&#039;config.php&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Indentation===&lt;br /&gt;
&lt;br /&gt;
Use an indent of &#039;&#039;&#039;4 spaces&#039;&#039;&#039; with no tab characters. Editors should be configured to treat tabs as spaces in order to prevent injection of new tab characters into the source code.&lt;br /&gt;
&lt;br /&gt;
Don&#039;t indent the main script level:&lt;br /&gt;
&lt;br /&gt;
GOOD:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php // $Id$&lt;br /&gt;
$a = required_param(&#039;a&#039;, PARAM_INT);&lt;br /&gt;
if ($a &amp;gt; 10) {&lt;br /&gt;
    call_some_error($a);&lt;br /&gt;
} else {&lt;br /&gt;
    do_something_with($a);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
BAD:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php // $Id$&lt;br /&gt;
    $a = required_param(&#039;a&#039;, PARAM_INT);&lt;br /&gt;
    if ($a &amp;gt; 10) {&lt;br /&gt;
        call_some_error($a);&lt;br /&gt;
    } else {&lt;br /&gt;
        do_something_with($a);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Maximum Line Length===&lt;br /&gt;
&lt;br /&gt;
Aim for 80 characters if it is convenient.  &lt;br /&gt;
&lt;br /&gt;
However, you can go up to 120 characters if it helps overall readability.&lt;br /&gt;
&lt;br /&gt;
===Line Termination===&lt;br /&gt;
&lt;br /&gt;
Use standard &#039;&#039;&#039;Unix&#039;&#039;&#039; text format. Lines must end only with a linefeed (LF). Linefeeds are represented as ordinal 10, or hexadecimal 0x0A.&lt;br /&gt;
&lt;br /&gt;
Do not use carriage returns (CR) like &#039;&#039;Macintosh&#039;&#039; computers (0x0D).&lt;br /&gt;
&lt;br /&gt;
Do not use the carriage return/linefeed combination (CRLF) as &#039;&#039;Windows&#039;&#039; computers (0x0D, 0x0A).&lt;br /&gt;
&lt;br /&gt;
Lines should not contain trailing spaces. In order to facilitate this convention, most editors can be configured to strip trailing spaces, such as upon a save operation.&lt;br /&gt;
&lt;br /&gt;
==Naming Conventions==&lt;br /&gt;
&lt;br /&gt;
===Filenames===&lt;br /&gt;
&lt;br /&gt;
Filenames should :&lt;br /&gt;
* be whole english words&lt;br /&gt;
* be as short as possible&lt;br /&gt;
* use lowercase letters only &lt;br /&gt;
* end in .php, .html, .js, or .xml &lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
Class names should always be lowercase english words, separated by underscores:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
class some_custom_class {&lt;br /&gt;
    function class_method() {&lt;br /&gt;
        echo &amp;quot;foo&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Functions and Methods===&lt;br /&gt;
&lt;br /&gt;
Function names should be simple English lowercase words, and start with the name of the module to avoid conflicts between modules. Words should be separated by underscores. &lt;br /&gt;
&lt;br /&gt;
Verbosity is encouraged: function names should be as illustrative as is practical to enhance understanding.&lt;br /&gt;
&lt;br /&gt;
Note there is no space between the function name and the following (brackets). &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function forum_set_display_mode($mode = 0) {&lt;br /&gt;
    global $USER, $CFG;&lt;br /&gt;
         &lt;br /&gt;
    if ($mode) {&lt;br /&gt;
        $USER-&amp;gt;mode = $mode;&lt;br /&gt;
    } else if (empty($USER-&amp;gt;mode)) {&lt;br /&gt;
        $USER-&amp;gt;mode = $CFG-&amp;gt;forum_displaymode;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Function Parameters====&lt;br /&gt;
&lt;br /&gt;
Parameters are always simple lowercase English words (sometimes more than one, like $initialvalue), and should always have sensible defaults if possible. &lt;br /&gt;
&lt;br /&gt;
Use &amp;quot;null&amp;quot; as the default value instead of &amp;quot;false&amp;quot; for situations like this where a default value isn&#039;t needed.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
public function foo($required, $optional = null)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, if an optional parameter is boolean, and its logical default value should be true, or false, then using true or false is acceptable.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Variable names should always be easy-to-read, meaningful lower-case English words. If you really need more than one word then run them together, but keep them short as possible. Use &#039;&#039;&#039;plural&#039;&#039;&#039; names for arrays of objects.&lt;br /&gt;
&lt;br /&gt;
 GOOD: $quiz&lt;br /&gt;
 GOOD: $errorstring&lt;br /&gt;
 GOOD: $assignments (for an array of objects)&lt;br /&gt;
 GOOD: $i (but only in little loops)&lt;br /&gt;
&lt;br /&gt;
 BAD: $Quiz&lt;br /&gt;
 BAD: $camelCase&lt;br /&gt;
 BAD: $aReallyLongVariableNameWithoutAGoodReason&lt;br /&gt;
 BAD: $error_string&lt;br /&gt;
&lt;br /&gt;
Core global variables in Moodle are identified using uppercase variables (ie $CFG, $SESSION, $USER, $COURSE, $SITE, $PAGE, $DB and $THEME).  Don&#039;t create any more!&lt;br /&gt;
&lt;br /&gt;
===Constants===&lt;br /&gt;
&lt;br /&gt;
Constants should always be in upper case, and always start with the name of the module. They should have words separated by underscores. &lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
define(&amp;quot;FORUM_MODE_FLATOLDEST&amp;quot;, 1);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Booleans and the NULL Value===&lt;br /&gt;
&lt;br /&gt;
Use lower case for &#039;&#039;&#039;true&#039;&#039;&#039;, &#039;&#039;&#039;false&#039;&#039;&#039; and &#039;&#039;&#039;null&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Strings ==&lt;br /&gt;
&lt;br /&gt;
Since string performance is not an issue in current versions of PHP, the main criteria for strings is readability. &lt;br /&gt;
&lt;br /&gt;
===Single quotes===&lt;br /&gt;
&lt;br /&gt;
Always use single quotes when a string is literal, or contains a lot of double quotes (like HTML):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$a = &#039;Example String&#039;; &lt;br /&gt;
echo &#039;&amp;lt;span class=&amp;quot;&#039;.s($class).&#039;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&#039;; &lt;br /&gt;
$html = &#039;&amp;lt;a href=&amp;quot;http://something&amp;quot; title=&amp;quot;something&amp;quot;&amp;gt;Link&amp;lt;/a&amp;gt;&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Double quotes===&lt;br /&gt;
&lt;br /&gt;
These are a lot less useful in Moodle.  &lt;br /&gt;
&lt;br /&gt;
Use double quotes when you need to include plain variables or a lot of single quotes.  In Moodle 2.0 or later you won&#039;t need to be doing a lot of single quotes for SQL so that&#039;s not an issue.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
echo &amp;quot;&amp;lt;span&amp;gt;$string&amp;lt;/span&amp;gt;&amp;quot;; &lt;br /&gt;
$statement = &amp;quot;You aren&#039;t serious!&amp;quot;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Variable substitution===&lt;br /&gt;
&lt;br /&gt;
Variable substitution can use either of these forms:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$greeting = &amp;quot;Hello $name, welcome back!&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
$greeting = &amp;quot;Hello {$name}, welcome back!&amp;quot;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===String concatenation===&lt;br /&gt;
&lt;br /&gt;
Strings must be concatenated using the &amp;quot;.&amp;quot; operator.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$longstring = $several.$short.&#039;strings&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the lines are long, break the statement into multiple lines to improve readability.  In these cases, put the &amp;quot;dot&amp;quot; at the end of each line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$sql = &amp;quot;SELECT id, username FROM user &amp;quot;.&lt;br /&gt;
       &amp;quot;WHERE username = &#039;susan&#039; &amp;quot;.&lt;br /&gt;
       &amp;quot;ORDER BY id ASC &amp;quot;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays==&lt;br /&gt;
&lt;br /&gt;
===Numerically indexed arrays===&lt;br /&gt;
&lt;br /&gt;
Negative numbers are not permitted as indices.&lt;br /&gt;
&lt;br /&gt;
An indexed array may start with any non-negative number, however all base indices besides 0 are discouraged.&lt;br /&gt;
&lt;br /&gt;
When declaring indexed arrays with the array function, a trailing space must be added after each comma delimiter to improve readability:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$myarray = array(1, 2, 3, &#039;Stuff&#039;, &#039;Here&#039;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Multi-line indexed arrays are fine, but pad each successive line with spaces so that the beginning of each line is aligned:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$myarray = array(1, 2, 3, &#039;Stuff&#039;, &#039;Here&#039;,&lt;br /&gt;
                 $a, $b, $c,&lt;br /&gt;
                 56.44, $d, 500);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Associative arrays===&lt;br /&gt;
&lt;br /&gt;
Use multiple lines where possible, and pad the successive lines with spaces like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$myarray = array(&#039;firstkey&#039;  =&amp;gt; &#039;firstvalue&#039;,&lt;br /&gt;
                 &#039;secondkey&#039; =&amp;gt; &#039;secondvalue&#039;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Classes==&lt;br /&gt;
&lt;br /&gt;
=== Class declarations ===&lt;br /&gt;
&lt;br /&gt;
* Classes must be named according to Moodle&#039;s naming conventions.&lt;br /&gt;
* The brace should always be written on the line beside the class name.&lt;br /&gt;
* Every class must have a documentation block that conforms to the PHPDocumentor standard.&lt;br /&gt;
* All code in a class must be indented with 4 spaces.&lt;br /&gt;
* Only one class is permitted in each PHP file.&lt;br /&gt;
&lt;br /&gt;
* Placing additional code in class files is permitted but discouraged. In such files, two blank lines must separate the class from any additional PHP code in the class file.&lt;br /&gt;
&lt;br /&gt;
: An example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * Documentation Block Here&lt;br /&gt;
 */&lt;br /&gt;
class SampleClass {&lt;br /&gt;
    // all contents of class&lt;br /&gt;
    // must be indented 4 spaces&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Class member variables===&lt;br /&gt;
&lt;br /&gt;
Member variables must be named according to Moodle&#039;s variable naming conventions.&lt;br /&gt;
&lt;br /&gt;
Any variables declared in a class must be listed at the top of the class, above the declaration of any methods.&lt;br /&gt;
&lt;br /&gt;
The var construct is not permitted. Member variables always declare their visibility by using one of the &#039;&#039;&#039;private&#039;&#039;&#039;, &#039;&#039;&#039;protected&#039;&#039;&#039;, or &#039;&#039;&#039;public&#039;&#039;&#039; modifiers. Giving access to member variables directly by declaring them as public is permitted but discouraged in favor of accessor methods (set/get).&lt;br /&gt;
&lt;br /&gt;
==Functions and methods==&lt;br /&gt;
===Function and method declaration===&lt;br /&gt;
&lt;br /&gt;
Functions must be named according to the Moodle function naming conventions.&lt;br /&gt;
&lt;br /&gt;
Methods inside classes must always declare their visibility by using one of the private, protected, or public modifiers.&lt;br /&gt;
&lt;br /&gt;
As with classes, the brace should always be written on same line as the function name. &lt;br /&gt;
&lt;br /&gt;
Don&#039;t leave spaces between the function name and the opening parenthesis for the arguments.&lt;br /&gt;
&lt;br /&gt;
Functions in the global scope are strongly discouraged.&lt;br /&gt;
&lt;br /&gt;
The return value must not be enclosed in parentheses. This can hinder readability, in additional to breaking code if a method is later changed to return by reference. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * Documentation Block Here&lt;br /&gt;
 */&lt;br /&gt;
class sample_class {&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Documentation Block Here&lt;br /&gt;
     */&lt;br /&gt;
    public function sample_function () {&lt;br /&gt;
        // all contents of function&lt;br /&gt;
        // must be indented four spaces&lt;br /&gt;
        return true;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Function and method usage===&lt;br /&gt;
&lt;br /&gt;
Function arguments should be separated by a single trailing space after the comma delimiter. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
threeArguments(1, 2, 3);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Control statements==&lt;br /&gt;
&lt;br /&gt;
In general, use white space liberally between lines and so on, to add clarity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===If / else===&lt;br /&gt;
&lt;br /&gt;
Put a space before and after the control statement in brackets, and separate the operators by spaces within the brackets.  Use inner brackets to improve logical grouping if it helps. &lt;br /&gt;
&lt;br /&gt;
Indent with four spaces. &lt;br /&gt;
&lt;br /&gt;
Don&#039;t use elseif !&lt;br /&gt;
&lt;br /&gt;
Always use braces (even if the block is one line and PHP doesn&#039;t require it).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
if ($x == $y) {&lt;br /&gt;
    $a = $b;&lt;br /&gt;
} else if ($x == $z) {&lt;br /&gt;
    $a = $c;&lt;br /&gt;
} else {&lt;br /&gt;
    $a = $d;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Switch===&lt;br /&gt;
&lt;br /&gt;
Put a space before and after the control statement in brackets, and separate the operators by spaces within the brackets.  Use inner brackets to improve logical grouping if it helps. &lt;br /&gt;
&lt;br /&gt;
Always indent with four spaces.  Content under each case statement should be indented a further four spaces.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
switch ($something) {&lt;br /&gt;
    case 1:&lt;br /&gt;
        break;&lt;br /&gt;
&lt;br /&gt;
    case 2:&lt;br /&gt;
        break;&lt;br /&gt;
&lt;br /&gt;
    default:&lt;br /&gt;
        break;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Foreach===&lt;br /&gt;
&lt;br /&gt;
As above, uses spaces like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
foreach ($objects as $key =&amp;gt; $thing) {&lt;br /&gt;
    process($thing);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Require / include==&lt;br /&gt;
&lt;br /&gt;
Each file should start by including the main config.php file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
require_once(&#039;../config.php&#039;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Any other include/require should use an absolute path beginning with $CFG-&amp;gt;dirroot or  $CFG-&amp;gt;libdir, not relative includes, which [http://uk.php.net/manual/en/function.include.php sometimes behave strangely under PHP].&lt;br /&gt;
&lt;br /&gt;
Includes should generally only be done at the top of files or inside functions/methods that need them, it&#039;s insecure to use include/require in the middle of file in global scope.&lt;br /&gt;
&lt;br /&gt;
==Documentation and comments==&lt;br /&gt;
&lt;br /&gt;
Inline documentation explains the code flow and the purpose of functions and variables.  Use it whenever practical.&lt;br /&gt;
&lt;br /&gt;
Moodle uses the [http://www.phpdoc.org/ phpDoc format]. This allows our code documentation to be generated automatically (see [http://phpdocs.moodle.org phpdocs.moodle.org].&lt;br /&gt;
&lt;br /&gt;
===Inline comments===&lt;br /&gt;
&lt;br /&gt;
Inline comments should use the // style, laid out neatly so that it fits among the code and lines up with it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function forum_get_ratings_mean($postid, $scale, $ratings=NULL) {&lt;br /&gt;
    if (!$ratings) {&lt;br /&gt;
&lt;br /&gt;
        $ratings = array();     // Initialize the empty array&lt;br /&gt;
&lt;br /&gt;
        if ($rates = get_records(&amp;quot;forum_ratings&amp;quot;, &amp;quot;post&amp;quot;, $postid)) {&lt;br /&gt;
&lt;br /&gt;
            // Process each rating in turn&lt;br /&gt;
            foreach ($rates as $rate) {&lt;br /&gt;
                ...&lt;br /&gt;
            }&lt;br /&gt;
            // Do something else here &lt;br /&gt;
            something_else();&lt;br /&gt;
&lt;br /&gt;
     ... etc.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Files===&lt;br /&gt;
&lt;br /&gt;
All files that contain PHP code should contain a full GPL copyright statement at the top, plus a separate docblock right under it containing:&lt;br /&gt;
* A short one-line description of the file&lt;br /&gt;
* A longer description of the file&lt;br /&gt;
* A @package tag, describing the part of Moodle this part of&lt;br /&gt;
* A @copyright tag, with year and copyright holder (creator) of the original file&lt;br /&gt;
* A @license tag, which must contain &amp;quot;http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
// This file is part of Moodle - http://moodle.org/ &lt;br /&gt;
// &lt;br /&gt;
// Moodle is free software: you can redistribute it and/or modify&lt;br /&gt;
// it under the terms of the GNU General Public License as published by&lt;br /&gt;
// the Free Software Foundation, either version 3 of the License, or&lt;br /&gt;
// (at your option) any later version.&lt;br /&gt;
//&lt;br /&gt;
// Moodle is distributed in the hope that it will be useful,&lt;br /&gt;
// but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;br /&gt;
// GNU General Public License for more details.&lt;br /&gt;
// &lt;br /&gt;
// You should have received a copy of the GNU General Public License&lt;br /&gt;
// along with Moodle.  If not, see &amp;lt;http://www.gnu.org/licenses/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * This is a one-line short description of the file&lt;br /&gt;
 *&lt;br /&gt;
 * You can have a rather longer description of the file as well, &lt;br /&gt;
 * if you like, and it can span multiple lines.&lt;br /&gt;
 * &lt;br /&gt;
 * @package   moodlecore&lt;br /&gt;
 * @copyright 2008 Kim Bloggs&lt;br /&gt;
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Packages ====&lt;br /&gt;
&lt;br /&gt;
The package keyword MUST be included and tags a file as being part of a group of files.  Conventions are:&lt;br /&gt;
&lt;br /&gt;
# If it&#039;s part of Moodle core libraries, use &#039;&#039;&#039;moodlecore&#039;&#039;&#039;&lt;br /&gt;
# If it&#039;s part of a module, use the path of the module with hyphens:  eg &#039;&#039;&#039;mod-forum&#039;&#039;&#039; or &#039;&#039;&#039;grade-report-visual&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
All classes should have a docblock with the following minimum information:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * Short description for class&lt;br /&gt;
 *&lt;br /&gt;
 * Long description for class (if any)...&lt;br /&gt;
 *&lt;br /&gt;
 * @copyright 2008 Kim Bloggs&lt;br /&gt;
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Functions===&lt;br /&gt;
&lt;br /&gt;
All functions and methods should have a docblock like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * The description should be first, with asterisks laid out exactly&lt;br /&gt;
 * like this example. If you want to refer to a another function,&lt;br /&gt;
 * do it like this: {@link clean_param()}. Then, add descriptions&lt;br /&gt;
 * for each parameter and the return value as follows.&lt;br /&gt;
 *&lt;br /&gt;
 * @param int   $postid The PHP type is followed by the variable name&lt;br /&gt;
 * @param array $scale The PHP type is followed by the variable name&lt;br /&gt;
 * @param array $ratings The PHP type is followed by the variable name&lt;br /&gt;
 * @return mixed&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exceptions==&lt;br /&gt;
&lt;br /&gt;
Use exceptions to report errors, especially in library code.&lt;br /&gt;
&lt;br /&gt;
Throwing an exception has almost exactly the same effect as calling print_error, but it is more flexible. For example, the caller can choose to catch the exception and handle it in some way. It also makes it easier to write unit tests.&lt;br /&gt;
&lt;br /&gt;
Any exception that is not caught will trigger an appropriate call to print_error, to report the problem to the user.&lt;br /&gt;
&lt;br /&gt;
Do not abuse exceptions for normal code flow. Exceptions should only be used in erroneous situations.&lt;br /&gt;
&lt;br /&gt;
===Exception classes===&lt;br /&gt;
&lt;br /&gt;
We have a set of custom exception classes. The base class is moodle_exception. You will see that the arguments you pass to new moodle_exception(...) are very similar to the ones you would pass to print_error. There are more specific subclasses for particular types of error.&lt;br /&gt;
&lt;br /&gt;
To get the full list of exception types, search for the regular expression &#039;class +\w+_exception +extends&#039; or ask your IDE to list all the subclasses of moodle_exception.&lt;br /&gt;
&lt;br /&gt;
Where appropriate, you should create new subclasses of moodle_exception for use in your code.&lt;br /&gt;
&lt;br /&gt;
A few notable exception types:&lt;br /&gt;
; moodle_exception : base class for exceptions in Moodle. Use this when a more specific type is not appropriate.&lt;br /&gt;
; coding_exception : thrown when the problem seems to be caused by a developer&#039;s mistake. Often thrown by core code that interacts with plugins. If you throw an exception of this type, try to make the error message helpful to the plugin author, so they know how to fix their code.&lt;br /&gt;
; dml_exception (and subclasses) : thrown when a database query fails.&lt;br /&gt;
; file_exception : thrown by the File API.&lt;br /&gt;
&lt;br /&gt;
==Credits==&lt;br /&gt;
&lt;br /&gt;
This document was drawn from the following sources:&lt;br /&gt;
&lt;br /&gt;
# The original [https://docs.moodle.org/en/index.php?title=Development:Coding&amp;amp;oldid=53799 Coding guidelines] page&lt;br /&gt;
# The [http://framework.zend.com/manual/en/coding-standard.html Zend guidelines] and &lt;br /&gt;
# Feedback from all core Moodle developers&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
[[Coding]]&lt;/div&gt;</summary>
		<author><name>Trick</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=User:Alan_Trick&amp;diff=21317</id>
		<title>User:Alan Trick</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=User:Alan_Trick&amp;diff=21317"/>
		<updated>2009-04-28T23:51:22Z</updated>

		<summary type="html">&lt;p&gt;Trick: New page: I’m the lead developer for the online course system at Trinity Western University. I’m also a student in Computer Science and Linguistics.  == Moodle Projects ==  * YUI menu — Le...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I’m the lead developer for the online course system at Trinity Western University. I’m also a student in Computer Science and Linguistics.&lt;br /&gt;
&lt;br /&gt;
== Moodle Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[YUI menu]] — Lead developer&lt;/div&gt;</summary>
		<author><name>Trick</name></author>
	</entry>
</feed>