During the recent breach incident with Canvas I put together a quick and dirty tool to bulk export gradebooks from courses in CSV format. This was put together in an evening and is very hacky but it does seem to work.
- The gradebook export functionality is not exposed via the regular API. This acts as a headless client to request an export be initiated, and then downloads that CSV locally. This will be the same gradebook teachers get when they do a gradebook export via the web.
- It also uses the canvasapi to perform what calls it can directly through the API so you'll need an access token for that.
- It requires that you log into Canvas as an administrative user with the required permissions and export a cookies.json which the script uses to access Canvas.
- It will take at least one second per course - that's how long it waits to check if an export is completed. It took several hours to run for me.
- It will navigate through subaccounts and creates a directory for each one, placing gradebooks into a directory based on the course code (e.g. MATH136).
- I don't know if this kind of automated behavior would trigger any warnings for Instructure. As a precaution, I ran it from an ip address not associated with our institution so that if my ip got banned, it wouldn't impact the entire school. (This was during the data breach and I was in a very throw caution to the wind and get this data out ASAP in case we lose access mood.)
- Configuration requires modifying the .py file itself.
This tool is not suitable for long term use, but it does get the job done. A better solution would be to use Canvas Data 2 reports that build verifiable replicas of grade-books or a tool built using the regular API which performs the same collection/formatting/calculations/etc. But sometimes you don't have the time to make the suitable tool and you just need to get a lot of known-good CSV files ASAP.
https://github.com/tonytoon/canvas-public
Absolutely use at your own risk and do not share the cookies.json file you export with anybody else. I don't know if I'll update it any in the future since it's not really the best way to get this data out. In an ideal world, Canvas would have such a tool already built in as a report or something similar. I could see a power user instructor using this as a starting point to download their own gradebooks automatically, although they'd probably have to change how it finds/navigates through courses.