Code to automate actions on Canvas using CanvasAPI
The CanvasAPI and its python wrapper provide a powerful framework to automate repetitive actions on the Canvas platform for teachers. In this repository we expand on these methods and we create pipelines to perform a variety of common teaching tasks, such as scheduling quizzes and exams, as well as creating summary statistics and plots. The routines have been designed (but not restricted) to work best with large auditorium courses at the Physics Department the University of Florida. Most of the routines rely on the section information, so courses without student sections will need to use the official Canvas API.
The easiest way to make use of this codebase is by reading the Jupyter Notebooks in the pipes
and tests
folders. There you can find a step by step implementation of many pipelines. NOTE: before you can run these codes, you will need to install this package.
While notstrictly required, it is recommended that you manage dependenccies for this project by installing conda and then creating a virtual invironment, by running (replace <any_name_for_kernel>
with a name of your choice for the new kernel):
conda create -n <any_name_for_kernel> python=3.9
conda activate <any_name_for_kernel>
Next, in order to be able to run the jupyter Notebooks, install ipython kernels:
conda install ipykernel
ipython kernel install --user --name=<any_name_for_kernel>
Download this package with one of the available methods offred by the platform (http, ssh, or zip file).
Finally, navigate to the directory where setup.py
resides, and run:
conda install pip
pip install -e .
Check that your installation worked by trying to import the package in a python script or in a python interactive terminal:
import autocanvas
If no errors are raised, the installation was successful.
The CanvasAPI library gives access to restricted information present on Canvas Course, which is available only to Canvas users with the appropriate permissions (e.g. teaching personel, course designers). As a result, authentication is needed to access this information. This comes in the form of API keys. The official Canvas API documentation page provides a lot of information on how to generate one. As described there, the simplest method of generating one is the following:
- Go on Canvas and click the "profile" link in the top right menu bar, or navigate to /profile
- Under the "Approved Integrations" section, click the button to generate a new access token.
- Once the token is generated, you cannot view it again, and you'll have to generate a new token if you forget it. Remember that access tokens are password equivalent, so keep it secret.
In order to avoid having to generate the API key everytime you run the code, store the API key in an environment file named .env
in the top-level folder (i.e. alongside the requirements.txt
file). This file should include an entry:
API_KEY=<value>
An example of this file is provided in the repository as .env.example
. You can rename it to .env
and then replace <value>
with your API key (replace the <
and >
symbols as well).
The CanvasAPI library returns a PaginatedList
of python objects after each call to its methods, which are not easy to handle and manipulate. Here we convert these to pandas DataFrames
, which are ideally suitted for the data processing actions we want perform in Canvas.
Implemented Pipelines:
- Create section overrides for all weekly quizzes.
- Fix the grade of individual questions of a Quiz assignment.
- Create summary plots for weekly quiz grading, grouped by Teaching Assistant (TA).
- Get summary statistics (mean, std) for quiz scores grouped by TA.
- Create quiz overrides for individual students, based on their section.
See how the grade distributions for a single quiz vary across graders. Example of a violin plot for a single quiz is shown above.
Progression of Quiz averages per TA. The calculation takes into account the fact that the same students are graded by each TA every week, so the sample grades are not i.i.d., and therefore the errorbars in the estimated grade average shrink only moderately.
Verifying that all quizzes are graded.
Some of the main dependencies of the code are:
selenium
>=3.141.0canvasapi
>=2.2.0pandas
>=1.2.3openpyxl
ipykernel
beautifulsoup4
>=4.9.3lxml
python-dotenv
>=0.17.0aiohttp
seaborn
tabulate