Canvas conversion tool¶
Note
This documentation was sourced from contrib/question_converters/canvas/README.md.
Converting Canvas assessments to PrairieLearn¶
This directory contains scripts that use the Canvas API to import course assessments into PrairieLearn. The current version includes a conversion of Canvas classic quizzes. Implementation of other converters is pending, and contributions are welcome.
An earlier version of this script was originally published at https://github.com/ubc-cpsc/canvasgrading and has been migrated to this repository by the original author.
Before running the script, you must create a config.json
file as follows:
{
"api_url": "https://[YOUR_INSTITUTION_CANVAS_URL]/api/v1",
"access_token": "[YOUR_ACCESS_TOKEN]"
}
The api_url
value is based on your institution's Canvas URL. The access_token
is based on an
access token associated to your account. The token can typically be generated by opening your user's
profile settings and selecting "Approved Integrations".
quiz2pl.py¶
This is a script that converts a Canvas quiz, including all of its questions, to a PrairieLearn assessment and questions. The script receives the following arguments:
-c COURSE
: the ID of the course on Canvas, optional. If you don't specify it, the script lists all courses you have access to and asks for a course. The ID can be obtained by looking at the URL on Canvas, it's the number aftercourses/
.
-q QUIZ
: the ID of the quiz, optional. If you don't specify it, the script lists all quizzes from the course you selected and asks for a quiz. The ID can be obtained by looking at the URL on Canvas when you open the quiz, it's the number afterquizzes/
.
-t ASSESSMENT_TYPE
: the assessment type to be used in the PrairieLearn assessment, optional. If not provided, "Exam" will be used if there is a time limit, otherwise "Homework" will be used.
-s ASSESSMENT_SET
: the assessment set to be used in the PrairieLearn assessment, optional. If not provided, the "Quiz" set is used.
-n ASSESSMENT_NUMBER
: the assessment number to be used in the PrairieLearn assessment, optional. If not provided, no number is set.
--topic TOPIC
: the topic to be used in the PrairieLearn questions, optional. If not provided, the topic is set to "None".
- the directory corresponding to the course repository where PrairieLearn is stored, required.
- the course instance where the assessment will be created, required.
The script will connect to the Canvas API to retrieve the quiz settings and all its questions.
The script currently supports the following question types in Canvas classic quizzes, replacing them with equivalent PrairieLearn elements: essay (tagged as Manual grading), fill-in the blank (including multiple blanks), multiple choice (including true/false and multiple answers), multiple dropdowns, matching, numerical answers and formula (calculated) questions. File upload questions are not currently supported. Text-only "questions" are converted to regular PrairieLearn questions, but you are strongly encouraged to review their use to ensure some gradable component is available.
The script also supports question groups, in which case each question version is saved in a different PrairieLearn question. Given some limitations of the Canvas API, this script does not support question groups linked to question banks. If using question groups, the questions must be included in the Canvas quiz itself instead of in the bank only.
The PrairieLearn assessment will be created with an AID based on the quiz title on Canvas. For each question in the quiz, a new PrairieLearn question is created. Given that question titles are typically unreliable on Canvas, each question will be printed on the terminal, asking for a question title. This title will also be used as a basis to create the QID of the question. If a question should be skipped, just keep the title blank.
While every effort has been made to create the question as close as possible to the original question on Canvas, minor differences may exist, and questions may be able to be optimized for the PrairieLearn environment. For example, this script does not organize the questions into zones, and does not populate question-specific tags to questions. You are strongly encouraged to revise the questions after converting them.