cancel
Showing results for 
Search instead for 
Did you mean: 
rsauls
Surveyor

Bulk or Batch Updating URLs included throughout Canvas

Jump to solution

I am looking to batch update 1000s of URLs throughout Canvas, but I am not finding a process for this type of update.  Any advice?  The URL's may have been added in Canvas in a variety of areas and in a variety of ways.  Needing to find and replace pattern within the URL- i.e wanting to change abc.com/example to xyz.com/example.

0 Kudos
2 Solutions

Accepted Solutions
robotcars
Navigator

Hi,

I do not have any code to share on this at the moment, and each use case depends on what you have to target. I can provide some guidance for the most efficient way I've figured out how to do this. Since there is no 'content search' in Canvas, the best place to get a current state of key content and descriptions of content in Canvas is through Canvas Data.

If you have Wiki Pages to update, you can consume https://portal.inshosteddata.com/docs#wiki_page_dim into a Db. Do a query for your string, which would return you the course and the wiki page id.

In your code, you would grab that content, replace the necessary string/url, then update the page with the API and repeat for all items found. https://canvas.instructure.com/doc/api/pages.html#method.wiki_pages_api.update

 

This can be repeated for Quiz, Discussions, Assignments

View solution in original post

dgrobani
Adventurer III

I've written a Python script to do this for Canvas pages. It gets each course in one or more subaccounts, gets each wiki page in the course, does a search and replace on the page content, and if the content changes, writes the page content back.

Unfortunately, you'd need to have experience running Python scripts against the Canvas API for it to help you.

View solution in original post

5 Replies
robotcars
Navigator

Hi,

I do not have any code to share on this at the moment, and each use case depends on what you have to target. I can provide some guidance for the most efficient way I've figured out how to do this. Since there is no 'content search' in Canvas, the best place to get a current state of key content and descriptions of content in Canvas is through Canvas Data.

If you have Wiki Pages to update, you can consume https://portal.inshosteddata.com/docs#wiki_page_dim into a Db. Do a query for your string, which would return you the course and the wiki page id.

In your code, you would grab that content, replace the necessary string/url, then update the page with the API and repeat for all items found. https://canvas.instructure.com/doc/api/pages.html#method.wiki_pages_api.update

 

This can be repeated for Quiz, Discussions, Assignments

View solution in original post

dgrobani
Adventurer III

I've written a Python script to do this for Canvas pages. It gets each course in one or more subaccounts, gets each wiki page in the course, does a search and replace on the page content, and if the content changes, writes the page content back.

Unfortunately, you'd need to have experience running Python scripts against the Canvas API for it to help you.

View solution in original post

Can you please share the script?
dgrobani
Adventurer III

I have to do some work on it to make it shareable. I should be able to post it tomorrow.

dgrobani
Adventurer III

OK, I've gathered into one file all my helper functions scattered among multiple modules, expanded the options for specifying the desired accounts and terms, tested it a bunch to make sure it still works, and uploaded it to my GitHub repo: py3-canvaslms-api/page_text_replace.py at master · dgrobani/py3-canvaslms-api.

After the import lines, there are seven parameters to specify, hopefully self-explanatory.

A reminder that this searches only wiki pages, not discussions, etc.

Do let me know if you have any questions. And if you're able to use it, please let me know how it goes. In any event, good luck!