<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/32/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tdjones</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/32/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tdjones"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/32/en/Special:Contributions/Tdjones"/>
	<updated>2026-04-11T15:43:28Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/32/en/index.php?title=Development:Local_customisation&amp;diff=82644</id>
		<title>Development:Local customisation</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/32/en/index.php?title=Development:Local_customisation&amp;diff=82644"/>
		<updated>2011-04-07T20:51:06Z</updated>

		<summary type="html">&lt;p&gt;Tdjones: /* Other /local/ customisation files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox Project&lt;br /&gt;
|name = Local customisations&lt;br /&gt;
|state = Implemented&lt;br /&gt;
|tracker = MDL-17376, MDL-16438&lt;br /&gt;
|discussion = http://moodle.org/mod/forum/discuss.php?d=126017 http://moodle.org/mod/forum/discuss.php?d=86903&lt;br /&gt;
|assignee = [[User:Petr Škoda (škoďák)|Petr Škoda (škoďák)]], some parts were originally proposed and implemented in 1.9 by Penny Leach&lt;br /&gt;
}}&lt;br /&gt;
{{Moodle 2.0}}&lt;br /&gt;
&lt;br /&gt;
The recommended way to add new functionality to Moodle is to create a new standard plugin (module, block, auth, enrol, etc.).The /local/ plugins are mostly suitable for things that do not fit standard plugins.&lt;br /&gt;
&lt;br /&gt;
== Custom /local/ plugins ==&lt;br /&gt;
&lt;br /&gt;
Local plugins are used in cases when no standard plugin fits, examples are:&lt;br /&gt;
* event consumers communicating with external systems&lt;br /&gt;
* custom definitions of web services and external functions&lt;br /&gt;
* applications that extend moodle at the system level (hub server, amos server, etc.)&lt;br /&gt;
* new database tables used in core hacks (discouraged)&lt;br /&gt;
* new capability definitions used in core hacks&lt;br /&gt;
* custom admin settings&lt;br /&gt;
* extending the navigation block with custom menus [http://moodle.org/mod/forum/discuss.php?d=170325&amp;amp;parent=753095]&lt;br /&gt;
&lt;br /&gt;
=== Standard plugin features: ===&lt;br /&gt;
* /local/xxx/version.php - version of script (must be incremented after changes)&lt;br /&gt;
* /local/xxx/db/install.xml - executed during install (new version.php found)&lt;br /&gt;
* /local/xxx/db/install.php - executed right after install.xml&lt;br /&gt;
* /local/xxx/db/uninstall.php - executed during uninstallation&lt;br /&gt;
* /local/xxx/db/upgrade.php - executed after version.php change&lt;br /&gt;
* /local/xxx/db/access.php - definition of capabilities&lt;br /&gt;
* /local/xxx/db/events.php - event handlers and subscripts&lt;br /&gt;
* /local/xxx/db/messages.php - messaging registration&lt;br /&gt;
* /local/xxx/db/external.php - web services and external functions descriptions&lt;br /&gt;
* /local/xxx/lang/en/local_pluginname.php - language file&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;xxx&#039;&#039; is used instead of your local plugin name, plugins of the same type are installed/upgraded in alphabetical order.&lt;br /&gt;
&lt;br /&gt;
=== List of differences from normal plugins: ===&lt;br /&gt;
* always executed last during install/upgrade - guaranteed by order of plugins in &amp;lt;code&amp;gt;get_plugin_types()&amp;lt;/code&amp;gt;&lt;br /&gt;
* are expected to use event handlers - events are intended for communication core--&amp;gt;plugins only, local plugins are the best candidates for event handlers&lt;br /&gt;
* can add admin settings to any settings page - loaded last when constructing admin tree&lt;br /&gt;
* do not need to have any UI - other plugins are usually visible somewhere&lt;br /&gt;
* some extra hooks (not implemented yet)&lt;br /&gt;
&lt;br /&gt;
== /local/xxx/db/messages.php ==&lt;br /&gt;
Example File Structure:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Defines message providers (types of messages being sent)&lt;br /&gt;
 *&lt;br /&gt;
 * @package mod-forum&lt;br /&gt;
 * @copyright  1999 onwards  Martin Dougiamas  http://moodle.com&lt;br /&gt;
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
$messageproviders = array (&lt;br /&gt;
&lt;br /&gt;
/// Ordinary single forum posts&lt;br /&gt;
    &#039;posts&#039; =&amp;gt; array (&lt;br /&gt;
    )&lt;br /&gt;
&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other /local/ customisation files== &lt;br /&gt;
&lt;br /&gt;
===Customised site defaults=== &lt;br /&gt;
&lt;br /&gt;
Different default site settings can be stored in file /local/defaults.php.&lt;br /&gt;
These new defaults are used during installation, upgrade and later are&lt;br /&gt;
displayed as default values in admin settings. This means that the content&lt;br /&gt;
of the defaults files is usually updated BEFORE installation or upgrade.&lt;br /&gt;
&lt;br /&gt;
These customised defaults are useful especially when using CLI tools&lt;br /&gt;
for installation and upgrade.&lt;br /&gt;
&lt;br /&gt;
Sample /local/defaults.php file content:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$defaults[&#039;moodle&#039;][&#039;forcelogin&#039;] = 1;  // new default for $CFG-&amp;gt;forcelogin&lt;br /&gt;
$defaults[&#039;scorm&#039;][&#039;maxgrade&#039;] = 20;    // default for get_config(&#039;scorm&#039;, &#039;maxgrade&#039;)&lt;br /&gt;
$defaults[&#039;moodlecourse&#039;][&#039;numsections&#039;] = 11;&lt;br /&gt;
$defaults[&#039;moodle&#039;][&#039;hiddenuserfields&#039;] = array(&#039;city&#039;, &#039;country&#039;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
First bracket contains string from column plugin of config_plugins table.&lt;br /&gt;
Second bracket is the name of setting. In the admin settings UI the plugin and&lt;br /&gt;
name of setting is separated by &amp;quot;|&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The values usually correspond to the raw string in config table, with the exception&lt;br /&gt;
of comma separated lists that are usually entered as real arrays.&lt;br /&gt;
&lt;br /&gt;
Please note that not all settings are converted to admin_tree,&lt;br /&gt;
they are mostly intended to be set directly in config.php.&lt;br /&gt;
&lt;br /&gt;
=== 2.0 pre-upgrade script===&lt;br /&gt;
&lt;br /&gt;
You can use /local/upgrade_pre20.php script for any code that needs to&lt;br /&gt;
be executed before the main upgrade to 2.0. Most probably this will&lt;br /&gt;
be used for undoing of old hacks that would otherwise break normal&lt;br /&gt;
2.0 upgrade.&lt;br /&gt;
&lt;br /&gt;
This file is just included directly, there does not need to be any&lt;br /&gt;
function inside. If the execution stops the script is executed again&lt;br /&gt;
during the next upgrade. The first execution of lib/db/upgrade.php&lt;br /&gt;
increments the version number and the pre upgrade script is not&lt;br /&gt;
executed any more.&lt;br /&gt;
&lt;br /&gt;
== Customisations outside of /local/ directory== &lt;br /&gt;
&lt;br /&gt;
=== Forced settings=== &lt;br /&gt;
&lt;br /&gt;
Sometimes it is useful to force some settings and prevent any changes of these settings via the standard admin UI. It is possible to hardcode these settings in config.php.&lt;br /&gt;
&lt;br /&gt;
In case of course settings it is very simply, the values are assigned directly to $CFG properties. In case of plugins the values are specified in a multidimensional array in $CFG-&amp;gt;force_plugin_settings.&lt;br /&gt;
&lt;br /&gt;
Sample code in config.php&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;allowobjectembed = 0;&lt;br /&gt;
$CFG-&amp;gt;forced_plugin_settings = array(&#039;page&#039;=&amp;gt;array(&#039;displayoptions&#039;=&amp;gt;5, &#039;requiremodintro&#039;=&amp;gt;1), &#039;folder&#039;=&amp;gt;&#039;requiremodintro&#039;=&amp;gt;1);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Local language customisations=== &lt;br /&gt;
&lt;br /&gt;
Moodle supports other type of local customisation of standard language&lt;br /&gt;
packs. If you want to create your own language pack based on another&lt;br /&gt;
language create new dataroot directory with &amp;quot;_local&amp;quot; suffix, for example&lt;br /&gt;
following file with content changes string &amp;quot;Login&amp;quot; to &amp;quot;Sign in&amp;quot;:&lt;br /&gt;
moodledata/lang/en_local&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
  $string[&#039;login&#039;] = &#039;Sign in&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
See also https://docs.moodle.org/en/Language_editing&lt;br /&gt;
&lt;br /&gt;
=== Custom script injection=== &lt;br /&gt;
&lt;br /&gt;
Very old customisation option that allows you to modify scripts by injecting&lt;br /&gt;
code right after the require &#039;config.php&#039; call.&lt;br /&gt;
&lt;br /&gt;
This setting is enabled by manually setting $CFG-&amp;gt;customscripts variable&lt;br /&gt;
in config.php script. The value is expected to be full path to directory&lt;br /&gt;
with the same structure as dirroot. Please note this hack only affects&lt;br /&gt;
files that actually include the config.php!&lt;br /&gt;
&lt;br /&gt;
; Examples:&lt;br /&gt;
* disable one specific moodle page without code modification&lt;br /&gt;
* alter page parameters on the fly&lt;br /&gt;
&lt;br /&gt;
=== Direct code modifications=== &lt;br /&gt;
This is usually the last resort, if possible do not do it. And if you still do it use some version control system (preferably git).&lt;br /&gt;
&lt;br /&gt;
=== Direct database modifications=== &lt;br /&gt;
Very strongly discouraged! Sometimes field lengths may be modified without side effects. Adding or removing of db fields will most probably cause major problems during future upgrades. New database tables should be added only from plugins.&lt;br /&gt;
&lt;br /&gt;
== Local customisations in previous versions ==&lt;br /&gt;
Previous versions include only partial support for customisations in /local/ directory.&lt;br /&gt;
&lt;br /&gt;
=== List of local customisations in 1.9.x: ===&lt;br /&gt;
* /local/cron.php - custom cron jobs&lt;br /&gt;
* /local/settings.php - custom admin settings&lt;br /&gt;
* /local/db/upgrade.php - general modifications&lt;br /&gt;
* /local/lang/* - custom strings&lt;br /&gt;
* /local/lib.php - local_delete_course()&lt;br /&gt;
&lt;br /&gt;
=== Migration from old 1.9.x /local/: ===&lt;br /&gt;
* &amp;lt;code&amp;gt;local/*&amp;lt;/code&amp;gt; needs to be copied to new directory&lt;br /&gt;
* &amp;lt;code&amp;gt;local/xxxx/db/install.php&amp;lt;/code&amp;gt; is intended for first installation, originally everything was in upgrade.php&lt;br /&gt;
* events are used instead of hooks&lt;br /&gt;
* upgrade code needs to migrate old settings, events, etc. directly in core db tables - such as change component strings and capability names from db/install.php or manually before/after upgrade&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=170325&amp;amp;parent=753095 Extending navigation block]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/discuss.php?d=86903 Local Customisations] forum discussion&lt;br /&gt;
* http://cvs.moodle.org/moodle/local/readme.txt?view=markup&lt;br /&gt;
* [[Local customisation (Moodle 1.9)]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer|Local customisation]]&lt;/div&gt;</summary>
		<author><name>Tdjones</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/32/en/index.php?title=Development:DML_functions&amp;diff=82385</id>
		<title>Development:DML functions</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/32/en/index.php?title=Development:DML_functions&amp;diff=82385"/>
		<updated>2011-03-29T16:40:12Z</updated>

		<summary type="html">&lt;p&gt;Tdjones: /* Inserting Records */&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;
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;
o $DB-&amp;gt;get_records_list($table, $field, array $values, $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;
====Example(s)====&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$record = new stdClass();&lt;br /&gt;
$record-&amp;gt;name         = &#039;overview&#039;;&lt;br /&gt;
$record-&amp;gt;displayorder = &#039;10000&#039;;&lt;br /&gt;
$DB-&amp;gt;insert_record(&#039;quiz_report&#039;, $record);&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>Tdjones</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/32/en/index.php?title=MNet&amp;diff=80992</id>
		<title>MNet</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/32/en/index.php?title=MNet&amp;diff=80992"/>
		<updated>2011-02-01T21:45:58Z</updated>

		<summary type="html">&lt;p&gt;Tdjones: /* Using it */&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;
For Moodle 2.0, you need to enable Networking (under the Site Administration &amp;gt; Advanced Features menu). This will add the &amp;quot;Networking&amp;quot; menu to the Site Administration menu.&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;
## (Although discussion exists about removing this setting, it is still required as of 2.0.1)  [http://moodle.org/mod/forum/discuss.php?d=141491] ). On both servers: &lt;br /&gt;
### For 2.0, go to &#039;&#039;Administration &amp;gt; Plugins &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039;. Enable &#039;&#039;MNet Authentication&#039;&#039; by clicking the &#039;enable&#039; icon.&lt;br /&gt;
### For 1.9, go to &#039;&#039;Administration &amp;gt; Users &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039;  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(SSO Identity Provider) publish and subscribe, and SSO-SP(SSO Service Provider) publish and subscribe.&lt;br /&gt;
## Do the equivalent on MoodleB. (By both publishing and subscribing you allow users to move freely between the two servers. By only publishing or subscribing between servers you create a one way traversal)&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;
### eg. enabling for &#039;&#039;Authenticated user&#039;&#039; allows any authenticated user to roam between servers.&lt;br /&gt;
## On both servers, 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 the server you want to receive enrolments:&lt;br /&gt;
### For 2.0, go to &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Enrolments &amp;gt; Manage enrol plugins&#039;&#039;. Enable &#039;&#039;MNet remote enrolments&#039;&#039; by clicking the &#039;enable&#039; icon. (For &#039;&#039;MNet remote enrolments&#039;&#039; settings info see [[MNet_remote_enrolments|MNet remote enrolments]])&lt;br /&gt;
### For 1.9, go to &#039;&#039;Administration &amp;gt; Users &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039;  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 Enrolment publish and/or subscribe.&lt;br /&gt;
## Do the equivalent on MoodleB.&lt;br /&gt;
## On every course you want to allow enrolments into:&lt;br /&gt;
### Enter course and go to &#039;&#039;Settings -&amp;gt; Course administration -&amp;gt; Users -&amp;gt; Enrolment methods&#039;&#039;&lt;br /&gt;
### From &#039;&#039;Add method&#039;&#039; drop-down select &#039;&#039;MNet remote enrolments&#039;&#039;&lt;br /&gt;
### On the new screen select the &#039;&#039;Remote host&#039;&#039; you want to allow enrolments from, the Role for the enrolled users, and click save. (Note: you can only add a single &#039;&#039;MNet remote enrolments&#039;&#039; method per course.)&lt;br /&gt;
&lt;br /&gt;
===Using it===&lt;br /&gt;
# For 1.9: 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;
# For 2.0: in MoodleA go to &#039;&#039;Admin &amp;gt; Networking &amp;gt; Remote enrolments client&#039;&#039;. You will see MoodleB listed. Click on &#039;&#039;Edit enrolments&#039;&#039; button beside MoodleB and you will see a list of courses that MoodleB offers for remote enrolment. Click &#039;Edit enrolments&#039;&#039;, select the users you want to enroll, and then click Add to enroll them in the course.&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>Tdjones</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/32/en/index.php?title=MNet&amp;diff=80991</id>
		<title>MNet</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/32/en/index.php?title=MNet&amp;diff=80991"/>
		<updated>2011-02-01T21:45:24Z</updated>

		<summary type="html">&lt;p&gt;Tdjones: /* 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;
For Moodle 2.0, you need to enable Networking (under the Site Administration &amp;gt; Advanced Features menu). This will add the &amp;quot;Networking&amp;quot; menu to the Site Administration menu.&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;
## (Although discussion exists about removing this setting, it is still required as of 2.0.1)  [http://moodle.org/mod/forum/discuss.php?d=141491] ). On both servers: &lt;br /&gt;
### For 2.0, go to &#039;&#039;Administration &amp;gt; Plugins &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039;. Enable &#039;&#039;MNet Authentication&#039;&#039; by clicking the &#039;enable&#039; icon.&lt;br /&gt;
### For 1.9, go to &#039;&#039;Administration &amp;gt; Users &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039;  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(SSO Identity Provider) publish and subscribe, and SSO-SP(SSO Service Provider) publish and subscribe.&lt;br /&gt;
## Do the equivalent on MoodleB. (By both publishing and subscribing you allow users to move freely between the two servers. By only publishing or subscribing between servers you create a one way traversal)&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;
### eg. enabling for &#039;&#039;Authenticated user&#039;&#039; allows any authenticated user to roam between servers.&lt;br /&gt;
## On both servers, 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 the server you want to receive enrolments:&lt;br /&gt;
### For 2.0, go to &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Enrolments &amp;gt; Manage enrol plugins&#039;&#039;. Enable &#039;&#039;MNet remote enrolments&#039;&#039; by clicking the &#039;enable&#039; icon. (For &#039;&#039;MNet remote enrolments&#039;&#039; settings info see [[MNet_remote_enrolments|MNet remote enrolments]])&lt;br /&gt;
### For 1.9, go to &#039;&#039;Administration &amp;gt; Users &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039;  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 Enrolment publish and/or subscribe.&lt;br /&gt;
## Do the equivalent on MoodleB.&lt;br /&gt;
## On every course you want to allow enrolments into:&lt;br /&gt;
### Enter course and go to &#039;&#039;Settings -&amp;gt; Course administration -&amp;gt; Users -&amp;gt; Enrolment methods&#039;&#039;&lt;br /&gt;
### From &#039;&#039;Add method&#039;&#039; drop-down select &#039;&#039;MNet remote enrolments&#039;&#039;&lt;br /&gt;
### On the new screen select the &#039;&#039;Remote host&#039;&#039; you want to allow enrolments from, the Role for the enrolled users, and click save. (Note: you can only add a single &#039;&#039;MNet remote enrolments&#039;&#039; method per 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>Tdjones</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/32/en/index.php?title=MNet&amp;diff=80990</id>
		<title>MNet</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/32/en/index.php?title=MNet&amp;diff=80990"/>
		<updated>2011-02-01T21:24:00Z</updated>

		<summary type="html">&lt;p&gt;Tdjones: /* 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;
For Moodle 2.0, you need to enable Networking (under the Site Administration &amp;gt; Advanced Features menu). This will add the &amp;quot;Networking&amp;quot; menu to the Site Administration menu.&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;
## (Although discussion exists about removing this setting, it is still required as of 2.0.1)  [http://moodle.org/mod/forum/discuss.php?d=141491] ). On both servers: &lt;br /&gt;
### For 2.0, go to &#039;&#039;Administration &amp;gt; Plugins &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039;. Enable &#039;&#039;MNet Authentication&#039;&#039; by clicking the &#039;enable&#039; icon.&lt;br /&gt;
### For 1.9, go to &#039;&#039;Administration &amp;gt; Users &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039;  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(SSO Identity Provider) publish and subscribe, and SSO-SP(SSO Service Provider) publish and subscribe.&lt;br /&gt;
## Do the equivalent on MoodleB. (By both publishing and subscribing you allow users to move freely between the two servers. By only publishing or subscribing between servers you create a one way traversal)&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;
### eg. enabling for &#039;&#039;Authenticated user&#039;&#039; allows any authenticated user to roam between servers.&lt;br /&gt;
## On both servers, 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 the server you want to receive enrolments:&lt;br /&gt;
### For 2.0, go to &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Enrolments &amp;gt; Manage enrol plugins&#039;&#039;. Enable &#039;&#039;MNet remote enrolments&#039;&#039; by clicking the &#039;enable&#039; icon. (For &#039;&#039;MNet remote enrolments&#039;&#039; settings info see [[MNet_remote_enrolments|MNet remote enrolments]])&lt;br /&gt;
### For 1.9, go to &#039;&#039;Administration &amp;gt; Users &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039;  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 Enrolment publish and/or subscribe.&lt;br /&gt;
## Do the equivalent on MoodleB.&lt;br /&gt;
## On every course you want to allow enrolments into:&lt;br /&gt;
### Enter course and go to &#039;&#039;Settings -&amp;gt; Course administration -&amp;gt; Users -&amp;gt; Enrolment methods&#039;&#039;&lt;br /&gt;
### From &#039;&#039;Add method&#039;&#039; drop-down select &#039;&#039;MNet remote enrolments&#039;&#039;&lt;br /&gt;
### On the new screen select the &#039;&#039;Remote host&#039;&#039; you want to allow enrolments from, the Role for the enrolled users, and click save. (Note: you can only add a single &#039;&#039;MNet remote enrolments&#039;&#039; method per course.)&lt;br /&gt;
## To use:&lt;br /&gt;
### For 1.9: 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;
### For 2.0: in MoodleA go to &#039;&#039;Admin &amp;gt; Networking &amp;gt; Remote enrolments client&#039;&#039;. You will see MoodleB listed. Click on &#039;&#039;Edit enrolments&#039;&#039; button beside MoodleB and you will see a list of courses that MoodleB offers for remote enrolment. Click &#039;Edit enrolments&#039;&#039;, select the users you want to enroll, and then click Add to enroll them in the 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>Tdjones</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/32/en/index.php?title=Activity_completion&amp;diff=78599</id>
		<title>Activity completion</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/32/en/index.php?title=Activity_completion&amp;diff=78599"/>
		<updated>2010-12-02T18:33:46Z</updated>

		<summary type="html">&lt;p&gt;Tdjones: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.0}}Activity completion is a new feature in Moodle 2.0 and is found under the advanced settings of most activities.  This feature allows the teacher to make student entry into the activity conditional upon meeting standards of completion by another activity.  &lt;br /&gt;
&lt;br /&gt;
For example, a teacher will set a Quiz to be dependent upon the student completing a specific Lesson or Assignment activity.&lt;br /&gt;
&lt;br /&gt;
:Note: When it was under development activity completion was called [[Conditional activities]] and there were contributed modules in pre 2.0 Moodles called [[Activity locking]].&lt;br /&gt;
&lt;br /&gt;
==Enabling activity completion==&lt;br /&gt;
&lt;br /&gt;
To use activity completion, the following settings must be enabled:&lt;br /&gt;
* By an administrator by checking the &#039;&#039;&amp;quot;Enable completion tracking&amp;quot;&#039;&#039; and &#039;&#039;&amp;quot;Enable conditional availability&amp;quot;&#039;&#039; checkboxes in &#039;&#039;Site Administration &amp;gt; [[Advanced features]]&#039;&#039;.&lt;br /&gt;
* By an administrator/instructor by selecting &#039;&#039;&amp;quot;Enabled, control via completion and activity settings&amp;quot;&#039;&#039; option in drop-down box for &#039;&#039;&amp;quot;Completion tracking&amp;quot;&#039;&#039; under &#039;&#039;&amp;quot;Student progress&amp;quot;&#039;&#039; area in the &#039;&#039;&amp;quot;Course administration&amp;quot; &amp;gt; &amp;quot;Edit settings&amp;quot;&#039;&#039; page.&lt;br /&gt;
&lt;br /&gt;
After the above settings are enabled, an Activity completion section will appear for teachers on the edit activity page.&lt;br /&gt;
&lt;br /&gt;
Essentially this asks the teacher what is necessary for this activity to be considered complete. It is found in the activity setting&#039;s &amp;quot;&#039;&#039;&#039;Activity completion&#039;&#039;&#039;&amp;quot; This condition can then be checked in the restrict condition area in another activity setting (see restrict availability condition above).&lt;br /&gt;
&lt;br /&gt;
==Require view==&lt;br /&gt;
&lt;br /&gt;
When this option is turned on, students have to view the activity in order to complete it.&lt;br /&gt;
&lt;br /&gt;
* In most cases, clicking the link is enough to &#039;view&#039; the activity.&lt;br /&gt;
* You should usually not turn on the &#039;view&#039; condition if you have other requirements - this makes extra work for the server and it&#039;s unlikely that a student could meet any other conditions without viewing the activity.&lt;br /&gt;
&lt;br /&gt;
==Require grade==&lt;br /&gt;
&lt;br /&gt;
When this option is turned on, students have to get a grade on the activity in order to complete it. For example, a quiz would be marked completed as soon as the user submits it.&lt;br /&gt;
&lt;br /&gt;
It does not matter how well the student did. Getting any grade will mark the activity completed.&lt;br /&gt;
&lt;br /&gt;
It is possible to distinguish between &#039;pass&#039; and &#039;fail&#039; grades so that the activity becomes &#039;completed, passed&#039; or &#039;completed, not passed&#039; instead of just &#039;completed&#039;. These results show a different icon and alternative text.&lt;br /&gt;
&lt;br /&gt;
To set this up, you need to specify the pass value for this activity&#039;s individual grade:&lt;br /&gt;
&lt;br /&gt;
# Go to the course gradebook by clicking the &#039;Grades&#039; link on the course administration block.&lt;br /&gt;
# From the &#039;Choose an action&#039; dropdown, pick &#039;Categories and items&#039;.&lt;br /&gt;
# Click the Edit icon next to the grade item for this activity.&lt;br /&gt;
# Turn on &#039;Show Advanced&#039;.&lt;br /&gt;
# Type a grade value (e.g. 5.0) in the &#039;Grade to pass&#039; box.&lt;br /&gt;
&lt;br /&gt;
Once you have done this, anybody submitting the quiz will receive either the pass or fail completion icon. If the quiz can be taken multiple times, the completion icon will automatically update whenever the grade does.&lt;br /&gt;
&lt;br /&gt;
There is one limitation: this only works if grades are immediately visible to students. The grade must be neither permanently hidden, nor hidden until a certain date. If a grade is hidden then only the standard &#039;completed&#039; state will be displayed - even once the hidden date has passed. &lt;br /&gt;
&lt;br /&gt;
==Locked completion options==&lt;br /&gt;
&lt;br /&gt;
If at least one person has completed an activity, completion options are &#039;locked&#039;. This is because changing these options may result in unexpected behaviour.&lt;br /&gt;
&lt;br /&gt;
If somebody has ticked an activity as manually completed, and you then set it to automatic completion, the activity will become unticked - very confusing for the student who had already ticked it!&lt;br /&gt;
&lt;br /&gt;
It is best not to unlock options unless you are sure it won&#039;t cause problems - for example, if you know that students don&#039;t have access to the course yet, so it will only be staff who have marked the activity completed when testing.&lt;br /&gt;
&lt;br /&gt;
===What happens when you unlock===&lt;br /&gt;
&lt;br /&gt;
Once you unlock options and then click &#039;Save changes&#039;, all completion information for the activity will be deleted and, if possible, regenerated according to the new settings.&lt;br /&gt;
&lt;br /&gt;
* If the new completion option is manual, everyone will be set to &#039;not completed&#039; regardless of any previous setting.&lt;br /&gt;
* If it is automatic then, depending on the options chosen, the system may or may not be able to construct a correct current value for everyone.&lt;br /&gt;
** The &#039;viewed&#039; requirement will not work - even if a student has viewed the activity before, it will not be marked completed until they view it again.&lt;br /&gt;
** Most other options will be recalculated successfully.&lt;br /&gt;
&lt;br /&gt;
If you change completion options while a student is logged in, they may not see the changes for some minutes.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://www.youtube.com/watch?v=G6vjgfMae8U Activity completion in Moodle 2.0 video]&lt;br /&gt;
* [[Course completion]]&lt;br /&gt;
* [[Conditional activities]]&lt;br /&gt;
* [[Activity locking]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Completion]]&lt;/div&gt;</summary>
		<author><name>Tdjones</name></author>
	</entry>
</feed>