MDL-66705 tool_uploaduser: Add an example csv file.

This commit is contained in:
Adrian Greeve
2019-10-15 10:56:29 +08:00
parent 8111abc331
commit 56ad15fc06
3 changed files with 16 additions and 1 deletions
+4
View File
@@ -0,0 +1,4 @@
username,firstname,lastname,email
student1,Student,One,[email protected]
student2,Student,Two,[email protected]
student3,Student,Three,[email protected]
1 username firstname lastname email
2 student1 Student One [email protected]
3 student2 Student Two [email protected]
4 student3 Student Three [email protected]
@@ -33,6 +33,10 @@ $string['deleteerrors'] = 'Delete errors';
$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.';
@@ -63,7 +67,9 @@ $string['uploadusers_help'] = 'Users may be uploaded (and optionally enrolled in
* 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';
+5
View File
@@ -40,6 +40,11 @@ class admin_uploaduser_form1 extends moodleform {
$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');