Created
August 27, 2021 22:03
-
-
Save phette23/7a999264a41e0a48407c763b6b0dd027 to your computer and use it in GitHub Desktop.
create a CSV to populate NSO groups in Moodle > Upload Users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# accepts three files that are just the copy-pasted email column from a Google Sheet | |
# some of the rows can be empty, also note that the course shortnames change year to year | |
FRESH=$1 | |
GRAD=$2 | |
TRSFR=$3 | |
# delete empty lines, remove "cca.edu" from emails | |
sed -e '/^$/d' -e 's|@cca\.edu||' -i '.bak' $FRESH | |
sed -e '/^$/d' -e 's|@cca\.edu||' -i '.bak' $GRAD | |
sed -e '/^$/d' -e 's|@cca\.edu||' -i '.bak' $TRSFR | |
# add respective course and group to every line | |
sed -e 's|$|,NSO-FRESH-2021SU,"Freshman International"|' -i '.bak' $FRESH | |
sed -e 's|$|,NSO-GRAD-2021SU,"Graduate International"|' -i '.bak' $GRAD | |
sed -e 's|$|,NSO-TRSFR-2021SU,"Transfer International"|' -i '.bak' $TRSFR | |
# add header row | |
echo 'username,course1,group1' | cat - $FRESH $GRAD $TRSFR > users.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment