0

I'm developing Python scripts for the automated grading of assignments using CanvasAPI, an API wrapper in Python for the Canvas learning management platform. In studying the documentation, I can successfully issue curl commands in Python for a few parameters. For example, this conversion below is for grading a single submission:

Curl command per the Canvas API docs:

PUT /api/v1/courses/:course_id/assignments/:assignment_id/submissions/:user_id

with

 submission[posted_grade]

Turns into this via the CanvasAPI Python wrapper:

edit(submission={'posted_grade': 'grade'})

Where I'm running into difficulties is the more complex parameter for rubrics. Using the same PUT request as above, the syntax in the documentation is as follows:

rubric_assessment[criterion_id][points]

For which I have:

edit(rubric_assessment[{'id': 'criterion_9980'},{'points', '37'}])

However, I get the following error:

Traceback (most recent call last):
  File "C:\Users\danie\AppData\Local\Temp\atom_script_tempfiles\2021528-29488-1eagfyw.k8hw", line 39, in <module>
    submission = assignment.get_submission(10370)
  File "C:\Users\danie\AppData\Local\Programs\Python\Python39\lib\site-packages\canvasapi\assignment.py", line 203, in get_submission
    response = self._requester.request(
  File "C:\Users\danie\AppData\Local\Programs\Python\Python39\lib\site-packages\canvasapi\requester.py", line 255, in request
    raise ResourceDoesNotExist("Not Found")
canvasapi.exceptions.ResourceDoesNotExist: Not Found

I suspect I'm fouling up the syntax somewhere along the line. Any suggestions? All help much appreciated.

Support Ukraine
  • 42,271
  • 4
  • 38
  • 63
  • 1
    try `edit(rubric_assessment={'criterion_9980':{'points': '37'}})` - That's a bunch of changes to yours, so, `rubric_assessment` is now a parameter name to the function with the value being a dictionary, and `criterion_9980` is used as a key to the first dictionary, and the value is a secondary dictionary with a single key of `points` and value of `37`. – Macattack Jun 28 '21 at 20:15
  • That did it! Many thanks! – Daniel Hutchinson Jun 28 '21 at 20:29

0 Answers0