<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ca">
	<id>https://docs.moodle.org/2x/ca/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bruno</id>
	<title>MoodleDocs - Contribucions de l&amp;#039;usuari [ca]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/2x/ca/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bruno"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/Especial:Contribucions/Bruno"/>
	<updated>2026-08-01T07:09:52Z</updated>
	<subtitle>Contribucions de l&amp;#039;usuari</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=error/moodle/csvloaderror&amp;diff=96690</id>
		<title>error/moodle/csvloaderror</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=error/moodle/csvloaderror&amp;diff=96690"/>
		<updated>2012-03-27T21:01:07Z</updated>

		<summary type="html">&lt;p&gt;Bruno: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Unfortunately the module which loads the csv data doesn&#039;t explain what is wrong.&lt;br /&gt;
&lt;br /&gt;
#Check&lt;br /&gt;
## First line must contain column headings SPELLED correctly&lt;br /&gt;
## There should not be quotes (i.e. &amp;quot;)&lt;br /&gt;
## There should not be a trailing comma (i.e. ,)&lt;br /&gt;
## When uploading custom profile field names, make sure that the short name is in lowercase&lt;br /&gt;
&lt;br /&gt;
While you&#039;re here, contrary to popular belief, usernames must be in lowercase in the file to be uploaded.&lt;br /&gt;
&lt;br /&gt;
for more, see https://docs.moodle.org/24/en/admin/tool/uploaduser/index&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Administration_via_command_line&amp;diff=82685</id>
		<title>Administration via command line</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Administration_via_command_line&amp;diff=82685"/>
		<updated>2011-04-10T05:17:58Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* Upgrading via command line */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.0}}&lt;br /&gt;
&lt;br /&gt;
If you have shell access to your web server, you may find various CLI (command line interface) scripts useful during Moodle administration. All command line tools are located in &amp;lt;code&amp;gt;admin/cli/*&amp;lt;/code&amp;gt; directory. To avoid problems with access control, you should run them as the owner of the web server process. It is especially important for CLI installation and upgrade as they create new files in moodledata directory and the web server has to have write access to them. In Linux distributions, the user that runs the web server is usually apache or wwrun or httpd or something similar. As a root, you will probably want to execute Moodle CLI scripts like this:&lt;br /&gt;
&lt;br /&gt;
    $ cd /path/to/your/moodle/dir&lt;br /&gt;
    $ sudo -u apache /usr/bin/php admin/cli/somescript.php --params&lt;br /&gt;
&lt;br /&gt;
Most of the scripts accept common --help (or -h) parameter to display the full usage information, for example:&lt;br /&gt;
&lt;br /&gt;
    $ sudo -u apache /usr/bin/php admin/cli/install.php --help&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation via command line ==&lt;br /&gt;
&lt;br /&gt;
Since version 2.0, Moodle can be installed from the command line. There are two modes of installation. In interactive mode, the install script asks you for all data needed to properly set up new Moodle site. In non-interactive mode, you must provide all required data as the script parameters and then the new site is installed silently. The parameters can be passed in the interactive mode, too. The provided values are then used as the default values during the interactive session.&lt;br /&gt;
&lt;br /&gt;
    $ sudo -u apache /usr/bin/php admin/cli/install.php --lang=cs&lt;br /&gt;
&lt;br /&gt;
== Maintenance mode ==&lt;br /&gt;
&lt;br /&gt;
To switch your site into the maintenance mode via CLI, you can use&lt;br /&gt;
&lt;br /&gt;
    $ sudo -u apache /usr/bin/php admin/cli/maintenance.php --enable&lt;br /&gt;
&lt;br /&gt;
To turn the maintenance mode off, just execute the same script with --disable parameter.&lt;br /&gt;
&lt;br /&gt;
== Offline mode ==&lt;br /&gt;
&lt;br /&gt;
In some situations, you may want to switch your Moodle site into offline mode so that it is not accessible via the web but you can not stop the web server completely (typically because there are other web pages and applications running there). If a file called &amp;lt;code&amp;gt;climaintenance.html&amp;lt;/code&amp;gt; exists in the root folder of moodledata directory, Moodle will automatically display the contents of that file instead of any other page.&lt;br /&gt;
&lt;br /&gt;
    $ cd /var/www/sites/moodle/moodledata/&lt;br /&gt;
    $ echo &#039;&amp;amp;lt;h1&amp;amp;gt;Sorry, maintenance in progress&amp;amp;lt;/h1&amp;amp;gt;&#039; &amp;amp;gt; climaintenance.html&lt;br /&gt;
&lt;br /&gt;
You can prepare a nice formatted HTML page to inform your users about the server being down and keep in the moodledata directory under a name like &amp;lt;code&amp;gt;climaintenance.off&amp;lt;/code&amp;gt; and rename it to the &amp;lt;code&amp;gt;climaintenance.html&amp;lt;/code&amp;gt; if needed.&lt;br /&gt;
&lt;br /&gt;
== Upgrading via command line ==&lt;br /&gt;
&lt;br /&gt;
Moodle can be upgraded from the command line. As with the installation script, there is either interactive or non-interactive mode of the upgrade. The script itself does not put the site into the maintenance mode, you have to do it on your own. Also, the script does not backup any data (if you read this page, you probably have some own scripts to backup your moodledata and the database, right?)&lt;br /&gt;
&lt;br /&gt;
    $ sudo -u aphe cli script for upgrading to moodle 2.0 normally outputs those same messages too.ache /usr/bin/php admin/cli/upgrade.php --non-interactive&lt;br /&gt;
&lt;br /&gt;
Upgrading via command line is a very comfortable way of Moodle upgrade if you use [[CVS]] or [[Git|git]] checkout of the Moodle source code. See the following procedure how to upgrade your site within several seconds to the most recent version while preserving your eventual local customizations tracked in git repository:&lt;br /&gt;
&lt;br /&gt;
    $ cd /var/www/sites/moodle/htdocs/&lt;br /&gt;
    $ git fetch&lt;br /&gt;
    $ sudo -u apache /usr/bin/php admin/cli/maintenance.php --enable&lt;br /&gt;
    $ git merge origin/cvshead&lt;br /&gt;
    $ sudo -u apache /usr/bin/php admin/cli/upgrade.php&lt;br /&gt;
    $ sudo -u apache /usr/bin/php admin/cli/maintenance.php --disable&lt;br /&gt;
&lt;br /&gt;
===Issues with Upgrading via Command Line===&lt;br /&gt;
&lt;br /&gt;
if your config.php contains information about several moodle instances (distinct moodle websites and databases sharing the same codebase), then this script will silently fail&lt;br /&gt;
&lt;br /&gt;
The solution is to temporarily eliminate from config.php all but the one instance you want to upgrade &lt;br /&gt;
&lt;br /&gt;
If this is a problem for the other instances (production sites), then modify the cli script to point to a copy of config.php  (which will be the one edited to contain only one moodle instance at a time)&lt;br /&gt;
&lt;br /&gt;
== Custom site defaults ==&lt;br /&gt;
&lt;br /&gt;
During the install and upgrade via CLI, Moodle sets the administration variables to the default values. You can use different defaults. See MDL-17850 for details. Shortly, all you need to do is to add a file &amp;lt;code&amp;gt;local/defaults.php&amp;lt;/code&amp;gt; into your Moodle installation. The format of the file is like&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$defaults[&#039;pluginname&#039;][&#039;settingname&#039;] = &#039;settingvalue&#039;; // for plugins&lt;br /&gt;
$defaults[&#039;moodle&#039;][&#039;settingname&#039;] = &#039;settingvalue&#039;;     // for core settings&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These defaults are used during install, upgrade and are also displayed as defaults at the Site administration pages.&lt;br /&gt;
&lt;br /&gt;
== Reset user password ==&lt;br /&gt;
&lt;br /&gt;
If you happen to forget your admin password (or you want to set a password for any other user of your Moodle system), you can use reset_password.php script. The script sets the correctly salted password for the given user.&lt;br /&gt;
&lt;br /&gt;
    $ sudo -u apache /usr/bin/php admin/cli/reset_password.php&lt;br /&gt;
&lt;br /&gt;
== MySQL storage engine conversion ==&lt;br /&gt;
&lt;br /&gt;
If you run your Moodle site with MySQL database backend and use the default MyISAM as the storage engine for your tables, you may want to convert them to use some more reliable engine like InnoDB (actually, you should want to switch to PostgreSQL ;-) anyway).&lt;br /&gt;
&lt;br /&gt;
    $ sudo -u apache /usr/bin/php admin/cli/mysql_engine.php --engine=InnoDB&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Running cron via command line ==&lt;br /&gt;
&lt;br /&gt;
In versions 1.x, you could execute admin/cron.php either from command line or via the web. Since Moodle 2.0, only admin/cli/cron.php script can be run via command line.&lt;br /&gt;
&lt;br /&gt;
[[Category:Administrator]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Administration en ligne de commande]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=DML_drivers&amp;diff=78614</id>
		<title>DML drivers</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=DML_drivers&amp;diff=78614"/>
		<updated>2010-12-03T06:41:02Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* Query logging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle_2.0}}Previous versions were using adodb abstraction partially encapsulated by old DML api. The database drivers are now fully separated from the rest of code and it is even possible to create new native drivers that do not rely on adodb abstraction anymore.&lt;br /&gt;
&lt;br /&gt;
At present there are three native drivers - mysqli, pgsql and unfinished Oracle driver. The benefits are:&lt;br /&gt;
* more optimised and probably faster&lt;br /&gt;
* consume less memory&lt;br /&gt;
* better possibility to improve logging, debugging, profiling, etc.&lt;br /&gt;
* less code, easier to fix and maintain&lt;br /&gt;
* and more&lt;br /&gt;
&lt;br /&gt;
Please note old adodb based drivers will be removed before the branching of 2.0.&lt;br /&gt;
&lt;br /&gt;
==Query logging==&lt;br /&gt;
New native DML drivers support logging of database queries to database table. Logging can be enabled in config.php&lt;br /&gt;
&lt;br /&gt;
 $CFG-&amp;gt;dboptions = array (&lt;br /&gt;
  &#039;dbpersist&#039; =&amp;gt; 0,&lt;br /&gt;
  //&#039;logall&#039;   =&amp;gt; true,&lt;br /&gt;
  &#039;logslow&#039;  =&amp;gt; 5,&lt;br /&gt;
  &#039;logerrors&#039;  =&amp;gt; true,&lt;br /&gt;
 );&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;logall&#039;&#039;&#039; - log all queries - suitable only for developers, causes high server loads&lt;br /&gt;
* &#039;&#039;&#039;logslow&#039;&#039;&#039; - log queries that take longer than specified number of seconds (float values are accepted)&lt;br /&gt;
* &#039;&#039;&#039;logerrors&#039;&#039;&#039; - log all error queries&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
* add more info here&lt;br /&gt;
* add separate docs pages for each driver - describe all options there&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Development:DML functions|DML functions]]: Where all the functions used to handle DB data ([[wikipedia:Data_Manipulation_Language|DML]]) are defined.&lt;br /&gt;
* [[Development:DML exceptions|DML exceptions]]: New DML code is throwing exceptions instead of returning false if anything goes wrong&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=DML_drivers&amp;diff=78613</id>
		<title>DML drivers</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=DML_drivers&amp;diff=78613"/>
		<updated>2010-12-03T06:40:25Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* Query logging */  spelling correction&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle_2.0}}Previous versions were using adodb abstraction partially encapsulated by old DML api. The database drivers are now fully separated from the rest of code and it is even possible to create new native drivers that do not rely on adodb abstraction anymore.&lt;br /&gt;
&lt;br /&gt;
At present there are three native drivers - mysqli, pgsql and unfinished Oracle driver. The benefits are:&lt;br /&gt;
* more optimised and probably faster&lt;br /&gt;
* consume less memory&lt;br /&gt;
* better possibility to improve logging, debugging, profiling, etc.&lt;br /&gt;
* less code, easier to fix and maintain&lt;br /&gt;
* and more&lt;br /&gt;
&lt;br /&gt;
Please note old adodb based drivers will be removed before the branching of 2.0.&lt;br /&gt;
&lt;br /&gt;
==Query logging==&lt;br /&gt;
New native DML drivers support logging of database queries to database table. Logging can be enabled in config.php&lt;br /&gt;
&lt;br /&gt;
 $CFG-&amp;gt;dboptions = array (&lt;br /&gt;
  &#039;dbpersit&#039; =&amp;gt; 0,&lt;br /&gt;
  //&#039;logall&#039;   =&amp;gt; true,&lt;br /&gt;
  &#039;logslow&#039;  =&amp;gt; 5,&lt;br /&gt;
  &#039;logerrors&#039;  =&amp;gt; true,&lt;br /&gt;
 );&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;logall&#039;&#039;&#039; - log all queries - suitable only for developers, causes high server loads&lt;br /&gt;
* &#039;&#039;&#039;logslow&#039;&#039;&#039; - log queries that take longer than specified number of seconds (float values are accepted)&lt;br /&gt;
* &#039;&#039;&#039;logerrors&#039;&#039;&#039; - log all error queries&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
* add more info here&lt;br /&gt;
* add separate docs pages for each driver - describe all options there&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Development:DML functions|DML functions]]: Where all the functions used to handle DB data ([[wikipedia:Data_Manipulation_Language|DML]]) are defined.&lt;br /&gt;
* [[Development:DML exceptions|DML exceptions]]: New DML code is throwing exceptions instead of returning false if anything goes wrong&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Broken/DML_functions&amp;diff=78612</id>
		<title>Broken/DML functions</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Broken/DML_functions&amp;diff=78612"/>
		<updated>2010-12-03T06:29:56Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* Using Recordsets */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle_2.0}}This page describes the functions available to access data in the Moodle database. You should &#039;&#039;&#039;exclusively&#039;&#039;&#039; use these functions in order to retrieve or modify database content because these functions provide a high level of abstraction and guarantee that your database manipulation will work against different RDBMSes.&lt;br /&gt;
&lt;br /&gt;
Where possible, tricks and examples will be documented here in order to make developers&#039; lives a bit easier. Of course, feel free to clarify, complete and add more information to  this documentation. It will be welcome, absolutely!&lt;br /&gt;
&lt;br /&gt;
== Main info ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important note:&#039;&#039;&#039; All the functions shown on this page are for use in &#039;&#039;&#039;Moodle 2.0 upwards&#039;&#039;&#039;, where we changed the [[Development:DB layer 2.0|DB layer]] to support some new features. If you need information for previous Moodle version, take a look to the [[Development:DML functions - pre 2.0|DML functions - pre 2.0]] page. For a detailed reference of changes, see the [[Development:DB layer 2.0 migration docs|migration docs]].&lt;br /&gt;
&lt;br /&gt;
* All the function calls on this page are public methods of the $DB global object, so you&#039;ll need to &amp;quot;import&amp;quot; it within your functions (not needed in global scripts) with one simple:&lt;br /&gt;
&amp;lt;code php&amp;gt;global $DB;&amp;lt;/code&amp;gt;&lt;br /&gt;
* All the $table parameters in the functions are meant to be the table name &#039;&#039;without&#039;&#039; prefixes.&lt;br /&gt;
&amp;lt;code php&amp;gt;$user = $DB-&amp;gt;get_record(&#039;user&#039;, array(&#039;id&#039;=&amp;gt;&#039;1&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
* When using the xxx_sql() functions, table names must be enclosed between curly braces.&lt;br /&gt;
&amp;lt;code php&amp;gt;$user = $DB-&amp;gt;get_record_sql(&#039;SELECT * FROM {user} WHERE id = ?&#039;, array(1));&amp;lt;/code&amp;gt;&lt;br /&gt;
* All the $conditions parameters in the functions are arrays of fieldname=&amp;gt;fieldvalue elements.&lt;br /&gt;
&amp;lt;code php&amp;gt;$user = $DB-&amp;gt;get_record(&#039;user&#039;, array(&#039;firstname&#039;=&amp;gt;&#039;Martin&#039;, &#039;lastname&#039;=&amp;gt;&#039;Dougiamas&#039;));&amp;lt;/code&amp;gt;&lt;br /&gt;
* All the $params parameters in the functions are arrays of values used to fill placeholders in SQL statements. Both the question mark and named placeholders can be used. Note that named params &#039;&#039;&#039;must be unique&#039;&#039;&#039; even if the value passed is the same.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
/// Question mark placeholders:&lt;br /&gt;
   $DB-&amp;gt;get_record_sql(&#039;SELECT * FROM {user} WHERE firstname = ? AND lastname = ?&#039;, &lt;br /&gt;
                       array(&#039;Martin&#039;, &#039;Dougiamas&#039;));&lt;br /&gt;
&lt;br /&gt;
/// Named placeholders:&lt;br /&gt;
   $DB-&amp;gt;get_record_sql(&#039;SELECT * FROM {user} WHERE firstname = :firstname AND lastname = :lastname&#039;,&lt;br /&gt;
                       array(&#039;firstname&#039;=&amp;gt;&#039;Martin&#039;, &#039;lastname&#039;=&amp;gt;&#039;Dougiamas&#039;));&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The functions ==&lt;br /&gt;
&lt;br /&gt;
===Seeing how many records match a given criteria===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;count_records($table, array $conditions=null) &lt;br /&gt;
  /// Count the records in a table where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;count_records_select($table, $select, array $params=null, $countitem=&amp;quot;COUNT(&#039;x&#039;)&amp;quot;) &lt;br /&gt;
  /// Count the records in a table which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;count_records_sql($sql, array $params=null) &lt;br /&gt;
  /// Get the result of a SQL SELECT COUNT(...) query.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Seeing if one record exists===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;record_exists($table, array $conditions=null) &lt;br /&gt;
  /// Test whether a record exists in a table where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;record_exists_select($table, $select, array $params=null) &lt;br /&gt;
  /// Test whether any records exists in a table which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;record_exists_sql($sql, array $params=null) &lt;br /&gt;
  /// Test whether a SQL SELECT statement returns any records.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Getting a single record===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;get_record($table, array $conditions, $fields=&#039;*&#039;, $ignoremultiple=false) &lt;br /&gt;
  /// Get a single database record as an object where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;get_record_select($table, $select, array $params=null, $fields=&#039;*&#039;, $ignoremultiple=false)&lt;br /&gt;
  /// Get a single database record as an object which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_record_sql($sql, array $params=null)&lt;br /&gt;
  /// Get a single database record as an object using a SQL statement.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Getting an array of records===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;get_records($table, array $conditions=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0) &lt;br /&gt;
  /// Get a number of records as an array of objects where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;get_records_select($table, $select, array $params=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0) &lt;br /&gt;
  /// Get a number of records as an array of objects which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_records_sql($sql, array $params=null, $limitfrom=0, $limitnum=0)&lt;br /&gt;
  /// Get a number of records as an array of objects using a SQL statement.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;get_records_menu($table, array $conditions=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0) &lt;br /&gt;
  /// Get the first two columns from a number of records as an associative array where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;get_records_select_menu($table, $select, array $params=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0)&lt;br /&gt;
  /// Get the first two columns from a number of records as an associative array which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_records_sql_menu($sql, array $params=null, $limitfrom=0, $limitnum=0)&lt;br /&gt;
  /// Get the first two columns from a number of records as an associative array using a SQL statement.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;get_records_list($table, $field=&#039;&#039;, $values=&#039;&#039;, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=&#039;&#039;, $limitnum=&#039;&#039;) &lt;br /&gt;
  /// Get a number of records as an array of objects where one field match one list of values.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Getting a particular field value from one record===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;get_field($table, $return, array $conditions)&lt;br /&gt;
  /// Get a single field value from a table record where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;get_field_select($table, $return, $select, array $params=null)&lt;br /&gt;
  /// Get a single field value from a table record which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_field_sql($sql, array $params=null)&lt;br /&gt;
  /// Get a single field value (first field) using a SQL statement.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Getting a particular field value from various records===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;get_fieldset_select($table, $return, $select, array $params=null)&lt;br /&gt;
  /// Selects records and return values of chosen field as an array which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_fieldset_sql($sql, array $params=null)&lt;br /&gt;
  /// Selects records and return values (first field) as an array using a SQL statement.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Setting a particular field in the database===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;set_field($table, $newfield, $newvalue, array $conditions=null)&lt;br /&gt;
  /// Set a single field in every table record where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;set_field_select($table, $newfield, $newvalue, $select, array $params=null)&lt;br /&gt;
  /// Set a single field in every table record which match a particular WHERE clause.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Deleting Records===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;delete_records($table, array $conditions=null) &lt;br /&gt;
  /// Delete the records from a table where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;delete_records_select($table, $select, array $params=null)&lt;br /&gt;
  /// Delete one or more records from a table which match a particular WHERE clause.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Inserting Records===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;insert_record($table, $dataobject, $returnid=true, $bulk=false) &lt;br /&gt;
  /// Insert a record into a table and return the &amp;quot;id&amp;quot; field if required.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Updating Records===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;update_record($table, $dataobject, $bulk=false)&lt;br /&gt;
  /// Update a record in a table.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using Recordsets===&lt;br /&gt;
&lt;br /&gt;
Where the number of records to be retrieved from DB is high, the &#039;&#039;&#039;get_records_xxx()&#039;&#039;&#039; functions above are far from optimal, because they load all the records in memory at the same time. Under those circumstances, it is highly recommended to use these &#039;&#039;&#039;get_recordset_xxx()&#039;&#039;&#039; functions instead, which use one nice mechanism to iterate over all the target records and save a lot of memory.&lt;br /&gt;
&lt;br /&gt;
Only one thing is &#039;&#039;&#039;absolutely important&#039;&#039;&#039;: Don&#039;t forget to close the recordsets after using them! (This will free up a lot of resources in the RDBMS).&lt;br /&gt;
&lt;br /&gt;
Here is the general way to iterate over records using the &#039;&#039;&#039;get_recordset_xxx()&#039;&#039;&#039; functions:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
if ($rs = $DB-&amp;gt;get_recordset(....) {&lt;br /&gt;
    foreach ($rs as $record) {&lt;br /&gt;
     /// Do whatever you want with this record&lt;br /&gt;
    }&lt;br /&gt;
    $rs-&amp;gt;close(); /// Don&#039;t forget to close the recordset!&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And this is the list of available functions (100% paired with the get_records_xxx() above):&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;get_recordset($table, array $conditions=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0) &lt;br /&gt;
  /// Get a number of records as a moodle_recordset where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;get_recordset_select($table, $select, array $params=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0) &lt;br /&gt;
  /// Get a number of records as a moodle_recordset which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_recordset_sql($sql, array $params=null, $limitfrom=0, $limitnum=0);&lt;br /&gt;
  /// Get a number of records as a moodle_recordset using a SQL statement.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;get_recordset_list($table, $field=&#039;&#039;, $values=&#039;&#039;, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=&#039;&#039;, $limitnum=&#039;&#039;) &lt;br /&gt;
  /// Get a number of records as a moodle_recordset where one field matches one list of values.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Delegated transactions===&lt;br /&gt;
&lt;br /&gt;
* Please note some databases do not support transactions (such as the MyISAM MySQL database engine), however all server administrators are strongly encouraged to migrate to databases that support transactions (such as the InnoDB MySQL database engine).&lt;br /&gt;
* Previous versions supported only one level of transaction. Since Moodle 2.0, the DML layer emulates delegated transactions that allow nesting of transactions.&lt;br /&gt;
* Transactions should not be used much in Moodle core; they are intended for various plugins such as web services, enrol and auth plugins.&lt;br /&gt;
* Some subsystems (such as messaging) do not support transactions because is it is not possible to rollback in external systems.&lt;br /&gt;
&lt;br /&gt;
A transaction is started by:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$transaction = $DB-&amp;gt;start_delegated_transaction();&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and finished by:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$transaction-&amp;gt;allow_commit();&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usually a transaction is rolled back when an exception is thrown. &amp;lt;code&amp;gt;$transaction-&amp;gt;rollback($ex);&amp;lt;/code&amp;gt; must be used very carefully because it might break compatibility with databases that do not support transactions. Transactions cannot be used as part of expected code flow; they can be used only as an emergency protection of data consistency.&lt;br /&gt;
&lt;br /&gt;
See more details in [[Development:DB layer 2.0 delegated transactions]] or MDL-20625.&lt;br /&gt;
&lt;br /&gt;
===Helper Functions===&lt;br /&gt;
&lt;br /&gt;
In order have real cross-db compatibility, there are some helper functions used to build SQL fragments based on the DB Moodle is running. Using them we&#039;ll avoid conditional queries here and there and have those &amp;quot;incompatibilities&amp;quot; fixed once and for ever.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;sql_bitand($int1, $int2) &lt;br /&gt;
  /// Returns the SQL text to be used in order to perform one bitwise AND &lt;br /&gt;
  /// operation between 2 integers.&lt;br /&gt;
o $DB-&amp;gt;sql_bitnot($int1) &lt;br /&gt;
  /// Returns the SQL text to be used in order to perform one bitwise NOT &lt;br /&gt;
  /// operation with 1 integer.&lt;br /&gt;
o $DB-&amp;gt;sql_bitor($int1, $int2)&lt;br /&gt;
  /// Returns the SQL text to be used in order to perform one bitwise OR &lt;br /&gt;
  /// operation between 2 integers.&lt;br /&gt;
o $DB-&amp;gt;sql_bitxor($int1, $int2) &lt;br /&gt;
  /// Returns the SQL text to be used in order to perform one bitwise XOR &lt;br /&gt;
  /// operation between 2 integers.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_null_from_clause()&lt;br /&gt;
  /// Returns the FROM clause required by some DBs in all SELECT statements.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_ceil($fieldname)&lt;br /&gt;
  /// Returns the correct CEIL expression applied to fieldname.&lt;br /&gt;
o $DB-&amp;gt;sql_ilike()&lt;br /&gt;
  /// Returns the proper SQL to do LIKE in a case-insensitive way.&lt;br /&gt;
o $DB-&amp;gt;sql_length($fieldname)&lt;br /&gt;
  /// Returns the SQL text to be used to calculate the length in characters of one expression.&lt;br /&gt;
o $DB-&amp;gt;sql_modulo($int1, $int2)&lt;br /&gt;
  /// Returns the SQL text to be used in order to calculate module - remainder after division&lt;br /&gt;
o $DB-&amp;gt;sql_position($needle, $haystack)&lt;br /&gt;
  /// Returns the SQL for returning searching one string for the location of another.&lt;br /&gt;
  /// Note: If using placeholders BOTH in $needle and $haystack, they MUST be named placeholders.&lt;br /&gt;
o $DB-&amp;gt;sql_substr($expr, $start, $length=false)&lt;br /&gt;
  /// Returns the proper substr() SQL text used to extract substrings from DB.&lt;br /&gt;
  /// Note: This fuction has changed in Moodle 2.0 and now at least 2 params are mandatory.&lt;br /&gt;
  /// Note: Now it returns the whole SQL text to be used instead of only the function name.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_cast_char2int($fieldname, $text=false)&lt;br /&gt;
  /// Returns the SQL to be used in order to CAST one CHAR column to INTEGER.&lt;br /&gt;
o $DB-&amp;gt;sql_cast_char2real($fieldname, $text=false)&lt;br /&gt;
  /// Returns the SQL to be used in order to CAST one CHAR column to REAL number.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_compare_text($fieldname, $numchars=32) &lt;br /&gt;
  /// Returns the SQL text to be used to compare one TEXT (clob) column.&lt;br /&gt;
  /// with one VARCHAR column.&lt;br /&gt;
o $DB-&amp;gt;sql_order_by_text($fieldname, $numchars=32)&lt;br /&gt;
  /// Returns the SQL text to be used to order by one TEXT (clob) column.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_concat()&lt;br /&gt;
  /// Returns the proper SQL to do CONCAT between the elements passed.&lt;br /&gt;
o $DB-&amp;gt;sql_concat_join($separator=&amp;quot;&#039; &#039;&amp;quot;, $elements=array())&lt;br /&gt;
  /// Returns the proper SQL to do CONCAT between the elements passed using one separator.&lt;br /&gt;
o $DB-&amp;gt;sql_fullname($first=&#039;firstname&#039;, $last=&#039;lastname&#039;)&lt;br /&gt;
  /// Returns the proper SQL to concatenate $firstname and $lastname.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_isempty($tablename, $fieldname, $nullablefield, $textfield)&lt;br /&gt;
  /// Returns the proper SQL to know if one field is empty.&lt;br /&gt;
o $DB-&amp;gt;sql_isnotempty($tablename, $fieldname, $nullablefield, $textfield)&lt;br /&gt;
  /// Returns the proper SQL to know if one field is not empty.&lt;br /&gt;
o $DB-&amp;gt;sql_empty()&lt;br /&gt;
  /// Returns the empty string char used by every supported DB.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[Development:DML exceptions|DML exceptions]]: New DML code is throwing exceptions instead of returning false if anything goes wrong&lt;br /&gt;
* [[Development:DML drivers|DML drivers]]: Database drivers for new DML layer&lt;br /&gt;
* [[Development:DML functions - pre 2.0|DML functions - pre 2.0]]: &#039;&#039;&#039;(deprecated!)&#039;&#039;&#039; For information valid before Moodle 2.0.&lt;br /&gt;
* [[Development:DDL functions|DDL functions]]: Where all the functions used to handle DB objects ([[wikipedia:Data_Definition_Language|DDL]]) are defined.&lt;br /&gt;
* [[Development:DB layer 2.0 examples|DB layer 2.0 examples]]: To see some code examples using various DML functions.&lt;br /&gt;
* [[Development:DB layer 2.0 migration docs|DB layer 2.0 migration docs]]: Information about how to modify your code to work with the new Moodle 2.0 DB layer.&lt;br /&gt;
* [[Development:DTL functions|DTL functions]]: Exporting, importing and moving of data stored in SQL databases&lt;br /&gt;
&lt;br /&gt;
[[Category:DB]]&lt;br /&gt;
[[Category:XMLDB]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Broken/DML_functions&amp;diff=78611</id>
		<title>Broken/DML functions</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Broken/DML_functions&amp;diff=78611"/>
		<updated>2010-12-03T06:28:37Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* Using Recordsets */  clearer english&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle_2.0}}This page describes the functions available to access data in the Moodle database. You should &#039;&#039;&#039;exclusively&#039;&#039;&#039; use these functions in order to retrieve or modify database content because these functions provide a high level of abstraction and guarantee that your database manipulation will work against different RDBMSes.&lt;br /&gt;
&lt;br /&gt;
Where possible, tricks and examples will be documented here in order to make developers&#039; lives a bit easier. Of course, feel free to clarify, complete and add more information to  this documentation. It will be welcome, absolutely!&lt;br /&gt;
&lt;br /&gt;
== Main info ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important note:&#039;&#039;&#039; All the functions shown on this page are for use in &#039;&#039;&#039;Moodle 2.0 upwards&#039;&#039;&#039;, where we changed the [[Development:DB layer 2.0|DB layer]] to support some new features. If you need information for previous Moodle version, take a look to the [[Development:DML functions - pre 2.0|DML functions - pre 2.0]] page. For a detailed reference of changes, see the [[Development:DB layer 2.0 migration docs|migration docs]].&lt;br /&gt;
&lt;br /&gt;
* All the function calls on this page are public methods of the $DB global object, so you&#039;ll need to &amp;quot;import&amp;quot; it within your functions (not needed in global scripts) with one simple:&lt;br /&gt;
&amp;lt;code php&amp;gt;global $DB;&amp;lt;/code&amp;gt;&lt;br /&gt;
* All the $table parameters in the functions are meant to be the table name &#039;&#039;without&#039;&#039; prefixes.&lt;br /&gt;
&amp;lt;code php&amp;gt;$user = $DB-&amp;gt;get_record(&#039;user&#039;, array(&#039;id&#039;=&amp;gt;&#039;1&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
* When using the xxx_sql() functions, table names must be enclosed between curly braces.&lt;br /&gt;
&amp;lt;code php&amp;gt;$user = $DB-&amp;gt;get_record_sql(&#039;SELECT * FROM {user} WHERE id = ?&#039;, array(1));&amp;lt;/code&amp;gt;&lt;br /&gt;
* All the $conditions parameters in the functions are arrays of fieldname=&amp;gt;fieldvalue elements.&lt;br /&gt;
&amp;lt;code php&amp;gt;$user = $DB-&amp;gt;get_record(&#039;user&#039;, array(&#039;firstname&#039;=&amp;gt;&#039;Martin&#039;, &#039;lastname&#039;=&amp;gt;&#039;Dougiamas&#039;));&amp;lt;/code&amp;gt;&lt;br /&gt;
* All the $params parameters in the functions are arrays of values used to fill placeholders in SQL statements. Both the question mark and named placeholders can be used. Note that named params &#039;&#039;&#039;must be unique&#039;&#039;&#039; even if the value passed is the same.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
/// Question mark placeholders:&lt;br /&gt;
   $DB-&amp;gt;get_record_sql(&#039;SELECT * FROM {user} WHERE firstname = ? AND lastname = ?&#039;, &lt;br /&gt;
                       array(&#039;Martin&#039;, &#039;Dougiamas&#039;));&lt;br /&gt;
&lt;br /&gt;
/// Named placeholders:&lt;br /&gt;
   $DB-&amp;gt;get_record_sql(&#039;SELECT * FROM {user} WHERE firstname = :firstname AND lastname = :lastname&#039;,&lt;br /&gt;
                       array(&#039;firstname&#039;=&amp;gt;&#039;Martin&#039;, &#039;lastname&#039;=&amp;gt;&#039;Dougiamas&#039;));&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The functions ==&lt;br /&gt;
&lt;br /&gt;
===Seeing how many records match a given criteria===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;count_records($table, array $conditions=null) &lt;br /&gt;
  /// Count the records in a table where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;count_records_select($table, $select, array $params=null, $countitem=&amp;quot;COUNT(&#039;x&#039;)&amp;quot;) &lt;br /&gt;
  /// Count the records in a table which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;count_records_sql($sql, array $params=null) &lt;br /&gt;
  /// Get the result of a SQL SELECT COUNT(...) query.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Seeing if one record exists===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;record_exists($table, array $conditions=null) &lt;br /&gt;
  /// Test whether a record exists in a table where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;record_exists_select($table, $select, array $params=null) &lt;br /&gt;
  /// Test whether any records exists in a table which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;record_exists_sql($sql, array $params=null) &lt;br /&gt;
  /// Test whether a SQL SELECT statement returns any records.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Getting a single record===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;get_record($table, array $conditions, $fields=&#039;*&#039;, $ignoremultiple=false) &lt;br /&gt;
  /// Get a single database record as an object where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;get_record_select($table, $select, array $params=null, $fields=&#039;*&#039;, $ignoremultiple=false)&lt;br /&gt;
  /// Get a single database record as an object which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_record_sql($sql, array $params=null)&lt;br /&gt;
  /// Get a single database record as an object using a SQL statement.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Getting an array of records===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;get_records($table, array $conditions=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0) &lt;br /&gt;
  /// Get a number of records as an array of objects where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;get_records_select($table, $select, array $params=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0) &lt;br /&gt;
  /// Get a number of records as an array of objects which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_records_sql($sql, array $params=null, $limitfrom=0, $limitnum=0)&lt;br /&gt;
  /// Get a number of records as an array of objects using a SQL statement.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;get_records_menu($table, array $conditions=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0) &lt;br /&gt;
  /// Get the first two columns from a number of records as an associative array where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;get_records_select_menu($table, $select, array $params=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0)&lt;br /&gt;
  /// Get the first two columns from a number of records as an associative array which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_records_sql_menu($sql, array $params=null, $limitfrom=0, $limitnum=0)&lt;br /&gt;
  /// Get the first two columns from a number of records as an associative array using a SQL statement.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;get_records_list($table, $field=&#039;&#039;, $values=&#039;&#039;, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=&#039;&#039;, $limitnum=&#039;&#039;) &lt;br /&gt;
  /// Get a number of records as an array of objects where one field match one list of values.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Getting a particular field value from one record===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;get_field($table, $return, array $conditions)&lt;br /&gt;
  /// Get a single field value from a table record where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;get_field_select($table, $return, $select, array $params=null)&lt;br /&gt;
  /// Get a single field value from a table record which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_field_sql($sql, array $params=null)&lt;br /&gt;
  /// Get a single field value (first field) using a SQL statement.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Getting a particular field value from various records===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;get_fieldset_select($table, $return, $select, array $params=null)&lt;br /&gt;
  /// Selects records and return values of chosen field as an array which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_fieldset_sql($sql, array $params=null)&lt;br /&gt;
  /// Selects records and return values (first field) as an array using a SQL statement.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Setting a particular field in the database===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;set_field($table, $newfield, $newvalue, array $conditions=null)&lt;br /&gt;
  /// Set a single field in every table record where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;set_field_select($table, $newfield, $newvalue, $select, array $params=null)&lt;br /&gt;
  /// Set a single field in every table record which match a particular WHERE clause.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Deleting Records===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;delete_records($table, array $conditions=null) &lt;br /&gt;
  /// Delete the records from a table where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;delete_records_select($table, $select, array $params=null)&lt;br /&gt;
  /// Delete one or more records from a table which match a particular WHERE clause.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Inserting Records===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;insert_record($table, $dataobject, $returnid=true, $bulk=false) &lt;br /&gt;
  /// Insert a record into a table and return the &amp;quot;id&amp;quot; field if required.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Updating Records===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;update_record($table, $dataobject, $bulk=false)&lt;br /&gt;
  /// Update a record in a table.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using Recordsets===&lt;br /&gt;
&lt;br /&gt;
Where the number of records to be retrieved from DB is high, the &#039;&#039;&#039;get_records_xxx()&#039;&#039;&#039; functions above are far from optimal, because they use to load all the records in memory at the same time. Under those circumstances, it&#039;s highly recommended to use this &#039;&#039;&#039;get_recordset_xxx()&#039;&#039;&#039; functions instead, which uses one nice mechanism to iterate over all the target records and save a lot of memory.&lt;br /&gt;
&lt;br /&gt;
Only one thing is &#039;&#039;&#039;absolutely important&#039;&#039;&#039;: Don&#039;t forget to close the recordsets after using them! (This will free up a lot of resources in the RDBMS).&lt;br /&gt;
&lt;br /&gt;
Here is the general way to iterate over records using the &#039;&#039;&#039;get_recordset_xxx()&#039;&#039;&#039; functions:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
if ($rs = $DB-&amp;gt;get_recordset(....) {&lt;br /&gt;
    foreach ($rs as $record) {&lt;br /&gt;
     /// Do whatever you want with this record&lt;br /&gt;
    }&lt;br /&gt;
    $rs-&amp;gt;close(); /// Don&#039;t forget to close the recordset!&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And this is the list of available functions (100% paired with the get_records_xxx() above):&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;get_recordset($table, array $conditions=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0) &lt;br /&gt;
  /// Get a number of records as a moodle_recordset where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;get_recordset_select($table, $select, array $params=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0) &lt;br /&gt;
  /// Get a number of records as a moodle_recordset which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_recordset_sql($sql, array $params=null, $limitfrom=0, $limitnum=0);&lt;br /&gt;
  /// Get a number of records as a moodle_recordset using a SQL statement.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;get_recordset_list($table, $field=&#039;&#039;, $values=&#039;&#039;, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=&#039;&#039;, $limitnum=&#039;&#039;) &lt;br /&gt;
  /// Get a number of records as a moodle_recordset where one field matches one list of values.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Delegated transactions===&lt;br /&gt;
&lt;br /&gt;
* Please note some databases do not support transactions (such as the MyISAM MySQL database engine), however all server administrators are strongly encouraged to migrate to databases that support transactions (such as the InnoDB MySQL database engine).&lt;br /&gt;
* Previous versions supported only one level of transaction. Since Moodle 2.0, the DML layer emulates delegated transactions that allow nesting of transactions.&lt;br /&gt;
* Transactions should not be used much in Moodle core; they are intended for various plugins such as web services, enrol and auth plugins.&lt;br /&gt;
* Some subsystems (such as messaging) do not support transactions because is it is not possible to rollback in external systems.&lt;br /&gt;
&lt;br /&gt;
A transaction is started by:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$transaction = $DB-&amp;gt;start_delegated_transaction();&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and finished by:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$transaction-&amp;gt;allow_commit();&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usually a transaction is rolled back when an exception is thrown. &amp;lt;code&amp;gt;$transaction-&amp;gt;rollback($ex);&amp;lt;/code&amp;gt; must be used very carefully because it might break compatibility with databases that do not support transactions. Transactions cannot be used as part of expected code flow; they can be used only as an emergency protection of data consistency.&lt;br /&gt;
&lt;br /&gt;
See more details in [[Development:DB layer 2.0 delegated transactions]] or MDL-20625.&lt;br /&gt;
&lt;br /&gt;
===Helper Functions===&lt;br /&gt;
&lt;br /&gt;
In order have real cross-db compatibility, there are some helper functions used to build SQL fragments based on the DB Moodle is running. Using them we&#039;ll avoid conditional queries here and there and have those &amp;quot;incompatibilities&amp;quot; fixed once and for ever.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;sql_bitand($int1, $int2) &lt;br /&gt;
  /// Returns the SQL text to be used in order to perform one bitwise AND &lt;br /&gt;
  /// operation between 2 integers.&lt;br /&gt;
o $DB-&amp;gt;sql_bitnot($int1) &lt;br /&gt;
  /// Returns the SQL text to be used in order to perform one bitwise NOT &lt;br /&gt;
  /// operation with 1 integer.&lt;br /&gt;
o $DB-&amp;gt;sql_bitor($int1, $int2)&lt;br /&gt;
  /// Returns the SQL text to be used in order to perform one bitwise OR &lt;br /&gt;
  /// operation between 2 integers.&lt;br /&gt;
o $DB-&amp;gt;sql_bitxor($int1, $int2) &lt;br /&gt;
  /// Returns the SQL text to be used in order to perform one bitwise XOR &lt;br /&gt;
  /// operation between 2 integers.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_null_from_clause()&lt;br /&gt;
  /// Returns the FROM clause required by some DBs in all SELECT statements.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_ceil($fieldname)&lt;br /&gt;
  /// Returns the correct CEIL expression applied to fieldname.&lt;br /&gt;
o $DB-&amp;gt;sql_ilike()&lt;br /&gt;
  /// Returns the proper SQL to do LIKE in a case-insensitive way.&lt;br /&gt;
o $DB-&amp;gt;sql_length($fieldname)&lt;br /&gt;
  /// Returns the SQL text to be used to calculate the length in characters of one expression.&lt;br /&gt;
o $DB-&amp;gt;sql_modulo($int1, $int2)&lt;br /&gt;
  /// Returns the SQL text to be used in order to calculate module - remainder after division&lt;br /&gt;
o $DB-&amp;gt;sql_position($needle, $haystack)&lt;br /&gt;
  /// Returns the SQL for returning searching one string for the location of another.&lt;br /&gt;
  /// Note: If using placeholders BOTH in $needle and $haystack, they MUST be named placeholders.&lt;br /&gt;
o $DB-&amp;gt;sql_substr($expr, $start, $length=false)&lt;br /&gt;
  /// Returns the proper substr() SQL text used to extract substrings from DB.&lt;br /&gt;
  /// Note: This fuction has changed in Moodle 2.0 and now at least 2 params are mandatory.&lt;br /&gt;
  /// Note: Now it returns the whole SQL text to be used instead of only the function name.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_cast_char2int($fieldname, $text=false)&lt;br /&gt;
  /// Returns the SQL to be used in order to CAST one CHAR column to INTEGER.&lt;br /&gt;
o $DB-&amp;gt;sql_cast_char2real($fieldname, $text=false)&lt;br /&gt;
  /// Returns the SQL to be used in order to CAST one CHAR column to REAL number.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_compare_text($fieldname, $numchars=32) &lt;br /&gt;
  /// Returns the SQL text to be used to compare one TEXT (clob) column.&lt;br /&gt;
  /// with one VARCHAR column.&lt;br /&gt;
o $DB-&amp;gt;sql_order_by_text($fieldname, $numchars=32)&lt;br /&gt;
  /// Returns the SQL text to be used to order by one TEXT (clob) column.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_concat()&lt;br /&gt;
  /// Returns the proper SQL to do CONCAT between the elements passed.&lt;br /&gt;
o $DB-&amp;gt;sql_concat_join($separator=&amp;quot;&#039; &#039;&amp;quot;, $elements=array())&lt;br /&gt;
  /// Returns the proper SQL to do CONCAT between the elements passed using one separator.&lt;br /&gt;
o $DB-&amp;gt;sql_fullname($first=&#039;firstname&#039;, $last=&#039;lastname&#039;)&lt;br /&gt;
  /// Returns the proper SQL to concatenate $firstname and $lastname.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_isempty($tablename, $fieldname, $nullablefield, $textfield)&lt;br /&gt;
  /// Returns the proper SQL to know if one field is empty.&lt;br /&gt;
o $DB-&amp;gt;sql_isnotempty($tablename, $fieldname, $nullablefield, $textfield)&lt;br /&gt;
  /// Returns the proper SQL to know if one field is not empty.&lt;br /&gt;
o $DB-&amp;gt;sql_empty()&lt;br /&gt;
  /// Returns the empty string char used by every supported DB.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[Development:DML exceptions|DML exceptions]]: New DML code is throwing exceptions instead of returning false if anything goes wrong&lt;br /&gt;
* [[Development:DML drivers|DML drivers]]: Database drivers for new DML layer&lt;br /&gt;
* [[Development:DML functions - pre 2.0|DML functions - pre 2.0]]: &#039;&#039;&#039;(deprecated!)&#039;&#039;&#039; For information valid before Moodle 2.0.&lt;br /&gt;
* [[Development:DDL functions|DDL functions]]: Where all the functions used to handle DB objects ([[wikipedia:Data_Definition_Language|DDL]]) are defined.&lt;br /&gt;
* [[Development:DB layer 2.0 examples|DB layer 2.0 examples]]: To see some code examples using various DML functions.&lt;br /&gt;
* [[Development:DB layer 2.0 migration docs|DB layer 2.0 migration docs]]: Information about how to modify your code to work with the new Moodle 2.0 DB layer.&lt;br /&gt;
* [[Development:DTL functions|DTL functions]]: Exporting, importing and moving of data stored in SQL databases&lt;br /&gt;
&lt;br /&gt;
[[Category:DB]]&lt;br /&gt;
[[Category:XMLDB]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Broken/DML_functions&amp;diff=78610</id>
		<title>Broken/DML functions</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Broken/DML_functions&amp;diff=78610"/>
		<updated>2010-12-03T06:24:10Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* Getting a single record */  get_record_sql syntax was incorrect&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle_2.0}}This page describes the functions available to access data in the Moodle database. You should &#039;&#039;&#039;exclusively&#039;&#039;&#039; use these functions in order to retrieve or modify database content because these functions provide a high level of abstraction and guarantee that your database manipulation will work against different RDBMSes.&lt;br /&gt;
&lt;br /&gt;
Where possible, tricks and examples will be documented here in order to make developers&#039; lives a bit easier. Of course, feel free to clarify, complete and add more information to  this documentation. It will be welcome, absolutely!&lt;br /&gt;
&lt;br /&gt;
== Main info ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important note:&#039;&#039;&#039; All the functions shown on this page are for use in &#039;&#039;&#039;Moodle 2.0 upwards&#039;&#039;&#039;, where we changed the [[Development:DB layer 2.0|DB layer]] to support some new features. If you need information for previous Moodle version, take a look to the [[Development:DML functions - pre 2.0|DML functions - pre 2.0]] page. For a detailed reference of changes, see the [[Development:DB layer 2.0 migration docs|migration docs]].&lt;br /&gt;
&lt;br /&gt;
* All the function calls on this page are public methods of the $DB global object, so you&#039;ll need to &amp;quot;import&amp;quot; it within your functions (not needed in global scripts) with one simple:&lt;br /&gt;
&amp;lt;code php&amp;gt;global $DB;&amp;lt;/code&amp;gt;&lt;br /&gt;
* All the $table parameters in the functions are meant to be the table name &#039;&#039;without&#039;&#039; prefixes.&lt;br /&gt;
&amp;lt;code php&amp;gt;$user = $DB-&amp;gt;get_record(&#039;user&#039;, array(&#039;id&#039;=&amp;gt;&#039;1&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
* When using the xxx_sql() functions, table names must be enclosed between curly braces.&lt;br /&gt;
&amp;lt;code php&amp;gt;$user = $DB-&amp;gt;get_record_sql(&#039;SELECT * FROM {user} WHERE id = ?&#039;, array(1));&amp;lt;/code&amp;gt;&lt;br /&gt;
* All the $conditions parameters in the functions are arrays of fieldname=&amp;gt;fieldvalue elements.&lt;br /&gt;
&amp;lt;code php&amp;gt;$user = $DB-&amp;gt;get_record(&#039;user&#039;, array(&#039;firstname&#039;=&amp;gt;&#039;Martin&#039;, &#039;lastname&#039;=&amp;gt;&#039;Dougiamas&#039;));&amp;lt;/code&amp;gt;&lt;br /&gt;
* All the $params parameters in the functions are arrays of values used to fill placeholders in SQL statements. Both the question mark and named placeholders can be used. Note that named params &#039;&#039;&#039;must be unique&#039;&#039;&#039; even if the value passed is the same.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
/// Question mark placeholders:&lt;br /&gt;
   $DB-&amp;gt;get_record_sql(&#039;SELECT * FROM {user} WHERE firstname = ? AND lastname = ?&#039;, &lt;br /&gt;
                       array(&#039;Martin&#039;, &#039;Dougiamas&#039;));&lt;br /&gt;
&lt;br /&gt;
/// Named placeholders:&lt;br /&gt;
   $DB-&amp;gt;get_record_sql(&#039;SELECT * FROM {user} WHERE firstname = :firstname AND lastname = :lastname&#039;,&lt;br /&gt;
                       array(&#039;firstname&#039;=&amp;gt;&#039;Martin&#039;, &#039;lastname&#039;=&amp;gt;&#039;Dougiamas&#039;));&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The functions ==&lt;br /&gt;
&lt;br /&gt;
===Seeing how many records match a given criteria===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;count_records($table, array $conditions=null) &lt;br /&gt;
  /// Count the records in a table where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;count_records_select($table, $select, array $params=null, $countitem=&amp;quot;COUNT(&#039;x&#039;)&amp;quot;) &lt;br /&gt;
  /// Count the records in a table which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;count_records_sql($sql, array $params=null) &lt;br /&gt;
  /// Get the result of a SQL SELECT COUNT(...) query.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Seeing if one record exists===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;record_exists($table, array $conditions=null) &lt;br /&gt;
  /// Test whether a record exists in a table where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;record_exists_select($table, $select, array $params=null) &lt;br /&gt;
  /// Test whether any records exists in a table which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;record_exists_sql($sql, array $params=null) &lt;br /&gt;
  /// Test whether a SQL SELECT statement returns any records.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Getting a single record===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;get_record($table, array $conditions, $fields=&#039;*&#039;, $ignoremultiple=false) &lt;br /&gt;
  /// Get a single database record as an object where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;get_record_select($table, $select, array $params=null, $fields=&#039;*&#039;, $ignoremultiple=false)&lt;br /&gt;
  /// Get a single database record as an object which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_record_sql($sql, array $params=null)&lt;br /&gt;
  /// Get a single database record as an object using a SQL statement.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Getting an array of records===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;get_records($table, array $conditions=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0) &lt;br /&gt;
  /// Get a number of records as an array of objects where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;get_records_select($table, $select, array $params=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0) &lt;br /&gt;
  /// Get a number of records as an array of objects which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_records_sql($sql, array $params=null, $limitfrom=0, $limitnum=0)&lt;br /&gt;
  /// Get a number of records as an array of objects using a SQL statement.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;get_records_menu($table, array $conditions=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0) &lt;br /&gt;
  /// Get the first two columns from a number of records as an associative array where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;get_records_select_menu($table, $select, array $params=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0)&lt;br /&gt;
  /// Get the first two columns from a number of records as an associative array which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_records_sql_menu($sql, array $params=null, $limitfrom=0, $limitnum=0)&lt;br /&gt;
  /// Get the first two columns from a number of records as an associative array using a SQL statement.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;get_records_list($table, $field=&#039;&#039;, $values=&#039;&#039;, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=&#039;&#039;, $limitnum=&#039;&#039;) &lt;br /&gt;
  /// Get a number of records as an array of objects where one field match one list of values.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Getting a particular field value from one record===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;get_field($table, $return, array $conditions)&lt;br /&gt;
  /// Get a single field value from a table record where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;get_field_select($table, $return, $select, array $params=null)&lt;br /&gt;
  /// Get a single field value from a table record which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_field_sql($sql, array $params=null)&lt;br /&gt;
  /// Get a single field value (first field) using a SQL statement.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Getting a particular field value from various records===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;get_fieldset_select($table, $return, $select, array $params=null)&lt;br /&gt;
  /// Selects records and return values of chosen field as an array which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_fieldset_sql($sql, array $params=null)&lt;br /&gt;
  /// Selects records and return values (first field) as an array using a SQL statement.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Setting a particular field in the database===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;set_field($table, $newfield, $newvalue, array $conditions=null)&lt;br /&gt;
  /// Set a single field in every table record where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;set_field_select($table, $newfield, $newvalue, $select, array $params=null)&lt;br /&gt;
  /// Set a single field in every table record which match a particular WHERE clause.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Deleting Records===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;delete_records($table, array $conditions=null) &lt;br /&gt;
  /// Delete the records from a table where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;delete_records_select($table, $select, array $params=null)&lt;br /&gt;
  /// Delete one or more records from a table which match a particular WHERE clause.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Inserting Records===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;insert_record($table, $dataobject, $returnid=true, $bulk=false) &lt;br /&gt;
  /// Insert a record into a table and return the &amp;quot;id&amp;quot; field if required.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Updating Records===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;update_record($table, $dataobject, $bulk=false)&lt;br /&gt;
  /// Update a record in a table.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using Recordsets===&lt;br /&gt;
&lt;br /&gt;
While the number of records to be retrieved from DB is high, the &#039;&#039;&#039;get_records_xxx()&#039;&#039;&#039; functions above are far from optimal, because they use to load all the records in memory at the same time. Under those circumstances, it&#039;s highly recommended to use this &#039;&#039;&#039;get_recordset_xxx()&#039;&#039;&#039; functions instead, which uses one nice mechanism to iterate over all the target records and save a lot of memory.&lt;br /&gt;
&lt;br /&gt;
Only one thing is &#039;&#039;&#039;absolutely important&#039;&#039;&#039;: Don&#039;t forget to close the recordsets after using them! (This will free up a lot of resources in the RDBMS).&lt;br /&gt;
&lt;br /&gt;
Here is the general way to iterate over records using the &#039;&#039;&#039;get_recordset_xxx()&#039;&#039;&#039; functions:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
if ($rs = $DB-&amp;gt;get_recordset(....) {&lt;br /&gt;
    foreach ($rs as $record) {&lt;br /&gt;
     /// Do whatever you want with this record&lt;br /&gt;
    }&lt;br /&gt;
    $rs-&amp;gt;close(); /// Don&#039;t forget to close the recordset!&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And this is the list of available functions (100% paired with the get_records_xxx() above):&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;get_recordset($table, array $conditions=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0) &lt;br /&gt;
  /// Get a number of records as a moodle_recordset where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;get_recordset_select($table, $select, array $params=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0) &lt;br /&gt;
  /// Get a number of records as a moodle_recordset which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_recordset_sql($sql, array $params=null, $limitfrom=0, $limitnum=0);&lt;br /&gt;
  /// Get a number of records as a moodle_recordset using a SQL statement.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;get_recordset_list($table, $field=&#039;&#039;, $values=&#039;&#039;, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=&#039;&#039;, $limitnum=&#039;&#039;) &lt;br /&gt;
  /// Get a number of records as a moodle_recordset where one field matches one list of values.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Delegated transactions===&lt;br /&gt;
&lt;br /&gt;
* Please note some databases do not support transactions (such as the MyISAM MySQL database engine), however all server administrators are strongly encouraged to migrate to databases that support transactions (such as the InnoDB MySQL database engine).&lt;br /&gt;
* Previous versions supported only one level of transaction. Since Moodle 2.0, the DML layer emulates delegated transactions that allow nesting of transactions.&lt;br /&gt;
* Transactions should not be used much in Moodle core; they are intended for various plugins such as web services, enrol and auth plugins.&lt;br /&gt;
* Some subsystems (such as messaging) do not support transactions because is it is not possible to rollback in external systems.&lt;br /&gt;
&lt;br /&gt;
A transaction is started by:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$transaction = $DB-&amp;gt;start_delegated_transaction();&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and finished by:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$transaction-&amp;gt;allow_commit();&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usually a transaction is rolled back when an exception is thrown. &amp;lt;code&amp;gt;$transaction-&amp;gt;rollback($ex);&amp;lt;/code&amp;gt; must be used very carefully because it might break compatibility with databases that do not support transactions. Transactions cannot be used as part of expected code flow; they can be used only as an emergency protection of data consistency.&lt;br /&gt;
&lt;br /&gt;
See more details in [[Development:DB layer 2.0 delegated transactions]] or MDL-20625.&lt;br /&gt;
&lt;br /&gt;
===Helper Functions===&lt;br /&gt;
&lt;br /&gt;
In order have real cross-db compatibility, there are some helper functions used to build SQL fragments based on the DB Moodle is running. Using them we&#039;ll avoid conditional queries here and there and have those &amp;quot;incompatibilities&amp;quot; fixed once and for ever.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;sql_bitand($int1, $int2) &lt;br /&gt;
  /// Returns the SQL text to be used in order to perform one bitwise AND &lt;br /&gt;
  /// operation between 2 integers.&lt;br /&gt;
o $DB-&amp;gt;sql_bitnot($int1) &lt;br /&gt;
  /// Returns the SQL text to be used in order to perform one bitwise NOT &lt;br /&gt;
  /// operation with 1 integer.&lt;br /&gt;
o $DB-&amp;gt;sql_bitor($int1, $int2)&lt;br /&gt;
  /// Returns the SQL text to be used in order to perform one bitwise OR &lt;br /&gt;
  /// operation between 2 integers.&lt;br /&gt;
o $DB-&amp;gt;sql_bitxor($int1, $int2) &lt;br /&gt;
  /// Returns the SQL text to be used in order to perform one bitwise XOR &lt;br /&gt;
  /// operation between 2 integers.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_null_from_clause()&lt;br /&gt;
  /// Returns the FROM clause required by some DBs in all SELECT statements.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_ceil($fieldname)&lt;br /&gt;
  /// Returns the correct CEIL expression applied to fieldname.&lt;br /&gt;
o $DB-&amp;gt;sql_ilike()&lt;br /&gt;
  /// Returns the proper SQL to do LIKE in a case-insensitive way.&lt;br /&gt;
o $DB-&amp;gt;sql_length($fieldname)&lt;br /&gt;
  /// Returns the SQL text to be used to calculate the length in characters of one expression.&lt;br /&gt;
o $DB-&amp;gt;sql_modulo($int1, $int2)&lt;br /&gt;
  /// Returns the SQL text to be used in order to calculate module - remainder after division&lt;br /&gt;
o $DB-&amp;gt;sql_position($needle, $haystack)&lt;br /&gt;
  /// Returns the SQL for returning searching one string for the location of another.&lt;br /&gt;
  /// Note: If using placeholders BOTH in $needle and $haystack, they MUST be named placeholders.&lt;br /&gt;
o $DB-&amp;gt;sql_substr($expr, $start, $length=false)&lt;br /&gt;
  /// Returns the proper substr() SQL text used to extract substrings from DB.&lt;br /&gt;
  /// Note: This fuction has changed in Moodle 2.0 and now at least 2 params are mandatory.&lt;br /&gt;
  /// Note: Now it returns the whole SQL text to be used instead of only the function name.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_cast_char2int($fieldname, $text=false)&lt;br /&gt;
  /// Returns the SQL to be used in order to CAST one CHAR column to INTEGER.&lt;br /&gt;
o $DB-&amp;gt;sql_cast_char2real($fieldname, $text=false)&lt;br /&gt;
  /// Returns the SQL to be used in order to CAST one CHAR column to REAL number.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_compare_text($fieldname, $numchars=32) &lt;br /&gt;
  /// Returns the SQL text to be used to compare one TEXT (clob) column.&lt;br /&gt;
  /// with one VARCHAR column.&lt;br /&gt;
o $DB-&amp;gt;sql_order_by_text($fieldname, $numchars=32)&lt;br /&gt;
  /// Returns the SQL text to be used to order by one TEXT (clob) column.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_concat()&lt;br /&gt;
  /// Returns the proper SQL to do CONCAT between the elements passed.&lt;br /&gt;
o $DB-&amp;gt;sql_concat_join($separator=&amp;quot;&#039; &#039;&amp;quot;, $elements=array())&lt;br /&gt;
  /// Returns the proper SQL to do CONCAT between the elements passed using one separator.&lt;br /&gt;
o $DB-&amp;gt;sql_fullname($first=&#039;firstname&#039;, $last=&#039;lastname&#039;)&lt;br /&gt;
  /// Returns the proper SQL to concatenate $firstname and $lastname.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_isempty($tablename, $fieldname, $nullablefield, $textfield)&lt;br /&gt;
  /// Returns the proper SQL to know if one field is empty.&lt;br /&gt;
o $DB-&amp;gt;sql_isnotempty($tablename, $fieldname, $nullablefield, $textfield)&lt;br /&gt;
  /// Returns the proper SQL to know if one field is not empty.&lt;br /&gt;
o $DB-&amp;gt;sql_empty()&lt;br /&gt;
  /// Returns the empty string char used by every supported DB.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[Development:DML exceptions|DML exceptions]]: New DML code is throwing exceptions instead of returning false if anything goes wrong&lt;br /&gt;
* [[Development:DML drivers|DML drivers]]: Database drivers for new DML layer&lt;br /&gt;
* [[Development:DML functions - pre 2.0|DML functions - pre 2.0]]: &#039;&#039;&#039;(deprecated!)&#039;&#039;&#039; For information valid before Moodle 2.0.&lt;br /&gt;
* [[Development:DDL functions|DDL functions]]: Where all the functions used to handle DB objects ([[wikipedia:Data_Definition_Language|DDL]]) are defined.&lt;br /&gt;
* [[Development:DB layer 2.0 examples|DB layer 2.0 examples]]: To see some code examples using various DML functions.&lt;br /&gt;
* [[Development:DB layer 2.0 migration docs|DB layer 2.0 migration docs]]: Information about how to modify your code to work with the new Moodle 2.0 DB layer.&lt;br /&gt;
* [[Development:DTL functions|DTL functions]]: Exporting, importing and moving of data stored in SQL databases&lt;br /&gt;
&lt;br /&gt;
[[Category:DB]]&lt;br /&gt;
[[Category:XMLDB]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Broken/DML_functions&amp;diff=78609</id>
		<title>Broken/DML functions</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Broken/DML_functions&amp;diff=78609"/>
		<updated>2010-12-03T06:22:39Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* Getting a single record */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle_2.0}}This page describes the functions available to access data in the Moodle database. You should &#039;&#039;&#039;exclusively&#039;&#039;&#039; use these functions in order to retrieve or modify database content because these functions provide a high level of abstraction and guarantee that your database manipulation will work against different RDBMSes.&lt;br /&gt;
&lt;br /&gt;
Where possible, tricks and examples will be documented here in order to make developers&#039; lives a bit easier. Of course, feel free to clarify, complete and add more information to  this documentation. It will be welcome, absolutely!&lt;br /&gt;
&lt;br /&gt;
== Main info ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important note:&#039;&#039;&#039; All the functions shown on this page are for use in &#039;&#039;&#039;Moodle 2.0 upwards&#039;&#039;&#039;, where we changed the [[Development:DB layer 2.0|DB layer]] to support some new features. If you need information for previous Moodle version, take a look to the [[Development:DML functions - pre 2.0|DML functions - pre 2.0]] page. For a detailed reference of changes, see the [[Development:DB layer 2.0 migration docs|migration docs]].&lt;br /&gt;
&lt;br /&gt;
* All the function calls on this page are public methods of the $DB global object, so you&#039;ll need to &amp;quot;import&amp;quot; it within your functions (not needed in global scripts) with one simple:&lt;br /&gt;
&amp;lt;code php&amp;gt;global $DB;&amp;lt;/code&amp;gt;&lt;br /&gt;
* All the $table parameters in the functions are meant to be the table name &#039;&#039;without&#039;&#039; prefixes.&lt;br /&gt;
&amp;lt;code php&amp;gt;$user = $DB-&amp;gt;get_record(&#039;user&#039;, array(&#039;id&#039;=&amp;gt;&#039;1&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
* When using the xxx_sql() functions, table names must be enclosed between curly braces.&lt;br /&gt;
&amp;lt;code php&amp;gt;$user = $DB-&amp;gt;get_record_sql(&#039;SELECT * FROM {user} WHERE id = ?&#039;, array(1));&amp;lt;/code&amp;gt;&lt;br /&gt;
* All the $conditions parameters in the functions are arrays of fieldname=&amp;gt;fieldvalue elements.&lt;br /&gt;
&amp;lt;code php&amp;gt;$user = $DB-&amp;gt;get_record(&#039;user&#039;, array(&#039;firstname&#039;=&amp;gt;&#039;Martin&#039;, &#039;lastname&#039;=&amp;gt;&#039;Dougiamas&#039;));&amp;lt;/code&amp;gt;&lt;br /&gt;
* All the $params parameters in the functions are arrays of values used to fill placeholders in SQL statements. Both the question mark and named placeholders can be used. Note that named params &#039;&#039;&#039;must be unique&#039;&#039;&#039; even if the value passed is the same.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
/// Question mark placeholders:&lt;br /&gt;
   $DB-&amp;gt;get_record_sql(&#039;SELECT * FROM {user} WHERE firstname = ? AND lastname = ?&#039;, &lt;br /&gt;
                       array(&#039;Martin&#039;, &#039;Dougiamas&#039;));&lt;br /&gt;
&lt;br /&gt;
/// Named placeholders:&lt;br /&gt;
   $DB-&amp;gt;get_record_sql(&#039;SELECT * FROM {user} WHERE firstname = :firstname AND lastname = :lastname&#039;,&lt;br /&gt;
                       array(&#039;firstname&#039;=&amp;gt;&#039;Martin&#039;, &#039;lastname&#039;=&amp;gt;&#039;Dougiamas&#039;));&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The functions ==&lt;br /&gt;
&lt;br /&gt;
===Seeing how many records match a given criteria===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;count_records($table, array $conditions=null) &lt;br /&gt;
  /// Count the records in a table where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;count_records_select($table, $select, array $params=null, $countitem=&amp;quot;COUNT(&#039;x&#039;)&amp;quot;) &lt;br /&gt;
  /// Count the records in a table which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;count_records_sql($sql, array $params=null) &lt;br /&gt;
  /// Get the result of a SQL SELECT COUNT(...) query.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Seeing if one record exists===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;record_exists($table, array $conditions=null) &lt;br /&gt;
  /// Test whether a record exists in a table where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;record_exists_select($table, $select, array $params=null) &lt;br /&gt;
  /// Test whether any records exists in a table which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;record_exists_sql($sql, array $params=null) &lt;br /&gt;
  /// Test whether a SQL SELECT statement returns any records.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Getting a single record===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;get_record($table, array $conditions, $fields=&#039;*&#039;, $ignoremultiple=false) &lt;br /&gt;
  /// Get a single database record as an object where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;get_record_select($table, $select, array $params=null, $fields=&#039;*&#039;, $ignoremultiple=false)&lt;br /&gt;
  /// Get a single database record as an object which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_record_sql($table, $sql, array $params=null)&lt;br /&gt;
  /// Get a single database record as an object using a SQL statement.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Getting an array of records===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;get_records($table, array $conditions=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0) &lt;br /&gt;
  /// Get a number of records as an array of objects where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;get_records_select($table, $select, array $params=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0) &lt;br /&gt;
  /// Get a number of records as an array of objects which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_records_sql($sql, array $params=null, $limitfrom=0, $limitnum=0)&lt;br /&gt;
  /// Get a number of records as an array of objects using a SQL statement.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;get_records_menu($table, array $conditions=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0) &lt;br /&gt;
  /// Get the first two columns from a number of records as an associative array where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;get_records_select_menu($table, $select, array $params=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0)&lt;br /&gt;
  /// Get the first two columns from a number of records as an associative array which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_records_sql_menu($sql, array $params=null, $limitfrom=0, $limitnum=0)&lt;br /&gt;
  /// Get the first two columns from a number of records as an associative array using a SQL statement.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;get_records_list($table, $field=&#039;&#039;, $values=&#039;&#039;, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=&#039;&#039;, $limitnum=&#039;&#039;) &lt;br /&gt;
  /// Get a number of records as an array of objects where one field match one list of values.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Getting a particular field value from one record===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;get_field($table, $return, array $conditions)&lt;br /&gt;
  /// Get a single field value from a table record where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;get_field_select($table, $return, $select, array $params=null)&lt;br /&gt;
  /// Get a single field value from a table record which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_field_sql($sql, array $params=null)&lt;br /&gt;
  /// Get a single field value (first field) using a SQL statement.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Getting a particular field value from various records===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;get_fieldset_select($table, $return, $select, array $params=null)&lt;br /&gt;
  /// Selects records and return values of chosen field as an array which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_fieldset_sql($sql, array $params=null)&lt;br /&gt;
  /// Selects records and return values (first field) as an array using a SQL statement.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Setting a particular field in the database===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;set_field($table, $newfield, $newvalue, array $conditions=null)&lt;br /&gt;
  /// Set a single field in every table record where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;set_field_select($table, $newfield, $newvalue, $select, array $params=null)&lt;br /&gt;
  /// Set a single field in every table record which match a particular WHERE clause.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Deleting Records===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;delete_records($table, array $conditions=null) &lt;br /&gt;
  /// Delete the records from a table where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;delete_records_select($table, $select, array $params=null)&lt;br /&gt;
  /// Delete one or more records from a table which match a particular WHERE clause.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Inserting Records===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;insert_record($table, $dataobject, $returnid=true, $bulk=false) &lt;br /&gt;
  /// Insert a record into a table and return the &amp;quot;id&amp;quot; field if required.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Updating Records===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;update_record($table, $dataobject, $bulk=false)&lt;br /&gt;
  /// Update a record in a table.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using Recordsets===&lt;br /&gt;
&lt;br /&gt;
While the number of records to be retrieved from DB is high, the &#039;&#039;&#039;get_records_xxx()&#039;&#039;&#039; functions above are far from optimal, because they use to load all the records in memory at the same time. Under those circumstances, it&#039;s highly recommended to use this &#039;&#039;&#039;get_recordset_xxx()&#039;&#039;&#039; functions instead, which uses one nice mechanism to iterate over all the target records and save a lot of memory.&lt;br /&gt;
&lt;br /&gt;
Only one thing is &#039;&#039;&#039;absolutely important&#039;&#039;&#039;: Don&#039;t forget to close the recordsets after using them! (This will free up a lot of resources in the RDBMS).&lt;br /&gt;
&lt;br /&gt;
Here is the general way to iterate over records using the &#039;&#039;&#039;get_recordset_xxx()&#039;&#039;&#039; functions:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
if ($rs = $DB-&amp;gt;get_recordset(....) {&lt;br /&gt;
    foreach ($rs as $record) {&lt;br /&gt;
     /// Do whatever you want with this record&lt;br /&gt;
    }&lt;br /&gt;
    $rs-&amp;gt;close(); /// Don&#039;t forget to close the recordset!&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And this is the list of available functions (100% paired with the get_records_xxx() above):&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;get_recordset($table, array $conditions=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0) &lt;br /&gt;
  /// Get a number of records as a moodle_recordset where all the given conditions met.&lt;br /&gt;
o $DB-&amp;gt;get_recordset_select($table, $select, array $params=null, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=0, $limitnum=0) &lt;br /&gt;
  /// Get a number of records as a moodle_recordset which match a particular WHERE clause.&lt;br /&gt;
o $DB-&amp;gt;get_recordset_sql($sql, array $params=null, $limitfrom=0, $limitnum=0);&lt;br /&gt;
  /// Get a number of records as a moodle_recordset using a SQL statement.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;get_recordset_list($table, $field=&#039;&#039;, $values=&#039;&#039;, $sort=&#039;&#039;, $fields=&#039;*&#039;, $limitfrom=&#039;&#039;, $limitnum=&#039;&#039;) &lt;br /&gt;
  /// Get a number of records as a moodle_recordset where one field matches one list of values.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Delegated transactions===&lt;br /&gt;
&lt;br /&gt;
* Please note some databases do not support transactions (such as the MyISAM MySQL database engine), however all server administrators are strongly encouraged to migrate to databases that support transactions (such as the InnoDB MySQL database engine).&lt;br /&gt;
* Previous versions supported only one level of transaction. Since Moodle 2.0, the DML layer emulates delegated transactions that allow nesting of transactions.&lt;br /&gt;
* Transactions should not be used much in Moodle core; they are intended for various plugins such as web services, enrol and auth plugins.&lt;br /&gt;
* Some subsystems (such as messaging) do not support transactions because is it is not possible to rollback in external systems.&lt;br /&gt;
&lt;br /&gt;
A transaction is started by:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$transaction = $DB-&amp;gt;start_delegated_transaction();&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and finished by:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$transaction-&amp;gt;allow_commit();&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usually a transaction is rolled back when an exception is thrown. &amp;lt;code&amp;gt;$transaction-&amp;gt;rollback($ex);&amp;lt;/code&amp;gt; must be used very carefully because it might break compatibility with databases that do not support transactions. Transactions cannot be used as part of expected code flow; they can be used only as an emergency protection of data consistency.&lt;br /&gt;
&lt;br /&gt;
See more details in [[Development:DB layer 2.0 delegated transactions]] or MDL-20625.&lt;br /&gt;
&lt;br /&gt;
===Helper Functions===&lt;br /&gt;
&lt;br /&gt;
In order have real cross-db compatibility, there are some helper functions used to build SQL fragments based on the DB Moodle is running. Using them we&#039;ll avoid conditional queries here and there and have those &amp;quot;incompatibilities&amp;quot; fixed once and for ever.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
o $DB-&amp;gt;sql_bitand($int1, $int2) &lt;br /&gt;
  /// Returns the SQL text to be used in order to perform one bitwise AND &lt;br /&gt;
  /// operation between 2 integers.&lt;br /&gt;
o $DB-&amp;gt;sql_bitnot($int1) &lt;br /&gt;
  /// Returns the SQL text to be used in order to perform one bitwise NOT &lt;br /&gt;
  /// operation with 1 integer.&lt;br /&gt;
o $DB-&amp;gt;sql_bitor($int1, $int2)&lt;br /&gt;
  /// Returns the SQL text to be used in order to perform one bitwise OR &lt;br /&gt;
  /// operation between 2 integers.&lt;br /&gt;
o $DB-&amp;gt;sql_bitxor($int1, $int2) &lt;br /&gt;
  /// Returns the SQL text to be used in order to perform one bitwise XOR &lt;br /&gt;
  /// operation between 2 integers.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_null_from_clause()&lt;br /&gt;
  /// Returns the FROM clause required by some DBs in all SELECT statements.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_ceil($fieldname)&lt;br /&gt;
  /// Returns the correct CEIL expression applied to fieldname.&lt;br /&gt;
o $DB-&amp;gt;sql_ilike()&lt;br /&gt;
  /// Returns the proper SQL to do LIKE in a case-insensitive way.&lt;br /&gt;
o $DB-&amp;gt;sql_length($fieldname)&lt;br /&gt;
  /// Returns the SQL text to be used to calculate the length in characters of one expression.&lt;br /&gt;
o $DB-&amp;gt;sql_modulo($int1, $int2)&lt;br /&gt;
  /// Returns the SQL text to be used in order to calculate module - remainder after division&lt;br /&gt;
o $DB-&amp;gt;sql_position($needle, $haystack)&lt;br /&gt;
  /// Returns the SQL for returning searching one string for the location of another.&lt;br /&gt;
  /// Note: If using placeholders BOTH in $needle and $haystack, they MUST be named placeholders.&lt;br /&gt;
o $DB-&amp;gt;sql_substr($expr, $start, $length=false)&lt;br /&gt;
  /// Returns the proper substr() SQL text used to extract substrings from DB.&lt;br /&gt;
  /// Note: This fuction has changed in Moodle 2.0 and now at least 2 params are mandatory.&lt;br /&gt;
  /// Note: Now it returns the whole SQL text to be used instead of only the function name.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_cast_char2int($fieldname, $text=false)&lt;br /&gt;
  /// Returns the SQL to be used in order to CAST one CHAR column to INTEGER.&lt;br /&gt;
o $DB-&amp;gt;sql_cast_char2real($fieldname, $text=false)&lt;br /&gt;
  /// Returns the SQL to be used in order to CAST one CHAR column to REAL number.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_compare_text($fieldname, $numchars=32) &lt;br /&gt;
  /// Returns the SQL text to be used to compare one TEXT (clob) column.&lt;br /&gt;
  /// with one VARCHAR column.&lt;br /&gt;
o $DB-&amp;gt;sql_order_by_text($fieldname, $numchars=32)&lt;br /&gt;
  /// Returns the SQL text to be used to order by one TEXT (clob) column.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_concat()&lt;br /&gt;
  /// Returns the proper SQL to do CONCAT between the elements passed.&lt;br /&gt;
o $DB-&amp;gt;sql_concat_join($separator=&amp;quot;&#039; &#039;&amp;quot;, $elements=array())&lt;br /&gt;
  /// Returns the proper SQL to do CONCAT between the elements passed using one separator.&lt;br /&gt;
o $DB-&amp;gt;sql_fullname($first=&#039;firstname&#039;, $last=&#039;lastname&#039;)&lt;br /&gt;
  /// Returns the proper SQL to concatenate $firstname and $lastname.&lt;br /&gt;
 &lt;br /&gt;
o $DB-&amp;gt;sql_isempty($tablename, $fieldname, $nullablefield, $textfield)&lt;br /&gt;
  /// Returns the proper SQL to know if one field is empty.&lt;br /&gt;
o $DB-&amp;gt;sql_isnotempty($tablename, $fieldname, $nullablefield, $textfield)&lt;br /&gt;
  /// Returns the proper SQL to know if one field is not empty.&lt;br /&gt;
o $DB-&amp;gt;sql_empty()&lt;br /&gt;
  /// Returns the empty string char used by every supported DB.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[Development:DML exceptions|DML exceptions]]: New DML code is throwing exceptions instead of returning false if anything goes wrong&lt;br /&gt;
* [[Development:DML drivers|DML drivers]]: Database drivers for new DML layer&lt;br /&gt;
* [[Development:DML functions - pre 2.0|DML functions - pre 2.0]]: &#039;&#039;&#039;(deprecated!)&#039;&#039;&#039; For information valid before Moodle 2.0.&lt;br /&gt;
* [[Development:DDL functions|DDL functions]]: Where all the functions used to handle DB objects ([[wikipedia:Data_Definition_Language|DDL]]) are defined.&lt;br /&gt;
* [[Development:DB layer 2.0 examples|DB layer 2.0 examples]]: To see some code examples using various DML functions.&lt;br /&gt;
* [[Development:DB layer 2.0 migration docs|DB layer 2.0 migration docs]]: Information about how to modify your code to work with the new Moodle 2.0 DB layer.&lt;br /&gt;
* [[Development:DTL functions|DTL functions]]: Exporting, importing and moving of data stored in SQL databases&lt;br /&gt;
&lt;br /&gt;
[[Category:DB]]&lt;br /&gt;
[[Category:XMLDB]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Usuari:Bruno_Vernier&amp;diff=78533</id>
		<title>Usuari:Bruno Vernier</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Usuari:Bruno_Vernier&amp;diff=78533"/>
		<updated>2010-11-30T18:03:45Z</updated>

		<summary type="html">&lt;p&gt;Bruno: New page: teacher in Vancouver, British Columbia , Canada&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;teacher in Vancouver, British Columbia , Canada&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Migration_from_MyISAM_to_InnoDB&amp;diff=78480</id>
		<title>Migration from MyISAM to InnoDB</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Migration_from_MyISAM_to_InnoDB&amp;diff=78480"/>
		<updated>2010-11-30T00:34:49Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* Difference between MyISAM and InnoDB */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
See [http://moodle.org/mod/forum/discuss.php?d=162871 Documentation for migration from MyISAM to InnoDB] for the current discussion which prompted the creation of this page. --[[User:Frank Ralf|Frank Ralf]] 11:41, 24 November 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== MySQL Configuration ==&lt;br /&gt;
Before attempting to change the table type, you should:&lt;br /&gt;
* &#039;&#039;&#039;check InnoDB is enabled&#039;&#039;&#039;. Log in to MySQL and run the command [http://dev.mysql.com/doc/refman/5.1/en/show-engines.html SHOW ENGINES]. Make sure that support for InnoDB shows either &amp;quot;YES&amp;quot; or &amp;quot;DEFAULT&amp;quot;.&lt;br /&gt;
* &#039;&#039;&#039;set innodb_file_per_table if required&#039;&#039;&#039;. [http://dev.mysql.com/doc/refman/5.1/en/innodb-multiple-tablespaces.html This setting] can be useful for large installations, but it only affects newly created tables and can&#039;t be applied retrospectively.&lt;br /&gt;
&lt;br /&gt;
== Various Methods described in Moodle Forums (choose one)==&lt;br /&gt;
* run the innodb script as a webpage http://www.YOUR_MOODLE_SITE/admin/innodb.php  (there might be timeout issues on large databases and it only works with mysql)&lt;br /&gt;
* use the CLI script in admin/cli/mysql_engine.php  (requires access to shell, mysql only, and the config.php must only have one moodle instance, but has no timeout issues) &lt;br /&gt;
* use PHPMyAdmin entering Structure view of a table and clicking Operations tab. Look for Storage Engine parameter. This is a tedious task due to the number of tables [http://moodle.org/mod/forum/discuss.php?d=162002]&lt;br /&gt;
* perform a database dump (e.g. mysqldump moodle_database &amp;gt; dump.SQL), use an editor or sed/perl/awk command to find/replace , replacing MyISAM with InnoDB.  Finally, restore back in the server. (e.g. mysql &amp;lt; dump.SQL or equivalent)   &lt;br /&gt;
&lt;br /&gt;
== Difference between MyISAM and InnoDB ==&lt;br /&gt;
* read [http://tag1consulting.com/MySQL_Engines_MyISAM_vs_InnoDB]&lt;br /&gt;
* InnoDB is best for data integrity, not so good for searching large files, and uses up more CPU cycles and storage space than MyISAM equivalent &lt;br /&gt;
* InnoDB is much younger than MyISAM but is becoming increasingly attractive ... but because it is more complex, some utilities written for MyISAM like mysqlhotcopy may not work&lt;br /&gt;
* It is perfectly OK to select InnoDB for certain tables, and MyISAM for others (based on above criteria)&lt;br /&gt;
[[fr:admin/innodb]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Migration_from_MyISAM_to_InnoDB&amp;diff=78479</id>
		<title>Migration from MyISAM to InnoDB</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Migration_from_MyISAM_to_InnoDB&amp;diff=78479"/>
		<updated>2010-11-30T00:33:27Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* Various Methods described in Moodle Forums (choose one) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
See [http://moodle.org/mod/forum/discuss.php?d=162871 Documentation for migration from MyISAM to InnoDB] for the current discussion which prompted the creation of this page. --[[User:Frank Ralf|Frank Ralf]] 11:41, 24 November 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== MySQL Configuration ==&lt;br /&gt;
Before attempting to change the table type, you should:&lt;br /&gt;
* &#039;&#039;&#039;check InnoDB is enabled&#039;&#039;&#039;. Log in to MySQL and run the command [http://dev.mysql.com/doc/refman/5.1/en/show-engines.html SHOW ENGINES]. Make sure that support for InnoDB shows either &amp;quot;YES&amp;quot; or &amp;quot;DEFAULT&amp;quot;.&lt;br /&gt;
* &#039;&#039;&#039;set innodb_file_per_table if required&#039;&#039;&#039;. [http://dev.mysql.com/doc/refman/5.1/en/innodb-multiple-tablespaces.html This setting] can be useful for large installations, but it only affects newly created tables and can&#039;t be applied retrospectively.&lt;br /&gt;
&lt;br /&gt;
== Various Methods described in Moodle Forums (choose one)==&lt;br /&gt;
* run the innodb script as a webpage http://www.YOUR_MOODLE_SITE/admin/innodb.php  (there might be timeout issues on large databases and it only works with mysql)&lt;br /&gt;
* use the CLI script in admin/cli/mysql_engine.php  (requires access to shell, mysql only, and the config.php must only have one moodle instance, but has no timeout issues) &lt;br /&gt;
* use PHPMyAdmin entering Structure view of a table and clicking Operations tab. Look for Storage Engine parameter. This is a tedious task due to the number of tables [http://moodle.org/mod/forum/discuss.php?d=162002]&lt;br /&gt;
* perform a database dump (e.g. mysqldump moodle_database &amp;gt; dump.SQL), use an editor or sed/perl/awk command to find/replace , replacing MyISAM with InnoDB.  Finally, restore back in the server. (e.g. mysql &amp;lt; dump.SQL or equivalent)   &lt;br /&gt;
&lt;br /&gt;
== Difference between MyISAM and InnoDB ==&lt;br /&gt;
* read [http://tag1consulting.com/MySQL_Engines_MyISAM_vs_InnoDB]&lt;br /&gt;
* InnoDB is best for data integrity, not so good for searching large files, and uses up more CPU cycles and storage space than MyISAM equivalent &lt;br /&gt;
* InnoDB is much younger than MyISAM but is becoming increasingly attractive ... but because it is more complex, some utilities written for MyISAM like mysqlhotcopy may not work&lt;br /&gt;
&lt;br /&gt;
[[fr:admin/innodb]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Migration_from_MyISAM_to_InnoDB&amp;diff=78478</id>
		<title>Migration from MyISAM to InnoDB</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Migration_from_MyISAM_to_InnoDB&amp;diff=78478"/>
		<updated>2010-11-30T00:24:10Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* Various Methods described in Moodle Forums */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
See [http://moodle.org/mod/forum/discuss.php?d=162871 Documentation for migration from MyISAM to InnoDB] for the current discussion which prompted the creation of this page. --[[User:Frank Ralf|Frank Ralf]] 11:41, 24 November 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== MySQL Configuration ==&lt;br /&gt;
Before attempting to change the table type, you should:&lt;br /&gt;
* &#039;&#039;&#039;check InnoDB is enabled&#039;&#039;&#039;. Log in to MySQL and run the command [http://dev.mysql.com/doc/refman/5.1/en/show-engines.html SHOW ENGINES]. Make sure that support for InnoDB shows either &amp;quot;YES&amp;quot; or &amp;quot;DEFAULT&amp;quot;.&lt;br /&gt;
* &#039;&#039;&#039;set innodb_file_per_table if required&#039;&#039;&#039;. [http://dev.mysql.com/doc/refman/5.1/en/innodb-multiple-tablespaces.html This setting] can be useful for large installations, but it only affects newly created tables and can&#039;t be applied retrospectively.&lt;br /&gt;
&lt;br /&gt;
== Various Methods described in Moodle Forums (choose one)==&lt;br /&gt;
* run the innodb script as a webpage http://www.YOUR_MOODLE_SITE/admin/innodb.php  (there might be timeout issues on large databases and it only works with mysql)&lt;br /&gt;
* use the CLI script in admin/cli/mysql_engine.php  (requires access to shell, mysql only, and the config.php must only have one moodle instance, but has no timeout issues) &lt;br /&gt;
* use PHPMyAdmin entering Structure view of a table and clicking Operations tab. Look for Storage Engine parameter. This is a tedious task due to the number of tables [http://moodle.org/mod/forum/discuss.php?d=162002]&lt;br /&gt;
* perform a database dump (e.g. mysqldump moodle_database &amp;gt; dump.SQL), use an editor or sed/perl/awk command to find/replace , replacing MyISAM with InnoDB.  Finally, restore back in the server. (e.g. mysql &amp;lt; dump.SQL or equivalent)   &lt;br /&gt;
&lt;br /&gt;
[[fr:admin/innodb]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Migration_from_MyISAM_to_InnoDB&amp;diff=78477</id>
		<title>Migration from MyISAM to InnoDB</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Migration_from_MyISAM_to_InnoDB&amp;diff=78477"/>
		<updated>2010-11-30T00:20:47Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* Various Methods described in Moodle Forums */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
See [http://moodle.org/mod/forum/discuss.php?d=162871 Documentation for migration from MyISAM to InnoDB] for the current discussion which prompted the creation of this page. --[[User:Frank Ralf|Frank Ralf]] 11:41, 24 November 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== MySQL Configuration ==&lt;br /&gt;
Before attempting to change the table type, you should:&lt;br /&gt;
* &#039;&#039;&#039;check InnoDB is enabled&#039;&#039;&#039;. Log in to MySQL and run the command [http://dev.mysql.com/doc/refman/5.1/en/show-engines.html SHOW ENGINES]. Make sure that support for InnoDB shows either &amp;quot;YES&amp;quot; or &amp;quot;DEFAULT&amp;quot;.&lt;br /&gt;
* &#039;&#039;&#039;set innodb_file_per_table if required&#039;&#039;&#039;. [http://dev.mysql.com/doc/refman/5.1/en/innodb-multiple-tablespaces.html This setting] can be useful for large installations, but it only affects newly created tables and can&#039;t be applied retrospectively.&lt;br /&gt;
&lt;br /&gt;
== Various Methods described in Moodle Forums==&lt;br /&gt;
* run the innodb script as a webpage http://www.YOUR_MOODLE_SITE/admin/innodb.php  (there might be timeout issues on large databases and it only works with mysql)&lt;br /&gt;
* use the CLI script in admin/cli/mysql_engine.php  (requires access to shell, mysql only, and the config.php must only have one moodle instance, but has no timeout issues) &lt;br /&gt;
* use PHPMyAdmin entering Structure view of a table and clicking Operations tab. Look for Storage Engine parameter. This is a tedious task due to the number of tables [http://moodle.org/mod/forum/discuss.php?d=162002]&lt;br /&gt;
* perform a database dump (e.g. mysqldump moodle_database &amp;gt; dump.SQL), use an editor or sed/perl/awk command to find/replace , replacing MyISAM with InnoDB.  Finally, restore back in the server. (e.g. mysql &amp;lt; dump.SQL or equivalent)   &lt;br /&gt;
&lt;br /&gt;
[[fr:admin/innodb]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Migration_from_MyISAM_to_InnoDB&amp;diff=78476</id>
		<title>Migration from MyISAM to InnoDB</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Migration_from_MyISAM_to_InnoDB&amp;diff=78476"/>
		<updated>2010-11-30T00:07:14Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* Various Methods described in Moodle Forums */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
See [http://moodle.org/mod/forum/discuss.php?d=162871 Documentation for migration from MyISAM to InnoDB] for the current discussion which prompted the creation of this page. --[[User:Frank Ralf|Frank Ralf]] 11:41, 24 November 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== MySQL Configuration ==&lt;br /&gt;
Before attempting to change the table type, you should:&lt;br /&gt;
* &#039;&#039;&#039;check InnoDB is enabled&#039;&#039;&#039;. Log in to MySQL and run the command [http://dev.mysql.com/doc/refman/5.1/en/show-engines.html SHOW ENGINES]. Make sure that support for InnoDB shows either &amp;quot;YES&amp;quot; or &amp;quot;DEFAULT&amp;quot;.&lt;br /&gt;
* &#039;&#039;&#039;set innodb_file_per_table if required&#039;&#039;&#039;. [http://dev.mysql.com/doc/refman/5.1/en/innodb-multiple-tablespaces.html This setting] can be useful for large installations, but it only affects newly created tables and can&#039;t be applied retrospectively.&lt;br /&gt;
&lt;br /&gt;
== Various Methods described in Moodle Forums==&lt;br /&gt;
* run the innodb script as a webpage http://www.YOUR_MOODLE_SITE/admin/innodb.php  (there might be timeout issues on large databases and it only works with mysql)&lt;br /&gt;
* use the CLI script in admin/cli/mysql_engine.php  (requires access to shell, mysql only, and the config.php must only have one moodle instance, but has no timeout issues) &lt;br /&gt;
* use PHPMyAdmin entering Structure view of a table and clicking Operations tab. Look for Storage Engine parameter. This is a tedious task due to the number of tables [http://moodle.org/mod/forum/discuss.php?d=162002]&lt;br /&gt;
&lt;br /&gt;
[[fr:admin/innodb]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Migration_from_MyISAM_to_InnoDB&amp;diff=78475</id>
		<title>Migration from MyISAM to InnoDB</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Migration_from_MyISAM_to_InnoDB&amp;diff=78475"/>
		<updated>2010-11-30T00:06:11Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* Various Methods described in Moodle Forums */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
See [http://moodle.org/mod/forum/discuss.php?d=162871 Documentation for migration from MyISAM to InnoDB] for the current discussion which prompted the creation of this page. --[[User:Frank Ralf|Frank Ralf]] 11:41, 24 November 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== MySQL Configuration ==&lt;br /&gt;
Before attempting to change the table type, you should:&lt;br /&gt;
* &#039;&#039;&#039;check InnoDB is enabled&#039;&#039;&#039;. Log in to MySQL and run the command [http://dev.mysql.com/doc/refman/5.1/en/show-engines.html SHOW ENGINES]. Make sure that support for InnoDB shows either &amp;quot;YES&amp;quot; or &amp;quot;DEFAULT&amp;quot;.&lt;br /&gt;
* &#039;&#039;&#039;set innodb_file_per_table if required&#039;&#039;&#039;. [http://dev.mysql.com/doc/refman/5.1/en/innodb-multiple-tablespaces.html This setting] can be useful for large installations, but it only affects newly created tables and can&#039;t be applied retrospectively.&lt;br /&gt;
&lt;br /&gt;
== Various Methods described in Moodle Forums==&lt;br /&gt;
* run the innodb script as a webpage http://www.mymoodle.com/admin/innodb.php  (there might be timeout issues on large databases and it only works with mysql)&lt;br /&gt;
* use the CLI script in admin/cli/mysql_engine.php  (requires access to shell, mysql only, and the config.php must only have one moodle instance) &lt;br /&gt;
* use PHPMyAdmin entering Structure view of a table and clicking Operations tab. Look for Storage Engine parameter. This is a tedious task due to the number of tables [http://moodle.org/mod/forum/discuss.php?d=162002]&lt;br /&gt;
&lt;br /&gt;
[[fr:admin/innodb]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Migration_from_MyISAM_to_InnoDB&amp;diff=78474</id>
		<title>Migration from MyISAM to InnoDB</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Migration_from_MyISAM_to_InnoDB&amp;diff=78474"/>
		<updated>2010-11-29T23:46:46Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* Various Methods described in Moodle Forums */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
See [http://moodle.org/mod/forum/discuss.php?d=162871 Documentation for migration from MyISAM to InnoDB] for the current discussion which prompted the creation of this page. --[[User:Frank Ralf|Frank Ralf]] 11:41, 24 November 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== MySQL Configuration ==&lt;br /&gt;
Before attempting to change the table type, you should:&lt;br /&gt;
* &#039;&#039;&#039;check InnoDB is enabled&#039;&#039;&#039;. Log in to MySQL and run the command [http://dev.mysql.com/doc/refman/5.1/en/show-engines.html SHOW ENGINES]. Make sure that support for InnoDB shows either &amp;quot;YES&amp;quot; or &amp;quot;DEFAULT&amp;quot;.&lt;br /&gt;
* &#039;&#039;&#039;set innodb_file_per_table if required&#039;&#039;&#039;. [http://dev.mysql.com/doc/refman/5.1/en/innodb-multiple-tablespaces.html This setting] can be useful for large installations, but it only affects newly created tables and can&#039;t be applied retrospectively.&lt;br /&gt;
&lt;br /&gt;
== Various Methods described in Moodle Forums==&lt;br /&gt;
* use the CLI script in admin/cli/mysql_engine.php  (requires access to shell, mysql only, and the config.php must only have one moodle instance) &lt;br /&gt;
* use PHPMyAdmin entering Structure view of a table and clicking Operations tab. Look for Storage Engine parameter. This is a tedious task due to the number of tables [http://moodle.org/mod/forum/discuss.php?d=162002]&lt;br /&gt;
&lt;br /&gt;
[[fr:admin/innodb]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Migration_from_MyISAM_to_InnoDB&amp;diff=78473</id>
		<title>Migration from MyISAM to InnoDB</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Migration_from_MyISAM_to_InnoDB&amp;diff=78473"/>
		<updated>2010-11-29T23:44:52Z</updated>

		<summary type="html">&lt;p&gt;Bruno: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
See [http://moodle.org/mod/forum/discuss.php?d=162871 Documentation for migration from MyISAM to InnoDB] for the current discussion which prompted the creation of this page. --[[User:Frank Ralf|Frank Ralf]] 11:41, 24 November 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== MySQL Configuration ==&lt;br /&gt;
Before attempting to change the table type, you should:&lt;br /&gt;
* &#039;&#039;&#039;check InnoDB is enabled&#039;&#039;&#039;. Log in to MySQL and run the command [http://dev.mysql.com/doc/refman/5.1/en/show-engines.html SHOW ENGINES]. Make sure that support for InnoDB shows either &amp;quot;YES&amp;quot; or &amp;quot;DEFAULT&amp;quot;.&lt;br /&gt;
* &#039;&#039;&#039;set innodb_file_per_table if required&#039;&#039;&#039;. [http://dev.mysql.com/doc/refman/5.1/en/innodb-multiple-tablespaces.html This setting] can be useful for large installations, but it only affects newly created tables and can&#039;t be applied retrospectively.&lt;br /&gt;
&lt;br /&gt;
== Various Methods described in Moodle Forums==&lt;br /&gt;
* use the CLI script in admin/cli/mysql_engine.php  (requires access to shell, mysql only, and the config.php must only have one moodle instance) &lt;br /&gt;
&lt;br /&gt;
[[fr:admin/innodb]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=MNet&amp;diff=78406</id>
		<title>MNet</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=MNet&amp;diff=78406"/>
		<updated>2010-11-29T01:05:18Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The network feature allows a Moodle administrator to establish a link with another Moodle, and to share some resources with the users of that Moodle. This features was introduced in Moodle 1.8.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
The initial release of MNet is bundled with a Authentication Plugin, which makes single-sign-on between Moodles possible. A user with the username &amp;lt;em&amp;gt;jody&amp;lt;/em&amp;gt; logs in to her Moodle server as normal, and clicks on a link that takes her to a page on another Moodle server. Normally, she would have only the privileges of a guest on the remote Moodle, but behind the scenes, single-sign-on has established a fully authenticated session for Jody on the remote site.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039;  MNet requires the use of &#039;&#039;&#039;xmlrpc&#039;&#039;&#039;. Please go to your phpinfo page if you are interested in using this and search for --with-xmlrpc.  If your php has not been compiled with xmlrpc then you need to address that first! At present it appears that PEAR xmlrpc will not work.&lt;br /&gt;
[[Image:Administration Block Users Authentication MoodleNetwork.jpg|thumb|MNet setting in &#039;&#039;Admin &amp;gt; User &amp;gt; Authentication &amp;gt; Moodle Network]]&lt;br /&gt;
&lt;br /&gt;
==Security==&lt;br /&gt;
The MNet feature requires that your server has the &#039;&#039;&#039;Curl&#039;&#039;&#039; and &#039;&#039;&#039;OpenSSL&#039;&#039;&#039; extensions installed. When you install or upgrade to Moodle 1.8, your system will generate a new OpenSSL certificate for encrypted communication with other Moodles, and will thereafter rotate encryption keys on a monthly basis (approx).&lt;br /&gt;
&lt;br /&gt;
Communication takes place over an XML-RPC transport, and the XML-RPC documents are wrapped first in an XMLDSIG (XML digital signature) envelope, and then in an XMLENC (XML encryption) envelope. The encryption all happens within PHP, and does not require an https (Apache SSL) server.&lt;br /&gt;
&lt;br /&gt;
References:&lt;br /&gt;
*[http://www.w3.org/TR/xmldsig-core/ XML Digital Signatures]&lt;br /&gt;
*[http://www.w3.org/TR/xmlenc-core/ XML Encryption]&lt;br /&gt;
&lt;br /&gt;
A special mode can be enabled which would allow a machine with a specified IP address to make calls to the XML-RPC layer without using either encryption or signature envelopes. This mode is provided to enable Moodle to communicate with other software systems in which the integration of signatures and encryption might be prohibitively difficult. It is not envisioned that unencrypted inter-Moodle networking will ever be enabled.&lt;br /&gt;
&lt;br /&gt;
==Peer to Peer Network==&lt;br /&gt;
&lt;br /&gt;
This is the basic layout of the system. It can be very useful to run one Moodle per faculty or departments, each with its own user management, and yet permit users to roam across the Moodle installs... subject to permissions of course. &lt;br /&gt;
&lt;br /&gt;
===Setup===&lt;br /&gt;
&lt;br /&gt;
The instructions will cover 2 Moodle installations: MoodleA and MoodleB. Both are installed correctly and have never had a Moodle Network configuration.&lt;br /&gt;
&lt;br /&gt;
Note: If you experience problems, ensure debugging is turned on in &#039;&#039;Site Administration &amp;gt; Server &amp;gt; Debugging&#039;&#039;. Extra diagnostic messages may be displayed (particularly from Moodle 1.9.2)&lt;br /&gt;
&lt;br /&gt;
# Get them to talk to each other&lt;br /&gt;
## Ensure &#039;&#039;Admin &amp;gt; Server &amp;gt; Environment&#039;&#039; indicates you have curl installed&lt;br /&gt;
## If MoodleA and MoodleB are hosted in the same domain, ensure they have a different cookie prefix. Note that changing the cookie prefix will log you out! You can change the cookie prefix via &#039;&#039;Admin &amp;gt; Server &amp;gt; Session Handling&#039;&#039;.&lt;br /&gt;
## On both, go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Settings&#039;&#039; and turn Networking ON.&lt;br /&gt;
## On MoodleA go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Peers&#039;&#039; - put the URL of MoodleB under &amp;quot;Add New Host&amp;quot; and click Add. The URL should include the directory where your Moodle code is located, for example &#039;&#039;www.mymoodle.org/moodle&#039;&#039;.&lt;br /&gt;
## Do the equivalent on MoodleB.&lt;br /&gt;
# Get user roaming going&lt;br /&gt;
## (skip this step for moodle 2.0 sites [http://moodle.org/mod/forum/discuss.php?d=141491] ) &#039;&#039; On both, go to &#039;&#039;Administration &amp;gt; Plugins &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039; in 2.0 onwards or &#039;&#039;Administration &amp;gt; Users &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039; in 1.9 and enable Moodle Network authentication plugin. Click on &#039;Settings&#039; and enable auto_add_remote_users.&#039;&#039;&lt;br /&gt;
## On MoodleA go to &#039;&#039;Admin &amp;gt; Networking &amp;gt; (Manage) Peers&#039;&#039;, click on &#039;MoodleB&#039;, and click on &#039;Services&#039;. Enable SSO-IDP publish and subscribe, and SSO-SP publish and subscribe.&lt;br /&gt;
## Do the equivalent on MoodleB.&lt;br /&gt;
## On both, go to &#039;&#039;Admin &amp;gt; Users &amp;gt; Permissions &amp;gt; Define Roles&#039;&#039;, only roles that have &amp;quot;Roam to a remote Moodle moodle/site:mnetlogintoremote&amp;quot; will be allowed to roam. Grant the privilege as appropriate.&lt;br /&gt;
## On both, go to the homepage, and add the &#039;Network Servers&#039; block.&lt;br /&gt;
## To test, it is recommended to use a different browser (even on a different machine) that is logged in to neither. Login to MoodleA with a non-administrator account that has the permissions to roam. You should see the Network Servers block, and clicking on it you should go to MoodleB with a newly autocreated account. &lt;br /&gt;
# Get remote enrolments going -- this is optional. It allows an administrator of MoodleB to enrol users that are &amp;quot;native&amp;quot; to MoodleB in remote courses in MoodleA, and viceversa.&lt;br /&gt;
## On both, go to &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Enrolments &amp;gt; Manage enrol plugins&#039;&#039; in 2.0 onwards or &#039;&#039;Administration &amp;gt; Courses &amp;gt; Enrolments&#039;&#039; pre-2.0 and enable Moodle Network enrolment plugin (click Save). Click on &#039;Edit&#039; and enable &#039;allow_allcourses&#039; or select some courses or categories to be remotely enrolled.&lt;br /&gt;
## On MoodleA go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Peers&#039;&#039;, click on &#039;MoodleB&#039;, and click on &#039;Services&#039;. Enable Enrolment publish and subscribe.&lt;br /&gt;
## Do the equivalent on MoodleB.&lt;br /&gt;
## To use, in MoodleA go to &#039;&#039;Admin &amp;gt; Networking &amp;gt; Enrolments&#039;&#039;. You will see MoodleB listed. Click on MoodleB and you will see a list of courses that MoodleB offers for remote enrolment. Select the course you want, and then enroll the users you want to that course.&lt;br /&gt;
&lt;br /&gt;
===Using it===&lt;br /&gt;
&lt;br /&gt;
==Connecting to a Mnet hub==&lt;br /&gt;
A Mnet hub (do not confuse it with the [[Community hub]] project of Moodle 2.0) is a Moodle server that is configured to accept connections from other Moodle servers, and to provide a set of services to users of these other servers. This guideline will direct you to connect to a Mnet hub, assess the services it has to offer, and enable those services for your users.&lt;br /&gt;
&lt;br /&gt;
===Setup===&lt;br /&gt;
# Get talking to the Hub&lt;br /&gt;
## Ensure that the &#039;&#039;Admin &amp;gt; Server &amp;gt; Environment&#039;&#039; page indicates you have curl and openssl installed&lt;br /&gt;
## Go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Settings&#039;&#039; and turn Networking on&lt;br /&gt;
## Go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Peers&#039;&#039; and enter the URL of Mnet Hub under &amp;quot;Add New Host&amp;quot;. Click &amp;lt;em&amp;gt;Add&amp;lt;/em&amp;gt;&lt;br /&gt;
## The host details for the Mnet Hub should appear with the Site Name field already populated. Click &amp;lt;em&amp;gt;Save changes&amp;lt;/em&amp;gt;&lt;br /&gt;
## The details will be written to your database and two new tabs will appear in this window: &#039;Services&#039; and &#039;Logs&#039;. Click &amp;lt;em&amp;gt;Services&amp;lt;/em&amp;gt;&lt;br /&gt;
##A list of services will appear, each with a checkbox for &#039;publish&#039; and &#039;subscribe&#039;. Check the checkboxes for any services you want to publish or subscribe to&lt;br /&gt;
&lt;br /&gt;
===Using it===&lt;br /&gt;
If the Mnet Hub has already enabled a service for you, there will be a tick alongside the appropriate checkbox, for example: if the Hub is &amp;lt;em&amp;gt;publishing&amp;lt;/em&amp;gt; Moodle Networked Enrolment, then a tick will appear alongside the &amp;lt;em&amp;gt;subscribe&amp;lt;/em&amp;gt; checkbox for this service. Note that in order to enable some functionality, prominently &amp;lt;em&amp;gt;single-sign-on&amp;lt;/em&amp;gt;, you may have to &amp;lt;em&amp;gt;publish&amp;lt;/em&amp;gt; a service, e.g. the &amp;lt;em&amp;gt;Identity Provider&amp;lt;/em&amp;gt; service. The Mnet Hub will access this service on your Moodle, asking it to authenticate your users.&lt;br /&gt;
# Enable Roaming&lt;br /&gt;
## Subscribe to &amp;lt;em&amp;gt;SSO (Service Provider)&amp;lt;/em&amp;gt; by checking the box&lt;br /&gt;
## Publish &amp;lt;em&amp;gt;SSO (Identity Provider)&amp;lt;/em&amp;gt; by checking the box&lt;br /&gt;
## Click &amp;lt;em&amp;gt;Save changes&amp;lt;/em&amp;gt;&lt;br /&gt;
## Go to &#039;&#039;Admin &amp;gt; Users &amp;gt; Permissions &amp;gt; Define Roles&#039;&#039;, and grant the capability &amp;lt;em&amp;gt;Roam to a remote Moodle moodle/site:mnetlogintoremote&amp;lt;/em&amp;gt; to an appropriate role&lt;br /&gt;
## Go to &#039;&#039;Administration &amp;gt; Plugins &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039; in 2.0 onwards or &#039;&#039;Administration &amp;gt; Users &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039; in 1.9 and enable the &amp;lt;em&amp;gt;Moodle Network authentication&amp;lt;/em&amp;gt; plugin&lt;br /&gt;
## Go to your homepage, turn on editing, and add the &#039;Network Servers&#039; block&lt;br /&gt;
## Using a different web-browser, log on as a non-admin user who inhabits the role you granted the roaming capability to&lt;br /&gt;
## Note that the Mnet Hub is listed in the Network Servers block on the homepage. Click on the link to that server&lt;br /&gt;
## Some of your user details will be transferred to the Mnet Hub server, and a browsing session will be started for you as if you had logged on there directly&lt;br /&gt;
# Enable Networked Enrolment&lt;br /&gt;
## Return to the web browser you&#039;ve been using as the site administrator&lt;br /&gt;
## Go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Peers&#039;&#039; and click on the entry for the Mnet Hub.&lt;br /&gt;
## Click on the Services tab&lt;br /&gt;
## Subscribe to &amp;lt;em&amp;gt;Moodle Networked Enrolment&amp;lt;/em&amp;gt;&lt;br /&gt;
## Go to &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Enrolments &amp;gt; Manage enrol plugins&#039;&#039; in 2.0 onwards or &#039;&#039;Administration &amp;gt; Courses &amp;gt; Enrolments&#039;&#039; pre-2.0 and enable the &amp;lt;em&amp;gt;Moodle Network enrolment&amp;lt;/em&amp;gt; plugin. Click &amp;lt;em&amp;gt;Save changes&amp;lt;/em&amp;gt;&lt;br /&gt;
## Click on &amp;lt;em&amp;gt;edit&amp;lt;/em&amp;gt; to view the details for networked enrolments.&lt;br /&gt;
## Go to &#039;&#039;Admin &amp;gt; Networking &amp;gt; Enrolments&#039;&#039; to see a list of Moodle servers that offer this service to you&lt;br /&gt;
## Click on a server name to view a list of courses that the server offers to your users&lt;br /&gt;
## Click on a course name, to view a list users that you can enrol in this course&lt;br /&gt;
## Enrol users&lt;br /&gt;
## Profit!&lt;br /&gt;
&lt;br /&gt;
==Running a Mnet hub==&lt;br /&gt;
A Mnet hub is a regular Moodle site that runs in a special mode. As a Moodle Administrator, when you add another Moodle site to your list of network peers, your Moodle will contact that site to find out what it is called, and to request its public key for encrypted communication. Normally, the remote server will simply provide this information without making any record of the transaction.&lt;br /&gt;
&lt;br /&gt;
A Mnet hub is different. As soon as you add an entry for a Mnet hub to your system, the Mnet hub will create an entry for your server in its list of hosts, and may immediately begin to offer services to the users of your site.&lt;br /&gt;
&lt;br /&gt;
This section will guide you to set up a Mnet hub, and select services to offer to all comers.&lt;br /&gt;
&lt;br /&gt;
===Setup===&lt;br /&gt;
# Enable Networking&lt;br /&gt;
## Ensure that the &#039;&#039;Admin &amp;gt; Server &amp;gt; Environment&#039;&#039; page indicates you have curl and openssl installed&lt;br /&gt;
## Go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Settings&#039;&#039; and turn Networking on &lt;br /&gt;
## Go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Peers&#039;&#039; and tick the checkbox for &amp;lt;em&amp;gt;Register all hosts&amp;lt;/em&amp;gt;. Click on &amp;lt;em&amp;gt;Save Changes&amp;lt;/em&amp;gt;&lt;br /&gt;
## On the same page, the first entry in your list of hosts should be &amp;lt;em&amp;gt;All hosts&amp;lt;/em&amp;gt;. Click this link&lt;br /&gt;
## Click on &amp;lt;em&amp;gt;Services&amp;lt;/em&amp;gt; and enable any services you want to offer to all comers&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[Moodle Network FAQ]]&lt;br /&gt;
* [[Development:Moodle Network|Moodle Network development notes]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=6976 MNet forum]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/discuss.php?d=92749 Examples of how people are using Moodle networks] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
[[Category:Enrolment]]&lt;br /&gt;
[[Category:MNet]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Réseau Moodle]]&lt;br /&gt;
[[ja:Moodleネットワーク]]&lt;br /&gt;
[[es:Red Moodle]]&lt;br /&gt;
[[cs:Síťové služby]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=MNet&amp;diff=78405</id>
		<title>MNet</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=MNet&amp;diff=78405"/>
		<updated>2010-11-29T00:34:53Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The network feature allows a Moodle administrator to establish a link with another Moodle, and to share some resources with the users of that Moodle. This features was introduced in Moodle 1.8.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
The initial release of MNet is bundled with a Authentication Plugin, which makes single-sign-on between Moodles possible. A user with the username &amp;lt;em&amp;gt;jody&amp;lt;/em&amp;gt; logs in to her Moodle server as normal, and clicks on a link that takes her to a page on another Moodle server. Normally, she would have only the privileges of a guest on the remote Moodle, but behind the scenes, single-sign-on has established a fully authenticated session for Jody on the remote site.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039;  MNet requires the use of &#039;&#039;&#039;xmlrpc&#039;&#039;&#039;. Please go to your phpinfo page if you are interested in using this and search for --with-xmlrpc.  If your php has not been compiled with xmlrpc then you need to address that first! At present it appears that PEAR xmlrpc will not work.&lt;br /&gt;
[[Image:Administration Block Users Authentication MoodleNetwork.jpg|thumb|MNet setting in &#039;&#039;Admin &amp;gt; User &amp;gt; Authentication &amp;gt; Moodle Network]]&lt;br /&gt;
&lt;br /&gt;
==Security==&lt;br /&gt;
The MNet feature requires that your server has the &#039;&#039;&#039;Curl&#039;&#039;&#039; and &#039;&#039;&#039;OpenSSL&#039;&#039;&#039; extensions installed. When you install or upgrade to Moodle 1.8, your system will generate a new OpenSSL certificate for encrypted communication with other Moodles, and will thereafter rotate encryption keys on a monthly basis (approx).&lt;br /&gt;
&lt;br /&gt;
Communication takes place over an XML-RPC transport, and the XML-RPC documents are wrapped first in an XMLDSIG (XML digital signature) envelope, and then in an XMLENC (XML encryption) envelope. The encryption all happens within PHP, and does not require an https (Apache SSL) server.&lt;br /&gt;
&lt;br /&gt;
References:&lt;br /&gt;
*[http://www.w3.org/TR/xmldsig-core/ XML Digital Signatures]&lt;br /&gt;
*[http://www.w3.org/TR/xmlenc-core/ XML Encryption]&lt;br /&gt;
&lt;br /&gt;
A special mode can be enabled which would allow a machine with a specified IP address to make calls to the XML-RPC layer without using either encryption or signature envelopes. This mode is provided to enable Moodle to communicate with other software systems in which the integration of signatures and encryption might be prohibitively difficult. It is not envisioned that unencrypted inter-Moodle networking will ever be enabled.&lt;br /&gt;
&lt;br /&gt;
==Peer to Peer Network==&lt;br /&gt;
&lt;br /&gt;
This is the basic layout of the system. It can be very useful to run one Moodle per faculty or departments, each with its own user management, and yet permit users to roam across the Moodle installs... subject to permissions of course. &lt;br /&gt;
&lt;br /&gt;
===Setup===&lt;br /&gt;
&lt;br /&gt;
The instructions will cover 2 Moodle installations: MoodleA and MoodleB. Both are installed correctly and have never had a Moodle Network configuration.&lt;br /&gt;
&lt;br /&gt;
Note: If you experience problems, ensure debugging is turned on in &#039;&#039;Site Administration &amp;gt; Server &amp;gt; Debugging&#039;&#039;. Extra diagnostic messages may be displayed (particularly from Moodle 1.9.2)&lt;br /&gt;
&lt;br /&gt;
# Get them to talk to each other&lt;br /&gt;
## Ensure &#039;&#039;Admin &amp;gt; Server &amp;gt; Environment&#039;&#039; indicates you have curl installed&lt;br /&gt;
## If MoodleA and MoodleB are hosted in the same domain, ensure they have a different cookie prefix. Note that changing the cookie prefix will log you out! You can change the cookie prefix via &#039;&#039;Admin &amp;gt; Server &amp;gt; Session Handling&#039;&#039;.&lt;br /&gt;
## On both, go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Settings&#039;&#039; and turn Networking ON.&lt;br /&gt;
## On MoodleA go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Peers&#039;&#039; - put the URL of MoodleB under &amp;quot;Add New Host&amp;quot; and click Add. The URL should include the directory where your Moodle code is located, for example &#039;&#039;www.mymoodle.org/moodle&#039;&#039;.&lt;br /&gt;
## Do the equivalent on MoodleB.&lt;br /&gt;
# Get user roaming going&lt;br /&gt;
## (skip this step, it is deprecated [http://moodle.org/mod/forum/discuss.php?d=141491] ) &#039;&#039; On both, go to &#039;&#039;Administration &amp;gt; Plugins &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039; in 2.0 onwards or &#039;&#039;Administration &amp;gt; Users &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039; in 1.9 and enable Moodle Network authentication plugin. Click on &#039;Settings&#039; and enable auto_add_remote_users.&#039;&#039;&lt;br /&gt;
## On MoodleA go to &#039;&#039;Admin &amp;gt; Networking &amp;gt; (Manage) Peers&#039;&#039;, click on &#039;MoodleB&#039;, and click on &#039;Services&#039;. Enable SSO-IDP publish and subscribe, and SSO-SP publish and subscribe.&lt;br /&gt;
## Do the equivalent on MoodleB.&lt;br /&gt;
## On both, go to &#039;&#039;Admin &amp;gt; Users &amp;gt; Permissions &amp;gt; Define Roles&#039;&#039;, only roles that have &amp;quot;Roam to a remote Moodle moodle/site:mnetlogintoremote&amp;quot; will be allowed to roam. Grant the privilege as appropriate.&lt;br /&gt;
## On both, go to the homepage, and add the &#039;Network Servers&#039; block.&lt;br /&gt;
## To test, it is recommended to use a different browser (even on a different machine) that is logged in to neither. Login to MoodleA with a non-administrator account that has the permissions to roam. You should see the Network Servers block, and clicking on it you should go to MoodleB with a newly autocreated account. &lt;br /&gt;
# Get remote enrolments going -- this is optional. It allows administrator of MoodleB can enrol users that are &amp;quot;native&amp;quot; to MoodleB in courses in MoodleA, and viceversa.&lt;br /&gt;
## On both, go to &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Enrolments &amp;gt; Manage enrol plugins&#039;&#039; in 2.0 onwards or &#039;&#039;Administration &amp;gt; Courses &amp;gt; Enrolments&#039;&#039; pre-2.0 and enable Moodle Network enrolment plugin (click Save). Click on &#039;Edit&#039; and enable &#039;allow_allcourses&#039; or select some courses or categories to be remotely enrolled.&lt;br /&gt;
## On MoodleA go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Peers&#039;&#039;, click on &#039;MoodleB&#039;, and click on &#039;Services&#039;. Enable Enrolment publish and subscribe.&lt;br /&gt;
## Do the equivalent on MoodleB.&lt;br /&gt;
## To use, in MoodleA go to &#039;&#039;Admin &amp;gt; Networking &amp;gt; Enrolments&#039;&#039;. You will see MoodleB listed. Click on MoodleB and you will see a list of courses that MoodleB offers for remote enrolment. Select the course you want, and then enroll the users you want to that course.&lt;br /&gt;
&lt;br /&gt;
===Using it===&lt;br /&gt;
&lt;br /&gt;
==Connecting to a Mnet hub==&lt;br /&gt;
A Mnet hub (do not confuse it with the [[Community hub]] project of Moodle 2.0) is a Moodle server that is configured to accept connections from other Moodle servers, and to provide a set of services to users of these other servers. This guideline will direct you to connect to a Mnet hub, assess the services it has to offer, and enable those services for your users.&lt;br /&gt;
&lt;br /&gt;
===Setup===&lt;br /&gt;
# Get talking to the Hub&lt;br /&gt;
## Ensure that the &#039;&#039;Admin &amp;gt; Server &amp;gt; Environment&#039;&#039; page indicates you have curl and openssl installed&lt;br /&gt;
## Go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Settings&#039;&#039; and turn Networking on&lt;br /&gt;
## Go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Peers&#039;&#039; and enter the URL of Mnet Hub under &amp;quot;Add New Host&amp;quot;. Click &amp;lt;em&amp;gt;Add&amp;lt;/em&amp;gt;&lt;br /&gt;
## The host details for the Mnet Hub should appear with the Site Name field already populated. Click &amp;lt;em&amp;gt;Save changes&amp;lt;/em&amp;gt;&lt;br /&gt;
## The details will be written to your database and two new tabs will appear in this window: &#039;Services&#039; and &#039;Logs&#039;. Click &amp;lt;em&amp;gt;Services&amp;lt;/em&amp;gt;&lt;br /&gt;
##A list of services will appear, each with a checkbox for &#039;publish&#039; and &#039;subscribe&#039;. Check the checkboxes for any services you want to publish or subscribe to&lt;br /&gt;
&lt;br /&gt;
===Using it===&lt;br /&gt;
If the Mnet Hub has already enabled a service for you, there will be a tick alongside the appropriate checkbox, for example: if the Hub is &amp;lt;em&amp;gt;publishing&amp;lt;/em&amp;gt; Moodle Networked Enrolment, then a tick will appear alongside the &amp;lt;em&amp;gt;subscribe&amp;lt;/em&amp;gt; checkbox for this service. Note that in order to enable some functionality, prominently &amp;lt;em&amp;gt;single-sign-on&amp;lt;/em&amp;gt;, you may have to &amp;lt;em&amp;gt;publish&amp;lt;/em&amp;gt; a service, e.g. the &amp;lt;em&amp;gt;Identity Provider&amp;lt;/em&amp;gt; service. The Mnet Hub will access this service on your Moodle, asking it to authenticate your users.&lt;br /&gt;
# Enable Roaming&lt;br /&gt;
## Subscribe to &amp;lt;em&amp;gt;SSO (Service Provider)&amp;lt;/em&amp;gt; by checking the box&lt;br /&gt;
## Publish &amp;lt;em&amp;gt;SSO (Identity Provider)&amp;lt;/em&amp;gt; by checking the box&lt;br /&gt;
## Click &amp;lt;em&amp;gt;Save changes&amp;lt;/em&amp;gt;&lt;br /&gt;
## Go to &#039;&#039;Admin &amp;gt; Users &amp;gt; Permissions &amp;gt; Define Roles&#039;&#039;, and grant the capability &amp;lt;em&amp;gt;Roam to a remote Moodle moodle/site:mnetlogintoremote&amp;lt;/em&amp;gt; to an appropriate role&lt;br /&gt;
## Go to &#039;&#039;Administration &amp;gt; Plugins &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039; in 2.0 onwards or &#039;&#039;Administration &amp;gt; Users &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039; in 1.9 and enable the &amp;lt;em&amp;gt;Moodle Network authentication&amp;lt;/em&amp;gt; plugin&lt;br /&gt;
## Go to your homepage, turn on editing, and add the &#039;Network Servers&#039; block&lt;br /&gt;
## Using a different web-browser, log on as a non-admin user who inhabits the role you granted the roaming capability to&lt;br /&gt;
## Note that the Mnet Hub is listed in the Network Servers block on the homepage. Click on the link to that server&lt;br /&gt;
## Some of your user details will be transferred to the Mnet Hub server, and a browsing session will be started for you as if you had logged on there directly&lt;br /&gt;
# Enable Networked Enrolment&lt;br /&gt;
## Return to the web browser you&#039;ve been using as the site administrator&lt;br /&gt;
## Go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Peers&#039;&#039; and click on the entry for the Mnet Hub.&lt;br /&gt;
## Click on the Services tab&lt;br /&gt;
## Subscribe to &amp;lt;em&amp;gt;Moodle Networked Enrolment&amp;lt;/em&amp;gt;&lt;br /&gt;
## Go to &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Enrolments &amp;gt; Manage enrol plugins&#039;&#039; in 2.0 onwards or &#039;&#039;Administration &amp;gt; Courses &amp;gt; Enrolments&#039;&#039; pre-2.0 and enable the &amp;lt;em&amp;gt;Moodle Network enrolment&amp;lt;/em&amp;gt; plugin. Click &amp;lt;em&amp;gt;Save changes&amp;lt;/em&amp;gt;&lt;br /&gt;
## Click on &amp;lt;em&amp;gt;edit&amp;lt;/em&amp;gt; to view the details for networked enrolments.&lt;br /&gt;
## Go to &#039;&#039;Admin &amp;gt; Networking &amp;gt; Enrolments&#039;&#039; to see a list of Moodle servers that offer this service to you&lt;br /&gt;
## Click on a server name to view a list of courses that the server offers to your users&lt;br /&gt;
## Click on a course name, to view a list users that you can enrol in this course&lt;br /&gt;
## Enrol users&lt;br /&gt;
## Profit!&lt;br /&gt;
&lt;br /&gt;
==Running a Mnet hub==&lt;br /&gt;
A Mnet hub is a regular Moodle site that runs in a special mode. As a Moodle Administrator, when you add another Moodle site to your list of network peers, your Moodle will contact that site to find out what it is called, and to request its public key for encrypted communication. Normally, the remote server will simply provide this information without making any record of the transaction.&lt;br /&gt;
&lt;br /&gt;
A Mnet hub is different. As soon as you add an entry for a Mnet hub to your system, the Mnet hub will create an entry for your server in its list of hosts, and may immediately begin to offer services to the users of your site.&lt;br /&gt;
&lt;br /&gt;
This section will guide you to set up a Mnet hub, and select services to offer to all comers.&lt;br /&gt;
&lt;br /&gt;
===Setup===&lt;br /&gt;
# Enable Networking&lt;br /&gt;
## Ensure that the &#039;&#039;Admin &amp;gt; Server &amp;gt; Environment&#039;&#039; page indicates you have curl and openssl installed&lt;br /&gt;
## Go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Settings&#039;&#039; and turn Networking on &lt;br /&gt;
## Go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Peers&#039;&#039; and tick the checkbox for &amp;lt;em&amp;gt;Register all hosts&amp;lt;/em&amp;gt;. Click on &amp;lt;em&amp;gt;Save Changes&amp;lt;/em&amp;gt;&lt;br /&gt;
## On the same page, the first entry in your list of hosts should be &amp;lt;em&amp;gt;All hosts&amp;lt;/em&amp;gt;. Click this link&lt;br /&gt;
## Click on &amp;lt;em&amp;gt;Services&amp;lt;/em&amp;gt; and enable any services you want to offer to all comers&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[Moodle Network FAQ]]&lt;br /&gt;
* [[Development:Moodle Network|Moodle Network development notes]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=6976 MNet forum]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/discuss.php?d=92749 Examples of how people are using Moodle networks] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
[[Category:Enrolment]]&lt;br /&gt;
[[Category:MNet]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Réseau Moodle]]&lt;br /&gt;
[[ja:Moodleネットワーク]]&lt;br /&gt;
[[es:Red Moodle]]&lt;br /&gt;
[[cs:Síťové služby]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=MNet&amp;diff=78404</id>
		<title>MNet</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=MNet&amp;diff=78404"/>
		<updated>2010-11-29T00:32:03Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The network feature allows a Moodle administrator to establish a link with another Moodle, and to share some resources with the users of that Moodle. This features was introduced in Moodle 1.8.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
The initial release of MNet is bundled with a Authentication Plugin, which makes single-sign-on between Moodles possible. A user with the username &amp;lt;em&amp;gt;jody&amp;lt;/em&amp;gt; logs in to her Moodle server as normal, and clicks on a link that takes her to a page on another Moodle server. Normally, she would have only the privileges of a guest on the remote Moodle, but behind the scenes, single-sign-on has established a fully authenticated session for Jody on the remote site.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039;  MNet requires the use of &#039;&#039;&#039;xmlrpc&#039;&#039;&#039;. Please go to your phpinfo page if you are interested in using this and search for --with-xmlrpc.  If your php has not been compiled with xmlrpc then you need to address that first! At present it appears that PEAR xmlrpc will not work.&lt;br /&gt;
[[Image:Administration Block Users Authentication MoodleNetwork.jpg|thumb|MNet setting in &#039;&#039;Admin &amp;gt; User &amp;gt; Authentication &amp;gt; Moodle Network]]&lt;br /&gt;
&lt;br /&gt;
==Security==&lt;br /&gt;
The MNet feature requires that your server has the &#039;&#039;&#039;Curl&#039;&#039;&#039; and &#039;&#039;&#039;OpenSSL&#039;&#039;&#039; extensions installed. When you install or upgrade to Moodle 1.8, your system will generate a new OpenSSL certificate for encrypted communication with other Moodles, and will thereafter rotate encryption keys on a monthly basis (approx).&lt;br /&gt;
&lt;br /&gt;
Communication takes place over an XML-RPC transport, and the XML-RPC documents are wrapped first in an XMLDSIG (XML digital signature) envelope, and then in an XMLENC (XML encryption) envelope. The encryption all happens within PHP, and does not require an https (Apache SSL) server.&lt;br /&gt;
&lt;br /&gt;
References:&lt;br /&gt;
*[http://www.w3.org/TR/xmldsig-core/ XML Digital Signatures]&lt;br /&gt;
*[http://www.w3.org/TR/xmlenc-core/ XML Encryption]&lt;br /&gt;
&lt;br /&gt;
A special mode can be enabled which would allow a machine with a specified IP address to make calls to the XML-RPC layer without using either encryption or signature envelopes. This mode is provided to enable Moodle to communicate with other software systems in which the integration of signatures and encryption might be prohibitively difficult. It is not envisioned that unencrypted inter-Moodle networking will ever be enabled.&lt;br /&gt;
&lt;br /&gt;
==Peer to Peer Network==&lt;br /&gt;
&lt;br /&gt;
This is the basic layout of the system. It can be very useful to run one Moodle per faculty or departments, each with its own user management, and yet permit users to roam across the Moodle installs... subject to permissions of course. &lt;br /&gt;
&lt;br /&gt;
===Setup===&lt;br /&gt;
&lt;br /&gt;
The instructions will cover 2 Moodle installations: MoodleA and MoodleB. Both are installed correctly and have never had a Moodle Network configuration.&lt;br /&gt;
&lt;br /&gt;
Note: If you experience problems, ensure debugging is turned on in &#039;&#039;Site Administration &amp;gt; Server &amp;gt; Debugging&#039;&#039;. Extra diagnostic messages may be displayed (particularly from Moodle 1.9.2)&lt;br /&gt;
&lt;br /&gt;
# Get them to talk to each other&lt;br /&gt;
## Ensure &#039;&#039;Admin &amp;gt; Server &amp;gt; Environment&#039;&#039; indicates you have curl installed&lt;br /&gt;
## If MoodleA and MoodleB are hosted in the same domain, ensure they have a different cookie prefix. Note that changing the cookie prefix will log you out! You can change the cookie prefix via &#039;&#039;Admin &amp;gt; Server &amp;gt; Session Handling&#039;&#039;.&lt;br /&gt;
## On both, go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Settings&#039;&#039; and turn Networking ON.&lt;br /&gt;
## On MoodleA go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Peers&#039;&#039; - put the URL of MoodleB under &amp;quot;Add New Host&amp;quot; and click Add. The URL should include the directory where your Moodle code is located, for example &#039;&#039;www.mymoodle.org/moodle&#039;&#039;.&lt;br /&gt;
## Do the equivalent on MoodleB.&lt;br /&gt;
# Get user roaming going&lt;br /&gt;
## (skip this step, it is deprecated [http://moodle.org/mod/forum/discuss.php?d=141491] ) &#039;&#039; On both, go to &#039;&#039;Administration &amp;gt; Plugins &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039; in 2.0 onwards or &#039;&#039;Administration &amp;gt; Users &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039; in 1.9 and enable Moodle Network authentication plugin. Click on &#039;Settings&#039; and enable auto_add_remote_users.&#039;&#039;&lt;br /&gt;
## On MoodleA go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Peers&#039;&#039;, click on &#039;MoodleB&#039;, and click on &#039;Services&#039;. Enable SSO-IDP publish and subscribe, and SSO-SP publish and subscribe.&lt;br /&gt;
## Do the equivalent on MoodleB.&lt;br /&gt;
## On both, go to &#039;&#039;Admin &amp;gt; Users &amp;gt; Permissions &amp;gt; Define Roles&#039;&#039;, only roles that have &amp;quot;Roam to a remote Moodle moodle/site:mnetlogintoremote&amp;quot; will be allowed to roam. Grant the privilege as appropriate.&lt;br /&gt;
## On both, go to the homepage, and add the &#039;Network Servers&#039; block.&lt;br /&gt;
## To test, it is recommended to use a different browser (even on a different machine) that is logged in to neither. Login to MoodleA with a non-administrator account that has the permissions to roam. You should see the Network Servers block, and clicking on it you should go to MoodleB with a newly autocreated account. &lt;br /&gt;
# Get remote enrolments going -- this is optional. It allows administrator of MoodleB can enrol users that are &amp;quot;native&amp;quot; to MoodleB in courses in MoodleA, and viceversa.&lt;br /&gt;
## On both, go to &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Enrolments &amp;gt; Manage enrol plugins&#039;&#039; in 2.0 onwards or &#039;&#039;Administration &amp;gt; Courses &amp;gt; Enrolments&#039;&#039; pre-2.0 and enable Moodle Network enrolment plugin (click Save). Click on &#039;Edit&#039; and enable &#039;allow_allcourses&#039; or select some courses or categories to be remotely enrolled.&lt;br /&gt;
## On MoodleA go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Peers&#039;&#039;, click on &#039;MoodleB&#039;, and click on &#039;Services&#039;. Enable Enrolment publish and subscribe.&lt;br /&gt;
## Do the equivalent on MoodleB.&lt;br /&gt;
## To use, in MoodleA go to &#039;&#039;Admin &amp;gt; Networking &amp;gt; Enrolments&#039;&#039;. You will see MoodleB listed. Click on MoodleB and you will see a list of courses that MoodleB offers for remote enrolment. Select the course you want, and then enroll the users you want to that course.&lt;br /&gt;
&lt;br /&gt;
===Using it===&lt;br /&gt;
&lt;br /&gt;
==Connecting to a Mnet hub==&lt;br /&gt;
A Mnet hub (do not confuse it with the [[Community hub]] project of Moodle 2.0) is a Moodle server that is configured to accept connections from other Moodle servers, and to provide a set of services to users of these other servers. This guideline will direct you to connect to a Mnet hub, assess the services it has to offer, and enable those services for your users.&lt;br /&gt;
&lt;br /&gt;
===Setup===&lt;br /&gt;
# Get talking to the Hub&lt;br /&gt;
## Ensure that the &#039;&#039;Admin &amp;gt; Server &amp;gt; Environment&#039;&#039; page indicates you have curl and openssl installed&lt;br /&gt;
## Go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Settings&#039;&#039; and turn Networking on&lt;br /&gt;
## Go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Peers&#039;&#039; and enter the URL of Mnet Hub under &amp;quot;Add New Host&amp;quot;. Click &amp;lt;em&amp;gt;Add&amp;lt;/em&amp;gt;&lt;br /&gt;
## The host details for the Mnet Hub should appear with the Site Name field already populated. Click &amp;lt;em&amp;gt;Save changes&amp;lt;/em&amp;gt;&lt;br /&gt;
## The details will be written to your database and two new tabs will appear in this window: &#039;Services&#039; and &#039;Logs&#039;. Click &amp;lt;em&amp;gt;Services&amp;lt;/em&amp;gt;&lt;br /&gt;
##A list of services will appear, each with a checkbox for &#039;publish&#039; and &#039;subscribe&#039;. Check the checkboxes for any services you want to publish or subscribe to&lt;br /&gt;
&lt;br /&gt;
===Using it===&lt;br /&gt;
If the Mnet Hub has already enabled a service for you, there will be a tick alongside the appropriate checkbox, for example: if the Hub is &amp;lt;em&amp;gt;publishing&amp;lt;/em&amp;gt; Moodle Networked Enrolment, then a tick will appear alongside the &amp;lt;em&amp;gt;subscribe&amp;lt;/em&amp;gt; checkbox for this service. Note that in order to enable some functionality, prominently &amp;lt;em&amp;gt;single-sign-on&amp;lt;/em&amp;gt;, you may have to &amp;lt;em&amp;gt;publish&amp;lt;/em&amp;gt; a service, e.g. the &amp;lt;em&amp;gt;Identity Provider&amp;lt;/em&amp;gt; service. The Mnet Hub will access this service on your Moodle, asking it to authenticate your users.&lt;br /&gt;
# Enable Roaming&lt;br /&gt;
## Subscribe to &amp;lt;em&amp;gt;SSO (Service Provider)&amp;lt;/em&amp;gt; by checking the box&lt;br /&gt;
## Publish &amp;lt;em&amp;gt;SSO (Identity Provider)&amp;lt;/em&amp;gt; by checking the box&lt;br /&gt;
## Click &amp;lt;em&amp;gt;Save changes&amp;lt;/em&amp;gt;&lt;br /&gt;
## Go to &#039;&#039;Admin &amp;gt; Users &amp;gt; Permissions &amp;gt; Define Roles&#039;&#039;, and grant the capability &amp;lt;em&amp;gt;Roam to a remote Moodle moodle/site:mnetlogintoremote&amp;lt;/em&amp;gt; to an appropriate role&lt;br /&gt;
## Go to &#039;&#039;Administration &amp;gt; Plugins &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039; in 2.0 onwards or &#039;&#039;Administration &amp;gt; Users &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039; in 1.9 and enable the &amp;lt;em&amp;gt;Moodle Network authentication&amp;lt;/em&amp;gt; plugin&lt;br /&gt;
## Go to your homepage, turn on editing, and add the &#039;Network Servers&#039; block&lt;br /&gt;
## Using a different web-browser, log on as a non-admin user who inhabits the role you granted the roaming capability to&lt;br /&gt;
## Note that the Mnet Hub is listed in the Network Servers block on the homepage. Click on the link to that server&lt;br /&gt;
## Some of your user details will be transferred to the Mnet Hub server, and a browsing session will be started for you as if you had logged on there directly&lt;br /&gt;
# Enable Networked Enrolment&lt;br /&gt;
## Return to the web browser you&#039;ve been using as the site administrator&lt;br /&gt;
## Go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Peers&#039;&#039; and click on the entry for the Mnet Hub.&lt;br /&gt;
## Click on the Services tab&lt;br /&gt;
## Subscribe to &amp;lt;em&amp;gt;Moodle Networked Enrolment&amp;lt;/em&amp;gt;&lt;br /&gt;
## Go to &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Enrolments &amp;gt; Manage enrol plugins&#039;&#039; in 2.0 onwards or &#039;&#039;Administration &amp;gt; Courses &amp;gt; Enrolments&#039;&#039; pre-2.0 and enable the &amp;lt;em&amp;gt;Moodle Network enrolment&amp;lt;/em&amp;gt; plugin. Click &amp;lt;em&amp;gt;Save changes&amp;lt;/em&amp;gt;&lt;br /&gt;
## Click on &amp;lt;em&amp;gt;edit&amp;lt;/em&amp;gt; to view the details for networked enrolments.&lt;br /&gt;
## Go to &#039;&#039;Admin &amp;gt; Networking &amp;gt; Enrolments&#039;&#039; to see a list of Moodle servers that offer this service to you&lt;br /&gt;
## Click on a server name to view a list of courses that the server offers to your users&lt;br /&gt;
## Click on a course name, to view a list users that you can enrol in this course&lt;br /&gt;
## Enrol users&lt;br /&gt;
## Profit!&lt;br /&gt;
&lt;br /&gt;
==Running a Mnet hub==&lt;br /&gt;
A Mnet hub is a regular Moodle site that runs in a special mode. As a Moodle Administrator, when you add another Moodle site to your list of network peers, your Moodle will contact that site to find out what it is called, and to request its public key for encrypted communication. Normally, the remote server will simply provide this information without making any record of the transaction.&lt;br /&gt;
&lt;br /&gt;
A Mnet hub is different. As soon as you add an entry for a Mnet hub to your system, the Mnet hub will create an entry for your server in its list of hosts, and may immediately begin to offer services to the users of your site.&lt;br /&gt;
&lt;br /&gt;
This section will guide you to set up a Mnet hub, and select services to offer to all comers.&lt;br /&gt;
&lt;br /&gt;
===Setup===&lt;br /&gt;
# Enable Networking&lt;br /&gt;
## Ensure that the &#039;&#039;Admin &amp;gt; Server &amp;gt; Environment&#039;&#039; page indicates you have curl and openssl installed&lt;br /&gt;
## Go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Settings&#039;&#039; and turn Networking on &lt;br /&gt;
## Go to &#039;&#039;Admin &amp;gt; Network &amp;gt; Peers&#039;&#039; and tick the checkbox for &amp;lt;em&amp;gt;Register all hosts&amp;lt;/em&amp;gt;. Click on &amp;lt;em&amp;gt;Save Changes&amp;lt;/em&amp;gt;&lt;br /&gt;
## On the same page, the first entry in your list of hosts should be &amp;lt;em&amp;gt;All hosts&amp;lt;/em&amp;gt;. Click this link&lt;br /&gt;
## Click on &amp;lt;em&amp;gt;Services&amp;lt;/em&amp;gt; and enable any services you want to offer to all comers&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[Moodle Network FAQ]]&lt;br /&gt;
* [[Development:Moodle Network|Moodle Network development notes]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=6976 MNet forum]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/discuss.php?d=92749 Examples of how people are using Moodle networks] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
[[Category:Enrolment]]&lt;br /&gt;
[[Category:MNet]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Réseau Moodle]]&lt;br /&gt;
[[ja:Moodleネットワーク]]&lt;br /&gt;
[[es:Red Moodle]]&lt;br /&gt;
[[cs:Síťové služby]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Calculated_question_improvements&amp;diff=52128</id>
		<title>Calculated question improvements</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Calculated_question_improvements&amp;diff=52128"/>
		<updated>2009-03-06T06:35:36Z</updated>

		<summary type="html">&lt;p&gt;Bruno: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Calculated question dev docs}}&lt;br /&gt;
I will use this page to describe the various improvements I am developping related to the calculated questions.&lt;br /&gt;
The code of 1.8 with the QuickForm HTML structure offer a considerable improvement in the interface user over the preceeding versions.&lt;br /&gt;
However at Université du Québec à Montréal, we moved from WebCT 4 to Moodle 1.6.3 in spring 2007 and will maintian this version for the next academic year. So exceptionnally, I will port down to 1.6 most of the improvements being made to the Moodle HEAD version.&lt;br /&gt;
&lt;br /&gt;
The following content of this page will be updated soon. &lt;br /&gt;
&lt;br /&gt;
==Working progress==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;2&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&#039;&#039;&#039;Improvements&#039;&#039;&#039;&lt;br /&gt;
!HEAD&lt;br /&gt;
!1.8&lt;br /&gt;
!1.7&lt;br /&gt;
!1.6&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
Moodle XML Import , Export&lt;br /&gt;
|Done&lt;br /&gt;
|Done&lt;br /&gt;
|Done&lt;br /&gt;
|Done&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
WebCT Import&lt;br /&gt;
|Done&lt;br /&gt;
|Done&lt;br /&gt;
|Done&lt;br /&gt;
|Done&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
Saving question at each step&lt;br /&gt;
*remove use of $SESSION to store parameters&lt;br /&gt;
|Done&lt;br /&gt;
|Done&lt;br /&gt;
|Done&lt;br /&gt;
|Done&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
Allow save as new question&lt;br /&gt;
*saving also the datasets and data items&lt;br /&gt;
|Done&lt;br /&gt;
|Done&lt;br /&gt;
|TO DO&lt;br /&gt;
|TO DO&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
Allow saving of multiple answers&lt;br /&gt;
|Done&lt;br /&gt;
|Done&lt;br /&gt;
|Done&lt;br /&gt;
|Done&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
Allow edition of multiple answers&lt;br /&gt;
|Done&lt;br /&gt;
|Done&lt;br /&gt;
|READY&lt;br /&gt;
|READY&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
Validation of user data before saving&lt;br /&gt;
*For QuickForm redisplay with red text&lt;br /&gt;
*Older version use notice when saving question-&amp;gt;options so there is a return to editquestion &lt;br /&gt;
|Done&lt;br /&gt;
|Done&lt;br /&gt;
|TESTING&lt;br /&gt;
|TESTING&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
Allow addition and removal of dataitems by steps &lt;br /&gt;
of 5,10,15, etc&lt;br /&gt;
|TESTING&lt;br /&gt;
|TESTING&lt;br /&gt;
|TESTING&lt;br /&gt;
|TESTING&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
larger field for formula &lt;br /&gt;
&lt;br /&gt;
|TO DO&lt;br /&gt;
|TO DO&lt;br /&gt;
|TO DO&lt;br /&gt;
|TO DO&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
subquestions &lt;br /&gt;
&lt;br /&gt;
|TO DO&lt;br /&gt;
|TO DO&lt;br /&gt;
|TO DO&lt;br /&gt;
|TO DO&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
Possible steps are :&lt;br /&gt;
* TO DO&lt;br /&gt;
* CODED&lt;br /&gt;
* TESTING&lt;br /&gt;
* READY&lt;br /&gt;
* Done i.e CVS and merged&lt;br /&gt;
07/05/23&lt;br /&gt;
&lt;br /&gt;
==Foolproof and clearer creation process==&lt;br /&gt;
Actually the creation or edition of calculated question is a three steps process ( 3 different pages) where the user can make errors that he cannot readily recuperate.&lt;br /&gt;
* Identify the steps and renaming the save changes or continue buttons.&lt;br /&gt;
* Using javascript to correct for errors or non valid values in each steps before going to the next step.[[Calculated question js validating forms]]&lt;br /&gt;
* Creating buttons to access the previous steps for corrections.&lt;br /&gt;
* Creating a table showing the variables used by the other calculated questions in the same category.&lt;br /&gt;
* Allowing to create or delete data items by 1, 10, 20 etc in one step.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Moving calculated questions to another category==&lt;br /&gt;
Actually the code (Moodle 1.7) for moving questions to another category means simply to change the category field in the database question record.&lt;br /&gt;
Although this is correct for most questions types, this is not the right way to do it with calculated questions because the same category field is also used in the datasets records.&lt;br /&gt;
A dataset can be shared by questions of the same category. &lt;br /&gt;
To search if there is a already sharable dataset in a category, the parameters used are the dataset-&amp;gt;name and the dataset-&amp;gt;category.&lt;br /&gt;
The possibilities are&lt;br /&gt;
#All the dataset used by the question to be moved are reserved for this question (dataset-&amp;gt;category=0). The calculated question can be moved to another category &#039;&#039;&#039;without restriction&#039;&#039;&#039;.This is the actual implementation.&lt;br /&gt;
#At least one of the dataset used by the question to be moved is sharable (dataset-&amp;gt;category = actual question category)&lt;br /&gt;
## If &#039;&#039;&#039;all&#039;&#039;&#039; the sharable dataset are &#039;&#039;&#039;only&#039;&#039;&#039; used by the question to be moved, the calculated question can be selected to move to the other category .&lt;br /&gt;
## If &#039;&#039;&#039;all&#039;&#039;&#039; the questions that are selected to be moved, and &#039;&#039;&#039;all&#039;&#039;&#039; the sharable datasets are only used by these questions to be moved, this set of questions can be selected to move to the other category .&lt;br /&gt;
## In the case that there are questions not selected that could used a sharable dataset, this dataset cannot be moved in the another category.&lt;br /&gt;
###Notify the user that another questions in the initial category share a parameter with this category.&lt;br /&gt;
####The user can choose to cancel the move and select all the other questions (Case 2.2).&lt;br /&gt;
####The user can choose to keep the question in the selected questions to be moved. In this case, the dataset should be duplicated when moving the another category.&lt;br /&gt;
===Duplicate datasets?===&lt;br /&gt;
If a similar sharable dataset already exists in the moveto category ( identical dataset-&amp;gt;name and dataset-&amp;gt;category = movetocategory).&lt;br /&gt;
Notify the user and giving information on the&lt;br /&gt;
#sharable dataset in selected questions to be moved &lt;br /&gt;
#already existing sharable datasets in the move_to_category.&lt;br /&gt;
The user should be able to select which dataset will be used in move_to_category.&lt;br /&gt;
&lt;br /&gt;
To implement these choices we need to add new functions in default questiontype class.&lt;br /&gt;
===function movable_to_category(&amp;amp;$questions,$categoryid)===&lt;br /&gt;
 default return null &lt;br /&gt;
 $questions contain all the question records data for all the selected questions &lt;br /&gt;
 so that qtype implementation could test &amp;lt;br&amp;gt;if the selected questions satisfy option 2.2&lt;br /&gt;
 a $questions-&amp;gt;notify can be added to be used by showbank.php and move_to_category.&lt;br /&gt;
===function move_to_category($question,$tocategory)=== &lt;br /&gt;
the default implementation should something like the actual code&lt;br /&gt;
  {&lt;br /&gt;
           if (!set_field(&#039;question&#039;, &#039;category&#039;, $tocategory-&amp;gt;id, &#039;id&#039;, $question-&amp;gt;id)) {&lt;br /&gt;
                            error(&#039;Could not update category field&#039;);&lt;br /&gt;
                        }&lt;br /&gt;
        return null;&lt;br /&gt;
    }&lt;br /&gt;
the calculated question implementation should be able to duplicate the datasets in the new category&lt;br /&gt;
&lt;br /&gt;
==Improvements in general question editing interface==&lt;br /&gt;
*Showing the text of the questions&lt;br /&gt;
&lt;br /&gt;
==Creation of a short (simple) calculated question==&lt;br /&gt;
The actual calculated question allows for calculated params that can be shared by different problems.&lt;br /&gt;
This could lead to a somewhat cloze used of calculated questions.However the questions cannot migrate individually to another category.&lt;br /&gt;
A short calculated question that just allow for calculated parameters reserved for this question will allow use of this question in drag and drop cloze lesson.&lt;br /&gt;
==Manipulating data items==&lt;br /&gt;
Actual functions and propôsal for new ones for manipulating data items are discussed in [[Data_Item_Functions]]&lt;br /&gt;
==Side effects to other modules==&lt;br /&gt;
* Modification of the question type to allow moving of calculated question to another category.&lt;br /&gt;
* Creation of general functions to standardize the import or export process.&lt;br /&gt;
==Creation and modification of calculated questions==&lt;br /&gt;
See the [[Development:Calculated question bugs and new features proposal]]&lt;br /&gt;
&lt;br /&gt;
See the [[Development:Calculated multiquestions proposal]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See the [[Calculated question actual 1.7 interface summary]]&lt;br /&gt;
&lt;br /&gt;
See the [[Calculated question 1.7 bugs solving proposal]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  [[User:Pierre Pichet|Pierre Pichet]]  August 2007 (WST)&lt;br /&gt;
[[Developer_notes]]&lt;br /&gt;
[[Calculated question creation developper docs]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Calculated_question_type_creation&amp;diff=52127</id>
		<title>Calculated question type creation</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Calculated_question_type_creation&amp;diff=52127"/>
		<updated>2009-03-06T06:19:26Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* A more FULL PROOF code proposal */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Calculated question dev docs}}&lt;br /&gt;
I will use this page and the followings to describe the PHP code principal processes of the calculated question creation and see how it could be improved.&lt;br /&gt;
==Calculated question parameters== &lt;br /&gt;
Calculated question is an extended numerical question where parameters of a mathematical problems are generated and used to calculate the answer using a mathematical formula.&lt;br /&gt;
&lt;br /&gt;
So the answer parameter of a numerical question is replaced by the mathematical formula using the same answer database structure that the numerical question.&lt;br /&gt;
 &lt;br /&gt;
The generated parameters are identified by a special format that is not used in a mathematical PHP equation {param} where the param name begins by a letter and can include alphanumerics symbol a-z A-Z _ 0-9  &lt;br /&gt;
 ex. {ad} {a_2} {a4_r} are valid parameter names &lt;br /&gt;
 {1a} {a+1} {a(0)} are invalid parameter names&lt;br /&gt;
  &lt;br /&gt;
These parameters are transform in datasets defined by a min,max,decimal and generation mode.&lt;br /&gt;
Using these datasets definitions a number of different values are generated (the dataset items) and used to generate different question instances where the parameters have different values although the question structure and answer formula are constant.&lt;br /&gt;
&lt;br /&gt;
==Creating a calculated question==&lt;br /&gt;
Actually the creation of a calculated question is a three step process&lt;br /&gt;
* &#039;&#039;&#039;Defining the common question parameters&#039;&#039;&#039;&lt;br /&gt;
** Question name&lt;br /&gt;
** Question text&lt;br /&gt;
** answer formula, limit, units&lt;br /&gt;
* &#039;&#039;&#039;Defining the dataset definitions range&#039;&#039;&#039; for each of them. The dataset definition ({params}) can be used in this new question only or could be used or add been already created by other questions in the question category in which the new question is created.&lt;br /&gt;
  question category is a set of questions that can contain various question types&lt;br /&gt;
* &#039;&#039;&#039;Defining the dataset definitions parameters&#039;&#039;&#039; (min,max, decimal and generation mode and &#039;&#039;&#039;adding at least one data item&#039;&#039;&#039; for each dataset definitions&lt;br /&gt;
 Actually a set of all the data items is created when you click the add button&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Saving&#039;&#039;&#039; the question parameters,dataset definitions parameters and data items.&lt;br /&gt;
The real saving procedure is done when you &#039;&#039;&#039;add&#039;&#039;&#039;  the &#039;&#039;&#039;first&#039;&#039;&#039; set of data items.&lt;br /&gt;
 Because in the actual code a calculated question needs that&lt;br /&gt;
 &#039;&#039;&#039;all&#039;&#039;&#039; these components be defined to be a &#039;&#039;&#039;valid&#039;&#039;&#039; calculated question,&lt;br /&gt;
 the saving is &#039;&#039;&#039;postponed&#039;&#039;&#039; until you click the &#039;&#039;&#039;add button&#039;&#039;&#039; to add the &#039;&#039;&#039;first&#039;&#039;&#039; set of data items.&lt;br /&gt;
 The parameters already entered are stored in the $Session object&lt;br /&gt;
 even if you click &#039;&#039;&#039;Saving changes&#039;&#039;&#039; at least&lt;br /&gt;
 &#039;&#039;&#039;twice&#039;&#039;&#039; &lt;br /&gt;
   1.&#039;&#039;&#039;Defining the common question parameters&#039;&#039;&#039; &lt;br /&gt;
   2.&#039;&#039;&#039;Defining the dataset definitions range&#039;&#039;&#039; steps.&lt;br /&gt;
 before adding your first set of data items.&lt;br /&gt;
&lt;br /&gt;
==Editing of a question==&lt;br /&gt;
When you modify the an actual question, if you click &#039;&#039;&#039;Saving changes&#039;&#039;&#039;. the changes are saved in the database. &lt;br /&gt;
==Creating a copy of a question==&lt;br /&gt;
When you create a new question as a copy of an actual question , the ordinary parameters are copied but you havo to reconstruct the database sets and the database.&lt;br /&gt;
==Moving a question to another category==&lt;br /&gt;
When you move a question to another category, the ordinary parameters are copied but you havo to reconstruct the database sets and the database.If you come back to the initial category, the initial datasets are retrivied. There is a bug in the transfer related to the complex structure of the calculated questions.&lt;br /&gt;
Correcting this bug is one of my priorities([[User:Pierre Pichet|Pierre Pichet]] 11:59, 21 August 2006 (CDT)).&lt;br /&gt;
==A summary of the actual functions==&lt;br /&gt;
See the [[Calculated question actual 1.7 interface summary]]&lt;br /&gt;
&lt;br /&gt;
==NOTHING is SAVED UNTIL you CLICK the ADD BUTTON==&lt;br /&gt;
In the preceding Moodle version (&amp;lt;1.6), the user could click the BACK TO QUIZ EDITING button before adding a first data set item&lt;br /&gt;
 If the user at the third step click BACK TO QUIZ EDITING when NO dataset items added, &lt;br /&gt;
 he LOOSE all his work because the question general parameters where not solved.&lt;br /&gt;
In the newer Moodle versions (1.65 beta,1.7, June 2006), the BACK TO QUIZ EDITING button does not appear unless there is at least one data set item.&lt;br /&gt;
see [[Calculated question back to quiz button]]&lt;br /&gt;
&lt;br /&gt;
Because of this three steps procedure, the creation of a calculated question is a process which can abort easily if the user do not follow exactly all the three steps in the order the Moodle code expect them.&lt;br /&gt;
Improvements to obtain a &#039;&#039;&#039;FOOLPROOF PROCESS&#039;&#039;&#039; are proposed in the next section.&lt;br /&gt;
&lt;br /&gt;
However, the teacher should always verify that for each added data item set, a valid answer, minimum and maximum value are obtained.&lt;br /&gt;
Fortunately, at this step the newly created calculated question is already saved in the database and the user could go back and modify the question if necessary.&lt;br /&gt;
&lt;br /&gt;
==A more FOOLPROOF code proposal == &lt;br /&gt;
See also [[Calculated question development| a proposed calculated question development]] in Developer notes  &lt;br /&gt;
&lt;br /&gt;
[[Category:Developer|Calculated question type creation]]&lt;br /&gt;
[[Category:Quiz]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Calculated_question_type_creation&amp;diff=52126</id>
		<title>Calculated question type creation</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Calculated_question_type_creation&amp;diff=52126"/>
		<updated>2009-03-06T06:19:07Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* NOTHING is SAVED UNTIL you CLICK the ADD BUTTON */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Calculated question dev docs}}&lt;br /&gt;
I will use this page and the followings to describe the PHP code principal processes of the calculated question creation and see how it could be improved.&lt;br /&gt;
==Calculated question parameters== &lt;br /&gt;
Calculated question is an extended numerical question where parameters of a mathematical problems are generated and used to calculate the answer using a mathematical formula.&lt;br /&gt;
&lt;br /&gt;
So the answer parameter of a numerical question is replaced by the mathematical formula using the same answer database structure that the numerical question.&lt;br /&gt;
 &lt;br /&gt;
The generated parameters are identified by a special format that is not used in a mathematical PHP equation {param} where the param name begins by a letter and can include alphanumerics symbol a-z A-Z _ 0-9  &lt;br /&gt;
 ex. {ad} {a_2} {a4_r} are valid parameter names &lt;br /&gt;
 {1a} {a+1} {a(0)} are invalid parameter names&lt;br /&gt;
  &lt;br /&gt;
These parameters are transform in datasets defined by a min,max,decimal and generation mode.&lt;br /&gt;
Using these datasets definitions a number of different values are generated (the dataset items) and used to generate different question instances where the parameters have different values although the question structure and answer formula are constant.&lt;br /&gt;
&lt;br /&gt;
==Creating a calculated question==&lt;br /&gt;
Actually the creation of a calculated question is a three step process&lt;br /&gt;
* &#039;&#039;&#039;Defining the common question parameters&#039;&#039;&#039;&lt;br /&gt;
** Question name&lt;br /&gt;
** Question text&lt;br /&gt;
** answer formula, limit, units&lt;br /&gt;
* &#039;&#039;&#039;Defining the dataset definitions range&#039;&#039;&#039; for each of them. The dataset definition ({params}) can be used in this new question only or could be used or add been already created by other questions in the question category in which the new question is created.&lt;br /&gt;
  question category is a set of questions that can contain various question types&lt;br /&gt;
* &#039;&#039;&#039;Defining the dataset definitions parameters&#039;&#039;&#039; (min,max, decimal and generation mode and &#039;&#039;&#039;adding at least one data item&#039;&#039;&#039; for each dataset definitions&lt;br /&gt;
 Actually a set of all the data items is created when you click the add button&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Saving&#039;&#039;&#039; the question parameters,dataset definitions parameters and data items.&lt;br /&gt;
The real saving procedure is done when you &#039;&#039;&#039;add&#039;&#039;&#039;  the &#039;&#039;&#039;first&#039;&#039;&#039; set of data items.&lt;br /&gt;
 Because in the actual code a calculated question needs that&lt;br /&gt;
 &#039;&#039;&#039;all&#039;&#039;&#039; these components be defined to be a &#039;&#039;&#039;valid&#039;&#039;&#039; calculated question,&lt;br /&gt;
 the saving is &#039;&#039;&#039;postponed&#039;&#039;&#039; until you click the &#039;&#039;&#039;add button&#039;&#039;&#039; to add the &#039;&#039;&#039;first&#039;&#039;&#039; set of data items.&lt;br /&gt;
 The parameters already entered are stored in the $Session object&lt;br /&gt;
 even if you click &#039;&#039;&#039;Saving changes&#039;&#039;&#039; at least&lt;br /&gt;
 &#039;&#039;&#039;twice&#039;&#039;&#039; &lt;br /&gt;
   1.&#039;&#039;&#039;Defining the common question parameters&#039;&#039;&#039; &lt;br /&gt;
   2.&#039;&#039;&#039;Defining the dataset definitions range&#039;&#039;&#039; steps.&lt;br /&gt;
 before adding your first set of data items.&lt;br /&gt;
&lt;br /&gt;
==Editing of a question==&lt;br /&gt;
When you modify the an actual question, if you click &#039;&#039;&#039;Saving changes&#039;&#039;&#039;. the changes are saved in the database. &lt;br /&gt;
==Creating a copy of a question==&lt;br /&gt;
When you create a new question as a copy of an actual question , the ordinary parameters are copied but you havo to reconstruct the database sets and the database.&lt;br /&gt;
==Moving a question to another category==&lt;br /&gt;
When you move a question to another category, the ordinary parameters are copied but you havo to reconstruct the database sets and the database.If you come back to the initial category, the initial datasets are retrivied. There is a bug in the transfer related to the complex structure of the calculated questions.&lt;br /&gt;
Correcting this bug is one of my priorities([[User:Pierre Pichet|Pierre Pichet]] 11:59, 21 August 2006 (CDT)).&lt;br /&gt;
==A summary of the actual functions==&lt;br /&gt;
See the [[Calculated question actual 1.7 interface summary]]&lt;br /&gt;
&lt;br /&gt;
==NOTHING is SAVED UNTIL you CLICK the ADD BUTTON==&lt;br /&gt;
In the preceding Moodle version (&amp;lt;1.6), the user could click the BACK TO QUIZ EDITING button before adding a first data set item&lt;br /&gt;
 If the user at the third step click BACK TO QUIZ EDITING when NO dataset items added, &lt;br /&gt;
 he LOOSE all his work because the question general parameters where not solved.&lt;br /&gt;
In the newer Moodle versions (1.65 beta,1.7, June 2006), the BACK TO QUIZ EDITING button does not appear unless there is at least one data set item.&lt;br /&gt;
see [[Calculated question back to quiz button]]&lt;br /&gt;
&lt;br /&gt;
Because of this three steps procedure, the creation of a calculated question is a process which can abort easily if the user do not follow exactly all the three steps in the order the Moodle code expect them.&lt;br /&gt;
Improvements to obtain a &#039;&#039;&#039;FOOLPROOF PROCESS&#039;&#039;&#039; are proposed in the next section.&lt;br /&gt;
&lt;br /&gt;
However, the teacher should always verify that for each added data item set, a valid answer, minimum and maximum value are obtained.&lt;br /&gt;
Fortunately, at this step the newly created calculated question is already saved in the database and the user could go back and modify the question if necessary.&lt;br /&gt;
&lt;br /&gt;
==A more FULL PROOF code proposal == &lt;br /&gt;
See also [[Calculated question development| a proposed calculated question development]] in Developer notes  &lt;br /&gt;
&lt;br /&gt;
[[Category:Developer|Calculated question type creation]]&lt;br /&gt;
[[Category:Quiz]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Marking_block&amp;diff=25634</id>
		<title>Marking block</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Marking_block&amp;diff=25634"/>
		<updated>2007-08-05T00:39:02Z</updated>

		<summary type="html">&lt;p&gt;Bruno: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
for moodle 1.8+ please read http://moodle.org/mod/data/view.php?d=13&amp;amp;rid=445&lt;br /&gt;
&lt;br /&gt;
the rest of this page concerns moodle 1.5 and 1.6 only&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==purpose:==&lt;br /&gt;
* to allow teacher to quickly see what needs to be &amp;quot;marked&amp;quot; in &#039;&#039;&#039;ONLY&#039;&#039;&#039;:&lt;br /&gt;
# assignments&lt;br /&gt;
# journals &lt;br /&gt;
# lessons&lt;br /&gt;
# forums&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Marking&#039;&#039;&#039; block is a Moodle block add-on that provides a summary of activities awaiting grading. It includes a separate page that provides an alternate gradebook functionality tied to the marking block. This block is restricted to teachers and administrators.&lt;br /&gt;
&lt;br /&gt;
This block displays marking information for newly submitted, resubmitted, and overdue (activities past their defined close dates) activities. The marking page provides the same information and easy access to the grading functions for these activities.&lt;br /&gt;
&lt;br /&gt;
This block can also display a list of students below a certain grade level.&lt;br /&gt;
&lt;br /&gt;
The block can be configured to display a maximum number of students in each list and to set the grade level to display below.&lt;br /&gt;
&lt;br /&gt;
This directory uses custom code for all activities it summarizes. There are few common activity library functions that can perform the same operations, and thus any new activities to be added will need new code.&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
&lt;br /&gt;
To install and use, unzip this file into your Moodle root directory making sure&lt;br /&gt;
that you &#039;use folder names&#039;. This will add a new block directory (marking) to&lt;br /&gt;
your &#039;/blocks&#039; directory and some language files to your language directory.&lt;br /&gt;
Once unzipped, visit your admin screen and configure the new block the way you&lt;br /&gt;
want.&lt;br /&gt;
&lt;br /&gt;
===Setting up Marking block for Moodle 1.6+===&lt;br /&gt;
&lt;br /&gt;
* download block_marking_1.6x from http://moodle.org/mod/data/view.php?d=13&amp;amp;rid=445&lt;br /&gt;
* unzip it in the root folder of your moodle directory&lt;br /&gt;
* adjust the settings in &#039;&#039;&#039;admin / configureation /blocks / marking / settings menu&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
* set &#039;&#039;&#039;$CFG-&amp;gt;block_marking_listnum =&#039;&#039;&#039; &#039;&#039;(some number other than the default 2)&#039;&#039;  via the &#039;&#039;&#039;admin / configureation /blocks / marking / settings menu&#039;&#039;&#039; (the default is to show two activites needing marking per section (unmarked / resubmitted / unsubmitted.)&lt;br /&gt;
** set it to a higher number to avoid the illusion that not all items are shown &amp;quot;to be marked&amp;quot;  (or click on the &amp;quot;MORE&amp;quot; button instead)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Credits==&lt;br /&gt;
&lt;br /&gt;
The marking block has been designed and built with the contributions of the&lt;br /&gt;
following people:&lt;br /&gt;
* Fernando Oliviera - G8 First Nation Schools &amp;gt; original design concept of the marking page&lt;br /&gt;
* Darren Smith - Egglescliffe School &amp;gt; orginal design concept of the marking block, and additional design of the marking page&lt;br /&gt;
* Mike Churchward - churchward.ca (mike AT churchward DOT ca)&amp;gt; original technical design and development&lt;br /&gt;
* Bruno Vernier - block packaging and some bug fixes&lt;br /&gt;
&lt;br /&gt;
==To do==&lt;br /&gt;
&lt;br /&gt;
* Make sure all strings are in language file&lt;br /&gt;
* Allow configuration of each section (i.e. enable/disable &#039;below average list&#039;)&lt;br /&gt;
* Create a local block library file and better compartmentalize functions&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* [http://download.moodle.org/download.php/modules/block_marking.zip Download]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=45432 Link to forum post with a lang/en file with all strings filled in]&lt;br /&gt;
&lt;br /&gt;
[[Category:Block (non-standard)]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Marking_block&amp;diff=25633</id>
		<title>Marking block</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Marking_block&amp;diff=25633"/>
		<updated>2007-08-05T00:38:21Z</updated>

		<summary type="html">&lt;p&gt;Bruno: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
for moodle 1.8+ please read http://moodle.org/mod/data/view.php?d=13&amp;amp;rid=445&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==purpose:==&lt;br /&gt;
* to allow teacher to quickly see what needs to be &amp;quot;marked&amp;quot; in &#039;&#039;&#039;ONLY&#039;&#039;&#039;:&lt;br /&gt;
# assignments&lt;br /&gt;
# journals &lt;br /&gt;
# lessons&lt;br /&gt;
# forums&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Marking&#039;&#039;&#039; block is a Moodle block add-on that provides a summary of activities awaiting grading. It includes a separate page that provides an alternate gradebook functionality tied to the marking block. This block is restricted to teachers and administrators.&lt;br /&gt;
&lt;br /&gt;
This block displays marking information for newly submitted, resubmitted, and overdue (activities past their defined close dates) activities. The marking page provides the same information and easy access to the grading functions for these activities.&lt;br /&gt;
&lt;br /&gt;
This block can also display a list of students below a certain grade level.&lt;br /&gt;
&lt;br /&gt;
The block can be configured to display a maximum number of students in each list and to set the grade level to display below.&lt;br /&gt;
&lt;br /&gt;
This directory uses custom code for all activities it summarizes. There are few common activity library functions that can perform the same operations, and thus any new activities to be added will need new code.&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
&lt;br /&gt;
To install and use, unzip this file into your Moodle root directory making sure&lt;br /&gt;
that you &#039;use folder names&#039;. This will add a new block directory (marking) to&lt;br /&gt;
your &#039;/blocks&#039; directory and some language files to your language directory.&lt;br /&gt;
Once unzipped, visit your admin screen and configure the new block the way you&lt;br /&gt;
want.&lt;br /&gt;
&lt;br /&gt;
===Setting up Marking block for Moodle 1.6+===&lt;br /&gt;
&lt;br /&gt;
* download block_marking_1.6x from http://moodle.org/mod/data/view.php?d=13&amp;amp;rid=445&lt;br /&gt;
* unzip it in the root folder of your moodle directory&lt;br /&gt;
* adjust the settings in &#039;&#039;&#039;admin / configureation /blocks / marking / settings menu&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
* set &#039;&#039;&#039;$CFG-&amp;gt;block_marking_listnum =&#039;&#039;&#039; &#039;&#039;(some number other than the default 2)&#039;&#039;  via the &#039;&#039;&#039;admin / configureation /blocks / marking / settings menu&#039;&#039;&#039; (the default is to show two activites needing marking per section (unmarked / resubmitted / unsubmitted.)&lt;br /&gt;
** set it to a higher number to avoid the illusion that not all items are shown &amp;quot;to be marked&amp;quot;  (or click on the &amp;quot;MORE&amp;quot; button instead)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Credits==&lt;br /&gt;
&lt;br /&gt;
The marking block has been designed and built with the contributions of the&lt;br /&gt;
following people:&lt;br /&gt;
* Fernando Oliviera - G8 First Nation Schools &amp;gt; original design concept of the marking page&lt;br /&gt;
* Darren Smith - Egglescliffe School &amp;gt; orginal design concept of the marking block, and additional design of the marking page&lt;br /&gt;
* Mike Churchward - churchward.ca (mike AT churchward DOT ca)&amp;gt; original technical design and development&lt;br /&gt;
* Bruno Vernier - block packaging and some bug fixes&lt;br /&gt;
&lt;br /&gt;
==To do==&lt;br /&gt;
&lt;br /&gt;
* Make sure all strings are in language file&lt;br /&gt;
* Allow configuration of each section (i.e. enable/disable &#039;below average list&#039;)&lt;br /&gt;
* Create a local block library file and better compartmentalize functions&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* [http://download.moodle.org/download.php/modules/block_marking.zip Download]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=45432 Link to forum post with a lang/en file with all strings filled in]&lt;br /&gt;
&lt;br /&gt;
[[Category:Block (non-standard)]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Web_services_API&amp;diff=25212</id>
		<title>Web services API</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Web_services_API&amp;diff=25212"/>
		<updated>2007-07-19T06:30:03Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* The server script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Web Services API provides Moodle with a web service interface to allow exchange of data and information with other systems.&lt;br /&gt;
&lt;br /&gt;
For example,&lt;br /&gt;
# Manage user data - send and retrieve the information,&lt;br /&gt;
# Manage course enrolments - add/remove teachers and students,&lt;br /&gt;
# Course management - create new courses based on templates,&lt;br /&gt;
# Gradebook info - extract grades information from Moodle.&lt;br /&gt;
&lt;br /&gt;
==XML-RPC background==&lt;br /&gt;
The XML-RPC service allows other servers to contact your Moodle server and request that it call a function. The Moodle server might do something, like create a user, or it might fetch some data and serve it back to your host.&lt;br /&gt;
&lt;br /&gt;
To communicate like this with another Moodle host, you&#039;d normally use the Moodle Network [https://docs.moodle.org/en/Moodle_Network] features, but it&#039;s also possible for other kinds of program to contact your Moodle, using plain-old-XML-RPC, with Moodle Network&#039;s encryption or signed-message features.&lt;br /&gt;
&lt;br /&gt;
==The server script==&lt;br /&gt;
* allow trusted sites to access web services by configuring &#039;&#039;&#039;admin/mnet/trustedhosts.php&#039;&#039;&#039;&lt;br /&gt;
* start by pointing your browser to &#039;&#039;&#039;mnet/xmlrpc/server.php&#039;&#039;&#039; - this should show an XML error message&lt;br /&gt;
* use POST data in this format:&lt;br /&gt;
 // $method is something like: &amp;quot;mod/forum/lib/forum_add_instance&amp;quot;&lt;br /&gt;
 // $params is an array of parameters. A parameter might itself be an array.&lt;br /&gt;
 // use only Whitelist characters that are permitted in a method name&lt;br /&gt;
 // The method name must not begin with a / - avoid absolute paths&lt;br /&gt;
 // A dot character . is only allowed in the filename, i.e. something.php&lt;br /&gt;
* use &#039;&#039;&#039;mnet/xmlrpc/client.php&#039;&#039;&#039; to make remote xmlrpc calls&lt;br /&gt;
&lt;br /&gt;
==Things you can do==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?f=965 Web Services forum]  &lt;br /&gt;
&lt;br /&gt;
[[Category:Developer|Web services API]]&lt;br /&gt;
[[Category:Administrator]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Web_services_API&amp;diff=25211</id>
		<title>Web services API</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Web_services_API&amp;diff=25211"/>
		<updated>2007-07-19T06:06:56Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* The server script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Web Services API provides Moodle with a web service interface to allow exchange of data and information with other systems.&lt;br /&gt;
&lt;br /&gt;
For example,&lt;br /&gt;
# Manage user data - send and retrieve the information,&lt;br /&gt;
# Manage course enrolments - add/remove teachers and students,&lt;br /&gt;
# Course management - create new courses based on templates,&lt;br /&gt;
# Gradebook info - extract grades information from Moodle.&lt;br /&gt;
&lt;br /&gt;
==XML-RPC background==&lt;br /&gt;
The XML-RPC service allows other servers to contact your Moodle server and request that it call a function. The Moodle server might do something, like create a user, or it might fetch some data and serve it back to your host.&lt;br /&gt;
&lt;br /&gt;
To communicate like this with another Moodle host, you&#039;d normally use the Moodle Network [https://docs.moodle.org/en/Moodle_Network] features, but it&#039;s also possible for other kinds of program to contact your Moodle, using plain-old-XML-RPC, with Moodle Network&#039;s encryption or signed-message features.&lt;br /&gt;
&lt;br /&gt;
==The server script==&lt;br /&gt;
* allow trusted sites to access web services by configuring &#039;&#039;&#039;/admin/mnet/trustedhosts.php&#039;&#039;&#039;&lt;br /&gt;
* start by pointing your browser to &#039;&#039;&#039;/mnet/xmlrpc/server.php&#039;&#039;&#039; - this should show an XML error message&lt;br /&gt;
* use POST data in this format:&lt;br /&gt;
 // $method is something like: &amp;quot;mod/forum/lib/forum_add_instance&amp;quot;&lt;br /&gt;
 // $params is an array of parameters. A parameter might itself be an array.&lt;br /&gt;
 // use only Whitelist characters that are permitted in a method name&lt;br /&gt;
 // The method name must not begin with a / - avoid absolute paths&lt;br /&gt;
 // A dot character . is only allowed in the filename, i.e. something.php&lt;br /&gt;
&lt;br /&gt;
==Things you can do==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?f=965 Web Services forum]  &lt;br /&gt;
&lt;br /&gt;
[[Category:Developer|Web services API]]&lt;br /&gt;
[[Category:Administrator]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Web_services_API&amp;diff=25210</id>
		<title>Web services API</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Web_services_API&amp;diff=25210"/>
		<updated>2007-07-19T05:56:24Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* The server script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Web Services API provides Moodle with a web service interface to allow exchange of data and information with other systems.&lt;br /&gt;
&lt;br /&gt;
For example,&lt;br /&gt;
# Manage user data - send and retrieve the information,&lt;br /&gt;
# Manage course enrolments - add/remove teachers and students,&lt;br /&gt;
# Course management - create new courses based on templates,&lt;br /&gt;
# Gradebook info - extract grades information from Moodle.&lt;br /&gt;
&lt;br /&gt;
==XML-RPC background==&lt;br /&gt;
The XML-RPC service allows other servers to contact your Moodle server and request that it call a function. The Moodle server might do something, like create a user, or it might fetch some data and serve it back to your host.&lt;br /&gt;
&lt;br /&gt;
To communicate like this with another Moodle host, you&#039;d normally use the Moodle Network [https://docs.moodle.org/en/Moodle_Network] features, but it&#039;s also possible for other kinds of program to contact your Moodle, using plain-old-XML-RPC, with Moodle Network&#039;s encryption or signed-message features.&lt;br /&gt;
&lt;br /&gt;
==The server script==&lt;br /&gt;
* allow trusted sites to access web services by configuring &#039;&#039;&#039;/admin/mnet/trustedhosts.php&#039;&#039;&#039;&lt;br /&gt;
* start by pointing your browser to &#039;&#039;&#039;/mnet/xmlrpc/server.php&#039;&#039;&#039; - this should show an XML error message&lt;br /&gt;
&lt;br /&gt;
 // $method is something like: &amp;quot;mod/forum/lib/forum_add_instance&amp;quot;&lt;br /&gt;
 // $params is an array of parameters. A parameter might itself be an array.&lt;br /&gt;
 // use only Whitelist characters that are permitted in a method name&lt;br /&gt;
 // The method name must not begin with a / - avoid absolute paths&lt;br /&gt;
 // A dot character . is only allowed in the filename, i.e. something.php&lt;br /&gt;
&lt;br /&gt;
==Things you can do==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?f=965 Web Services forum]  &lt;br /&gt;
&lt;br /&gt;
[[Category:Developer|Web services API]]&lt;br /&gt;
[[Category:Administrator]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Web_services_API&amp;diff=25209</id>
		<title>Web services API</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Web_services_API&amp;diff=25209"/>
		<updated>2007-07-19T05:54:40Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* The server script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Web Services API provides Moodle with a web service interface to allow exchange of data and information with other systems.&lt;br /&gt;
&lt;br /&gt;
For example,&lt;br /&gt;
# Manage user data - send and retrieve the information,&lt;br /&gt;
# Manage course enrolments - add/remove teachers and students,&lt;br /&gt;
# Course management - create new courses based on templates,&lt;br /&gt;
# Gradebook info - extract grades information from Moodle.&lt;br /&gt;
&lt;br /&gt;
==XML-RPC background==&lt;br /&gt;
The XML-RPC service allows other servers to contact your Moodle server and request that it call a function. The Moodle server might do something, like create a user, or it might fetch some data and serve it back to your host.&lt;br /&gt;
&lt;br /&gt;
To communicate like this with another Moodle host, you&#039;d normally use the Moodle Network [https://docs.moodle.org/en/Moodle_Network] features, but it&#039;s also possible for other kinds of program to contact your Moodle, using plain-old-XML-RPC, with Moodle Network&#039;s encryption or signed-message features.&lt;br /&gt;
&lt;br /&gt;
==The server script==&lt;br /&gt;
* allow trusted sites to access web services by configuring &#039;&#039;&#039;/admin/mnet/trustedhosts.php&#039;&#039;&#039;&lt;br /&gt;
* start by pointing your browser to &#039;&#039;&#039;/mnet/xmlrpc/server.php&#039;&#039;&#039; - this should show an XML error message&lt;br /&gt;
&lt;br /&gt;
 // $method is something like: &amp;quot;mod/forum/lib/forum_add_instance&amp;quot;&lt;br /&gt;
 // $params is an array of parameters. A parameter might itself be an array.&lt;br /&gt;
&lt;br /&gt;
==Things you can do==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?f=965 Web Services forum]  &lt;br /&gt;
&lt;br /&gt;
[[Category:Developer|Web services API]]&lt;br /&gt;
[[Category:Administrator]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Web_services_API&amp;diff=25208</id>
		<title>Web services API</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Web_services_API&amp;diff=25208"/>
		<updated>2007-07-19T05:33:02Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* The server script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Web Services API provides Moodle with a web service interface to allow exchange of data and information with other systems.&lt;br /&gt;
&lt;br /&gt;
For example,&lt;br /&gt;
# Manage user data - send and retrieve the information,&lt;br /&gt;
# Manage course enrolments - add/remove teachers and students,&lt;br /&gt;
# Course management - create new courses based on templates,&lt;br /&gt;
# Gradebook info - extract grades information from Moodle.&lt;br /&gt;
&lt;br /&gt;
==XML-RPC background==&lt;br /&gt;
The XML-RPC service allows other servers to contact your Moodle server and request that it call a function. The Moodle server might do something, like create a user, or it might fetch some data and serve it back to your host.&lt;br /&gt;
&lt;br /&gt;
To communicate like this with another Moodle host, you&#039;d normally use the Moodle Network [https://docs.moodle.org/en/Moodle_Network] features, but it&#039;s also possible for other kinds of program to contact your Moodle, using plain-old-XML-RPC, with Moodle Network&#039;s encryption or signed-message features.&lt;br /&gt;
&lt;br /&gt;
==The server script==&lt;br /&gt;
* allow trusted sites to access web services by configuring &#039;&#039;&#039;/admin/mnet/trustedhosts.php&#039;&#039;&#039;&lt;br /&gt;
* start by pointing your browser to &#039;&#039;&#039;/mnet/xmlrpc/server.php&#039;&#039;&#039; - this should show an XML error message&lt;br /&gt;
&lt;br /&gt;
==Things you can do==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?f=965 Web Services forum]  &lt;br /&gt;
&lt;br /&gt;
[[Category:Developer|Web services API]]&lt;br /&gt;
[[Category:Administrator]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Web_services_API&amp;diff=25207</id>
		<title>Web services API</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Web_services_API&amp;diff=25207"/>
		<updated>2007-07-19T05:29:41Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* The server script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Web Services API provides Moodle with a web service interface to allow exchange of data and information with other systems.&lt;br /&gt;
&lt;br /&gt;
For example,&lt;br /&gt;
# Manage user data - send and retrieve the information,&lt;br /&gt;
# Manage course enrolments - add/remove teachers and students,&lt;br /&gt;
# Course management - create new courses based on templates,&lt;br /&gt;
# Gradebook info - extract grades information from Moodle.&lt;br /&gt;
&lt;br /&gt;
==XML-RPC background==&lt;br /&gt;
The XML-RPC service allows other servers to contact your Moodle server and request that it call a function. The Moodle server might do something, like create a user, or it might fetch some data and serve it back to your host.&lt;br /&gt;
&lt;br /&gt;
To communicate like this with another Moodle host, you&#039;d normally use the Moodle Network [https://docs.moodle.org/en/Moodle_Network] features, but it&#039;s also possible for other kinds of program to contact your Moodle, using plain-old-XML-RPC, with Moodle Network&#039;s encryption or signed-message features.&lt;br /&gt;
&lt;br /&gt;
==The server script==&lt;br /&gt;
* start by pointing your browser to &#039;&#039;_http://your_domain/path_to_moodle&#039;&#039;&#039;&#039;&#039;/mnet/xmlrpc/server.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Things you can do==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?f=965 Web Services forum]  &lt;br /&gt;
&lt;br /&gt;
[[Category:Developer|Web services API]]&lt;br /&gt;
[[Category:Administrator]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Web_services_API&amp;diff=25206</id>
		<title>Web services API</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Web_services_API&amp;diff=25206"/>
		<updated>2007-07-19T05:29:25Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* The server script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Web Services API provides Moodle with a web service interface to allow exchange of data and information with other systems.&lt;br /&gt;
&lt;br /&gt;
For example,&lt;br /&gt;
# Manage user data - send and retrieve the information,&lt;br /&gt;
# Manage course enrolments - add/remove teachers and students,&lt;br /&gt;
# Course management - create new courses based on templates,&lt;br /&gt;
# Gradebook info - extract grades information from Moodle.&lt;br /&gt;
&lt;br /&gt;
==XML-RPC background==&lt;br /&gt;
The XML-RPC service allows other servers to contact your Moodle server and request that it call a function. The Moodle server might do something, like create a user, or it might fetch some data and serve it back to your host.&lt;br /&gt;
&lt;br /&gt;
To communicate like this with another Moodle host, you&#039;d normally use the Moodle Network [https://docs.moodle.org/en/Moodle_Network] features, but it&#039;s also possible for other kinds of program to contact your Moodle, using plain-old-XML-RPC, with Moodle Network&#039;s encryption or signed-message features.&lt;br /&gt;
&lt;br /&gt;
==The server script==&lt;br /&gt;
* start by pointing your browser to _&#039;&#039;http://your_domain/path_to_moodle&#039;&#039;&#039;&#039;&#039;/mnet/xmlrpc/server.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Things you can do==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?f=965 Web Services forum]  &lt;br /&gt;
&lt;br /&gt;
[[Category:Developer|Web services API]]&lt;br /&gt;
[[Category:Administrator]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Web_services_API&amp;diff=25205</id>
		<title>Web services API</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Web_services_API&amp;diff=25205"/>
		<updated>2007-07-19T05:28:51Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* The server script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Web Services API provides Moodle with a web service interface to allow exchange of data and information with other systems.&lt;br /&gt;
&lt;br /&gt;
For example,&lt;br /&gt;
# Manage user data - send and retrieve the information,&lt;br /&gt;
# Manage course enrolments - add/remove teachers and students,&lt;br /&gt;
# Course management - create new courses based on templates,&lt;br /&gt;
# Gradebook info - extract grades information from Moodle.&lt;br /&gt;
&lt;br /&gt;
==XML-RPC background==&lt;br /&gt;
The XML-RPC service allows other servers to contact your Moodle server and request that it call a function. The Moodle server might do something, like create a user, or it might fetch some data and serve it back to your host.&lt;br /&gt;
&lt;br /&gt;
To communicate like this with another Moodle host, you&#039;d normally use the Moodle Network [https://docs.moodle.org/en/Moodle_Network] features, but it&#039;s also possible for other kinds of program to contact your Moodle, using plain-old-XML-RPC, with Moodle Network&#039;s encryption or signed-message features.&lt;br /&gt;
&lt;br /&gt;
==The server script==&lt;br /&gt;
* start by pointing your browser to hhttp://your_domain/path_to_moodle&#039;&#039;&#039;/mnet/xmlrpc/server.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Things you can do==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?f=965 Web Services forum]  &lt;br /&gt;
&lt;br /&gt;
[[Category:Developer|Web services API]]&lt;br /&gt;
[[Category:Administrator]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Web_services_API&amp;diff=25204</id>
		<title>Web services API</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Web_services_API&amp;diff=25204"/>
		<updated>2007-07-19T05:27:48Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* The server script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Web Services API provides Moodle with a web service interface to allow exchange of data and information with other systems.&lt;br /&gt;
&lt;br /&gt;
For example,&lt;br /&gt;
# Manage user data - send and retrieve the information,&lt;br /&gt;
# Manage course enrolments - add/remove teachers and students,&lt;br /&gt;
# Course management - create new courses based on templates,&lt;br /&gt;
# Gradebook info - extract grades information from Moodle.&lt;br /&gt;
&lt;br /&gt;
==XML-RPC background==&lt;br /&gt;
The XML-RPC service allows other servers to contact your Moodle server and request that it call a function. The Moodle server might do something, like create a user, or it might fetch some data and serve it back to your host.&lt;br /&gt;
&lt;br /&gt;
To communicate like this with another Moodle host, you&#039;d normally use the Moodle Network [https://docs.moodle.org/en/Moodle_Network] features, but it&#039;s also possible for other kinds of program to contact your Moodle, using plain-old-XML-RPC, with Moodle Network&#039;s encryption or signed-message features.&lt;br /&gt;
&lt;br /&gt;
==The server script==&lt;br /&gt;
* start by pointing your browser to http://your_domain/path_to_moodle&#039;&#039;&#039;/mnet/xmlrpc/server.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Things you can do==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?f=965 Web Services forum]  &lt;br /&gt;
&lt;br /&gt;
[[Category:Developer|Web services API]]&lt;br /&gt;
[[Category:Administrator]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Themes&amp;diff=23278</id>
		<title>Themes</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Themes&amp;diff=23278"/>
		<updated>2007-05-15T02:22:56Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* Installing your own theme */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Themes}}&lt;br /&gt;
&lt;br /&gt;
Moodle has a powerful &#039;&#039;&#039;themes&#039;&#039;&#039; system that allows for a variety of effects through the use of XHTML and CSS.&lt;br /&gt;
&lt;br /&gt;
* Themes may be [[Theme config|configured]] at site level, course level and/or user level.&lt;br /&gt;
* Each page is individually-addressable via CSS, allowing you to pinpoint exact items.&lt;br /&gt;
* Our CSS class naming system uses simple English, is consistent and easily understood.&lt;br /&gt;
* New modules can tell Moodle what styles they need and automatically include these in the stylesheet.&lt;br /&gt;
* Themes can be based on the &#039;&#039;standard&#039;&#039; theme, which is very plain but functional.  You simply override styles you want to change by adding to the stylesheet in your own theme.  This means that if you upgrade Moodle later and new styles are needed, your custom theme will still work without any changes, because the new classes will be defined in the &#039;&#039;standard&#039;&#039; theme.&lt;br /&gt;
* Themes can also be based on any other theme.  This allows you to easily create families of themes, or variations on a theme.  For example you might create a spectrum of pastel shades for use in different courses, but with the same basic layout and logos.  You may also want to create a family of differently-coloured themes for accessibility purposes.&lt;br /&gt;
&lt;br /&gt;
== Creating your own theme ==&lt;br /&gt;
&lt;br /&gt;
If you plan to work on your own theme please create a new one (with its own named subfolder) and use Moodle&#039;s [what] feature to base your theme on an existing theme such as &#039;&#039;standard&#039;&#039;. If you just modify one of the delivered themes it will be overwritten by the next Moodle update.&lt;br /&gt;
&lt;br /&gt;
== Installing your own theme ==&lt;br /&gt;
&lt;br /&gt;
Once you have your own theme created, you should follow these steps to install it on your site:&lt;br /&gt;
&lt;br /&gt;
# Zip the theme folder using winzip or similar&lt;br /&gt;
# Upload the .zip file into the theme folder moodle/themes/&lt;br /&gt;
# Unzip&lt;br /&gt;
# note: make sure the new theme folder and its contents are readable by the webserver. in Mac OS X, set Group and Other privileges to  &#039;Read &amp;amp; Write&#039; (select File&amp;gt; Get Info&amp;gt; Ownership &amp;amp; Permissions) otherwise Moodle may not be able to display the newly installed theme.&lt;br /&gt;
# Choose your new theme from within Moodle Admin&amp;gt;Appearances&amp;gt;Themes (version 1.7 +). For older versions, the path is Moodle Admin&amp;gt;Configuration&amp;gt;Themes&lt;br /&gt;
&lt;br /&gt;
== Theme system changes across Moodle versions ==&lt;br /&gt;
&lt;br /&gt;
Moodle 1.5 themes are quite different from previous versions and so a [[Theme upgrade|theme upgrade]] is required. A theme upgrade is also required for the [[1.6 theme upgrade|transition from 1.5 to 1.6]], since the XHTML structure has been reworked for improved [[Accessibility|accessibility]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Administrator]]&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:Themes]]&lt;br /&gt;
&lt;br /&gt;
[[es:Temas]]&lt;br /&gt;
[[fr:Thèmes]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Themes&amp;diff=23277</id>
		<title>Themes</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Themes&amp;diff=23277"/>
		<updated>2007-05-15T02:21:45Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* Installing your own theme */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Themes}}&lt;br /&gt;
&lt;br /&gt;
Moodle has a powerful &#039;&#039;&#039;themes&#039;&#039;&#039; system that allows for a variety of effects through the use of XHTML and CSS.&lt;br /&gt;
&lt;br /&gt;
* Themes may be [[Theme config|configured]] at site level, course level and/or user level.&lt;br /&gt;
* Each page is individually-addressable via CSS, allowing you to pinpoint exact items.&lt;br /&gt;
* Our CSS class naming system uses simple English, is consistent and easily understood.&lt;br /&gt;
* New modules can tell Moodle what styles they need and automatically include these in the stylesheet.&lt;br /&gt;
* Themes can be based on the &#039;&#039;standard&#039;&#039; theme, which is very plain but functional.  You simply override styles you want to change by adding to the stylesheet in your own theme.  This means that if you upgrade Moodle later and new styles are needed, your custom theme will still work without any changes, because the new classes will be defined in the &#039;&#039;standard&#039;&#039; theme.&lt;br /&gt;
* Themes can also be based on any other theme.  This allows you to easily create families of themes, or variations on a theme.  For example you might create a spectrum of pastel shades for use in different courses, but with the same basic layout and logos.  You may also want to create a family of differently-coloured themes for accessibility purposes.&lt;br /&gt;
&lt;br /&gt;
== Creating your own theme ==&lt;br /&gt;
&lt;br /&gt;
If you plan to work on your own theme please create a new one (with its own named subfolder) and use Moodle&#039;s [what] feature to base your theme on an existing theme such as &#039;&#039;standard&#039;&#039;. If you just modify one of the delivered themes it will be overwritten by the next Moodle update.&lt;br /&gt;
&lt;br /&gt;
== Installing your own theme ==&lt;br /&gt;
&lt;br /&gt;
Once you have your own theme created, you should follow these steps to install it on your site:&lt;br /&gt;
&lt;br /&gt;
# Zip the theme folder using winzip or similar&lt;br /&gt;
# Upload the .zip file into the theme folder moodle/themes/&lt;br /&gt;
# Unzip&lt;br /&gt;
# note: make sure the new theme folder and its contents are readable by the webserver.&lt;br /&gt;
if you are using Mac OS X, make sure that the files have Group and Other privileges set to  &#039;Read &amp;amp; Write&#039; (select File&amp;gt; Get Info&amp;gt; Ownership &amp;amp; Permissions) otherwise Moodle may not be able to display the newly installed theme.&lt;br /&gt;
# Choose your new theme from within Moodle Admin&amp;gt;Appearances&amp;gt;Themes (version 1.7 +). For older versions, the path is Moodle Admin&amp;gt;Configuration&amp;gt;Themes&lt;br /&gt;
&lt;br /&gt;
== Theme system changes across Moodle versions ==&lt;br /&gt;
&lt;br /&gt;
Moodle 1.5 themes are quite different from previous versions and so a [[Theme upgrade|theme upgrade]] is required. A theme upgrade is also required for the [[1.6 theme upgrade|transition from 1.5 to 1.6]], since the XHTML structure has been reworked for improved [[Accessibility|accessibility]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Administrator]]&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:Themes]]&lt;br /&gt;
&lt;br /&gt;
[[es:Temas]]&lt;br /&gt;
[[fr:Thèmes]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Themes&amp;diff=23276</id>
		<title>Themes</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Themes&amp;diff=23276"/>
		<updated>2007-05-15T02:21:29Z</updated>

		<summary type="html">&lt;p&gt;Bruno: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Themes}}&lt;br /&gt;
&lt;br /&gt;
Moodle has a powerful &#039;&#039;&#039;themes&#039;&#039;&#039; system that allows for a variety of effects through the use of XHTML and CSS.&lt;br /&gt;
&lt;br /&gt;
* Themes may be [[Theme config|configured]] at site level, course level and/or user level.&lt;br /&gt;
* Each page is individually-addressable via CSS, allowing you to pinpoint exact items.&lt;br /&gt;
* Our CSS class naming system uses simple English, is consistent and easily understood.&lt;br /&gt;
* New modules can tell Moodle what styles they need and automatically include these in the stylesheet.&lt;br /&gt;
* Themes can be based on the &#039;&#039;standard&#039;&#039; theme, which is very plain but functional.  You simply override styles you want to change by adding to the stylesheet in your own theme.  This means that if you upgrade Moodle later and new styles are needed, your custom theme will still work without any changes, because the new classes will be defined in the &#039;&#039;standard&#039;&#039; theme.&lt;br /&gt;
* Themes can also be based on any other theme.  This allows you to easily create families of themes, or variations on a theme.  For example you might create a spectrum of pastel shades for use in different courses, but with the same basic layout and logos.  You may also want to create a family of differently-coloured themes for accessibility purposes.&lt;br /&gt;
&lt;br /&gt;
== Creating your own theme ==&lt;br /&gt;
&lt;br /&gt;
If you plan to work on your own theme please create a new one (with its own named subfolder) and use Moodle&#039;s [what] feature to base your theme on an existing theme such as &#039;&#039;standard&#039;&#039;. If you just modify one of the delivered themes it will be overwritten by the next Moodle update.&lt;br /&gt;
&lt;br /&gt;
== Installing your own theme ==&lt;br /&gt;
&lt;br /&gt;
Once you have your own theme created, you should follow these steps to install it on your site:&lt;br /&gt;
&lt;br /&gt;
# Zip the theme folder using winzip or similar&lt;br /&gt;
# Upload the .zip file into the theme folder moodle/themes/&lt;br /&gt;
# Unzip&lt;br /&gt;
# note: make sure the new theme folder and its contents are readable by the webserver.&lt;br /&gt;
 if you are using Mac OS X, make sure that the files have Group and Other privileges set to  &#039;Read &amp;amp; Write&#039; (select File&amp;gt; Get Info&amp;gt; Ownership &amp;amp; Permissions) otherwise Moodle may not be able to display the newly installed theme.&lt;br /&gt;
# Choose your new theme from within Moodle Admin&amp;gt;Appearances&amp;gt;Themes (version 1.7 +). For older versions, the path is Moodle Admin&amp;gt;Configuration&amp;gt;Themes&lt;br /&gt;
&lt;br /&gt;
== Theme system changes across Moodle versions ==&lt;br /&gt;
&lt;br /&gt;
Moodle 1.5 themes are quite different from previous versions and so a [[Theme upgrade|theme upgrade]] is required. A theme upgrade is also required for the [[1.6 theme upgrade|transition from 1.5 to 1.6]], since the XHTML structure has been reworked for improved [[Accessibility|accessibility]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Administrator]]&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:Themes]]&lt;br /&gt;
&lt;br /&gt;
[[es:Temas]]&lt;br /&gt;
[[fr:Thèmes]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=tracksessionip&amp;diff=22858</id>
		<title>tracksessionip</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=tracksessionip&amp;diff=22858"/>
		<updated>2007-04-29T04:04:20Z</updated>

		<summary type="html">&lt;p&gt;Bruno: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
==Comments==&lt;br /&gt;
* &amp;quot;It restricts a single session from changing IP, and this is mostly a debugging tool for a strange problem that we think is a PHP bug. It does not stop a single user from having more than one session.&amp;quot;&lt;br /&gt;
** Martin Langhoff in http://moodle.org/mod/forum/discuss.php?d=47271#217274&lt;br /&gt;
* &amp;quot;suppose you logged in using a dial up connection.  If you get disconnected and then reconnect, tracksessionip will not let you open pages even if you had your browser open.&amp;quot;&lt;br /&gt;
** Vikram Solia in http://moodle.org/mod/forum/discuss.php?d=32879#157645&lt;br /&gt;
&lt;br /&gt;
==Config.php==&lt;br /&gt;
* to turn it on, go to config.php and uncomment:&lt;br /&gt;
* $CFG-&amp;gt;tracksessionip= True;&lt;br /&gt;
&lt;br /&gt;
 // If this setting is set to true, then Moodle will track the IP of the&lt;br /&gt;
 // current user to make sure it hasn&#039;t changed during a session.  This&lt;br /&gt;
 // will prevent the possibility of sessions being hijacked via XSS, but it&lt;br /&gt;
 // may break things for users coming using proxies that change all the time,&lt;br /&gt;
 // like AOL.&lt;br /&gt;
&lt;br /&gt;
==Alternative==&lt;br /&gt;
* set dbsessions to &amp;quot;YES&amp;quot; so that sessions are stored in the db&lt;br /&gt;
* non-recommended alternative method is to allow domain users write access to the sessions directory (see note at bottom of [[NTLM_authentication]])&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=tracksessionip&amp;diff=22857</id>
		<title>tracksessionip</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=tracksessionip&amp;diff=22857"/>
		<updated>2007-04-29T03:47:33Z</updated>

		<summary type="html">&lt;p&gt;Bruno: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Comments==&lt;br /&gt;
* &amp;quot;It restricts a single session from changing IP, and this is mostly a debugging tool for a strange problem that we think is a PHP bug. It does not stop a single user from having more than one session.&amp;quot;&lt;br /&gt;
** Martin Langhoff in http://moodle.org/mod/forum/discuss.php?d=47271#217274&lt;br /&gt;
* &amp;quot;suppose you logged in using a dial up connection.  If you get disconnected and then reconnect, tracksessionip will not let you open pages even if you had your browser open.&amp;quot;&lt;br /&gt;
** Vikram Solia in http://moodle.org/mod/forum/discuss.php?d=32879#157645&lt;br /&gt;
&lt;br /&gt;
==Config.php==&lt;br /&gt;
* to turn it on, go to config.php and uncomment:&lt;br /&gt;
* $CFG-&amp;gt;tracksessionip= True;&lt;br /&gt;
&lt;br /&gt;
 // If this setting is set to true, then Moodle will track the IP of the&lt;br /&gt;
 // current user to make sure it hasn&#039;t changed during a session.  This&lt;br /&gt;
 // will prevent the possibility of sessions being hijacked via XSS, but it&lt;br /&gt;
 // may break things for users coming using proxies that change all the time,&lt;br /&gt;
 // like AOL.&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=tracksessionip&amp;diff=22856</id>
		<title>tracksessionip</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=tracksessionip&amp;diff=22856"/>
		<updated>2007-04-29T03:42:35Z</updated>

		<summary type="html">&lt;p&gt;Bruno: /* Config.php */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Martin Langhoff==&lt;br /&gt;
* &amp;quot;It restricts a single session from changing IP, and this is mostly a debugging tool for a strange problem that we think is a PHP bug. It does not stop a single user from having more than one session.&amp;quot;&lt;br /&gt;
* http://moodle.org/mod/forum/discuss.php?d=47271#217274&lt;br /&gt;
&lt;br /&gt;
==Config.php==&lt;br /&gt;
* to turn it on, go to config.php and uncomment:&lt;br /&gt;
* $CFG-&amp;gt;tracksessionip= True;&lt;br /&gt;
&lt;br /&gt;
 // If this setting is set to true, then Moodle will track the IP of the&lt;br /&gt;
 // current user to make sure it hasn&#039;t changed during a session.  This&lt;br /&gt;
 // will prevent the possibility of sessions being hijacked via XSS, but it&lt;br /&gt;
 // may break things for users coming using proxies that change all the time,&lt;br /&gt;
 // like AOL.&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=tracksessionip&amp;diff=22855</id>
		<title>tracksessionip</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=tracksessionip&amp;diff=22855"/>
		<updated>2007-04-29T03:41:40Z</updated>

		<summary type="html">&lt;p&gt;Bruno: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Martin Langhoff==&lt;br /&gt;
* &amp;quot;It restricts a single session from changing IP, and this is mostly a debugging tool for a strange problem that we think is a PHP bug. It does not stop a single user from having more than one session.&amp;quot;&lt;br /&gt;
* http://moodle.org/mod/forum/discuss.php?d=47271#217274&lt;br /&gt;
&lt;br /&gt;
==Config.php==&lt;br /&gt;
* to turn it on, go to config.php and uncomment:&lt;br /&gt;
* $CFG-&amp;gt;tracksessionip= True;&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=tracksessionip&amp;diff=22854</id>
		<title>tracksessionip</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=tracksessionip&amp;diff=22854"/>
		<updated>2007-04-29T03:41:26Z</updated>

		<summary type="html">&lt;p&gt;Bruno: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[category:admin]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Martin Langhoff==&lt;br /&gt;
* &amp;quot;It restricts a single session from changing IP, and this is mostly a debugging tool for a strange problem that we think is a PHP bug. It does not stop a single user from having more than one session.&amp;quot;&lt;br /&gt;
* http://moodle.org/mod/forum/discuss.php?d=47271#217274&lt;br /&gt;
&lt;br /&gt;
==Config.php==&lt;br /&gt;
* to turn it on, go to config.php and uncomment:&lt;br /&gt;
* $CFG-&amp;gt;tracksessionip= True;&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=tracksessionip&amp;diff=22853</id>
		<title>tracksessionip</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=tracksessionip&amp;diff=22853"/>
		<updated>2007-04-29T03:40:54Z</updated>

		<summary type="html">&lt;p&gt;Bruno: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[category:administrator]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Martin Langhoff==&lt;br /&gt;
* &amp;quot;It restricts a single session from changing IP, and this is mostly a debugging tool for a strange problem that we think is a PHP bug. It does not stop a single user from having more than one session.&amp;quot;&lt;br /&gt;
* http://moodle.org/mod/forum/discuss.php?d=47271#217274&lt;br /&gt;
&lt;br /&gt;
==Config.php==&lt;br /&gt;
* to turn it on, go to config.php and uncomment:&lt;br /&gt;
* $CFG-&amp;gt;tracksessionip= True;&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=customscripts&amp;diff=22779</id>
		<title>customscripts</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=customscripts&amp;diff=22779"/>
		<updated>2007-04-26T20:35:40Z</updated>

		<summary type="html">&lt;p&gt;Bruno: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Custom Scripts Mechanism==&lt;br /&gt;
&lt;br /&gt;
 Any scripts that are called directly via a url (eg index.php, user/view.php) &lt;br /&gt;
 can now be customised by placing a file with the same name (including directories) in &lt;br /&gt;
 my_moodle_data_dir/customscripts&lt;br /&gt;
 For example:&lt;br /&gt;
 my_moodle_data_dir/customscripts/index.php; my_moodle_data_dir/customscripts/user/view.php&lt;br /&gt;
&lt;br /&gt;
* this is for people making short term changes to VISIBLE web pages in the moodle source code&lt;br /&gt;
** need to check relative links ; for example: never require ../config.php&lt;br /&gt;
** cannot add new files to customscripts folder because they are not accessible directly via web.&lt;br /&gt;
** better to use cvs or cogito for long term management of customisations to moodle code&lt;br /&gt;
&lt;br /&gt;
* it seems to have been used extensively only by the [[Moodle_for_Mobiles]] project&lt;br /&gt;
&lt;br /&gt;
* to enable Custom Scripts, add $CFG-&amp;gt;customscript=path/to/customscript/folder (see [[Configuration_file]])&lt;br /&gt;
&lt;br /&gt;
==references==&lt;br /&gt;
* http://moodle.org/mod/forum/discuss.php?d=31895&lt;br /&gt;
* http://tracker.moodle.org/secure/QuickSearch.jspa and type &amp;quot;customscripts&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[category:developper]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=customscripts&amp;diff=22778</id>
		<title>customscripts</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=customscripts&amp;diff=22778"/>
		<updated>2007-04-26T20:32:38Z</updated>

		<summary type="html">&lt;p&gt;Bruno: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Custom Scripts Mechanism==&lt;br /&gt;
&lt;br /&gt;
 Any scripts that are called directly via a url (eg index.php, user/view.php) &lt;br /&gt;
 can now be customised by placing a file with the same name (including directories) in &lt;br /&gt;
 my_moodle_data_dir/customscripts&lt;br /&gt;
 For example:&lt;br /&gt;
 my_moodle_data_dir/customscripts/index.php; my_moodle_data_dir/customscripts/user/view.php&lt;br /&gt;
&lt;br /&gt;
* this is for people making short term changes to VISIBLE web pages in the moodle source code&lt;br /&gt;
** better to use cvs or cogito for long term management of customisations to moodle code&lt;br /&gt;
&lt;br /&gt;
* it seems to have been used extensively only by the [[Moodle_for_Mobiles]] project&lt;br /&gt;
&lt;br /&gt;
* to enable Custom Scripts, add $CFG-&amp;gt;customscript=path/to/customscript/folder (see [[Configuration_file]])&lt;br /&gt;
&lt;br /&gt;
==references==&lt;br /&gt;
* http://moodle.org/mod/forum/discuss.php?d=31895&lt;br /&gt;
* http://tracker.moodle.org/secure/QuickSearch.jspa and type &amp;quot;customscripts&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[category:developper]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=customscripts&amp;diff=22776</id>
		<title>customscripts</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=customscripts&amp;diff=22776"/>
		<updated>2007-04-26T20:32:08Z</updated>

		<summary type="html">&lt;p&gt;Bruno: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Custom Scripts Mechanism==&lt;br /&gt;
&lt;br /&gt;
 Any scripts that are called directly via a url (eg index.php, user/view.php) &lt;br /&gt;
 can now be customised by placing a file with the same name (including directories) in &lt;br /&gt;
 my_moodle_data_dir/customscripts&lt;br /&gt;
 For example:&lt;br /&gt;
 my_moodle_data_dir/customscripts/index.php; my_moodle_data_dir/customscripts/user/view.php&lt;br /&gt;
&lt;br /&gt;
* this is for people making short term changes to VISIBLE web pages in the moodle source code&lt;br /&gt;
** better to use cvs or cogito for long term management of customisations to moodle code&lt;br /&gt;
&lt;br /&gt;
* it seems to have been used extensively only by the [[Moodle_for_Mobiles]] project&lt;br /&gt;
&lt;br /&gt;
* to enable Custom Scripts, add $CFG-&amp;gt;customscript=path/to/customscript/folder (see [[Configuration_file]])&lt;br /&gt;
&lt;br /&gt;
==reference==&lt;br /&gt;
* http://moodle.org/mod/forum/discuss.php?d=31895&lt;br /&gt;
* http://tracker.moodle.org/secure/QuickSearch.jspa and type &amp;quot;customscripts&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[category:developper]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=customscripts&amp;diff=22775</id>
		<title>customscripts</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=customscripts&amp;diff=22775"/>
		<updated>2007-04-26T20:28:53Z</updated>

		<summary type="html">&lt;p&gt;Bruno: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Custom Scripts Mechanism==&lt;br /&gt;
&lt;br /&gt;
 Any scripts that are called directly via a url (eg index.php, user/view.php) &lt;br /&gt;
 can now be customised by placing a file with the same name (including directories) in &lt;br /&gt;
 my_moodle_data_dir/customscripts&lt;br /&gt;
 For example:&lt;br /&gt;
 my_moodle_data_dir/customscripts/index.php; my_moodle_data_dir/customscripts/user/view.php&lt;br /&gt;
&lt;br /&gt;
* this is for people making short term changes to VISIBLE web pages in the moodle source code&lt;br /&gt;
&lt;br /&gt;
* it seems to have been used extensively only by the [[Moodle_for_Mobiles]] project&lt;br /&gt;
&lt;br /&gt;
* to enable Custom Scripts, add $CFG-&amp;gt;customscript=path/to/customscript/folder (see [[Configuration_file]])&lt;br /&gt;
&lt;br /&gt;
==reference==&lt;br /&gt;
* http://moodle.org/mod/forum/discuss.php?d=31895&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=customscripts&amp;diff=22774</id>
		<title>customscripts</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=customscripts&amp;diff=22774"/>
		<updated>2007-04-26T20:28:17Z</updated>

		<summary type="html">&lt;p&gt;Bruno: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Custom Scripts Mechanism==&lt;br /&gt;
&lt;br /&gt;
 Any scripts that are called directly via a url (eg index.php, user/view.php) can now be customised by placing a file with the same name (including directories) in my_moodle_data_dir/customscripts&lt;br /&gt;
 For example:&lt;br /&gt;
 my_moodle_data_dir/customscripts/index.php; my_moodle_data_dir/customscripts/user/view.php&lt;br /&gt;
&lt;br /&gt;
* this is for people making short term changes to VISIBLE web pages in the moodle source code&lt;br /&gt;
&lt;br /&gt;
* it seems to have been used extensively only by the [[Moodle_for_Mobiles]] project&lt;br /&gt;
&lt;br /&gt;
* to enable Custom Scripts, add $CFG-&amp;gt;customscript=path/to/customscript/folder (see [[Configuration_file]])&lt;br /&gt;
&lt;br /&gt;
==reference==&lt;br /&gt;
* http://moodle.org/mod/forum/discuss.php?d=31895&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Layout_course_editing&amp;diff=15761</id>
		<title>Layout course editing</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Layout_course_editing&amp;diff=15761"/>
		<updated>2006-09-12T07:23:10Z</updated>

		<summary type="html">&lt;p&gt;Bruno: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Course Layout Editor==&lt;br /&gt;
__NOTOC__&lt;br /&gt;
* allows graphical (quick) editing of course layout &lt;br /&gt;
** move activities and sections around with javascript&lt;br /&gt;
** add activities from other courses&lt;br /&gt;
** move , add, delete activities and sideblocks&lt;br /&gt;
&lt;br /&gt;
* make a backup copy of the course/format/... that you wish to patch &lt;br /&gt;
* unzip layout2.zip in that format folder &lt;br /&gt;
* copy back the format.php from the backup&#039;d folder&lt;br /&gt;
* make the suggested patch in the README provided&lt;br /&gt;
* a new link should appear when in &amp;quot;course edit&amp;quot; mode pointing to layout.php&lt;br /&gt;
* Timothy Takemoto reports that it works fine in moodle 1.6 (although it is unchanged from moodle 1.5)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
todo: package in standard manner and upload in standard spot on moodle server, and include appropriate credits and licence notice&lt;br /&gt;
&lt;br /&gt;
==Layout Editor Version 1.6a==&lt;br /&gt;
* Created by Audun Hauge, modified by Timothy Takemoto and packaged by Bruno Vernier (c) GPL 2005-2006&lt;br /&gt;
** note: there are at least 2 minor forks of the original version for moodle 1.5&lt;br /&gt;
** Bruno attempted to merge them for moodle 1.6 into this package&lt;br /&gt;
** please let him have any new patches at bruno.vernier@gmail.com&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
# download from http://moodle.org/mod/data/view.php?d=13&amp;amp;rid=49&lt;br /&gt;
# Unzip this file at the root folder of moodle source code&lt;br /&gt;
# You will next need to MANUALLY add a link within your existing course formats to allow for the layout editor to be enabled. &lt;br /&gt;
# edit course/format/&#039;&#039;&#039;whatever&#039;&#039;&#039;/format.php   (or to skip this part, see tip at bottom of this page)&lt;br /&gt;
# Look for the commented line &#039;&#039;&#039;/// Start main column&#039;&#039;&#039; and adjust it to appear as shown below.&lt;br /&gt;
&lt;br /&gt;
    Change:&lt;br /&gt;
    /// Start main column&lt;br /&gt;
    echo &#039;&amp;lt;td id=&amp;quot;middle-column&amp;quot;&amp;gt;&#039;;&lt;br /&gt;
    print_heading_block(get_string(&#039;weeklyoutline&#039;), &#039;outline&#039;);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    To:&lt;br /&gt;
    /// Start main column&lt;br /&gt;
    echo &#039;&amp;lt;td id=&amp;quot;middle-column&amp;quot;&amp;gt;&#039;;&lt;br /&gt;
    $extra = &#039;&#039;;&lt;br /&gt;
    if (isediting($course-&amp;gt;id)) {&lt;br /&gt;
        $extra = &#039; &amp;amp;nbsp; &amp;lt;a title=&amp;quot;&#039;.get_string(&#039;layout&#039;,&#039;layout&#039;).&#039;&amp;quot;&lt;br /&gt;
        href=&amp;quot;&#039;.$CFG-&amp;gt;wwwroot.&#039;/course/layout/layout.php?id=&#039;.$course-&amp;gt;id.&#039;&amp;quot;&amp;gt;&#039;.&lt;br /&gt;
        get_string(&#039;layout&#039;,&#039;layout&#039;).&#039;&amp;lt;/a&amp;gt;&#039;;&lt;br /&gt;
    }&lt;br /&gt;
    print_heading_block(get_string(&#039;weeklyoutline&#039;).$extra, &#039;outline&#039;);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;note:&#039;&#039;&#039; if you are using &amp;quot;topics&amp;quot; or &amp;quot;social&amp;quot;, change the&#039;&#039;&#039; get_string&#039;&#039;&#039; parameter in the line above to the same as in the original line&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Using this Feature==&lt;br /&gt;
* A link to the course layout editor will appear once editing has been turned on.&lt;br /&gt;
* if you don&#039;t want to make the patch above, just create a bookmark like this:&lt;br /&gt;
** (URL to your moodle site)&#039;&#039;&#039;/course/layout/layout.php?id=&#039;&#039;&#039;(course id number)&lt;br /&gt;
* The editor provides a simple to use click and drag interface to allow for a quick and simple adjustment of moodle course design and flow.&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/2x/ca/index.php?title=Marking_block&amp;diff=15757</id>
		<title>Marking block</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/2x/ca/index.php?title=Marking_block&amp;diff=15757"/>
		<updated>2006-09-12T06:25:19Z</updated>

		<summary type="html">&lt;p&gt;Bruno: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&lt;br /&gt;
==purpose:==&lt;br /&gt;
* to allow teacher to quickly see what needs to be &amp;quot;marked&amp;quot; in &#039;&#039;&#039;ONLY&#039;&#039;&#039;:&lt;br /&gt;
# assignments&lt;br /&gt;
# journals &lt;br /&gt;
# lessons&lt;br /&gt;
# forums&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Marking&#039;&#039;&#039; block is a Moodle block add-on that provides a summary of activities awaiting grading. It includes a separate page that provides an alternate gradebook functionality ties to the marking block. This block is restricted to teachers and administrators.&lt;br /&gt;
&lt;br /&gt;
This block displays marking information for newly submitted, resubmitted, and overdue (activities past their defined close dates) activities. The marking page provides the same information and easy access to the grading functions for these activities.&lt;br /&gt;
&lt;br /&gt;
This block cam also display a list of students below a certain grade level.&lt;br /&gt;
&lt;br /&gt;
The block can be configured to display a maximum number of students in each list and to set the grade level to display below.&lt;br /&gt;
&lt;br /&gt;
This directory uses custom code for all activities it summarizes. There are few common activity library functions that can perform the same operations, and thus any new activities to be added will need new code.&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
{{Moodle 1.5}}&lt;br /&gt;
To install and use, unzip this file into your Moodle root directory making sure&lt;br /&gt;
that you &#039;use folder names&#039;. This will add a new block directory (marking) to&lt;br /&gt;
your &#039;/blocks&#039; directory and some language files to your langage directory.&lt;br /&gt;
Once unzipped, visit your admin screen and configure the new block the way you&lt;br /&gt;
want.&lt;br /&gt;
&lt;br /&gt;
===setting up marking block for moodle 1.6+===&lt;br /&gt;
{{Moodle 1.6}}&lt;br /&gt;
* download block_marking_1.6x from http://moodle.org/mod/data/view.php?d=13&amp;amp;rid=445&lt;br /&gt;
* unzip it in the root folder of your moodle directory&lt;br /&gt;
* adjust the settings in &#039;&#039;&#039;admin / configureation /blocks / marking / settings menu&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
* set &#039;&#039;&#039;$CFG-&amp;gt;block_marking_listnum =&#039;&#039;&#039; &#039;&#039;(some number other than the default 2)&#039;&#039;  via the &#039;&#039;&#039;admin / configureation /blocks / marking / settings menu&#039;&#039;&#039; (the default is to show two activites needing marking per section (unmarked / resubmitted / unsubmitted.)&lt;br /&gt;
** set it to a higher number to avoid the illusion that not all items are shown &amp;quot;to be marked&amp;quot;  (or click on the &amp;quot;MORE&amp;quot; button instead)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Credits==&lt;br /&gt;
&lt;br /&gt;
The marking block has been designed and built with the contributions of the&lt;br /&gt;
following people:&lt;br /&gt;
* Fernando Oliviera - G8 First Nation Schools &amp;gt; original design concept of the marking page&lt;br /&gt;
* Darren Smith - Egglescliffe School &amp;gt; orginal design concept of the marking block, and additional design of the marking page&lt;br /&gt;
* Mike Churchward - churchward.ca (mike AT churchward DOT ca)&amp;gt; original technical design and development&lt;br /&gt;
* Bruno Vernier - block packaging and some bug fixes&lt;br /&gt;
&lt;br /&gt;
==To do==&lt;br /&gt;
&lt;br /&gt;
* Make sure all strings are in language file&lt;br /&gt;
* Allow configuration of each section (i.e. enable/disable &#039;below average list&#039;)&lt;br /&gt;
* Create a local block library file and better compartmentalize functions&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* [http://download.moodle.org/download.php/modules/block_marking.zip Download]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=45432 Link to forum post with a lang/en file with all strings filled in]&lt;br /&gt;
&lt;br /&gt;
[[Category:Block (non-standard)]]&lt;/div&gt;</summary>
		<author><name>Bruno</name></author>
	</entry>
</feed>