Creating and Editing Assignments with Plagiarism Review via API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My institution recently integrated our Canvas instance with Copyleaks. I already utilize the Canvas API for a few things in my courses. One of those things is creating and editing assignments.
I would like to update my use of the API to mimic the behavior of creating/editing a course using a browser and selecting the "Copyleaks (Plagiarism Checker)" option in the dropdown within the "Plagiarism Review" section. I've attached some screenshots to showcase what I'm trying to achieve from the API.
I can't seem to find any references on how I can achieve this behavior in the REST-based online documentation. I also looked around the new (not well documented) GraphQL documenation, but still no luck.
I'm cool using either system (REST or GraphQL), but I need some guidance on how to achieve my goal.
Any assistance would be greatly appreciated!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks to the awesome answer to a similar question by @afromero2, I was able to figure out how to accomplish my goal!
I refactored the php code that was used in that answer. In case anyone else is interested in doing this, here's the snippet I wrote:
import requests
import json
# Pretend canvas url
url = "https://my.canvas.edu"
# Pretend course id
course = "12345"
#Pretend assignment id
assignment = "54321"
#Pretend plagiarism LTI id
lti = "999"
#Pretend bearer token
token = "abc123"
request_url = "{}/api/v1/courses/{}/assignments/{}".format(url, course, assignment)
# Create the payload
payload = {
'assignment': {
'id': assignment,
'submission_types': ['online_upload'],
'submission_type': 'online',
'similarityDetectionTool': 'Lti::MessageHandler_' + lti,
'configuration_tool_type': 'Lti::MessageHandler',
'report_visibility': 'immediate'
}
}
# Define the headers
headers = {
'Authorization': 'Bearer {}'.format(token),
'Content-Type': 'application/json',
'cache-control': 'no-cache'
}
# Make the PUT request
response = requests.put(url, headers=headers, data=json.dumps(payload))
# Check on response status
if response.status_code == 200:
print("Yay!")
else:
print("Boo!")