Showing results for 
Show  only  | Search instead for 
Did you mean: 

Bulk Update Default View in Courses

New Member
3 1 435

Here is a script that will take a csv of course SIS IDs and update the default view for all of the SIS IDs to wiki pages.  You can, of course, change the assignment of default view to any of the other parameters.

# import gems
require 'typhoeus'
require 'json'
require 'csv'

canvas_url = '' # put full canvas test url eg:
canvas_token = '' # put canvas API token here'
csv_file = '' # full path to csv file  eg: full/path/to/file/api_courses.csv
default_view = "wiki" #can also use other parameters such as feed, modules, syllabus, assignments

CSV.foreach(csv_file, headers: true) do |row|
    sis_course_id = row['course_id']

    update_course =
        headers: { authorization: "Bearer #{canvas_token}" },
        method: :put,
        params: {
            "course[default_view]" => default_view
        update_course.on_complete do |response|
            if response.code == 200
                data = JSON.parse(response.body)
                puts "The course_id #{sis_course_id} has been updated."
                puts "Something went wrong! Response code was #{response.code}"
Tags (1)
1 Comment