Bulk upload of pages created in an outside HTML editor

0 Likes
(2)

It would be nice to have a mechanism which allows to create pages for a course outside of Canvas and then upload them (as pages). Or, failed that, upload them as files and then convert these HTML files into Canvas pages.

Here is one rationale for doing that. Let us say you teach the same course quite often. The structure of the class is always the same, but there are some minor things that needs to be tweaked. They are easy to modify on your computer but take forever to modify in Canvas. Basically, on your computer you can write and run a script that updates templates created once and for all, but in Canvas you have to open and edit each and every page, and there are quite a few of them. Opening the HTML editor and copy/pasting works when you only have a very limited number of pages, but when you have 20+ of them, it consumes a lot of time. Having fewer pages is not an option because that would be inconvenient for students.

9 Comments
Stef_retired
Instructure Alumni
Instructure Alumni
Status changed to: Moderating

@jgrnst 

Have you looked into embedding Google Docs on Canvas pages? I created course templates used for two different math courses that our school used to populate almost 300 separate courses; the master documents were owned and maintained by the department chair who could make changes behind the scenes in the Google Doc and automatically populate those changes to all of those courses without touching Canvas at all. This is an old blog post but it is still largely accurate: Using Google Docs for dynamic Canvas content  When embedded correctly, the content integrates seamlessly into the Canvas page.

Would that work?

jgrnst
Community Member

Thank you for this suggestion. Let me check if it works for my purposes.

jgrnst
Community Member

In this model, if I understand correctly, once you make a change, it affects all instances of the corresponding page, including the past courses. I am trying to create a model in which the making of a new copy of the course takes the least time possible while the previous copy remains intact.

Stef_retired
Instructure Alumni
Instructure Alumni

@jgrnst 

Yes, you're correct on that score. For some users, that might not matter, but I can see that in your use case it's not optimal. We can certainly move this idea forward for broader discussion.

Stef_retired
Instructure Alumni
Instructure Alumni
Status changed to: Open
 
jgrnst
Community Member

Thank you.

LarsDeRichter
Community Member

I was just looking if this was possible in Canvas. I would love to see something like this. 

Zip a folder with HTML-pages (and supporting image files) and upload it as course materials, maybe even as a single module with all the pages.

jgrnst
Community Member

I fount a way to do it via API. One can write a rather simple-minded script that creates pages in a given Canvas course from all HTML files in a directory (for example in Python)

 

 

 

import requests
import json
import glob
import os

token= "" # API token (generated in Canvas) 
canvas="https://" # Canvas url
api= canvas+"/api/v1"   # 
headers    = {'Authorization' : 'Bearer ' + '%s' % token}
course_id = # Course ID
path = ""

files=glob.glob(path+"*.html")

for f in files:
    pn = os.path.splitext(os.path.basename(ff))[0]  # Each page is given the name of the corresponding file without the .html suffix
    fh = open(f,"r")
    body = fh.read()
    payload = { 'wiki_page[title]' : pn, 'wiki_page[body]': body, 'wiki_page[editing_roles]':"teachers", 'wiki_page[published]': 'false'}

    url = api + 'courses/'+ str(course_id) +'/pages'
    requests.post(url, params = payload, headers = headers)

 

 

Some remarks:

- pages created by this script remain unpublished; replacing 'false' with 'true' in wiki_page[published] changes that behavior;

- there is, probably, some limit on the size of page body;

- to the best of my knowledge, Canvas does not support JavaScript and supports only certain ways of using CSS; 

- it is not hard to write a script that creates modules and populates them with pages if you have a fixed module/page structure for your course;

- uploading files (as opposed to creating pages) via API is a bit tricky. Unlike creating a page, it is a 3-stage process;

ProductPanda
Instructure
Instructure
Status changed to: Archived
Comments from Instructure

As part of the new Ideas & Themes process, all ideas in Idea Conversations were reviewed by the Product Team. Any Idea that was associated with an identified theme was moved to the new Idea & Themes space. Any Idea that was not part of the move is being marked as Archived. This will preserve the history of the conversations while also letting Community members know that Instructure will not explore the request at this time.