Adding users
Using a CSV
Note that this method is mainly for bulk-importing student and staff users. This will let you assign group leaders as well.
-
Prepare the following CSVs, without headers and with the fields name, username, group name, in that order. All fields are required.
- students
- group leaders (TAs)
- mentors
You only need to create the CSVs that you wish to update.
Users are keyed by username, and groups are keyed by group name. If there are multiple rows with the same key, the later rows will overwrite the earlier rows.
Leaders and mentors are created with the staff role. They are set as the leader (or mentor) of the specified group, but they are not themselves added to the group.
Note: groups are used only to group students into their tutorial groups. The group leader is meant to be the group’s TA, and the leader’s grading view will be by default filtered to show only their group’s submissions. The group mentor field is currently unused.
-
Transfer the CSVs to the server the backend is running on. Note: if you are using our Terraform deployment with 2 (or more) redundant nodes, you only need to transfer the CSVs (and do the remaining steps) on one of the nodes.
-
Enter the Elixir REPL in the context of the backend. If you followed the deployment guides, you can run
/opt/cadet/bin/cadet remote
to do so. -
Execute
Mix.Tasks.Cadet.Users.Import.run(nil)
-
Enter the paths to the files as needed.
-
Done!
Directly via SQL
-
Connect to your PostgreSQL database using
psql
or whatever preferred tool you use. -
Add users:
INSERT INTO users (name, role, username, inserted_at, updated_at) values ('name', 'admin', 'username', NOW(), NOW());
-
Done!