cancel
Showing results for 
Search instead for 
Did you mean: 

Unwrapping Yet Another Python Canvas API Wrapper—and More

Adventurer II
16 2 1,399

For the last several years I’ve been developing a library of Python code that makes my life as Samuel Merritt University’s Canvas admin easier and enables me to turn institutional ideas into reality. Though I’ve always intended to share this code with the Canvas Community in case someone else might find it helpful, it's always been a work in progress, and it’s been all-too-easy to fall into believing it’s not complete enough, not polished enough, not professional enough, not documented enough....

But now, in a mighty effort to stop letting the perfect being the enemy of the good, I’m sharing it just as it is, with these few words of introduction.

I began developing this library in response to an institutional need to import learning outcomes into Canvas courses from CMI, our homebrew, stand-alone assessment tool. I accomplished that through the use of Python, the Requests module, and the Canvas API documentation, as well as PyCharm, the Python IDE I can’t say enough good things about! (Python coders in academic institutions can get a free academic license).

Over time, the library of API call wrappers and utility functions has grown in the process of writing scripts to automate new tasks. Among the tasks I’ve automated using this library are:

  • Sync subaccount-level learning outcomes with outcomes in an external repository.
  • Sync course-level learning outcomes with subaccount-level outcomes.
  • Import outcomes into a course from a formatted Word document.
  • Generate a syllabus for a course by wrangling data from Canvas, our SIS, and CMI into a Word template.
  • Download all syllabus files from courses.
  • List assignments that use the Turnitin API.
  • Retrieve an SIS report.
  • Do an SIS import of enrollments by uploading a CSV file created by running a SQL file against the SIS.
  • Assist in assessing Canvas course design best practices by generating an inventory of specific Canvas features that courses use.
  • Find and replace text in Canvas pages.
  • List all cross-listed courses.
  • List admins at the account and subaccount level.

You can find the code for the core API functions, the utility functions, and the scripts that use them at my GitHub repository. I welcome any and all questions about the code or how to use it, and I’d be supremely grateful to receive recommendations for improving it.

Many thanks to 50581462, toby@ksu.edu‌, and james@richland.edu‌--sharing your work has inspired me to share mine.

Tags (2)
2 Comments
Community Member

Hi Daniel Grobani! I'm really interested in generating a list of Turnitin API assignments and in my search, I found your blog post. I was able to locate the code in github, but I'm a complete novice when it comes to the API, programming, etc. I was able to access the API and generate a token, but that's about it. Can I just copy and past the code somewhere to generate the report? What edits do I have to make to the code? Do I have to download a program to do this for me? Any advice or resources you can point me to would be greatly appreciated. Thanks!

Adventurer II

garciah@oregonstate.edu‌, I apologize for the delay in replying.

To run that report, you'd need to do at least all this, and possibly more:

  1. Download and install Python on your computer.
  2. Install the requests and XlsxWriter Python libraries.
  3. Download the entirety of my code.
  4. Edit the "canvas" and "directories" sections of the /core/config.json file to reflect your institution's details.
  5. Edit the term_data() function in /core/terms.py to reflect your institution's term id's.
  6. Edit the program_data() function in /core/accounts.py to reflect your institution's account id's.
  7. Direct Python to execute the assignments/assignments_turnitin_api_list.py file.

Do you know anyone with programming experience? I suspect that without any programming experience at all, this will be more trouble than it's worth.