<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/310/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Maherne</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/310/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Maherne"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/Special:Contributions/Maherne"/>
	<updated>2026-05-11T10:18:34Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Managing_roles&amp;diff=131567</id>
		<title>Managing roles</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Managing_roles&amp;diff=131567"/>
		<updated>2018-07-27T15:39:03Z</updated>

		<summary type="html">&lt;p&gt;Maherne: /* Allow role to view */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Roles}}&lt;br /&gt;
Managing overall role capabilities can be done by an administrator using  &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.   This is the place to add custom roles or modify existing roles.   The &amp;quot;Manage roles&amp;quot; tab, allows the system administrator to edit any one of over 350 different capabilities associated with any role.   The &amp;quot;Allow role assignments&amp;quot;, &amp;quot;Allow role overrides&amp;quot; and &amp;quot;Allow role switches&amp;quot; contain a matrix which give the ability for a specific role to work with other specific roles. &lt;br /&gt;
&lt;br /&gt;
==Manage roles==&lt;br /&gt;
&lt;br /&gt;
The &#039;Manage roles&#039; tab contains a list of roles on your site. The edit column contains icons for editing, deleting roles and copying roles, and for moving them up or down in the list (affecting the way that roles are listed around Moodle).&lt;br /&gt;
&lt;br /&gt;
[[Image:Allowroletoview.png]]&lt;br /&gt;
&lt;br /&gt;
To edit a role:&lt;br /&gt;
#Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.&lt;br /&gt;
#Click the edit icon opposite the role you want to edit. For example &amp;quot;student&amp;quot;.&lt;br /&gt;
#On the editing role page, change permissions as required for each capability.&lt;br /&gt;
#Scroll to the bottom of the page and click the &amp;quot;Save changes&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
See [[Creating custom roles]] for information about adding a new role and creating a duplicate role.&lt;br /&gt;
&lt;br /&gt;
==Role name localisation==&lt;br /&gt;
&lt;br /&gt;
If a standard role name or description is empty Moodle uses a default string from the current language pack. Custom roles can be customised using multilang syntax.&lt;br /&gt;
&lt;br /&gt;
You may also override the role names separately in each course.&lt;br /&gt;
&lt;br /&gt;
==Resetting a role==&lt;br /&gt;
&lt;br /&gt;
To reset a role back to the default permissions:&lt;br /&gt;
#Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.&lt;br /&gt;
#Click on the name of the role, for example &amp;quot;student&amp;quot;.&lt;br /&gt;
#Click the &#039;Reset&#039; button.&lt;br /&gt;
&lt;br /&gt;
Note that if you have students who have been given extra permissions at course and/or activity levels (such as forum ratings), then they will no longer be able to do this once the role has been reset to its default. A teacher would need to go back and set up these extra permissions in the course/activity levels again.&lt;br /&gt;
&lt;br /&gt;
==Allow role assignments==&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Allow role assignments&amp;quot; tab allows (or does not allow) a specific role to be able to assign specific roles to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Enabling teachers to assign other teachers===&lt;br /&gt;
By default, teachers can only assign other users the roles of non-editing teachers, students and guests. If you want teachers to be able to assign other teachers in their course, you can allow the role assignment:&lt;br /&gt;
&lt;br /&gt;
#Click on &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.&lt;br /&gt;
#Click the Allow role assignments tab.&lt;br /&gt;
#Click the checkbox where the teacher row and column intersect.&lt;br /&gt;
#Click the &amp;quot;Save changes&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
==Allow role overrides==&lt;br /&gt;
The &amp;quot;Allow role overrides&amp;quot; tab allows (or does not allow) a specific role to be able to override specific roles for a user.  For example, it might allow a teacher role to override a student&#039;s role to a non-editing teacher&#039;s role. &lt;br /&gt;
&lt;br /&gt;
:Note that the settings only apply to roles that have the capabilities [[Capabilities/moodle/role:override|moodle/role:override]] or [[Capabilities/moodle/role:safeoverride|moodle/role:safeoverride]] allowed.&lt;br /&gt;
&lt;br /&gt;
==Allow role switches==&lt;br /&gt;
The &amp;quot;Allow role switches&amp;quot; tab allows (or does not allow) a specific role to be able to temporarily change their role to another specific role.  For example, this might allow a users assigned to a custom role in a course to see &amp;quot;Student&amp;quot; in the Settings &amp;gt; Switch role list.   &lt;br /&gt;
 &lt;br /&gt;
:Note: the selected role must also have the moodle/role:switchroles capability to be able to switch.&lt;br /&gt;
&lt;br /&gt;
==Allow role to view==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New in 3.5:&#039;&#039;&#039; This setting allows the administrator to decide which roles users can see, search and filter by, according to their existing role.&lt;br /&gt;
&lt;br /&gt;
==Roles capabilities==&lt;br /&gt;
&lt;br /&gt;
*[[Capabilities/moodle/role:manage|Create and manage roles]]&lt;br /&gt;
*[[Capabilities/moodle/role:assign|Assign roles to users]]&lt;br /&gt;
*[[Capabilities/moodle/role:switchroles|Switch to other roles]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Site administration]]&lt;br /&gt;
&lt;br /&gt;
[[es:Gestionar_roles]]&lt;br /&gt;
[[eu:Rolak_kudeatu]]&lt;br /&gt;
[[fr:Gestion des rôles]]&lt;br /&gt;
[[ja:ロールの管理]]&lt;br /&gt;
[[de:Rollen verwalten]]&lt;/div&gt;</summary>
		<author><name>Maherne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Managing_roles&amp;diff=131566</id>
		<title>Managing roles</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Managing_roles&amp;diff=131566"/>
		<updated>2018-07-27T15:37:39Z</updated>

		<summary type="html">&lt;p&gt;Maherne: Undo revision 131565 by Maherne (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Roles}}&lt;br /&gt;
Managing overall role capabilities can be done by an administrator using  &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.   This is the place to add custom roles or modify existing roles.   The &amp;quot;Manage roles&amp;quot; tab, allows the system administrator to edit any one of over 350 different capabilities associated with any role.   The &amp;quot;Allow role assignments&amp;quot;, &amp;quot;Allow role overrides&amp;quot; and &amp;quot;Allow role switches&amp;quot; contain a matrix which give the ability for a specific role to work with other specific roles. &lt;br /&gt;
&lt;br /&gt;
==Manage roles==&lt;br /&gt;
&lt;br /&gt;
The &#039;Manage roles&#039; tab contains a list of roles on your site. The edit column contains icons for editing, deleting roles and copying roles, and for moving them up or down in the list (affecting the way that roles are listed around Moodle).&lt;br /&gt;
&lt;br /&gt;
[[Image:Allowroletoview.png]]&lt;br /&gt;
&lt;br /&gt;
To edit a role:&lt;br /&gt;
#Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.&lt;br /&gt;
#Click the edit icon opposite the role you want to edit. For example &amp;quot;student&amp;quot;.&lt;br /&gt;
#On the editing role page, change permissions as required for each capability.&lt;br /&gt;
#Scroll to the bottom of the page and click the &amp;quot;Save changes&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
See [[Creating custom roles]] for information about adding a new role and creating a duplicate role.&lt;br /&gt;
&lt;br /&gt;
==Role name localisation==&lt;br /&gt;
&lt;br /&gt;
If a standard role name or description is empty Moodle uses a default string from the current language pack. Custom roles can be customised using multilang syntax.&lt;br /&gt;
&lt;br /&gt;
You may also override the role names separately in each course.&lt;br /&gt;
&lt;br /&gt;
==Resetting a role==&lt;br /&gt;
&lt;br /&gt;
To reset a role back to the default permissions:&lt;br /&gt;
#Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.&lt;br /&gt;
#Click on the name of the role, for example &amp;quot;student&amp;quot;.&lt;br /&gt;
#Click the &#039;Reset&#039; button.&lt;br /&gt;
&lt;br /&gt;
Note that if you have students who have been given extra permissions at course and/or activity levels (such as forum ratings), then they will no longer be able to do this once the role has been reset to its default. A teacher would need to go back and set up these extra permissions in the course/activity levels again.&lt;br /&gt;
&lt;br /&gt;
==Allow role assignments==&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Allow role assignments&amp;quot; tab allows (or does not allow) a specific role to be able to assign specific roles to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Enabling teachers to assign other teachers===&lt;br /&gt;
By default, teachers can only assign other users the roles of non-editing teachers, students and guests. If you want teachers to be able to assign other teachers in their course, you can allow the role assignment:&lt;br /&gt;
&lt;br /&gt;
#Click on &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.&lt;br /&gt;
#Click the Allow role assignments tab.&lt;br /&gt;
#Click the checkbox where the teacher row and column intersect.&lt;br /&gt;
#Click the &amp;quot;Save changes&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
==Allow role overrides==&lt;br /&gt;
The &amp;quot;Allow role overrides&amp;quot; tab allows (or does not allow) a specific role to be able to override specific roles for a user.  For example, it might allow a teacher role to override a student&#039;s role to a non-editing teacher&#039;s role. &lt;br /&gt;
&lt;br /&gt;
:Note that the settings only apply to roles that have the capabilities [[Capabilities/moodle/role:override|moodle/role:override]] or [[Capabilities/moodle/role:safeoverride|moodle/role:safeoverride]] allowed.&lt;br /&gt;
&lt;br /&gt;
==Allow role switches==&lt;br /&gt;
The &amp;quot;Allow role switches&amp;quot; tab allows (or does not allow) a specific role to be able to temporarily change their role to another specific role.  For example, this might allow a users assigned to a custom role in a course to see &amp;quot;Student&amp;quot; in the Settings &amp;gt; Switch role list.   &lt;br /&gt;
 &lt;br /&gt;
:Note: the selected role must also have the moodle/role:switchroles capability to be able to switch.&lt;br /&gt;
&lt;br /&gt;
==Allow role to view==&lt;br /&gt;
&lt;br /&gt;
{{Moodle 3.4}}&lt;br /&gt;
&lt;br /&gt;
This setting allows the administrator to decide which roles users can see, search and filter by, according to their existing role.&lt;br /&gt;
&lt;br /&gt;
==Roles capabilities==&lt;br /&gt;
&lt;br /&gt;
*[[Capabilities/moodle/role:manage|Create and manage roles]]&lt;br /&gt;
*[[Capabilities/moodle/role:assign|Assign roles to users]]&lt;br /&gt;
*[[Capabilities/moodle/role:switchroles|Switch to other roles]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Site administration]]&lt;br /&gt;
&lt;br /&gt;
[[es:Gestionar_roles]]&lt;br /&gt;
[[eu:Rolak_kudeatu]]&lt;br /&gt;
[[fr:Gestion des rôles]]&lt;br /&gt;
[[ja:ロールの管理]]&lt;br /&gt;
[[de:Rollen verwalten]]&lt;/div&gt;</summary>
		<author><name>Maherne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Managing_roles&amp;diff=131565</id>
		<title>Managing roles</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Managing_roles&amp;diff=131565"/>
		<updated>2018-07-27T15:36:07Z</updated>

		<summary type="html">&lt;p&gt;Maherne: /* Allow role to view */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Roles}}&lt;br /&gt;
Managing overall role capabilities can be done by an administrator using  &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.   This is the place to add custom roles or modify existing roles.   The &amp;quot;Manage roles&amp;quot; tab, allows the system administrator to edit any one of over 350 different capabilities associated with any role.   The &amp;quot;Allow role assignments&amp;quot;, &amp;quot;Allow role overrides&amp;quot; and &amp;quot;Allow role switches&amp;quot; contain a matrix which give the ability for a specific role to work with other specific roles. &lt;br /&gt;
&lt;br /&gt;
==Manage roles==&lt;br /&gt;
&lt;br /&gt;
The &#039;Manage roles&#039; tab contains a list of roles on your site. The edit column contains icons for editing, deleting roles and copying roles, and for moving them up or down in the list (affecting the way that roles are listed around Moodle).&lt;br /&gt;
&lt;br /&gt;
[[Image:Allowroletoview.png]]&lt;br /&gt;
&lt;br /&gt;
To edit a role:&lt;br /&gt;
#Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.&lt;br /&gt;
#Click the edit icon opposite the role you want to edit. For example &amp;quot;student&amp;quot;.&lt;br /&gt;
#On the editing role page, change permissions as required for each capability.&lt;br /&gt;
#Scroll to the bottom of the page and click the &amp;quot;Save changes&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
See [[Creating custom roles]] for information about adding a new role and creating a duplicate role.&lt;br /&gt;
&lt;br /&gt;
==Role name localisation==&lt;br /&gt;
&lt;br /&gt;
If a standard role name or description is empty Moodle uses a default string from the current language pack. Custom roles can be customised using multilang syntax.&lt;br /&gt;
&lt;br /&gt;
You may also override the role names separately in each course.&lt;br /&gt;
&lt;br /&gt;
==Resetting a role==&lt;br /&gt;
&lt;br /&gt;
To reset a role back to the default permissions:&lt;br /&gt;
#Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.&lt;br /&gt;
#Click on the name of the role, for example &amp;quot;student&amp;quot;.&lt;br /&gt;
#Click the &#039;Reset&#039; button.&lt;br /&gt;
&lt;br /&gt;
Note that if you have students who have been given extra permissions at course and/or activity levels (such as forum ratings), then they will no longer be able to do this once the role has been reset to its default. A teacher would need to go back and set up these extra permissions in the course/activity levels again.&lt;br /&gt;
&lt;br /&gt;
==Allow role assignments==&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Allow role assignments&amp;quot; tab allows (or does not allow) a specific role to be able to assign specific roles to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Enabling teachers to assign other teachers===&lt;br /&gt;
By default, teachers can only assign other users the roles of non-editing teachers, students and guests. If you want teachers to be able to assign other teachers in their course, you can allow the role assignment:&lt;br /&gt;
&lt;br /&gt;
#Click on &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.&lt;br /&gt;
#Click the Allow role assignments tab.&lt;br /&gt;
#Click the checkbox where the teacher row and column intersect.&lt;br /&gt;
#Click the &amp;quot;Save changes&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
==Allow role overrides==&lt;br /&gt;
The &amp;quot;Allow role overrides&amp;quot; tab allows (or does not allow) a specific role to be able to override specific roles for a user.  For example, it might allow a teacher role to override a student&#039;s role to a non-editing teacher&#039;s role. &lt;br /&gt;
&lt;br /&gt;
:Note that the settings only apply to roles that have the capabilities [[Capabilities/moodle/role:override|moodle/role:override]] or [[Capabilities/moodle/role:safeoverride|moodle/role:safeoverride]] allowed.&lt;br /&gt;
&lt;br /&gt;
==Allow role switches==&lt;br /&gt;
The &amp;quot;Allow role switches&amp;quot; tab allows (or does not allow) a specific role to be able to temporarily change their role to another specific role.  For example, this might allow a users assigned to a custom role in a course to see &amp;quot;Student&amp;quot; in the Settings &amp;gt; Switch role list.   &lt;br /&gt;
 &lt;br /&gt;
:Note: the selected role must also have the moodle/role:switchroles capability to be able to switch.&lt;br /&gt;
&lt;br /&gt;
==Allow role to view==&lt;br /&gt;
&lt;br /&gt;
{{Moodle 3.1}}&lt;br /&gt;
&lt;br /&gt;
This setting allows the administrator to decide which roles users can see, search and filter by, according to their existing role.&lt;br /&gt;
&lt;br /&gt;
==Roles capabilities==&lt;br /&gt;
&lt;br /&gt;
*[[Capabilities/moodle/role:manage|Create and manage roles]]&lt;br /&gt;
*[[Capabilities/moodle/role:assign|Assign roles to users]]&lt;br /&gt;
*[[Capabilities/moodle/role:switchroles|Switch to other roles]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Site administration]]&lt;br /&gt;
&lt;br /&gt;
[[es:Gestionar_roles]]&lt;br /&gt;
[[eu:Rolak_kudeatu]]&lt;br /&gt;
[[fr:Gestion des rôles]]&lt;br /&gt;
[[ja:ロールの管理]]&lt;br /&gt;
[[de:Rollen verwalten]]&lt;/div&gt;</summary>
		<author><name>Maherne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Managing_roles&amp;diff=131564</id>
		<title>Managing roles</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Managing_roles&amp;diff=131564"/>
		<updated>2018-07-27T15:35:58Z</updated>

		<summary type="html">&lt;p&gt;Maherne: /* Allow role to view */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Roles}}&lt;br /&gt;
Managing overall role capabilities can be done by an administrator using  &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.   This is the place to add custom roles or modify existing roles.   The &amp;quot;Manage roles&amp;quot; tab, allows the system administrator to edit any one of over 350 different capabilities associated with any role.   The &amp;quot;Allow role assignments&amp;quot;, &amp;quot;Allow role overrides&amp;quot; and &amp;quot;Allow role switches&amp;quot; contain a matrix which give the ability for a specific role to work with other specific roles. &lt;br /&gt;
&lt;br /&gt;
==Manage roles==&lt;br /&gt;
&lt;br /&gt;
The &#039;Manage roles&#039; tab contains a list of roles on your site. The edit column contains icons for editing, deleting roles and copying roles, and for moving them up or down in the list (affecting the way that roles are listed around Moodle).&lt;br /&gt;
&lt;br /&gt;
[[Image:Allowroletoview.png]]&lt;br /&gt;
&lt;br /&gt;
To edit a role:&lt;br /&gt;
#Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.&lt;br /&gt;
#Click the edit icon opposite the role you want to edit. For example &amp;quot;student&amp;quot;.&lt;br /&gt;
#On the editing role page, change permissions as required for each capability.&lt;br /&gt;
#Scroll to the bottom of the page and click the &amp;quot;Save changes&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
See [[Creating custom roles]] for information about adding a new role and creating a duplicate role.&lt;br /&gt;
&lt;br /&gt;
==Role name localisation==&lt;br /&gt;
&lt;br /&gt;
If a standard role name or description is empty Moodle uses a default string from the current language pack. Custom roles can be customised using multilang syntax.&lt;br /&gt;
&lt;br /&gt;
You may also override the role names separately in each course.&lt;br /&gt;
&lt;br /&gt;
==Resetting a role==&lt;br /&gt;
&lt;br /&gt;
To reset a role back to the default permissions:&lt;br /&gt;
#Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.&lt;br /&gt;
#Click on the name of the role, for example &amp;quot;student&amp;quot;.&lt;br /&gt;
#Click the &#039;Reset&#039; button.&lt;br /&gt;
&lt;br /&gt;
Note that if you have students who have been given extra permissions at course and/or activity levels (such as forum ratings), then they will no longer be able to do this once the role has been reset to its default. A teacher would need to go back and set up these extra permissions in the course/activity levels again.&lt;br /&gt;
&lt;br /&gt;
==Allow role assignments==&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Allow role assignments&amp;quot; tab allows (or does not allow) a specific role to be able to assign specific roles to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Enabling teachers to assign other teachers===&lt;br /&gt;
By default, teachers can only assign other users the roles of non-editing teachers, students and guests. If you want teachers to be able to assign other teachers in their course, you can allow the role assignment:&lt;br /&gt;
&lt;br /&gt;
#Click on &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.&lt;br /&gt;
#Click the Allow role assignments tab.&lt;br /&gt;
#Click the checkbox where the teacher row and column intersect.&lt;br /&gt;
#Click the &amp;quot;Save changes&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
==Allow role overrides==&lt;br /&gt;
The &amp;quot;Allow role overrides&amp;quot; tab allows (or does not allow) a specific role to be able to override specific roles for a user.  For example, it might allow a teacher role to override a student&#039;s role to a non-editing teacher&#039;s role. &lt;br /&gt;
&lt;br /&gt;
:Note that the settings only apply to roles that have the capabilities [[Capabilities/moodle/role:override|moodle/role:override]] or [[Capabilities/moodle/role:safeoverride|moodle/role:safeoverride]] allowed.&lt;br /&gt;
&lt;br /&gt;
==Allow role switches==&lt;br /&gt;
The &amp;quot;Allow role switches&amp;quot; tab allows (or does not allow) a specific role to be able to temporarily change their role to another specific role.  For example, this might allow a users assigned to a custom role in a course to see &amp;quot;Student&amp;quot; in the Settings &amp;gt; Switch role list.   &lt;br /&gt;
 &lt;br /&gt;
:Note: the selected role must also have the moodle/role:switchroles capability to be able to switch.&lt;br /&gt;
&lt;br /&gt;
==Allow role to view==&lt;br /&gt;
&lt;br /&gt;
{{Moodle 3.4}}&lt;br /&gt;
&lt;br /&gt;
This setting allows the administrator to decide which roles users can see, search and filter by, according to their existing role.&lt;br /&gt;
&lt;br /&gt;
==Roles capabilities==&lt;br /&gt;
&lt;br /&gt;
*[[Capabilities/moodle/role:manage|Create and manage roles]]&lt;br /&gt;
*[[Capabilities/moodle/role:assign|Assign roles to users]]&lt;br /&gt;
*[[Capabilities/moodle/role:switchroles|Switch to other roles]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Site administration]]&lt;br /&gt;
&lt;br /&gt;
[[es:Gestionar_roles]]&lt;br /&gt;
[[eu:Rolak_kudeatu]]&lt;br /&gt;
[[fr:Gestion des rôles]]&lt;br /&gt;
[[ja:ロールの管理]]&lt;br /&gt;
[[de:Rollen verwalten]]&lt;/div&gt;</summary>
		<author><name>Maherne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Managing_roles&amp;diff=131563</id>
		<title>Managing roles</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Managing_roles&amp;diff=131563"/>
		<updated>2018-07-27T15:35:46Z</updated>

		<summary type="html">&lt;p&gt;Maherne: /* Allow role to view */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Roles}}&lt;br /&gt;
Managing overall role capabilities can be done by an administrator using  &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.   This is the place to add custom roles or modify existing roles.   The &amp;quot;Manage roles&amp;quot; tab, allows the system administrator to edit any one of over 350 different capabilities associated with any role.   The &amp;quot;Allow role assignments&amp;quot;, &amp;quot;Allow role overrides&amp;quot; and &amp;quot;Allow role switches&amp;quot; contain a matrix which give the ability for a specific role to work with other specific roles. &lt;br /&gt;
&lt;br /&gt;
==Manage roles==&lt;br /&gt;
&lt;br /&gt;
The &#039;Manage roles&#039; tab contains a list of roles on your site. The edit column contains icons for editing, deleting roles and copying roles, and for moving them up or down in the list (affecting the way that roles are listed around Moodle).&lt;br /&gt;
&lt;br /&gt;
[[Image:Allowroletoview.png]]&lt;br /&gt;
&lt;br /&gt;
To edit a role:&lt;br /&gt;
#Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.&lt;br /&gt;
#Click the edit icon opposite the role you want to edit. For example &amp;quot;student&amp;quot;.&lt;br /&gt;
#On the editing role page, change permissions as required for each capability.&lt;br /&gt;
#Scroll to the bottom of the page and click the &amp;quot;Save changes&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
See [[Creating custom roles]] for information about adding a new role and creating a duplicate role.&lt;br /&gt;
&lt;br /&gt;
==Role name localisation==&lt;br /&gt;
&lt;br /&gt;
If a standard role name or description is empty Moodle uses a default string from the current language pack. Custom roles can be customised using multilang syntax.&lt;br /&gt;
&lt;br /&gt;
You may also override the role names separately in each course.&lt;br /&gt;
&lt;br /&gt;
==Resetting a role==&lt;br /&gt;
&lt;br /&gt;
To reset a role back to the default permissions:&lt;br /&gt;
#Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.&lt;br /&gt;
#Click on the name of the role, for example &amp;quot;student&amp;quot;.&lt;br /&gt;
#Click the &#039;Reset&#039; button.&lt;br /&gt;
&lt;br /&gt;
Note that if you have students who have been given extra permissions at course and/or activity levels (such as forum ratings), then they will no longer be able to do this once the role has been reset to its default. A teacher would need to go back and set up these extra permissions in the course/activity levels again.&lt;br /&gt;
&lt;br /&gt;
==Allow role assignments==&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Allow role assignments&amp;quot; tab allows (or does not allow) a specific role to be able to assign specific roles to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Enabling teachers to assign other teachers===&lt;br /&gt;
By default, teachers can only assign other users the roles of non-editing teachers, students and guests. If you want teachers to be able to assign other teachers in their course, you can allow the role assignment:&lt;br /&gt;
&lt;br /&gt;
#Click on &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.&lt;br /&gt;
#Click the Allow role assignments tab.&lt;br /&gt;
#Click the checkbox where the teacher row and column intersect.&lt;br /&gt;
#Click the &amp;quot;Save changes&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
==Allow role overrides==&lt;br /&gt;
The &amp;quot;Allow role overrides&amp;quot; tab allows (or does not allow) a specific role to be able to override specific roles for a user.  For example, it might allow a teacher role to override a student&#039;s role to a non-editing teacher&#039;s role. &lt;br /&gt;
&lt;br /&gt;
:Note that the settings only apply to roles that have the capabilities [[Capabilities/moodle/role:override|moodle/role:override]] or [[Capabilities/moodle/role:safeoverride|moodle/role:safeoverride]] allowed.&lt;br /&gt;
&lt;br /&gt;
==Allow role switches==&lt;br /&gt;
The &amp;quot;Allow role switches&amp;quot; tab allows (or does not allow) a specific role to be able to temporarily change their role to another specific role.  For example, this might allow a users assigned to a custom role in a course to see &amp;quot;Student&amp;quot; in the Settings &amp;gt; Switch role list.   &lt;br /&gt;
 &lt;br /&gt;
:Note: the selected role must also have the moodle/role:switchroles capability to be able to switch.&lt;br /&gt;
&lt;br /&gt;
==Allow role to view==&lt;br /&gt;
&lt;br /&gt;
{{Moodle 3.5}}&lt;br /&gt;
&lt;br /&gt;
This setting allows the administrator to decide which roles users can see, search and filter by, according to their existing role.&lt;br /&gt;
&lt;br /&gt;
==Roles capabilities==&lt;br /&gt;
&lt;br /&gt;
*[[Capabilities/moodle/role:manage|Create and manage roles]]&lt;br /&gt;
*[[Capabilities/moodle/role:assign|Assign roles to users]]&lt;br /&gt;
*[[Capabilities/moodle/role:switchroles|Switch to other roles]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Site administration]]&lt;br /&gt;
&lt;br /&gt;
[[es:Gestionar_roles]]&lt;br /&gt;
[[eu:Rolak_kudeatu]]&lt;br /&gt;
[[fr:Gestion des rôles]]&lt;br /&gt;
[[ja:ロールの管理]]&lt;br /&gt;
[[de:Rollen verwalten]]&lt;/div&gt;</summary>
		<author><name>Maherne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Managing_roles&amp;diff=131562</id>
		<title>Managing roles</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Managing_roles&amp;diff=131562"/>
		<updated>2018-07-27T15:35:34Z</updated>

		<summary type="html">&lt;p&gt;Maherne: /* Allow role to view */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Roles}}&lt;br /&gt;
Managing overall role capabilities can be done by an administrator using  &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.   This is the place to add custom roles or modify existing roles.   The &amp;quot;Manage roles&amp;quot; tab, allows the system administrator to edit any one of over 350 different capabilities associated with any role.   The &amp;quot;Allow role assignments&amp;quot;, &amp;quot;Allow role overrides&amp;quot; and &amp;quot;Allow role switches&amp;quot; contain a matrix which give the ability for a specific role to work with other specific roles. &lt;br /&gt;
&lt;br /&gt;
==Manage roles==&lt;br /&gt;
&lt;br /&gt;
The &#039;Manage roles&#039; tab contains a list of roles on your site. The edit column contains icons for editing, deleting roles and copying roles, and for moving them up or down in the list (affecting the way that roles are listed around Moodle).&lt;br /&gt;
&lt;br /&gt;
[[Image:Allowroletoview.png]]&lt;br /&gt;
&lt;br /&gt;
To edit a role:&lt;br /&gt;
#Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.&lt;br /&gt;
#Click the edit icon opposite the role you want to edit. For example &amp;quot;student&amp;quot;.&lt;br /&gt;
#On the editing role page, change permissions as required for each capability.&lt;br /&gt;
#Scroll to the bottom of the page and click the &amp;quot;Save changes&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
See [[Creating custom roles]] for information about adding a new role and creating a duplicate role.&lt;br /&gt;
&lt;br /&gt;
==Role name localisation==&lt;br /&gt;
&lt;br /&gt;
If a standard role name or description is empty Moodle uses a default string from the current language pack. Custom roles can be customised using multilang syntax.&lt;br /&gt;
&lt;br /&gt;
You may also override the role names separately in each course.&lt;br /&gt;
&lt;br /&gt;
==Resetting a role==&lt;br /&gt;
&lt;br /&gt;
To reset a role back to the default permissions:&lt;br /&gt;
#Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.&lt;br /&gt;
#Click on the name of the role, for example &amp;quot;student&amp;quot;.&lt;br /&gt;
#Click the &#039;Reset&#039; button.&lt;br /&gt;
&lt;br /&gt;
Note that if you have students who have been given extra permissions at course and/or activity levels (such as forum ratings), then they will no longer be able to do this once the role has been reset to its default. A teacher would need to go back and set up these extra permissions in the course/activity levels again.&lt;br /&gt;
&lt;br /&gt;
==Allow role assignments==&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Allow role assignments&amp;quot; tab allows (or does not allow) a specific role to be able to assign specific roles to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Enabling teachers to assign other teachers===&lt;br /&gt;
By default, teachers can only assign other users the roles of non-editing teachers, students and guests. If you want teachers to be able to assign other teachers in their course, you can allow the role assignment:&lt;br /&gt;
&lt;br /&gt;
#Click on &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.&lt;br /&gt;
#Click the Allow role assignments tab.&lt;br /&gt;
#Click the checkbox where the teacher row and column intersect.&lt;br /&gt;
#Click the &amp;quot;Save changes&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
==Allow role overrides==&lt;br /&gt;
The &amp;quot;Allow role overrides&amp;quot; tab allows (or does not allow) a specific role to be able to override specific roles for a user.  For example, it might allow a teacher role to override a student&#039;s role to a non-editing teacher&#039;s role. &lt;br /&gt;
&lt;br /&gt;
:Note that the settings only apply to roles that have the capabilities [[Capabilities/moodle/role:override|moodle/role:override]] or [[Capabilities/moodle/role:safeoverride|moodle/role:safeoverride]] allowed.&lt;br /&gt;
&lt;br /&gt;
==Allow role switches==&lt;br /&gt;
The &amp;quot;Allow role switches&amp;quot; tab allows (or does not allow) a specific role to be able to temporarily change their role to another specific role.  For example, this might allow a users assigned to a custom role in a course to see &amp;quot;Student&amp;quot; in the Settings &amp;gt; Switch role list.   &lt;br /&gt;
 &lt;br /&gt;
:Note: the selected role must also have the moodle/role:switchroles capability to be able to switch.&lt;br /&gt;
&lt;br /&gt;
==Allow role to view==&lt;br /&gt;
{{Moodle 3.5}}&lt;br /&gt;
This setting allows the administrator to decide which roles users can see, search and filter by, according to their existing role.&lt;br /&gt;
&lt;br /&gt;
==Roles capabilities==&lt;br /&gt;
&lt;br /&gt;
*[[Capabilities/moodle/role:manage|Create and manage roles]]&lt;br /&gt;
*[[Capabilities/moodle/role:assign|Assign roles to users]]&lt;br /&gt;
*[[Capabilities/moodle/role:switchroles|Switch to other roles]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Site administration]]&lt;br /&gt;
&lt;br /&gt;
[[es:Gestionar_roles]]&lt;br /&gt;
[[eu:Rolak_kudeatu]]&lt;br /&gt;
[[fr:Gestion des rôles]]&lt;br /&gt;
[[ja:ロールの管理]]&lt;br /&gt;
[[de:Rollen verwalten]]&lt;/div&gt;</summary>
		<author><name>Maherne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Server_cluster&amp;diff=128295</id>
		<title>Server cluster</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Server_cluster&amp;diff=128295"/>
		<updated>2017-07-19T10:26:34Z</updated>

		<summary type="html">&lt;p&gt;Maherne: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is going to describe some basic information related to server clustering...&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
&lt;br /&gt;
* database server - ACID compliant, for example PostgreSQL and MariaDB&lt;br /&gt;
* main server that is able to share dataroot - locking support recommended, for example NFS&lt;br /&gt;
* load balancer - for example Nginx&lt;br /&gt;
* cluster nodes - web servers&lt;br /&gt;
* Memcached server for shared caches&lt;br /&gt;
&lt;br /&gt;
Note: this guide is not intended for Windows OS or any other Microsoft technologies.&lt;br /&gt;
&lt;br /&gt;
==Initial installation==&lt;br /&gt;
&lt;br /&gt;
# Perform standard CLI installation on the main server using shared database and dataroot directory.&lt;br /&gt;
# Setup web servers on cluster nodes - use local dirroot and shared database and dataroot.&lt;br /&gt;
# Configure load balancing.&lt;br /&gt;
&lt;br /&gt;
==Related config.php settings==&lt;br /&gt;
&lt;br /&gt;
===$CFG-&amp;gt;wwwroot===&lt;br /&gt;
It must be the same on all nodes, it must be the public facing URL. It cannot be dynamic.&lt;br /&gt;
&lt;br /&gt;
===$CFG-&amp;gt;sslproxy===&lt;br /&gt;
Enable if you have https:// wwwroot but the SSL is done by load-balancer instead of web server.&lt;br /&gt;
&lt;br /&gt;
Please note that it is not compatible with $CFG-&amp;gt;loginhttps. This is because in order for loginhttps to work, we need to know the original request, and whether it was http or https. This allows us to only provide the login form over ssl. The original request is lost when made through a &amp;quot;reverse&amp;quot; proxy / load balancer, so we cannot determine what protocol the request was made in. So we can&#039;t provide most of moodle over http and the login page over https.&lt;br /&gt;
&lt;br /&gt;
Enable &#039;&#039;Secure cookies only&#039;&#039; to make your site really secure, without it cookie stealing is still trivial.&lt;br /&gt;
&lt;br /&gt;
===$CFG-&amp;gt;reverseproxy===&lt;br /&gt;
Enable if your nodes are accessed via different URL.&lt;br /&gt;
&lt;br /&gt;
Please note that it is not compatible with $CFG-&amp;gt;loginhttps. This is because in order for loginhttps to work, we need to know the original request, and whether it was http or https. This allows us to only provide the login form over ssl. The original request is lost when made through a &amp;quot;reverse&amp;quot; proxy / load balancer, so we cannot determine what protocol the request was made in. So we can&#039;t provide most of moodle over http and the login page over https.&lt;br /&gt;
&lt;br /&gt;
===$CFG-&amp;gt;dirroot===&lt;br /&gt;
It is strongly recommended that $CFG-&amp;gt;dirroot (which is automatically set via realpath(config.php)) contains the same path on all nodes. It does not need to point to the same shared directory though. The reason is that some some low level code may use the dirroot value for cache invalidation.&lt;br /&gt;
&lt;br /&gt;
The simplest solution is to have the same directory structure on each cluster node and synchronise these during each upgrade.&lt;br /&gt;
&lt;br /&gt;
The dirroot should be always read only for apache process because otherwise built in plugin installation and uninstallation would get the nodes out of sync.&lt;br /&gt;
&lt;br /&gt;
===$CFG-&amp;gt;dataroot===&lt;br /&gt;
&lt;br /&gt;
This &#039;&#039;&#039;MUST&#039;&#039;&#039; be a shared directory where each cluster node is accessing the files directly. It must be very reliable, administrators cannot manipulate files directly.&lt;br /&gt;
&lt;br /&gt;
Locking support is not required, if any code tries to use file locks in dataroot outside of cachedir or muc directory it is a bug.&lt;br /&gt;
&lt;br /&gt;
===$CFG-&amp;gt;tempdir===&lt;br /&gt;
&lt;br /&gt;
This directory &#039;&#039;&#039;MUST&#039;&#039;&#039; be shared by all cluster nodes. Locking is required.&lt;br /&gt;
&lt;br /&gt;
===$CFG-&amp;gt;cachedir===&lt;br /&gt;
&lt;br /&gt;
This directory &#039;&#039;&#039;MUST&#039;&#039;&#039; be shared by all cluster nodes. Locking is required.&lt;br /&gt;
&lt;br /&gt;
===$CFG-&amp;gt;localcachedir===&lt;br /&gt;
&lt;br /&gt;
The difference from $CFG-&amp;gt;cachedir is that the directory does not have to be shared by all cluster nodes, the file contents do not change. Use local fast filesystem on each cluster node.&lt;br /&gt;
&lt;br /&gt;
==Performance recommendations==&lt;br /&gt;
&lt;br /&gt;
#Use OPcache extension on all cluster nodes.&lt;br /&gt;
#Set $CFG-&amp;gt;localcachedir to fast local filesystem on each node.&lt;br /&gt;
#Use one big central memcached server for all shared caches that support it.&lt;br /&gt;
#Use local memcached instances on cluster nodes for local caches that support it.&lt;br /&gt;
#Store user sessions in one shared memcached server. (See [[Session_handling]] for details)&lt;br /&gt;
#Use fast local directory for dirroot on each cluster node.&lt;br /&gt;
#Use dynamic cluster node management.&lt;br /&gt;
#Use transparent proxy servers.&lt;br /&gt;
&lt;br /&gt;
==Upgrade procedure==&lt;br /&gt;
&lt;br /&gt;
#Disable load balancer.&lt;br /&gt;
#Upgrade dirroot files on master server.&lt;br /&gt;
#Perform CLI upgrade.&lt;br /&gt;
#Manually reset all caches in cluster nodes - restart web server, delete localcachedir and temp directories, restart memcached, etc. Or delete all cluster nodes and create nodes from a new template.&lt;br /&gt;
#Enable load balancer.&lt;br /&gt;
&lt;br /&gt;
==Step by step guide for server clustering in Moodle 2.6==&lt;br /&gt;
From hardware and performance forum thread [https://moodle.org/mod/forum/discuss.php?d=251547 https://moodle.org/mod/forum/discuss.php?d=251547]&lt;br /&gt;
&lt;br /&gt;
* 1 Determine your specific need for caches. This involves the concepts of shared cache or local cache, disk based cache or server based cache or protocol specific cache like Memcached or MongoDB. &lt;br /&gt;
** 1.1 If you have a slow shared disk, you might benefit from a local disk cache.&lt;br /&gt;
** 1.2 If you have only a few users on your Moodle site, you might not want to set up a Memcached service, even if the acceleration that Memcached provides, is very significant for the user experience.&lt;br /&gt;
** 1.3 If you want to do anything in your power for accelerating the site, you might consider MongoDB.&lt;br /&gt;
* 2 Configure the caches, test them and verify them. There is room for improvement in the examples for cache configuration. This is probably the most difficult step.&lt;br /&gt;
* 3 Install the cache support on server level. This may involve installing php modules or config for php modules.&lt;br /&gt;
* 4 Create a cache instance in MUC here: example.com/cache/admin.php?action=addstore&amp;amp;plugin=memcached&lt;br /&gt;
** 4.1 Give the cache instance some arbitrary name.&lt;br /&gt;
** 4.2 All other fields have a question mark that can be clicked on for excellent help that tells you what to fill in, and the syntax (very important).&lt;br /&gt;
** 4.3 The result should be a Configured Store Instance, with the name of your choice.&lt;br /&gt;
* 5 The final step is to deploy the created cache instances by Editing Mappings for e.g. Language string cache in the list of Known cache definitions.&lt;br /&gt;
** 5.1  While experimenting with this, I have found it a life saver to open a separate browser window, where the default setting is selected, so I just need to click on the Save button to revert the setting, just in case I lose contact with the site.&lt;br /&gt;
** 5.2 Select the name of your configured store instance from the dropdown list and click on the Save button. &lt;br /&gt;
** 5.3 Test the new cache setting. If you lose contact with the site or it behaves weirdly, try using the trick in step 1. In case of emergency you might remove the cache config file (muc/config.php) in the folder pointed to by $CFG-&amp;gt;dataroot .  It seems that Moodle writes a new default config file if it is missing.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[Performance recommendations]]&lt;br /&gt;
*[[Caching]]&lt;br /&gt;
*[[:dev:Server clustering improvements proposal]]&lt;br /&gt;
*Hardware and performance forum thread [https://moodle.org/mod/forum/discuss.php?d=251547https://moodle.org/mod/forum/discuss.php?d=251547]&lt;br /&gt;
*How to Cluster Moodle on Multiple Servers for High Availability and Scalability [http://www.severalnines.com/blog/clustering-moodle-multiple-servers-high-availability-scalability]&lt;/div&gt;</summary>
		<author><name>Maherne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=User:Michael_Aherne&amp;diff=124201</id>
		<title>User:Michael Aherne</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=User:Michael_Aherne&amp;diff=124201"/>
		<updated>2016-06-23T07:58:57Z</updated>

		<summary type="html">&lt;p&gt;Maherne: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Software Developer,&lt;br /&gt;
VLE Team,&lt;br /&gt;
University of Strathclyde,&lt;br /&gt;
Glasgow, Scotland&lt;br /&gt;
&lt;br /&gt;
michael.aherne@strath.ac.uk&lt;br /&gt;
&lt;br /&gt;
[[User:maherne/Setting up Eclipse]]&lt;/div&gt;</summary>
		<author><name>Maherne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=User:Michael_Aherne&amp;diff=124200</id>
		<title>User:Michael Aherne</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=User:Michael_Aherne&amp;diff=124200"/>
		<updated>2016-06-23T07:58:26Z</updated>

		<summary type="html">&lt;p&gt;Maherne: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Software Developer,&lt;br /&gt;
VLE Team,&lt;br /&gt;
University of Strathclyde,&lt;br /&gt;
Glasgow, Scotland&lt;br /&gt;
&lt;br /&gt;
michael.aherne@strath.ac.uk&lt;br /&gt;
&lt;br /&gt;
[[User:Michael_Aherne/Setting up Eclipse]]&lt;/div&gt;</summary>
		<author><name>Maherne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=User:Michael_Aherne&amp;diff=124199</id>
		<title>User:Michael Aherne</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=User:Michael_Aherne&amp;diff=124199"/>
		<updated>2016-06-23T07:57:59Z</updated>

		<summary type="html">&lt;p&gt;Maherne: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Software Developer,&lt;br /&gt;
VLE Team,&lt;br /&gt;
University of Strathclyde,&lt;br /&gt;
Glasgow, Scotland&lt;br /&gt;
&lt;br /&gt;
michael.aherne@strath.ac.uk&lt;br /&gt;
&lt;br /&gt;
[[User:Michael Aherne/Setting up Eclipse]]&lt;/div&gt;</summary>
		<author><name>Maherne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=User:Michael_Aherne&amp;diff=124198</id>
		<title>User:Michael Aherne</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=User:Michael_Aherne&amp;diff=124198"/>
		<updated>2016-06-23T07:57:35Z</updated>

		<summary type="html">&lt;p&gt;Maherne: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Software Developer,&lt;br /&gt;
VLE Team,&lt;br /&gt;
University of Strathclyde,&lt;br /&gt;
Glasgow, Scotland&lt;br /&gt;
&lt;br /&gt;
michael.aherne@strath.ac.uk&lt;br /&gt;
&lt;br /&gt;
[Setting up Eclipse]&lt;/div&gt;</summary>
		<author><name>Maherne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=User:Michael_Aherne&amp;diff=124197</id>
		<title>User:Michael Aherne</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=User:Michael_Aherne&amp;diff=124197"/>
		<updated>2016-06-23T07:56:42Z</updated>

		<summary type="html">&lt;p&gt;Maherne: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Software Developer,&lt;br /&gt;
VLE Team,&lt;br /&gt;
University of Strathclyde,&lt;br /&gt;
Glasgow, Scotland&lt;br /&gt;
&lt;br /&gt;
michael.aherne@strath.ac.uk&lt;br /&gt;
&lt;br /&gt;
[User:Michael Aherne/Setting up Eclipse]&lt;/div&gt;</summary>
		<author><name>Maherne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Server_cluster&amp;diff=109572</id>
		<title>Server cluster</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Server_cluster&amp;diff=109572"/>
		<updated>2014-01-30T12:16:47Z</updated>

		<summary type="html">&lt;p&gt;Maherne: /* Performance recommendations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is going to describe some basic information related to server clustering...&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
&lt;br /&gt;
* database server - ACID compliant, for example PostgreSQL and MariaDB&lt;br /&gt;
* main server that is able to share dataroot - locking support recommended, for example NFS&lt;br /&gt;
* load balancer - for example Nginx&lt;br /&gt;
* cluster nodes - web servers&lt;br /&gt;
* Memcached server for shared caches&lt;br /&gt;
&lt;br /&gt;
Note: this guide is not intended for Windows OS or any other Microsoft technologies.&lt;br /&gt;
&lt;br /&gt;
==Initial installation==&lt;br /&gt;
&lt;br /&gt;
# Perform standard CLI installation on the main server using shared database and dataroot directory.&lt;br /&gt;
# Setup web servers on cluster nodes - use local dirroot and shared database and dataroot.&lt;br /&gt;
# Configure load balancing.&lt;br /&gt;
&lt;br /&gt;
==Related config.php settings==&lt;br /&gt;
&lt;br /&gt;
===$CFG-&amp;gt;wwwroot===&lt;br /&gt;
It must be the same on all nodes, it must be the public facing URL. It cannot be dynamic.&lt;br /&gt;
&lt;br /&gt;
===$CFG-&amp;gt;sslproxy===&lt;br /&gt;
Enable if you have https:// wwwroot but the SSL is doen by load-balancer instead of web server.&lt;br /&gt;
&lt;br /&gt;
Enable &#039;&#039;Secure cookies only&#039;&#039; to make your site really secure, without it cookie stealing is still trivial.&lt;br /&gt;
&lt;br /&gt;
===$CFG-&amp;gt;reverseproxy===&lt;br /&gt;
Enable if your nodes are accessed via different URL. Please note that it is not compatible with $CFG-&amp;gt;loginhttps.&lt;br /&gt;
&lt;br /&gt;
===$CFG-&amp;gt;dirroot===&lt;br /&gt;
It is strongly recommended that $CFG-&amp;gt;dirroot (which is automatically set via realpath(config.php)) contains the same path on all nodes. It does not need to point to the same shared directory though. The reason is that some some low level code may use the dirroot value for cache invalidation.&lt;br /&gt;
&lt;br /&gt;
The simplest solution is to have the same directory structure on each cluster node and synchronise these during each upgrade.&lt;br /&gt;
&lt;br /&gt;
The dirroot should be always read only for apache process because otherwise built in add-on installation and plugin uninstallation would get the nodes out of sync.&lt;br /&gt;
&lt;br /&gt;
===$CFG-&amp;gt;dataroot===&lt;br /&gt;
&lt;br /&gt;
This &#039;&#039;&#039;MUST&#039;&#039;&#039; be a shared directory where each cluster node is accessing the files directly. It must be very reliable, administrators cannot manipulate files directly.&lt;br /&gt;
&lt;br /&gt;
Locking support is not required, if any code tries to use file locks in dataroot outside of cachedir or muc directory it is a bug.&lt;br /&gt;
&lt;br /&gt;
===$CFG-&amp;gt;tempdir===&lt;br /&gt;
&lt;br /&gt;
It is recommended to use separate ram disks on each node. Scripts may use this directory during one request only. The contents of this directory may be deleted if there is no pending HTTP request, otherwise delete only files with older timestamps.&lt;br /&gt;
&lt;br /&gt;
Always purge this directory when starting cluster node, you may get some notices or temporary errors if you purge this directory while other requests are active.&lt;br /&gt;
&lt;br /&gt;
===$CFG-&amp;gt;cachedir===&lt;br /&gt;
&lt;br /&gt;
This directory &#039;&#039;&#039;MUST&#039;&#039;&#039; be shared by all cluster nodes. Locking is required.&lt;br /&gt;
&lt;br /&gt;
===$CFG-&amp;gt;localcachedir===&lt;br /&gt;
&lt;br /&gt;
The difference from $CFG-&amp;gt;cachedir is that the directory does not have to be shared by all cluster nodes, the file contents do not change. Use local fast filesystem on each cluster node.&lt;br /&gt;
&lt;br /&gt;
==Performance recommendations==&lt;br /&gt;
&lt;br /&gt;
#Use OPcache extension on all cluster nodes.&lt;br /&gt;
#Set $CFG-&amp;gt;localcachedir to fast local filesystem on each node.&lt;br /&gt;
#Set $CFG-&amp;gt;tempdir to fast local filesystem on each node.&lt;br /&gt;
#Use one big central memcached server for all shared caches that support it.&lt;br /&gt;
#Use local memcached instances on cluster nodes for local caches that support it.&lt;br /&gt;
#Store user sessions in one shared memcached server. (See [[Session_handling]] for details)&lt;br /&gt;
#Use fast local directory for dirroot on each cluster node.&lt;br /&gt;
#Use dynamic cluster node management.&lt;br /&gt;
#Use transparent proxy servers.&lt;br /&gt;
&lt;br /&gt;
==Upgrade procedure==&lt;br /&gt;
&lt;br /&gt;
#Disable load balancer.&lt;br /&gt;
#Upgrade dirroot files on master server.&lt;br /&gt;
#Perform CLI upgrade.&lt;br /&gt;
#Manually reset all caches in cluster nodes - restart web server, delete localcachedir and temp directories, restart memcached, etc. Or delete all cluster nodes and create nodes from a new template.&lt;br /&gt;
#Enable load balancer.&lt;br /&gt;
&lt;br /&gt;
==Step by step guide for server clustering in Moodle 2.6==&lt;br /&gt;
From hardware and performance forum thread [https://moodle.org/mod/forum/discuss.php?d=251547 https://moodle.org/mod/forum/discuss.php?d=251547]&lt;br /&gt;
&lt;br /&gt;
* 1 Determine your specific need for caches. This involves the concepts of shared cache or local cache, disk based cache or server based cache or protocol specific cache like Memcached or MongoDB. &lt;br /&gt;
** 1.1 If you have a slow shared disk, you might benefit from a local disk cache.&lt;br /&gt;
** 1.2 If you have only a few users on your Moodle site, you might not want to set up a Memcached service, even if the acceleration that Memcached provides, is very significant for the user experience.&lt;br /&gt;
** 1.3 If you want to do anything in your power for accelerating the site, you might consider MongoDB.&lt;br /&gt;
* 2 Configure the caches, test them and verify them. There is room for improvement in the examples for cache configuration. This is probably the most difficult step.&lt;br /&gt;
* 3 Install the cache support on server level. This may involve installing php modules or config for php modules.&lt;br /&gt;
* 4 Create a cache instance in MUC here: example.com/cache/admin.php?action=addstore&amp;amp;plugin=memcached&lt;br /&gt;
** 4.1 Give the cache instance some arbitrary name.&lt;br /&gt;
** 4.2 All other fields have a question mark that can be clicked on for excellent help that tells you what to fill in, and the syntax (very important).&lt;br /&gt;
** 4.3 The result should be a Configured Store Instance, with the name of your choice.&lt;br /&gt;
* 5 The final step is to deploy the created cache instances by Editing Mappings for e.g. Language string cache in the list of Known cache definitions.&lt;br /&gt;
** 5.1  While experimenting with this, I have found it a life saver to open a separate browser window, where the default setting is selected, so I just need to click on the Save button to revert the setting, just in case I lose contact with the site.&lt;br /&gt;
** 5.2 Select the nam of your configured store instance from the dropdown list and click on the Save button. &lt;br /&gt;
** 5.3 Test the new cache setting. If you lose contact with the site or it behaves weirdly, try using the trick in step 1. In case of emergency you might remove the cache config file (muc/config.php) in the folder pointed to by $CFG-&amp;gt;dataroot .  It seems that Moodle writes a new default config file if it is missing.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[Performance recommendations]]&lt;br /&gt;
*[[Caching]]&lt;br /&gt;
*[[:dev:Server clustering improvements proposal]]&lt;br /&gt;
*Hardware and performance forum thread [https://moodle.org/mod/forum/discuss.php?d=251547https://moodle.org/mod/forum/discuss.php?d=251547]&lt;/div&gt;</summary>
		<author><name>Maherne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Import_groups&amp;diff=106160</id>
		<title>Import groups</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Import_groups&amp;diff=106160"/>
		<updated>2013-07-24T12:05:06Z</updated>

		<summary type="html">&lt;p&gt;Maherne: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Grouping users}}&lt;br /&gt;
Groups import provides a simple, easy way to create groups from a spreadsheet (CSV).&lt;br /&gt;
&lt;br /&gt;
To import groups&lt;br /&gt;
*Click the &#039;Import groups&#039; button in &#039;&#039;Settings &amp;gt; Course administration &amp;gt; Users &amp;gt; Groups&#039;&#039;&lt;br /&gt;
*Upload the CSV file (see below for file format) either by dragging and dropping into the box with the arrow (&#039;&#039;1 below&#039;&#039;) or by clicking &amp;quot;choose a file&amp;quot; and uploading from the [[File picker]]. (&#039;&#039;2 below&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
[[File:newimportgroups.png]]&lt;br /&gt;
&lt;br /&gt;
*Click the &#039;Import groups&#039; button&lt;br /&gt;
&lt;br /&gt;
==CSV file fieldnames==&lt;br /&gt;
&lt;br /&gt;
The CSV file has just one required fieldname (groupname), but can include default and/or optional fieldnames&lt;br /&gt;
&lt;br /&gt;
* Each line of the file contains one record&lt;br /&gt;
* Each record is a series of data separated by commas&lt;br /&gt;
* The first record of the file is special, and contains a list of fieldnames. This defines the format of the rest of the file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Required fieldnames&#039;&#039;&#039; - These fields must be included in the first record, and defined for each column&lt;br /&gt;
&lt;br /&gt;
 groupname&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default fieldnames&#039;&#039;&#039; - These are optional - if they are not included then the values are taken from the current language and current course&lt;br /&gt;
&lt;br /&gt;
 idnumber,coursename,lang&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Optional fieldnames&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 description,enrolmentkey&lt;br /&gt;
&lt;br /&gt;
(Note: The field &amp;quot;picture&amp;quot; and &amp;quot;hidepicture&amp;quot; will produce a &amp;quot;not a valid fieldname&amp;quot; error when uploaded.)&lt;br /&gt;
&lt;br /&gt;
{{New features}}&lt;br /&gt;
If the &#039;&#039;groupingname&#039;&#039; is included, the imported groups will be allocated to those groupings. The groupings will be created if they do not already exist:&lt;br /&gt;
 groupingname&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Separation between the comma and the text can not be a blank.&lt;br /&gt;
*Commas within the data should be encoded as &amp;amp;#44 - the script will automatically decode these back to commas.&lt;br /&gt;
*For Boolean fields, use 0 for false and 1 for true.&lt;br /&gt;
*Either idnumber or coursename can be used to identify the course. Idnumber overrides coursename. If neither is specified, the groups will be added to the current course.&lt;br /&gt;
*Coursename is the course shortname.&lt;br /&gt;
*Group ID numbers are for matching groups against external systems. Within a course, all group ID numbers must be unique.&lt;br /&gt;
*The file must be in ANSI encoding, at least not be saved in UTF-8 encoding.&lt;br /&gt;
&lt;br /&gt;
Note: If a group is already registered in the Moodle database for a particular course, this script will return the group name for that group. Teachers are only allowed to upload groups in courses they are authorized to edit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A sample file looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
groupname,description,enrolmentkey&lt;br /&gt;
Team 1,Group Assignment Team 1,orange&lt;br /&gt;
Team 2,Group Assignment Team 2,purple&lt;br /&gt;
Team 3,Group Assignment Team 3,green&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[de:Gruppen importieren]]&lt;/div&gt;</summary>
		<author><name>Maherne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Cohort_sync&amp;diff=99881</id>
		<title>Cohort sync</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Cohort_sync&amp;diff=99881"/>
		<updated>2012-08-08T11:06:22Z</updated>

		<summary type="html">&lt;p&gt;Maherne: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Enrolment}}&lt;br /&gt;
Cohorts, or site-wide groups, enable all members of a cohort to be enrolled in a course in one action, either manually or synchronised automatically.&lt;br /&gt;
&lt;br /&gt;
==Enrolling a cohort in a course==&lt;br /&gt;
&lt;br /&gt;
In order to actually enrol users from a Cohort into courses the &#039;&#039;Cohort-Sync&#039;&#039; Enrollment plugin needs to be added to the enrollment methods for the course. The Administrator will first need to enable the &#039;&#039;Cohort-Sync&#039;&#039; enrolment plugin site wide (&#039;&#039;Settings &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Enrolments&#039;&#039;) and then add it to the required Course: (&#039;&#039;Settings &amp;gt; Course administration &amp;gt; Users &amp;gt; Enrolment Methods&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Cohortsync.png]]&lt;br /&gt;
&lt;br /&gt;
At this stage the &#039;&#039;Cohort-Sync&#039;&#039; instance for the course is edited and the appropriate Cohort selected. The role to which the Cohort users are assigned is also selected at this point (typically Student).&lt;br /&gt;
&lt;br /&gt;
Visiting the &#039;&#039;Settings &amp;gt; Course administration &amp;gt; Users &amp;gt; Enrolled Users&#039;&#039; page will show users enrolled via the &#039;&#039;Cohort-Sync&#039;&#039; plugin. &lt;br /&gt;
&lt;br /&gt;
Note that, by default, a teacher cannot add this plugin to their course. It needs to be configured by an Administrator or a user with the Manager role. Also note, that the user should be a Manager on a site level, not on the category or course level, otherwise the user will not see the option. If you want the user with the Manager role on the category level to see this enrol option, then you must add some cohorts on the category level, not on the site level.&lt;br /&gt;
&lt;br /&gt;
The required capabilities for setting up a cohort sync are:&lt;br /&gt;
* moodle/course:enrolconfig in the course context&lt;br /&gt;
* moodle/cohort:config in the course context&lt;br /&gt;
* moodle/cohort:view in the same context as category&lt;br /&gt;
&lt;br /&gt;
The required capabilities for manually enrolling cohort members are:&lt;br /&gt;
* the same as cohort sync (note: this is a bug MDL-28431)&lt;br /&gt;
* enrol/manual:enrol in course context&lt;br /&gt;
* moodle/course:enrolreview in course context&lt;br /&gt;
&lt;br /&gt;
==Enrolling a cohort in a category==&lt;br /&gt;
See [[Category enrolments]] where it is recommended that cohort sync be used in preference to category enrolments.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[Cohorts]] for information on how to create a cohort&lt;br /&gt;
&lt;br /&gt;
[[de:Einschreibung über globale Gruppen]]&lt;br /&gt;
[[ja:コーホート同期]]&lt;/div&gt;</summary>
		<author><name>Maherne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Setting_up_Eclipse&amp;diff=80099</id>
		<title>Development:Setting up Eclipse</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Setting_up_Eclipse&amp;diff=80099"/>
		<updated>2011-01-06T14:43:39Z</updated>

		<summary type="html">&lt;p&gt;Maherne: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://www.eclipse.org/ Eclipse] is an IDE originally designed for Java, but now with plugins for many languages including PHP. It has lots of very powerful features, and it is the editor that some Moodle developers like to use. Other (more) popular choices are vim and emacs.&lt;br /&gt;
&lt;br /&gt;
However, Eclipse is not the easiest program in the world to get started with, so I&#039;m going to take you through it step by step. These instructions assume Eclipse 3.2, the current version at the time of writing. It should not change much between releases.&lt;br /&gt;
&lt;br /&gt;
This article started off as a brain-dump by [[User:Tim Hunt|Tim Hunt]]. Since then, several other people have worked through it and made corrections, so the information here should be pretty accurate.&lt;br /&gt;
&lt;br /&gt;
Since this page was written, Eclipse 3.3 and 3.4 have been released, along with a new PHP plugin called PDT, which is better, but uses more memory. You can download an all-in-one Eclipse+PDT from http://www.eclipse.org/pdt/downloads/. The following instructions, from the section [[#Setting_the_preferences_for_Moodle_development]] mostly still apply after you have done the install, but some of the details are a bit different.--[[User:Tim Hunt|Tim Hunt]] 07:30, 31 January 2009 (CST)&lt;br /&gt;
&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
&lt;br /&gt;
Eclipse is written in Java, so I recommend getting the latest Java runtime environment from http://java.com/ for maximum speed and reliability.&lt;br /&gt;
&lt;br /&gt;
Eclipse is quite big, so I recommend lots of memory in your computer. I have used it on Windows, MacOS X and Linux, in each case with 1GB of memory, and that is plenty.&lt;br /&gt;
&lt;br /&gt;
==Installing Eclipse==&lt;br /&gt;
&lt;br /&gt;
Go to http://www.eclipse.org/downloads/. Click on the link corresponding to your operating system where it says &#039;&#039;&#039;Eclipse Classic&#039;&#039;&#039;. Choose a Mirror, and wait for the ~100MB download.&lt;br /&gt;
&lt;br /&gt;
You will notice that what you have got is a zip file (unless your system automatically decompresses it for you).&lt;br /&gt;
&lt;br /&gt;
On Windows, unzip it into &#039;&#039;&#039;C:\Program Files&#039;&#039;&#039; (all the files go into an &#039;&#039;&#039;Eclipse&#039;&#039;&#039; folder there). Then look in the Eclipse folder and drag Eclipse.exe to the Start menu/Desktop/Quicklaunch bar to make a shortcut for starting it.&lt;br /&gt;
&lt;br /&gt;
On MacOS, unzip and copy the Eclipse folder into Applications. Go into the Eclipse folder and drag the Eclipse app to the Dock for ease of launching.&lt;br /&gt;
&lt;br /&gt;
On Linux, unzip somewhere suitable, and make an easy way to launch it.&lt;br /&gt;
&lt;br /&gt;
==The first time you run Eclipse==&lt;br /&gt;
&lt;br /&gt;
The first time you launch Eclipse it does a bit of setup stuff, for instance, it creates a &#039;&#039;&#039;workspace&#039;&#039;&#039;. This is where it stores the things you are working on. The default location is sensible on all platforms, so use that. &lt;br /&gt;
&lt;br /&gt;
For some reason, every time you start Eclipse, it asks you which workspace you want to use. I have never seen the need to have more than one, so I recommend turning on the checkbox that says &amp;quot;Use this as the default and do not ask again&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another thing that happens the first time you run Eclipse is that you arrive at a welcome screen. This has links to various bits of help, which you can read if you like, but you probably don&#039;t need to if you are following these instructions. So find the button on the welcome page that closes it and gets you to the main Eclipse screen.&lt;br /&gt;
&lt;br /&gt;
==Installing the necessary plugins, for Eclipse Classic==&lt;br /&gt;
&lt;br /&gt;
The following information of this section about plugins for PHP is for Eclipse 3.4 Ganymede or before. On Eclipse 3.5 Galileo or later, a special package of Eclipse for PHP Developers has been built. Needless to install plugin for PHP anymore.&lt;br /&gt;
&lt;br /&gt;
By default, Eclipse comes with the Java tools. For everything else you will need to install some plugins.&lt;br /&gt;
&lt;br /&gt;
If you are sitting behind a web proxy, from the &#039;&#039;&#039;Window&#039;&#039;&#039; menu  choose &#039;&#039;&#039;Preferences ...&#039;&#039;&#039;. Choose &#039;&#039;&#039;Install/Update&#039;&#039;&#039; from the tree view on the left, and enter the proxy information in the boxes on the right. If you aren&#039;t behind a proxy, ignore this step. (On Eclipse 3.4.0 on OSX this is in &#039;&#039;&#039;Eclipse &amp;gt; Preferences &amp;gt; General &amp;gt; Network Connections&#039;&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
From the &#039;&#039;&#039;Help&#039;&#039;&#039; menu choose &#039;&#039;&#039;Check for Updates&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
On the first screen of the wizard, make sure that &amp;quot;Search for new features to install&amp;quot; is selected, then click &#039;&#039;&#039;Next &amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The next screen is a list of upgrade sites to check. You need to add one to the list, so click the &#039;&#039;&#039;New Remote Site ...&#039;&#039;&#039; Button.&lt;br /&gt;
&lt;br /&gt;
In the pop-up dialog, give the remote site a name like &#039;&#039;&#039;PHPeclipse Update Site&#039;&#039;&#039;; set the URL to http://update.phpeclipse.net/update/nightly; then click &#039;&#039;&#039;OK&#039;&#039;&#039;. Click &#039;&#039;&#039;Finish&#039;&#039;&#039;. Under &#039;&#039;&#039;PHPEclipse Nightly Builds&#039;&#039;&#039;, check &#039;&#039;&#039;PHPeclipse&#039;&#039;&#039;. Click &#039;&#039;&#039;Finish&#039;&#039;&#039;. Wait while it downloads (this may take a few minutes). Click &#039;&#039;&#039;Install&#039;&#039;&#039;. You will be prompted to restart Eclipse, click &#039;&#039;&#039;Restart&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note, there is now also another PHP editor for Eclipse. The update URL ishttp://download.eclipse.org/tools/pdt/updates/. I am just trying it--[[User:Tim Hunt|Tim Hunt]] 11:39, 7 November 2007 (CST)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Restart the wizard (from the &#039;&#039;&#039;Help&#039;&#039;&#039; menu choose &#039;&#039;&#039;Software Updates -&amp;gt; Find and Install&#039;&#039;&#039;). &lt;br /&gt;
&lt;br /&gt;
On the first screen of the wizard, make sure that &amp;quot;Search for new features to install&amp;quot; is selected, then click &#039;&#039;&#039;Next &amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Select just two things in the box &amp;quot;Sites to include in search&amp;quot;:&lt;br /&gt;
* Your newly created &#039;&#039;&#039;Phpeclipse Update Site&#039;&#039;&#039;; and&lt;br /&gt;
* the one called &#039;&#039;&#039;Europa Discovery Site&#039;&#039;&#039; (or possibly &#039;&#039;&#039;Callisto Discovery Site&#039;&#039;&#039;).&lt;br /&gt;
Then click &#039;&#039;&#039;Finish&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
It goes off and sees what updates are available at those sites. As it does so, it may occasionally pop up a dialog asking you to choose a mirror. Each time, select a sensible one.&lt;br /&gt;
&lt;br /&gt;
Eventually, you get to a new wizard for selecting and installing the updates you want (Select the features to install). The ones you want (you may have to expand and search the tree structure) are: all the &#039;&#039;&#039;PHPEclipse Nightly Builds&#039;&#039;&#039; (from your newly created PHPEclipse Update Site) and the &#039;&#039;&#039;Web Standard Tools (WST)&#039;&#039;&#039; (usually under Callisto or Europa Discovery Site --&amp;gt; Web and J2EE Development). &lt;br /&gt;
&lt;br /&gt;
Next, and very importantly, you must click the &#039;&#039;&#039;Select Required&#039;&#039;&#039; button which should resolve dependencies and remove the warning message you are probably worrying about. Then you can click the &#039;&#039;&#039;Next &amp;gt;&#039;&#039;&#039; button.&lt;br /&gt;
&lt;br /&gt;
Read and agree to all the license agreements. Then click &#039;&#039;&#039;Next &amp;gt;&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Click &#039;&#039;&#039;Finish&#039;&#039;&#039;, and wait for the plugins to download.&lt;br /&gt;
&lt;br /&gt;
Once the downloads have finished, a warning will pop-up telling you that all the plugins you downloaded are not digitally signed. The Eclipse Foundation built digital signing of plugins into their architecture as a security measure, and then did not sign any of their own plugins! Anyway, click the &#039;&#039;&#039;Install All&#039;&#039;&#039; button.&lt;br /&gt;
&lt;br /&gt;
Finally, a window will pop up asking you to restart Eclipse. Do so.&lt;br /&gt;
&lt;br /&gt;
==Setting the preferences for Moodle development==&lt;br /&gt;
&lt;br /&gt;
Now go to the &#039;&#039;&#039;Window&#039;&#039;&#039; menu, and choose &#039;&#039;&#039;Preferences ...&#039;&#039;&#039; (&#039;&#039;&#039;Eclipse&#039;&#039;&#039; menu on Mac OS X).&lt;br /&gt;
&lt;br /&gt;
The Eclipse preferences are immense, with a tree view on the left, which selects which screen to display on the right. Don&#039;t panic, we&#039;ll guide you through it.&lt;br /&gt;
&lt;br /&gt;
===General settings===&lt;br /&gt;
&lt;br /&gt;
If you have strong feelings about fonts (I would hate to edit code an anything except Andale Mono), choose &#039;&#039;&#039;General -&amp;gt; Appearance -&amp;gt; Colors and Fonts&#039;&#039;&#039; from the tree on the left. Then on the right look under &#039;&#039;&#039;Basic&#039;&#039;&#039; and change &#039;&#039;&#039;Text Font&#039;&#039;&#039;. All the other editor font settings will inherit from this, so this is probably the only one you have to change.&lt;br /&gt;
&lt;br /&gt;
Under &#039;&#039;&#039;General -&amp;gt; Content Types&#039;&#039;&#039;, select PHP Source File, and add &#039;&#039;&#039;*.html&#039;&#039;&#039; to the box at the bottom.&lt;br /&gt;
&lt;br /&gt;
Under &#039;&#039;&#039;General -&amp;gt; Editors -&amp;gt; File Associations&#039;&#039;&#039;, if it is not already there, add &#039;&#039;&#039;*.php&#039;&#039;&#039; to the top box. With &#039;&#039;&#039;*.php&#039;&#039;&#039; selected in the top box, make sure &#039;&#039;&#039;PHP Editor&#039;&#039;&#039; is set to default in the bottom box (use the &#039;&#039;&#039;Default&#039;&#039;&#039; button - the default will appear at the top of the list). &lt;br /&gt;
&lt;br /&gt;
With &#039;&#039;&#039;*.html&#039;&#039;&#039; selected in the top box, if it is not already there, add &#039;&#039;&#039;PHP Editor&#039;&#039;&#039; to the bottom box. Then select &#039;&#039;&#039;PHP Editor&#039;&#039;&#039; in the bottom box and click the &#039;&#039;&#039;Default&#039;&#039;&#039; button to change it, because in Moodle, most HTML files actually contain PHP code.&lt;br /&gt;
&lt;br /&gt;
If you use a web proxy, enter the details under &#039;&#039;&#039;Network Connections&#039;&#039;&#039;. (Yes, I know you have entered them somewhere else before. Now you have to enter them again here. I don&#039;t know why. You just do.)&lt;br /&gt;
&lt;br /&gt;
===PHP Settings===&lt;br /&gt;
&lt;br /&gt;
Under &#039;&#039;&#039;General -&amp;gt; Editors -&amp;gt; Text Editors&#039;&#039;&#039;, check &#039;&#039;&#039;Show line numbers&#039;&#039;&#039; to display line numbers in the left margin (optional). Click &#039;&#039;&#039;Apply&#039;&#039;&#039;. (When you are editing a PHP file, you could left-click in the left margin and tick the &#039;&#039;&#039;Show Line Numbers&#039;&#039;&#039; line in the contextual menu. However, this toggle only applies to plain text files, &#039;&#039;not&#039;&#039; to HTML or PHP files. The only place where you can toggle line numbers on/off for such files is in the PHP/Appearance menu.)&lt;br /&gt;
&lt;br /&gt;
Under &#039;&#039;&#039;PHPeclipse -&amp;gt; Browser Preview Defaults&#039;&#039;&#039;, turn off all checkboxes (if necessary). Click &#039;&#039;&#039;Apply&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Under &#039;&#039;&#039;PHPeclipse -&amp;gt; PHP&#039;&#039;&#039;, on the &#039;&#039;&#039;Appearance&#039;&#039;&#039; tab, set &#039;&#039;&#039;Displayed tab width&#039;&#039;&#039; to 4 (if necessary). Click &#039;&#039;&#039;Apply&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Under &#039;&#039;&#039;PHPeclipse -&amp;gt; PHP&#039;&#039;&#039;, on the &#039;&#039;&#039;Typing&#039;&#039;&#039; tab, turn off all the options except &#039;&#039;&#039;Pasting for correct indentation&#039;&#039;&#039;, &#039;&#039;&#039;Insert spaces for tab&#039;&#039;&#039; and &#039;&#039;&#039;Close PHPdocs and comments&#039;&#039;&#039;.  Click &#039;&#039;&#039;Apply&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Under &#039;&#039;&#039;PHPeclipse -&amp;gt; PHP -&amp;gt; Editor&#039;&#039;&#039;, turn on &#039;&#039;&#039;Remove trailing spaces on editor save&#039;&#039;&#039;. Click &#039;&#039;&#039;Apply&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Under &#039;&#039;&#039;PHPeclipse -&amp;gt; PHP -&amp;gt; Formatter&#039;&#039;&#039;, on the &#039;&#039;&#039;New Lines&#039;&#039;&#039; tab, turn on &#039;&#039;&#039;Clear all blank lines&#039;&#039;&#039;. Click &#039;&#039;&#039;Apply&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Under &#039;&#039;&#039;PHPeclipse -&amp;gt; PHP -&amp;gt; Formatter&#039;&#039;&#039;, on the &#039;&#039;&#039;Style&#039;&#039;&#039; tab, turn off &#039;&#039;&#039;Indentation is represented by a tab&#039;&#039;&#039;. Click &#039;&#039;&#039;Apply&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Under &#039;&#039;&#039;PHPeclipse -&amp;gt; PHP -&amp;gt; Templates&#039;&#039;&#039;, I like to define a new template to help with debugging:&lt;br /&gt;
;Name&lt;br /&gt;
:dump &lt;br /&gt;
;Description&lt;br /&gt;
:Dump a PHP variable&lt;br /&gt;
;Pattern&lt;br /&gt;
&amp;lt;pre&amp;gt;print_object(${word_selection}${cursor}); // DONOTCOMMIT&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can do other useful things with templates too. Here are two more I use:&lt;br /&gt;
&amp;lt;pre&amp;gt;debugging(&amp;quot;&#039;${word_selection}${cursor}&#039;&amp;quot;); // DONOTCOMMIT&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;$$string[&#039;${word_selection}${cursor}&#039;] = &#039;.&#039;;&amp;lt;/pre&amp;gt;&lt;br /&gt;
That is, a simple debug message with a stack trace, and a new language string.&lt;br /&gt;
&lt;br /&gt;
There is a really stupid bug. Under &#039;&#039;&#039;PHPeclipse -&amp;gt; Project Defaults&#039;&#039;&#039;, you would like to add &amp;quot;.&amp;quot; to the &#039;&#039;&#039;Include Paths&#039;&#039;&#039;, but you can&#039;t using the GUI. You will have to edit one of the Eclipse config files by hand. So&lt;br /&gt;
# Note down the path to your Eclipse profile. On Windows it will be something like &#039;&#039;&#039;C:/Documents and settings/XXXX/workspace&#039;&#039;&#039;, and on Unixy systems something like &#039;&#039;&#039;~/workspace&#039;&#039;&#039;.&lt;br /&gt;
# Close Eclipse. &lt;br /&gt;
# Open the file &#039;&#039;&#039;net.sourceforge.phpeclipse.ui.prefs&#039;&#039;&#039; that is in the directory &#039;&#039;&#039;(your workspace)/.metadata/.plugins/org.eclipse.core.runtime/.settings&#039;&#039;&#039; in a text editor.&lt;br /&gt;
# Look for a line in the file that starts &#039;&#039;&#039;_php_include_paths=&#039;&#039;&#039; If it is not there, add it at the end.&lt;br /&gt;
# Change this line to say &#039;&#039;&#039;_php_include_paths=.&#039;&#039;&#039;&lt;br /&gt;
# Run Eclipse again.&lt;br /&gt;
&lt;br /&gt;
===SSH2===&lt;br /&gt;
Information about generating SSH2 keys for the purpose of connecting to cvs.moodle.org can be found here at https://docs.moodle.org/en/Development:SSH_key , but please finish reading this section before reading that material.&lt;br /&gt;
&lt;br /&gt;
The Eclipse installation has its own SSH client plugin so you do not have to use a separate ssh client in connection with your use of Eclipse (this is one reason you will be using extssh below,  instead of just ext,  however,  if you wish you may alter the configuration to use an external client but please post news of your success and configuration). See, http://www.jcraft.com/eclipse-cvsssh2/ , for additional information on this plugin.  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039; Since Eclipse 3.0M6 the CVSSSH plugin is incorporated into Eclipse, [http://www.jroller.com/prane/entry/eclipse_3_0_cvs_support as &amp;quot;extssh&amp;quot; instead of &amp;quot;extssh2&amp;quot;] - --[[User:Olli Savolainen|Olli Savolainen]] 07:54, 23  June 2008 (CDT)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Please note that Eclipse is fully equipped to generate ssh2 rsa and dsa keys as well as import keys.  You may encounter issues with passphrases that are too long (a bug reportedly fixed but which may still in fact be present) and some issues with using keypairs generated by other applications have been seen, so it may be best to generate a key pair with Eclipse. Additional details on how to do this will be added.&lt;br /&gt;
&lt;br /&gt;
Sourceforge, at http://sourceforge.net/docs/F02/ , provides instructions on how to create a SSH key for it&#039;s CVS (remember,  Moodle does not use sourceforge for its CVS now and you will need to generate keys for cvs.moodle.org, not sourceforge). This is mentioned by way of general explanation, not for the purposes of providing instructions on how to generate your keys for Eclipse. To make use of the public key, login to Moodle.org and add it via the Update My Developer Information tab under CVS Developers (http://moodle.org/cvs). Remember,  public keys provided to Moodle must be in the Openssh format.&lt;br /&gt;
&lt;br /&gt;
===CVS Settings===&lt;br /&gt;
&lt;br /&gt;
These are almost all hidden under the &#039;&#039;&#039;Team&#039;&#039;&#039; bit of the tree.&lt;br /&gt;
&lt;br /&gt;
Under &#039;&#039;&#039;General -&amp;gt; Network Connections -&amp;gt; SSH2 -&amp;gt; Key Management&#039;&#039;&#039;, you can set up a public/private key pair. If you do this, you won&#039;t have to keep typing your password when doing CVS operations. &lt;br /&gt;
&lt;br /&gt;
The rest of the ones in this section are personal preferences, but I recommend them because the default settings are very irritating.&lt;br /&gt;
&lt;br /&gt;
Under &#039;&#039;&#039;Team&#039;&#039;&#039;, set &#039;&#039;&#039;Perspectives&#039;&#039;&#039; to &#039;&#039;&#039;None&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Under &#039;&#039;&#039;Team -&amp;gt; CVS&#039;&#039;&#039;, on the &#039;&#039;&#039;Files and Folders&#039;&#039;&#039; tab, set &#039;&#039;&#039;Default text mode&#039;&#039;&#039; to &#039;&#039;&#039;ASCII with keyword expansion (-kkv)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Under &#039;&#039;&#039;Team -&amp;gt; CVS -&amp;gt; Annotate&#039;&#039;&#039; set &#039;&#039;&#039;Use Quick Diff annotate mode for local file annotations&#039;&#039;&#039; to &#039;&#039;&#039;Yes&#039;&#039;&#039;, and &#039;&#039;&#039;Open perspective after a &#039;Show Annotations&#039; operation&#039;&#039;&#039; to &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Under &#039;&#039;&#039;Team -&amp;gt; CVS -&amp;gt; Label Decorations&#039;&#039;&#039;, switch to the &#039;&#039;&#039;Icon Decorations&#039;&#039;&#039; tab and turn on all the settings, and then on the &#039;&#039;&#039;Text Decorations&#039;&#039;&#039; tab change both &#039;&#039;&#039;File Decoration&#039;&#039;&#039; and &#039;&#039;&#039;Folder Decoration&#039;&#039;&#039; to be just &#039;&#039;&#039;{name}&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
===Web and XML settings===&lt;br /&gt;
&lt;br /&gt;
For each XXX in CSS, HTML, Javascript, XML:&lt;br /&gt;
&lt;br /&gt;
Under &#039;&#039;&#039;Web and XML -&amp;gt; XML Files -&amp;gt; Source&#039;&#039;&#039;, choose &#039;&#039;&#039;Indent using spaces&#039;&#039;&#039; and &#039;&#039;&#039;indentation size&#039;&#039;&#039; 4.&lt;br /&gt;
&lt;br /&gt;
==Checking out the Moodle code==&lt;br /&gt;
&lt;br /&gt;
From the &#039;&#039;&#039;File&#039;&#039;&#039; menu, choose &#039;&#039;&#039;New -&amp;gt; Project ...&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In the wizard that pops up, choose &#039;&#039;&#039;CVS -&amp;gt; Projects from CVS&#039;&#039;&#039;, then click &#039;&#039;&#039;Next &amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Select &#039;&#039;&#039;Create a new repository location&#039;&#039;&#039;, then click &#039;&#039;&#039;Next &amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Fill in&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right; border: 1px solid orange; padding: 0 1em;&amp;quot;&amp;gt;&lt;br /&gt;
For anonymous CVS access use&lt;br /&gt;
;Host&lt;br /&gt;
:XX.cvs.moodle.org&lt;br /&gt;
where XX.cvs.moodle.org is one of [[CVS_for_Administrators#CVS_Servers|these mirrors]]&lt;br /&gt;
;Repository path&lt;br /&gt;
:/cvsroot/moodle&lt;br /&gt;
;User&lt;br /&gt;
:anonymous&lt;br /&gt;
;Password&lt;br /&gt;
:(leave blank)&lt;br /&gt;
;Connection type&lt;br /&gt;
:pserver&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
;Host&lt;br /&gt;
:cvs.moodle.org&lt;br /&gt;
;Repository path&lt;br /&gt;
:/cvsroot/moodle&lt;br /&gt;
;User&lt;br /&gt;
:(your Moodle CVS username)&lt;br /&gt;
;Password&lt;br /&gt;
:(if you set up the SSH2 key thing in preferences, leave this blank, otherwise, type in your Moodle CVS password.)&lt;br /&gt;
;Connection type&lt;br /&gt;
:extssh&lt;br /&gt;
(CVS experts, if you are confused by that last one, know it is an Eclipse-specific thing.) Then click &#039;&#039;&#039;Next &amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
On the next screen of the Wizard, choose &#039;&#039;&#039;Use an existing module&#039;&#039;&#039;. Wait a moment, then select &#039;&#039;&#039;moodle&#039;&#039;&#039; from the list. Click &#039;&#039;&#039;Next &amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
On the next screen, make sure the option &#039;&#039;&#039;Check out as a project configured using the New Project Wizard&#039;&#039;&#039; is selected, then click &#039;&#039;&#039;Next &amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Click &#039;&#039;&#039;Refresh Tags&#039;&#039;&#039;, then choose the branch you want. For now leave it set to &#039;&#039;&#039;HEAD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Click &#039;&#039;&#039;Finish&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now you  will find yourself back at the start of the &#039;&#039;&#039;New Project&#039;&#039;&#039; Wizard. This is because of the option you chose three paragraphs ago. This time you should select &#039;&#039;&#039;PHP -&amp;gt; PHP Project&#039;&#039;&#039;, then click &#039;&#039;&#039;Next &amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Make up a project name. &#039;&#039;&#039;moodle&#039;&#039;&#039; would be sensible.&lt;br /&gt;
&lt;br /&gt;
Click &#039;&#039;&#039;Finish&#039;&#039;&#039;, and wait while all the moodle files are checked out of CVS.&lt;br /&gt;
&lt;br /&gt;
Once it has finished, it will probably ask you if you want to switch to the PHP perspective. Answer &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you also need another branch (1.6, 1.7, 1.8, ...) repeat all the other steps with a few changes:&lt;br /&gt;
* This time you can choose &#039;&#039;&#039;Use an existing repository location&#039;&#039;&#039; instead of typing all the sourceforge CVS details again.&lt;br /&gt;
* Select the appropriate branch. If you don&#039;t see the branch you want, see [https://docs.moodle.org/en/Development:Setting_up_Eclipse#Resetting_the_branch_information this Troubleshooting tip].&lt;br /&gt;
* Use a different project name (e.g. moodle16, moodle17, etc.).&lt;br /&gt;
&lt;br /&gt;
==Let your development web server know where your files are==&lt;br /&gt;
&lt;br /&gt;
Either by editing you web server&#039;s config files, or using a symbolic link. Make sure your webserver can see your new working set of files at a sensible URL, so you can test the code you are working on.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Quick tour of some cool features, and remaining configuration changes==&lt;br /&gt;
&lt;br /&gt;
I find the default workbench setup is pretty good. Here is a quick guide to some of the bits.&lt;br /&gt;
&lt;br /&gt;
===Navigator===&lt;br /&gt;
&lt;br /&gt;
To the left is the &#039;&#039;&#039;Navigator&#039;&#039;&#039;. This is a tree view of all your files. If you double-click on a file, it opens in the editor in the middle. Try opening &#039;&#039;&#039;course/lib.php&#039;&#039;&#039; now. You will notice that it comes up nicely syntax-highlighted.&lt;br /&gt;
&lt;br /&gt;
===Error highlighting===&lt;br /&gt;
&lt;br /&gt;
In the middle of the file, just type any old text, for example &amp;quot;I like Eclipse&amp;quot;. Obviously, this is not valid PHP syntax, and Eclipse will notice this, and put a red underline under it. Also, by the scrollbar is a ruler with a red mark in it to show the error.&lt;br /&gt;
&lt;br /&gt;
You will see some yellow marks lower down the ruler. There are warnings. Click on one, and you will be taken to where that warning is in the file. Hover your mouse over the warning, and you will get a tooltip explaining what the problem might be.&lt;br /&gt;
&lt;br /&gt;
Save the edited file. (Don&#039;t worry that it is broken, we&#039;ll clean up the mess later.) Notice that a red error marker is added to the file in the navigator, so you can see that there is a problem. Also, error markers are added to the course folder, and the whole project, so you could see there was an error even if the navigator tree was collapsed.&lt;br /&gt;
&lt;br /&gt;
You will probably find lots of warnings that the config.php file can&#039;t be found. In the navigator, find the file &#039;&#039;&#039;config-dist.php&#039;&#039;&#039;. Do &#039;&#039;&#039;Copy&#039;&#039;&#039; then &#039;&#039;&#039;Paste&#039;&#039;&#039; and choose to call the new file &#039;&#039;&#039;config.php&#039;&#039;&#039;. Edit this new config.php as normal. You should find that most of the include file warnings have gone now.&lt;br /&gt;
&lt;br /&gt;
Notice also that there is another marker on each file icon. A little yellow cylinder on most files, but a white-on-brown star on the one you have edited. This is telling you the CVS status of each file. The brown stars are changes you have made but not checked in yet.&lt;br /&gt;
&lt;br /&gt;
===Outline===&lt;br /&gt;
&lt;br /&gt;
Over to the right is the Outline view. This shows a list of functions and classes defined in this file. By default, they are listed in the same order as in the file, but if you click on the &#039;&#039;&#039;az&#039;&#039;&#039; toolbar button, they are sorted into alphabetical order.&lt;br /&gt;
&lt;br /&gt;
Click on the function name &#039;&#039;&#039;add_course_module&#039;&#039;&#039; in the Outline. You will see that the editor scrolls to the definition of that function.&lt;br /&gt;
&lt;br /&gt;
===Code navigation===&lt;br /&gt;
&lt;br /&gt;
In that function, hover the mouse pointer over the function name &#039;&#039;&#039;insert_record&#039;&#039;&#039;. After a while, the documentation for that function will appear in a big tooltip.&lt;br /&gt;
&lt;br /&gt;
Hold down CTRL, move the mouse pointer over the function name &#039;&#039;&#039;insert_record&#039;&#039;&#039;, then click. Eclipse should load &#039;&#039;&#039;dmllib.php&#039;&#039;&#039;, and scroll you to where this function is defined. (You can also do this by clicking on the function name and pressing the F3 key.)&lt;br /&gt;
&lt;br /&gt;
In the main Eclipse toolbar, there are forward and back arrows like in a web browser. Click back now to get back to &#039;&#039;&#039;course/lib.php&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
===Open resource===&lt;br /&gt;
&lt;br /&gt;
From the &#039;&#039;&#039;Navigate&#039;&#039;&#039; menu, choose &#039;&#039;&#039;Open Resource...&#039;&#039;&#039;. In the dialog that pops up, start typing a filename for instance type &#039;&#039;&#039;moodlel&#039;&#039;&#039;. In the box in the middle of the dialog, you will see it list all the files in the project whose names start that way. At the bottom is a box which lists the different folders that contain a file with that name. This can be a very quick way of opening files with fairly unique names like moodlelib.php, without having to click through the levels of the navigator tree. Of course, it is not so useful for an index.php file! Click OK now to open moodlelib.php. (It would actually work if you just did CTRL + Shift + R, moodlel, Enter.)&lt;br /&gt;
&lt;br /&gt;
===Multi-file search===&lt;br /&gt;
&lt;br /&gt;
Scroll down moodlelib a little bit, and double click on the name of the constant &#039;&#039;&#039;MOODLE_INTERNAL&#039;&#039;&#039; where it is defined, so that the text is selected. Then, from the &#039;&#039;&#039;Search&#039;&#039;&#039; menu, choose &#039;&#039;&#039;Search...&#039;&#039;&#039;. Notice that the &#039;&#039;&#039;Containing text&#039;&#039;&#039; box has already been filled in for you with the text you just selected. Of course you can just type text into this box without selecting it first. Notice that you can do regular expression searches, but leave that turned off for now. In the &#039;&#039;&#039;File name patterns&#039;&#039;&#039; box type &#039;&#039;&#039;*.css, *.html, *.inc, *.js, *.php, *.xml&#039;&#039;&#039;. (This is the most useful general setting for working on moodle. Eclipse will remember this setting, so you only have to enter it once.) Click &#039;&#039;&#039;Search&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The search results will appear in a new view underneath the editor. That view has a toolbar with yellow up and down arrows. Click the down arrow a few times and it will take you to the first few matches in the code, opening the relevant files as necessary.&lt;br /&gt;
&lt;br /&gt;
===Synchronize view===&lt;br /&gt;
&lt;br /&gt;
I think this is my favorite feature. From the &#039;&#039;&#039;Window&#039;&#039;&#039; menu, select &#039;&#039;&#039;Show View -&amp;gt; Other...&#039;&#039;&#039;. In the dialog that pops up, select &#039;&#039;&#039;Team -&amp;gt; Synchronize&#039;&#039;&#039;, then click &#039;&#039;&#039;OK&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This opens the Synchronize view below the editor. The view has a toolbar. Click on the first toolbar button, which pops up the Synchronize wizard.&lt;br /&gt;
&lt;br /&gt;
On the first screen, there will probably only be one option: &#039;&#039;&#039;CVS&#039;&#039;&#039;. Make sure that is selected, then click &#039;&#039;&#039;Next &amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Under &#039;&#039;&#039;Scope&#039;&#039;&#039;, choose &#039;&#039;&#039;Workspace&#039;&#039;&#039;, then click &#039;&#039;&#039;Finish&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Wait while it talks to the CVS server. After a while, you will see that the Synchronize view lists course/lib.php, and something called &#039;&#039;&#039;.project...&#039;&#039;&#039; That is, it is listing just the files you have edited, but not checked in yet.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;.project&#039;&#039;&#039; is something that belongs to Eclipse that we don&#039;t care about. So select it and bring up the context menu, and choose &#039;&#039;&#039;Add to .cvsignore...&#039;&#039;&#039;. In the dialog that pops up, choose the top option, then click &#039;&#039;&#039;OK&#039;&#039;&#039;. Then you will find the Synchronize view shows you a &#039;&#039;&#039;.cvsignore&#039;&#039;&#039; file that you aren&#039;t interested in, so add that to .cvsignore too!&lt;br /&gt;
&lt;br /&gt;
If you double-click on &#039;&#039;&#039;course/lib.php&#039;&#039;&#039; here, you will see that it opens the compare editor, which is a nice graphical display of the changes in this file.&lt;br /&gt;
&lt;br /&gt;
If you select a file or files here, then bring up the context menu, you will see the option to &#039;&#039;&#039;Commit...&#039;&#039;&#039; the changes. (But don&#039;t do that now!). This is the easiest way to commit things in Eclipse.&lt;br /&gt;
&lt;br /&gt;
However, our changes were rubbish, so we want to undo them. So open the context menu again, and choose &#039;&#039;&#039;Override and Update&#039;&#039;&#039;. This checks a clean copy of the file out of CVS, removing our changes.&lt;br /&gt;
&lt;br /&gt;
Note that the easiest way to do an ordinary CVS Update is to select the top-level project-folder in the Navigator view on the left, open the context menu, and choose &#039;&#039;&#039;Team -&amp;gt; Update&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
That&#039;s all of the really important features. I&#039;m sure you can learn everything else on your own. And you can always read the built in help!&lt;br /&gt;
&lt;br /&gt;
===Creating a patch===&lt;br /&gt;
&lt;br /&gt;
In the synchronise view, right-click an item (file or folder) and choose &#039;&#039;&#039;Create Patch...&#039;&#039;&#039;. Or in the navigator, right-click an item and choose &#039;&#039;&#039;Team -&amp;gt; Create Patch...&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This brings up a two-page wizard. On the first page you can select where you want the patch made. For small patches it can be useful to create them on the clipboard, but normally you will want to save them in a file.&lt;br /&gt;
&lt;br /&gt;
On the second page, you can set some options, but normally you don&#039;t need to change the defaults which are &#039;&#039;&#039;Unified&#039;&#039;&#039; diff format, and Patch root set to &#039;&#039;&#039;Workspace&#039;&#039;&#039;. Well, sometimes it is helpful to change the second one to &#039;&#039;&#039;Project&#039;&#039;&#039; but it is not important.&lt;br /&gt;
&lt;br /&gt;
There is a corresponding apply patch wizard that you can use to apply a patch to a project.&lt;br /&gt;
&lt;br /&gt;
===Switching to another branch or version===&lt;br /&gt;
&lt;br /&gt;
Suppose you have been using a check-out of HEAD from CVS, and then as the 1.9 release approaches, the MOODLE_19_STABLE branch is created, and you want to start following that instead.&lt;br /&gt;
# Right click on the moodle project in the navigator view, and select &#039;&#039;&#039;Team -&amp;gt; Switch to Another Branch or Version ...&#039;&#039;&#039;.&lt;br /&gt;
# choose the second radio button: &#039;&#039;&#039;Select the tag from the following list&#039;&#039;&#039;.&lt;br /&gt;
# If the branch you want is not in the &#039;&#039;&#039;Matching tags&#039;&#039;&#039; box, see [[Development:Setting_up_Eclipse#Resetting the branch information|Resetting the branch information]] below.&lt;br /&gt;
# Select the branch you want and click &#039;&#039;&#039;Finish&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Troubleshooting==&lt;br /&gt;
&lt;br /&gt;
Some tips on how to solve common problems that may crop up.&lt;br /&gt;
&lt;br /&gt;
===Resetting the branch information===&lt;br /&gt;
&lt;br /&gt;
Every now and then, Eclipse may lose information on the branch tags it knows about. Hitting refresh tags may fix it, but if not, try the following:&lt;br /&gt;
&lt;br /&gt;
#Bring up the tag dialogue (example using &amp;quot;Team / Switch to Another Branch or Version&amp;quot;).&lt;br /&gt;
#Click on Configure tags... (not Refresh tags).&lt;br /&gt;
#Select config-dist.php in the top left box (if this is a Moodle checkout).&lt;br /&gt;
#Click Add Checked tags.&lt;br /&gt;
#Click OK.&lt;br /&gt;
#Then you will have all tags.&lt;br /&gt;
&lt;br /&gt;
(thanks to Tim Hunt)&lt;br /&gt;
&lt;br /&gt;
This info saved my day to find all branches:&lt;br /&gt;
   1. Window-&amp;gt;Show View-&amp;gt;Other. Select CVS-&amp;gt;CVS Repositories.&lt;br /&gt;
   2. Context Menu-&amp;gt;New-&amp;gt;Repository Location...&lt;br /&gt;
   3. Fill in the location information identifying your repository and click Finish.&lt;br /&gt;
   4. Expand the newly-created repository location.&lt;br /&gt;
   5. Add the branch:&lt;br /&gt;
         1. Right-click it and expand configure branches and versions.&lt;br /&gt;
         2. Expand HEAD and select the project moodle.&lt;br /&gt;
         3. Context Menu-&amp;gt;Configure Branches and Versions...&lt;br /&gt;
         4. In the &amp;quot;Browse files for tags&amp;quot; table, select one or more files &lt;br /&gt;
            that contain tags you would like to see (for example scroll down &lt;br /&gt;
            to find config.php).&lt;br /&gt;
         5. On the right the existing tags will appear.&lt;br /&gt;
         6. Select the tags: for example MOODLE_15_STABLE&lt;br /&gt;
         7. Click &amp;quot;Add Selected Tags&amp;quot;.&lt;br /&gt;
         8. Click &amp;quot;OK&amp;quot;.&lt;br /&gt;
   6. Locate branches, MOODLE_19_STABLE, moodle MOODLE_19_STABLE.&lt;br /&gt;
   7. Context Menu-&amp;gt;Check Out As Project.&lt;br /&gt;
(&amp;quot;stolen&amp;quot; from  Joan Codina Filba	&lt;br /&gt;
General developer forum -&amp;gt; Moodle floating &amp;quot;block&amp;quot;/toolbar released -&amp;gt; Re: Moodle floating &amp;quot;block--PATCH FOR GRADES &amp;amp; ASIGNMENT --PROBLEM)&lt;br /&gt;
&lt;br /&gt;
===Error loading php files after Ubuntu 7.04 Install===&lt;br /&gt;
&lt;br /&gt;
A java issue with Ubuntu 7.04 may cause an error when you attempt to load php pages. Refer to:&lt;br /&gt;
http://www.plog4u.org/index.php/Using_PHPEclipse_:_Installation_:_Installing_PHPEclipse for details about how to fix this in Ubuntu 7.04.&lt;br /&gt;
&lt;br /&gt;
After upgrading from Ubuntu 7.04 to 7.10, I had to go in and re-edit the /etc/eclipse/java_home file in order to get the CVS functions to work and be able to open PHP files. When I tried to do a CVS update, I initially received an error about org.eclipse.team.internal.ccvs.ui.wizards.CheckoutWizard). Everything seemed to work again after reapplying the fix for the aforementioned 7.04 java issue.&lt;br /&gt;
&lt;br /&gt;
===Strange mouse behavior in Eclipse with Ubuntu 9.10===&lt;br /&gt;
&lt;br /&gt;
After upgrading to Ubuntu 9.10 I began have left mouse clicks that did not appear to be actually firing off the expected events. I stumbled across https://bugs.launchpad.net/ubuntu/+source/gtk+2.0/+bug/452938. Essentially what I did was modify /usr/bin/eclipse and added in the line: export GDK_NATIVE_WINDOWS=true so that it executes before starting Eclipse.&lt;br /&gt;
&lt;br /&gt;
== Related Links ==&lt;br /&gt;
&lt;br /&gt;
There is an excellent series of articles published by IBM on using Eclipse for Drupal developement here : [http://www-128.ibm.com/developerworks/ibm/osource/index.html Using open source software to design, develop, and deploy a collaborative Web site Tools and techniques for getting relatively complicated Web sites up and running quickly].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer|Eclipse]]&lt;br /&gt;
[[Category:Developer tools|Eclipse]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Développement:Eclipse]]&lt;/div&gt;</summary>
		<author><name>Maherne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Unit_tests&amp;diff=59991</id>
		<title>Development:Unit tests</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Unit_tests&amp;diff=59991"/>
		<updated>2009-07-16T11:40:55Z</updated>

		<summary type="html">&lt;p&gt;Maherne: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 1.7}}Location: &#039;&#039;Administration &amp;gt; Reports &amp;gt; Unit tests&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The purpose of Unit Tests is to evaluate the individual parts of a program (functions, and methods of classes) to make sure that each element individually does the right thing. Unit Tests can be one of the first steps in a quality control process for developing or tweaking Moodle code.  The next steps will involve other forms of testing to ensure that these different parts work together properly. &lt;br /&gt;
&lt;br /&gt;
The unit testing framework is based on the [http://www.simpletest.org/ SimpleTest] framework.&lt;br /&gt;
&lt;br /&gt;
== Running the unit tests in Moodle ==&lt;br /&gt;
&lt;br /&gt;
=== Running the basic tests ===&lt;br /&gt;
&lt;br /&gt;
# Log in with an admin account. &lt;br /&gt;
# Administration ► Development ► Unit tests (moodle &amp;gt;= 2.0, Administration ► Reports ► Unit tests Moodle &amp;lt;= 1.9)&lt;br /&gt;
# Click on the &#039;&#039;&#039;Reports&#039;&#039;&#039; link near the bottom of the page.&lt;br /&gt;
# Click the &#039;&#039;&#039;Run tests&#039;&#039;&#039; button and wait.&lt;br /&gt;
&lt;br /&gt;
This finds all the tests in Moodle and runs them. You can run a subset of the tests by entering a path (for example question/type) in the &#039;Only run tests in&#039; box. Similarly, if a test fails, you get some links in the failure message to make it easy to re-run just those tests.&lt;br /&gt;
&lt;br /&gt;
== Writing new tests ==&lt;br /&gt;
&lt;br /&gt;
As an example, suppose we wanted to write some tests for the string_manager class in mod/quiz/editlib.php.&lt;br /&gt;
&lt;br /&gt;
=== Where to put the tests ===&lt;br /&gt;
&lt;br /&gt;
The unit test report finds tests by looking for files called &#039;test....php&#039; inside folders called &#039;simpletest&#039;.&lt;br /&gt;
&lt;br /&gt;
So, for our example, we want to create called something like &#039;&#039;&#039;mod/quiz/simpletest/testeditlib.php&#039;&#039;&#039;. The skeleton of this file should look like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Unit tests for (some of) mod/quiz/editlib.php.&lt;br /&gt;
 *&lt;br /&gt;
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License&lt;br /&gt;
 * @package question&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
if (!defined(&#039;MOODLE_INTERNAL&#039;)) {&lt;br /&gt;
    die(&#039;Direct access to this script is forbidden.&#039;); //  It must be included from a Moodle page&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Make sure the code being tested is accessible.&lt;br /&gt;
require_once($CFG-&amp;gt;dirroot . &#039;/mod/quiz/editlib.php&#039;); // Include the code to test&lt;br /&gt;
&lt;br /&gt;
/** This class contains the test cases for the functions in editlib.php. */&lt;br /&gt;
class quiz_editlib_test extends UnitTestCase {&lt;br /&gt;
    function test_something() {&lt;br /&gt;
        // Do the test here.&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // ... more test methods.&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That is, you have a class called something_test, and in that class you have lots of methods called test_something. Normally, you have one test method for each particular thing you want to test, and you should try to name the function to describe what is being tested - without making the name too ridiculously long!&lt;br /&gt;
&lt;br /&gt;
=== A test function ===&lt;br /&gt;
&lt;br /&gt;
The a test function typically looks like&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function test_move_question_up() {&lt;br /&gt;
    // Setup fixture&lt;br /&gt;
&lt;br /&gt;
    // Exercise SUT&lt;br /&gt;
    $newlayout = quiz_move_question_up(&#039;1,2,0&#039;, 2);&lt;br /&gt;
&lt;br /&gt;
    // Validate outcome&lt;br /&gt;
    $this-&amp;gt;assertEqual($newlayout, &#039;2,1,0&#039;);&lt;br /&gt;
&lt;br /&gt;
    // Teardown fixture&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is the [http://xunitpatterns.com/Four%20Phase%20Test.html four phase test pattern]. Those comments use a lot of testing jargon. The fixture is is the background situation that needs to be set up before the test runs. SUT is short for &#039;situation under test&#039;. This is where you call the function or method that you want to test. Then you check to see if the function did the right thing. Finally, you have to clean up the fixture you created. With luck there is nothing to do here&lt;br /&gt;
&lt;br /&gt;
In this simple example, there is no setup or teardown to do. We just call the function we are testing with some sample input, and check that the return value is what we expect.&lt;br /&gt;
&lt;br /&gt;
=== Shared setUp and tearDown methods ===&lt;br /&gt;
&lt;br /&gt;
If all your test cases relate to the same area of code, then they may all need to same bit of fixture set up. For example, all the tests in lib/simpletest/teststringmanager.php need an instance of the string_manager class to test.&lt;br /&gt;
&lt;br /&gt;
To avoid duplicating code, you can override a method called &amp;lt;code&amp;gt;setUp()&amp;lt;/code&amp;gt; that sets up the test data. If present, this method will be called before each test method. You can write a matching &amp;lt;code&amp;gt;tearDown()&amp;lt;/code&amp;gt; method if there is any clean-up that needs to be done after each test case has run. For example, in lib/simpletest/teststringmanager.php there are setUp and tearDown methods that do something like:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
public function setUp() {&lt;br /&gt;
    // ...&lt;br /&gt;
    $this-&amp;gt;stringmanager = new string_manager(...);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public function tearDown() {&lt;br /&gt;
    $this-&amp;gt;stringmanager = null;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Then, each test can use $this-&amp;gt;stringmanager without having to worry about the details of how it is set up.&lt;br /&gt;
&lt;br /&gt;
=== Further information ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;SimpleTest&#039;&#039; documentation is at: http://www.simpletest.org/.&lt;br /&gt;
&lt;br /&gt;
== Changes to your existing code to make it work with unit testing ==&lt;br /&gt;
&lt;br /&gt;
The whole point of unit testing is to test each piece of functionality separately. You can only do this is only possible to isolate that function and call it individually, perhaps after setting up a few other things.&lt;br /&gt;
&lt;br /&gt;
Therefore, it is good if you can write your code to depend on as few other things as possible. &lt;br /&gt;
&lt;br /&gt;
=== Include paths ===&lt;br /&gt;
&lt;br /&gt;
Includes like&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
require_once(&#039;../../config.php&#039;); // Won&#039;t work.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
won&#039;t work. Instead, the more robust option is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
require_once(dirname(__FILE__) . &#039;/../../config.php&#039;); // Do this.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Access to global variables ===&lt;br /&gt;
&lt;br /&gt;
Because your code was included from within a function, you can&#039;t access global variables until you have done a global statement.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
require_once(dirname(__FILE__) . &#039;/../../config.php&#039;);&lt;br /&gt;
require_once($CFG-&amp;gt;libdir . &#039;/moodlelib.php&#039;); // Won&#039;t work.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
require_once(dirname(__FILE__) . &#039;/../../config.php&#039;);&lt;br /&gt;
&lt;br /&gt;
global $CFG; // You need this.&lt;br /&gt;
require_once($CFG-&amp;gt;libdir . &#039;/moodlelib.php&#039;); // Will work now.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Calls to global functions ===&lt;br /&gt;
Testing a class method that calls global functions can be problematic. At least, it&#039;s always complex, because we can&#039;t control what goes on in the global functions. We can&#039;t override the global functions or mock them in our unit tests. If the global functions themselves are well tested, this may not be a big problem, but most global functions are not well tested.&lt;br /&gt;
&lt;br /&gt;
==== Bridge Pattern ====&lt;br /&gt;
If your code needs to rely extensively on some public API, you could use the [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] to decouple your code from that API. This way, when you write unit tests, you can override the bridging class or mock it, and control its outputs while you focus exclusively on testing your code.&lt;br /&gt;
&lt;br /&gt;
An basic example follows: Imagine that I do not trust the &#039;&#039;get_string()&#039;&#039; global function, but my code needs to use it. Initially my code has strong coupling with &#039;&#039;get_string()&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
class myclass {&lt;br /&gt;
    public function print_stuff($stuff) {&lt;br /&gt;
        echo get_string($stuff);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s write a bridging class to solve this coupling issue and use it instead of &#039;&#039;get_string()&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
class languageBridge {&lt;br /&gt;
    public function get_string($stuff,$module=&#039;moodle&#039;) {&lt;br /&gt;
        echo get_string($stuff, $module);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class myclass {&lt;br /&gt;
    public $lang_bridge;&lt;br /&gt;
    public function __construct() {&lt;br /&gt;
        $this-&amp;gt;lang_bridge = new languageBridge();&lt;br /&gt;
    }&lt;br /&gt;
    public function print_stuff($stuff) {&lt;br /&gt;
        echo $this-&amp;gt;lang_bridge-&amp;gt;get_string($stuff);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following is yet another example using a bridging method to decouple from the Moodle core API.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
class workshop_api {&lt;br /&gt;
    /**&lt;br /&gt;
     * This is a method we want to unittest&lt;br /&gt;
     */&lt;br /&gt;
    public function get_peer_reviewers($context) {&lt;br /&gt;
        static $users=null;&lt;br /&gt;
        if (is_null($users)) {&lt;br /&gt;
            $users = $this-&amp;gt;get_users_by_capability($context, &#039;mod/workshop:peerassess&#039;, &lt;br /&gt;
                        &#039;u.id, u.lastname, u.firstname&#039;, &#039;u.lastname,u.firstname&#039;, &#039;&#039;, &#039;&#039;, &#039;&#039;, &#039;&#039;, false, false, true);&lt;br /&gt;
        }&lt;br /&gt;
        return $users;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /**  &lt;br /&gt;
     * Bridging method to decouple from Moodle core API&lt;br /&gt;
     */&lt;br /&gt;
    protected function get_users_by_capability() {&lt;br /&gt;
        $args = func_get_args();&lt;br /&gt;
        return call_user_func_array(&#039;get_users_by_capability&#039;, $args);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039; Here are some comments on the examples above expressing that the bridge pattern should be used very carefully.&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;I think that is a case of unit tests leading to worse software design, in that you are not using the standard API for something. But if you really want to unit test, I can&#039;t think of a better solution.&amp;quot;&lt;br /&gt;
* &amp;quot;I think this can be OK if used very selectively. Unfortunately I don&#039;t think it&#039;s the solution if you want to decouple the very complex and deeply nested Moodle functions from each other&amp;quot;&lt;br /&gt;
* &amp;quot;...your code is designed to be part of Moodle, so decoupling from a standard Moodle API is perverse.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Unit testing in 2.0 ==&lt;br /&gt;
&lt;br /&gt;
{{Moodle 2.0}}&lt;br /&gt;
With the Objectification of the Database libraries in Moodle 2.0, new and better approaches to Unit testing can be used. Here is a sample of a simple test case: (in course/simpletest)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
 require_once($CFG-&amp;gt;dirroot . &#039;/course/lib.php&#039;);&lt;br /&gt;
 &lt;br /&gt;
 global $DB;&lt;br /&gt;
 Mock::generate(get_class($DB), &#039;mockDB&#039;);&lt;br /&gt;
 &lt;br /&gt;
 class courselib_test extends UnitTestCase {&lt;br /&gt;
     var $realDB;&lt;br /&gt;
 &lt;br /&gt;
     function setUp() {&lt;br /&gt;
         global $DB;&lt;br /&gt;
         $this-&amp;gt;realDB = $DB;&lt;br /&gt;
         $DB           = new mockDB();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     function tearDown() {&lt;br /&gt;
         global $DB;&lt;br /&gt;
         $DB = $this-&amp;gt;realDB;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     function testMoveSection() {&lt;br /&gt;
         global $DB;&lt;br /&gt;
         $course = new stdClass();&lt;br /&gt;
         $course-&amp;gt;id = 1;&lt;br /&gt;
 &lt;br /&gt;
         $sections = array();&lt;br /&gt;
         for ($i = 1; $i &amp;lt; 11; $i++) {&lt;br /&gt;
             $sections[$i]          = new stdClass();&lt;br /&gt;
             $sections[$i]-&amp;gt;id      = $i;&lt;br /&gt;
             $sections[$i]-&amp;gt;section = $i - 1;&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         $DB-&amp;gt;expectOnce(&#039;get_records&#039;, array(&#039;course_sections&#039;, array(&#039;course&#039; =&amp;gt; $course-&amp;gt;id)));&lt;br /&gt;
         $DB-&amp;gt;setReturnValue(&#039;get_records&#039;, $sections);&lt;br /&gt;
         $this-&amp;gt;assertFalse(move_section($course, 2, 3));&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See also &#039;&#039;&#039;UnitTestCaseUsingDatabase&#039;&#039;&#039; in lib/simpletestlib.php.&lt;br /&gt;
&lt;br /&gt;
== Code coverage analysis==&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; This section is a work in progress. Please use the [[{{TALKPAGENAME}}|page comments]] or an appropriate [http://moodle.org/course/view.php?id=5 moodle.org forum] for any recommendations/suggestions for improvement.{{{info|}}}&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Moodle 2.0}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;[[Wikipedia:Code_coverage|Code coverage]]&#039;&#039;&#039; is a technique, strongly tied with software testing, that allows to &#039;&#039;&#039;check and improve the quality of the tests&#039;&#039;&#039; by measuring the degree of source code that is being covered by them. With Moodle supporting more and more tests each day (slowly towards a &#039;&#039;&#039;Test Driven Development&#039;&#039;&#039; model) we need to integrate some tool into our development process helping to analyse the quality of ours tests.&lt;br /&gt;
&lt;br /&gt;
Right now (in Moodle 2.0) we are using [http://www.simpletest.org/ SimpleTest], one simple and great tool to perform all the tests. Unluckily, it doesn&#039;t support code coverage analysis at all. In the other hand, other PHP unit testing products like [http://www.phpunit.de/ PHPUnit], more complex and powerful, have built-in support for that technique, but switching to a new product is out from our current [[Roadmap]] plans.&lt;br /&gt;
&lt;br /&gt;
So, after some readings and comparisons, Moodle will implement its own extensions to SimpleTest, in order to fulfil the main goal of having statement/line code coverage analysis working under Moodle 2.0 onwards. To achieve this, also [http://developer.spikesource.com/projects/phpcoverage Spike PHPCoverage], a basic code-coverage tool, will be used and extended. You can find the details of the implementation of this tool at MDL-19579.&lt;br /&gt;
&lt;br /&gt;
=== Changes ===&lt;br /&gt;
&lt;br /&gt;
To enable code coverage in your tests, only a few modifications need to be performed to your current code:&lt;br /&gt;
&lt;br /&gt;
# Change your test classes by adding two (public static) attributes: &#039;&#039;&#039;$includecoverage&#039;&#039;&#039; and &#039;&#039;&#039;$excludecoverage&#039;&#039;&#039;, both arrays, being used to inform to the code coverage tool (via reflection) about which source code files and dirs must be covered/skipped by the analysis.&lt;br /&gt;
# Use &#039;&#039;&#039;[http://cvs.moodle.org/moodle/lib/simpletestcoveragelib.php?view=markup simpletestcoveragelib.php]&#039;&#039;&#039; instead of simpletestlib.php in your caller scripts.&lt;br /&gt;
# Use the &#039;&#039;&#039;autogroup_test_coverage&#039;&#039;&#039; class instead of the AutoGroupTest one (see below for details) in your caller scripts.&lt;br /&gt;
&lt;br /&gt;
(note that only the 1st point above is needed for new unit tests being created because both 2 and 3 (changes in caller scripts) are already implemented in Moodle and awaiting your cool unit tests.&lt;br /&gt;
&lt;br /&gt;
That&#039;s all! With those 3 basic changes, you will end with a complete code coverage report available for further analysis.&lt;br /&gt;
&lt;br /&gt;
=== API ===&lt;br /&gt;
&lt;br /&gt;
When using code coverage within Moodle there are two alternative APIs available, both providing the same code coverage reports at the end, but doing that in a different way. Here they are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Internal (hidden) coverage API&#039;&#039;&#039;: This API is completely hidden beyond the Unit testing API and you won&#039;t need to know the details about it. Just perform the 1-2-3 changes described above and, after running the tests you&#039;ll get the final report available for being used immediately, without needing to perform anything in your code. His major drawback: it only can perform &#039;&#039;&#039;one&#039;&#039;&#039; &amp;quot;code coverage session&amp;quot; (a.k.a. instrumentation), so it&#039;s only suitable for testing scripts using only one unit test execution. One example of this type of unit testing is  [http://cvs.moodle.org/moodle/admin/report/unittest/index.php?view=markup admin/report/unittest/index.php] where only one (big) test-group is executed.&lt;br /&gt;
* &#039;&#039;&#039;External (explicit) coverage API&#039;&#039;&#039;: This API needs extra coding as long as coverage instantiating, configuration and report generation happens in the main script. It&#039;s a bit more complex but, in the other hand, it support &#039;&#039;&#039;multiple&#039;&#039;&#039; instrumentations to be performed, and gives you more control about the code coverage process.  One example of this type of unit testing is  [http://cvs.moodle.org/moodle/admin/report/unittest/dbtest.php?view=markup admin/report/unittest/dbtest.php] where multiple (one for each DB being tested) test-group are executed.&lt;br /&gt;
&lt;br /&gt;
So, first of all (point 1 in prev section - usage), we need to define, for each unit test, which files / directories (relative to dirroot) we want to analyse with the tool. Here it&#039;s one example, for the &#039;&#039;&#039;dml_test&#039;&#039;&#039; unit test ([http://cvs.moodle.org/moodle/lib/dml/simpletest/testdml.php?view=markup /lib/dml/simpletest/testdml.php]), all we need to add to these lines to the class declaration :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
public  static $includecoverage = array(&#039;lib/dml&#039;);&lt;br /&gt;
public  static $excludecoverage = array(&#039;lib/dml/somedir&#039;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By doing so, the code coverage tool will know which are the target files to perform coverage analysis/reporting and will do that for all the files (recursively) in the &#039;&#039;lib/dml&#039;&#039;&#039; dir but excluding the &#039;&#039;lib/dml/somedir&#039;&#039; directory (recursively too). Note that both attributes are arrays so multiple paths can be specified in any of them. Also note that the dir where the UnitTest is stored is automatically excluded (usually &#039;&#039;simpletest&#039;&#039; dirs).&lt;br /&gt;
&lt;br /&gt;
And, as said, that&#039;s all you need to fulfil in order to get current/new unit tests being analysed by the code coverage tool by current Moodle scripts. The documentation below is only interesting for developers wanting to create new scripts able to perform unit testing with code coverage (points 2 and 3 in prev section - usage).&lt;br /&gt;
&lt;br /&gt;
==== Internal coverage API ====&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$test = new autogroup_test_coverage($showsearch, $test_name, $performcoverage, $coveragename, $coveragedir);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Create one new autogroup test object with code coverage support, there you can specify if you want to perform coverage (true/false), the name of the report (title) and the directory where the final report will be created (under moodledata/codecoverage). &lt;br /&gt;
Optionally you can add more files and directories (relative to dirroot) to the list of files to be covered / ignored by using these functions (in case the defined in point 1 aren&#039;t enough).&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$test-&amp;gt;add_coverage_include_path($path);&lt;br /&gt;
$test-&amp;gt;add_coverage_exclude_path($path);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
And then, affter adding a bunch of unit tests to the group, you simply invoke the test execution with code coverage support to end with a nice code coverage report under &#039;&#039;dataroot/codecoverage/$coveragedir&#039;&#039;:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$test-&amp;gt;run($unit_test_reporter);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
(don&#039;t forget that this API supports only &#039;&#039;&#039;one&#039;&#039;&#039; instrumentation to be performed)&lt;br /&gt;
&lt;br /&gt;
And that&#039;s all!&lt;br /&gt;
&lt;br /&gt;
==== External coverage API ====&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$covreporter = new moodle_coverage_reporter($coveragename, $coveragedir);&lt;br /&gt;
$covrecorder = new moodle_coverage_recorder($covreporter);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Create one coverage reporter, by passing its title and output directory as parameters.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$test = new autogroup_test_coverage($showsearch, $test_name, $performcoverage);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Create one new autogroup test object with code coverage support, you don&#039;t need to specify the title and dir here (as already have been defined by the moodle_coverage_reporter object).&lt;br /&gt;
Optionally you can add more files and directories (relative to dirroot) to the list of files to be covered / ignored by using these functions (in case the defined in point 1 aren&#039;t enough).&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$test-&amp;gt;add_coverage_include_path($path);&lt;br /&gt;
$test-&amp;gt;add_coverage_exclude_path($path);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Then, after adding a bunch of unit tests to the group, you simply invoke the test execution with code coverage support with:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$test-&amp;gt;run_with_external_coverage($unit_test_reporter, $covrecorder);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
(don&#039;t forget that this API supports &#039;&#039;&#039;multiple&#039;&#039;&#039; instrumentations to be performed)&lt;br /&gt;
&lt;br /&gt;
And finally, you generate the code coverage report (under &#039;&#039;dataroot/codecoverage/$coveragedir&#039;&#039;) using:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$covrecorder-&amp;gt;generate_report();&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Once more, that&#039;s all!&lt;br /&gt;
&lt;br /&gt;
==== Final notes ====&lt;br /&gt;
* Note that there are some more methods available in the moodle_coverage_recorder class. They will allow to control starting/stopping instrumentations by hand and other minor things but they shouldn&#039;t really be used. The run() and run_with_external_coverage() methods should be enough in 99% of cases.&lt;br /&gt;
* Not being part of the API, but used by it, there is one &#039;&#039;&#039;[http://cvs.moodle.org/moodle/admin/report/unittest/coveragefile.php?view=markup overagefile.php]&#039;&#039;&#039; script under &#039;&#039;admin/report/unittest&#039;&#039; responsible for serving the coverage report files from within Moodle. See current scripts in that dir to see how can be used.&lt;br /&gt;
* All the test execution / reporting / coverage utilities must be protected with the &#039;moodle/site:config&#039; permission.&lt;br /&gt;
&lt;br /&gt;
== A warning ==&lt;br /&gt;
&lt;br /&gt;
In &#039;xUnit Test Patterns&#039; there is a [http://xunitpatterns.com/TestAutomationRoadmap.html scale of testing difficulty] that goes from 1. to 6. Moodle is definitely at number 6. on that scale &#039;Non-object-oriented legacy software&#039;. It then goes recommend that you don&#039;t start to learn about unit testing with that sort of software :-(&lt;br /&gt;
&lt;br /&gt;
== Further reading about unit testing ==&lt;br /&gt;
&lt;br /&gt;
[http://manning.com/reiersol/ PHP in Action] has an excellent chapter explaining unit testing in PHP with &#039;&#039;simpletest&#039;&#039;. (Although the rest of that book advocates a style of programming that is very different from the style used in Moodle.)&lt;br /&gt;
&lt;br /&gt;
[http://www.pragprog.com/titles/utj/pragmatic-unit-testing-in-java-with-junit Pragmatic Unit Testing in Java with JUnit] is also a very good introduction, despite being in the wrong programming language. JUnit and Simpletest are very similar.&lt;br /&gt;
&lt;br /&gt;
[http://xunitpatterns.com/ xUnit Test Patterns] is the ultimate unit test book. I think it teaches you everything you could learn about unit testing by reading a book. The only way to learn more would be years of experience. It has really great advice for dealing with the kind of messy problems you get in a big, real project like Moodle. &lt;br /&gt;
&lt;br /&gt;
{{CategoryDeveloper}}&lt;br /&gt;
[[Category:Quality Assurance]]&lt;/div&gt;</summary>
		<author><name>Maherne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=User:Michael_Aherne&amp;diff=39425</id>
		<title>User:Michael Aherne</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=User:Michael_Aherne&amp;diff=39425"/>
		<updated>2008-07-11T11:26:44Z</updated>

		<summary type="html">&lt;p&gt;Maherne: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Software Developer,&lt;br /&gt;
VLE Team,&lt;br /&gt;
University of Strathclyde,&lt;br /&gt;
Glasgow, Scotland&lt;br /&gt;
&lt;br /&gt;
michael.aherne@strath.ac.uk&lt;/div&gt;</summary>
		<author><name>Maherne</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=User:Michael_Aherne&amp;diff=39424</id>
		<title>User:Michael Aherne</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=User:Michael_Aherne&amp;diff=39424"/>
		<updated>2008-07-11T11:26:25Z</updated>

		<summary type="html">&lt;p&gt;Maherne: New page: Software Developer VLE Team University of Strathclyde Glasgow, Scotland  michael.aherne@strath.ac.uk&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Software Developer&lt;br /&gt;
VLE Team&lt;br /&gt;
University of Strathclyde&lt;br /&gt;
Glasgow, Scotland&lt;br /&gt;
&lt;br /&gt;
michael.aherne@strath.ac.uk&lt;/div&gt;</summary>
		<author><name>Maherne</name></author>
	</entry>
</feed>