Resetting a course with canvasapi

swaldie
Community Explorer

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!