[ARCHIVED] How to create a TurnItIn assignment using the "plagiarism framework" via the canvas API

andrew_mathas
Community Participant

Previously I have created TurnItIn assignments on canvas using the canvas API with (python) code like:

import requests
access_token =' .... '
assignment={'assignment': {
     'description': 'A really wonderful test assignment',
     'due_at': '2020-02-23T12:59:59Z',
     'grading_type': 'points',
     'name': 'Another test Assignment',
     'points_possible': 32.0,
     'submission_types': ['external_tool'],
     'external_tool_tag_attributes': {'url': 'https://api.turnitin.com/api/lti/1p0/assignment'},
    }
}
headers = {'Accept': 'application/json',
 'Authorization': 'Bearer ' + access_token,
 'Cache-control': 'no-cache',
 'Content-Type': 'application/json; charset=UTF-8'}
}
requests.post(url='https://canvas....u/api/v1/courses/./.../assignments',
                headers=headers, json=assignment)

This worked fine but this interface is being phased out and I need to start using the plagiarism framework. Specifically, I want the assignments created through the API to have these settings:

canvas screens

Using the code above but with

assignment={'assignment': {
     'description': 'A really wonderful test assignment',
     'due_at': '2020-02-23T12:59:59Z',
     'grading_type': 'points',
     'name': 'Another test Assignment',
     'points_possible': 32.0,
     'submission_types': ['online_upload'],
    }
}

I get close to what I want except that when I go into canvas and edit the assignment created this way the "Select to use TurnItIn" menu is set to "None". So I have not enabled TurnItIn, which is not surprising since the json above does not mention it. The canvas documentation seems to suggest that setting

assignment['assignment]['turnitin_enabled] = true

might solve my problem but this does not help.

I have tried many variations on the code above, combed through the canvas API documentation and searched on the net but I can't find anything does what I want. Previously I was able to troubleshoot assignments by looking at the output from an API call

GET /api/v1/courses/:course_id/assignments/:id

but, surprisingly, there is no change in the returned json for the assignment before and after TurnItIn is manually added to the assignment, so I can't see what to change in my API call to create the assignment.

Is anyone able to suggest what I should do?

Labels (2)
Users who also had this question