Canvas Tools
This repository contains several tools for interacting with the Canvas API.
Obtaining a Token
Log in to Canvas and select Account->Settings. Under "Approved
Integrations", click on "+ New Access Token". Fill in the required
details and click "Generate Token". Copy the text next to "Token:" and
save it to the file .canvastoken
in your home directory.
Installation
Get the code and install:
$ git clone git@gitlab.eecs.umich.edu:akamil/canvas-tools.git
$ cd canvas-tools/
$ pip3 install .
Scripts
The following are the scripts currently in this repo. They require Python >= 3.6 and can be executed directly.
canvas-list-courses
This lists the courses associated with the current user. Includes the course ID and name. Example:
$ canvas-list-courses
44750: EECS 183 001-004 WN 2016
44995: EECS 280 001 WN 2016
59029: Amir Kamil's Practice Course
90350: EECS 490 001 FA 2016
97555: EECS 285 001 FA 2016
...
canvas-list-assignments
This lists the assignments for a given course ID. Includes the assignment ID and name. Example:
$ canvas-list-assignments 90350
176644: Homework 1
192920: Project 1
184653: Homework 2
215731: Project 2
194161: Homework 3
226652: Project 3
206424: Homework 4
208937: Homework 5
221766: Homework 6
196125: Midterm
227748: Final
227749: Participation
canvas-get-comments
This retrieves the set of grader comments used for a particular assignment. Requires the course ID and assignment ID.
$ canvas-get-comments 90350 192920
canvas-get-roster
This downloads a roster from Canvas. Requires the course ID. An output
filename may be specified with -o
; otherwise output is to standard
out.
$ canvas-get-roster 90350
$ canvas-get-roster 90350 -o roster.csv
If no filename is specified, prints one email address per line. The
resulting data can be uploaded to
https://autograder.io using the ag-roster
tool in the autograder tools
repo.
If a filename is specified, produces output in CSV format that can be imported into Gradescope (Full Name, Email, SID columns).
canvas-list-quizzes
This lists the quizzes for a given course ID. Includes the quiz ID and title. Example:
$ canvas-list-quizzes 59029
136362: Unnamed Quiz
136505: Written Quiz
canvas-get-quiz-questions
This retrieves the questions for each submission of a quiz. Requires
the course ID and quiz ID. Produces a single HTML file listing the
questions for each user. An output filename may be specified with
-o
; otherwise output is to standard out.
$ canvas-get-quiz-questions 59029 136505
$ canvas-get-quiz-questions 59029 136505 -o questions.html
canvas-grant-extra-time
This gives extra time to a set of students on Canvas quizzes. Requires the course ID, the name of a file containing a list of uniqnames, and the amount of time in minutes. Writes the set of extensions to standard out, with uniqname, quiz ID, and extra time as the columns.
$ canvas-grant-extra-time 59029 names 15
akamil+gmail.com 137468 15
akamil+gmail.com 136362 15
akamil+gmail.com 136505 15