Skip to content

Commit

Permalink
MDL-66705 tool_uploaduser: Add an example csv file.
Browse files Browse the repository at this point in the history
  • Loading branch information
abgreeve committed Oct 15, 2019
1 parent 8111abc commit 56ad15f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions admin/tool/uploaduser/example.csv
@@ -0,0 +1,4 @@
username,firstname,lastname,email
student1,Student,One,s1@example.com
student2,Student,Two,s2@example.com
student3,Student,Three,s3@example.com
8 changes: 7 additions & 1 deletion admin/tool/uploaduser/lang/en/tool_uploaduser.php
Expand Up @@ -33,6 +33,10 @@
$string['encoding'] = 'Encoding';
$string['errormnetadd'] = 'Can not add remote users';
$string['errors'] = 'Errors';
$string['examplecsv'] = 'Example text file';
$string['examplecsv_help'] = 'To use the example text file, download it then open it with a text or spreadsheet editor. Leave the first line unchanged, then edit the following lines (records) and add your user data, adding more lines as necessary. Save the file as CSV then upload it.
The example text file may also be used for testing, as you are able to preview user data and can choose to cancel the action before user accounts are created.';
$string['invalidupdatetype'] = 'This option cannot be selected with the chosen upload type.';
$string['invaliduserdata'] = 'Invalid data detected for user {$a} and it has been automatically cleaned.';
$string['invalidtheme'] = 'Theme "{$a}" is not installed and will be ignored.';
Expand Down Expand Up @@ -63,7 +67,9 @@
* Each line of the file contains one record
* Each record is a series of data separated by commas (or other delimiters)
* The first record contains a list of fieldnames defining the format of the rest of the file
* Required fieldnames are username, password, firstname, lastname, email';
* Required fieldnames are username, password, firstname, lastname, email
<a href="https://docs.moodle.org/en/Upload_users" target="_blank">More help</a>';
$string['uploaduserspreview'] = 'Upload users preview';
$string['uploadusersresult'] = 'Upload users results';
$string['uploaduser:uploaduserpictures'] = 'Upload user pictures';
Expand Down
5 changes: 5 additions & 0 deletions admin/tool/uploaduser/user_form.php
Expand Up @@ -40,6 +40,11 @@ function definition () {

$mform->addElement('header', 'settingsheader', get_string('upload'));

$url = new moodle_url('example.csv');
$link = html_writer::link($url, 'example.csv');
$mform->addElement('static', 'examplecsv', get_string('examplecsv', 'tool_uploaduser'), $link);
$mform->addHelpButton('examplecsv', 'examplecsv', 'tool_uploaduser');

$mform->addElement('filepicker', 'userfile', get_string('file'));
$mform->addRule('userfile', null, 'required');

Expand Down

0 comments on commit 56ad15f

Please sign in to comment.