<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/403/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Davidbalch</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/403/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Davidbalch"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/Special:Contributions/Davidbalch"/>
	<updated>2026-05-17T02:21:09Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=Site_backup&amp;diff=133339</id>
		<title>Site backup</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=Site_backup&amp;diff=133339"/>
		<updated>2019-03-15T10:59:02Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: Add mention of making sure backups are consistent.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Backup}}&lt;br /&gt;
A site backup allows a site administrator to save everything associated with a moodle site. These backups can be restored to bring a site back to the point in time when the backup was made.  &lt;br /&gt;
&lt;br /&gt;
Performing regular backups are highly recommended to reduce the amount of lost information in the event of a problem on the site and to speed the overall recovery process.&lt;br /&gt;
&lt;br /&gt;
== What needs to be backed up? ==&lt;br /&gt;
&lt;br /&gt;
A Moodle system comprises three parts:&lt;br /&gt;
# The data stored in the database (For example, a MySQL database)&lt;br /&gt;
# The uploaded files (For example, site and course files uploaded via Moodle located in moodledata)&lt;br /&gt;
# The &#039;&#039;&#039;Moodle code&#039;&#039;&#039; (For example, everything in server/htdocs/moodle)&lt;br /&gt;
You can confirm where all these things are located in a Moodle installation by checking the &#039;&#039;&#039;[[Configuration file|config.php]]&#039;&#039;&#039; file. &lt;br /&gt;
&lt;br /&gt;
:# &#039;&#039;&#039;$CFG-&amp;gt;dbname&#039;&#039;&#039; shows the database name&lt;br /&gt;
:# &#039;&#039;&#039;$CFG-&amp;gt;prefix&#039;&#039;&#039; shows the the database table name prefix&lt;br /&gt;
:# &#039;&#039;&#039;$CFG-&amp;gt;dataroot&#039;&#039;&#039; controls where the &#039;&#039;uploaded files&#039;&#039; are stored; and&lt;br /&gt;
:# &#039;&#039;&#039;$CFG-&amp;gt;wwwroot&#039;&#039;&#039; points to where the &#039;&#039;code&#039;&#039; is stored.&lt;br /&gt;
&lt;br /&gt;
;Tip &lt;br /&gt;
Generally speaking, the database (&amp;quot;dbname and prefix&amp;quot;) and the uploaded files (dataroot) are the two most important to copy on a regular basis. These contain information that will change most often. &lt;br /&gt;
&lt;br /&gt;
The Moodle code (wwwroot) is less important as a frequent backup, since it will only change when the the actual code is changed through upgrades, addins and code tweaks. You can always get a copy of the standard Moodle code from http://download.moodle.org so you only have to backup the parts you added or changed yourself.&lt;br /&gt;
&lt;br /&gt;
== Creating a backup of your Moodle site ==&lt;br /&gt;
&lt;br /&gt;
=== Database ===&lt;br /&gt;
&lt;br /&gt;
The right way to back up your database depends on which database system you are using. The instructions below are one way to back up a MySQL database. Another option would be to use a tool like phpMyAdmin to manually make a backup. The documentation for your database will give more options.&lt;br /&gt;
&lt;br /&gt;
There are many ways to do such backups. Here is an outline of a little script you can run on Unix to backup the database (it works well to have such a script run daily via a cron task):&lt;br /&gt;
&lt;br /&gt;
 cd /my/backup/directory&lt;br /&gt;
 mv moodle-database.sql.gz moodle-database-old.sql.gz&lt;br /&gt;
 mysqldump -h example.com -u myusername --password=mypassword -C -Q -e --create-options mydatabasename &amp;gt; moodle-database.sql&lt;br /&gt;
 gzip moodle-database.sql&lt;br /&gt;
&lt;br /&gt;
Also consider using an option to help ensure that the backup is consistent (e.g. avoid the data changing half-way through the backup), e.g. for MySQL/MariaDB and mysqldump try  [https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#option_mysqldump_single-transaction --single-transaction].&lt;br /&gt;
&lt;br /&gt;
==== Character encoding ====&lt;br /&gt;
Make sure that a database backup uses the correct character encoding. In most databases, use [[UTF-8]].&lt;br /&gt;
&lt;br /&gt;
When dumping the entire Moodle database, check for possible character encoding issues. In some instances, backups created with [http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html mysqldump] or [http://www.phpmyadmin.net phpMyAdmin] may not properly encode all of the data.  This will result in non-readable characters when the database is restored. &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;Tip&#039;&#039;: One solution is to use MySQL Administrator 1.1 or another tool that will force a UTF-8 dump of the data.&lt;br /&gt;
&lt;br /&gt;
==== Tools for database backups ====&lt;br /&gt;
&lt;br /&gt;
; phpMyAdmin&lt;br /&gt;
: [http://www.phpmyadmin.net phpMyAdmin] is the tool of choice with most web hosting providers.&lt;br /&gt;
&lt;br /&gt;
; MySQLDumper&lt;br /&gt;
: [http://www.mysqldumper.de/en/ MySQLDumper] is a backup script for MySQL databases, written in PHP and Perl. MySQLDumper uses a proprietary technique to avoid execution interruption when running PHP scripts (the max. execution time is usually set to 30 seconds). MySQLDumper also cares for the encoding problems mentioned above. It also works with compressed files and allows setting up regular cron jobs for updating and updating to a remote FTP site.&lt;br /&gt;
&lt;br /&gt;
=== Uploaded files (moodledata) ===&lt;br /&gt;
Through the Moodle interface, users can upload or create files and folders.  These are located in a directory, often called &amp;quot;moodledata&amp;quot;. Since they are just files and folders, there are many different ways to backup or copy moodledata.  &lt;br /&gt;
&lt;br /&gt;
* For example, using a file transfer program, copy the entire moodledata directory to a different area, drive or computer.  Example of file transfer programs include: FTP, WinSP, wget, rsync.&lt;br /&gt;
&lt;br /&gt;
* You might use a compression program  to create compact files (tar, zip. 7z, XZ, BZIP2, GZIP, and WIM are a few file formats) of the entire directory.  This can be done before or after file transfers.&lt;br /&gt;
&lt;br /&gt;
; Tips &lt;br /&gt;
* Typically not all moodledata files change between regular/periodic backups. A new Administrator might want to look into [http://en.wikipedia.org/wiki/Incremental_backup incremental or other efficient backups] procedures. &lt;br /&gt;
* Depending upon the operating environment there are many tools for backing up server files and ways of backing up moodledata.  See [[Tools_for_backing_up_server_files]] for tips on using rsync, FTP or Wget.&lt;br /&gt;
&lt;br /&gt;
=== Moodle code ===&lt;br /&gt;
Backing up the Moodle code, will be similar to backing up moodledata. See [[Tools for backing up server files]].&lt;br /&gt;
&lt;br /&gt;
;Tip&lt;br /&gt;
It is always a good idea to have several backup copies of your Moodle code files.  While you can always download a fresh base copy of the Moodle code from http://download.moodle.org, you might have customized that code. It is a good idea to create a separate backup of your Moodle code before you customize the code.  This includes installing [[Contributed code]], [[Themes]] and upgrading.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [https://www.youtube.com/watch?v=k5rwTy3sNh0 Screencast: How to back up a Moodle site] (thanks to Bruce Chambr)&lt;br /&gt;
*[[Site restore]] Now that you have a backup, how to restore it&lt;br /&gt;
* [[Moodle migration]] - move a Moodle site to a different server&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/discuss.php?d=140949 Site DatabaseBackup Using phpMyAdmin] forum discussion&lt;br /&gt;
* [[Site Backup for Low-tech Users]]&lt;br /&gt;
&lt;br /&gt;
[[de:Sicherung der Moodle-Installation]]&lt;br /&gt;
[[ja:サイトバックアップ]]&lt;br /&gt;
[[es:Copia de seguridad del sitio]]&lt;br /&gt;
[[fr:Sauvegarde de site]]&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=Calendar_block&amp;diff=131600</id>
		<title>Calendar block</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=Calendar_block&amp;diff=131600"/>
		<updated>2018-08-02T15:30:21Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Blocks}}&lt;br /&gt;
The &#039;&#039;&#039;Calendar&#039;&#039;&#039; block displays the following events:&lt;br /&gt;
* Site (event viewable in all courses - created by admin users)&lt;br /&gt;
* &#039;&#039;&#039;New in 3.4:&#039;&#039;&#039; Category&lt;br /&gt;
* Course (event viewable only to course members - created by teachers)&lt;br /&gt;
* Groups (event viewable only by members of a group - created by teachers)&lt;br /&gt;
* User (personal event a student user can create - viewable only by the user)&lt;br /&gt;
&lt;br /&gt;
[[File:newcalendar.png]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Calendar]]&lt;br /&gt;
&lt;br /&gt;
[[de:Kalender-Block]]&lt;br /&gt;
[[eu:Egutegia_blokea]]&lt;br /&gt;
[[fr:Bloc Calendrier]]&lt;br /&gt;
[[es:Bloque del calendario]]&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=LDAP_authentication&amp;diff=129453</id>
		<title>LDAP authentication</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=LDAP_authentication&amp;diff=129453"/>
		<updated>2017-11-20T09:46:18Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: Change &amp;quot;Creators&amp;quot; role assignment to more flexible &amp;quot;System role mapping&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Authentication}}&lt;br /&gt;
This document describes how to set up Lightweight Directory Access Protocol (LDAP) authentication in Moodle.  We cover the basic, advanced and some trouble shooting sections to assist the user in the installation and administrating LDAP in Moodle.  &lt;br /&gt;
&lt;br /&gt;
==Basic Scenario==&lt;br /&gt;
The simple and straightforward approach  for most installations.&lt;br /&gt;
&lt;br /&gt;
===Assumptions===&lt;br /&gt;
&lt;br /&gt;
# Your Moodle site is located at &#039;&#039;&#039;http://your.moodle.site/&#039;&#039;&#039;&lt;br /&gt;
# You have configured your PHP installation with the LDAP extension. It is loaded and activated, and it shows when you go to &#039;&#039;&#039;http://your.moodle.site/admin/phpinfo.php&#039;&#039;&#039; (logged in as user &#039;admin&#039;).&lt;br /&gt;
# Your LDAP server has &#039;&#039;&#039;192.168.1.100&#039;&#039;&#039; as its IP address.&lt;br /&gt;
# You are not using LDAP with SSL (also known as LDAPS) in your settings. This might prevent certain operations from working (e.g., you cannot update data if you are using MS Active Directory -- MS-AD from here on --), but should be OK if you just want to authenticate your users.&lt;br /&gt;
# You don&#039;t want your users to change their passwords the first time they log in into Moodle.&lt;br /&gt;
# You are using a single domain as the source of your authentication data in case you are using MS-AD (more on this in the Appendices).&lt;br /&gt;
# You are using a top level distinguished name (DN) of &#039;&#039;&#039;dc=my,dc=organization,dc=domain&#039;&#039;&#039; as the root of your LDAP tree. &lt;br /&gt;
# You have a non-privileged LDAP user account you will use to bind to the LDAP server. This is not necessary with certain LDAP servers, but MS-AD requires this and it won&#039;t hurt if you use it even if your LDAP server doesn&#039;t need it. Make sure &#039;&#039;&#039;this account and its password don&#039;t expire&#039;&#039;&#039;, and make this password as strong as possible. Remember you only need to type this password once, when configuring Moodle, so don&#039;t be afraid of making it as hard to guess as possible. Let&#039;s say this user account has a DN of &#039;&#039;&#039;cn=ldap-user,dc=my,dc=organization,dc=domain&#039;&#039;&#039;, and password &#039;&#039;&#039;hardtoguesspassword&#039;&#039;&#039;.&lt;br /&gt;
# All of your Moodle users are in an organizational unit (OU) called &#039;&#039;&#039;moodleusers&#039;&#039;&#039;, which is right under your LDAP root. That OU has a DN of &#039;&#039;&#039;ou=moodleusers,dc=my,dc=organization,dc=domain&#039;&#039;&#039;.&lt;br /&gt;
# You &#039;&#039;&#039;don&#039;t&#039;&#039;&#039; want your LDAP users&#039; passwords to be stored in Moodle at all.&lt;br /&gt;
&lt;br /&gt;
===Enabling LDAP authentication===&lt;br /&gt;
&lt;br /&gt;
An administrator can enable LDAP authentication as follows:&lt;br /&gt;
&lt;br /&gt;
# Go to &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039; and click the eye icon opposite LDAP Server. When enabled, it will no longer be greyed out.&lt;br /&gt;
# Click the settings link, configure as required (see information below), then click the &#039;Save changes&#039; button.&lt;br /&gt;
&lt;br /&gt;
[[Image:LDAPserversettings.png|center]]&lt;br /&gt;
&lt;br /&gt;
Now, you just have to fill in the values. Let&#039;s go step by step.&lt;br /&gt;
&lt;br /&gt;
====LDAP Server Settings====&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
! Field name&lt;br /&gt;
! Value to fill in&lt;br /&gt;
|-&lt;br /&gt;
| Host URL&lt;br /&gt;
| As the IP of your LDAP server is 192.168.1.100, type &amp;quot;&#039;&#039;&#039;ldap://192.168.1.100&#039;&#039;&#039;&amp;quot; (without the quotes), or just &amp;quot;&#039;&#039;&#039;192.168.1.100&#039;&#039;&#039;&amp;quot; (some people have trouble connecting with the first syntax, specially on MS Windows servers).&lt;br /&gt;
|-&lt;br /&gt;
| Version&lt;br /&gt;
| Unless you are using a really old LDAP server, &#039;&#039;&#039;version 3&#039;&#039;&#039; is the one you should choose.&lt;br /&gt;
|-&lt;br /&gt;
| LDAP Encoding&lt;br /&gt;
| Specify encoding used by LDAP server. Most probably utf-8.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[LDAP_authentication#Table of Contents|Table of Contents]]&lt;br /&gt;
&lt;br /&gt;
====Bind settings====&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
! Field name&lt;br /&gt;
! Value to fill in&lt;br /&gt;
|-&lt;br /&gt;
| Don&#039;t cache passwords&lt;br /&gt;
| As you &#039;&#039;&#039;don&#039;t&#039;&#039;&#039; want to store the users&#039;s password in Moodle&#039;s database, choose &#039;&#039;&#039;Yes&#039;&#039;&#039; here.&lt;br /&gt;
|-&lt;br /&gt;
| Distinguished Name&lt;br /&gt;
| This is the distinguished name of the bind user defined above. Just type &amp;quot;&#039;&#039;&#039;cn=ldap-user,dc=my,dc=organization,dc=domain&#039;&#039;&#039;&amp;quot; (without the quotes).&lt;br /&gt;
|-&lt;br /&gt;
| Password&lt;br /&gt;
| This is the bind user password defined above. Type &amp;quot;&#039;&#039;&#039;hardtoguesspassword&#039;&#039;&#039;&amp;quot; (without the quotes).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[LDAP_authentication#Table of Contents|Table of Contents]]&lt;br /&gt;
&lt;br /&gt;
====User lookup settings====&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
! Field name&lt;br /&gt;
! Value to fill in&lt;br /&gt;
|-&lt;br /&gt;
| User type&lt;br /&gt;
| Choose: &lt;br /&gt;
* &#039;&#039;&#039;Novel Edirectory&#039;&#039;&#039; if your LDAP server is running Novell&#039;s eDdirectory.&lt;br /&gt;
* &#039;&#039;&#039;posixAccount (rfc2307)&#039;&#039;&#039; if your LDAP server is running a RFC-2307 compatible LDAP server (choose this is your server is running OpenLDAP, including Mac OS X server).&lt;br /&gt;
* &#039;&#039;&#039;posixAccount (rfc2307bis)&#039;&#039;&#039; if your LDAP server is running a RFC-2307bis compatible LDAP server.&lt;br /&gt;
* &#039;&#039;&#039;sambaSamAccount (v.3.0.7)&#039;&#039;&#039; if your LDAP server is running with SAMBA&#039;s 3.x LDAP schema extension and you want to use it.&lt;br /&gt;
* &#039;&#039;&#039;MS ActiveDirectory&#039;&#039;&#039; if your LDAP server is running Microsoft&#039;s Active Directory (MS-AD)&lt;br /&gt;
|-&lt;br /&gt;
| Contexts&lt;br /&gt;
| The DN of the context (container) where all of your Moodle users are found. Type &#039;&#039;&#039;ou=moodleusers,dc=my,dc=organization,dc=domain&#039;&#039;&#039; here.  &lt;br /&gt;
&lt;br /&gt;
On a Mac OS X Server, this is usually &#039;&#039;&#039;cn=users,dc=my,dc=organization,dc=domain&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| Search subcontexts&lt;br /&gt;
| If you have any sub organizational units (subcontexts) hanging from &#039;&#039;&#039;ou=moodleusers,dc=my,dc=organization,dc=domain&#039;&#039;&#039; and you want Moodle to search there too, set this to &#039;&#039;&#039;yes&#039;&#039;&#039;. Otherwise, set this to &#039;&#039;&#039;no&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| Dereference aliases&lt;br /&gt;
| Sometimes your LDAP server will tell you that the real value you are searching for is in fact in another part of the LDAP tree (this is called an alias). If you want Moodle to &#039;dereference&#039; the alias and fetch the real value from the original location, set this to &#039;&#039;&#039;yes&#039;&#039;&#039;. If you don&#039;t want Moodle to dereference it, set this to &#039;&#039;&#039;no&#039;&#039;&#039;. If you are using MS-AD, set this to &#039;&#039;&#039;no&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| User attribute&lt;br /&gt;
| The attribute used to name/search users in your LDAP tree. This option takes a default value based on the &#039;&#039;User type&#039;&#039; value you chose above. &amp;lt;u&amp;gt;So unless you need something special, you don&#039;t need to fill this in&amp;lt;/u&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
By the way, it&#039;s usually &#039;&#039;&#039;cn&#039;&#039;&#039; (Novell eDirectory and MS-AD) or &#039;&#039;&#039;uid&#039;&#039;&#039; (RFC-2037, RFC-2037bis and SAMBA 3.x LDAP extension), but if you are using MS-AD you could (and have to, if you intend to use NTLM SSO) use &#039;&#039;&#039;sAMAccountName&#039;&#039;&#039; (the pre-Windows 2000 logon account name) if you need too.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Correction&#039;&#039;&#039;: With MS-AD &#039;&#039;&#039;sAMAccountName&#039;&#039;&#039; should be used anyway. With default value (&#039;&#039;&#039;cn&#039;&#039;&#039;) AD users will have to login with full name / password (Username: &#039;&#039;&#039;John Doe&#039;&#039;&#039;, Password: &#039;&#039;&#039;john&#039;s_pass&#039;&#039;&#039;). If you want to enable your users to login with domain username instead (Username: &#039;&#039;&#039;johnd&#039;&#039;&#039; Password: &#039;&#039;&#039;john&#039;s_pass&#039;&#039;&#039;), you should use &#039;&#039;&#039;sAMAccountName&#039;&#039;&#039;. Sadly, but logging in with DOMAIN\user or user@domain.com will not work anyway.&lt;br /&gt;
&lt;br /&gt;
Note: You may wish to consider allowing extended characters in usernames in &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Security &amp;gt; [[Site policies]]&#039;&#039;. &lt;br /&gt;
|-&lt;br /&gt;
| Member attribute&lt;br /&gt;
| The attribute used to list the members of a given group. This option takes a default value based on the &#039;&#039;User type&#039;&#039; value you choosed above. &amp;lt;u&amp;gt;So unless you need something special, you don&#039;t need to fill this in.&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By the way, the usual values are &#039;&#039;&#039;member&#039;&#039;&#039; and &#039;&#039;&#039;memberUid&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| Member attribute uses dn&lt;br /&gt;
| Whether the member attribute contains distinguished names (1) or not (0).This option takes a default value based on the &#039;&#039;User type&#039;&#039; value you choosed above. &amp;lt;u&amp;gt;So unless you need something special, you don&#039;t need to fill this in.&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Object class&lt;br /&gt;
| The type of LDAP object used to search for users. This option takes a default value based on the &#039;&#039;User type&#039;&#039; value you chose above. &amp;lt;u&amp;gt;So unless you need something special, you don&#039;t need to fill this in.&amp;lt;/u&amp;gt;&lt;br /&gt;
* If you leave it blank, the default value based on the &#039;&#039;User type&#039;&#039; selected above will be used (see below)&lt;br /&gt;
* If you provide &amp;quot;objectClass=some-string&amp;quot;, then it will provide &amp;quot;(objectClass=some-string)&amp;quot; as the filter.&lt;br /&gt;
* If you provide a value that does not start with &amp;quot;(&amp;quot;, it is assumed to be a value that should be set to &amp;quot;objectClass&amp;quot;. So if you provide &amp;quot;some-string&amp;quot;, then it will provide &amp;quot;(objectClass=some-string)&amp;quot; as the filter.&lt;br /&gt;
* If you provide a string that starts with a &amp;quot;(&amp;quot;, then it will pass that as is. So if you provide &amp;quot;(&amp;amp;(objectClass=user)(enabledMoodleUser=1))&amp;quot;, then it will pass that as the filter.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: In the last case, that feature can be used on interactive logins,&lt;br /&gt;
&lt;br /&gt;
Here are the default values for each of the &#039;&#039;ldap_user_type&#039;&#039; values:&lt;br /&gt;
* &#039;&#039;&#039;(objectClass=user)&#039;&#039;&#039; for Novel eDirectory&lt;br /&gt;
* &#039;&#039;&#039;(objectClass=posixAccount)&#039;&#039;&#039; for RFC-2037 and RFC-2037bis&lt;br /&gt;
* &#039;&#039;&#039;(objectClass=sambaSamAccount)&#039;&#039;&#039; for SAMBA 3.0.x LDAP extension&lt;br /&gt;
* &#039;&#039;&#039;(objectClass=user)&#039;&#039;&#039; for MS-AD&lt;br /&gt;
* &#039;&#039;&#039;(objectClass=*)&#039;&#039;&#039; for Default&lt;br /&gt;
If you get an error about a problem with updating the ldap server (even if you have specified not to write changes back to the ldap server) try setting the ldap object class to * - see http://moodle.org/mod/forum/discuss.php?d=70566 for a discussion on this problem&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Force change password====&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
! Field name&lt;br /&gt;
! Value to fill in&lt;br /&gt;
|-&lt;br /&gt;
| Force change password&lt;br /&gt;
| &#039;&#039;&#039;NOTE: This setting is only used when creating your users with the LDAP sync users task. It&#039;s not used if your users are created as part of their first login to moodle&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Set this to &#039;&#039;Yes&#039;&#039; if you want to force your users to change their password on the first login into Moodle. Otherwise, set this to &#039;&#039;no&#039;&#039;. Bear in mind the password they are forced to change is the one stored in your LDAP server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;As you don&#039;t want your users to change their passwords in their first login, leave this set to &#039;&#039;No&#039;&#039;&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Use standard Change Password Page&lt;br /&gt;
|&lt;br /&gt;
* Setting this to &#039;&#039;Yes&#039;&#039; makes Moodle use its own standard password change page, everytime users want to change their passwords.&lt;br /&gt;
* Setting this to &#039;&#039;No&#039;&#039; makes Moodle use the the page specified in the field called &amp;quot;Password change URL&amp;quot; (see below).&lt;br /&gt;
&lt;br /&gt;
Bear in mind that changing your LDAP passwords from Moodle might require a LDAPS connection (this is actually a requirement for MS-AD). In addition to that, the bind user specified above must have the rights needed to change other users&#039; passwords.&lt;br /&gt;
&lt;br /&gt;
Also, code for changing passwords from Moodle for anything but Novell eDirectory and Active Directory is almost not tested, so this may or may not work for other LDAP servers.&lt;br /&gt;
|-&lt;br /&gt;
| Password Format&lt;br /&gt;
| Specify how the new password is encrypted before sending it to the LDAP server: Plain text, MD5 hash or SHA-1 hash. MS-AD uses plain text, for example.&lt;br /&gt;
|-&lt;br /&gt;
| Password change URL&lt;br /&gt;
| Here you can specify a location at which your users can recover or change their username/password if they&#039;ve forgotten it. This will be provided to users as a button on the login page and their user page. if you leave this blank the button will not be printed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====LDAP password expiration settings====&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
! Field name&lt;br /&gt;
! Value to fill in&lt;br /&gt;
|-&lt;br /&gt;
| Expiration&lt;br /&gt;
| &lt;br /&gt;
* Setting this to &#039;&#039;No&#039;&#039; will make Moodle not to check if the password of the user has expired or not.&lt;br /&gt;
* Setting this to &#039;&#039;LDAP&#039;&#039; will make Moodle check if the LDAP password of the user has expired or not, and warn them a number of days before the password expires. When the password has expired, a &amp;quot;Your password has expired&amp;quot; message is displayed, and if the user is able to change their password from Moodle, they are offered the option to do so.&lt;br /&gt;
&lt;br /&gt;
Current code only deals with Novell eDirectory LDAP server and MS-AD.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;So unless you have Novell eDirectory server or MS-AD, choose &#039;&#039;No&#039;&#039; here.&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Expiration warning&lt;br /&gt;
| This value sets how many days in advance of password expiration the user is warned that her password is about to expire.&lt;br /&gt;
|-&lt;br /&gt;
| Expiration attribute.&lt;br /&gt;
| The LDAP user attribute used to check password expiration. This option takes a default value based on the &#039;&#039;User type&#039;&#039; value you chose above. &amp;lt;u&amp;gt;So unless you need something special, you don&#039;t need to fill this in.&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Grace logins&lt;br /&gt;
| This setting is specific to Novell eDirectory. If set to &#039;&#039;Yes&#039;&#039;, enable LDAP gracelogin support. After password has expired the user can login until gracelogin count is 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;So unless you have Novell eDirectory server and want to allow gracelogin support, choose &#039;&#039;No&#039;&#039; here.&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Grace login attribute&lt;br /&gt;
| This setting is currently not used in the code (and is specific to Novell eDirectory). &lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;So you don&#039;t need to fill this in.&amp;lt;/u&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Enable user creation====&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
! Field name&lt;br /&gt;
! Value to fill in&lt;br /&gt;
|-&lt;br /&gt;
| Create users externally&lt;br /&gt;
| New (anonymous) users can self-create user accounts on the external LDAP server and confirm them via email. If you enable this, remember to also configure module-specific options for user creation and to fill in some instructions in &#039;&#039;auth_instructions&#039;&#039; field in &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039;. Otherwise the new users won&#039;t be able to self-create new accounts.&lt;br /&gt;
&lt;br /&gt;
Novell eDirectory and MS-AD can create users externally. You can also create users in RFC-2307 compliant servers. &lt;br /&gt;
|-&lt;br /&gt;
| Context for new users&lt;br /&gt;
| Specify the context where users are created. This context should be different from other users&#039; contexts to prevent security issues. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Assign system roles====&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
! Field name&lt;br /&gt;
! Value to fill in&lt;br /&gt;
|-&lt;br /&gt;
| System role mapping&lt;br /&gt;
| This section lists all roles that have can be assigned in the System context - by default this will be &amp;quot;Manager context&amp;quot; and &amp;quot;Course creator context&amp;quot;, but can be customisable in the [[Creating custom roles|role definitions]].&lt;br /&gt;
&lt;br /&gt;
To assign LDAP users to any of the roles, specify the DN containing all users who should be granted that role at the system level.&lt;br /&gt;
&lt;br /&gt;
Thie DN is typically a posixGroup with a &amp;quot;memberUid&amp;quot; attribute for each user you want to be a creator.  If your group is called &#039;&#039;creators&#039;&#039;, type &#039;&#039;&#039;cn=creators,ou=moodleusers,dc=my,dc=organization,dc=domain&#039;&#039;&#039; here.  Each memberUid attribute contains the CN of a user who is authorized to be a creator.  Do not use the user&#039;s full DN (e.g.,  not &#039;&#039;&#039;memberUid: cn=JoeTeacher,ou=moodleusers,dc-my,dc=organizations,dc=domain&#039;&#039;&#039;, but rather &#039;&#039;&#039;memberUid: JoeTeacher&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
In eDirectory, the objectClass for a group is (by default) not &#039;&#039;&#039;posixGroup&#039;&#039;&#039; but &#039;&#039;&#039;groupOfNames,&#039;&#039;&#039; whose member attribute is &#039;&#039;&#039;member,&#039;&#039;&#039; not &#039;&#039;&#039;memberUid,&#039;&#039;&#039; and whose value is the full DN of the user in question.  Although you can probably modify Moodle&#039;s code to use this field, a better solution is just to add a new &#039;&#039;&#039;objectClass&#039;&#039;&#039; attribute of &#039;&#039;&#039;posixGroup&#039;&#039;&#039; to your creators group and put the CNs for each creator in a &#039;&#039;&#039;memberUid&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
In MS Active Directory, you will need to create a security group for your creators to be part of and then add them all. If your ldap context above is &#039;ou=staff,dc=my,dc=org&#039; then your group should then be &#039;cn=creators,ou=staff,dc=my,dc=org&#039;. If some of the users are from other contexts and have been added to the same security group, you&#039;ll have to add these as separate contexts after the first one using the same format.&lt;br /&gt;
&lt;br /&gt;
This section replaces the &amp;quot;Course creator&amp;quot; section found in Moodle 3.3. The upgrade process should migrate any DN specified to the new approach.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====User account syncronisation====&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
! Field name&lt;br /&gt;
! Value to fill in&lt;br /&gt;
|-&lt;br /&gt;
| Removed ext user&lt;br /&gt;
| Specify what to do with internal user account during mass synchronization when user was removed from external source. Only suspended users are automatically revived if they reappear in ext source.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====NTLM SSO====&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
! Field name&lt;br /&gt;
! Value to fill in&lt;br /&gt;
|-&lt;br /&gt;
| Enable&lt;br /&gt;
| If you want to use NTLM SSO (see details at [[NTLM_authentication]]), choose &#039;&#039;Yes&#039;&#039; here. Otherwise, choose &#039;&#039;No&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| Subnet&lt;br /&gt;
| Specify the subnets of the clients that will use NTLM SSO (see details at [[NTLM_authentication]]).&lt;br /&gt;
|-&lt;br /&gt;
| MS IE Fast Path?&lt;br /&gt;
| If all of you clients (or most of them) are using MS Internet Explorer, you can set this option to bypasses certain steps of the SSO login and speed up login times. This only works with MS Internet Explorer, but deals with other browsers in a sensible way (they are automatically sent to the plain login page).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Data Mapping====&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
! Field name&lt;br /&gt;
! Value to fill in&lt;br /&gt;
|-&lt;br /&gt;
| First name&lt;br /&gt;
| The name of the attribute that holds the first name of your users in your LDAP server. This is usually &#039;&#039;&#039;givenName&#039;&#039;&#039; or &#039;&#039;&#039;displayName&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Surname&lt;br /&gt;
| The name of the attribute that holds the surname of your users in your LDAP server. This is usually &#039;&#039;&#039;sn&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Email address&lt;br /&gt;
| The name of the attribute that holds the email address of your users in your LDAP server. This is usually &#039;&#039;&#039;mail&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| City/town&lt;br /&gt;
| The name of the attribute that holds the city/town of your users in your LDAP server. This is usully &#039;&#039;&#039;l&#039;&#039;&#039; (lowercase L) or &#039;&#039;&#039;localityName&#039;&#039;&#039; (not valid in MS-AD).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
| Country&lt;br /&gt;
| The name of the attribute that holds the country of your users in your LDAP server. This is usully &#039;&#039;&#039;c&#039;&#039;&#039; or &#039;&#039;&#039;countryName&#039;&#039;&#039; (not valid in MS-AD).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Language&lt;br /&gt;
| &#039;&#039;&#039;preferredLanguage&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Description&lt;br /&gt;
| &#039;&#039;&#039;description&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Webpage&lt;br /&gt;
| &amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| ID Number&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Institution&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Department&lt;br /&gt;
| The name of the attribute that holds the department name of your users in your LDAP server. This is usully &#039;&#039;&#039;departmentNumber&#039;&#039;&#039; (for posixAccount and maybe eDirectory) or &#039;&#039;&#039;department&#039;&#039;&#039; (for MS-AD).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Phone 1&lt;br /&gt;
| The name of the attribute that holds the telephone number of your users in your LDAP server. This is usually &#039;&#039;&#039;telephoneNumber&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Phone 2&lt;br /&gt;
|  The name of the attribute that holds an additional telephone number of your users in your LDAP server. This can be &#039;&#039;&#039;homePhone&#039;&#039;&#039;, &#039;&#039;&#039;mobile&#039;&#039;&#039;, &#039;&#039;&#039;pager&#039;&#039;&#039;, &#039;&#039;&#039;facsimileTelephoneNumber&#039;&#039;&#039; or even others.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Address&lt;br /&gt;
| The name of the attribute that holds the street address of your users in your LDAP server. This is usully &#039;&#039;&#039;streetAddress&#039;&#039;&#039; or &#039;&#039;&#039;street&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=====Custom User profile fields=====&lt;br /&gt;
&lt;br /&gt;
Any user profile fields created in &#039;&#039;Site administration &amp;gt; Users &amp;gt; Accounts &amp;gt; User profile fields&#039;&#039; should now automatically show up at the end of the Data mapping field list after the &#039;&#039;&#039;Address&#039;&#039;&#039; field. See example: [[File:ldapcustomuserprofilefields.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Enabling the LDAP users sync job==&lt;br /&gt;
&lt;br /&gt;
The LDAP users sync job (&#039;&#039;\auth_ldap\task\sync_task&#039;&#039;) [[Scheduled tasks|scheduled task]] (new in Moodle 3.0; previously there was a CLI script, see MDL-51824 for more info)  is responsible for creating and updating user information, and suspending and deleting LDAP accounts. &lt;br /&gt;
&lt;br /&gt;
After enabling LDAP server authentication, an administrator need to enable and configure the LDAP users sync job as follows:&lt;br /&gt;
&lt;br /&gt;
# Go to &#039;&#039;Site administration &amp;gt; Server &amp;gt; Scheduled tasks&#039;&#039; and click the gear icon opposite LDAP users sync job.&lt;br /&gt;
# Select the desired frequency of running and enable the task by un-ticking the disabled checkbox.&lt;br /&gt;
{{Warning|It is important to make sure that all LDAP settings are working properly before enabling the LDAP users sync job (as well as backing up your database and moodledata folders), since incorrect LDAP configuration can result in users being wrongly deleted!}}&lt;br /&gt;
&lt;br /&gt;
If you find that the script is not running through all of your users properly and you have over 1000 users in each LDAP container, this is because by default some LDAP stores such as MS AD only send back 1000 users at a time and PHP versions prior to 5.4 did not implement paged support for LDAP results. If you upgrade to PHP 5.4 or higher then Moodle will obtain all your users correctly. If you can&#039;t upgrade to PHP 5.4 you may be able to follow the instructions in http://support.microsoft.com/kb/315071 to set the Active Directory MaxPageSize setting to a number higher than your total number of users (both now and in future) to fix it. This is a forest-wide setting.&lt;br /&gt;
&lt;br /&gt;
==Active Directory help==&lt;br /&gt;
[[Active Directory]] is Microsoft&#039;s directory service. It is included in Windows 2000 Server and later versions of their operating system. For more information about subjects below, &#039;&#039;&#039;[[Active Directory|please go here]]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
*Warning: The PHP LDAP module does not seem to be present&lt;br /&gt;
*LDAP-module cannot connect any LDAP servers &lt;br /&gt;
*Getting correct CNs for Contexts and Creators&lt;br /&gt;
*Getting the right user_attribute&lt;br /&gt;
*Installing ldp.exe Server Tool&lt;br /&gt;
*Example Active Directory Configuration&lt;br /&gt;
*Child Domains and the Global Catalog in MS Active Directory&lt;br /&gt;
*Enabling the Global Catalog&lt;br /&gt;
*Active Directory with Moodle 1.8&lt;br /&gt;
*MS Active Directory + SSL&lt;br /&gt;
&lt;br /&gt;
==Advanced Scenarios - Multiple servers or locations==&lt;br /&gt;
For larger installations with  multiple LDAP servers, or multiple locations (contexts) in a LDAP tree.&lt;br /&gt;
&lt;br /&gt;
===Making your LDAP directory connection resilient===&lt;br /&gt;
* Entering more than one name in the ldap_host_url field can provide some sort of resilience to your system. Simply use the syntax:&lt;br /&gt;
&lt;br /&gt;
 ldap://my.first.server; ldap://my.second.server; ...&lt;br /&gt;
&lt;br /&gt;
Of course, this will only work if all the servers share the same directory information, if using eDirectory you would need to ensure your servers have viability of all relevant tree partitions, or if using Active Directory the servers are holding the same information you need though replication - see notes on a multi-domain environment if this applies.&lt;br /&gt;
&lt;br /&gt;
There is one drawback in Moodle 1.5 - 1.6 implementation of LDAP authentication : the auth_ldap_connect() function processes the servers sequentially, not in a round robin mode. Thus, if the primary server fails, you will have to wait for the connection to time out before switching to the following one.&lt;br /&gt;
&lt;br /&gt;
See also: [http://moodle.org/mod/forum/discuss.php?d=17198 Using multiple LDAP servers - Our students are on separate domain] forum discussion&lt;br /&gt;
&lt;br /&gt;
===Using a multi-domain AD environment===&lt;br /&gt;
* If you&#039;re running Active Directory with multiple domains and you have users in more then one domain you will want to configure Moodle to look at your Global Catalog server. Specifically your top level domain Global Catalog server. Here is a simple example of this kind of Active Directory layout:&lt;br /&gt;
&lt;br /&gt;
 my.domain.ca (Root AD Domain)&lt;br /&gt;
 | - dc1.my.domain.ca (Domain Controller)&lt;br /&gt;
 | - dc2.my.domain.ca (Domain Controller)&lt;br /&gt;
 |&lt;br /&gt;
 | - - students.my.domain.ca (Sub AD Domain)&lt;br /&gt;
 | - - - dc1.students.my.domain.ca (Domain Controller)&lt;br /&gt;
 | - - - dc2.students.my.domain.ca (Domain Controller)&lt;br /&gt;
 |&lt;br /&gt;
 | - - faculty.my.domain.ca (Sub AD Domain)&lt;br /&gt;
 | - - - dc1.faculty.my.domain.ca (Domain Controller)&lt;br /&gt;
 | - - - dc2.faculty.my.domain.ca (Domain Controller)&lt;br /&gt;
 &lt;br /&gt;
In this example we have our top level domain (my.domain.ca) and two sub-domains. One sub-domain is for faculty accounts (faculty.my.domain.ca) and the other is for student accounts (students.my.domain.ca). Listed under each of those are two domain controllers.&lt;br /&gt;
&lt;br /&gt;
Using the above example you&#039;ll want to use the following for accessing the Global Catalog over SSL:&lt;br /&gt;
&lt;br /&gt;
 ldaps://my.domain.ca:3269/&lt;br /&gt;
&lt;br /&gt;
If you prefer to access your global catalog over a non-SSL connection you&#039;ll want to use:&lt;br /&gt;
&lt;br /&gt;
 ldap://my.domain.ca:3268/&lt;br /&gt;
 &lt;br /&gt;
We found if you didn&#039;t configure things this way you&#039;d get errors like:&lt;br /&gt;
&lt;br /&gt;
  [Thu May 26 15:23:53 2011] [error] [client 192.168.xxx.xxx] PHP Warning:  ldap_search() [&amp;lt;a href=&#039;function.ldap-search&#039;&amp;gt;function.ldap-search&amp;lt;/a&amp;gt;]: Search: Partial results and referral received in /xxx/xxx/moodle20/lib/ldaplib.php on line 241, referer: http://moodle.my.domain.ca/moodle20/login/index.php&lt;br /&gt;
  [Thu May 26 15:23:53 2011] [error] [client 192.168.xxx.xxx] PHP Warning:  ldap_first_entry(): supplied argument is not a valid ldap result resource in /xxx/xxx/moodle20/lib/ldaplib.php on line 248, referer: http://moodle.my.domain.ca/moodle20/login/index.php&lt;br /&gt;
&lt;br /&gt;
===Using multiple user locations (contexts) in your LDAP tree===&lt;br /&gt;
There is no need to use multiple user locations if your directory tree is flat, i.e. if all user accounts reside in a &#039;&#039;&#039;ou=people,dc=my,dc=organization,dc=domain&#039;&#039;&#039; or &#039;&#039;&#039;ou=people,o=myorg&#039;&#039;&#039; container. &lt;br /&gt;
&lt;br /&gt;
At the opposite, if you use the ACL mecanism to delegate user management, there are chances that your users will be stored in containers like &#039;&#039;&#039;ou=students,ou=dept1,o=myorg&#039;&#039;&#039; and &#039;&#039;&#039;ou=students,ou=dept2,o=myorg&#039;&#039;&#039; ...&lt;br /&gt;
&lt;br /&gt;
Then there is an alternative :&lt;br /&gt;
* Look at the &#039;&#039;&#039;o=myorg&#039;&#039;&#039; level with the ldap_search_sub attribute set to &#039;&#039;&#039;yes&#039;&#039;&#039;.&lt;br /&gt;
* Set the ldap_context to &#039;&#039;&#039;ou=students,ou=dept1,o=myorg ; ou=students,ou=dept2,o=myorg&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Choosing between these two solutions supposes some sort of benchmarking, as the result depends heavily on the structure of your directory tree &#039;&#039;&#039;and&#039;&#039;&#039; on your LDAP software indexing capabilities. Simply note that there is a probability in such deep trees that two users share the same &#039;&#039;common name&#039;&#039; (cn), while having different &#039;&#039;distinguished names&#039;&#039;. Then only the second solution will have a deterministic result (returning allways the same user).&lt;br /&gt;
&lt;br /&gt;
===Using LDAPS (LDAP over SSL)===&lt;br /&gt;
====Enabling LDAPS on your directory server====&lt;br /&gt;
&lt;br /&gt;
* [[Active_Directory#MS_Active_Directory_.2B_SSL|Enabling LDAPS on MS Active Directory ]]&lt;br /&gt;
&lt;br /&gt;
====Enabling LDAPS on your Moodle server====&lt;br /&gt;
Enabling LDAPS on your server can be tricky and often it is hard to pinpoint where things are going wrong. There are also differences between Windows and Linux and even different versions and distributions of Linux. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;If you have not done so already you will need to decide upon your approach to establishing an SSL connection to your directory server:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* SSL connection with unverified self-signed certificate.&lt;br /&gt;
&lt;br /&gt;
You can generate your own SSL certificate, and then instruct your Moodle server to ignore the fact that it is not valid. This setup is not as secure as others since you cannot be sure the server you are connecting to is not fake.&lt;br /&gt;
&lt;br /&gt;
* SSL connection with trusted self-signed certificate.&lt;br /&gt;
&lt;br /&gt;
You can generate your own SSL certificate on your directory server, and then specifically trust this certificate by installing it on your Moodle server. &lt;br /&gt;
&lt;br /&gt;
* SSL connection with verified certificate from Internet-trusted certificate authority (CA)&lt;br /&gt;
&lt;br /&gt;
In this approach the LDAP server has an installed certificate from an Internet-based CA, this means that your directory server would have an Internet address &amp;amp; host name. Your Moodle server must be trusting the certificate authority and have Internet access. This approach is not often used as it usually incurs a cost for the certificate, and it requires your directory server and Moodle server to be exposed to the Internet.&lt;br /&gt;
&lt;br /&gt;
==Linux servers==&lt;br /&gt;
&#039;&#039;&#039;These instructions are for establishing a link using a trusted self-signed certificate.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: written for a Red Hat Enterprise Linux 6 server, other Linux distributions may differ, especially in the location of the SSL certificates and OpenLdap config files, but the core principals are the same.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To check that your directory server is online and accepting SSL connections on your LDAPS port (636), you can use try:&lt;br /&gt;
 openssl s_client –connect &amp;lt;ldap server ip address&amp;gt;:636&lt;br /&gt;
&lt;br /&gt;
Get your directory server’s certificate (.crt) and upload to Moodle server&#039;s ssl certificate directory, on RHEL6 this is at &#039;&#039;&#039;/etc/ssl/certs&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Convert your ‘DER’ X509 certificate into a ‘PEM’ public key certificate.&lt;br /&gt;
 openssl x509 -in my_server_certificate.cer -inform DER -out my_server_certificate.pem -outform PEM&lt;br /&gt;
&lt;br /&gt;
Create certificate hashes using c_rehash&lt;br /&gt;
 c_rehash&lt;br /&gt;
&#039;&#039;If c_rehash is not installed install with: yum install /usr/bin/c_rehash&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Ensure you are able to access your LDAPS server by a DNS name, this may mean adding an entry to your host file (/etc/hosts)&lt;br /&gt;
 &amp;lt;ldap server ip address&amp;gt;    my_server.mydomain.school&lt;br /&gt;
&lt;br /&gt;
Verify your certificate to check that it is installed correctly&lt;br /&gt;
 openssl verify -verbose -CApath /etc/ssl/certs /etc/ssl/certs/my_server_certificate.pem&lt;br /&gt;
 /etc/ssl/certs/my_server_certificate.pem: OK&lt;br /&gt;
&lt;br /&gt;
You should now be able to connect to your LDAPS server over SSL without any errors&lt;br /&gt;
 openssl s_client –connect &amp;lt;ldap server DNS name&amp;gt;:636&lt;br /&gt;
&lt;br /&gt;
Edit your OpenLDAP config, on RHEL6 this is located at &#039;&#039;&#039;/etc/openldap/ldap.conf&#039;&#039;&#039;&lt;br /&gt;
 # Define location of a CA Cert&lt;br /&gt;
 TLS_CACERT /etc/ssl/certs/my_server_certificate.pem&lt;br /&gt;
 TLS_CACERTDIR /etc/ssl/certs&lt;br /&gt;
&lt;br /&gt;
Finally, you may or may not need to restart Apache, before configuring Moodle to use ldaps://&amp;lt;server DNS name&amp;gt;&lt;br /&gt;
 httpd -k restart&lt;br /&gt;
&lt;br /&gt;
==Windows servers==&lt;br /&gt;
&#039;&#039;&#039;These instructions are for establishing a link using an unverified self-signed certificate.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can tell PHP&#039;s OpenLDAP extension to disable SSL server certificate checking to do this you must create a directory called &#039;&#039;&#039;&#039;C:\OpenLDAP\sysconf\&#039;&#039;&#039;&#039; In this directory, create a file called &#039;&#039;ldap.conf&#039;&#039; with the following content:&lt;br /&gt;
&lt;br /&gt;
 TLS_REQCERT never&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;(If you are using certain versions of PHP 5.3.x you &#039;&#039;&#039;may need to place the file at other locations&#039;&#039;&#039;, [http://bugs.php.net/bug.php?id=48866 see PHP bug #48866])&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Now you should be able to use &#039;&#039;&#039;ldaps://&#039;&#039;&#039; when connecting to your LDAP server.&lt;br /&gt;
&lt;br /&gt;
==Appendices==&lt;br /&gt;
&lt;br /&gt;
=== Setting Resource Limits RedHat Directory Server ===&lt;br /&gt;
&lt;br /&gt;
Operational attributes can be set for the bind user DN using the command-line. &lt;br /&gt;
One can simply use ldapmodify to add the following attributes:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
! Attribute Name &lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| nsLookThroughLimit&lt;br /&gt;
| Specifies how many entries are examined for a search operation. Giving this attribute a value of -1 indicates that there is no limit.&lt;br /&gt;
|-&lt;br /&gt;
| nsSizeLimit &lt;br /&gt;
| Specifies the maximum number of entries the server returns to a client application in response to a search operation. Giving this attribute a value of -1 indicates that there is no limit.&lt;br /&gt;
|-&lt;br /&gt;
| nsTimeLimit &lt;br /&gt;
| Specifies the maximum time the server spends processing a search operation. Giving this attribute a value of -1 indicates that there is no time limit.&lt;br /&gt;
|-&lt;br /&gt;
| nsIdleTimeout 	        &lt;br /&gt;
| Specifies the time a connection to the server can be idle before the connection is dropped. The value is given in seconds. Giving this attribute a value of -1 indicates that there is no limit.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;pre&amp;gt; LDAP Console Command-Line&lt;br /&gt;
&lt;br /&gt;
 ldapmodify -h redhat_dir_server -p 389 -D &amp;quot;cn=directory manager&amp;quot; -w secretpwd&lt;br /&gt;
&lt;br /&gt;
 dn: uid=MoodleAdmin,ou=system,dc=myschool,dc=edu&lt;br /&gt;
 changetype: modify&lt;br /&gt;
 add:nsSizeLimit&lt;br /&gt;
 nsSizeLimit: 1000&lt;br /&gt;
 &amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==Any questions?==&lt;br /&gt;
&lt;br /&gt;
Please post in the [http://moodle.org/mod/forum/view.php?id=42 Authentication forum] on moodle.org.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[NTLM_authentication]]&lt;br /&gt;
* [[Active_Directory]]&lt;br /&gt;
* [[LDAP enrolment]]&lt;br /&gt;
* [http://download.moodle.org/download.php/docs/en/how-to_guides/ldap_auth_and_enrolment_set-up.pdf LDAP auth and enrolment set-up guide] (PDF 227KB)&lt;br /&gt;
&lt;br /&gt;
Forum discussions:&lt;br /&gt;
* [http://moodle.org/mod/forum/view.php?id=42 User authentication forum]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=32168 PHP LDAP module does not seem to be present] forum discussion&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=140901 Syncronisation with AUTH_LDAP_SYNC_USERS.PHP produces fewer accounts than it should] forum discussion&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=17198 Using multiple LDAP servers] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[es:LDAP_authentication]]&lt;br /&gt;
[[fr:Utiliser un serveur LDAP]]&lt;br /&gt;
[[ja:LDAP認証]]&lt;br /&gt;
[[de:LDAP-Server]]&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=MoodleDocs:Guidelines_for_contributors&amp;diff=128439</id>
		<title>MoodleDocs:Guidelines for contributors</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=MoodleDocs:Guidelines_for_contributors&amp;diff=128439"/>
		<updated>2017-08-04T14:01:45Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: /* Creating new pages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Help}}You are welcome to contribute to Moodle Docs. Find something that can be improved, either in content, grammar or formatting, and fix it! Note: You will need to [[Special:Userlogin|login]] to edit pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
* Please note that all contributions are released here under [[License|GNU General Public License]].&lt;br /&gt;
* Every page in Moodle has a link to a corresponding page in Moodle Docs. You can see this on [http://moodle.org moodle.org] and, from an administrator&#039;s perspective, on the [http://demo.moodle.net/ Moodle demo site].&lt;br /&gt;
* You are encouraged to illustrate documentation with screenshots. Please refer to the [[MoodleDocs:Style guide|style guide]] for further information.&lt;br /&gt;
* See [[MoodleDocs:Templates]] for ways of asking for editing help from other contributors.&lt;br /&gt;
&lt;br /&gt;
==Creating new pages==&lt;br /&gt;
&lt;br /&gt;
* You are welcome to create pages for additional documentation about Moodle. Simply type the name of your new page between double brackets &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[New page name]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; on an existing page and follow the link to start editing the new page. Alternatively, you may type in your browser address bar: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;https://docs.moodle.org/en/New_page_name&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; (i.e. replace spaces in the new page name with underscores).&lt;br /&gt;
** Please choose a short name and capitalize the first word only (with a few exceptions, such as the word &#039;&#039;Moodle&#039;&#039;).&lt;br /&gt;
** Please follow the [[MoodleDocs:Style guide|style guide]]. If you categorize new pages it can make it easier for users to find, but the important thing is to put good content into the page. &lt;br /&gt;
** Page titles may be changed in the future by redirecting/moving pages, as part of documentation restructuring.&lt;br /&gt;
* If the page is versioned in-line with Moodle releases, MoodleHQ will create the new page as the new release approaches, by cloning the documentation for the previous release.&lt;br /&gt;
** Example of a versioned page:&lt;br /&gt;
*** Moodle 3.2: https://docs.moodle.org/32/en/LDAP_authentication&lt;br /&gt;
*** Moodle 3.3: https://docs.moodle.org/403/en/LDAP_authentication&lt;br /&gt;
&lt;br /&gt;
==Inter-language linking==&lt;br /&gt;
&lt;br /&gt;
* Inter-language links between pages in different languages may be added by typing, for example, &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[es:Corresponding page title in Spanish]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; in the English MoodleDocs, or &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[en:Corresponding page title in English]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; in the [[:es:Portada|Spanish MoodleDocs]], at the bottom of the page, below the category link. Inter-language links will appear automatically in the &amp;quot;In other languages&amp;quot; block.&lt;br /&gt;
&lt;br /&gt;
== Page comments ==&lt;br /&gt;
&lt;br /&gt;
* For comments about a particular page, and/or short discussions, please use the corresponding talk page (click on the page comments tab). Please sign and date your talk page contribution by typing four tildes &amp;lt;nowiki&amp;gt;~~~~&amp;lt;/nowiki&amp;gt;. There&#039;s also a handy button for signing in the toolbar of the editing field: [[Image:Signature Icon.png]]&lt;br /&gt;
&lt;br /&gt;
* For longer discussions about the documentation, please post on moodle.org in the [http://moodle.org/mod/forum/view.php?id=7135 Moodle community sites forum].&lt;br /&gt;
&lt;br /&gt;
* If you find an unsigned comment you can use the Template:Unsigned like so &amp;lt;nowiki&amp;gt;{{Unsigned|Username}}&amp;lt;/nowiki&amp;gt; which will show as &amp;lt;small&amp;gt;(&#039;&#039;The preceding comment was added by&#039;&#039; [[User:Username]])&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Page protection==&lt;br /&gt;
&lt;br /&gt;
* Certain pages, such as the [[Table of Contents]], are protected from editing. Please use the page comments for suggesting additional content or other changes. &lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[[Moodle documentation FAQ]]&lt;br /&gt;
*[http://moodle.org/mod/forum/view.php?id=7135 Moodle community sites forum].&lt;br /&gt;
&lt;br /&gt;
[[Category:MoodleDocs|Guidelines for contributors]]&lt;br /&gt;
&lt;br /&gt;
[[ca:MoodleDocs:Recomanacions_als_ajudants]]&lt;br /&gt;
[[de:Hinweise für Moodle Docs Autoren]]&lt;br /&gt;
[[es:MoodleDocs:Normas para colaboradores]]&lt;br /&gt;
[[fr:Contribution à la documentation]]&lt;br /&gt;
[[ja:MoodleDocs:寄稿のガイドライン]]&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=Add_fonts_for_embedding&amp;diff=124865</id>
		<title>Add fonts for embedding</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=Add_fonts_for_embedding&amp;diff=124865"/>
		<updated>2016-08-11T11:23:59Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: Add reference to online font conversion via http://fonts.snm-portal.com/&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Certificate}}&lt;br /&gt;
Additional fonts can be included in Moodle and used by the Certificate module, embedding them in the PDF (when using an &amp;quot;embedded&amp;quot; certificate type).&lt;br /&gt;
&lt;br /&gt;
== Add a font from TTF file ==&lt;br /&gt;
Assuming you have a font licensed for converting and embedding...&lt;br /&gt;
&lt;br /&gt;
=== Using an online converter ===&lt;br /&gt;
You can upload TTF (or OTF) fonts to http://fonts.snm-portal.com/, and download converted versions.&lt;br /&gt;
&lt;br /&gt;
Fonts created this way seem to handle accented characters better than converting locally.&lt;br /&gt;
&lt;br /&gt;
=== Converting locally ===&lt;br /&gt;
&lt;br /&gt;
Fonts created this way may not handle accented characters correctly; this is probably dependant on the specific software versions. If you encounter this problem, you might want to try using an online converter (above).&lt;br /&gt;
&lt;br /&gt;
1. Copy the .ttf file to /lib/tcpdf/fonts&lt;br /&gt;
&lt;br /&gt;
2. Create a &amp;quot;convertfont.php&amp;quot; file in /lib/tcpdf/fonts (and ensure the web server has permissions to run it), containing:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
include(&#039;../tcpdf.php&#039;);&lt;br /&gt;
$pdf = new TCPDF_FONTS(&#039;P&#039;, &#039;mm&#039;, &#039;A4&#039;, true, &#039;UTF-8&#039;, false);&lt;br /&gt;
$pdf-&amp;gt;addTTFfont(&#039;./MyFont.ttf&#039;, &#039;TrueTypeUnicode&#039;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
3. View the file at http://&#039;&#039;hostname&#039;&#039;/lib/tcpdf/fonts/convertfont.php (it should just show a blank page).&lt;br /&gt;
&lt;br /&gt;
4. Verify that new files have been created in /lib/tcpdf:&lt;br /&gt;
* myfont.ctg.z&lt;br /&gt;
* myfont.php&lt;br /&gt;
* myfont.z&lt;br /&gt;
&lt;br /&gt;
See below for using the font in a certificate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Add all TCPDF fonts ==&lt;br /&gt;
&lt;br /&gt;
From /lib/tcpdf/fonts/readme_moodle.txt:&lt;br /&gt;
&lt;br /&gt;
:This directory contains just selected set of original tcpdf fonts in order to keep the standard Moodle distribution lightweight. You may want to manually download tcpdf package and extract its fonts/ directory into your $CFG-&amp;gt;dataroot/fonts/. In such case, pdflib.php will use this directory.  In the future, we plan to have fonts downloadable in a same way as languages are. (TODO MDL-18663).&lt;br /&gt;
&lt;br /&gt;
== Using a new font ==&lt;br /&gt;
&lt;br /&gt;
Once added, there are two ways to use the new font:&lt;br /&gt;
# Go to the Certificate module setting page and set it as the new Serif or Sans-serif font. This will apply to all standard certificates.&lt;br /&gt;
# Create a custom certificate type in /mod/certificate/type, and replace the $fontserif and $fontsans variables, as needed.&lt;br /&gt;
&lt;br /&gt;
* Replacing font for the whole file:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// $fontsans = get_config(&#039;certificate&#039;, &#039;fontsans&#039;); // Comment out old code&lt;br /&gt;
&lt;br /&gt;
$fontsans = &#039;myfont&#039;; // Add new code.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Replacing font for just the student name:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
//certificate_print_text($pdf, $x, $y + 36, &#039;C&#039;, $fontsans, &#039;&#039;, 30, fullname($USER)); // Comment out old code&lt;br /&gt;
&lt;br /&gt;
certificate_print_text($pdf, $x, $y + 36, &#039;C&#039;, &#039;myfont&#039;, &#039;&#039;, 30, fullname($USER)); // Add new code.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Certificate]]&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=Add_fonts_for_embedding&amp;diff=124864</id>
		<title>Add fonts for embedding</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=Add_fonts_for_embedding&amp;diff=124864"/>
		<updated>2016-08-11T10:31:02Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Certificate}}&lt;br /&gt;
Additional fonts can be included in Moodle and used by the Certificate module, embedding them in the PDF (when using an &amp;quot;embedded&amp;quot; certificate type).&lt;br /&gt;
&lt;br /&gt;
== Add a font from TTF file ==&lt;br /&gt;
Assuming you have a font licensed for converting and embedding...&lt;br /&gt;
&lt;br /&gt;
1. Copy the .ttf file to /lib/tcpdf/fonts&lt;br /&gt;
&lt;br /&gt;
2. Create a &amp;quot;convertfont.php&amp;quot; file in /lib/tcpdf/fonts (and ensure the web server has permissions to run it), containing:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
include(&#039;../tcpdf.php&#039;);&lt;br /&gt;
$pdf = new TCPDF_FONTS(&#039;P&#039;, &#039;mm&#039;, &#039;A4&#039;, true, &#039;UTF-8&#039;, false);&lt;br /&gt;
$pdf-&amp;gt;addTTFfont(&#039;./MyFont.ttf&#039;, &#039;TrueTypeUnicode&#039;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
3. View the file at http://&#039;&#039;hostname&#039;&#039;/lib/tcpdf/fonts/convertfont.php (it should just show a blank page).&lt;br /&gt;
&lt;br /&gt;
4. Verify that new files have been created in /lib/tcpdf:&lt;br /&gt;
* myfont.ctg.z&lt;br /&gt;
* myfont.php&lt;br /&gt;
* myfont.z&lt;br /&gt;
&lt;br /&gt;
See below for using the font in a certificate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Add all TCPDF fonts ==&lt;br /&gt;
&lt;br /&gt;
From /lib/tcpdf/fonts/readme_moodle.txt:&lt;br /&gt;
&lt;br /&gt;
:This directory contains just selected set of original tcpdf fonts in order to keep the standard Moodle distribution lightweight. You may want to manually download tcpdf package and extract its fonts/ directory into your $CFG-&amp;gt;dataroot/fonts/. In such case, pdflib.php will use this directory.  In the future, we plan to have fonts downloadable in a same way as languages are. (TODO MDL-18663).&lt;br /&gt;
&lt;br /&gt;
== Using a new font ==&lt;br /&gt;
&lt;br /&gt;
Once added, there are two ways to use the new font:&lt;br /&gt;
# Go to the Certificate module setting page and set it as the new Serif or Sans-serif font. This will apply to all standard certificates.&lt;br /&gt;
# Create a custom certificate type in /mod/certificate/type, and replace the $fontserif and $fontsans variables, as needed.&lt;br /&gt;
&lt;br /&gt;
* Replacing font for the whole file:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// $fontsans = get_config(&#039;certificate&#039;, &#039;fontsans&#039;); // Comment out old code&lt;br /&gt;
&lt;br /&gt;
$fontsans = &#039;myfont&#039;; // Add new code.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Replacing font for just the student name:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
//certificate_print_text($pdf, $x, $y + 36, &#039;C&#039;, $fontsans, &#039;&#039;, 30, fullname($USER)); // Comment out old code&lt;br /&gt;
&lt;br /&gt;
certificate_print_text($pdf, $x, $y + 36, &#039;C&#039;, &#039;myfont&#039;, &#039;&#039;, 30, fullname($USER)); // Add new code.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Certificate]]&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=Template:Certificate&amp;diff=124863</id>
		<title>Template:Certificate</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=Template:Certificate&amp;diff=124863"/>
		<updated>2016-08-11T10:24:15Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: Link to page for custom fonts.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div class=&amp;quot;sideblock right&amp;quot; style=&amp;quot;width: 12em;&amp;quot;&amp;gt;	&lt;br /&gt;
&amp;lt;div class=&amp;quot;header&amp;quot;&amp;gt;[[Certificate module|Certificate]]&amp;lt;/div&amp;gt;	&lt;br /&gt;
&amp;lt;div class=&amp;quot;content&amp;quot;&amp;gt;&lt;br /&gt;
* [[Add/edit certificate module|Certificate settings]]&lt;br /&gt;
* [[Certificate customizing|Customizing]]&lt;br /&gt;
* [[Add fonts for embedding|Adding new fonts]]&lt;br /&gt;
* [[Certificate reports]]&lt;br /&gt;
* [[Certificate FAQ]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=Add_fonts_for_embedding&amp;diff=124861</id>
		<title>Add fonts for embedding</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=Add_fonts_for_embedding&amp;diff=124861"/>
		<updated>2016-08-11T10:14:43Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: Tweak formatting under &amp;quot;Add all TCPDF fonts&amp;quot;. Add  Category:Certificate&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Certificate}}&lt;br /&gt;
Additional fonts can be included in Moodle and used by the Certificate module, embedding them in the PDF (when using an &amp;quot;embedded&amp;quot; certificate type).&lt;br /&gt;
&lt;br /&gt;
== Add a font from TTF file ==&lt;br /&gt;
Assuming you have a font licensed for converting and embedding...&lt;br /&gt;
&lt;br /&gt;
1. Copy the .ttf file to /lib/tcpdf/fonts&lt;br /&gt;
&lt;br /&gt;
2. Create a &amp;quot;convertfont.php&amp;quot; file in /lib/tcpdf/fonts (and ensure the web server has permissions to run it), containing:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
include(&#039;../tcpdf.php&#039;);&lt;br /&gt;
$pdf = new TCPDF_FONTS(&#039;P&#039;, &#039;mm&#039;, &#039;A4&#039;, true, &#039;UTF-8&#039;, false);&lt;br /&gt;
$pdf-&amp;gt;addTTFfont(&#039;./MyFont.ttf&#039;, &#039;TrueTypeUnicode&#039;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
3. View the file at http://&#039;&#039;hostname&#039;&#039;/lib/tcpdf/fonts/convertfont.php&lt;br /&gt;
&lt;br /&gt;
4. Verify that new files have been created in /lib/tcpdf:&lt;br /&gt;
* myfont.ctg.z&lt;br /&gt;
* myfont.php&lt;br /&gt;
* myfont.z&lt;br /&gt;
&lt;br /&gt;
See below for using the font in a certificate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Add all TCPDF fonts ==&lt;br /&gt;
&lt;br /&gt;
From /lib/tcpdf/fonts/readme_moodle.txt:&lt;br /&gt;
&lt;br /&gt;
:This directory contains just selected set of original tcpdf fonts in order to keep the standard Moodle distribution lightweight. You may want to manually download tcpdf package and extract its fonts/ directory into your $CFG-&amp;gt;dataroot/fonts/. In such case, pdflib.php will use this directory.  In the future, we plan to have fonts downloadable in a same way as languages are. (TODO MDL-18663).&lt;br /&gt;
&lt;br /&gt;
== Using a new font ==&lt;br /&gt;
&lt;br /&gt;
Once added, there are two ways to use the new font:&lt;br /&gt;
# Go to the Certificate module setting page and set it as the new Serif or Sans-serif font. This will apply to all standard certificates.&lt;br /&gt;
# Create a custom certificate type in /mod/certificate/type, and replace the $fontserif and $fontsans variables, as needed.&lt;br /&gt;
&lt;br /&gt;
* Replacing font for the whole file:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// $fontsans = get_config(&#039;certificate&#039;, &#039;fontsans&#039;); // Comment out old code&lt;br /&gt;
&lt;br /&gt;
$fontsans = &#039;myfont&#039;; // Add new code.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Replacing font for just the student name:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
//certificate_print_text($pdf, $x, $y + 36, &#039;C&#039;, $fontsans, &#039;&#039;, 30, fullname($USER)); // Comment out old code&lt;br /&gt;
&lt;br /&gt;
certificate_print_text($pdf, $x, $y + 36, &#039;C&#039;, &#039;myfont&#039;, &#039;&#039;, 30, fullname($USER)); // Add new code.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Certificate]]&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=Add_fonts_for_embedding&amp;diff=124860</id>
		<title>Add fonts for embedding</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=Add_fonts_for_embedding&amp;diff=124860"/>
		<updated>2016-08-11T09:52:51Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: Initial add.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Certificate}}&lt;br /&gt;
Additional fonts can be included in Moodle and used by the Certificate module, embedding them in the PDF (when using an &amp;quot;embedded&amp;quot; certificate type).&lt;br /&gt;
&lt;br /&gt;
== Add a font from TTF file ==&lt;br /&gt;
Assuming you have a font licensed for converting and embedding...&lt;br /&gt;
&lt;br /&gt;
1. Copy the .ttf file to /lib/tcpdf/fonts&lt;br /&gt;
&lt;br /&gt;
2. Create a &amp;quot;convertfont.php&amp;quot; file in /lib/tcpdf/fonts (and ensure the web server has permissions to run it), containing:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
include(&#039;../tcpdf.php&#039;);&lt;br /&gt;
$pdf = new TCPDF_FONTS(&#039;P&#039;, &#039;mm&#039;, &#039;A4&#039;, true, &#039;UTF-8&#039;, false);&lt;br /&gt;
$pdf-&amp;gt;addTTFfont(&#039;./MyFont.ttf&#039;, &#039;TrueTypeUnicode&#039;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
3. View the file at http://&#039;&#039;hostname&#039;&#039;/lib/tcpdf/fonts/convertfont.php&lt;br /&gt;
&lt;br /&gt;
4. Verify that new files have been created in /lib/tcpdf:&lt;br /&gt;
* myfont.ctg.z&lt;br /&gt;
* myfont.php&lt;br /&gt;
* myfont.z&lt;br /&gt;
&lt;br /&gt;
See below for using the font in a certificate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Add all TCPDF fonts ==&lt;br /&gt;
&lt;br /&gt;
From /lib/tcpdf/fonts/readme_moodle.txt:&lt;br /&gt;
&lt;br /&gt;
  This directory contains just selected set of original tcpdf fonts in order to keep the standard Moodle distribution lightweight. You may want to manually download tcpdf package and extract its fonts/ directory into your &amp;lt;code php&amp;gt;$CFG-&amp;gt;dataroot/fonts/&amp;lt;/code&amp;gt;. In such case, pdflib.php will use this directory.  In the future, we plan to have fonts downloadable in a same way as languages are. (TODO MDL-18663).&lt;br /&gt;
&lt;br /&gt;
== Using a new font ==&lt;br /&gt;
&lt;br /&gt;
Once added, there are two ways to use the new font:&lt;br /&gt;
# Go to the Certificate module setting page and set it as the new Serif or Sans-serif font. This will apply to all standard certificates.&lt;br /&gt;
# Create a custom certificate type in /mod/certificate/type, and replace the $fontserif and $fontsans variables, as needed.&lt;br /&gt;
&lt;br /&gt;
* Replacing font for the whole file:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// $fontsans = get_config(&#039;certificate&#039;, &#039;fontsans&#039;); // Comment out old code&lt;br /&gt;
&lt;br /&gt;
$fontsans = &#039;myfont&#039;; // Add new code.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Replacing font for just the student name:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
//certificate_print_text($pdf, $x, $y + 36, &#039;C&#039;, $fontsans, &#039;&#039;, 30, fullname($USER)); // Comment out old code&lt;br /&gt;
&lt;br /&gt;
certificate_print_text($pdf, $x, $y + 36, &#039;C&#039;, &#039;myfont&#039;, &#039;&#039;, 30, fullname($USER)); // Add new code.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=Block_layout&amp;diff=122698</id>
		<title>Block layout</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=Block_layout&amp;diff=122698"/>
		<updated>2016-03-30T13:25:49Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: Update reset code for deprecated get_context_instance()&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Blocks}}&lt;br /&gt;
==Default block layout for new courses==&lt;br /&gt;
&lt;br /&gt;
To amend the default block layout for new courses, one or more of the following lines (omitting the forward slashes) from &#039;&#039;config-dist.php&#039;&#039; may be added to &#039;&#039;[[Configuration_file|config.php]]&#039;&#039;, amending the block names as required.&lt;br /&gt;
&lt;br /&gt;
 // These variables define DEFAULT block variables for new courses&lt;br /&gt;
 // If this one is set it overrides all others and is the only one used.&lt;br /&gt;
 //      $CFG-&amp;gt;defaultblocks_override =    &#039;participants,activity_modules,search_forums,course_list:news_items,calendar_upcoming,recent_activity&#039;;&lt;br /&gt;
 //&lt;br /&gt;
 // These variables define the specific settings for defined course formats.&lt;br /&gt;
 // They override any settings defined in the formats own config file.&lt;br /&gt;
 //      $CFG-&amp;gt;defaultblocks_site = &#039;site_main_menu,course_list:course_summary,calendar_month&#039;;&lt;br /&gt;
 //      $CFG-&amp;gt;defaultblocks_social =  &#039;participants,search_forums,calendar_month,calendar_upcoming,social_activities,recent_activity,course_list&#039;;&lt;br /&gt;
 //      $CFG-&amp;gt;defaultblocks_topics =  &#039;participants,activity_modules,search_forums,course_list:news_items,calendar_upcoming,recent_activity&#039;;&lt;br /&gt;
 //      $CFG-&amp;gt;defaultblocks_weeks =  &#039;participants,activity_modules,search_forums,course_list:news_items,calendar_upcoming,recent_activity&#039;;&lt;br /&gt;
 // These blocks are used when no other default setting is found.&lt;br /&gt;
 //      $CFG-&amp;gt;defaultblocks = &#039;participants,activity_modules,search_forums,course_list:news_items,calendar_upcoming,recent_activity&#039;;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, to set the default block layout for topics format courses to People, Tags and Administration on the left, and Messages, Online users and Recent activity on the right, simply add the following line to your &#039;&#039;config.php&#039;&#039; file:&lt;br /&gt;
&lt;br /&gt;
 $CFG-&amp;gt;defaultblocks_topics =  &#039;participants,tags:messages,online_users,recent_activity&#039;;&lt;br /&gt;
&lt;br /&gt;
Note how the colon is used to separate those blocks appearing on the left, from those appearing on the right.&lt;br /&gt;
&lt;br /&gt;
==Resetting the block layout for existing courses==&lt;br /&gt;
&lt;br /&gt;
The block layout for existing courses may be reset by copying the following script into a text file, saving it as &#039;&#039;resetblocks.php&#039;&#039;, copying it into the Moodle root directory, then visiting &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;http://yourmoodlesite.org/resetblocks.php&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning&#039;&#039;&#039;: This script may change the layout of your course pages and also remove blocks from those pages if they have not been specified in the config.php line. Check which of your courses has blocks which are not in the config.php line and be prepared to spend time adding blocks to your course pages again. &#039;&#039;Please note that a database backup is recommended before using the script&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;M2.2 and later:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 //moodle 2.2+&lt;br /&gt;
 require_once(&#039;config.php&#039;);&lt;br /&gt;
 require_once($CFG-&amp;gt;libdir.&#039;/blocklib.php&#039;);&lt;br /&gt;
 $courses = get_courses();//can be feed categoryid to just effect one category&lt;br /&gt;
 foreach($courses as $course) {&lt;br /&gt;
    $context = get_context_instance(CONTEXT_COURSE,$course-&amp;gt;id);&lt;br /&gt;
    $context = context_course::instance($course-&amp;gt;id);&lt;br /&gt;
    blocks_delete_all_for_context($context-&amp;gt;id);&lt;br /&gt;
    blocks_add_default_course_blocks($course);&lt;br /&gt;
 } &lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;M2.0 to M2.2:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 //moodle 2.0 - 2.2&lt;br /&gt;
 require_once(&#039;config.php&#039;);&lt;br /&gt;
 require_once($CFG-&amp;gt;libdir.&#039;/blocklib.php&#039;);&lt;br /&gt;
 $courses = get_courses();//can be feed categoryid to just effect one category&lt;br /&gt;
 foreach($courses as $course) {&lt;br /&gt;
    $context = get_context_instance(CONTEXT_COURSE,$course-&amp;gt;id);&lt;br /&gt;
    blocks_delete_all_for_context($context-&amp;gt;id);&lt;br /&gt;
    blocks_add_default_course_blocks($course);&lt;br /&gt;
 } &lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[es:Diseño de bloque]]&lt;br /&gt;
[[ja:ブロックレイアウト]]&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=Creating_custom_roles&amp;diff=112779</id>
		<title>Creating custom roles</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=Creating_custom_roles&amp;diff=112779"/>
		<updated>2014-05-27T15:24:46Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: /* Role archetypes */  Add list of archetypes.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Roles}}&lt;br /&gt;
==Creating a new role==&lt;br /&gt;
&lt;br /&gt;
To create a custom 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 &amp;quot;Add a new role&amp;quot; button.&lt;br /&gt;
#Select template for the new role or upload a preset&lt;br /&gt;
#Give the role a Short name e.g. &#039;Parent&#039;.The short name is necessary for other plugins in Moodle that may need to refer to the role (e.g. when uploading users from a file or setting enrolments via an enrolment plugin).&lt;br /&gt;
#You must provide a full name for all custom roles. If you need to name the role for multiple languages you can use [[Multi language content|multi-lang syntax]] if you wish.&lt;br /&gt;
#Give the role a description (optional).&lt;br /&gt;
#Select an appropriate role archetype (see below for further information).&lt;br /&gt;
#Select the contexts where the role may be assigned e.g. &#039;User&#039; for Parent role.&lt;br /&gt;
#Set permissions as required.&lt;br /&gt;
#Scroll to the top or bottom of the page and click the &amp;quot;Create this role&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:addinganewrole26.png|thumb|Adding a new role and setting context types]]&lt;br /&gt;
| [[Image:permissions125.png|thumb|Choose &amp;quot;Allow&amp;quot; where required]]&lt;br /&gt;
| [[Image:permissions225.png|thumb|Extra options with &amp;quot;Show advanced&amp;quot; enabled]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Role archetypes==&lt;br /&gt;
&lt;br /&gt;
A role archetype&lt;br /&gt;
&lt;br /&gt;
* Is a hard-coded template for a role&lt;br /&gt;
* Is used during upgrades when adding defaults for new capabilities - no archetype = no new capabilities during upgrade&lt;br /&gt;
* Is used during when resetting a role to determine the defaults - no archetype = reset removes all capabilities&lt;br /&gt;
&lt;br /&gt;
There is no need to set a role archetype for custom roles used for overrides or if the site admin wants to specify new capabilities manually after upgrading.&lt;br /&gt;
&lt;br /&gt;
The archetypes (which relate directly to the built-in roles) are:&lt;br /&gt;
* manager&lt;br /&gt;
* coursecreator&lt;br /&gt;
* editingteacher&lt;br /&gt;
* teacher&lt;br /&gt;
* guest&lt;br /&gt;
* user&lt;br /&gt;
* frontpage&lt;br /&gt;
&lt;br /&gt;
==Creating a duplicate role==&lt;br /&gt;
&lt;br /&gt;
To create a duplicate 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 &amp;quot;Add a new role&amp;quot; button.&lt;br /&gt;
#Select existing role as a template&lt;br /&gt;
#Give a name and set permissions for your new role; scroll down and click &amp;quot;Create this role&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==New role considerations==&lt;br /&gt;
&lt;br /&gt;
A new role is not automatically listed in course descriptions even if was created by copying a role that is listed, such as Teacher. If you want the new role to appear in the course listing, you must set it explicitly via &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Appearance &amp;gt; Course managers&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Testing a new role==&lt;br /&gt;
&#039;&#039;Administration &amp;gt; Switch role to&#039;&#039;&lt;br /&gt;
Use the &amp;quot;Switch role to&amp;quot; link to see what another role will see in that context.  &lt;br /&gt;
&lt;br /&gt;
Since switching roles confines you to those roles you can assign in a course context, this method is only useful for testing course-scoped capabilities (i.e. it will not be useful for testing permissions that apply outside the course context, like moodle/user:edit).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tip:&#039;&#039; You can always create test user and assign the new role to them.  Then logout as admin and login as the test user.  This is really the best way to test a new role.&lt;br /&gt;
&lt;br /&gt;
==Example custom roles==&lt;br /&gt;
&lt;br /&gt;
*[[Parent role|Parent]] - for providing parents/mentors/tutors with permission to view certain information about their children/mentees/tutees&lt;br /&gt;
*[[Demo teacher role|Demo teacher]] - for providing a demonstration teacher account with a password which can&#039;t be changed&lt;br /&gt;
*[[Forum moderator role|Forum moderator]] - for providing a user with permission in a particular forum to edit or delete forum posts, split discussions and move discussions to other forums&lt;br /&gt;
*[[Calendar editor role|Calendar editor]] - for enabling a user to add site or course events to the calendar&lt;br /&gt;
*[[Blogger role|Blogger]] - for limiting blogging to specific users only&lt;br /&gt;
*[[Quiz user with unlimited time role|Quiz user with unlimited time]] - for allowing a user unlimited time to attempt a quiz which has a time limit set&lt;br /&gt;
*[[Question creator role|Question creator]] - for enabling students to create questions for use in quizzes&lt;br /&gt;
*[[Question sharer]] - for allowing teachers to share questions between courses&lt;br /&gt;
*[[Course requester role]] - for restricting users who can make course requests&lt;br /&gt;
*[[Cohort enroller]] - for allowing teachers to enrol category cohorts into their course&lt;br /&gt;
*[[Feedback template creator]] - for allowing teachers to save as &amp;quot;Public&amp;quot; a Feedback template.&lt;br /&gt;
*[[Grading forms publisher]] for allowing teachers to share Advanced grading forms with others&lt;br /&gt;
*[[Grading forms manager]] for allowing teachers to share Advanced grading forms with others and to delete templates others have created.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
Using Moodle forum discussions:&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=66782 What happens if a user has multiple roles in a course?]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=90140 logged in: what role am I?]&lt;br /&gt;
* For more information, Ask questions and get answers on the [http://moodle.org/mod/forum/view.php?id=6826 &amp;quot;Roles and Permissions&amp;quot;] forum.&lt;br /&gt;
&lt;br /&gt;
[[Category:Site administration]]&lt;br /&gt;
&lt;br /&gt;
[[de:Neue Rollen anlegen]]&lt;br /&gt;
[[es:Crear roles personalizados]]&lt;br /&gt;
[[fr:Création_de_rôles_personnalisés]]&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=Database_templates&amp;diff=107860</id>
		<title>Database templates</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=Database_templates&amp;diff=107860"/>
		<updated>2013-11-18T12:37:06Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: /* Javascript template */  Better JS &amp;amp; YUI approach - ref https://moodle.org/mod/forum/discuss.php?d=243477#p1056563&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Database}}&lt;br /&gt;
Templates for the [[Database activity module]] allow you to control the visual layout of information when listing, viewing or editing database entries. It is a similar to the technique used to &#039;&#039;mail merge&#039;&#039; letters in word processors such as Open Office Writer or Microsoft Word. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tag usage ==&lt;br /&gt;
&lt;br /&gt;
The content of each [[Database fields|field]] you create for your database and some special tags (listed below) can be inserted into the output template by the use of tags.&lt;br /&gt;
&lt;br /&gt;
Fields have the format &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[fieldname]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. All other tags have the format &amp;lt;code&amp;gt;##sometag##&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To use the tags in the box on the left of the page, use the HTML viewer, place your cursor in the text area of your target edit and then click on the tag you want to place. Alternatively, you may simply type the appropriate name within the required symbols like &amp;lt;code&amp;gt;##this##&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[this]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;##edit##&amp;lt;/code&amp;gt; creates a clickable icon link that allows you to edit the current entry (only appears if you have the rights to do this)&lt;br /&gt;
* &amp;lt;code&amp;gt;##delete##&amp;lt;/code&amp;gt; creates a link that lets you delete the current entry (only appears if you have the rights to do this)&lt;br /&gt;
* &amp;lt;code&amp;gt;##approve##&amp;lt;/code&amp;gt; create a link that lets you approve the current database entry (only appears if you have the rights to do this)&lt;br /&gt;
* &amp;lt;code&amp;gt;##more##&amp;lt;/code&amp;gt; creates a link to the single view, which may contain more detailed info&lt;br /&gt;
* &amp;lt;code&amp;gt;##moreurl##&amp;lt;/code&amp;gt; creates just the URL for the above link, useful for creating your own links. You can click on the link icon and type &amp;lt;code&amp;gt;##moreurl##&amp;lt;/code&amp;gt; into URL field or in source view type &amp;lt;pre&amp;gt;&amp;lt;a href=&amp;quot;##moreurl##&amp;quot;&amp;gt;[[fieldname]]&amp;lt;/a&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;##comments##&amp;lt;/code&amp;gt; creates a link to the view/edit comments page, the link text is the current number of comments (only appears if comments are turned on)&lt;br /&gt;
* &amp;lt;code&amp;gt;##user##&amp;lt;/code&amp;gt; creates a link to the user page of the user who submitted the entry, link text is their name&lt;br /&gt;
* &amp;lt;code&amp;gt;##timeadded##&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;##timemodified##&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== List template ==&lt;br /&gt;
&lt;br /&gt;
This template allows you to control the fields used and their layout when viewing multiple entries at once (e.g. search results). It is possible that this view may simply provide an overview with more detailed information available by clicking on an entry to access the single view of the entry.&lt;br /&gt;
&lt;br /&gt;
See [http://tracker.moodle.org/secure/attachment/23333/moodle_databse_activity_list_formatting.pdf Designing a list view in Moodle database activity] for instructions on how to create a list template table.&lt;br /&gt;
&lt;br /&gt;
The list template can also be used as a way to [[Database export|export your database]] as a CSV file.&lt;br /&gt;
&lt;br /&gt;
== Single template ==&lt;br /&gt;
This is used to display a single entry at a time and so has more space for display and can use, for example, larger versions of images or optionally provide more information than shown in the list view.&lt;br /&gt;
&lt;br /&gt;
[[Image:Databasesingletemplate.png]]&lt;br /&gt;
&lt;br /&gt;
== Advanced search template ==&lt;br /&gt;
&lt;br /&gt;
An advanced search template is for creating the interface form used in the advanced search. &lt;br /&gt;
&lt;br /&gt;
== Add template ==&lt;br /&gt;
&lt;br /&gt;
This template creates the interface form used when adding or editing database entries. &lt;br /&gt;
&lt;br /&gt;
== RSS template ==&lt;br /&gt;
&lt;br /&gt;
Lets you control the content of the [[RSS]] feed for database entries.&lt;br /&gt;
&lt;br /&gt;
== CSS template ==&lt;br /&gt;
&lt;br /&gt;
If any of the [[HTML in Moodle|HTML]] in your other templates requires [[CSS]] to provide visual style you can specify it here.&lt;br /&gt;
&lt;br /&gt;
== Javascript template ==&lt;br /&gt;
&lt;br /&gt;
You can use javascript to manipulate the way elements are displayed in either the List, Single or Add templates. Basically you need to enclose the part you want to manipulate in some named html element. The naming is essential as it allows you to identify the element for manipulation. &lt;br /&gt;
&lt;br /&gt;
Let&#039;s say, for example, you have a field in your database that stores a person&#039;s name and when you display the names in the List View you want to count the times a name matches some criteria and display the result.&lt;br /&gt;
&lt;br /&gt;
Your database will contain a field which we will call &amp;quot;name&amp;quot;. In your List template you will be able to display the contents of that field by using the &amp;lt;nowiki&amp;gt;[[name]]&amp;lt;/nowiki&amp;gt; construct at the place where you want that information displayed. For example in the &#039;&#039;Repeated entry&#039;&#039; on the list template you will have&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;table&amp;gt;&lt;br /&gt;
   &amp;lt;tr&amp;gt;&lt;br /&gt;
     &amp;lt;td&amp;gt;Name: [[name]]&amp;lt;/td&amp;gt;&lt;br /&gt;
   &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;table&amp;gt;  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You now need to modify that entry to ensure that the part you want to manipulate is a named element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;table&amp;gt;&lt;br /&gt;
   &amp;lt;tr&amp;gt;&lt;br /&gt;
     &amp;lt;td name=&amp;quot;named&amp;quot;&amp;gt;Name: [[name]]&amp;lt;/td&amp;gt;&lt;br /&gt;
   &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;table&amp;gt;  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The footer of your list view can then contain another named element to display the result.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;lt;div name=&amp;quot;result&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your javascript template can now look as follows&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 var cnt = 0;&lt;br /&gt;
 var re = /foo|Foo/;&lt;br /&gt;
 &lt;br /&gt;
 function init(){&lt;br /&gt;
   var namedElements = document.getElementsByName(&amp;quot;named&amp;quot;);&lt;br /&gt;
   for (i=0; i &amp;lt; namedElements.length; i++) {&lt;br /&gt;
       if(re.test(namedElements[i].innerHTML)) cnt++;&lt;br /&gt;
     }&lt;br /&gt;
   var namedResult = document.getElementsByName(&amp;quot;result&amp;quot;);&lt;br /&gt;
   namedResult[0].innerHTML = cnt;&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
 window.onload = init;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will display a table of names as is usual in the list view. Now at the bottom there will also be the count of the names that matched foo or Foo.&lt;br /&gt;
&lt;br /&gt;
Note that window.onload does not handle any dependencies on [https://docs.moodle.org/dev/Javascript_FAQ#What_JavaScript_library_does_Moodle_use.3F YUI] code, so any YUI modules required by your init() code may not be loaded, and your code will fail.&lt;br /&gt;
&lt;br /&gt;
In this case, instead of onload, use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
YUI().use(&#039;node&#039;, &#039;other&#039;, &#039;dependencies&#039;, function(Y) {&lt;br /&gt;
&lt;br /&gt;
  // Your code here.&lt;br /&gt;
&lt;br /&gt;
  // This function is a closure so the Y object you define in the function definition is yours and nothing else on the page should be able to break it.&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reset templates button ==&lt;br /&gt;
&lt;br /&gt;
When you first create a database the templates will be pre-filled with appropriate HTML. If you later add fields then you can press the &#039;&#039;reset templates&#039;&#039; button and it will add HTML for the new fields in a similar fashion. If you have edited any of the templates in the meantime then your changes will be lost. It is recommended that you finalize the database fields before changing the template code.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[Database presets]]&lt;br /&gt;
*[http://video.google.com/videoplay?docid=7026851446099005477 Video demonstrating tag usage]&lt;br /&gt;
&lt;br /&gt;
Using Moodle forum discussions: &lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=55338 Look of the database module]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=74243 How can I list database information horizontally instead of vertically?]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=61179 For those who want the display of Moodle Site&#039;s Modules and plugins]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=84050 Can&#039;t get columns to line up in list view]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=86927 Time stamp for database entries?]&lt;br /&gt;
&lt;br /&gt;
[[de:Datenbank-Vorlagen]]&lt;br /&gt;
[[fr:Modèles]]&lt;br /&gt;
[[ru:Шаблоны]]&lt;br /&gt;
[[ja:データベーステンプレート]]&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=Database_templates&amp;diff=107844</id>
		<title>Database templates</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=Database_templates&amp;diff=107844"/>
		<updated>2013-11-15T11:26:06Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: /* Javascript template */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Database}}&lt;br /&gt;
Templates for the [[Database activity module]] allow you to control the visual layout of information when listing, viewing or editing database entries. It is a similar to the technique used to &#039;&#039;mail merge&#039;&#039; letters in word processors such as Open Office Writer or Microsoft Word. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tag usage ==&lt;br /&gt;
&lt;br /&gt;
The content of each [[Database fields|field]] you create for your database and some special tags (listed below) can be inserted into the output template by the use of tags.&lt;br /&gt;
&lt;br /&gt;
Fields have the format &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[fieldname]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. All other tags have the format &amp;lt;code&amp;gt;##sometag##&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To use the tags in the box on the left of the page, use the HTML viewer, place your cursor in the text area of your target edit and then click on the tag you want to place. Alternatively, you may simply type the appropriate name within the required symbols like &amp;lt;code&amp;gt;##this##&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[this]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;##edit##&amp;lt;/code&amp;gt; creates a clickable icon link that allows you to edit the current entry (only appears if you have the rights to do this)&lt;br /&gt;
* &amp;lt;code&amp;gt;##delete##&amp;lt;/code&amp;gt; creates a link that lets you delete the current entry (only appears if you have the rights to do this)&lt;br /&gt;
* &amp;lt;code&amp;gt;##approve##&amp;lt;/code&amp;gt; create a link that lets you approve the current database entry (only appears if you have the rights to do this)&lt;br /&gt;
* &amp;lt;code&amp;gt;##more##&amp;lt;/code&amp;gt; creates a link to the single view, which may contain more detailed info&lt;br /&gt;
* &amp;lt;code&amp;gt;##moreurl##&amp;lt;/code&amp;gt; creates just the URL for the above link, useful for creating your own links. You can click on the link icon and type &amp;lt;code&amp;gt;##moreurl##&amp;lt;/code&amp;gt; into URL field or in source view type &amp;lt;pre&amp;gt;&amp;lt;a href=&amp;quot;##moreurl##&amp;quot;&amp;gt;[[fieldname]]&amp;lt;/a&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;##comments##&amp;lt;/code&amp;gt; creates a link to the view/edit comments page, the link text is the current number of comments (only appears if comments are turned on)&lt;br /&gt;
* &amp;lt;code&amp;gt;##user##&amp;lt;/code&amp;gt; creates a link to the user page of the user who submitted the entry, link text is their name&lt;br /&gt;
* &amp;lt;code&amp;gt;##timeadded##&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;##timemodified##&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== List template ==&lt;br /&gt;
&lt;br /&gt;
This template allows you to control the fields used and their layout when viewing multiple entries at once (e.g. search results). It is possible that this view may simply provide an overview with more detailed information available by clicking on an entry to access the single view of the entry.&lt;br /&gt;
&lt;br /&gt;
See [http://tracker.moodle.org/secure/attachment/23333/moodle_databse_activity_list_formatting.pdf Designing a list view in Moodle database activity] for instructions on how to create a list template table.&lt;br /&gt;
&lt;br /&gt;
The list template can also be used as a way to [[Database export|export your database]] as a CSV file.&lt;br /&gt;
&lt;br /&gt;
== Single template ==&lt;br /&gt;
This is used to display a single entry at a time and so has more space for display and can use, for example, larger versions of images or optionally provide more information than shown in the list view.&lt;br /&gt;
&lt;br /&gt;
[[Image:Databasesingletemplate.png]]&lt;br /&gt;
&lt;br /&gt;
== Advanced search template ==&lt;br /&gt;
&lt;br /&gt;
An advanced search template is for creating the interface form used in the advanced search. &lt;br /&gt;
&lt;br /&gt;
== Add template ==&lt;br /&gt;
&lt;br /&gt;
This template creates the interface form used when adding or editing database entries. &lt;br /&gt;
&lt;br /&gt;
== RSS template ==&lt;br /&gt;
&lt;br /&gt;
Lets you control the content of the [[RSS]] feed for database entries.&lt;br /&gt;
&lt;br /&gt;
== CSS template ==&lt;br /&gt;
&lt;br /&gt;
If any of the [[HTML in Moodle|HTML]] in your other templates requires [[CSS]] to provide visual style you can specify it here.&lt;br /&gt;
&lt;br /&gt;
== Javascript template ==&lt;br /&gt;
&lt;br /&gt;
You can use javascript to manipulate the way elements are displayed in either the List, Single or Add templates. Basically you need to enclose the part you want to manipulate in some named html element. The naming is essential as it allows you to identify the element for manipulation. &lt;br /&gt;
&lt;br /&gt;
Let&#039;s say, for example, you have a field in your database that stores a person&#039;s name and when you display the names in the List View you want to count the times a name matches some criteria and display the result.&lt;br /&gt;
&lt;br /&gt;
Your database will contain a field which we will call &amp;quot;name&amp;quot;. In your List template you will be able to display the contents of that field by using the &amp;lt;nowiki&amp;gt;[[name]]&amp;lt;/nowiki&amp;gt; construct at the place where you want that information displayed. For example in the &#039;&#039;Repeated entry&#039;&#039; on the list template you will have&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;table&amp;gt;&lt;br /&gt;
   &amp;lt;tr&amp;gt;&lt;br /&gt;
     &amp;lt;td&amp;gt;Name: [[name]]&amp;lt;/td&amp;gt;&lt;br /&gt;
   &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;table&amp;gt;  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You now need to modify that entry to ensure that the part you want to manipulate is a named element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;table&amp;gt;&lt;br /&gt;
   &amp;lt;tr&amp;gt;&lt;br /&gt;
     &amp;lt;td name=&amp;quot;named&amp;quot;&amp;gt;Name: [[name]]&amp;lt;/td&amp;gt;&lt;br /&gt;
   &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;table&amp;gt;  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The footer of your list view can then contain another named element to display the result.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;lt;div name=&amp;quot;result&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your javascript template can now look as follows&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 var cnt = 0;&lt;br /&gt;
 var re = /foo|Foo/;&lt;br /&gt;
 &lt;br /&gt;
 function init(){&lt;br /&gt;
   var namedElements = document.getElementsByName(&amp;quot;named&amp;quot;);&lt;br /&gt;
   for (i=0; i &amp;lt; namedElements.length; i++) {&lt;br /&gt;
       if(re.test(namedElements[i].innerHTML)) cnt++;&lt;br /&gt;
     }&lt;br /&gt;
   var namedResult = document.getElementsByName(&amp;quot;result&amp;quot;);&lt;br /&gt;
   namedResult[0].innerHTML = cnt;&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
 window.onload = init;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will display a table of names as is usual in the list view. Now at the bottom there will also be the count of the names that matched foo or Foo.&lt;br /&gt;
&lt;br /&gt;
Note that window.onload does not handle any dependencies on [https://docs.moodle.org/dev/Javascript_FAQ#What_JavaScript_library_does_Moodle_use.3F YUI] code, so any YUI modules required by your init() code may not be loaded, and your code will fail. In this case, use a Y.use() call.&lt;br /&gt;
&lt;br /&gt;
== Reset templates button ==&lt;br /&gt;
&lt;br /&gt;
When you first create a database the templates will be pre-filled with appropriate HTML. If you later add fields then you can press the &#039;&#039;reset templates&#039;&#039; button and it will add HTML for the new fields in a similar fashion. If you have edited any of the templates in the meantime then your changes will be lost. It is recommended that you finalize the database fields before changing the template code.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[Database presets]]&lt;br /&gt;
*[http://video.google.com/videoplay?docid=7026851446099005477 Video demonstrating tag usage]&lt;br /&gt;
&lt;br /&gt;
Using Moodle forum discussions: &lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=55338 Look of the database module]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=74243 How can I list database information horizontally instead of vertically?]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=61179 For those who want the display of Moodle Site&#039;s Modules and plugins]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=84050 Can&#039;t get columns to line up in list view]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=86927 Time stamp for database entries?]&lt;br /&gt;
&lt;br /&gt;
[[de:Datenbank-Vorlagen]]&lt;br /&gt;
[[fr:Modèles]]&lt;br /&gt;
[[ru:Шаблоны]]&lt;br /&gt;
[[ja:データベーステンプレート]]&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=Database_templates&amp;diff=107822</id>
		<title>Database templates</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=Database_templates&amp;diff=107822"/>
		<updated>2013-11-15T10:31:11Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: /* Javascript template */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Database}}&lt;br /&gt;
Templates for the [[Database activity module]] allow you to control the visual layout of information when listing, viewing or editing database entries. It is a similar to the technique used to &#039;&#039;mail merge&#039;&#039; letters in word processors such as Open Office Writer or Microsoft Word. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tag usage ==&lt;br /&gt;
&lt;br /&gt;
The content of each [[Database fields|field]] you create for your database and some special tags (listed below) can be inserted into the output template by the use of tags.&lt;br /&gt;
&lt;br /&gt;
Fields have the format &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[fieldname]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. All other tags have the format &amp;lt;code&amp;gt;##sometag##&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To use the tags in the box on the left of the page, use the HTML viewer, place your cursor in the text area of your target edit and then click on the tag you want to place. Alternatively, you may simply type the appropriate name within the required symbols like &amp;lt;code&amp;gt;##this##&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[this]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;##edit##&amp;lt;/code&amp;gt; creates a clickable icon link that allows you to edit the current entry (only appears if you have the rights to do this)&lt;br /&gt;
* &amp;lt;code&amp;gt;##delete##&amp;lt;/code&amp;gt; creates a link that lets you delete the current entry (only appears if you have the rights to do this)&lt;br /&gt;
* &amp;lt;code&amp;gt;##approve##&amp;lt;/code&amp;gt; create a link that lets you approve the current database entry (only appears if you have the rights to do this)&lt;br /&gt;
* &amp;lt;code&amp;gt;##more##&amp;lt;/code&amp;gt; creates a link to the single view, which may contain more detailed info&lt;br /&gt;
* &amp;lt;code&amp;gt;##moreurl##&amp;lt;/code&amp;gt; creates just the URL for the above link, useful for creating your own links. You can click on the link icon and type &amp;lt;code&amp;gt;##moreurl##&amp;lt;/code&amp;gt; into URL field or in source view type &amp;lt;pre&amp;gt;&amp;lt;a href=&amp;quot;##moreurl##&amp;quot;&amp;gt;[[fieldname]]&amp;lt;/a&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;##comments##&amp;lt;/code&amp;gt; creates a link to the view/edit comments page, the link text is the current number of comments (only appears if comments are turned on)&lt;br /&gt;
* &amp;lt;code&amp;gt;##user##&amp;lt;/code&amp;gt; creates a link to the user page of the user who submitted the entry, link text is their name&lt;br /&gt;
* &amp;lt;code&amp;gt;##timeadded##&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;##timemodified##&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== List template ==&lt;br /&gt;
&lt;br /&gt;
This template allows you to control the fields used and their layout when viewing multiple entries at once (e.g. search results). It is possible that this view may simply provide an overview with more detailed information available by clicking on an entry to access the single view of the entry.&lt;br /&gt;
&lt;br /&gt;
See [http://tracker.moodle.org/secure/attachment/23333/moodle_databse_activity_list_formatting.pdf Designing a list view in Moodle database activity] for instructions on how to create a list template table.&lt;br /&gt;
&lt;br /&gt;
The list template can also be used as a way to [[Database export|export your database]] as a CSV file.&lt;br /&gt;
&lt;br /&gt;
== Single template ==&lt;br /&gt;
This is used to display a single entry at a time and so has more space for display and can use, for example, larger versions of images or optionally provide more information than shown in the list view.&lt;br /&gt;
&lt;br /&gt;
[[Image:Databasesingletemplate.png]]&lt;br /&gt;
&lt;br /&gt;
== Advanced search template ==&lt;br /&gt;
&lt;br /&gt;
An advanced search template is for creating the interface form used in the advanced search. &lt;br /&gt;
&lt;br /&gt;
== Add template ==&lt;br /&gt;
&lt;br /&gt;
This template creates the interface form used when adding or editing database entries. &lt;br /&gt;
&lt;br /&gt;
== RSS template ==&lt;br /&gt;
&lt;br /&gt;
Lets you control the content of the [[RSS]] feed for database entries.&lt;br /&gt;
&lt;br /&gt;
== CSS template ==&lt;br /&gt;
&lt;br /&gt;
If any of the [[HTML in Moodle|HTML]] in your other templates requires [[CSS]] to provide visual style you can specify it here.&lt;br /&gt;
&lt;br /&gt;
== Javascript template ==&lt;br /&gt;
&lt;br /&gt;
You can use javascript to manipulate the way elements are displayed in either the List, Single or Add templates. Basically you need to enclose the part you want to manipulate in some named html element. The naming is essential as it allows you to identify the element for manipulation. &lt;br /&gt;
&lt;br /&gt;
Let&#039;s say, for example, you have a field in your database that stores a person&#039;s name and when you display the names in the List View you want to count the times a name matches some criteria and display the result.&lt;br /&gt;
&lt;br /&gt;
Your database will contain a field which we will call &amp;quot;name&amp;quot;. In your List template you will be able to display the contents of that field by using the &amp;lt;nowiki&amp;gt;[[name]]&amp;lt;/nowiki&amp;gt; construct at the place where you want that information displayed. For example in the &#039;&#039;Repeated entry&#039;&#039; on the list template you will have&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;table&amp;gt;&lt;br /&gt;
   &amp;lt;tr&amp;gt;&lt;br /&gt;
     &amp;lt;td&amp;gt;Name: [[name]]&amp;lt;/td&amp;gt;&lt;br /&gt;
   &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;table&amp;gt;  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You now need to modify that entry to ensure that the part you want to manipulate is a named element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;table&amp;gt;&lt;br /&gt;
   &amp;lt;tr&amp;gt;&lt;br /&gt;
     &amp;lt;td name=&amp;quot;named&amp;quot;&amp;gt;Name: [[name]]&amp;lt;/td&amp;gt;&lt;br /&gt;
   &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;table&amp;gt;  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The footer of your list view can then contain another named element to display the result.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;lt;div name=&amp;quot;result&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your javascript template can now look as follows&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 var cnt = 0;&lt;br /&gt;
 var re = /foo|Foo/;&lt;br /&gt;
 &lt;br /&gt;
 function init(){&lt;br /&gt;
   var namedElements = document.getElementsByName(&amp;quot;named&amp;quot;);&lt;br /&gt;
   for (i=0; i &amp;lt; namedElements.length; i++) {&lt;br /&gt;
       if(re.test(namedElements[i].innerHTML)) cnt++;&lt;br /&gt;
     }&lt;br /&gt;
   var namedResult = document.getElementsByName(&amp;quot;result&amp;quot;);&lt;br /&gt;
   namedResult[0].innerHTML = cnt;&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
 window.onload = init;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will display a table of names as is usual in the list view. Now at the bottom there will also be the count of the names that matched foo or Foo.&lt;br /&gt;
&lt;br /&gt;
Note that window.onload does not handle any dependencies on [https://docs.moodle.org/dev/Javascript_FAQ#What_JavaScript_library_does_Moodle_use.3F YUI] code, so any YUI modules required by your init() code may not be loaded, and your code will fail.&lt;br /&gt;
&lt;br /&gt;
== Reset templates button ==&lt;br /&gt;
&lt;br /&gt;
When you first create a database the templates will be pre-filled with appropriate HTML. If you later add fields then you can press the &#039;&#039;reset templates&#039;&#039; button and it will add HTML for the new fields in a similar fashion. If you have edited any of the templates in the meantime then your changes will be lost. It is recommended that you finalize the database fields before changing the template code.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[Database presets]]&lt;br /&gt;
*[http://video.google.com/videoplay?docid=7026851446099005477 Video demonstrating tag usage]&lt;br /&gt;
&lt;br /&gt;
Using Moodle forum discussions: &lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=55338 Look of the database module]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=74243 How can I list database information horizontally instead of vertically?]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=61179 For those who want the display of Moodle Site&#039;s Modules and plugins]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=84050 Can&#039;t get columns to line up in list view]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=86927 Time stamp for database entries?]&lt;br /&gt;
&lt;br /&gt;
[[de:Datenbank-Vorlagen]]&lt;br /&gt;
[[fr:Modèles]]&lt;br /&gt;
[[ru:Шаблоны]]&lt;br /&gt;
[[ja:データベーステンプレート]]&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=Embedding_content&amp;diff=88984</id>
		<title>Embedding content</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=Embedding_content&amp;diff=88984"/>
		<updated>2011-08-31T13:38:14Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Working with media}}&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Please refer to [[Page_notes#Embedding content|these notes]] before editing this page.&#039;&#039;&#039;&amp;lt;/p&amp;gt;&lt;br /&gt;
{{Improve}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Embedding media files ==&lt;br /&gt;
When adding content to a course with a [[Page]] resource, media files can be embedded using [[Multimedia_plugins|multimedia plugins]] to take media file URLs entered in the HTML editor and convert them into relevant player software embedded in the page.&lt;br /&gt;
&lt;br /&gt;
== Embedding uploaded resources ==&lt;br /&gt;
&lt;br /&gt;
When adding a File resource to a course, there are several options for how the file will be displayed to the user: Automatic, Embed, Force download, Open, In pop-up, and disabled by default: In frame, and New window. (See [[mod/file/mod|file mod]] for more details on all of these.)&lt;br /&gt;
&lt;br /&gt;
The options relevant to embedding are Embed and In frame:&lt;br /&gt;
=== Embed ===&lt;br /&gt;
This uses a HTML &amp;lt;code&amp;gt;object&amp;lt;/code&amp;gt; element, or &amp;lt;code&amp;gt;iframe&amp;lt;/code&amp;gt; element for older versions of Internet Explorer.&lt;br /&gt;
&lt;br /&gt;
The resource is embedded at a default size 800x600, and automatically resized to fill available space by javascript on page load and resize. Due to the variety of different content that might be embedded (e.g. Flash, PDFs, HTML pages) the resized embed may not maximise use of available screen space, e.g. unused space below the footer.&lt;br /&gt;
&lt;br /&gt;
=== In frame ===&lt;br /&gt;
This uses a resizable HTML &amp;lt;code&amp;gt;frameset&amp;lt;/code&amp;gt; with an upper &amp;lt;code&amp;gt;frame&amp;lt;/code&amp;gt; to show the Moodle heading (with navigation) and the file description, with the file displayed in a &amp;lt;code&amp;gt;frame&amp;lt;/code&amp;gt; below.&lt;br /&gt;
&lt;br /&gt;
Disabled by default, In frame is not recommended as frames have been depreciated in recent versions of the HTML standard, due to the problems they create for accessibility.&lt;br /&gt;
It can be enabled via &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Activity modules &amp;gt; File&#039;&#039;.&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=Embedding_content&amp;diff=88981</id>
		<title>Embedding content</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=Embedding_content&amp;diff=88981"/>
		<updated>2011-08-31T12:56:56Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Working with media}}&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Please refer to [[Page_notes#Embedding content|these notes]] before editing this page.&#039;&#039;&#039;&amp;lt;/p&amp;gt;&lt;br /&gt;
{{Improve}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Embedding media files ==&lt;br /&gt;
When adding content to a course with a [[Page]] resource, media files can be embedded using [[Multimedia_plugins|multimedia plugins]] to take media file URLs entered in the HTML editor and convert them into relevant player software embedded in the page.&lt;br /&gt;
&lt;br /&gt;
== Embedding uploaded resources ==&lt;br /&gt;
&lt;br /&gt;
When adding a File resource to a course, there are several options for how the file will be displayed to the user: Automatic, Embed, Force download, Open, In pop-up, and disabled by default: In frame, and New window. (See [[mod/file/mod|file mod]] for more details on all of these.)&lt;br /&gt;
&lt;br /&gt;
The options relevant to embedding are Embed and In frame:&lt;br /&gt;
=== Embed ===&lt;br /&gt;
This uses a HTML &amp;lt;code&amp;gt;object&amp;lt;/code&amp;gt; element, or &amp;lt;code&amp;gt;iframe&amp;lt;/code&amp;gt; element for older versions of Internet Explorer. The resource is embedded at a default size 800x600, and automatically resized to fill available space by javascript on page load and resize.&lt;br /&gt;
&lt;br /&gt;
=== In frame ===&lt;br /&gt;
This uses a resizable HTML &amp;lt;code&amp;gt;frameset&amp;lt;/code&amp;gt; with an upper &amp;lt;code&amp;gt;frame&amp;lt;/code&amp;gt; to show the Moodle heading (with navigation) and the file description, with the file displayed in a &amp;lt;code&amp;gt;frame&amp;lt;/code&amp;gt; below.&lt;br /&gt;
&lt;br /&gt;
Disabled by default, In frame is not recommended as frames have been depreciated in recent versions of the HTML standard, due to the problems they create for accessibility.&lt;br /&gt;
It can be enabled via &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Activity modules &amp;gt; File&#039;&#039;.&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=Embedding_content&amp;diff=88978</id>
		<title>Embedding content</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=Embedding_content&amp;diff=88978"/>
		<updated>2011-08-31T11:37:14Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: First pass.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Working with media}}&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Please refer to [[Page_notes#Embedding content|these notes]] before editing this page.&#039;&#039;&#039;&amp;lt;/p&amp;gt;&lt;br /&gt;
{{Improve}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Embedding media files ==&lt;br /&gt;
When adding content to a course with a [[Page]] resource, media files can be embedded using [[Multimedia_plugins|multimedia plugins]] to take media file URLs entered in the HTML editor and convert them into relevant player software embedded in the page.&lt;br /&gt;
&lt;br /&gt;
== Embedding uploaded resources ==&lt;br /&gt;
&lt;br /&gt;
When adding a File resource to a course, there are several options for how the file will be displayed to the user: Automatic, Embed, Force download, Open, In pop-up, and disabled by default: In frame, and New window. (See [[mod/file/mod|file mod]] for more details on all of these.)&lt;br /&gt;
&lt;br /&gt;
The options relevant to embedding are Embed and In frame:&lt;br /&gt;
=== Embed ===&lt;br /&gt;
This uses a HTML &amp;lt;code&amp;gt;object&amp;lt;/code&amp;gt; element, or &amp;lt;code&amp;gt;iframe&amp;lt;/code&amp;gt; element for older versions of Internet Explorer.&lt;br /&gt;
&lt;br /&gt;
=== In frame ===&lt;br /&gt;
This uses a resizable HTML &amp;lt;code&amp;gt;frameset&amp;lt;/code&amp;gt; with an upper &amp;lt;code&amp;gt;frame&amp;lt;/code&amp;gt; to show the Moodle heading (with navigation) and the file description, with the file displayed in a &amp;lt;code&amp;gt;frame&amp;lt;/code&amp;gt; below.&lt;br /&gt;
&lt;br /&gt;
Disabled by default, In frame is not recommended due to accessibility problems caused by HTML frames.&lt;br /&gt;
It can be enabled via &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Activity modules &amp;gt; File&#039;&#039;.&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=Upload_users&amp;diff=76307</id>
		<title>Upload users</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=Upload_users&amp;diff=76307"/>
		<updated>2010-09-29T09:15:55Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: Change &amp;quot;Enrolment field names&amp;quot; layout to make it more comprehensible&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Location: &#039;&#039;Administration &amp;gt; Users &amp;gt; Accounts &amp;gt; Upload users&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:Upload users preview.png|thumb|Upload users preview in Moodle 1.9]]&lt;br /&gt;
Firstly, note that it is usually not necessary to import users in bulk - to keep maintenance work down you should first explore forms of authentication that do not require manual maintenance, such as [[External database authentication|connecting to existing external databases]] or letting the [[Internal enrolment|users create their own accounts]]. See [[Manage authentication]] for more information.&lt;br /&gt;
&lt;br /&gt;
If you are sure you want to import multiple user accounts from a text file, then you need to format your text file as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Upload file format==&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 (or other delimiters)&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;
:&#039;&#039;&#039;Required fieldnames&#039;&#039;&#039;: These fields must be included in the first record, and defined for each user&lt;br /&gt;
:&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;username, password, firstname, lastname, email&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
:&amp;lt;p&amp;gt;Remember that validity checks for the username, password, and email fields will be performed.Usernames can only contain alphabetical letters in lowercase, numbers, hypen &#039;-&#039;, underscore &#039;_&#039;, period &#039;.&#039;, or at sign &#039;@&#039;. Passwords should meet the requirements specified for the site&#039;s [[Site_policies#Password_policy|Password policy]]. Emails should be in the format of a valid email.&amp;lt;/p&amp;gt; &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;&#039;Optional fieldnames&#039;&#039;&#039;: If a value is present for the field in the file, then that value is used; else, the default value for that field is used&lt;br /&gt;
:&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;institution, department, city, country, lang, auth, ajax, timezone, idnumber, icq, phone1, phone2, address, url, description, mailformat, maildisplay, htmleditor, autosubscribe, emailstop&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;&#039;Custom profile field names&#039;&#039;&#039;: Optional, xxxxx is the real custom user profile field name (i.e. the unique short name)&lt;br /&gt;
:&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;profile_field_xxxxx&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
:&#039;&#039;&#039;Warning:&#039;&#039;&#039;: If you want to create custom profile fields, you need to follow the standard header in your .csv file to import users. You must create the custom fields BEFORE importing users from list. The &amp;quot;shortname&amp;quot; for your custom field is xxxxx, and the header collumn to all users data in .csv file have standard notation &amp;quot;profile_field_xxxxx&amp;quot;.&lt;br /&gt;
:&#039;&#039;&#039;Example&#039;&#039;&#039;: If you want to create a custom field &amp;quot;genre&amp;quot; in your Moodle site, you must write a shortname &amp;quot;genre&amp;quot; in the new field, and write &amp;quot;profile_field_genre&amp;quot; in the header of the .csv file.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;&#039;Special field names&#039;&#039;&#039;: Used for changing of usernames and deleting of users&lt;br /&gt;
:&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;deleted, oldusername&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
:&#039;&#039;&#039;Enrolment field names&#039;&#039;&#039;: Optional:&lt;br /&gt;
** The course names are the &amp;quot;shortnames&amp;quot; of the courses - if present then the user will be enrolled in those courses.&lt;br /&gt;
** &amp;quot;Type&amp;quot; means type of role to be used for associated course enrolment. Value 1 is default course role, 2 is legacy Teacher role and 3 is legacy Non-editing Teacher.&lt;br /&gt;
** You can use role field instead to specify roles directly - use either role short name or id (numeric names of roles are not supported).&lt;br /&gt;
** Users may be also assigned to groups in course (group1 in course1, group2 in course2, etc.).&lt;br /&gt;
** Groups are again identified by its names or ids (numeric names of groups are not supported).&lt;br /&gt;
** From Moodle 2.0, you can also set the enrolment duration in days for each course (enrolperiod1 for course1, enrolperiod2 for course 2, etc.).&lt;br /&gt;
:&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;course1, type1, role1, group1, enrolperiod1, course2, type2, role2, group2, enrolperiod2&amp;lt;/code&amp;gt; etc.&amp;lt;/p&amp;gt;&lt;br /&gt;
&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;
* Force password change: Set the password field for desired users to &#039;&#039;&#039;changeme&#039;&#039;&#039;.&lt;br /&gt;
* Turn email off: The parameter &#039;&#039;&#039;emailstop&#039;&#039;&#039; must be set to 1 if the email address should not work. If you set it to 0 then the email address is switched on. If you want to have all the email addresses active then you do not need the additional parameter in your upload file.&lt;br /&gt;
* In order to prevent users from receiving a larger number of emails from courses and forced subscription forums use the &#039;&#039;&#039;maildigest&#039;&#039;&#039; fieldname.  The options for this fieldname are 0 = No digest, 1 = Complete digest and 2 = Digest with just subjects.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a valid import file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;username, password, firstname, lastname, email, lang, idnumber, maildisplay, course1, group1, type1&amp;lt;br /&amp;gt;&lt;br /&gt;
jonest, verysecret, Tom, Jones, jonest@someplace.edu, en, 3663737, 1, Junk102, Section 1, 1&amp;lt;br /&amp;gt;&lt;br /&gt;
reznort, somesecret, Trent, Reznor, reznort@someplace.edu, en_us, 6736733, 0, Junk102, Section 3, 3&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Templates==&lt;br /&gt;
&lt;br /&gt;
The default values are processed as templates in which the following codes are allowed:&lt;br /&gt;
&lt;br /&gt;
* %l - will be replaced by the lastname&lt;br /&gt;
* %f - will be replaced by the firstname&lt;br /&gt;
* %u - will be replaced by the username&lt;br /&gt;
* %% - will be replaced by the %&lt;br /&gt;
&lt;br /&gt;
Between the percent sign (%) and any code letter (l, f or u) the following modifiers are allowed:&lt;br /&gt;
&lt;br /&gt;
* (-) minus sign - the information specified by the code letter will be converted to lowercase&lt;br /&gt;
* (+) plus sign - the information specified by the code letter will be converted to UPPERCASE&lt;br /&gt;
* (~) tilde sign - the information specified by the code letter will be converted to Title Case&lt;br /&gt;
* a decimal number - the information specified by the code letter will be truncated to that many characters&lt;br /&gt;
&lt;br /&gt;
For example, if the firstname is John and the lastname is Doe, the following values will be obtained with the specified templates:&lt;br /&gt;
&lt;br /&gt;
* %l%f = DoeJohn&lt;br /&gt;
* %l%1f = DoeJ&lt;br /&gt;
* %-l%+f = doeJOHN&lt;br /&gt;
* %-f_%-l = john_doe&lt;br /&gt;
* http://www.example.com/~%u/ = http://www.example.com/~jdoe/ (if the username is jdoe or %-1f%-l)&lt;br /&gt;
&lt;br /&gt;
Template processing is done only on default values, and not on the values retrieved from the CSV file.&lt;br /&gt;
&lt;br /&gt;
In order to create correct Moodle usernames, the username is always converted to lowercase. Moreover, if the &amp;quot;Allow extended characters in usernames&amp;quot; option in the Site policies page is off, characters different to letters, digits, dash (-) and dot (.) are removed. For example if the firstname is John Jr. and the lastname is Doe, the username %-f_%-l will produce john jr._doe when Allow extended characters in usernames is on, and johnjr.doe when off.&lt;br /&gt;
&lt;br /&gt;
When the &amp;quot;New username duplicate handling&amp;quot; setting is set to Append counter, an auto-increment counter will be append to duplicate usernames produced by the template. For example, if the CSV file contains the users named John Doe, Jane Doe and Jenny Doe without explicit usernames, the default username is %-1f%-l and New username duplicate handling is set to Append counter, then the usernames produced will be jdoe, jdoe2 and jdoe3. &lt;br /&gt;
&lt;br /&gt;
==Updating existing accounts==&lt;br /&gt;
&lt;br /&gt;
By default Moodle assumes that you will be creating new user accounts, and skips records where the username matches an existing account. However, if you set &amp;quot;Update existing accounts&amp;quot; to &#039;&#039;&#039;Yes&#039;&#039;&#039;, the existing user account will be updated.&lt;br /&gt;
&lt;br /&gt;
When updating existing accounts you can change usernames as well. Set &amp;quot;Allow renames&amp;quot; to &#039;&#039;&#039;Yes&#039;&#039;&#039; and include in your file a field called &amp;lt;code&amp;gt;oldusername&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning&#039;&#039;&#039;: any errors updating existing accounts can affect your users badly. Be careful when using the options to update.&lt;br /&gt;
&lt;br /&gt;
==Deleting accounts==&lt;br /&gt;
&lt;br /&gt;
If the &amp;lt;code&amp;gt;deleted&amp;lt;/code&amp;gt; field is present, users with value 1 for it will be deleted. In this case, all the fields may be omitted, except for &amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Deleting and uploading accounts could be done with a single CSV file. For example, the following file will add the user Tom Jones and delete the user reznort:&lt;br /&gt;
&lt;br /&gt;
 username, firstname, lastname, deleted&lt;br /&gt;
 jonest, Tom, Jones, 0&lt;br /&gt;
 reznort, , , 1 &lt;br /&gt;
&lt;br /&gt;
==Encoding==&lt;br /&gt;
&lt;br /&gt;
In Moodle 1.8 the file must be UTF-8. In Moodle 1.9 onwards, the encoding may be selected from a large list, including ISO-8859-1.&lt;br /&gt;
&lt;br /&gt;
==Hints==&lt;br /&gt;
&lt;br /&gt;
===Spreadsheet===&lt;br /&gt;
&lt;br /&gt;
If you use a spreadsheet program such as Excel to create your .csv file, check the resulting output in a text editor before you upload it.  It is possible to get trailing commas on each line from an empty field if you have added and deleted columns of information prior to saving the final file. Also check the character encoding. A csv file is a simple text file (ASCII or Unicode) that can be used to upload user accounts.&lt;br /&gt;
&lt;br /&gt;
Excel translates passwords that begin with - (minus) or + (plus) as zero. Even when saving as .csv and saying &amp;quot;Yes&amp;quot; to &amp;quot;Keep this format, and leave out any incompatible features.&amp;quot; Check for this before uploading, as a zero halts the upload process.&lt;br /&gt;
&lt;br /&gt;
If you use a formula in Excel to create fields (for example, the concatenate function to create a user name), then remember to copy the cells with the formula and use special paste with values checked to make them into an acceptable data for a csv file.&lt;br /&gt;
&lt;br /&gt;
===Country===&lt;br /&gt;
The country should be written as a two letter code, in capitals. For example, use BE for Belgium or NL for the Netherlands.  Using &amp;quot;be&amp;quot; or &amp;quot;nl&amp;quot; as a country code will result in a database error.&lt;br /&gt;
:&#039;&#039;Tip:&#039;&#039;  If you are having trouble working out the two-letter code for a country, you can consult this Moodle source code file /moodle/lang/en_utf8/countries.php [http://cvs.moodle.org/moodle/lang/en_utf8/countries.php?view=markup&amp;amp;pathrev=MOODLE_19_STABLE or click here for a 1.9 STABLE list].&lt;br /&gt;
ISO Website: [http://www.iso.org/iso/country_codes/iso_3166_code_lists/english_country_names_and_code_elements.htm]&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
Moodle Docs:&lt;br /&gt;
*[[Flat file]]&lt;br /&gt;
&lt;br /&gt;
Using Moodle forum discussions:&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=36851 Can I auto enroll from Excel?]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=58215 Making Email Optional]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=97903 Uploading users to custom roles]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=144569 Matriculacion con flat file csv] - discussion in Spanish&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
[[Category:Enrolment]]&lt;br /&gt;
[[Category:Groups]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Importer des utilisateurs]]&lt;br /&gt;
[[ja:ユーザのアップロード]]&lt;br /&gt;
[[zh:上传用户]]&lt;br /&gt;
[[ru:Загрузка пользователей]]&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=Development:NEWMODULE_Documentation&amp;diff=63422</id>
		<title>Development:NEWMODULE Documentation</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=Development:NEWMODULE_Documentation&amp;diff=63422"/>
		<updated>2009-09-22T09:20:56Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: Changed icon dimensions, as the files are 16x16. Added description of index.php&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Work in progress}}&lt;br /&gt;
{{New_Module}}&lt;br /&gt;
&lt;br /&gt;
This first draft of Moodle Docs page about the creation of  a new module is divided into the following sections:&lt;br /&gt;
&lt;br /&gt;
*[[Development:NEWMODULE Tutorial]]&lt;br /&gt;
*[[Development:NEWMODULE Reference]]&lt;br /&gt;
*[[Development:NEWMODULE FAQ]]&lt;br /&gt;
*[[Development:NEWMODULE Adding capabilities]]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Daniele, did you know about [[Development:Modules]], which is linked to from [[Developer_documentation#Make_a_new_plugin]]? You may be better off editing that, rather than starting a new page. However don&#039;t let me discourage you. That documentation is very limited, and badly needs to be expanded, so it is absolutely brilliant that you want to work on it.--[[User:Tim Hunt|Tim Hunt]] 12:03, 28 March 2008 (CDT)&lt;br /&gt;
&lt;br /&gt;
::Good point Tim! Anyway... I think we can use this as temporary root for Daniele&#039;s work and then, simply, move things to their final place. Let&#039;s see how this evolves. -- [[User:Eloy Lafuente (stronk7)|Eloy Lafuente (stronk7)]] 12:33, 28 March 2008 (CDT)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://lyceum.open.ac.uk/temp/creating_moodle_modules.ppt My powerpoint about creating moodle modules] is a bit old (1.8) and maybe not that comprehensible but I use it when I&#039;m trying to explain things to people. It includes a list of all the things you need to have in a module, except the ones I forgot (backuplib iirc is missing). [[User:sam marshall|sam marshall]] 12:52, 28 March 2008 (CDT)&lt;br /&gt;
&lt;br /&gt;
::That&#039;s really great, Sam. For sure that presentation will help.Thanks! -- [[User:Eloy Lafuente (stronk7)|Eloy Lafuente (stronk7)]] 13:08, 28 March 2008 (CDT)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Dear Tim, Sam and Eloy, I wrote what was my learning path on these issues. I wrote whatever I found in your powerpoint guide (thanks again, Sam) and whatever I got mainly from Tim, Eloy and Petr. A lot of issues are still obscure to me like: grades, groups, groupings, backup and so forth. Please let me know your opinion to make all together a plan to carry on in the best way. Thanks. -- [[User:Daniele Cordella|Daniele Cordella]] 11:55, 10 September 2009 (UTC)&lt;br /&gt;
&lt;br /&gt;
==Getting started==&lt;br /&gt;
&lt;br /&gt;
To download the newmodule package, please refer to:&lt;br /&gt;
:* 1.8: http://download.moodle.org/plugins18/mod/NEWMODULE.zip&lt;br /&gt;
:* 1.9: http://download.moodle.org/plugins19/mod/NEWMODULE.zip&lt;br /&gt;
:* HEAD: http://download.moodle.org/plugins/mod/NEWMODULE.zip&lt;br /&gt;
&lt;br /&gt;
Although you can download the newmodule package for moodle 1.8, such as 1.9 and head, this tutorial is intended for the newmodule development in Moodle 1.9 ONLY.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start by getting an idea about what you find in the newmodule folder taken from http://download.moodle.org/plugins19/mod/NEWMODULE.zip&lt;br /&gt;
&amp;lt;pre&amp;gt;NEWMODULE:&lt;br /&gt;
01)    db/install.xml&lt;br /&gt;
02)    db/upgrade.php&lt;br /&gt;
03)    icon.gif&lt;br /&gt;
04)    index.php&lt;br /&gt;
05)    lang/en_utf8/help/newmodule/index.html&lt;br /&gt;
06)    lang/en_utf8/help/newmodule/mods.html&lt;br /&gt;
07)    lang/en_utf8/newmodule.php&lt;br /&gt;
08)    lib.php&lt;br /&gt;
09)    mod_form.php&lt;br /&gt;
10)    README.txt&lt;br /&gt;
11)    version.php&lt;br /&gt;
12)    view.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The path where you find each file is the correct one. So don&#039;t change the path of files and folders in this newmodule package.&lt;br /&gt;
&lt;br /&gt;
Inside the db folder, at the beginning, you can only find install.xml and upgrade.php but sooner you will start to always add the new file &amp;quot;access.php&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
01) &#039;&#039;&#039;db/install.xml&#039;&#039;&#039; is the file to write the xml describing the tables needed by the module. Tables are at least two, one named with the same name of the module, one named &amp;quot;log_display&amp;quot;. They follow a strict syntax that you can learn by editing one of the several example you can find inside moodle modules. Ultimately the only thing to take care is the &amp;lt;&amp;lt;previous&amp;gt;&amp;gt; &amp;lt;&amp;lt;next&amp;gt;&amp;gt; connection between tables and fields. This is the mandatory file where you MUST write the structure of the tables your module is going to use. Tha table &amp;quot;log_display&amp;quot; is the tables where you are requested to list all the &amp;quot;actions&amp;quot; that you will add to the logs of your module.&lt;br /&gt;
&lt;br /&gt;
02) &#039;&#039;&#039;db/upgrade.php&#039;&#039;&#039; is the file that you will write each time you need to change the structure of the tables of your module. To learn how to write this file, please refer to the examples you may find in the file itself.&lt;br /&gt;
&lt;br /&gt;
03) &#039;&#039;&#039;icon.gif&#039;&#039;&#039;, it is a 16px per 16px icon identifying each instance of your module in the frame of a course&lt;br /&gt;
&lt;br /&gt;
04) &#039;&#039;&#039;index.php&#039;&#039;&#039; is a page to list all instances of the functionality the module provides in a course.&lt;br /&gt;
&lt;br /&gt;
05) &#039;&#039;&#039;lang&#039;&#039;&#039; is the folder reserved to language packs. A module language pack is a folder named &amp;quot;xx_utf8&amp;quot; containing, in turn, a folder named &amp;quot;help&amp;quot; and a language file named with the same name of the module. xx is the two char long name of the language, i.e. en, de, es, it, fr and so forth.&lt;br /&gt;
:Each language file is dedicated to a specific language. The lang folder may contain as much language packs as provided by different translators. The lang/xx_utf8/newmodule/ folder contains all the help files you want to provide to your module. In order to link a help file from inside the code of your module pages try:&lt;br /&gt;
:* helpbutton(&#039;&amp;lt;&amp;lt;name of your help file saved in lang/xx_utf8/newmodule/&amp;gt;&amp;gt;&#039;, get_string(&#039;your_string&#039;,&#039;newmodule&#039;), &#039;newmodule&#039;);&lt;br /&gt;
:or, in mod_form.php,&lt;br /&gt;
:* $mform-&amp;gt;setHelpButton as stated in&lt;br /&gt;
&lt;br /&gt;
08) &#039;&#039;&#039;lib.php&#039;&#039;&#039; is the pre-filled file with &amp;quot;core&amp;quot; functions needed by each module.&lt;br /&gt;
Let me start by remembering the convention to name functions into lib.php and locallib.php.&lt;br /&gt;
:See: https://docs.moodle.org/en/Development:Coding_style#Functions_and_Methods&lt;br /&gt;
:or&lt;br /&gt;
:https://docs.moodle.org/en/Development:Modules&lt;br /&gt;
&lt;br /&gt;
:Mandatory function are, at least:&lt;br /&gt;
:*&#039;&#039;&#039;function newmodule_add_instance($newmodule)&#039;&#039;&#039;&lt;br /&gt;
:This function is executed after an editing teacher create an instance of newmodule&lt;br /&gt;
:See, lib.php for more details just above the function.&lt;br /&gt;
&lt;br /&gt;
:*&#039;&#039;&#039;function newmodule_update_instance($newmodule)&#039;&#039;&#039;&lt;br /&gt;
:This function is executed after an editing teacher update an instance of newmodule&lt;br /&gt;
:See, lib.php for more details just above the function.&lt;br /&gt;
&lt;br /&gt;
:*&#039;&#039;&#039;function newmodule_delete_instance($id)&#039;&#039;&#039;&lt;br /&gt;
:This function is executed after an editing teacher delete an instance of newmodule&lt;br /&gt;
:See, lib.php for more details just above the function.&lt;br /&gt;
&lt;br /&gt;
:*&#039;&#039;&#039;function newmodule_user_outline()&#039;&#039;&#039;&lt;br /&gt;
:See, lib.php for more details just above the function.&lt;br /&gt;
&lt;br /&gt;
:*&#039;&#039;&#039;function newmodule_user_complete($course, $user, $mod, $newmodule)&#039;&#039;&#039;&lt;br /&gt;
:See, lib.php for more details just above the function.&lt;br /&gt;
&lt;br /&gt;
:*&#039;&#039;&#039;function newmodule_print_recent_activity($course, $isteacher, $timestart)&#039;&#039;&#039;&lt;br /&gt;
:See, lib.php for more details just above the function.&lt;br /&gt;
&lt;br /&gt;
:*&#039;&#039;&#039;function newmodule_cron()&#039;&#039;&#039;&lt;br /&gt;
:Take care with this function.&lt;br /&gt;
:Differently by all the other functions, this function is not called by passing it the $newmodule record. This means that this function, called by moodle core cron has to look for each newmodule instance id before operating.&lt;br /&gt;
:Don&#039;t worry, even if you have more than a single instance of your module among moodle courses, this function will be executed just one time.&lt;br /&gt;
&lt;br /&gt;
:*&#039;&#039;&#039;function newmodule_get_participants($newmoduleid)&#039;&#039;&#039;&lt;br /&gt;
:See, lib.php for more details just above the function.&lt;br /&gt;
&lt;br /&gt;
:*&#039;&#039;&#039;function newmodule_scale_used($newmoduleid, $scaleid)&#039;&#039;&#039;&lt;br /&gt;
:See, lib.php for more details just above the function.&lt;br /&gt;
&lt;br /&gt;
:*&#039;&#039;&#039;function newmodule_scale_used_anywhere($scaleid)&#039;&#039;&#039;&lt;br /&gt;
:See, lib.php for more details just above the function.&lt;br /&gt;
&lt;br /&gt;
:*&#039;&#039;&#039;function newmodule_install()&#039;&#039;&#039;&lt;br /&gt;
:See, lib.php for more details just above the function.&lt;br /&gt;
&lt;br /&gt;
:*&#039;&#039;&#039;function newmodule_uninstall()&#039;&#039;&#039;&lt;br /&gt;
:See, lib.php for more details just above the function.&lt;br /&gt;
&lt;br /&gt;
:In my honest opinion some more functions should be added. Among these I want to list:&lt;br /&gt;
&lt;br /&gt;
:*&#039;&#039;&#039;function newmodule_reset_course_form_definition(&amp;amp;$mform)&#039;&#039;&#039;&lt;br /&gt;
:*&#039;&#039;&#039;function newmodule_reset_course_form_defaults($course)&#039;&#039;&#039;&lt;br /&gt;
:*&#039;&#039;&#039;function newmodule_reset_userdata($data)&#039;&#039;&#039;&lt;br /&gt;
:These last three functions are responsible for the mewmodule reset process during the more general course reset process. Please, refer to mod/data/lib.php or to mod/feedback/lib.php, for instance, to understand them better.&lt;br /&gt;
&lt;br /&gt;
:Two more functions should be added to lib.php are, in my opinion:&lt;br /&gt;
:*&#039;&#039;&#039;function newmodule_get_view_actions()&#039;&#039;&#039;&lt;br /&gt;
:*&#039;&#039;&#039;function newmodule_get_post_actions()&#039;&#039;&#039;&lt;br /&gt;
:They distinguish between &amp;quot;read&amp;quot; and &amp;quot;post&amp;quot; log actions.&lt;br /&gt;
:These functions are used by moodle core during log gather.&lt;br /&gt;
:The actions you list inside these two functions, must match the ones you listed in the table &amp;quot;log_display&amp;quot; in install.xml&lt;br /&gt;
&lt;br /&gt;
Still about the lib.php file, it is important to read what is stated at the end of lib.php: &amp;lt;pre&amp;gt;//////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/// Any other newmodule functions go here.  Each of them must have a name that&lt;br /&gt;
/// starts with newmodule_&lt;br /&gt;
/// Remember (see note in first lines) that, if this section grows, it&#039;s HIGHLY&lt;br /&gt;
/// recommended to move all functions below to a new &amp;quot;locallib.php&amp;quot; file.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:One important issue is about the connection between &#039;&#039;&#039;lib.php&#039;&#039;&#039; and &#039;&#039;&#039;locallib.php&#039;&#039;&#039;&lt;br /&gt;
:Who has to call the other, how and why?&lt;br /&gt;
:It has to be locallib.php to call lib.php through: &amp;lt;pre&amp;gt;require_once(&amp;quot;$CFG-&amp;gt;dirroot/mod/newmodule/lib.php&amp;quot;);&amp;lt;/pre&amp;gt;&lt;br /&gt;
:as first line.&lt;br /&gt;
&lt;br /&gt;
:In this way, if moodle core calls function inside mod/newmodule/lib.php no module specific function will be loaded in memory.&lt;br /&gt;
:If it is your newmodule to call a function, it has to require_once(&#039;locallib.php&#039;); that, in turn, will require_once(&#039;lib.php&#039;) so that your module will &amp;quot;see&amp;quot; all its available functions.&lt;br /&gt;
&lt;br /&gt;
09) &#039;&#039;&#039;mod_form.php&#039;&#039;&#039; is the file describing the form you get at the module instance creation or at the instance editing time.&lt;br /&gt;
The syntax is very simple and by reading the file it is simple to change it on your need.&lt;br /&gt;
:It uses the syntax you can learn in:&lt;br /&gt;
:https://docs.moodle.org/en/Development:lib/formslib.php_Form_Definition&lt;br /&gt;
&lt;br /&gt;
:At date, there is a missing detail by the end of the file.&lt;br /&gt;
:You can read:&lt;br /&gt;
&amp;lt;pre&amp;gt;//------------------------------------------------------------------------------&lt;br /&gt;
        // add standard elements, common to all modules&lt;br /&gt;
        $this-&amp;gt;standard_coursemodule_elements();&lt;br /&gt;
//------------------------------------------------------------------------------&amp;lt;/pre&amp;gt;&lt;br /&gt;
:This part is responsible for the common modules section at the end of your newmodule editing instance page. (the section related to groups)&lt;br /&gt;
:This code can be customized by changing it as described below:&lt;br /&gt;
&amp;lt;pre&amp;gt;//------------------------------------------------------------------------------&lt;br /&gt;
        // add standard elements, common to all modules&lt;br /&gt;
        $features = new object();&lt;br /&gt;
        $features-&amp;gt;groups           = false;&lt;br /&gt;
        $features-&amp;gt;groupings        = false;&lt;br /&gt;
        $features-&amp;gt;groupmembersonly = true;&lt;br /&gt;
        $this-&amp;gt;standard_coursemodule_elements($features);&lt;br /&gt;
//------------------------------------------------------------------------------&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One more tip about this file.&lt;br /&gt;
:Once you submit the form described by this file, your module executes the function: newmodule_add_instance or newmodule_update_instance both pre-written in lib.php.&lt;br /&gt;
:It seems that check boxes in the editing instance form don&#039;t work. To test this, please verify the passed parameter $newmodule inside your function newmodule_update_instance through a simple: &amp;lt;pre&amp;gt;print_object($newmodule);&amp;lt;/pre&amp;gt;&lt;br /&gt;
:You will find that even by selecting or unselecting the check box in the newmodule instance editing form, the corresponding value in the array doesn&#039;t change. This is not an error, but at least a lack of code.&lt;br /&gt;
:By adding a simple code like: &amp;lt;pre&amp;gt;$checkboxes = array(&#039;myfirstcheckboxfield&#039;, &#039;mysecondcheckboxfield&#039;, and so fort with all your checkbox field);&lt;br /&gt;
foreach ($checkboxes as $checkbox) {&lt;br /&gt;
    if (empty($newmodule-&amp;gt;{$checkbox})) {&lt;br /&gt;
        $newmodule-&amp;gt;{$checkbox} = 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
:at the beginning of both functions, you will find that all works fine.&lt;br /&gt;
&lt;br /&gt;
10) &#039;&#039;&#039;README.txt&#039;&#039;&#039; is the file where you are welcome to write what your newmodule does.&lt;br /&gt;
&lt;br /&gt;
11) &#039;&#039;&#039;version.php&#039;&#039;&#039; is a really very simple file as simple as important.&lt;br /&gt;
To understand why it is important, you need to know that there are a bunch of actions that moodle performs for your newmodule ONLY (with only one exception) at the newmodule installation. They are, at least, db tables editing and load of capability. If during the development of your module (that you already installed on your development environment or that you already shared with remote users) you need to change the structure of your newmodule tables or you need to change the capability used by your newmodule, you need to force moodle to edit tables and reload capability. This is done by:&lt;br /&gt;
:* adding the proper code in newmodule/db/upgrade.php (to do this, use XMLDB as stated in this same page below)&lt;br /&gt;
:* increasing the newmodule version.&lt;br /&gt;
:* visiting the notification page of your installation of Moodle.&lt;br /&gt;
&lt;br /&gt;
12) &#039;&#039;&#039;view.php&#039;&#039;&#039; is the first executed code of your module. By selecting the link of the instance of your module, the code of newmodule/view.php is executed.&lt;br /&gt;
&lt;br /&gt;
== Some very important missing files ==&lt;br /&gt;
There are five files that are not present in the newmodule package that 90% of times you will go to add to your newmodule.&lt;br /&gt;
&lt;br /&gt;
1. The first one is locallib.php already described before.&lt;br /&gt;
&lt;br /&gt;
2. The second one is access.php that has to be saved inside newmodule/db/ folder.&lt;br /&gt;
:In this file you will add all the capability used by your newmodule and loaded at the installation time or upgrade time. To learn the syntax of the capability, please refer to the same file in other modules or to: https://docs.moodle.org/en/Development:NEWMODULE_Adding_capabilities&lt;br /&gt;
3. The third missing file must be added to newmodule/ folder. It is settings.php and describes the form that can be accessed from: Site Administration block -&amp;gt; Modules -&amp;gt; Activities -&amp;gt; &amp;lt;&amp;lt;your newmodule name&amp;gt;&amp;gt;&lt;br /&gt;
:This form stores general settings for your newmodule into the site wide $CFG object. Because of this, it is strongly recommended to give to your newmodule general settings with names starting with &amp;quot;newmodule_&amp;quot;. This file is useful when there is a setting that doesn&#039;t depend from the instance. I.e., if your newmodule simulates a telephone, you will probably save your telephone number in this newmodule setting site wide form instead of typing it each time you add a new instance of your newmodule into a course. In this case, to refer to you telephone number inside your newmodule you will use: $CFG-&amp;gt;newmodule_telephonenumber&lt;br /&gt;
4. Directly in the newmodule folder, you need to add backuplib.php that is responsible for the backup of each instance of your module and of its log.&lt;br /&gt;
:To learn how to code it, start by stealing it from some other module and read it.&lt;br /&gt;
5. Again in the newmodule folder, you need to add restorelib.php that is responsible for the restore of each instance your module and of its log.&lt;br /&gt;
:To learn how to code it, start by stealing it from some other module and read it.&lt;br /&gt;
&lt;br /&gt;
==Let&#039;s start==&lt;br /&gt;
To start using a downloaded package, please perform the 7 actions described in https://docs.moodle.org/en/Development:NEWMODULE_Tutorial in How to Begin the Creation of a New Module paragraph.&lt;br /&gt;
&lt;br /&gt;
Then, draw the structure of your tables on a sheet, edit the file db/install.xml according to your project, save, put your renamed newmodule folder in moodle/mod/ and visit the moodle notification page.&lt;br /&gt;
&lt;br /&gt;
To add code to db/upgrade.php never do it manually. I always make use of Site Administration block -&amp;gt; Miscellaneous -&amp;gt; XMLDB editor and I ask it to write the code for me. It never fails.&lt;br /&gt;
&lt;br /&gt;
Please remember: within your module, never use &amp;quot;embedded messages&amp;quot; like:&lt;br /&gt;
&amp;lt;pre&amp;gt;echo &#039;Welcome to this newmodule&#039;;&amp;lt;/pre&amp;gt;&lt;br /&gt;
but make use of get_string or print_string. In this way your module will be multilang with a really small effort.&lt;br /&gt;
Use, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;print_string(&#039;welcomemessage&#039;,&#039;newmodule&#039;);&amp;lt;/pre&amp;gt;&lt;br /&gt;
saving in newmodule/lang/en_utf8/newmodule.php&lt;br /&gt;
&amp;lt;pre&amp;gt;$string[&#039;welcomemessage&#039;] = &#039;Welcome to this newmodule&#039;;&amp;lt;/pre&amp;gt;&lt;br /&gt;
==Some code snippets that I find useful==&lt;br /&gt;
&#039;&#039;&#039;**To check the capability of a user&#039;&#039;&#039;, try:&lt;br /&gt;
&amp;lt;pre&amp;gt;if (newmodule_hascapabilitytodothis()) {&lt;br /&gt;
    //user is allowed&lt;br /&gt;
} else {&lt;br /&gt;
    // user is not allowed&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
typing in locallib.php&lt;br /&gt;
&amp;lt;pre&amp;gt;function newmodule_hascapabilitytodothis($cm) {&lt;br /&gt;
    $context = get_context_instance(CONTEXT_MODULE, $cm-&amp;gt;id);&lt;br /&gt;
&lt;br /&gt;
    return (has_capability(&#039;mod/newmodule:candothis&#039;, $context));&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
typing in db/access.php&lt;br /&gt;
&amp;lt;pre&amp;gt;$mod_newmodule_capabilities = array(&lt;br /&gt;
    &#039;mod/newmodule:candothis&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;captype&#039; =&amp;gt; &#039;read&#039;,&lt;br /&gt;
        &#039;contextlevel&#039; =&amp;gt; CONTEXT_MODULE,&lt;br /&gt;
        &#039;legacy&#039; =&amp;gt; array(&lt;br /&gt;
            &#039;teacher&#039; =&amp;gt; CAP_ALLOW,&lt;br /&gt;
            &#039;editingteacher&#039; =&amp;gt; CAP_ALLOW,&lt;br /&gt;
            &#039;admin&#039; =&amp;gt; CAP_ALLOW&lt;br /&gt;
        )&lt;br /&gt;
    )&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;To edit the tables in use by your newmodule&#039;&#039;&#039;, try:&lt;br /&gt;
* edit install.xml manually by editing fields and or tables in the xml structure.&lt;br /&gt;
* go to Site Administration block -&amp;gt; Miscellaneous -&amp;gt; XMLDB editor and load the tables of your module&lt;br /&gt;
* ask to the XMLDB editor the snippets of code you need to add to db/upgrade.php&lt;br /&gt;
* copy and paste in db/upgrade.php&lt;br /&gt;
* in the line: if ($result &amp;amp;&amp;amp; $oldversion &amp;lt; xxxxxxxxxxxx), (replace xxxxxxxxxxxx with the version number you are going to give to your newmodule)&lt;br /&gt;
* change (increase) the version number&lt;br /&gt;
* visit the Moodle notification page&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;To add a single line to logs from your mewmodule&#039;&#039;&#039;, try:&lt;br /&gt;
&amp;lt;pre&amp;gt;add_to_log($course-&amp;gt;id, &#039;newmodule&#039;, &#039;&amp;lt;&amp;lt;action already listed in log_display&amp;gt;&amp;gt;&#039;, &amp;quot;view.php?id=$cm-&amp;gt;id&amp;quot;, &amp;quot;$newmodule-&amp;gt;id&amp;quot;);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;To be sure that remote user will not be able to contact your pages by typing their URL directly in the address bar&#039;&#039;&#039;, try:&lt;br /&gt;
&lt;br /&gt;
as first line of each of your php script&lt;br /&gt;
&amp;lt;pre&amp;gt;defined(&#039;NEWMODULE_INCLUDE_TEST&#039;) OR die(&#039;not allowed&#039;);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
typing in lib.php, at the beginning&lt;br /&gt;
&amp;lt;pre&amp;gt;define(&#039;NEWMODULE_INCLUDE_TEST&#039;, 1);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Some suggestion I find useful==&lt;br /&gt;
&#039;&#039;&#039;To include php scripts&#039;&#039;&#039;, try:&lt;br /&gt;
&amp;lt;pre&amp;gt;require_once(myscript.php);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;To include php library&#039;&#039;&#039;, try:&lt;br /&gt;
&amp;lt;pre&amp;gt;require_once(&#039;locallib.php&#039;);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;To periodically execute function newmodule_cron()&#039;&#039;&#039;, try:&lt;br /&gt;
&amp;lt;pre&amp;gt;$module-&amp;gt;cron = xxxx;&amp;lt;/pre&amp;gt;&lt;br /&gt;
providing some code in: &amp;lt;pre&amp;gt;function newmodule_cron()&amp;lt;/pre&amp;gt;&lt;br /&gt;
Your function newmodule_cron() will be executed about each xxxx seconds&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Do not include config when it is not needed&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;require_once(&#039;config.php&#039;)&amp;lt;/pre&amp;gt;&lt;br /&gt;
is not needed in library scripts&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Do not use global $cm or $newmodule in your function&#039;&#039;&#039;&lt;br /&gt;
but use proper function parameters.&lt;br /&gt;
&lt;br /&gt;
So, never use:&lt;br /&gt;
&amp;lt;pre&amp;gt;function newmodule_lookatthesky() {&lt;br /&gt;
    global $cm, $newmodule;&lt;br /&gt;
    &lt;br /&gt;
    // your stuff&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
but use: &lt;br /&gt;
&amp;lt;pre&amp;gt;function newmodule_lookatthesky($cm, $newmodule) {&lt;br /&gt;
    &lt;br /&gt;
    // your stuff&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://dev.moodle.org/course/view.php?id=2 Moodle Developers&#039; Course]&lt;br /&gt;
* [[Development:Modules]]&lt;br /&gt;
* [[Development:Places to search for lang strings|Where to put language strings for your plugin]]&lt;br /&gt;
* [[Development:Installing and upgrading plugin database tables|Defining the database tables for your plugin]]&lt;br /&gt;
&lt;br /&gt;
{{CategoryDeveloper}}&lt;br /&gt;
[[Category:Developer|Modules]]&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=IMS_content_package&amp;diff=54545</id>
		<title>IMS content package</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=IMS_content_package&amp;diff=54545"/>
		<updated>2009-04-20T16:00:53Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: /* IMS content package repository */  Added notes about deployment size and deploying IMSCPs from a repository.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Resources}}&lt;br /&gt;
{{Moodle 1.6}}&lt;br /&gt;
&lt;br /&gt;
IMS is a body which helps define technical standards for various things, including e-learning material. The [http://www.imsglobal.org/content/packaging/ IMS Content Packaging specification] makes it possible to store chunks of material in a standard format which can be re-used in different systems, without having to convert the material into new formats.&lt;br /&gt;
&lt;br /&gt;
The IMS content package in Moodle 1.6 enables such content packages to be uploaded and included in Moodle courses. There are various options for displaying content in a pop-up window, with a navigation menu or buttons etc. In addition, the resource type supports an optional repository, enabling content packages to be shared between courses.&lt;br /&gt;
&lt;br /&gt;
==IMS content package repository==&lt;br /&gt;
&lt;br /&gt;
The IMS content package repository enables access to a repository of IMS and SCORM packages within Moodle.&lt;br /&gt;
&lt;br /&gt;
Using the repository will save disk space (and any corresponding backup resources if you copy the filesystem as part of your backup strategy) compared to uploading content packages directly into a course. The repository only needs an unzipped copy of the package, whereas within a course there will be the unzipped copy, plus two zipped copies just taking up space.&lt;br /&gt;
&lt;br /&gt;
===Using the repository===&lt;br /&gt;
&lt;br /&gt;
The repository is disabled by default. It may be enabled as follows:&lt;br /&gt;
&lt;br /&gt;
# Find repository_config.php in &#039;&#039;moodle/mod/resource/type/ims&#039;&#039; and change &amp;lt;code&amp;gt;$CFG-&amp;gt;repositoryactivate = false;&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;$CFG-&amp;gt;repositoryactivate = true&amp;lt;/code&amp;gt;&lt;br /&gt;
# Create a folder named &#039;&#039;ims_repository&#039;&#039; in the webroot or somewhere underneath your webroot.&lt;br /&gt;
# Change &amp;lt;code&amp;gt;$CFG-&amp;gt;repository = &amp;quot;C:/public/www/html/ims_repository&amp;quot;;&amp;lt;/code&amp;gt; to point to this folder on your file system&lt;br /&gt;
# If your ims_repository is not located directly in your webroot, edit &amp;lt;code&amp;gt;$CFG-&amp;gt;repositorywebroot = &amp;quot;/ims_repository&amp;quot;;&amp;lt;/code&amp;gt; to point to the location of your repository.&lt;br /&gt;
&lt;br /&gt;
Content packages should be extracted to the folder &#039;&#039;ims_repository&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
To use a repository package in a course:&lt;br /&gt;
# Create/edit an IMS CP resource.&lt;br /&gt;
# Click the &amp;quot;Browse repository&amp;quot; button, opening a window listing the packages in &#039;&#039;ims_repository&#039;&#039;. If you can&#039;t see your content package, check it&#039;s in the right directory and has been unzipped.&lt;br /&gt;
# Find your package in the list and click Deploy, and you get a chance to preview the resource. Close the window.&lt;br /&gt;
# Click the &amp;quot;Browse repository&amp;quot; button again, and then and Choose the package.&lt;br /&gt;
# Save your IMS CP resource.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://www.nln.ac.uk/?p=Moodle NLN Materials - Support: Using the NLN Materials in Moodle]&lt;br /&gt;
&lt;br /&gt;
Using Moodle forum discussions:&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=31011 New resource type: IMS CP]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=86101 What is an IMS package?]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=48684 Trying to add NLN Materials via IMS CP]&lt;br /&gt;
&lt;br /&gt;
[[Category:Administrator]]&lt;br /&gt;
[[Category:Resource]]&lt;br /&gt;
&lt;br /&gt;
[[de:IMS-Paket]]&lt;br /&gt;
[[eu:Baliabidea:IMS]]&lt;br /&gt;
[[es:Recurso: IMS]]&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=Development:Filters_schema&amp;diff=23036</id>
		<title>Development:Filters schema</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=Development:Filters_schema&amp;diff=23036"/>
		<updated>2007-05-04T08:37:21Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The objective of this page is to document all the ideas and improvements to be implemented in the &amp;quot;Filters&amp;quot; functionality of Moodle.&lt;br /&gt;
&lt;br /&gt;
Every idea will be documented here, including its associated &amp;quot;thoughts&amp;quot; and potential &amp;quot;implementations&amp;quot;. Feel free to add/modify everything as you want!&lt;br /&gt;
&lt;br /&gt;
These are the main areas to discuss/analyse/implement:&lt;br /&gt;
&lt;br /&gt;
* [[Course/site filters | Enable/Disable Filters by Course and Site]]&lt;br /&gt;
* [[Course/site filter config | Optional Configuration of Filters by Course and Site]]&lt;br /&gt;
* [[Multilang filter | Changes in the Caching System to Support the Multilang Filter]]&lt;br /&gt;
* [[Enable/Disable Filters by Activities]]&lt;br /&gt;
* Allow filtering data before it will save in database? It will do possible exclude some data from text (like TeX formulas) and save in separate table. It will allow change formula by clicking on it and open popup window.&lt;br /&gt;
* It&#039;d be great if you could set the text cache lifetime for individual filters. This would be handy for filters that use external resources (e.g., Wikipedia) that sometimes have slow response times. I&#039;d guess that you could use a cache lifetime of a week or more for a Wikipedia filter without causing major usability problems.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[http://moodle.org/bugs/bug.php?op=show&amp;amp;bugid=2400 Bug 2400] - a lot of ideas and request have been written here&lt;br /&gt;
http://tracker.moodle.org/browse/MDL-9443 - add support for filtering XHTML resources as well as HTML.&lt;br /&gt;
[[Category:Developer]]&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/403/en/index.php?title=Development:Course/site_filter_config&amp;diff=22516</id>
		<title>Development:Course/site filter config</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/403/en/index.php?title=Development:Course/site_filter_config&amp;diff=22516"/>
		<updated>2007-04-18T10:37:14Z</updated>

		<summary type="html">&lt;p&gt;Davidbalch: Added config idea.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This topic is to define how to add the possibility of &amp;quot;configure&amp;quot; filters both at site and course level.&lt;br /&gt;
&lt;br /&gt;
* The mp3player may be configured at site level to only start downloading when the play button is pressed.&lt;br /&gt;
* The filters could configured to apply to classes of files by MIME type and/or file extension.&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer]]&lt;/div&gt;</summary>
		<author><name>Davidbalch</name></author>
	</entry>
</feed>