<?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=Conhorne</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=Conhorne"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/Special:Contributions/Conhorne"/>
	<updated>2026-10-06T02:38:10Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Setting_up_xhprof_on_Moodle&amp;diff=48053</id>
		<title>Setting up xhprof on Moodle</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Setting_up_xhprof_on_Moodle&amp;diff=48053"/>
		<updated>2015-06-17T15:06:27Z</updated>

		<summary type="html">&lt;p&gt;Conhorne: /* Configuring Moodle to use xhprof */  correcting spelling issues&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The following instructions are for setting up xhprof for Moodle under a Ubuntu/Debian environment. The process should be similar for other linux enviroments, but will need some tweaking if you wish to do this under windows. Please update this document if you find any major problems.&lt;br /&gt;
&lt;br /&gt;
==Installing xhprof with Linux==&lt;br /&gt;
&lt;br /&gt;
===Debian/Ubuntu package===&lt;br /&gt;
 apt-get install php5-xhprof&lt;br /&gt;
The current LTS Ubuntu package is version 0.9.4-1build1&lt;br /&gt;
&lt;br /&gt;
===Build manually===&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
mkdir ~/src/&lt;br /&gt;
cd ~/src/&lt;br /&gt;
wget http://pecl.php.net/get/xhprof-0.9.2.tgz&lt;br /&gt;
tar xvf xhprof-0.9.2.tgz&lt;br /&gt;
cd xhprof-0.9.2/extension/&lt;br /&gt;
phpize&lt;br /&gt;
./configure&lt;br /&gt;
make&lt;br /&gt;
sudo make install&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: The version downloaded via these instructions is not compatible with PHP 5.4 - instead you should download the latest version of the code from https://github.com/facebook/xhprof (before following the instructions from &#039;cd xhprof-0.9.2/extension/&#039; onwards). &lt;br /&gt;
&lt;br /&gt;
Note: It is available now, the 0.9.3 version from the pecl website. You can run wget http://pecl.php.net/get/xhprof-0.9.3.tgz, if you have PHP 5.4 version.&lt;br /&gt;
&lt;br /&gt;
Add the following to the apache version of you php.ini file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code ini&amp;gt;&lt;br /&gt;
[xhprof]&lt;br /&gt;
extension=xhprof.so&lt;br /&gt;
xhprof.output_dir=&amp;quot;/var/tmp/xhprof&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart Apache&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a file in your web root that makes a call to phpinfo(); and then view the result in your browser to make sure that xhprof is enabled in PHP. Checking the output of &#039;&#039;&#039;php -m&#039;&#039;&#039; would also work if you are sure that the command line version of PHP uses the same php.ini file as your web server.&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting===&lt;br /&gt;
If you see a &#039;&#039;&#039;failed to shell execute cmd=&amp;quot; dot -Tpng&#039;&#039;&#039; error when you follow the &#039;&#039;&#039;View Full Callgraph&#039;&#039;&#039; link you may need to install graphviz (&#039;&#039;&#039;sudo apt-get install graphviz&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
Into Windows environment this error can be caused by a path hardcoded into &amp;quot;\lib\xhprof\xhprof_lib\utils\callgraph_utils.php&amp;quot;, you must replace one parameter of the proc_open function which is a Linux path &amp;quot;/tmp&amp;quot; by a Windows one, like &amp;quot;c:/temp&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Installing xhprof with Windows==&lt;br /&gt;
&lt;br /&gt;
You will need to download PHP extensions compiled for your version of PHP. [http://dev.freshsite.pl/php-extensions/xhprof.html Here is one source...]&lt;br /&gt;
&lt;br /&gt;
Extract the contained dll file to the ext directory of your server. With XAMPP this is in xampp\php\ext&lt;br /&gt;
&lt;br /&gt;
Add a line to your php.ini file that matches dll filename you are using. This goes in the Dynamic Extensions section.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
extension=xhprof_0.10.3_php54_vc9.dll&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop and restart Apache through your server control interface. If it complains, you probably don&#039;t have the correct extension for your version of PHP, or the extension entry in your php.ini file doesn&#039;t match the dll file.&lt;br /&gt;
&lt;br /&gt;
To test that the extension is installed, log in to Moodle as an administrator and navigate to Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; PHP info. Search for information about the xhprof extension. It should be present and enabled.&lt;br /&gt;
&lt;br /&gt;
==Configuring Moodle to use xhprof==&lt;br /&gt;
[[Image:profilingOption.png|thumb|left|The profiling option is displayed when the php xhprof extension is installed]]&lt;br /&gt;
[[Image:profilingOutput.png|thumb|right|Tabular profiling output produced by xhprof]]&lt;br /&gt;
[[Image:callgraph.png|thumb|right|An example call graph showing slow parts of the profiled run]]&lt;br /&gt;
Once the xhprof php extension is correctly installed you will find a new &amp;quot;Profiling&amp;quot; option available under Settings &amp;gt; Site administration &amp;gt; Development&lt;br /&gt;
&lt;br /&gt;
When you load the profiling settings page you are confronted with several options. In order to get xhprof up and running with minimal fuss you merely need to check the &amp;quot;Enable profiling&amp;quot; box and set a path that you wish to be profiled. You can simply set this to a wildcard using the asterisk symbol (&#039;&#039;&#039;*&#039;&#039;&#039;) while you are testing profiling. Afterwards you can come back and set this to a more restrictive setting once you know profiling is working. Note the paths need to be specified relative to your Moodle directory and not the web root.&lt;br /&gt;
&lt;br /&gt;
After you have enabled profiling you should load some pages within the &amp;quot;Profile these&amp;quot; filter that you set in the step above. Once you have done these go to Settings &amp;gt; Site administration &amp;gt; Development &amp;gt; Profiling runs and you should see a list of the pages you visited. Clicking on one of these and then clicking on the &amp;quot;View profiling details&amp;quot; will take you to a profiling table full of helpful stats for tracking down slow pages and functions. You can get an even more interesting breakdown of this by then clicking on the &amp;quot;View Full Callgraph&amp;quot; link. This callgraph makes it easy to see where the slow parts of each particular run are and functions which individually may not take a long time to run but which are run thousands of times and thus resulting in a great deal of slowdown.&lt;br /&gt;
[[Image:profilingSettings.png|frame|center|Enabling profiling and setting it to run on all pages via a wildcard]]&lt;br /&gt;
[[Image:profilingRuns.png|frame|left|A profiling runs option can be seen after enabling profiling]]&lt;br /&gt;
&lt;br /&gt;
==Using XHProf==&lt;br /&gt;
&lt;br /&gt;
MDL-39443 shows the kind of thing that can be done using XHProf.&lt;br /&gt;
&lt;br /&gt;
[http://tjhunt.blogspot.co.uk/2013/05/performance-testing-moodle.html This blog post] talks about the process.&lt;br /&gt;
&lt;br /&gt;
Since Moodle 2.5.1 it&#039;s possible to export and import any profiling run. That enables some interesting uses like, comparisons along the time, between different systems and sharing or runs in other systems like the Tracker when optimization issues are being fixed.&lt;/div&gt;</summary>
		<author><name>Conhorne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Setting_up_xhprof_on_Moodle&amp;diff=48052</id>
		<title>Setting up xhprof on Moodle</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Setting_up_xhprof_on_Moodle&amp;diff=48052"/>
		<updated>2015-06-17T15:05:11Z</updated>

		<summary type="html">&lt;p&gt;Conhorne: /* Configuring Moodle to use xhprof */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The following instructions are for setting up xhprof for Moodle under a Ubuntu/Debian environment. The process should be similar for other linux enviroments, but will need some tweaking if you wish to do this under windows. Please update this document if you find any major problems.&lt;br /&gt;
&lt;br /&gt;
==Installing xhprof with Linux==&lt;br /&gt;
&lt;br /&gt;
===Debian/Ubuntu package===&lt;br /&gt;
 apt-get install php5-xhprof&lt;br /&gt;
The current LTS Ubuntu package is version 0.9.4-1build1&lt;br /&gt;
&lt;br /&gt;
===Build manually===&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
mkdir ~/src/&lt;br /&gt;
cd ~/src/&lt;br /&gt;
wget http://pecl.php.net/get/xhprof-0.9.2.tgz&lt;br /&gt;
tar xvf xhprof-0.9.2.tgz&lt;br /&gt;
cd xhprof-0.9.2/extension/&lt;br /&gt;
phpize&lt;br /&gt;
./configure&lt;br /&gt;
make&lt;br /&gt;
sudo make install&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: The version downloaded via these instructions is not compatible with PHP 5.4 - instead you should download the latest version of the code from https://github.com/facebook/xhprof (before following the instructions from &#039;cd xhprof-0.9.2/extension/&#039; onwards). &lt;br /&gt;
&lt;br /&gt;
Note: It is available now, the 0.9.3 version from the pecl website. You can run wget http://pecl.php.net/get/xhprof-0.9.3.tgz, if you have PHP 5.4 version.&lt;br /&gt;
&lt;br /&gt;
Add the following to the apache version of you php.ini file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code ini&amp;gt;&lt;br /&gt;
[xhprof]&lt;br /&gt;
extension=xhprof.so&lt;br /&gt;
xhprof.output_dir=&amp;quot;/var/tmp/xhprof&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart Apache&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a file in your web root that makes a call to phpinfo(); and then view the result in your browser to make sure that xhprof is enabled in PHP. Checking the output of &#039;&#039;&#039;php -m&#039;&#039;&#039; would also work if you are sure that the command line version of PHP uses the same php.ini file as your web server.&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting===&lt;br /&gt;
If you see a &#039;&#039;&#039;failed to shell execute cmd=&amp;quot; dot -Tpng&#039;&#039;&#039; error when you follow the &#039;&#039;&#039;View Full Callgraph&#039;&#039;&#039; link you may need to install graphviz (&#039;&#039;&#039;sudo apt-get install graphviz&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
Into Windows environment this error can be caused by a path hardcoded into &amp;quot;\lib\xhprof\xhprof_lib\utils\callgraph_utils.php&amp;quot;, you must replace one parameter of the proc_open function which is a Linux path &amp;quot;/tmp&amp;quot; by a Windows one, like &amp;quot;c:/temp&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Installing xhprof with Windows==&lt;br /&gt;
&lt;br /&gt;
You will need to download PHP extensions compiled for your version of PHP. [http://dev.freshsite.pl/php-extensions/xhprof.html Here is one source...]&lt;br /&gt;
&lt;br /&gt;
Extract the contained dll file to the ext directory of your server. With XAMPP this is in xampp\php\ext&lt;br /&gt;
&lt;br /&gt;
Add a line to your php.ini file that matches dll filename you are using. This goes in the Dynamic Extensions section.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
extension=xhprof_0.10.3_php54_vc9.dll&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop and restart Apache through your server control interface. If it complains, you probably don&#039;t have the correct extension for your version of PHP, or the extension entry in your php.ini file doesn&#039;t match the dll file.&lt;br /&gt;
&lt;br /&gt;
To test that the extension is installed, log in to Moodle as an administrator and navigate to Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; PHP info. Search for information about the xhprof extension. It should be present and enabled.&lt;br /&gt;
&lt;br /&gt;
==Configuring Moodle to use xhprof==&lt;br /&gt;
[[Image:profilingOption.png|thumb|left|The profiling option is displayed when the php xhprof extension is installed]]&lt;br /&gt;
[[Image:profilingOutput.png|thumb|right|Tabular profiling output produced by xhprof]]&lt;br /&gt;
[[Image:callgraph.png|thumb|right|An example call graph showing slow parts of the profiled run]]&lt;br /&gt;
Once the xhprof php extension is correctly installed you will find a new &amp;quot;Profiling&amp;quot; option available under Settings &amp;gt; Site administration &amp;gt; Development&lt;br /&gt;
&lt;br /&gt;
When you load the profiling settings page you are confronted with several options. In order to get xhprof up and running with minimal fuss you merely need to check the &amp;quot;Enable profiling&amp;quot; box and set a path that you wish to be profiled. You can simply set this to a wildcard using the asterisk symbol (&#039;&#039;&#039;*&#039;&#039;&#039;) while you are testing profiling. Afterwards you can come back and set this to a more restrictive setting once you know profiling is working. Note the paths need to be specified relative to your Moodle directory and not the web root.&lt;br /&gt;
&lt;br /&gt;
After you have enabled profiling you should load some pages within the &amp;quot;Profile these&amp;quot; filter that you set in the step above. Once you have done these go to Settings &amp;gt; Site administration &amp;gt; Development &amp;gt; Profiling runs and you should see a list of the pages you visited. Clicking on one of these and then clicking on the &amp;quot;View profiling details&amp;quot; will take you to a profiling table full of helpful stats for tracking down slow pages and functions. You can get an even more ineresting breakdown of this by then clicking on the &amp;quot;View Full Callgraph&amp;quot; link. This callgraph makes it easy to see where the slow parts of each particular run are and functions which individually may not take a long time to run but which are run thousands of times and thus resulting in a great deal of slowdown.&lt;br /&gt;
[[Image:profilingSettings.png|frame|center|Enabling profiling and setting it to run on all pages via a wildcard]]&lt;br /&gt;
[[Image:profilingRuns.png|frame|left|A profiling runs option can be seen after enabling profiling]]&lt;br /&gt;
&lt;br /&gt;
==Using XHProf==&lt;br /&gt;
&lt;br /&gt;
MDL-39443 shows the kind of thing that can be done using XHProf.&lt;br /&gt;
&lt;br /&gt;
[http://tjhunt.blogspot.co.uk/2013/05/performance-testing-moodle.html This blog post] talks about the process.&lt;br /&gt;
&lt;br /&gt;
Since Moodle 2.5.1 it&#039;s possible to export and import any profiling run. That enables some interesting uses like, comparisons along the time, between different systems and sharing or runs in other systems like the Tracker when optimization issues are being fixed.&lt;/div&gt;</summary>
		<author><name>Conhorne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=PHPUnit&amp;diff=44922</id>
		<title>PHPUnit</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=PHPUnit&amp;diff=44922"/>
		<updated>2014-05-22T18:34:57Z</updated>

		<summary type="html">&lt;p&gt;Conhorne: /* fixing wrong word */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.3}}&lt;br /&gt;
&lt;br /&gt;
=What is PHPUnit=&lt;br /&gt;
PHPUnit by Sebastian Bergmann is an advanced unit testing framework for PHP. It is installed as Composer dependency and is not part of Moodle installation. To run PHPUnit tests, you have to manually install it on your development computer or test server.&lt;br /&gt;
&lt;br /&gt;
Read the excellent guide at&lt;br /&gt;
* [http://phpunit.de/manual/current/en/index.html PHPUnit Manual]&lt;br /&gt;
&lt;br /&gt;
=Installation of PHPUnit via Composer=&lt;br /&gt;
&lt;br /&gt;
The installation procedure depends on your operating system.&lt;br /&gt;
* Install Composer dependency manager&lt;br /&gt;
&lt;br /&gt;
 cd /your/moodle/dirroot&lt;br /&gt;
 curl -s https://getcomposer.org/installer | php&lt;br /&gt;
&lt;br /&gt;
On Windows go to https://getcomposer.org/download/ and download the Composer-Setup.exe file&lt;br /&gt;
&lt;br /&gt;
* Execute Composer installer&lt;br /&gt;
&lt;br /&gt;
 cd /your/moodle/dirroot&lt;br /&gt;
 php composer.phar install --dev&lt;br /&gt;
&lt;br /&gt;
(If that gives you connection problems try...)&lt;br /&gt;
&lt;br /&gt;
 php composer.phar install --dev --prefer-source&lt;br /&gt;
&lt;br /&gt;
Troubleshooting:&lt;br /&gt;
* On Windows if you are behind a proxy you will need to setup an environment variable called HTTP_PROXY with a value detailing your HTTP Proxy address and port before composer will correctly download files.&lt;br /&gt;
* You may be prompted for github credentials when installing composer dependencies.&lt;br /&gt;
** This is used to generate an personal access token to avoid being rate limited by github.&lt;br /&gt;
** If you have Two Factor Authentication enabled on your github account, or do not wish to supply your own credentials you will need to generate a token manually:&lt;br /&gt;
*** Visit https://github.com/settings/applications and request personal access token&lt;br /&gt;
*** Copy this token and add it to your [https://gist.github.com/andrewnicols/c5377ed25a9df1006ce1 ~/.composer/config.json]&lt;br /&gt;
** ( See [https://github.com/composer/composer/issues/2280 composer issue #2280] for further details of this bug.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Detailed instructions:&lt;br /&gt;
* [http://getcomposer.org/doc/00-intro.md Composer documentation]&lt;br /&gt;
&lt;br /&gt;
Detailed instructions:&lt;br /&gt;
* [[PHPUnit installation in Windows]]&lt;br /&gt;
* [[PHPUnit installation in OS X]]&lt;br /&gt;
&lt;br /&gt;
== Uninstalling previous PEAR based version ==&lt;br /&gt;
&lt;br /&gt;
Before using composer, this page used to suggest to install phpunit via PEAR. If you did so, you may wish to uninstall that package now. This should work:&lt;br /&gt;
&lt;br /&gt;
   $ pear uninstall phpunit/DbUnit&lt;br /&gt;
   $ pear uninstall phpunit/PHPUnit&lt;br /&gt;
&lt;br /&gt;
=Initialisation of test environment=&lt;br /&gt;
&lt;br /&gt;
Our PHPUnit integration requires a dedicated database and dataroot.  First, add a new dataroot directory and prefix into your config.php, you can find examples in config-dist.php (scroll down to &#039;Section 9&#039;).&lt;br /&gt;
&lt;br /&gt;
 $CFG-&amp;gt;phpunit_prefix = &#039;phpu_&#039;;&lt;br /&gt;
 $CFG-&amp;gt;phpunit_dataroot = &#039;/home/example/phpu_moodledata&#039;;&lt;br /&gt;
&lt;br /&gt;
If your system does not have a direct connection to the Internet, you also need to specify your proxy in config.php - even though you normally specify it by using the admin settings user interface. (If you do not use a proxy, you can skip this step.) Check the settings on the relevant admin settings page, or from the mdl_config table in your database, if you are unsure of the correct values.&lt;br /&gt;
 &lt;br /&gt;
 // Normal proxy settings&lt;br /&gt;
 $CFG-&amp;gt;proxyhost = &#039;wwwcache.example.org&#039;;&lt;br /&gt;
 $CFG-&amp;gt;proxyport = 80;&lt;br /&gt;
 $CFG-&amp;gt;proxytype = &#039;HTTP&#039;;&lt;br /&gt;
 $CFG-&amp;gt;proxybypass = &#039;localhost, 127.0.0.1, .example.org&#039;;&lt;br /&gt;
 // Omit the next lines if your proxy doesn&#039;t need a username/password:&lt;br /&gt;
 $CFG-&amp;gt;proxyuser = &#039;systemusername&#039;;&lt;br /&gt;
 $CFG-&amp;gt;proxypassword = &#039;systempassword&#039;;&lt;br /&gt;
&lt;br /&gt;
Then you need to initialise the test environment using following command.&lt;br /&gt;
&lt;br /&gt;
 cd /home/example/moodle&lt;br /&gt;
 php admin/tool/phpunit/cli/init.php&lt;br /&gt;
&lt;br /&gt;
This command has to be repeated after any upgrade, plugin (un)installation or if you have added tests to a plugin you are developing:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; make sure that your php cli executable (or the one you want to use) is correctly on your path as the individual init scripts will call it repeatedly.&lt;br /&gt;
&lt;br /&gt;
=Test execution=&lt;br /&gt;
&lt;br /&gt;
To execute all test suites from main configuration file execute the &amp;lt;code&amp;gt;vendor/bin/phpunit&amp;lt;/code&amp;gt; script from your &amp;lt;code&amp;gt;$CFG-&amp;gt;dirroot&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
 cd /home/example/moodle&lt;br /&gt;
 vendor/bin/phpunit&lt;br /&gt;
&lt;br /&gt;
The rest of examples uses &amp;lt;code&amp;gt;phpunit&amp;lt;/code&amp;gt;, please substitute it with &amp;lt;code&amp;gt;vendor/bin/phpunit&amp;lt;/code&amp;gt; or create a shortcut in your dirroot.&lt;br /&gt;
&lt;br /&gt;
In IDEs, you may need to specify the path to the PHPUnit configuration file. Use the absolute path to &amp;lt;code&amp;gt;phpunit.xml&amp;lt;/code&amp;gt; from your &amp;lt;code&amp;gt;$CFG-&amp;gt;dirroot&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is an alternative script for running of tests via web interface: &amp;lt;code&amp;gt;admin/tool/phpunit/webrunner.php&amp;lt;/code&amp;gt;. Use this as the last resort only when you cannot use the command-line interface on your test server. It will most probably break due to permissions problems if you try to execute it both from command-line and from webrunner. This feature is not officially supported.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===How to run only some tests===&lt;br /&gt;
&lt;br /&gt;
==== Running a single test quickly ====&lt;br /&gt;
&lt;br /&gt;
The fastest way to run a single test is:&lt;br /&gt;
&lt;br /&gt;
 vendor/bin/phpunit my_test_class_name my/tests/filename.php&lt;br /&gt;
&lt;br /&gt;
This is faster than other methods because it avoids the need to search for the test file, but you should be careful because it may be possible to run tests this way which are not included in the normal run. If you use this method, do at least one full test run (or --group run, as below) to ensure the test can be found.&lt;br /&gt;
&lt;br /&gt;
==== Using the @group annotation ====&lt;br /&gt;
&lt;br /&gt;
If you add annotations like&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * Unit tests for {@link stack_cas_keyval}.&lt;br /&gt;
 * @group qtype_stack&lt;br /&gt;
 */&lt;br /&gt;
class stack_cas_keyval_exception_test extends basic_testcase {&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to all the classes in your plugin, then you can run just the tests for your plugin by doing&lt;br /&gt;
&lt;br /&gt;
 phpunit --group qtype_stack&lt;br /&gt;
&lt;br /&gt;
Therefore, it is suggested that you annotate all your tests with the Frankenstyle name of your plugin.&lt;br /&gt;
&lt;br /&gt;
==== Using multiple phpunit.xml files ====&lt;br /&gt;
&lt;br /&gt;
It&#039;s easy to create alternative phpunit.xml files defining which tests must be run together. For reference, take a look to the default /phpunit.xml available in your base directory once the testing environment has been initialised. After creating the custom file you will be able to run those tests with&lt;br /&gt;
&lt;br /&gt;
 vendor/bin/phpunit -c path/to/your/alternative/phpunit/file.xml&lt;br /&gt;
&lt;br /&gt;
Also, for commodity, you can use this command:&lt;br /&gt;
&lt;br /&gt;
 php admin/tool/phpunit/cli/util.php --buildcomponentconfigs&lt;br /&gt;
&lt;br /&gt;
It will, automatically, create one valid phpunit.xml file within each component (plugin or subsystem) and other important directories, so later you will be able to execute tests like&lt;br /&gt;
&lt;br /&gt;
 vendor/bin/phpunit -c mod/forum[/phpunit.xml]  // Note that it&#039;s not needed to specify the name of the file (if it is &#039;phpunit.xml&#039;).&lt;br /&gt;
 vendor/bin/phpunit -c question&lt;br /&gt;
 vendor/bin/phpunit -c question/type/calculated&lt;br /&gt;
 vendor/bin/phpunit -c backup&lt;br /&gt;
 vendor/bin/phpunit -c lib/dml&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
or, also&lt;br /&gt;
&lt;br /&gt;
 cd directory/with/phpunit.xml&lt;br /&gt;
 phpunit&lt;br /&gt;
&lt;br /&gt;
=External test resources=&lt;br /&gt;
{{Moodle 2.6}}&lt;br /&gt;
By default Moodle phpunit tests contact http://download.moodle.org server when testing curl related functionality. Optionally you may checkout a local copy of the test scripts and access it instead:&lt;br /&gt;
&lt;br /&gt;
# clone https://github.com/moodlehq/moodle-exttests to web directory&lt;br /&gt;
# add to your config.php or modify phpunit.xml file &amp;lt;code php&amp;gt;define(&#039;TEST_EXTERNAL_FILES_HTTP_URL&#039;, &#039;http://localhost/moodle-exttests&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Writing new tests=&lt;br /&gt;
* read [http://www.phpunit.de/manual/current/en/ official PHPUnit online documentation]&lt;br /&gt;
* see [[Writing PHPUnit tests]]&lt;br /&gt;
&lt;br /&gt;
=Conversion of existing SimpleTests=&lt;br /&gt;
* see [[SimpleTest conversion]]&lt;br /&gt;
&lt;br /&gt;
=PHPUnit support in IDEs=&lt;br /&gt;
&lt;br /&gt;
* [http://www.phpsrc.org/projects/pti-phpunit/wiki/ Eclipse PHP Tool Integration]&lt;br /&gt;
* [http://blog.jetbrains.com/webide/2009/12/phpunit-support/ PHPStorm IDE]&lt;br /&gt;
* [http://netbeans.org/kb/docs/php/phpunit.html Netbeans]&lt;br /&gt;
&lt;br /&gt;
=Common Unit Test Problems=&lt;br /&gt;
[[Common unit test problems]]&lt;br /&gt;
&lt;br /&gt;
=Performance=&lt;br /&gt;
&lt;br /&gt;
A typical run of full PHPUnit tests for Moodle 2.7 takes 10-20 minutes depending on the machine. If tests run slowly for you:&lt;br /&gt;
&lt;br /&gt;
* Ensure you are using a database and filesystem running on the same machine that is running the tests (not on a remote server).&lt;br /&gt;
* Apply developer-only performance settings to your database: [[Postgres Tuning For Developers]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Unit testing]]&lt;/div&gt;</summary>
		<author><name>Conhorne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Coding&amp;diff=44921</id>
		<title>Coding</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Coding&amp;diff=44921"/>
		<updated>2014-05-22T17:21:31Z</updated>

		<summary type="html">&lt;p&gt;Conhorne: /* Added clean theme info */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is the top-level page describing Moodle&#039;s coding guidelines.  It&#039;s the place to start if you want to know how to write code for Moodle.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Moodle architecture==&lt;br /&gt;
&lt;br /&gt;
Moodle tries to run on the widest possible range of platforms, for the widest possible number of people, while remaining easy to install, use, upgrade and integrate with other systems.&lt;br /&gt;
&lt;br /&gt;
For more about this, see [[Moodle architecture]].&lt;br /&gt;
&lt;br /&gt;
==Plugins== &lt;br /&gt;
&lt;br /&gt;
Moodle has a general philosophy of modularity.  There are nearly 30 different standard types of plugins and even more sub-plugin types, however all of these plugin types work the same way. Blocks and activities are the only small exceptions.&lt;br /&gt;
&lt;br /&gt;
See [[Plugins|Moodle plugins]] and [[Subplugins|Moodle sub-plugins]] for more information.&lt;br /&gt;
&lt;br /&gt;
==Coding style==&lt;br /&gt;
&lt;br /&gt;
Consistent coding style is important in any development project, and particularly so 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;
Writing your code in this way is an important step to having your code accepted by the Moodle community.&lt;br /&gt;
&lt;br /&gt;
Our [[Coding_style|Moodle coding style]] document explains this standard.&lt;br /&gt;
&lt;br /&gt;
==Security==&lt;br /&gt;
&lt;br /&gt;
Security is about protecting the interests and data of all our users.  Moodle may not be banking software, but it is still protecting a lot of sensitive and important data such as private discussions and grades from outside eyes (or student hackers!) as well as protecting our users from spammers and other internet predators.&lt;br /&gt;
&lt;br /&gt;
It&#039;s also a script running on people&#039;s servers, so Moodle needs to be a responsible Internet citizen and not introduce vulnerabilities that could allow crackers to gain unlawful access to the server it runs on. &lt;br /&gt;
&lt;br /&gt;
Any single script (in Moodle core or a third party module) can introduce a vulnerability to thousands of sites, so it&#039;s important that all developers strictly follow our [[Security|Moodle security guidelines]].&lt;br /&gt;
&lt;br /&gt;
==XHTML and CSS==&lt;br /&gt;
&lt;br /&gt;
It&#039;s important that Moodle produces strict, well-formed [http://en.wikipedia.org/wiki/HTML5 HTML 5] code (preferably backwards compatible with [[XHTML|XHTML 1.1]] if possible), compliant with all common accessibility guidelines (such as [http://www.w3.org/TR/WCAG20/ W3C WAG 2.0], [http://www.w3.org/TR/wai-aria-practices/ ARIA]).&lt;br /&gt;
&lt;br /&gt;
CSS should be used for layout. Moodle comes with several themes installed. Beginning with version 2.7, only the &#039;Clean&#039; theme comes in the base Moodle code. The &#039;standard&#039; theme, which should be a plain theme suitable to act as a building block for other themes. That should contain the minimal styling to make Moodle look OK and be functional. Then Moodle comes with several other default themes that look good and demonstrate various techniques for building themes.&lt;br /&gt;
&lt;br /&gt;
This helps consistency across browsers in a nicely-degrading way (especially those using non-visual or mobile browsers), as well as improving life for theme designers.&lt;br /&gt;
&lt;br /&gt;
==JavaScript==&lt;br /&gt;
&lt;br /&gt;
In general, everything in Moodle should work with JavaScript turned off in your browser. This is important for accessibility, and in line with the principles of unobtrusive JavaScript and progressive enhancement. &lt;br /&gt;
&lt;br /&gt;
Features that are not available without JavaScript must be compliant with all accessibility standards.&lt;br /&gt;
&lt;br /&gt;
See the [[JavaScript guidelines|Moodle JavaScript guidelines]] for more information.&lt;br /&gt;
&lt;br /&gt;
==Internationalisation==&lt;br /&gt;
&lt;br /&gt;
Moodle works in over 84 languages because we pay great attention to keeping the language strings and locale information separate from the code, in language packs.&lt;br /&gt;
&lt;br /&gt;
The default language for all code, comments and documentation, however, is English (AU).&lt;br /&gt;
&lt;br /&gt;
Full details:  [[Internationalisation|Moodle Internationalisation]]&lt;br /&gt;
&lt;br /&gt;
==Accessibility==&lt;br /&gt;
&lt;br /&gt;
Moodle should work well for the widest possible range of people.&lt;br /&gt;
&lt;br /&gt;
See [[Accessibility|Moodle Accessibility]] for more information.&lt;br /&gt;
&lt;br /&gt;
==Usability==&lt;br /&gt;
&lt;br /&gt;
See [[Interface_guidelines| Interface Guidelines]] (under construction)&lt;br /&gt;
&lt;br /&gt;
==Performance==&lt;br /&gt;
&lt;br /&gt;
The load any Moodle site can cope with will, of course, depend on the server and network hardware that it is running on. However there are some features (intended especially for developers) that are discouraged on production sites for performance reasons.&lt;br /&gt;
&lt;br /&gt;
The most important property is scalability, so a small increase in the number of users, courses, activities in a course, and so on, only causes a correspondingly small increase in server load.&lt;br /&gt;
&lt;br /&gt;
For more information and advice, see [[Performance and scalability|Performance and scalability]].&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
Moodle has a powerful database abstraction layer that we wrote ourselves, called [[XMLDB_Documentation|XMLDB]].  This lets the same Moodle code work on MySQL/MariaDB, PostgreSQL, MS SQL Server and Oracle. There are know issues when using Oracle, it is not fully supported and is not recommended for production sites.&lt;br /&gt;
&lt;br /&gt;
We have tools and API for [[DDL functions|defining and modifying tables]] as well as [[Data manipulation API|methods for getting data in and out]] of the database.&lt;br /&gt;
&lt;br /&gt;
Overview: [[Database|Moodle Database]] guidelines&lt;br /&gt;
&lt;br /&gt;
==Events==&lt;br /&gt;
&lt;br /&gt;
Moodle allows inter-module communication via &#039;&#039;&#039;events&#039;&#039;&#039;.  Modules can &#039;&#039;&#039;trigger&#039;&#039;&#039; specific events and other modules can choose to &#039;&#039;&#039;handle/observe&#039;&#039;&#039; those events.&lt;br /&gt;
&lt;br /&gt;
See:&lt;br /&gt;
* [[Events_API|Events API]] - Moodle 2.0 - 2.5&lt;br /&gt;
* [[Event_2|New Events API]] - Moodle 2.6 and later&lt;br /&gt;
&lt;br /&gt;
==Unit testing==&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Unit_testing Unit testing] is not simply a technique but a philosophy of software development.&lt;br /&gt;
&lt;br /&gt;
The idea is to create automatable tests for each bit of functionality that you are developing (at the same time you are developing it).  This not only helps everyone later test that the software works, but helps the development itself, because it forces you to work in a modular way with very clearly defined structures and goals.&lt;br /&gt;
&lt;br /&gt;
Moodle uses a framework called [https://github.com/sebastianbergmann/phpunit/ PHPUnit] that makes writing unit tests fairly simple.&lt;br /&gt;
&lt;br /&gt;
See [[PHPUnit]] for more information.&lt;br /&gt;
&lt;br /&gt;
==Acceptance testing==&lt;br /&gt;
&lt;br /&gt;
PHPUnit covers mostly the internal implementation of functions and classes, the user interaction testing can be automated using the [http://behat.org Behat framework].&lt;br /&gt;
&lt;br /&gt;
See [[Acceptance testing]] for more information.&lt;br /&gt;
&lt;br /&gt;
== Other standards ==&lt;br /&gt;
&lt;br /&gt;
Please note that Moodle coding style and design is pretty unique, it is not compatible with [http://pear.php.net/manual/en/standards.php PEAR coding standards] or any other common PHP standards.&lt;/div&gt;</summary>
		<author><name>Conhorne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Moodle_architecture&amp;diff=44920</id>
		<title>Moodle architecture</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Moodle_architecture&amp;diff=44920"/>
		<updated>2014-05-22T17:06:35Z</updated>

		<summary type="html">&lt;p&gt;Conhorne: /* corrected an incorrect working */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The aim of this document is to quickly give an overview of how the Moodle works at a technical level. Hopefully this will be helpful to Administrators and Developers. However, to actually do Moodle development you will have to study the code in much more detail than is provided here. See the [[Developer_documentation|developer documentation]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What is Moodle?==&lt;br /&gt;
&lt;br /&gt;
Moodle is a Learning Management System, Course Management System, or Virtual Learning Environment, depending on which term you prefer. Its goal is to give teachers and students the tools they need to teach and learn. Moodle comes from a background of [[:en:Pedagogy|Social Constructionist pedagogy]], however, it can be used to support any style of teaching and learning.&lt;br /&gt;
&lt;br /&gt;
There are other types of software systems that are important for educational institutions, for example ePortfolios, Student Information Systems and Content repositories. Generally, Moodle does not try to re-invent these areas of functionality. Instead, tries to be the best LMS possible, and then interoperate gracefully with other systems that provide the other areas of functionality. It is, however, perfectly possible to use Moodle as a stand-alone system, without integrating it with anything else.&lt;br /&gt;
&lt;br /&gt;
Moodle is a web application written in PHP. Moodle is open source. Copyright is owned by individual contributors, not assigned to a single entity, although the company Moodle Pty Ltd in Perth Australia, owned by Moodle&#039;s founder Martin Dougiamas, manages the project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Overview of a Moodle installation==&lt;br /&gt;
&lt;br /&gt;
A Moodle installation comprises the Moodle code executing in a PHP-capable web server; a database managed by MySQL, PostgreSQL, Microsoft SQL Server, MariaDB, or Oracle; and a file store for uploaded and generated files (the moodledata folder).&lt;br /&gt;
&lt;br /&gt;
All three parts can run on a single server; or they can be separated with many load-balanced web-servers, a database cluster, and a file-server; or anywhere between those extremes.&lt;br /&gt;
&lt;br /&gt;
Moodle is designed to be simple to install on any server that meets these basic requirements. Moodle self-installs once the code has been copied to the web server and a blank database created (see [[:en:Installing Moodle]]). Similarly, Moodle can always self-upgrade from one version to the next (see [[:en:Upgrading]]).&lt;br /&gt;
&lt;br /&gt;
==Moodle as a modular system==&lt;br /&gt;
&lt;br /&gt;
Like many successful open source systems, Moodle is structured as an application core, surrounded by numerous plugins to provide specific functionality. Moodle is designed to be highly extensible and customizable without modifying the core libraries, as doing so would create problems when upgrading Moodle to a newer version. So when customizing or extending your own Moodle install, always do so through the plugin architecture. &lt;br /&gt;
&lt;br /&gt;
Plugins in Moodle are of specific types. That is, an authentication plugin and an activity module will communicate with Moodle core using different APIs, tailored to the type of functionality the plugin provides. Functionality common to all plugins (installation, upgrade, permissions, configuration, ...) are, however, handled consistently across all plugin types.&lt;br /&gt;
&lt;br /&gt;
The standard Moodle distribution includes Moodle core and a number of plugins of each type, so that a new Moodle installation can immediately be used to start teaching and learning. After installation a Moodle site can be adapted for a particular purpose by changing the default configuration option, and by installing add-ons or removing standard plugins. Most add-ons that have been shared publicly are listed in the [http://moodle.org/plugins/index.php Moodle Plugins Directory].&lt;br /&gt;
&lt;br /&gt;
Physically, a Moodle plugin is just a folder of PHP scripts (and CSS, JavaScript, etc. if necessary). Moodle core communicates with the plugin by looking for particular entry points, often defined in the file &amp;lt;tt&amp;gt;lib.php&amp;lt;/tt&amp;gt; within the plugin.&lt;br /&gt;
&lt;br /&gt;
==An overview of Moodle core==&lt;br /&gt;
&lt;br /&gt;
Moodle core provides all the infrastructure necessary to build a Learning Management System. It implements the key concepts that all the different plugins will need to work with. These include:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Courses and activities:&#039;&#039;&#039;&lt;br /&gt;
A Moodle course is a sequence of activities and resources grouped into sections. Courses themselves are organized into a hierarchical set of categories within a Moodle site.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Users:&#039;&#039;&#039;&lt;br /&gt;
In moodle, users are anyone who uses the moodle system. In order to participate in course users need to be enrolled into course with a given role, such as:&lt;br /&gt;
&lt;br /&gt;
*Students&lt;br /&gt;
*Teachers&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Course enrolment&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
*Enrolment gives user the possibility to participate in course as a student or teacher.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;User functionality in moodle:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*User roles in moodle: Roles assigned to users give them a set of capabilities in given context. For example: Teacher, Student and Forum moderator are examples of roles.&lt;br /&gt;
*User&#039;s capabilities in moodle: A capability is a description of some particular Moodle feature. Capabilities are associated with roles. For example, mod/forum:replypost is a capability.&lt;br /&gt;
*Context: A context is a &amp;quot;space&amp;quot; in the Moodle, such as courses, activity modules, blocks etc.&lt;br /&gt;
*Permissions: A permission is some value that is assigned for a capability for a particular role. For example, allow or prevent.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Added facilities provided by moodle:  Added facilities provided by moodle:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*Creation and editing of user profiles: In moodle, the moment an user creates his account, a profile is created for that user. The user needs to fill in his initial details for completing his profile. The user generally always have the permission to edit his own profile anytime on moodle.&lt;br /&gt;
*Groups and cohorts: Cohorts, or site-wide groups, enable all members of a cohort to be enrolled in a course in one action, either manually or synchronised automatically.&lt;br /&gt;
*Enrolments and access control: Users are generally enrolled into some courses and according to their permission settings and the groups to which they belong, they have limited access on moodle.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;A bit more about moodle:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*Activity and course completion: The activity completion system allows activities such as Quizzes, SCORM modules, etc. to be marked complete when specified conditions are met.&lt;br /&gt;
*Navigation, settings and configuration: The Navigation block provide easy access to view various sections of the Moodle site and includes:&lt;br /&gt;
**My home - a personalised home page displaying links to the courses a user is associated with and activity information (such as unread forum posts and upcoming assignments)&lt;br /&gt;
**Site pages - links to site pages and resources from the front page of Moodle&lt;br /&gt;
**My profile - quick links allowing a user to view their profile, forums posts, blogs and messages as well as manage their private files&lt;br /&gt;
**My courses - lists (by course shortname) and links to courses the user is associated with. Click the course&#039;s shortname to view the front page of the course or use the arrows to navigate quickly to a specific section, resource or activity.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;JavaScript library:&#039;&#039;&#039;&lt;br /&gt;
*Moodle has adopted the Yahoo User Interface library. There is also a nice system for loading the additional JavaScript files required by each page.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Upgrading moodle:&#039;&#039;&#039;&lt;br /&gt;
Moodle can be upgraded in four simple steps:&lt;br /&gt;
&lt;br /&gt;
#Make sure that your server can run the latest Moodle version&lt;br /&gt;
#You should always be prepared to &amp;quot;roll back&amp;quot; if there&#039;s an issue with your data or some custom code you&#039;ve added. So before committing, create a test install and always make backups.&lt;br /&gt;
#At this stage you can replace the Moodle code on your server with the version you downloaded and check for the plugins.&lt;br /&gt;
#Perform the upgrade by triggering the upgrade from the admin page.&lt;br /&gt;
&lt;br /&gt;
(More information about upgrading can be found here : https://docs.moodle.org/27/en/Upgrade_overview)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logs and statistics in moodle:&#039;&#039;&#039;&lt;br /&gt;
*Statistics in moodle: The statistics graphs and tables show how many hits there have been on various parts of your site during various time frames. They do not show how many distinct users there have been. They are processed daily at a time you specify. You must enable statistics before you will see anything.&lt;br /&gt;
*Log in moodle: Logs in Moodle are activity reports. Logs are available at site level and course level.&lt;br /&gt;
&lt;br /&gt;
==The most important plugin types==&lt;br /&gt;
&lt;br /&gt;
===Activities and resources===&lt;br /&gt;
&lt;br /&gt;
Activities and resources are the most basic individual components that make up a course and are the main tools for teaching and learning. Some examples of resources are: pages, links and IMS content packages. Examples of activities include: forums, wikis, quizzes, and assignments.&lt;br /&gt;
&lt;br /&gt;
Activities are by far the largest type of plugin in terms of amount of code. A forum or wiki system could be a software project in its own right. Both activities and resources are installed in the &amp;lt;tt&amp;gt;mod&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
===Blocks===&lt;br /&gt;
&lt;br /&gt;
Blocks are small bits of interface functionality that can be added to (normally the sides of) pages. Many blocks provide additional views of data stored and modified elsewhere. Blocks live in the &amp;lt;tt&amp;gt;blocks&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
===Themes===&lt;br /&gt;
&lt;br /&gt;
The overall visual style of a Moodle site, a particular course, or all courses in a category, can be changed by selecting a different theme at these different levels. Themes are the standard way of making aesthetic changes to your Moodle application, decoupling presentation from content and functionality.&lt;br /&gt;
&lt;br /&gt;
Themes live in the &amp;lt;tt&amp;gt;theme&amp;lt;/tt&amp;gt; folder, and published themes are listed in the [http://moodle.org/mod/data/view.php?id=6552 Themes database].&lt;br /&gt;
&lt;br /&gt;
===Language packs===&lt;br /&gt;
&lt;br /&gt;
Moodle is internationalised. That is, you can get language packs for many different languages. Language packs are normally downloaded and installed via the Moodle administration screens, but they can also be downloaded manually from [http://download.moodle.org/langpack/ Moodle.org: language packs].&lt;br /&gt;
&lt;br /&gt;
Administrators can also manually change any of the standard user interface strings if the terms used in the installed language pack are not appropriate.&lt;br /&gt;
&lt;br /&gt;
===Course formats===&lt;br /&gt;
&lt;br /&gt;
control how the structure of the course, a sequence of activities grouped into sections, is presented to the users. Course formats live in the &amp;lt;tt&amp;gt;course/format&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
===Authentication plugins===&lt;br /&gt;
&lt;br /&gt;
control how users log in. Moodle can manage usernames and passwords itself, or use those stored in LDAP or another database. Alternatively, Moodle can use a number of single-sign-on schemes. Authentication plugins live in the &amp;lt;tt&amp;gt;auth&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
===Enrolment plugins===&lt;br /&gt;
&lt;br /&gt;
control which users are enrolled in which courses. Again this can be by synchronising with another system, perhaps a student information system, or it can be tracked internally by Moodle. Enrolment plugins live in the &amp;lt;tt&amp;gt;enrol&amp;lt;/tt&amp;gt; folder. (Moodle was created by an Australian, so enrol is the correct spelling ;-).)&lt;br /&gt;
&lt;br /&gt;
===Repository plugins===&lt;br /&gt;
&lt;br /&gt;
Ways for users to get content (files) into Moodle, either by uploading from their hard drive, or by getting the file from another location on the Internet, perhaps Drop Box, Google Docs, or Flickr. Repository plugins live in the &amp;lt;tt&amp;gt;repository&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
===Others===&lt;br /&gt;
&lt;br /&gt;
There are [[Developer_documentation#Make_a_new_plugin|many more types of plugins]] (more than 30 at the last count). These include text filters, question types, gradebook reports, admin reports, course reports, plagiarism detection services and web service protocols.&lt;br /&gt;
&lt;br /&gt;
For a definitive, up-to-date list, look at the value returned by the &amp;lt;tt&amp;gt;get_plugin_types()&amp;lt;/tt&amp;gt; function, which is defined in &amp;lt;tt&amp;gt;lib/moodlelib.php&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How Moodle code is organised==&lt;br /&gt;
&lt;br /&gt;
Moodle mostly follows a [http://martinfowler.com/eaaCatalog/transactionScript.html transaction script] approach. That is, suppose you are looking at a Forum. The URL will be &amp;lt;tt&amp;gt;.../mod/forum/view.php?id=1234&amp;lt;/tt&amp;gt;. and &amp;lt;tt&amp;gt;mod/forum/view.php&amp;lt;/tt&amp;gt; the PHP script that generates that page. One could argue that transaction script is not an appropriate pattern for an application as complex as Moodle. However, it is a very natural architecture for a PHP application, and Moodle is an aggregate of many different plugins, rather than a single complex application.&lt;br /&gt;
&lt;br /&gt;
Behind that basic transaction script approach, a lot of the core functionality has been refactored out into libraries (mostly in the &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt; folder). This provides elements of a [http://martinfowler.com/eaaCatalog/domainModel.html domain model]. The Moodle project started before PHP could handle object-oriented code, however, so don&#039;t expect an object-oriented domain model except in some of the more recent parts of the Moodle code.&lt;br /&gt;
&lt;br /&gt;
There are two layers used to separate presentation from the business logic. The outer layer is the theme (see above) which controls the more visual aspects of the Moodle interface. Then there are renderer classes which generate the HTML to be output from the data supplied by the transaction scripts and the domain model. Unfortunately, neither PHP, nor the Moodle architecture, enforces a clear separation of the UI layer. It is possible for sloppy developers to make a mess, and this has happened in the past. The code in the standard Moodle distribution is gradually being cleaned up.&lt;br /&gt;
&lt;br /&gt;
==The Moodle database==&lt;br /&gt;
&lt;br /&gt;
The Moodle database comprises many tables (more than 250) because the whole database is an aggregate of the core tables and the tables belonging to each plugin. Fortunately, this large structure is understandable, because the tables for one particular plugin typically only link to each other and a few core tables. See [[Database_schema_introduction|Database schema introduction]] for more information.&lt;br /&gt;
&lt;br /&gt;
The Moodle database structure is defined in &amp;lt;tt&amp;gt;install.xml&amp;lt;/tt&amp;gt; files inside the &amp;lt;tt&amp;gt;db&amp;lt;/tt&amp;gt; folder in each plugin. For example &amp;lt;tt&amp;gt;mod/forum/db/install.xml&amp;lt;/tt&amp;gt; contains the database definition for the forum module. &amp;lt;tt&amp;gt;lib/db/install.xml&amp;lt;/tt&amp;gt; defines the tables used by Moodle core. The &amp;lt;tt&amp;gt;install.xml&amp;lt;/tt&amp;gt; files contain comments that should explain the purpose of each table and column. These comments can be turned into human-readable documentation by going to Site administration -&amp;gt; Development -&amp;gt; XMLDB editor in your Moodle installation, and clicking on the [Doc] link.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[:en:Administrator documentation]]&lt;br /&gt;
* [[Developer_documentation|Developer documentation]]&lt;br /&gt;
* [[Database_schema_introduction|Database schema introduction]]&lt;br /&gt;
* [http://moodle.org/mod/data/view.php?id=6009 Modules and plugins] and [http://moodle.org/mod/data/view.php?id=6552 themes] databases&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=64465 Forum thread with a vigorous argument about whether an architecture document is a good idea, which eventually lead to this page being rewritten]&lt;br /&gt;
* [http://www.aosabook.org/en/moodle.html The chapter of The Architecture of Open Source Applications about Moodle]&lt;br /&gt;
&lt;br /&gt;
[[Category:Coding guidelines]]&lt;/div&gt;</summary>
		<author><name>Conhorne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Moodle_architecture&amp;diff=44919</id>
		<title>Moodle architecture</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Moodle_architecture&amp;diff=44919"/>
		<updated>2014-05-22T17:03:13Z</updated>

		<summary type="html">&lt;p&gt;Conhorne: /* Correcting spelling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The aim of this document is to quickly give an overview of how the Moodle works at a technical level. Hopefully this will be helpful to Administrators and Developers. However, to actually do Moodle development you will have to study the code in much more detail than is provided here. See the [[Developer_documentation|developer documentation]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What is Moodle?==&lt;br /&gt;
&lt;br /&gt;
Moodle is a Learning Management System, Course Management System, or Virtual Learning Environment, depending on which term you prefer. Its goal is to give teachers and students the tools they need to teach and learn. Moodle comes from a background of [[:en:Pedagogy|Social Constructionist pedagogy]], however, it can be used to support any style of teaching and learning.&lt;br /&gt;
&lt;br /&gt;
There are other types of software systems that are important for educational institutions, for example ePortfolios, Student Information Systems and Content repositories. Generally, Moodle does not try to re-invent these areas of functionality. Instead, tries to be the best LMS possible, and then interoperate gracefully with other systems that provide the other areas of functionality. It is, however, perfectly possible to use Moodle as a stand-alone system, without integrating it with anything else.&lt;br /&gt;
&lt;br /&gt;
Moodle is a web application written in PHP. Moodle is open source. Copyright is owned by individual contributors, not assigned to a single entity, although the company Moodle Pty Ltd in Perth Australia, owned by Moodle&#039;s founder Martin Dougiamas, manages the project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Overview of a Moodle installation==&lt;br /&gt;
&lt;br /&gt;
A Moodle installation comprises the Moodle code executing in a PHP-capable web server; a database managed by MySQL, PostgreSQL, Microsoft SQL Server, MariaDB, or Oracle; and a file store for uploaded and generated files (the moodledata folder).&lt;br /&gt;
&lt;br /&gt;
All three parts can run on a single server; or they can be separated with many load-balanced web-servers, a database cluster, and a file-server; or anywhere between those extremes.&lt;br /&gt;
&lt;br /&gt;
Moodle is designed to be simple to install on any server that meets these basic requirements. Moodle self-installs once the code has been copied to the web server and a blank database created (see [[:en:Installing Moodle]]). Similarly, Moodle can always self-upgrade from one version to the next (see [[:en:Upgrading]]).&lt;br /&gt;
&lt;br /&gt;
==Moodle as a modular system==&lt;br /&gt;
&lt;br /&gt;
Like many successful open source systems, Moodle is structured as an application core, surrounded by numerous plugins to provide specific functionality. Moodle is designed to be highly extensible and customizable without modifying the core libraries, as doing so would create problems when upgrading Moodle to a newer version. So when customizing or extending your own Moodle install, always do so through the plugin architecture. &lt;br /&gt;
&lt;br /&gt;
Plugins in Moodle are of specific types. That is, an authentication plugin and an activity module will communicate with Moodle core using different APIs, tailored to the type of functionality the plugin provides. Functionality common to all plugins (installation, upgrade, permissions, configuration, ...) are, however, handled consistently across all plugin types.&lt;br /&gt;
&lt;br /&gt;
The standard Moodle distribution includes Moodle core and a number of plugins of each type, so that a new Moodle installation can immediately be used to start teaching and learning. After installation a Moodle site can be adapted for a particular purpose by changing the default configuration option, and by installing add-ons or removing standard plugins. Most add-ons that have been shared publicly are listed in the [http://moodle.org/plugins/index.php Moodle Plugins Directory].&lt;br /&gt;
&lt;br /&gt;
Physically, a Moodle plugin is just a folder of PHP scripts (and CSS, JavaScript, etc. if necessary). Moodle core communicates with the plugin by looking for particular entry points, often defined in the file &amp;lt;tt&amp;gt;lib.php&amp;lt;/tt&amp;gt; within the plugin.&lt;br /&gt;
&lt;br /&gt;
==An overview of Moodle core==&lt;br /&gt;
&lt;br /&gt;
Moodle core provides all the infrastructure necessary to build a Learning Management System. It implements the key concepts that all the different plugins will need to work with. These include:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Courses and activities:&#039;&#039;&#039;&lt;br /&gt;
A Moodle course is a sequence of activities and resources grouped into sections. Courses themselves are organized into a hierarchical set of categories within a Moodle site.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Users:&#039;&#039;&#039;&lt;br /&gt;
In moodle, users are anyone who uses the moodle system. In order to participate in course users need to be enrolled into course with a given role, such as:&lt;br /&gt;
&lt;br /&gt;
*Students&lt;br /&gt;
*Teachers&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Course enrolment&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
*Enrolment gives user the possibility to participate in course as a student or teacher.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;User functionality in moodle:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*User roles in moodle: Roles assigned to users give them a set of capabilities in given context. For example: Teacher, Student and Forum moderator are examples of roles.&lt;br /&gt;
*User&#039;s capabilities in moodle: A capability is a description of some particular Moodle feature. Capabilities are associated with roles. For example, mod/forum:replypost is a capability.&lt;br /&gt;
*Context: A context is a &amp;quot;space&amp;quot; in the Moodle, such as courses, activity modules, blocks etc.&lt;br /&gt;
*Permissions: A permission is some value that is assigned for a capability for a particular role. For example, allow or prevent.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Added facilities provided by moodle:  Added facilities provided by moodle:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*Creation and editing of user profiles: In moodle, the moment an user creates his account, a profile is created for that user. The user needs to fill in his initial details for completing his profile. The user generally always have the permission to edit his own profile anytime on moodle.&lt;br /&gt;
*Groups and cohorts: Cohorts, or site-wide groups, enable all members of a cohort to be enrolled in a course in one action, either manually or synchronised automatically.&lt;br /&gt;
*Enrolments and access control: Users are generally enrolled into some courses and according to their permission settings and the groups to which they belong, they have limited access on moodle.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;A bit more about moodle:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*Activity and course completion: The activity completion system allows activities such as Quizzes, SCORM modules, etc. to be marked complete when specified conditions are met.&lt;br /&gt;
*Navigation, settings and configuration: The Navigation block provide easy access to view various sections of the Moodle site and includes:&lt;br /&gt;
**My home - a personalised home page displaying links to the courses a user is associated with and activity information (such as unread forum posts and upcoming assignments)&lt;br /&gt;
**Site pages - links to site pages and resources from the front page of Moodle&lt;br /&gt;
**My profile - quick links allowing a user to view their profile, forums posts, blogs and messages as well as manage their private files&lt;br /&gt;
**My courses - lists (by course shortname) and links to courses the user is associated with. Click the course&#039;s shortname to view the front page of the course or use the arrows to navigate quickly to a specific section, resource or activity.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;JavaScript library:&#039;&#039;&#039;&lt;br /&gt;
*Moodle has adopted the Yahoo User Interface library. There is also a nice system for loading the additional JavaScript files required by each page.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Upgrading moodle:&#039;&#039;&#039;&lt;br /&gt;
Moodle can be upgraded in four simple steps:&lt;br /&gt;
&lt;br /&gt;
#Make sure that your server can run the latest Moodle version&lt;br /&gt;
#You should always be prepared to &amp;quot;roll back&amp;quot; if there&#039;s an issue with your data or some custom code you&#039;ve added. So before committing, create a test install and always make backups.&lt;br /&gt;
#At this stage you can replace the Moodle code on your server with the version you downloaded and check for the plugins.&lt;br /&gt;
#Perform the upgrade by triggering the upgrade from the admin page.&lt;br /&gt;
&lt;br /&gt;
(More information about upgrading can be found here : https://docs.moodle.org/27/en/Upgrade_overview)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logs and statistics in moodle:&#039;&#039;&#039;&lt;br /&gt;
*Statistics in moodle: The statistics graphs and tables show how many hits there have been on various parts of your site during various time frames. They do not show how many distinct users there have been. They are processed daily at a time you specify. You must enable statistics before you will see anything.&lt;br /&gt;
*Log in moodle: Logs in Moodle are activity reports. Logs are available at site level and course level.&lt;br /&gt;
&lt;br /&gt;
==The most important plugin types==&lt;br /&gt;
&lt;br /&gt;
===Activities and resources===&lt;br /&gt;
&lt;br /&gt;
Activities and resources are the most basic individual components that make up a course and are the main tools for teaching and learning. Some examples of resources are: pages, links and IMS content packages. Examples of activities include: forums, wikis, quizzes, and assignments.&lt;br /&gt;
&lt;br /&gt;
Activities are by far the largest type of plugin in terms of amount of code. A forum or wiki system could be a software project in its own right. Both activities and resources are installed in the &amp;lt;tt&amp;gt;mod&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
===Blocks===&lt;br /&gt;
&lt;br /&gt;
Blocks are small bits of interface functionality that can be added to (normally the sides of) pages. Many blocks provide additional views of data stored and modified elsewhere. Blocks live in the &amp;lt;tt&amp;gt;blocks&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
===Themes===&lt;br /&gt;
&lt;br /&gt;
The overall visual style of a Moodle site, a particular course, or all courses in a category, can be changed by selecting a different theme at these different levels. Themes are the standard way of making aesthetic changes to your Moodle application, decoupling presentation from content and functionality.&lt;br /&gt;
&lt;br /&gt;
Themes live in the &amp;lt;tt&amp;gt;theme&amp;lt;/tt&amp;gt; folder, and published themes are listed in the [http://moodle.org/mod/data/view.php?id=6552 Themes database].&lt;br /&gt;
&lt;br /&gt;
===Language packs===&lt;br /&gt;
&lt;br /&gt;
Moodle is internationalised. That is, you can get language packs for many different languages. Language packs are normally downloaded and installed via the Moodle administration screens, but they can also be downloaded manually from [http://download.moodle.org/langpack/ Moodle.org: language packs].&lt;br /&gt;
&lt;br /&gt;
Administrators can also manually change any of the standard user interface strings if the terms used in the installed language pack are not appropriate.&lt;br /&gt;
&lt;br /&gt;
===Course formats===&lt;br /&gt;
&lt;br /&gt;
control how the structure of the course, a sequence of activities grouped into sections, is presented to the users. Course formats live in the &amp;lt;tt&amp;gt;course/format&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
===Authentication plugins===&lt;br /&gt;
&lt;br /&gt;
control how users log in. Moodle can manage usernames and passwords itself, or use those stored in LDAP or another database. Alternatively, Moodle can use a number of single-sign-on schemes. Authentication plugins live in the &amp;lt;tt&amp;gt;auth&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
===Enrolment plugins===&lt;br /&gt;
&lt;br /&gt;
control which users are enrolled in which courses. Again this can be by synchronising with another system, perhaps a student information system, or it can be tracked internally by Moodle. Enrolment plugins live in the &amp;lt;tt&amp;gt;enrol&amp;lt;/tt&amp;gt; folder. (Moodle was created by an Australian, so enrol is the correct spelling ;-).)&lt;br /&gt;
&lt;br /&gt;
===Repository plugins===&lt;br /&gt;
&lt;br /&gt;
Ways for users to get content (files) into Moodle, either by uploading from their hard drive, or by getting the file from another location on the Internet, perhaps Drop Box, Google Docs, or Flickr. Repository plugins live in the &amp;lt;tt&amp;gt;repository&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
===Others===&lt;br /&gt;
&lt;br /&gt;
There are [[Developer_documentation#Make_a_new_plugin|many more types of plugins]] (more than 30 at the last count). These include text filters, question types, gradebook reports, admin reports, course reports, plagiarism detection services and web service protocols.&lt;br /&gt;
&lt;br /&gt;
For a definitive, up-to-date list, look at the value returned by the &amp;lt;tt&amp;gt;get_plugin_types()&amp;lt;/tt&amp;gt; function, which is defined in &amp;lt;tt&amp;gt;lib/moodlelib.php&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How Moodle code is organised==&lt;br /&gt;
&lt;br /&gt;
Moodle mostly follows a [http://martinfowler.com/eaaCatalog/transactionScript.html transaction script] approach. That is, suppose you are looking at a Forum. The URL will be &amp;lt;tt&amp;gt;.../mod/forum/view.php?id=1234&amp;lt;/tt&amp;gt;. and &amp;lt;tt&amp;gt;mod/forum/view.php&amp;lt;/tt&amp;gt; the PHP script that generates that page. One could argue that transaction script is not an appropriate pattern for an application as complex as Moodle. However, it is a very natural architecture for a PHP application, and Moodle is an aggregate of many different plugins, rather than a single complex application.&lt;br /&gt;
&lt;br /&gt;
Behind that basic transaction script approach, a lot of the core functionality has be refactored out into libraries (mostly in the &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt; folder). This provides elements of a [http://martinfowler.com/eaaCatalog/domainModel.html domain model]. The Moodle project started before PHP could handle object-oriented code, however, so don&#039;t expect an object-oriented domain model except in some of the more recent parts of the Moodle code.&lt;br /&gt;
&lt;br /&gt;
There are two layers used to separate presentation from the business logic. The outer layer is the theme (see above) which controls the more visual aspects of the Moodle interface. Then there are renderer classes which generate the HTML to be output from the data supplied by the transaction scripts and the domain model. Unfortunately, neither PHP, nor the Moodle architecture, enforces a clear separation of the UI layer. It is possible for sloppy developers to make a mess, and this has happened in the past. The code in the standard Moodle distribution is gradually being cleaned up.&lt;br /&gt;
&lt;br /&gt;
==The Moodle database==&lt;br /&gt;
&lt;br /&gt;
The Moodle database comprises many tables (more than 250) because the whole database is an aggregate of the core tables and the tables belonging to each plugin. Fortunately, this large structure is understandable, because the tables for one particular plugin typically only link to each other and a few core tables. See [[Database_schema_introduction|Database schema introduction]] for more information.&lt;br /&gt;
&lt;br /&gt;
The Moodle database structure is defined in &amp;lt;tt&amp;gt;install.xml&amp;lt;/tt&amp;gt; files inside the &amp;lt;tt&amp;gt;db&amp;lt;/tt&amp;gt; folder in each plugin. For example &amp;lt;tt&amp;gt;mod/forum/db/install.xml&amp;lt;/tt&amp;gt; contains the database definition for the forum module. &amp;lt;tt&amp;gt;lib/db/install.xml&amp;lt;/tt&amp;gt; defines the tables used by Moodle core. The &amp;lt;tt&amp;gt;install.xml&amp;lt;/tt&amp;gt; files contain comments that should explain the purpose of each table and column. These comments can be turned into human-readable documentation by going to Site administration -&amp;gt; Development -&amp;gt; XMLDB editor in your Moodle installation, and clicking on the [Doc] link.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[:en:Administrator documentation]]&lt;br /&gt;
* [[Developer_documentation|Developer documentation]]&lt;br /&gt;
* [[Database_schema_introduction|Database schema introduction]]&lt;br /&gt;
* [http://moodle.org/mod/data/view.php?id=6009 Modules and plugins] and [http://moodle.org/mod/data/view.php?id=6552 themes] databases&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=64465 Forum thread with a vigorous argument about whether an architecture document is a good idea, which eventually lead to this page being rewritten]&lt;br /&gt;
* [http://www.aosabook.org/en/moodle.html The chapter of The Architecture of Open Source Applications about Moodle]&lt;br /&gt;
&lt;br /&gt;
[[Category:Coding guidelines]]&lt;/div&gt;</summary>
		<author><name>Conhorne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Moodle_architecture&amp;diff=44918</id>
		<title>Moodle architecture</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Moodle_architecture&amp;diff=44918"/>
		<updated>2014-05-22T16:36:14Z</updated>

		<summary type="html">&lt;p&gt;Conhorne: /* Added MariaDB */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The aim of this document is to quickly give an overview of how the Moodle works at a technical level. Hopefully this will be helpful to Administrators and Developers. However, to actually do Moodle development you will have to study the code in much more detail than is provided here. See the [[Developer_documentation|developer documentation]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What is Moodle?==&lt;br /&gt;
&lt;br /&gt;
Moodle is a Learning Management System, Course Management System, or Virtual Learning Environment, depending on which term you prefer. Its goal is to give teachers and students the tools they need to teach and learn. Moodle comes from a background of [[:en:Pedagogy|Social Constructionist pedagogy]], however, it can be used to support any style of teaching and learning.&lt;br /&gt;
&lt;br /&gt;
There are other types of software systems that are important for educational institutions, for example ePortfolios, Student Information Systems and Content repositories. Generally, Moodle does not try to re-invent these areas of functionality. Instead, tries to be the best LMS possible, and then interoperate gracefully with other systems that provide the other areas of functionality. It is, however, perfectly possible to use Moodle as a stand-alone system, without integrating it with anything else.&lt;br /&gt;
&lt;br /&gt;
Moodle is a web application written in PHP. Moodle is open source. Copyright is owned by individual contributors, not assigned to a single entity, although the company Moodle Pty Ltd in Perth Australia, owned by Moodle&#039;s founder Martin Dougiamas, manages the project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Overview of a Moodle installation==&lt;br /&gt;
&lt;br /&gt;
A Moodle installation comprises the Moodle code executing in a PHP-capable web server; a database managed by MySQL, PostgreSQL, Microsoft SQL Server, MariaDB, or Oracle; and a file store for uploaded and generated files (the moodledata folder).&lt;br /&gt;
&lt;br /&gt;
All three parts can run on a single server; or they can be separated with many load-balanced web-servers, a database cluster, and a file-server; or anywhere between those extremes.&lt;br /&gt;
&lt;br /&gt;
Moodle is designed to be simple to install on any server that meets these basic requirements. Moodle self-installs once the code has been copied to the web server and a blank database created (see [[:en:Installing Moodle]]). Similarly, Moodle can always self-upgrade from one version to the next (see [[:en:Upgrading]]).&lt;br /&gt;
&lt;br /&gt;
==Moodle as a modular system==&lt;br /&gt;
&lt;br /&gt;
Like many successful open source systems, Moodle is structured as an application core, surrounded by numerous plugins to provide specific functionality. Moodle is designed to be highly extensible and customizable without modifying the core libraries, as doing so would create problems when upgrading Moodle to a newer version. So when customizing or extending your own Moodle install, always do so through the plugin architecture. &lt;br /&gt;
&lt;br /&gt;
Plugins in Moodle are of specific types. That is, an authentication plugin and an activity module will communicate with Moodle core using different APIs, tailored to the type of functionality the plugin provides. Functionality common to all plugins (installation, upgrade, permissions, configuration, ...) are, however, handled consistently across all plugin types.&lt;br /&gt;
&lt;br /&gt;
The standard Moodle distribution includes Moodle core and a number of plugins of each type, so that a new Moodle installation can immediately be used to start teaching and learning. After installation a Moodle site can be adapted for a particular purpose by changing the default configuration option, and by installing add-ons or removing standard plugins. Most add-ons that have been shared publicly are listed in the [http://moodle.org/plugins/index.php Moodle Plugins Directory].&lt;br /&gt;
&lt;br /&gt;
Physically, a Moodle plugin is just a folder of PHP scripts (and CSS, JavaScript, etc. if necessary). Moodle core communicates with the plugin by looking for particular entry points, often defined in the file &amp;lt;tt&amp;gt;lib.php&amp;lt;/tt&amp;gt; within the plugin.&lt;br /&gt;
&lt;br /&gt;
==An overview of Moodle core==&lt;br /&gt;
&lt;br /&gt;
Moodle core provides all the infrastructure necessary to build a Learning Management System. It implements the key concepts that all the different plugins will need to work with. These include:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Courses and activities:&#039;&#039;&#039;&lt;br /&gt;
A Moodle course is a sequence of activities and resources grouped into sections. Courses themselves are organized into a hierarchical set of categories within a Moodle site.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Users:&#039;&#039;&#039;&lt;br /&gt;
In moodle, users are anyone who uses the moodle system. In order to participate in course users need to be enrolled into course with a given role, such as:&lt;br /&gt;
&lt;br /&gt;
*Students&lt;br /&gt;
*Teachers&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Course enrolment&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
*Enrolment gives user the possibility to participate in course as a student or teacher.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;User functionality in moodle:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*User roles in moodle: Roles assigned to users give them a set of capabilities in given context. For example: Teacher, Student and Forum moderator are examples of roles.&lt;br /&gt;
*User&#039;s capabilities in moodle: A capability is a description of some particular Moodle feature. Capabilities are associated with roles. For example, mod/forum:replypost is a capability.&lt;br /&gt;
*Context: A context is a &amp;quot;space&amp;quot; in the Moodle, such as courses, activity modules, blocks etc.&lt;br /&gt;
*Permissions: A permission is some value that is assigned for a capability for a particular role. For example, allow or prevent.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Added facilities provided by moodle:  Added facilities provided by moodle:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*Creation and editing of user profiles: In moodle, the moment an user creates his account, a profile is created for that user. The user needs to fill in his initial details for completing his profile. The user generally always have the permission to edit his own profile anytime on moodle.&lt;br /&gt;
*Groups and cohorts: Cohorts, or site-wide groups, enable all members of a cohort to be enrolled in a course in one action, either manually or synchronised automatically.&lt;br /&gt;
*Enrolments and access control: Users are generally enrolled into some courses and according to their permission settings and the groups to which they belong, they have limited access on moodle.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;A bit more about moodle:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*Activity and course completion: The activity completion system allows activities such as Quizzes, SCORM modules, etc. to be marked complete when specified conditions are met.&lt;br /&gt;
*Navigation, settings and configuration: The Navigation block provide easy access to view various sections of the Moodle site and includes:&lt;br /&gt;
**My home - a personalised home page displaying links to the courses a user is associated with and activity information (such as unread forum posts and upcoming assignments)&lt;br /&gt;
**Site pages - links to site pages and resources from the front page of Moodle&lt;br /&gt;
**My profile - quick links allowing a user to view their profile, forums posts, blogs and messages as well as manage their private files&lt;br /&gt;
**My courses - lists (by course shortname) and links to courses the user is associated with. Click the course&#039;s shortname to view the front page of the course or use the arrows to navigate quickly to a specific section, resource or activity.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;JavaScript library:&#039;&#039;&#039;&lt;br /&gt;
*Moodle has adopted the Yahoo User Interface library. There is also a nice system for loading the additional JavaScript files required by each page.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Upgradation of moodle:&#039;&#039;&#039;&lt;br /&gt;
Moodle can be upgraded in four simple steps:&lt;br /&gt;
&lt;br /&gt;
#Make sure that your server can run the lates Moodle version&lt;br /&gt;
#You should always be prepared to &amp;quot;roll back&amp;quot; if there&#039;s an issue with your data or some custom code you&#039;ve added. So before comitting, create a test install and always make backups.&lt;br /&gt;
#At this stage you can replace the Moodle code on your server with the version you downloaded and check for the plugins.&lt;br /&gt;
#Perform the upgrade by triggering the upgrade from the admin page.&lt;br /&gt;
&lt;br /&gt;
(More information about upgradation can be found here : https://docs.moodle.org/26/en/Upgrade_overview)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logs and statistics in moodle:&#039;&#039;&#039;&lt;br /&gt;
*Statistics in moodle: The statistics graphs and tables show how many hits there have been on various parts of your site during various time frames. They do not show how many distinct users there have been. They are processed daily at a time you specify. You must enable statistics before you will see anything.&lt;br /&gt;
*Log in moodle: Logs in Moodle are activity reports. Logs are available at site level and course level.&lt;br /&gt;
&lt;br /&gt;
==The most important plugin types==&lt;br /&gt;
&lt;br /&gt;
===Activities and resources===&lt;br /&gt;
&lt;br /&gt;
Activities and resources are the most basic individual components that make up a course and are the main tools for teaching and learning. Some examples of resources are: pages, links and IMS content packages. Examples of activities include: forums, wikis, quizzes, and assignments.&lt;br /&gt;
&lt;br /&gt;
Activities are by far the largest type of plugin in terms of amount of code. A forum or wiki system could be a software project in its own right. Both activities and resources are installed in the &amp;lt;tt&amp;gt;mod&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
===Blocks===&lt;br /&gt;
&lt;br /&gt;
Blocks are small bits of interface functionality that can be added to (normally the sides of) pages. Many blocks provide additional views of data stored and modified elsewhere. Blocks live in the &amp;lt;tt&amp;gt;blocks&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
===Themes===&lt;br /&gt;
&lt;br /&gt;
The overall visual style of a Moodle site, a particular course, or all courses in a category, can be changed by selecting a different theme at these different levels. Themes are the standard way of making aesthetic changes to your Moodle application, decoupling presentation from content and functionality.&lt;br /&gt;
&lt;br /&gt;
Themes live in the &amp;lt;tt&amp;gt;theme&amp;lt;/tt&amp;gt; folder, and published themes are listed in the [http://moodle.org/mod/data/view.php?id=6552 Themes database].&lt;br /&gt;
&lt;br /&gt;
===Language packs===&lt;br /&gt;
&lt;br /&gt;
Moodle is internationalised. That is, you can get language packs for many different languages. Language packs are normally downloaded and installed via the Moodle administration screens, but they can also be downloaded manually from [http://download.moodle.org/langpack/ Moodle.org: language packs].&lt;br /&gt;
&lt;br /&gt;
Administrators can also manually change any of the standard user interface strings if the terms used in the installed language pack are not appropriate.&lt;br /&gt;
&lt;br /&gt;
===Course formats===&lt;br /&gt;
&lt;br /&gt;
control how the structure of the course, a sequence of activities grouped into sections, is presented to the users. Course formats live in the &amp;lt;tt&amp;gt;course/format&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
===Authentication plugins===&lt;br /&gt;
&lt;br /&gt;
control how users log in. Moodle can manage usernames and passwords itself, or use those stored in LDAP or another database. Alternatively, Moodle can use a number of single-sign-on schemes. Authentication plugins live in the &amp;lt;tt&amp;gt;auth&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
===Enrolment plugins===&lt;br /&gt;
&lt;br /&gt;
control which users are enrolled in which courses. Again this can be by synchronising with another system, perhaps a student information system, or it can be tracked internally by Moodle. Enrolment plugins live in the &amp;lt;tt&amp;gt;enrol&amp;lt;/tt&amp;gt; folder. (Moodle was created by an Australian, so enrol is the correct spelling ;-).)&lt;br /&gt;
&lt;br /&gt;
===Repository plugins===&lt;br /&gt;
&lt;br /&gt;
Ways for users to get content (files) into Moodle, either by uploading from their hard drive, or by getting the file from another location on the Internet, perhaps Drop Box, Google Docs, or Flickr. Repository plugins live in the &amp;lt;tt&amp;gt;repository&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
===Others===&lt;br /&gt;
&lt;br /&gt;
There are [[Developer_documentation#Make_a_new_plugin|many more types of plugins]] (more than 30 at the last count). These include text filters, question types, gradebook reports, admin reports, course reports, plagiarism detection services and web service protocols.&lt;br /&gt;
&lt;br /&gt;
For a definitive, up-to-date list, look at the value returned by the &amp;lt;tt&amp;gt;get_plugin_types()&amp;lt;/tt&amp;gt; function, which is defined in &amp;lt;tt&amp;gt;lib/moodlelib.php&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How Moodle code is organised==&lt;br /&gt;
&lt;br /&gt;
Moodle mostly follows a [http://martinfowler.com/eaaCatalog/transactionScript.html transaction script] approach. That is, suppose you are looking at a Forum. The URL will be &amp;lt;tt&amp;gt;.../mod/forum/view.php?id=1234&amp;lt;/tt&amp;gt;. and &amp;lt;tt&amp;gt;mod/forum/view.php&amp;lt;/tt&amp;gt; the PHP script that generates that page. One could argue that transaction script is not an appropriate pattern for an application as complex as Moodle. However, it is a very natural architecture for a PHP application, and Moodle is an aggregate of many different plugins, rather than a single complex application.&lt;br /&gt;
&lt;br /&gt;
Behind that basic transaction script approach, a lot of the core functionality has be refactored out into libraries (mostly in the &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt; folder). This provides elements of a [http://martinfowler.com/eaaCatalog/domainModel.html domain model]. The Moodle project started before PHP could handle object-oriented code, however, so don&#039;t expect an object-oriented domain model except in some of the more recent parts of the Moodle code.&lt;br /&gt;
&lt;br /&gt;
There are two layers used to separate presentation from the business logic. The outer layer is the theme (see above) which controls the more visual aspects of the Moodle interface. Then there are renderer classes which generate the HTML to be output from the data supplied by the transaction scripts and the domain model. Unfortunately, neither PHP, nor the Moodle architecture, enforces a clear separation of the UI layer. It is possible for sloppy developers to make a mess, and this has happened in the past. The code in the standard Moodle distribution is gradually being cleaned up.&lt;br /&gt;
&lt;br /&gt;
==The Moodle database==&lt;br /&gt;
&lt;br /&gt;
The Moodle database comprises many tables (more than 250) because the whole database is an aggregate of the core tables and the tables belonging to each plugin. Fortunately, this large structure is understandable, because the tables for one particular plugin typically only link to each other and a few core tables. See [[Database_schema_introduction|Database schema introduction]] for more information.&lt;br /&gt;
&lt;br /&gt;
The Moodle database structure is defined in &amp;lt;tt&amp;gt;install.xml&amp;lt;/tt&amp;gt; files inside the &amp;lt;tt&amp;gt;db&amp;lt;/tt&amp;gt; folder in each plugin. For example &amp;lt;tt&amp;gt;mod/forum/db/install.xml&amp;lt;/tt&amp;gt; contains the database definition for the forum module. &amp;lt;tt&amp;gt;lib/db/install.xml&amp;lt;/tt&amp;gt; defines the tables used by Moodle core. The &amp;lt;tt&amp;gt;install.xml&amp;lt;/tt&amp;gt; files contain comments that should explain the purpose of each table and column. These comments can be turned into human-readable documentation by going to Site administration -&amp;gt; Development -&amp;gt; XMLDB editor in your Moodle installation, and clicking on the [Doc] link.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[:en:Administrator documentation]]&lt;br /&gt;
* [[Developer_documentation|Developer documentation]]&lt;br /&gt;
* [[Database_schema_introduction|Database schema introduction]]&lt;br /&gt;
* [http://moodle.org/mod/data/view.php?id=6009 Modules and plugins] and [http://moodle.org/mod/data/view.php?id=6552 themes] databases&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=64465 Forum thread with a vigorous argument about whether an architecture document is a good idea, which eventually lead to this page being rewritten]&lt;br /&gt;
* [http://www.aosabook.org/en/moodle.html The chapter of The Architecture of Open Source Applications about Moodle]&lt;br /&gt;
&lt;br /&gt;
[[Category:Coding guidelines]]&lt;/div&gt;</summary>
		<author><name>Conhorne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Admin_reports&amp;diff=42008</id>
		<title>Admin reports</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Admin_reports&amp;diff=42008"/>
		<updated>2013-08-13T17:26:10Z</updated>

		<summary type="html">&lt;p&gt;Conhorne: /* What to do in index.php */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.1}}&lt;br /&gt;
This document applies to Moodle versions before 2.2.  See [[Reports]] for the new unified reports in Moodle 2.2 and later.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
An admin report is a folder of code under admin/report. For example, you might make a folder in there called &#039;&#039;&#039;myreport&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In there, the only code you are required to have is an index.php file. This will normally display a simple HTML form for controlling the report, and, the code for displaying the report. You will probably also want a language file, which would be called lang/en_utf8/report_myreport.php following the example above. &lt;br /&gt;
&lt;br /&gt;
In addition, you can add any other PHP code you like, and then link people to it from index.php.&lt;br /&gt;
&lt;br /&gt;
So, the minimal code layout is:&lt;br /&gt;
&lt;br /&gt;
 admin/&lt;br /&gt;
   ...&lt;br /&gt;
   report/&lt;br /&gt;
     backups/&lt;br /&gt;
     capability/&lt;br /&gt;
     ...&lt;br /&gt;
     myreport/&lt;br /&gt;
       lang/&lt;br /&gt;
         en_utf8/&lt;br /&gt;
           report_myreport.php&lt;br /&gt;
       index.php&lt;br /&gt;
     ...&lt;br /&gt;
  ...&lt;br /&gt;
&lt;br /&gt;
==What to do in index.php==&lt;br /&gt;
&lt;br /&gt;
The simplest way to work this out is by example. You should look at some of the reports that ship with Moodle. [http://cvs.moodle.org/moodle/admin/report/capability/index.php?view=markup admin/report/capability] (warning: capability report does not exist in v2.4+), is a good one to start with. Let us go through that example to see what is there (I will put into italics the bits that are more advanced - the things that the capability report does, but which a simple report will not need to do.):&lt;br /&gt;
# Require some libraries. Admin reports will always need config.php and adminlib.php.&lt;br /&gt;
# Check the user is logged in and has appropriate permissions. &#039;&#039;(Normally admin reports are controlled by the &#039;moodle/site:viewreports&#039; capability, the capability report is a special case.)&#039;&#039;&lt;br /&gt;
# Get the parameters from the URL that control the report, and clean them up a bit.&lt;br /&gt;
# &#039;&#039;Include some JavaScript code that enhances the report for people with JavaScript turned on in their browser.&#039;&#039;&lt;br /&gt;
# Log this request.&lt;br /&gt;
# Print the page header. Since this is an administration page, we need to do this using the admin_externalpage... functions. You probably just need to copy these two lines exactly, then replace &#039;capability&#039; with your report name.&lt;br /&gt;
# Display a form to control the report.&lt;br /&gt;
# If the URL contains all the parameters needed to generate the report, do so, and display the results. &#039;&#039;(You don&#039;t need to understand the details of what the capability report is doing, because your report will do something different. However, the general structure will probably be the same: get some data out of the database, then display it.)&#039;&#039;&lt;br /&gt;
# Print the footer, using the admin_externalpage... function.&lt;br /&gt;
# &#039;&#039;Define some functions, if that is the best way to structure the code of your report. You could, of course, create a separate lib.php file inside your report folder.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==How your report gets included in the admin tree==&lt;br /&gt;
&lt;br /&gt;
By default, your report will be included in the admin tree under the &#039;Reports&#039; section, and it will only appear to people with the &#039;moodle/site:viewreports&#039; capability. If the report is in the &#039;&#039;myreport&#039;&#039; folder, then the report name will be get_string(&amp;quot;myreport&amp;quot;, &amp;quot;report_&#039;&#039;myreport&#039;&#039;&amp;quot;). The report name, needed for the call to admin_externalpage_setup, will be &amp;quot;report&#039;&#039;myreport&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If you want more control over how your report appears, for example, if you want it to appear somewhere other than under Reports, or if you want it to be controlled by another capability, then you can create a settings.php file. For example, for the capability report, there is a settings.php file that contains:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
 &amp;lt;?php  // $Id$&lt;br /&gt;
 $ADMIN-&amp;gt;add(&#039;&#039;&#039;&amp;quot;roles&amp;quot;&#039;&#039;&#039;, new admin_externalpage(&#039;reportcapability&#039;,&lt;br /&gt;
	get_string(&#039;capability&#039;, &#039;report_capability&#039;),&lt;br /&gt;
	&amp;quot;$CFG-&amp;gt;wwwroot/$CFG-&amp;gt;admin/report/capability/index.php&amp;quot;,&lt;br /&gt;
	&amp;quot;moodle/role:manage&amp;quot;&lt;br /&gt;
));&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(The two non-standard bits there have been put into bold.)&lt;br /&gt;
&lt;br /&gt;
==Strings you must define in you lang/en_utf8/report_&#039;&#039;myreport&#039;&#039;.php==&lt;br /&gt;
&lt;br /&gt;
You just need to define&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
 $string[&amp;quot;myreport&amp;quot;] = &#039;What my report is called&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to make the report show up properly in the admin tree, but if your report does anything interesting, you will almost certainly need more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating a new report in admin block ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I am using Moodle 1.9. I have created a new reporting module in my local moodle server.  I tried following the examples on this page but was not able to get the new report folder to show in my menu, the admin_externalpage functions where failing. To accomplish the same thing, I completed these steps:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1 -&#039;&#039;&#039; Created a new folder under admin\report, called AU_ProfessionalDevelopment&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2 -&#039;&#039;&#039; Copied index.php and settings.php from the admin\report\question folder into the AU_ProfessionalDevelopment folder.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3 -&#039;&#039;&#039; edited setting.php, updating the string &#039;&#039;&#039;question&#039;&#039;&#039; with folder name &#039;&#039;&#039;AU_ProfessionalDevelopment&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4 -&#039;&#039;&#039; edited index.php, stripping out most of the code, leaving the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
    require_once(&#039;../../../config.php&#039;);&lt;br /&gt;
    require_once($CFG-&amp;gt;libdir.&#039;/adminlib.php&#039;);&lt;br /&gt;
    admin_externalpage_setup(&#039;reportAU_ProfessionalDevelopment&#039;);&lt;br /&gt;
    admin_externalpage_print_header();&lt;br /&gt;
    admin_externalpage_print_footer();&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;5&#039;&#039;&#039; Reloaded the moodle page (i am logged in as the admin - and can see the Admin. Block). I can see &#039;&#039;&#039;AU_ProfessionalDevelopment&#039;&#039;&#039; in the admin\report block.  Clicking on it loads my page with the admin header and footer.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://moodle.org/mod/data/view.php?d=13&amp;amp;rid=913 System images report] this is another very simple report, in contrib. Might be a good one to look at.&lt;br /&gt;
&lt;br /&gt;
[[Category:Plugins]]&lt;/div&gt;</summary>
		<author><name>Conhorne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Using_images_in_a_theme&amp;diff=30983</id>
		<title>Using images in a theme</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Using_images_in_a_theme&amp;diff=30983"/>
		<updated>2011-12-16T17:20:04Z</updated>

		<summary type="html">&lt;p&gt;Conhorne: /* Using your images within you layout files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Themes}}{{Moodle 2.0}}&lt;br /&gt;
==A little background==&lt;br /&gt;
Moodle 2.0 has introduced a new improved method of making use of images within its pages enabling theme designers to take full control over what images are being used and when possible ensures images are passed through Moodle&#039;s new performance caching system to obtain the best possible performance.&lt;br /&gt;
&lt;br /&gt;
$CFG-&amp;gt;themewww and custom pix in Moodle 1.9 and lower are gone from Moodle 2.0 and have been replaced by this new system.&lt;br /&gt;
&lt;br /&gt;
==Before we start==&lt;br /&gt;
&lt;br /&gt;
# Make sure you have a theme and images to work with, one that you have a backup of just in case.&lt;br /&gt;
# Take note of your theme&#039;s main layout file e.g. &#039;&#039;standard.php&#039;&#039;.&lt;br /&gt;
# Take note of your theme&#039;s main CSS file e.g. &#039;&#039;core.css&#039;&#039;.&lt;br /&gt;
# Turn on &#039;&#039;&#039;Theme designer mode&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
==Image locations within Moodle==&lt;br /&gt;
&lt;br /&gt;
There are three main areas in which images are located - core, plugin and theme.&lt;br /&gt;
&lt;br /&gt;
Core images are used throughout Moodle and are stored in &#039;&#039;moodle/pix&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The pix directory contains the following subdirectories:&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;a&#039;&#039; - Icons that are not widely used&lt;br /&gt;
:&#039;&#039;c&#039;&#039; - Calendar-related icons&lt;br /&gt;
:&#039;&#039;f&#039;&#039; - File icons for different file types&lt;br /&gt;
:&#039;&#039;g&#039;&#039; - Default user icons and thumbnails&lt;br /&gt;
:&#039;&#039;i&#039;&#039; - General icons&lt;br /&gt;
:&#039;&#039;m&#039;&#039; - Currency symbols&lt;br /&gt;
:&#039;&#039;s&#039;&#039; - Smileys&lt;br /&gt;
:&#039;&#039;t&#039;&#039; - General icons&lt;br /&gt;
:&#039;&#039;u&#039;&#039; - User icons and thumbnails&lt;br /&gt;
:&#039;&#039;y&#039;&#039; - YUI icons&lt;br /&gt;
&lt;br /&gt;
Plugin images are used by plugins and are stored within the plugin&#039;s directory e.g. &#039;&#039;mod/forum/*&#039;&#039; or &#039;&#039;blocks/navigation/*&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Theme images are used in themes and are stored in the &#039;&#039;pix&#039;&#039; subdirectory of a theme.&lt;br /&gt;
&lt;br /&gt;
==Adding new images to your theme==&lt;br /&gt;
&lt;br /&gt;
To add new images to your theme, such as a background image or a log, you should start by creating a pix directory within your themes directory.&lt;br /&gt;
&lt;br /&gt;
Lets assume you have two images, gradient.png and logo.jpg. Copy both files to your themes pix directory.&lt;br /&gt;
&lt;br /&gt;
The plan is to use gradient.png as the background image for your theme (in CSS) and use logo.jpg in the header (in your theme&#039;s layout file).&lt;br /&gt;
&lt;br /&gt;
===Using images within CSS===&lt;br /&gt;
&lt;br /&gt;
Moodle parses all CSS files. When theme designer mode is off, Moodle combines them into a handful of large CSS files that get cached and served. At the same time Moodle also looks at the CSS and replaces special syntax rules. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&#039;padding:10px;background-color:#f7f7f7;border:1px dashed #123456&#039;&amp;gt;&amp;lt;nowiki&amp;gt;[[pix:theme|&amp;lt;/nowiki&amp;gt;&amp;lt;span style=&#039;color:#336699;font-weight:bold;&#039;&amp;gt;&amp;lt;nowiki&amp;gt;path/to/image/&amp;lt;/nowiki&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&#039;color:#33993A;font-weight:bold;&#039;&amp;gt;imagename&amp;lt;/span&amp;gt;&amp;lt;nowiki&amp;gt;]]&amp;lt;/nowiki&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above pattern is looked for by Moodle and gets replaced with the correct image URL when found.&lt;br /&gt;
You should note the following things about this patter when using you own images within CSS:&lt;br /&gt;
&lt;br /&gt;
# The bits in black don&#039;t change&lt;br /&gt;
# The bit in blue is the path to your image within the pix directory. It shouldn&#039;t start with a / but should end with one.&lt;br /&gt;
# The bit in green is the filename (&#039;&#039;&#039;no need to include the file extension&#039;&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
To use background.png as the background for our pages, add the following line of CSS to the themes core.css.&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
body {background-image:url([[pix:theme|gradient]]);}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before we look at how to use your own images within your themes layout files we should first look at how this changes if the image is in a sub directory.&lt;br /&gt;
&lt;br /&gt;
Lets assume gradient.png is located here: &#039;&#039;&#039;pix/myimages/gradients/gradient.png&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The CSS would need to be as follows:&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
body {background-image:url([[pix:theme|myimages/gradients/gradient]]);}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to refer to an image belonging to a plugin, you can do it like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
body {background-image:url([[pix:quiz|icon]]);}&lt;br /&gt;
body {background-image:url([[pix:qtype_ddmarker|grid]]);}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That refers to mod/quiz/pix/icon.png/gif and question/type/ddmarker/pix/grid.png/gif respectively (or whatever icons you have put in your theme to override these).&lt;br /&gt;
&lt;br /&gt;
===Using your images within your layout files===&lt;br /&gt;
&lt;br /&gt;
To use logo.jpg within the header of the layout file, open the layout file e.g. standard.php and find the correct spot to put your logo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
....&lt;br /&gt;
&amp;lt;div id=&amp;quot;page-header&amp;quot; class=&amp;quot;clearfix&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Logo should go here --&amp;gt;&lt;br /&gt;
    &amp;lt;h1 class=&amp;quot;headermain&amp;quot;&amp;gt;&amp;lt;?php echo $PAGE-&amp;gt;heading ?&amp;gt;&amp;lt;/h1&amp;gt;&lt;br /&gt;
    &amp;lt;div class=&amp;quot;headermenu&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
        echo $OUTPUT-&amp;gt;login_info();&lt;br /&gt;
        echo $OUTPUT-&amp;gt;lang_menu();&lt;br /&gt;
        echo $PAGE-&amp;gt;headingmenu;&lt;br /&gt;
    ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
....&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To achieve this I simply need to add the following line of code:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;img src=&amp;quot;&amp;lt;?php echo $OUTPUT-&amp;gt;pix_url(&#039;logo&#039;, &#039;theme&#039;); ?&amp;gt;&amp;quot; alt=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
As before, the image&#039;s file extension is not needed as Moodle finds it automatically.&lt;br /&gt;
&lt;br /&gt;
Combined the solution is very simple:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
....&lt;br /&gt;
&amp;lt;div id=&amp;quot;page-header&amp;quot; class=&amp;quot;clearfix&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;img src=&amp;quot;&amp;lt;?php echo $OUTPUT-&amp;gt;pix_url(&#039;logo&#039;, &#039;theme&#039;); ?&amp;gt;&amp;quot; alt=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;h1 class=&amp;quot;headermain&amp;quot;&amp;gt;&amp;lt;?php echo $PAGE-&amp;gt;heading ?&amp;gt;&amp;lt;/h1&amp;gt;&lt;br /&gt;
    &amp;lt;div class=&amp;quot;headermenu&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
        echo $OUTPUT-&amp;gt;login_info();&lt;br /&gt;
        echo $OUTPUT-&amp;gt;lang_menu();&lt;br /&gt;
        echo $PAGE-&amp;gt;headingmenu;&lt;br /&gt;
    ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
....&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The only other thing to consider is how this example would look if logo.jpg was located in a subfolder e.g. &#039;&#039;&#039;pix/myimages/logos/logo.jpg&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The code for this would be:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;img src=&amp;quot;&amp;lt;?php echo $OUTPUT-&amp;gt;pix_url(&#039;myimages/logos/logo&#039;, &#039;theme&#039;); ?&amp;gt;&amp;quot; alt=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Overriding images in your theme==&lt;br /&gt;
&lt;br /&gt;
Overriding images within your theme can be an important part of creating and/or modifying themes.&lt;br /&gt;
&lt;br /&gt;
As mentioned, there are three main areas for images within Moodle, core, plugins, and themes. Obviously we won&#039;t be overriding theme images as we are in a theme and have full control over that already which just leaves core and plugin images that you may want to override.&lt;br /&gt;
&lt;br /&gt;
Within your theme create the following two directories:&lt;br /&gt;
; /pix_core/ : This is where your images to override core images will need to be.&lt;br /&gt;
; /pix_plugins/ : This is where images to override plugins will need to be.&lt;br /&gt;
&lt;br /&gt;
Next, copy the images that you wish to override into either the pix_core or pix_plugins directory. You need to replicate the directory structure that the images are located in.&lt;br /&gt;
&lt;br /&gt;
The following two examples illustrate how this works for both core and plugin images.&lt;br /&gt;
&lt;br /&gt;
===Overriding core images===&lt;br /&gt;
For this example I am going to override the following two images:&lt;br /&gt;
# &#039;&#039;&#039;moodle/pix/help.gif&#039;&#039;&#039; This image is used for all help image icons and is shown throughout Moodle.&lt;br /&gt;
# &#039;&#039;&#039;moodle/pix/i/info.gif&#039;&#039;&#039; This image is used in several places, most notably the front page if the combo list is being displayed.&lt;br /&gt;
&lt;br /&gt;
So first up help.gif. This is the most basic example of overriding an image. Because the image is directly within Moodle&#039;s pix directory we can simply place our new help image into our themes pix_core directory. There&#039;s nothing more to it!&lt;br /&gt;
&lt;br /&gt;
The second example if not really any more difficult. Because the image is located within the subdirectory &#039;&#039;&#039;i&#039;&#039;&#039; we must create a sub directory within our pix_core directory into which we will copy our new help image. That is, the image ends up at &#039;&#039;&#039;/pix_core/i/info.png&#039;&#039;&#039; inside your theme folder. And again done!&lt;br /&gt;
&lt;br /&gt;
You should also note that, as with any other image in Moodle, the extension doesn&#039;t matter. If you want to replace help.gif with a help.png you can just put the png into the correct directory. As long as the filename is the same Moodle will find it.&lt;br /&gt;
&lt;br /&gt;
===Overriding plugin images===&lt;br /&gt;
This is a little bit more difficult than overriding core images, but not too much so. For this example, let&#039;s say I want to override the following two plugin images:&lt;br /&gt;
# &#039;&#039;&#039;moodle/mod/forum/icon.gif&#039;&#039;&#039; This is the icon that is used everywhere for the forum.&lt;br /&gt;
# &#039;&#039;&#039;moodle/blocks/customblock/activate.png&#039;&#039;&#039; This is an icon in a custom block I have installed.&lt;br /&gt;
&lt;br /&gt;
First up, the forum icon. Just as with core images, we need to put the image in the correct directory structure. In this case it is going to be within our theme&#039;s pix_plugins directory.&lt;br /&gt;
&lt;br /&gt;
Here we need to create the directory structure between &#039;&#039;&#039;/mod/&#039;&#039;&#039; and the image, so we need the following structure &#039;&#039;&#039;/pix_plugins/mod/forum/&#039;&#039;&#039; and into the final forum directory we put our replacement image.&lt;br /&gt;
&lt;br /&gt;
The second example is done in exactly the same way, but with the blocks path. We simply need to put our replacement image in &#039;&#039;&#039;/pix_plugins/blocks/customblock/&#039;&#039;&#039; and it will automatically be overridden.&lt;br /&gt;
&lt;br /&gt;
==Example: Silkicons theme==&lt;br /&gt;
As an example of how this all looks when done I have attached a screen shot of a theme I quickly created using the Silk icon set created by Mark James available at [http://famfamfam.com/lab/icons/silk/ http://famfamfam.com/lab/icons/silk/].&lt;br /&gt;
&lt;br /&gt;
[[Image:Silkicon.theme.screenshot.jpg]]&lt;br /&gt;
&lt;br /&gt;
I have also uploaded the this file to this forum discussion if you would like to check it out for yourself.&lt;br /&gt;
[http://moodle.org/mod/forum/discuss.php?d=151581 http://moodle.org/mod/forum/discuss.php?d=151581]&lt;br /&gt;
&lt;br /&gt;
==More information==&lt;br /&gt;
&lt;br /&gt;
[[Themes 2.0]]&lt;br /&gt;
&lt;br /&gt;
[[Themes 2.0 creating your first theme]]&lt;br /&gt;
&lt;br /&gt;
[[Plugins]]&lt;br /&gt;
&lt;br /&gt;
[http://moodle.org/mod/forum/discuss.php?d=151581 http://moodle.org/mod/forum/discuss.php?d=151581]&lt;/div&gt;</summary>
		<author><name>Conhorne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Talk:Using_images_in_a_theme&amp;diff=30982</id>
		<title>Talk:Using images in a theme</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Talk:Using_images_in_a_theme&amp;diff=30982"/>
		<updated>2011-12-16T17:19:06Z</updated>

		<summary type="html">&lt;p&gt;Conhorne: /* standard.php ?? */ new section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Just had a quick browse through this, I have not tested this but are there file extensions missing in the examples?&lt;br /&gt;
&lt;br /&gt;
e.g. - &lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
body {background-image:url([[pix:theme|gradient]]);}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
shouldn&#039;t this read -&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
body {background-image:url([[pix:theme|gradient.png]]);}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
--Matthew Cannings&lt;br /&gt;
&lt;br /&gt;
No. It is intentional.&lt;br /&gt;
&lt;br /&gt;
It is not really important for theme images. After all, if you are making a theme, you probably do know what type your images are. However, suppose in your theme you want to override one of the standard icons, for example i/edit. Well, even though the standard images is i/edit.gif, you might want to replace it with i/edit.png in your theme, and you can, and Moodle will find the image as long as it is one of the supported formats. We use the same basic system for all images (theme, core and plugin) so that is why you must not specify the extension when you link to the image, and you can use any format you like.--[[User:Tim Hunt|Tim Hunt]] 18:50, 10 June 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
These documents are essentially for developers, but is there going to be a plainer version for us who do not speak the necessary jargon? I have been trying to figure out how to explain this in the [[Front Page FAQ]] to provide people looking at Moodle 2.0 with a hope of including their own logos onto their selected themes. Seriously, I do not have either the time or the patience to learn PHP to the point where I might be able to explain it in a non-technical manner. From what I am able to decipher, it might be easier than earlier versions, but I cannot be sure. --[[User:Colin Fraser|Colin Fraser]] 09:02, 2 October 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== couple small errors ==&lt;br /&gt;
&lt;br /&gt;
In the text below, the second &amp;quot;pattern&amp;quot; has no &amp;quot;n&amp;quot;, and I believe &amp;quot;background.png&amp;quot; should be &amp;quot;gradient.png&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The above pattern is looked for by Moodle and gets replaced with the correct image URL when found. You should note the following things about this &#039;&#039;&#039;patter&#039;&#039;&#039; when using you own images within CSS:&lt;br /&gt;
&lt;br /&gt;
   1. The bits in black don&#039;t change&lt;br /&gt;
   2. The bit in blue is the path to your image within the pix directory. It shouldn&#039;t start with a / but should end with one.&lt;br /&gt;
   3. The bit in green is the filename (no need to include the file extension) &lt;br /&gt;
&lt;br /&gt;
To use &#039;&#039;&#039;background.png&#039;&#039;&#039; as the background for our pages, add the following line of CSS to the themes core.css.&lt;br /&gt;
&lt;br /&gt;
body {background-image:url([[pix:theme|gradient]]);}&lt;br /&gt;
&lt;br /&gt;
-------&lt;br /&gt;
&lt;br /&gt;
: If you spot something that is clearly a typo, please just fix it directly. Thanks. Also, I don&#039;t think that it matters, for this example, whether the code uses background or gradient.--[[User:Tim Hunt|Tim Hunt]] 14:19, 8 October 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== standard.php ?? ==&lt;br /&gt;
&lt;br /&gt;
The instructions say &amp;quot;open the layout file e.g. standard.php&amp;quot;. I don&#039;t see any file called standard.php in version 2.2. So what file am I looking for?&lt;/div&gt;</summary>
		<author><name>Conhorne</name></author>
	</entry>
</feed>