https://github.com/extua/laec-classroom-automation-scripts
Python scripts for doing bulk operations with Google Classroom
https://github.com/extua/laec-classroom-automation-scripts
gam
Last synced: 9 months ago
JSON representation
Python scripts for doing bulk operations with Google Classroom
- Host: GitHub
- URL: https://github.com/extua/laec-classroom-automation-scripts
- Owner: extua
- License: mit
- Created: 2023-08-09T08:54:36.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-01T07:25:03.000Z (about 2 years ago)
- Last Synced: 2024-05-01T08:33:39.221Z (about 2 years ago)
- Topics: gam
- Language: Python
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LAEC classroom automation scripts
> [!IMPORTANT]
> This code hasn't been touched in over two years and it's probably out of date.
This is a collection of python scripts used for automating common Google Classroom admin tasks, using the [Google Workspace API](https://developers.google.com/classroom/reference/rest).
## Scope
These scripts were written to handle courses at [Leicester Adult Education](https://leicesteradulted.ac.uk/), they're not designed to be usable for other use cases. Email addresses and API calls to the Leicester Adult Education database have been replaced with `example.com`.
Consider this a starting point and inspiration for your own code. For a more comprehensive solution, see [GAM](https://github.com/GAM-team/GAM) and [GAMADV-XTD3](https://github.com/taers232c/GAMADV-XTD3/)
## Usage
Follow the steps [here](https://developers.google.com/admin-sdk/directory/v1/quickstart/python) and make sure you have the client libraries in your python environment.
All API calls need to be authenticated with your credentials, and so in each script the first API call needs to be prefixed with credential validation. For the sake of simplicity, the credential handling has been put in its own file `credentials_flow.py` which provides the `getcreds()` function.
The first time you run the credentials flow you'll have to go through an authentication process with google, which will leave you with the `credentials.json` and `token.json` files in the project directory defined in the credentials flow.
### Bulk add courses
Take a csv containing course information for many courses, and create these on Google Classroom. You can also do this using GAM, but the script gives some more flexibility with what you add to the course object.
### Call ebs, add courses
Same as above but this time getting course information by making a call to an API provided by [ebs](https://www.tribalgroup.com/solutions/student-information-systems/ebs).[^tribal] With this, courses on ebs could be automatically added to Google Classroom.
[^tribal]: A student information system used for administration of student records and course information.
### Bulk delete users
Take a csv containing lots of old user ids of people who haven't taken a course in several years. Check whether their account is unused,[^last_login] and if not, delete the account. With a huge number of accounts you quickly encounter rate limiting and have to slow down the script, which makes this one a pain to run. That said, manually deleting user accounts doesn't scale well either.
[^last_login]: An account is unused if the last login date equals the Unix epoch (1970-01-01 00\:00\:00), and you can change that to get accounts not logged into since a set date.
### Get course ids
List all google ids of all provisioned courses. Makes use of pagination to get courses in batches.
### Get ids and aliases
List all active courses with their google ids and by alias. You can think of this as a right join on course ids and aliases. In the final list, aliases are unique, but google ids are not. This is useful for disaggregating the situations where multiple courses (with different course codes/aliases) share the same Google Classroom.
### Mass announcement
Make an announcement to all active classes, which would be useful for situations where you need to broadcast that the college has been closed due to a weather accident or some other emergency. Beware if you add an announcement to a de-provisioned course, it'll be made active.