SE-977 assign cohort and course mode on bulk register students
This PR adds two optional columns to the bulk register/enroll csv: cohort and course mode. This enables setting the course mode and cohort for a user in the same process as bulk enrolling/registering. The changes aim to be 100% backwards compatible both for behaviour and csv format. The two new fields should set the cohort and course mode in an idempotent manner, with some edge cases. The test instructions aim to define and cover all edge cases.
*JIRA tickets*: (https://openedx.atlassian.net/browse/OSPR-3767)
*Merge deadline*: None
1. set `ALLOW_AUTOMATED_SIGNUPS: true` under `FEATURES` (automatically set on the sandbox)
2. navigate to the membership tab of the instructor dashboard for a test course. Check that cohorts are disabled.
3. upload a csv following the existing format, but with two extra colums (cohort name and course mode), and cohort names set in the 5th column.
4. notice that you get errors saying that cohorts are not enabled
5. verify that a user added in step 3 was enrolled in the course successfully (cohort names should be ignored and users enrolled successfully)
5. enable cohorts on the cohorts tab and create cohortA and cohortB
6. make a new enrollment csv, with the extra cohort name column. There should be new users from step 3, one row with a new non-existing user email and cohort set to cohortA, one row with a random non-existant cohort name, one row with an existing user and cohort set to cohortA.
7. re-upload and notice that you are given errors for any cohorts that don't exist
8. verify that all users were successfully enrolled
9. verify that both the existing and non-existing user that were assigned to cohortA were successfully enrolled and assigned
10. verify that the enrolled user with a non-existant cohort is assigned to the default cohort and successfully enrolled
11. edit the csv from step 6 and change cohortA to cohortB. re-upload
12. verify that the user has been reassigned from cohortA to cohortB
13. upload a csv with only 4 columns, following the original spec to test backward compatibility
14. create a csv with 4 new users, with the 6th column (course mode) set to nothing, a random string, "audit", and "verified" . The 5th column (cohorts) can be arbitrary or blank to not attempt to set a cohort). upload
14. verify that a warning message has been shown about the invalid mode. the user should still be enrolled successfully, but falling back to the default course mode.
15. verify that each user has been enrolled in the course with the default mode, default mode, audit, and verified respectively. This can be done by logging in as each of the new users and checking the text under the course in the dashboard ('audit' will show a 'upgrade to verified' button, 'verified' will show information about verifying identity instead 'verify now').
16. modify the course modes on the csv from step 14 and reupload
17. verify that the course modes have not been changed from step 15.
18. uncheck 'Notify users by email' and upload a csv containing a new user that doesn't exist, and a user that does exist but isn't enrolled. Both users should have an email address that you can check. Verify that these emails do not receive the standard 'you have been enrolled' notification email.
19. upload a csv with users that have previously been enrolled, but with different course modes. Verify that the course modes have been updated to those from the csv.
For reference, here is an example csv that follows the spec: https://gist.github.com/swalladge/e81e79d24736701a9253141f5e33b31d
*Author notes and concerns*:
Notes on current behaviour:
no errors on cohort name or course mode cause failure to enroll student
invalid cohort name falls back to not setting a cohort (effectively using default cohort)
invalid course mode falls back to default course mode
setting a cohort name will always result in the student being assigned to that cohort if the cohort name was valid. If the student was already enrolled in the course and/or in a different cohort, the cohort will be re-assigned to that of the csv
setting a course mode from the csv will change the course mode of students that are already enrolled in the course
Examples of new warning messages shown:
[ ] (openEdx reviewer TBD)