Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.6.3
-
MOODLE_36_STABLE
-
MOODLE_310_STABLE
-
Hide
If you want, create your own CSV file and follow documentation to https://docs.moodle.org/39/en/Upload_users
Test 1. Basic scenarios
- In the command line from the moodle directory run
php admin/tool/uploaduser/cli/uploaduser.php --help
- Observe the generated help and make sure it makes sense (i.e. information about the script, its supported parameters and how to use it should be printed)
- Try to run CLI script without arguments
php admin/tool/uploaduser/cli/uploaduser.php
- Check the "Argument --file is required" message is displayed
- Try to run CLI script specifying non-existing file. The script should fail and exit code should be 1
php admin/tool/uploaduser/cli/uploaduser.php --file=PATHTONONEXISTINGFILE
- Check the "File xxxxxxx does not exist or is not readable" message is displayed
- Take attached examplecohorts.csv file, copy it to the Moodle root directory and run:
php admin/tool/uploaduser/cli/uploaduser.php --file=../../../../examplecohorts.csv
- Make sure users are created and added to the cohorts. There will be errors about non existing course
- Create the course with shortname "math102"
- Run the same script again - it should say that users already exist. Make sure users are not enrolled in the course.
- Run the same script with the same file but with additional argument
php admin/tool/uploaduser/cli/uploaduser.php --file=../../../../examplecohorts.csv --uutype=2
- Make sure users are now enrolled into the course and groups are created and the users are added to the groups groupA and groupB (as in the file)
- Run the command (this will use semicolon as delimiter):
php admin/tool/uploaduser/cli/uploaduser.php --file=../../../../examplecohorts.csv --delimiter_name=semicolon
- Check the errors "Not enough columns" is displayed
- Replace all commas in the file with semicolons and run the same command again.
- Check script completes correctly (in this case there will be no changes because users already exist)
Test 2 . Error testing
- Download a fresh examplecohorts.csv.
- Edit it and remove the "cohort1" text in the first row.
- Run the script with the file:
php admin/tool/uploaduser/cli/uploaduser.php --file=../../../../examplecohorts.csv
- Make sure CLI script prints the message error '"" is not a valid field name'.
- Download a fresh examplecohorts.csv.
- Edit it and add a "x" colum after "cohort1".
- Run the script with the file:
php admin/tool/uploaduser/cli/uploaduser.php --file=../../../../examplecohorts.csv
- Make sure CLI script prints the message error ' "x" is not a valid field name'.
- Download a fresh examplecohorts.csv.
- Run the script with the file:
php admin/tool/uploaduser/cli/uploaduser.php --file=../../../../examplecohorts.csv --uutype=5
- Make sure CLI script prints the message error "Value for argument --uutype is not valid. Allowed values: 0, 1, 2, 3"
- Run the script with the file:
php admin/tool/uploaduser/cli/uploaduser.php --file=../../../../examplecohorts.csv --country=Australia
- Make sure CLI script prints the message error "Value for argument --country is not valid. Allowed values: , AF, AX, [...]"
Test 3. Colors in the UI
- Go to "Site administration > Users > Accounts > Upload users"
- Upload the same file, submit again leave all default values
- Make sure the status column displays warnings with yellow-ish background
- Upload the same file, submit and then change the upload type to "update existing users"
- On the next screen, make sure the enrolment actions are displayed with green-ish background
- In the CSV file change one of the users' names, upload it and submit the second form with the default values
- Check the error message about the duplicate email address is displayed with the red-ish background
ShowIf you want, create your own CSV file and follow documentation to https://docs.moodle.org/39/en/Upload_users Test 1. Basic scenarios In the command line from the moodle directory run php admin/tool/uploaduser/cli/uploaduser.php --help Observe the generated help and make sure it makes sense (i.e. information about the script, its supported parameters and how to use it should be printed) Try to run CLI script without arguments php admin/tool/uploaduser/cli/uploaduser.php Check the "Argument --file is required" message is displayed Try to run CLI script specifying non-existing file. The script should fail and exit code should be 1 php admin/tool/uploaduser/cli/uploaduser.php --file=PATHTONONEXISTINGFILE Check the "File xxxxxxx does not exist or is not readable" message is displayed Take attached examplecohorts.csv file, copy it to the Moodle root directory and run: php admin/tool/uploaduser/cli/uploaduser.php --file=../../../../examplecohorts.csv Make sure users are created and added to the cohorts. There will be errors about non existing course Create the course with shortname "math102" Run the same script again - it should say that users already exist. Make sure users are not enrolled in the course. Run the same script with the same file but with additional argument php admin/tool/uploaduser/cli/uploaduser.php --file=../../../../examplecohorts.csv --uutype=2 Make sure users are now enrolled into the course and groups are created and the users are added to the groups groupA and groupB (as in the file) Run the command (this will use semicolon as delimiter): php admin/tool/uploaduser/cli/uploaduser.php --file=../../../../examplecohorts.csv --delimiter_name=semicolon Check the errors "Not enough columns" is displayed Replace all commas in the file with semicolons and run the same command again. Check script completes correctly (in this case there will be no changes because users already exist) Test 2 . Error testing Download a fresh examplecohorts.csv. Edit it and remove the "cohort1" text in the first row. Run the script with the file: php admin/tool/uploaduser/cli/uploaduser.php --file=../../../../examplecohorts.csv Make sure CLI script prints the message error '"" is not a valid field name'. Download a fresh examplecohorts.csv. Edit it and add a "x" colum after "cohort1". Run the script with the file: php admin/tool/uploaduser/cli/uploaduser.php --file=../../../../examplecohorts.csv Make sure CLI script prints the message error ' "x" is not a valid field name'. Download a fresh examplecohorts.csv. Run the script with the file: php admin/tool/uploaduser/cli/uploaduser.php --file=../../../../examplecohorts.csv --uutype=5 Make sure CLI script prints the message error "Value for argument --uutype is not valid. Allowed values: 0, 1, 2, 3" Run the script with the file: php admin/tool/uploaduser/cli/uploaduser.php --file=../../../../examplecohorts.csv --country=Australia Make sure CLI script prints the message error "Value for argument --country is not valid. Allowed values: , AF, AX, [...] " Test 3. Colors in the UI Go to "Site administration > Users > Accounts > Upload users" Upload the same file, submit again leave all default values Make sure the status column displays warnings with yellow-ish background Upload the same file, submit and then change the upload type to "update existing users" On the next screen, make sure the enrolment actions are displayed with green-ish background In the CSV file change one of the users' names, upload it and submit the second form with the default values Check the error message about the duplicate email address is displayed with the red-ish background - In the command line from the moodle directory run
Description
I would like to upload users from command line and also enrolling them to courses. Currently I generate a CSV and use the web interface to perform this, which takes a long and I would like to automate this, as data source is a special database with daily updates.
So I would like to have something like this:
php admin/tool/uploaduser/cli/uploaduser.php userlist.csv
Attachments
- examplecohorts.csv
- 0.2 kB
- Screenshot_1.jpg
- 101 kB
- Screenshot_2.jpg
- 106 kB
- Screenshot_3.jpg
- 75 kB
- Screenshot_4.jpg
- 105 kB
- Screenshot_5.jpg
- 51 kB
- upload_users.csv
- 0.1 kB