WIP! Questions? Ask Alison - alison.myers@sauder.ubc.ca
This script will extract Canvas page html, and module / item information associated with a given page (if any) for an entire Canvas course. The predicted read time of each page is also provided, using the readtime project.
Input is entered as terminal arguments: {COURSE_ID} {WPM}
- Canvas course id
- Optional: words per minute for the read time calculaton
i.e) 1000_pageinfo_200.csv (course id: 1000, wpm: 200)
Column | Description | Note |
---|---|---|
page_id | The Canvas Page ID | Not the same as module_item_id |
page_html_url | The full url to the given page | |
page_url | The page url extension | In Canvas, this is designated by the title of the page (will change if page title changes) |
page_published | Boolean - whether the page is published | |
page_title | The page title | |
page_readtime | The estimated readtime of the page (rounded to minute, minimum 1 minute) | Calculation from readtime with either default or given Words per Minute |
page_readtime_secs | The estimated readtime of the page in seconds | Calculation from readtime with either default or given Words per Minute |
page_body | The html of the page | |
item_id | If the page is a Canvas item, the item id, otherwise empty | A Canvas item (module item) is a page that is part of a module |
item_title | If the page is a Canvas item, the title, otherwise empty | Should be the same as the page_title |
item_url | If the page is a Canvas item, the url, otherwise empty | The item_url uses the item_id in the url |
item_position | The position of the page within a module | |
module_id | The module id of the associated module | Must be a Canvas item to have a module id |
module_published | Boolean - whether the module is published | |
module_position | The position of the module (relative to other modules) |
In Canvas a "page" can be associated with a module, when this is the case there are additional associations with the page - it is now also a module item and has module information.
- Ensure you have conda installed (Python 3.9 version)
- Clone {canvas-get-page-content} repository
- Import environment (once):
$ conda env create -f environment.yml
- Create .env file and include:
Note - anything in {SQUIGLY BRACES} means you must use your own values
API_TOKEN = {MY API TOKEN}
API_INSTANCE = {MY INSTANCE}
Example instance = 'https://ubc.instructure.com'
-
Run:
- navigate to your directory
$ cd {YOUR_PATH}/canvas-get-page-content
- activate the environment (see step 3 on first run)
$ conda activate canvas-get-page-content
- run the script and follow prompts in terminal
$ python src/get_page_content.py {COURSE_ID} {WPM - optional}
When you run the script, you need to enter the course id as an input, and you can enter a new words per minute (standard is set at 265) if desired.
- i.e) if my course id is 99999, and I want to use a words per minute of 200
$ python src/get_page_content.py 99999 200
- i.e) if my course id is 900, but I want to use the default words per minute
$ python src/get_page_content.py 900
- navigate to your directory
I want to thank and acknowledge the contributors to readtime, which this project uses to calculate page read time!