<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/21/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tbachert</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/21/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tbachert"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/21/en/Special:Contributions/Tbachert"/>
	<updated>2026-04-22T14:27:52Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/21/en/index.php?title=Upload_users&amp;diff=86234</id>
		<title>Upload users</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/21/en/index.php?title=Upload_users&amp;diff=86234"/>
		<updated>2011-07-21T15:50:37Z</updated>

		<summary type="html">&lt;p&gt;Tbachert: /* Upload users file format */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Accounts}}&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Please refer to [[TOC_with_notes#Accounts|these notes]] before editing this page.&#039;&#039;&#039;&amp;lt;/p&amp;gt;&lt;br /&gt;
Location: &#039;&#039;Administration &amp;gt; Users &amp;gt; Accounts &amp;gt; Upload users&#039;&#039;&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 users file format==&lt;br /&gt;
&lt;br /&gt;
* Each line contains fields &#039;&#039;&#039;separated&#039;&#039;&#039; by commas (or other delimiters) without quotes (&amp;quot;) and no trailing delimiter&lt;br /&gt;
* The first line is special, and contains fieldnames defining the format for the rest of the file.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Required fields&#039;&#039;&#039;:  In any order&lt;br /&gt;
:&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;username, firstname, lastname, email&amp;lt;/code&amp;gt;&lt;br /&gt;
:Validity checks are performed for:&lt;br /&gt;
#&amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt; can only contain alphabetical &#039;&#039;&#039;lowercase&#039;&#039;&#039; letters , numbers, hypen &#039;-&#039;, underscore &#039;_&#039;, period &#039;.&#039;, or at-sign &#039;@&#039; &lt;br /&gt;
#&amp;lt;code&amp;gt;email&amp;lt;/code&amp;gt; is in the form: &#039;&#039;name@example.com&#039;&#039; .&amp;lt;/p&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Password field&#039;&#039;&#039;: &amp;quot;password&amp;quot; field is optional if &amp;quot;Create password if needed&amp;quot; setting is chosen (default). &lt;br /&gt;
**If included, values should meet the requirements for the site&#039;s [[Site_policies#Password_policy|Password policy]]. To force password change for a particular user, set the password field to &amp;lt;code&amp;gt;changeme&amp;lt;/code&amp;gt;. &lt;br /&gt;
**If omitted, a password will be generated for each user (during the next Cron job) and welcome e-mails sent out (not working in v2.0.2?).&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Optional fields&#039;&#039;&#039;: To provide values other than the default include one or more of these&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, emailstop, htmleditor, autosubscribe&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 shortname)&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;
: Create the custom fields BEFORE importing. Use the standard header. The &amp;quot;shortname&amp;quot; for your custom field is xxxxx (NB: as at v2.0.2, the shortname must be all lowercase, otherwise won&#039;t be recognised). The first record must include &amp;quot;profile_field_xxxxx&amp;quot;.&lt;br /&gt;
:&#039;&#039;&#039;Example&#039;&#039;&#039;: To create a custom field &amp;quot;genre&amp;quot;, 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 fields&#039;&#039;&#039;: Used for changing of usernames or deleting of users&lt;br /&gt;
:&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;oldusername&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;deleted&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
*&#039;&#039;&#039;Enrolment fields&#039;&#039;&#039;: (Optional):&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.&lt;br /&gt;
**&amp;lt;code&amp;gt;course&amp;lt;/code&amp;gt; is the &amp;quot;shortname&amp;quot;  if present the user will be enrolled in those courses.&lt;br /&gt;
** &amp;lt;code&amp;gt;type&amp;lt;/code&amp;gt; refers to the 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;
*** A group is identified by name or id (numeric group names are not supported).&lt;br /&gt;
** From Moodle 2.0, you can set the enrolment duration, in days, for each course (&amp;lt;code&amp;gt;enrolperiod1&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;course1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;enrolperiod2&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;course2&amp;lt;/code&amp;gt;, etc.).&lt;br /&gt;
&lt;br /&gt;
Commas within  a field must be encoded as &amp;amp;#44 - the script will decode these back to commas.&lt;br /&gt;
&lt;br /&gt;
For Boolean fields, use &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; for false and &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; for true.&lt;br /&gt;
&lt;br /&gt;
To prevent users from receiving a large number of emails from courses or forced subscription forums use the &#039;&#039;&#039;maildigest&#039;&#039;&#039;.  The options for this field 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 upload file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;username, password, firstname, lastname, email, emailstop, course1, group1&amp;lt;br /&amp;gt;&lt;br /&gt;
jonest, verysecret, Tom, Jones, jonest@someplace.edu, 1, math102, Section 1&amp;lt;br /&amp;gt;&lt;br /&gt;
reznort, somesecret, Trent, Reznor, reznort@someplace.edu, 1, math102, Section 3&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Updating existing accounts==&lt;br /&gt;
By default Moodle  creates new user accounts, and skips lines where the &amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt; matches an existing account. Set &amp;quot;Upload Type&amp;quot; to &#039;&#039;&#039;Add  new and update existing accounts&#039;&#039;&#039;, and existing user account will be updated.&lt;br /&gt;
&lt;br /&gt;
Include  fieldname &amp;lt;code&amp;gt;oldusername&amp;lt;/code&amp;gt; to updating existing accounts and change usernames.  In the preview options, Set &amp;quot;Allow renames&amp;quot; to &#039;&#039;&#039;Yes&#039;&#039;. &lt;br /&gt;
&#039;&#039;&#039;Warning&#039;&#039;&#039;: errors updating existing accounts can affect your users badly. Be careful when using the options to update.&lt;br /&gt;
&lt;br /&gt;
==After preview==&lt;br /&gt;
After the preprocessing, depending on the contents of the upload, the following may be available before final user creation&lt;br /&gt;
*Settings&lt;br /&gt;
** New user password &lt;br /&gt;
** Existing user details&lt;br /&gt;
** Existing user password&lt;br /&gt;
** Allow renames&lt;br /&gt;
** Allow deletes&lt;br /&gt;
** Prevent email addess duplicates&lt;br /&gt;
** Select for bulk operations&lt;br /&gt;
&lt;br /&gt;
* Default values&lt;br /&gt;
** Authentication method: Manual account |no login | EMail-based self-registration&lt;br /&gt;
** Email display: Allow only other course members to see my email address | hide .. from everyone | allow anyone ...&lt;br /&gt;
** Email format Pretty HTML | plain text&lt;br /&gt;
** Email digest type: none|complete subjects&lt;br /&gt;
** Forum auto-subscribe: no |yes when  I post&lt;br /&gt;
** When editing text: use HTML| standard web forms&lt;br /&gt;
** AJAX and Javascript: yes|no&lt;br /&gt;
** city/town&lt;br /&gt;
** country&lt;br /&gt;
** timezone&lt;br /&gt;
** Preferred language&lt;br /&gt;
** Description&lt;br /&gt;
** Web page&lt;br /&gt;
** ID number&lt;br /&gt;
** Institution&lt;br /&gt;
** Department&lt;br /&gt;
** Phone&lt;br /&gt;
** Mobile Phone&lt;br /&gt;
** Address&lt;br /&gt;
&lt;br /&gt;
==After results ==&lt;br /&gt;
Users which were not added, will NOT be auto-enrolled in courses&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Open another moodle browser and &lt;br /&gt;
* Site administration&lt;br /&gt;
** Courses&lt;br /&gt;
*** Add/edit courses; select the category, and the course&lt;br /&gt;
* Course administration&lt;br /&gt;
** Users&lt;br /&gt;
*** Enrolled Users&lt;br /&gt;
**** Enrol users and select the users flagged from other window&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;
&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;. After uploading the file, be sure to change the &amp;quot;Upload type&amp;quot; to &amp;quot;Update existing users only&amp;quot; and the &amp;quot;Allow deletes&amp;quot; option to &amp;quot;Yes&amp;quot;.&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=181259 User upload option: standardise usernames]&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>Tbachert</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/21/en/index.php?title=Upload_users&amp;diff=86232</id>
		<title>Upload users</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/21/en/index.php?title=Upload_users&amp;diff=86232"/>
		<updated>2011-07-21T15:24:44Z</updated>

		<summary type="html">&lt;p&gt;Tbachert: /* Upload users file format */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Accounts}}&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Please refer to [[TOC_with_notes#Accounts|these notes]] before editing this page.&#039;&#039;&#039;&amp;lt;/p&amp;gt;&lt;br /&gt;
Location: &#039;&#039;Administration &amp;gt; Users &amp;gt; Accounts &amp;gt; Upload users&#039;&#039;&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 users file format==&lt;br /&gt;
&lt;br /&gt;
* Each line contains fields &#039;&#039;&#039;separated&#039;&#039;&#039; by commas (or other delimiters) without quotes (&amp;quot;) and no trailing delimiter&lt;br /&gt;
* The first line is special, and contains fieldnames defining the format for the rest of the file.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Required fields&#039;&#039;&#039;:  In any order&lt;br /&gt;
:&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;username, firstname, lastname, email&amp;lt;/code&amp;gt;&lt;br /&gt;
:Validity checks are performed for:&lt;br /&gt;
#&amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt; can only contain alphabetical &#039;&#039;&#039;lowercase&#039;&#039;&#039; letters , numbers, hypen &#039;-&#039;, underscore &#039;_&#039;, period &#039;.&#039;, or at-sign &#039;@&#039; &lt;br /&gt;
#&amp;lt;code&amp;gt;email&amp;lt;/code&amp;gt; is in the form: &#039;&#039;name@example.com&#039;&#039; .&amp;lt;/p&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Password field&#039;&#039;&#039;: &amp;quot;password&amp;quot; field is optional if &amp;quot;Create password if needed&amp;quot; setting is chosen (default). &lt;br /&gt;
**If included, values should meet the requirements for the site&#039;s [[Site_policies#Password_policy|Password policy]]. To force password change for a particular user, set the password field to &amp;lt;code&amp;gt;changeme&amp;lt;/code&amp;gt;. &lt;br /&gt;
**If omitted, a password will be generated for each user (during the next Cron job) and welcome e-mails sent out (not working in v2.0.2?).&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Optional fields&#039;&#039;&#039;: To provide values other than the default include one or more of these&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, mailstop, htmleditor, autosubscribe&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 shortname)&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;
: Create the custom fields BEFORE importing. Use the standard header. The &amp;quot;shortname&amp;quot; for your custom field is xxxxx (NB: as at v2.0.2, the shortname must be all lowercase, otherwise won&#039;t be recognised). The first record must include &amp;quot;profile_field_xxxxx&amp;quot;.&lt;br /&gt;
:&#039;&#039;&#039;Example&#039;&#039;&#039;: To create a custom field &amp;quot;genre&amp;quot;, 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 fields&#039;&#039;&#039;: Used for changing of usernames or deleting of users&lt;br /&gt;
:&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;oldusername&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;deleted&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
*&#039;&#039;&#039;Enrolment fields&#039;&#039;&#039;: (Optional):&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.&lt;br /&gt;
**&amp;lt;code&amp;gt;course&amp;lt;/code&amp;gt; is the &amp;quot;shortname&amp;quot;  if present the user will be enrolled in those courses.&lt;br /&gt;
** &amp;lt;code&amp;gt;type&amp;lt;/code&amp;gt; refers to the 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;
*** A group is identified by name or id (numeric group names are not supported).&lt;br /&gt;
** From Moodle 2.0, you can set the enrolment duration, in days, for each course (&amp;lt;code&amp;gt;enrolperiod1&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;course1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;enrolperiod2&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;course2&amp;lt;/code&amp;gt;, etc.).&lt;br /&gt;
&lt;br /&gt;
Commas within  a field must be encoded as &amp;amp;#44 - the script will decode these back to commas.&lt;br /&gt;
&lt;br /&gt;
For Boolean fields, use &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; for false and &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; for true.&lt;br /&gt;
&lt;br /&gt;
To prevent users from receiving a large number of emails from courses or forced subscription forums use the &#039;&#039;&#039;maildigest&#039;&#039;&#039;.  The options for this field 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 upload file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;username, password, firstname, lastname, email, mailstop, course1, group1&amp;lt;br /&amp;gt;&lt;br /&gt;
jonest, verysecret, Tom, Jones, jonest@someplace.edu, 1, math102, Section 1&amp;lt;br /&amp;gt;&lt;br /&gt;
reznort, somesecret, Trent, Reznor, reznort@someplace.edu, 1, math102, Section 3&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Updating existing accounts==&lt;br /&gt;
By default Moodle  creates new user accounts, and skips lines where the &amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt; matches an existing account. Set &amp;quot;Upload Type&amp;quot; to &#039;&#039;&#039;Add  new and update existing accounts&#039;&#039;&#039;, and existing user account will be updated.&lt;br /&gt;
&lt;br /&gt;
Include  fieldname &amp;lt;code&amp;gt;oldusername&amp;lt;/code&amp;gt; to updating existing accounts and change usernames.  In the preview options, Set &amp;quot;Allow renames&amp;quot; to &#039;&#039;&#039;Yes&#039;&#039;. &lt;br /&gt;
&#039;&#039;&#039;Warning&#039;&#039;&#039;: errors updating existing accounts can affect your users badly. Be careful when using the options to update.&lt;br /&gt;
&lt;br /&gt;
==After preview==&lt;br /&gt;
After the preprocessing, depending on the contents of the upload, the following may be available before final user creation&lt;br /&gt;
*Settings&lt;br /&gt;
** New user password &lt;br /&gt;
** Existing user details&lt;br /&gt;
** Existing user password&lt;br /&gt;
** Allow renames&lt;br /&gt;
** Allow deletes&lt;br /&gt;
** Prevent email addess duplicates&lt;br /&gt;
** Select for bulk operations&lt;br /&gt;
&lt;br /&gt;
* Default values&lt;br /&gt;
** Authentication method: Manual account |no login | EMail-based self-registration&lt;br /&gt;
** Email display: Allow only other course members to see my email address | hide .. from everyone | allow anyone ...&lt;br /&gt;
** Email format Pretty HTML | plain text&lt;br /&gt;
** Email digest type: none|complete subjects&lt;br /&gt;
** Forum auto-subscribe: no |yes when  I post&lt;br /&gt;
** When editing text: use HTML| standard web forms&lt;br /&gt;
** AJAX and Javascript: yes|no&lt;br /&gt;
** city/town&lt;br /&gt;
** country&lt;br /&gt;
** timezone&lt;br /&gt;
** Preferred language&lt;br /&gt;
** Description&lt;br /&gt;
** Web page&lt;br /&gt;
** ID number&lt;br /&gt;
** Institution&lt;br /&gt;
** Department&lt;br /&gt;
** Phone&lt;br /&gt;
** Mobile Phone&lt;br /&gt;
** Address&lt;br /&gt;
&lt;br /&gt;
==After results ==&lt;br /&gt;
Users which were not added, will NOT be auto-enrolled in courses&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Open another moodle browser and &lt;br /&gt;
* Site administration&lt;br /&gt;
** Courses&lt;br /&gt;
*** Add/edit courses; select the category, and the course&lt;br /&gt;
* Course administration&lt;br /&gt;
** Users&lt;br /&gt;
*** Enrolled Users&lt;br /&gt;
**** Enrol users and select the users flagged from other window&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;
&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;. After uploading the file, be sure to change the &amp;quot;Upload type&amp;quot; to &amp;quot;Update existing users only&amp;quot; and the &amp;quot;Allow deletes&amp;quot; option to &amp;quot;Yes&amp;quot;.&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=181259 User upload option: standardise usernames]&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>Tbachert</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/21/en/index.php?title=Upload_users&amp;diff=86231</id>
		<title>Upload users</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/21/en/index.php?title=Upload_users&amp;diff=86231"/>
		<updated>2011-07-21T15:21:01Z</updated>

		<summary type="html">&lt;p&gt;Tbachert: /* Upload users file format */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Accounts}}&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Please refer to [[TOC_with_notes#Accounts|these notes]] before editing this page.&#039;&#039;&#039;&amp;lt;/p&amp;gt;&lt;br /&gt;
Location: &#039;&#039;Administration &amp;gt; Users &amp;gt; Accounts &amp;gt; Upload users&#039;&#039;&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 users file format==&lt;br /&gt;
&lt;br /&gt;
* Each line contains fields &#039;&#039;&#039;separated&#039;&#039;&#039; by commas (or other delimiters) without quotes (&amp;quot;) and no trailing delimiter&lt;br /&gt;
* The first line is special, and contains fieldnames defining the format for the rest of the file.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Required fields&#039;&#039;&#039;:  In any order&lt;br /&gt;
:&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;username, firstname, lastname, email&amp;lt;/code&amp;gt;&lt;br /&gt;
:Validity checks are performed for:&lt;br /&gt;
#&amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt; can only contain alphabetical &#039;&#039;&#039;lowercase&#039;&#039;&#039; letters , numbers, hypen &#039;-&#039;, underscore &#039;_&#039;, period &#039;.&#039;, or at-sign &#039;@&#039; &lt;br /&gt;
#&amp;lt;code&amp;gt;email&amp;lt;/code&amp;gt; is in the form: &#039;&#039;name@example.com&#039;&#039; .&amp;lt;/p&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Password field&#039;&#039;&#039;: &amp;quot;password&amp;quot; field is optional if &amp;quot;Create password if needed&amp;quot; setting is chosen (default). &lt;br /&gt;
**If included, values should meet the requirements for the site&#039;s [[Site_policies#Password_policy|Password policy]]. To force password change for a particular user, set the password field to &amp;lt;code&amp;gt;changeme&amp;lt;/code&amp;gt;. &lt;br /&gt;
**If omitted, a password will be generated for each user (during the next Cron job) and welcome e-mails sent out (not working in v2.0.2?).&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Optional fields&#039;&#039;&#039;: To provide values other than the default include one or more of these&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, mailstop, htmleditor, autosubscribe&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 shortname)&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;
: Create the custom fields BEFORE importing. Use the standard header. The &amp;quot;shortname&amp;quot; for your custom field is xxxxx (NB: as at v2.0.2, the shortname must be all lowercase, otherwise won&#039;t be recognised). The first record must include &amp;quot;profile_field_xxxxx&amp;quot;.&lt;br /&gt;
:&#039;&#039;&#039;Example&#039;&#039;&#039;: To create a custom field &amp;quot;genre&amp;quot;, 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 fields&#039;&#039;&#039;: Used for changing of usernames or deleting of users&lt;br /&gt;
:&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;oldusername&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;deleted&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
*&#039;&#039;&#039;Enrolment fields&#039;&#039;&#039;: (Optional):&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.&lt;br /&gt;
**&amp;lt;code&amp;gt;course&amp;lt;/code&amp;gt; is the &amp;quot;shortname&amp;quot;  if present the user will be enrolled in those courses.&lt;br /&gt;
** &amp;lt;code&amp;gt;type&amp;lt;/code&amp;gt; refers to the 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;
*** A group is identified by name or id (numeric group names are not supported).&lt;br /&gt;
** From Moodle 2.0, you can set the enrolment duration, in days, for each course (&amp;lt;code&amp;gt;enrolperiod1&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;course1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;enrolperiod2&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;course2&amp;lt;/code&amp;gt;, etc.).&lt;br /&gt;
&lt;br /&gt;
Commas within  a field must be encoded as &amp;amp;#44 - the script will decode these back to commas.&lt;br /&gt;
&lt;br /&gt;
For Boolean fields, use &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; for false and &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; for true.&lt;br /&gt;
&lt;br /&gt;
To prevent users from receiving a large number of emails from courses or forced subscription forums use the &#039;&#039;&#039;maildigest&#039;&#039;&#039;.  The options for this field 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 upload file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;username, password, firstname, lastname, email, course1, group1&amp;lt;br /&amp;gt;&lt;br /&gt;
jonest, verysecret, Tom, Jones, jonest@someplace.edu, math102, Section 1&amp;lt;br /&amp;gt;&lt;br /&gt;
reznort, somesecret, Trent, Reznor, reznort@someplace.edu,math102, Section 3&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Updating existing accounts==&lt;br /&gt;
By default Moodle  creates new user accounts, and skips lines where the &amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt; matches an existing account. Set &amp;quot;Upload Type&amp;quot; to &#039;&#039;&#039;Add  new and update existing accounts&#039;&#039;&#039;, and existing user account will be updated.&lt;br /&gt;
&lt;br /&gt;
Include  fieldname &amp;lt;code&amp;gt;oldusername&amp;lt;/code&amp;gt; to updating existing accounts and change usernames.  In the preview options, Set &amp;quot;Allow renames&amp;quot; to &#039;&#039;&#039;Yes&#039;&#039;. &lt;br /&gt;
&#039;&#039;&#039;Warning&#039;&#039;&#039;: errors updating existing accounts can affect your users badly. Be careful when using the options to update.&lt;br /&gt;
&lt;br /&gt;
==After preview==&lt;br /&gt;
After the preprocessing, depending on the contents of the upload, the following may be available before final user creation&lt;br /&gt;
*Settings&lt;br /&gt;
** New user password &lt;br /&gt;
** Existing user details&lt;br /&gt;
** Existing user password&lt;br /&gt;
** Allow renames&lt;br /&gt;
** Allow deletes&lt;br /&gt;
** Prevent email addess duplicates&lt;br /&gt;
** Select for bulk operations&lt;br /&gt;
&lt;br /&gt;
* Default values&lt;br /&gt;
** Authentication method: Manual account |no login | EMail-based self-registration&lt;br /&gt;
** Email display: Allow only other course members to see my email address | hide .. from everyone | allow anyone ...&lt;br /&gt;
** Email format Pretty HTML | plain text&lt;br /&gt;
** Email digest type: none|complete subjects&lt;br /&gt;
** Forum auto-subscribe: no |yes when  I post&lt;br /&gt;
** When editing text: use HTML| standard web forms&lt;br /&gt;
** AJAX and Javascript: yes|no&lt;br /&gt;
** city/town&lt;br /&gt;
** country&lt;br /&gt;
** timezone&lt;br /&gt;
** Preferred language&lt;br /&gt;
** Description&lt;br /&gt;
** Web page&lt;br /&gt;
** ID number&lt;br /&gt;
** Institution&lt;br /&gt;
** Department&lt;br /&gt;
** Phone&lt;br /&gt;
** Mobile Phone&lt;br /&gt;
** Address&lt;br /&gt;
&lt;br /&gt;
==After results ==&lt;br /&gt;
Users which were not added, will NOT be auto-enrolled in courses&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Open another moodle browser and &lt;br /&gt;
* Site administration&lt;br /&gt;
** Courses&lt;br /&gt;
*** Add/edit courses; select the category, and the course&lt;br /&gt;
* Course administration&lt;br /&gt;
** Users&lt;br /&gt;
*** Enrolled Users&lt;br /&gt;
**** Enrol users and select the users flagged from other window&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;
&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;. After uploading the file, be sure to change the &amp;quot;Upload type&amp;quot; to &amp;quot;Update existing users only&amp;quot; and the &amp;quot;Allow deletes&amp;quot; option to &amp;quot;Yes&amp;quot;.&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=181259 User upload option: standardise usernames]&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>Tbachert</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/21/en/index.php?title=Quickmail_block&amp;diff=50884</id>
		<title>Quickmail block</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/21/en/index.php?title=Quickmail_block&amp;diff=50884"/>
		<updated>2009-02-13T19:57:08Z</updated>

		<summary type="html">&lt;p&gt;Tbachert: /* History */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;quickmail&#039;&#039;&#039; block adds a link to a tool that has a checkbox list of all students in the course, and a mail composition text area. You can check the students you like, and email those and only those. This enhances the existing communications systems of messaging (one user) and subcribed forums (all subscribers) by allowing teachers to select a specific subset of students. It was developed by Michael Penney&#039;s team at Humboldt.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
Download Quickmail with the provided link in the [[Quickmail_block#Links | Links section]].  After unzipping the file, you will find the quickmail directory in block_quickmail_1.5/blocks/.  Copy this quickmail directory to your Moodle&#039;s blocks directory.  Then visit Moodle&#039;s admin screen, clik in Notifications so that Quickmail can install itself.  After that, you can add Quickmail to any course.&lt;br /&gt;
&lt;br /&gt;
==Block Display==&lt;br /&gt;
[[Image:Quickmail-en-blockdisplay-screenshot.jpg|right]]&lt;br /&gt;
The image to the right shows how Quickmail will appear when added to a course.  The three links are described as follows:&lt;br /&gt;
*&#039;&#039;&#039;Compose:&#039;&#039;&#039; takes you to Quickmail&#039;s email composition page.&lt;br /&gt;
*&#039;&#039;&#039;History:&#039;&#039;&#039; takes you to a history of all your emails sent by Quickmail in the current course.&lt;br /&gt;
*&#039;&#039;&#039;Settings:&#039;&#039;&#039; takes you to Quickmail&#039;s configuration screen; the same configuration screen as the block&#039;s edit button when course editing is turned on.  This link only appears for course teachers and administrators.&lt;br /&gt;
&lt;br /&gt;
==Block Settings==&lt;br /&gt;
Quickmail has two settings:&lt;br /&gt;
*&#039;&#039;&#039;Allow Students to use Quickmail:&#039;&#039;&#039; if &#039;&#039;Yes&#039;&#039; then Students will be able to see Quickmail in the course and use it to send emails.  If &#039;&#039;No&#039;&#039; then Quickmail will be hidden to the Students. &lt;br /&gt;
NOTE: Quickmail displays &#039;&#039;&#039;all email addresses&#039;&#039;&#039; for &#039;&#039;&#039;all moodle users&#039;&#039;&#039; in &#039;&#039;&#039;any course&#039;&#039;&#039;.  Quickmail overrides the user profile setting of &amp;quot;Hide my Email address from everyone&amp;quot;. &lt;br /&gt;
*&#039;&#039;&#039;Group mode:&#039;&#039;&#039; set the [[Groups#Group_modes | group mode]] of Quickmail.  This setting is disabled if [[Force_group_mode | Force group mode]] is turned &#039;&#039;On&#039;&#039; in the course.&lt;br /&gt;
&lt;br /&gt;
In Moodle 1.7 or later, the &#039;&#039;Allow Students to use Quickmail&#039;&#039; setting has been removed.  To allow students (or any other role) to use Quickmail, just override the Quickmail block capability called [[Capabilities/block/quickmail:cansend | block/quickmail:cansend]].  For more information about role management, please review the [[Manage_roles | Manage roles]] page.&lt;br /&gt;
&lt;br /&gt;
==Compose==&lt;br /&gt;
When composing an email, the following fields must be set:&lt;br /&gt;
*&#039;&#039;&#039;To:&#039;&#039;&#039; this area contains a series of check boxes, one for each course user.  Each user who has their check box &#039;&#039;checked&#039;&#039;, will be emailed.  Also, there is a handy button that can &#039;&#039;Check All&#039;&#039; or &#039;&#039;Uncheck All&#039;&#039; users.  If a Group mode has been set in Quickmail&#039;s settings or if Force group mode is turned on, then the display of the users and their check boxes changes.  Here is how the different modes affect the display:&lt;br /&gt;
**&#039;&#039;&#039;Visible groups:&#039;&#039;&#039; users and their check boxes are grouped together by their groups and each group has a &#039;&#039;Check All&#039;&#039; and an &#039;&#039;Uncheck All&#039;&#039; button.&lt;br /&gt;
**&#039;&#039;&#039;Separate groups:&#039;&#039;&#039; only users belonging to your group are displayed.  Teachers always see the &#039;&#039;Visisible groups&#039;&#039; display because s/he never belongs to a group.&lt;br /&gt;
**&#039;&#039;&#039;Similarities between both modes:&#039;&#039;&#039; each group&#039;s name and picture are printed.  Also, all users not belonging to a group are added at the bottom.&lt;br /&gt;
*&#039;&#039;&#039;Subject:&#039;&#039;&#039; whatever is written here will appear as the email&#039;s subject.&lt;br /&gt;
*&#039;&#039;&#039;Message:&#039;&#039;&#039; this area is used to compose the email message or body.  You can use the [[HTML_editor | HTML editor]] for this section if you have it turned on in your user profile.  Otherwise, you can select from one of Moodle&#039;s [[Formatting_options | formats]].&lt;br /&gt;
*&#039;&#039;&#039;Attachment:&#039;&#039;&#039; this is the only optional field and it behaves differently for Students and for Teachers.&lt;br /&gt;
**Students can select a file from their hard drive to attach to the email.  This file is only temporarily stored on the server and it deleted after the email has been sent.&lt;br /&gt;
**Teachers use the standard course files interface.  These files are stored in the course files and are never removed by Quickmail.&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
This page displays a table with information regarding sent emails.  The columns are as follows:&lt;br /&gt;
*&#039;&#039;&#039;Date:&#039;&#039;&#039; the day and time of when the email was sent.&lt;br /&gt;
*&#039;&#039;&#039;Subject:&#039;&#039;&#039; the subject of the email.&lt;br /&gt;
*&#039;&#039;&#039;Attachment:&#039;&#039;&#039; name of the attachment sent along with the email.&lt;br /&gt;
*&#039;&#039;&#039;Action:&#039;&#039;&#039; contains action buttons.  The button that looks like a magnifying glass takes you back to the &#039;&#039;Compose email&#039;&#039; page, but pre-fills the form with the original values from the old email.  This is handy for resending an email to a particular user or for sending similar emails.  The other image is in a shape of an &#039;&#039;X&#039;&#039; and it deletes a single sent email.&lt;br /&gt;
All columns are collapsible and sortable.  If you have more than ten emails in the history, then a paging mechanism is displayed for paging through all the sent emails.&lt;br /&gt;
&lt;br /&gt;
Also, there is a &#039;&#039;&#039;Clear History&#039;&#039;&#039; button on the right in the header of the page.  Clicking on this button brings you to a confirmation page prompting you to delete all entries in your history.  Choosing &#039;&#039;yes&#039;&#039; will clear your history and choosing &#039;&#039;no&#039;&#039; will leave the history unchanged.  If you have no emails in your history, then the button is disabled.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;By the way&#039;&#039;&#039; there is an modified version of Quickmail which has a more straight-forward Graphical User Interface (GUI) and is easier to use for large classes. This block is known as &#039;&#039;&#039;&amp;quot;quickmail for large classes&amp;quot;&#039;&#039;&#039; or &#039;&#039;&#039;&amp;quot;quickmail v2.&amp;quot;&#039;&#039;&#039; This mod was implemented by the team at San Francisco State University and is currently maintained by Wen Hao Chuang. This enhanced version of Quickmail could be downloaded from http://moodle.org/mod/forum/discuss.php?d=68296&lt;br /&gt;
&lt;br /&gt;
==Credits==&lt;br /&gt;
*Original developer: Mark Nielsen (currently co-maintained by Wen Hao Chuang)&lt;br /&gt;
*Project Manager: Michael Penney&lt;br /&gt;
*Postgres7 contribution: Rubens Ribeiro&lt;br /&gt;
*Language Translations:&lt;br /&gt;
**Japanese: Mitsuhiro Yoshida&lt;br /&gt;
**Spanish: Rubens Ribeiro&lt;br /&gt;
**French: Yves Dufour&lt;br /&gt;
**German: Andy Tagliani&lt;br /&gt;
**Slovak: Miroslav Fikar&lt;br /&gt;
**Hungarian: Császár-Cs. Péter&lt;br /&gt;
**Hebrew: Miki Alliel&lt;br /&gt;
**Italian: Lorenzo Nicora&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* [http://moodle.org/mod/data/view.php?d=13&amp;amp;rid=92 Quickmail in modules and plugins]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributed code]]&lt;br /&gt;
&lt;br /&gt;
[[ja:クイックメールブロック]]&lt;/div&gt;</summary>
		<author><name>Tbachert</name></author>
	</entry>
</feed>