Resetting a course with canvasapi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2020
04:49 PM
I'm trying my hand at a python script that will reset a batch of courses using the canvasapi, and I want to attempt it with the following:
import csv
import sys
from canvasapi import Canvas
API_URL = "https://my.test.instructure.com"
API_KEY = <your api key here>
canvas = Canvas(API_URL, API_KEY)
with open('H:\TESTING RESULTS\cnvs_200227_050011_courses.csv') as csvDataFile:
csvReader = csv.reader(csvDataFile)
for row in csvReader:
courseId = row[0]
partedCourse = courseId.rpartition("-")
term = partedCourse[2]
print(courseId, term)
if term == '21/SP' or term == '21/IN' or term == '20/FA':
course = canvas.get_course(courseId)
course.reset()
I've confirmed that I can successfully read the records from the csv file, and accurately parse out the course ID and term. But can someone confirm that the last 2 lines will perform the desired task?
I'm a total noob at both python and working with the CanvasAPI, so any other suggestions are also welcome.
TIA!
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.