Note: You are currently viewing documentation for Moodle 2.0. Up-to-date documentation for the latest stable version is available here: Upload users.

Talk:Upload users: Difference between revisions

From MoodleDocs
(→‎Proposed changes July 2008: Completed 25% of reedit)
Line 36: Line 36:
----
----
INTRODUCTION
INTRODUCTION
Location: ''Administration > Users > Accounts > Upload users''
The upload users utility is a simple but powerful way to upload user information into Moodle. It is possible to either create authenticate users, or to create authenticate users and enrol them into a course at once.
*Note: that recent versions of Moodle have tools to keep the site administrators personal maintenance work down besides this particular form of manual authentication.  For example, connecting to existing external databases or letting the [[Internal enrolment|users create their own accounts]]. See the [[Authentication]] section in the admin menus.
The user data text file must follow a certain format, as described below.


==Basic Steps==
==Basic Steps==
The uploading users process uses 3 screens and many options to consider.  
The uploading users process uses 3 screens and has many options to consider.  
 
===1 User upload screen===
#Open up the Upload users screen in Site Administration >Users>Accounts>Upload users
#Open up the Upload users screen in Site Administration >Users>Accounts>Upload users
#Find the upload file using the browse button
:Upload file using the browse button
#Review and change if necessary the separating value
:CSV delimiter= review and change if necessary the separating value (comma, colon, semi colon and tab (/t)
#Review and change if necessary the basic language
:Encoding language - should match the Moodle site
:Preview rows: Set the number of records to display in the next preview screen
 
[[Image:Administration Block Users Authentication Upload Users 0.jpg|thumb|center|Initial Upload user screen Moodle 1.9]]
 
===2 Upload user preview screen===
There are 4 parts to this screen: Preview of text file, Settings, Roles  and Default values.
[[Image:Administration Block Users Authentication Upload Users 1.jpg|thumb|center|Top of Upload user preview screen Moodle 1.9]]
[[Image:Administration Block Users Authentication Upload Users 1b.png|thumb|center|Bottom of Upload user preview screen Moodle 1.9]]
 
====Preview of text file====
At the top of the page are the first records in the file.  It is always a best practice to look at them to make sure the field information is in the correct place.
 
====Settings====
 
Upload type:
:Add new only, skip existing users
:Add all, append counter (a number) to name if needed
:Add new and update existing users
:Update existing users only
 
New user password: (Will not effect existing users passwords)
:Field required in text file
:Create password if necessary
 
Existing user details
:No changes
:Override file
:Override with file and defaults
:Fill in missing with file from defaults
Existing user password
:No changes
:Update
Allow renames
:Yes or No
 
Allow deletes
:Yes or No
 
Prevent email address duplicates
:Yes or No
 
Select for bulk operations (this can make global changes to all users like Bulk user changes)
:No
:New users
:Updated users
:All users
 
====Roles====
You may assign a user any one of 3 roles when using Update user. Each user in the text file mayhave been assigned a role (see below) and that will appear in the Type1 column in the preview section.
 
Select the role from a pulldown menu for each of the numeric types.  For example, we could change type 3 from a non-editing teacher to an editing teacher.
 
:(Original Student) typeN=1  Type 1
:(Original Teacher) typeN=2
:(Original Non-editing teacher) typeN=3
 
 
====Default values====
[[Image:Administration Block Users Authentication Upload Users 1b.png|thumb|center|Bottom of Upload user preview screen Moodle 1.9]]
 
 
 
==Upload file format==
 
Users may be imported, enrolled on courses and organised into groups via flat file.
 
 
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:
 
* Each line of the file contains one record
* Each record is a series of data separated by commas
* The first record of the file is special, and contains a list of fieldnames. This defines the format of the rest of the file.
 
:'''Required fieldnames''': these fields must be included in the first record, and defined for each user
:<p><code>username, password, firstname, lastname, email</code></p>
 
:'''Default fieldnames''': these are optional - if they are not included then the values are taken from the primary admin
:<p><code>institution, department, city, country, lang, auth, timezone</code></p>
 
:'''Optional fieldnames''': all of these are completely optional. The course names are the "shortnames" of the courses - if present then the user will be enrolled as students in those courses. Group names must be associated to the corresponding courses, i.e. group1 to course1, etc.
:<p><code>idnumber, icq, phone1, phone2, address, url, description, mailformat, maildisplay, htmleditor, autosubscribe, course1, course2, course3, course4, course5, group1, group2, group3, group4, group5, type1, type2, type3, type4, type5</code></p>
 
'''Roles amendments''':  Note that since roles have been added in Moodle 1.7, there is a new (better) fieldname to use for enrolments and that is ''role''. You can use ''role'' field instead of the legacy ''type'' field to specify roles directly - use either role short name or id (numeric names of roles are not supported).
===Tips on upload file creation===
* Commas within the data should be encoded as &#44 - the script will automatically decode these back to commas.
* For Boolean fields, use 0 for false and 1 for true.
* Types are used to tell Moodle whether the user is a student or a teacher if a corresponding course exists (e.g. type2 corresponds to course2). 1 = Student, 2 = Editing Teacher, and 3 = Non-editing Teacher. If type is left blank, or if no course is specified, the user is default to student.
* Force password change: Set the password field for desired users to '''changeme'''.
* Turn email off: The parameter '''emailstop''' 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.
* For courses, use the short name for the course
* Note: If a user is already registered in the Moodle user database, this script will return the userid number (database index) for that user, and will enrol the user as a student in any of the specified courses WITHOUT updating the other specified data.
 
Here is an example of a valid import file:
 
<code>username, password, firstname, lastname, email, lang, idnumber, maildisplay, course1, group1, type1<br />
jonest, verysecret, Tom, Jones, jonest@someplace.edu, en, 3663737, 1, Junk102, Section 1, 1<br />
reznort, somesecret, Trent, Reznor, reznort@someplace.edu, en_us, 6736733, 0, Junk102, Section 3, 3</code>
 
(Text copied from [http://moodle.org/help.php?file=uploadusers.html Upload users help file].)
 
==Updating existing accounts==
 
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 "Update existing accounts" to '''Yes''', the existing user account will be updated.
 
When updating existing accounts you can change usernames as well. Set "Allow renames" to '''Yes''' and include in your file a field called <code>oldusername</code>.
 
'''Warning''': any errors updating existing accounts can affect your users badly. Be careful when using the options to update.
 
==Encoding==
 
Prior to Moodle 1.9, the file must have the same encoding as your language pack. In Moodle 1.7 and 1.8 it is always UTF-8.
 
{{Moodle 1.9}}In Moodle 1.9 onwards, the encoding may be selected.
 
==Hints==
 
===Spreadsheet===
 
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.
 
Also, Excel translates passwords that begin with - (minus) or + (plus) as zero. Even when saving as .csv and saying "Yes" to "Keep this format, and leave out any incompatible features." Check for this before uploading, as a zero halts the upload process.
 
===Country===
The country should be written as a two letter code, e.g. BE for Belgium, NL for the Netherlands, and should be written in capitals. If not, it gets abbreviated to two letters, which can cause an invalid country entry in the database.
 
==See also==
 
*[[Flat file]]
 
Using Moodle forum discussions:
*[http://moodle.org/mod/forum/discuss.php?d=36851 Can I auto enroll from Excel?]
*[http://moodle.org/mod/forum/discuss.php?d=58215 Making Email Optional]
*[http://moodle.org/mod/forum/discuss.php?d=97903 Uploading users to custom roles]

Revision as of 12:01, 25 July 2008

I copied text from the help file to this page. Please let me know if this is not the way to go. I felt that the Docs should be self-sufficient without the "online help files". --Samuli Karevaara 02:39, 1 September 2006 (CDT)

Hi Samuli, it's not necessary to copy all help file text into the documentation wiki, however it can sometimes help. --Helen Foster 03:09, 4 October 2007 (CDT)

Possible inconsistency or lack of clarity

It's not obvious whether these two sections contradict each other:

Note: If a user is already registered in the Moodle user database, this script will return the userid number (database index) for that user, and will enrol the user as a student in any of the specified courses WITHOUT updating the other specified data
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 "Update existing accounts" to Yes, the existing user account will be updated.

Is the former an exception to the latter? Does adding an existing user to a course and/or group count as 'updating'? --David Scotson 13:37, 6 September 2006 (CDT)

What is meant "set "Update existing accounts" to Yes" ?? Where can i find it in moodle?

As far as I can tell, uploading users with "update" off doesn't affect enrollments in any way. This is from personal experience and from looking at the code. The help file is incorrect.

Can some more clarity be added about csv file types, it seems that the instructions for uploading files for user accounts say just .txt files ( Since a CSV file is a simple text file (ASCII or Unicode) maybe it should be listed as a acceptable file type for uploading. GM 05/28/08 Moodle rooms assignment 14.1

Changes in 1.9

It is worth noting that in version 1.9 the interface for batch-uploading users is significantly different than in 1.8 and previously. In 1.9 the options have been split into two pages; first the file gets uploaded and parsed, then you tell Moodle what you want it to do with that file. E.g. you do not get to choose whether the file should update existing accounts until page 2.

This page needs serious work for 1.9

In MoodleSpeak of 1.9 this page can use some serious work. I suspect the language is left from older versions of Moodle.

In short: Upload Users is about Authentication, Flat File is about Enrolment. Flat File is probably a poor name but we can not do anything about it except not use it on this page. While both Authentication and Enrolment use a special text file for bulk uploads, each has a different set of data fields and each is processed differently by the interface.--Chris collman 15:08, 24 July 2008 (CDT)

Proposed changes July 2008

I have walked through 3 or 4 Upload users and snapped some screen shots on a local host in 1.9. Since I am "new" at this process, I will propose changes to the page in hopes someone who is more about the process will catch errors.

While this page should contain much of the same information as help, it should not be a duplication of help


INTRODUCTION Location: Administration > Users > Accounts > Upload users

The upload users utility is a simple but powerful way to upload user information into Moodle. It is possible to either create authenticate users, or to create authenticate users and enrol them into a course at once.

  • Note: that recent versions of Moodle have tools to keep the site administrators personal maintenance work down besides this particular form of manual authentication. For example, connecting to existing external databases or letting the users create their own accounts. See the Authentication section in the admin menus.

The user data text file must follow a certain format, as described below.


Basic Steps

The uploading users process uses 3 screens and has many options to consider.

1 User upload screen

  1. Open up the Upload users screen in Site Administration >Users>Accounts>Upload users
Upload file using the browse button
CSV delimiter= review and change if necessary the separating value (comma, colon, semi colon and tab (/t)
Encoding language - should match the Moodle site
Preview rows: Set the number of records to display in the next preview screen
Initial Upload user screen Moodle 1.9

2 Upload user preview screen

There are 4 parts to this screen: Preview of text file, Settings, Roles and Default values.

Top of Upload user preview screen Moodle 1.9
Bottom of Upload user preview screen Moodle 1.9

Preview of text file

At the top of the page are the first records in the file. It is always a best practice to look at them to make sure the field information is in the correct place.

Settings

Upload type:

Add new only, skip existing users
Add all, append counter (a number) to name if needed
Add new and update existing users
Update existing users only

New user password: (Will not effect existing users passwords)

Field required in text file
Create password if necessary

Existing user details

No changes
Override file
Override with file and defaults
Fill in missing with file from defaults

Existing user password

No changes
Update

Allow renames

Yes or No

Allow deletes

Yes or No

Prevent email address duplicates

Yes or No

Select for bulk operations (this can make global changes to all users like Bulk user changes)

No
New users
Updated users
All users

Roles

You may assign a user any one of 3 roles when using Update user. Each user in the text file mayhave been assigned a role (see below) and that will appear in the Type1 column in the preview section.

Select the role from a pulldown menu for each of the numeric types. For example, we could change type 3 from a non-editing teacher to an editing teacher.

(Original Student) typeN=1 Type 1
(Original Teacher) typeN=2
(Original Non-editing teacher) typeN=3


Default values

Bottom of Upload user preview screen Moodle 1.9


Upload file format

Users may be imported, enrolled on courses and organised into groups via flat file.


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:

  • Each line of the file contains one record
  • Each record is a series of data separated by commas
  • The first record of the file is special, and contains a list of fieldnames. This defines the format of the rest of the file.
Required fieldnames: these fields must be included in the first record, and defined for each user

username, password, firstname, lastname, email

Default fieldnames: these are optional - if they are not included then the values are taken from the primary admin

institution, department, city, country, lang, auth, timezone

Optional fieldnames: all of these are completely optional. The course names are the "shortnames" of the courses - if present then the user will be enrolled as students in those courses. Group names must be associated to the corresponding courses, i.e. group1 to course1, etc.

idnumber, icq, phone1, phone2, address, url, description, mailformat, maildisplay, htmleditor, autosubscribe, course1, course2, course3, course4, course5, group1, group2, group3, group4, group5, type1, type2, type3, type4, type5

Roles amendments: Note that since roles have been added in Moodle 1.7, there is a new (better) fieldname to use for enrolments and that is role. You can use role field instead of the legacy type field to specify roles directly - use either role short name or id (numeric names of roles are not supported).

Tips on upload file creation

  • Commas within the data should be encoded as &#44 - the script will automatically decode these back to commas.
  • For Boolean fields, use 0 for false and 1 for true.
  • Types are used to tell Moodle whether the user is a student or a teacher if a corresponding course exists (e.g. type2 corresponds to course2). 1 = Student, 2 = Editing Teacher, and 3 = Non-editing Teacher. If type is left blank, or if no course is specified, the user is default to student.
  • Force password change: Set the password field for desired users to changeme.
  • Turn email off: The parameter emailstop 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.
  • For courses, use the short name for the course
  • Note: If a user is already registered in the Moodle user database, this script will return the userid number (database index) for that user, and will enrol the user as a student in any of the specified courses WITHOUT updating the other specified data.

Here is an example of a valid import file:

username, password, firstname, lastname, email, lang, idnumber, maildisplay, course1, group1, type1
jonest, verysecret, Tom, Jones, jonest@someplace.edu, en, 3663737, 1, Junk102, Section 1, 1
reznort, somesecret, Trent, Reznor, reznort@someplace.edu, en_us, 6736733, 0, Junk102, Section 3, 3

(Text copied from Upload users help file.)

Updating existing accounts

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 "Update existing accounts" to Yes, the existing user account will be updated.

When updating existing accounts you can change usernames as well. Set "Allow renames" to Yes and include in your file a field called oldusername.

Warning: any errors updating existing accounts can affect your users badly. Be careful when using the options to update.

Encoding

Prior to Moodle 1.9, the file must have the same encoding as your language pack. In Moodle 1.7 and 1.8 it is always UTF-8.

Template:Moodle 1.9In Moodle 1.9 onwards, the encoding may be selected.

Hints

Spreadsheet

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.

Also, Excel translates passwords that begin with - (minus) or + (plus) as zero. Even when saving as .csv and saying "Yes" to "Keep this format, and leave out any incompatible features." Check for this before uploading, as a zero halts the upload process.

Country

The country should be written as a two letter code, e.g. BE for Belgium, NL for the Netherlands, and should be written in capitals. If not, it gets abbreviated to two letters, which can cause an invalid country entry in the database.

See also

Using Moodle forum discussions: