cancel
Showing results for 
Search instead for 
Did you mean: 
jtheaton
Community Participant

Grading an assignment without a submission.

Jump to solution

I have several assignments setup where the student will not actually submit anything through Canvas.  If I am using the web GUI I can easily add a grade to such an assignment, the student does not need to have submitted anything.  However, when I am trying to add a grade through the API I get an error.  I am attempting

PUT:  https://canvas.instructure.com/api/v1/courses/[course id]/assignments/[assignment id]/submissions/[student id]

Body:

{ "submission":{
"posted_grade": 10
}
}  

However, I get the following:

{"errors":[{"message":"The specified resource does not exist."}],"error_report_id":"60780000000096536"}

If I try this same process on a student who has submitted something, it works just fine.  

How can I simply assign a grade to an assignment? (without a submission)

Labels (1)
1 Solution

Accepted Solutions
James
Community Champion

 @jtheaton  

I tried this and it worked for me. It worked on one assignment, but then I realized I had gone into SpeedGrader and made a manual assignment so I could see what call was being made by Canvas and that might have messed up things. I tried it again by duplicating the first assignment and it worked, too. Then I thought that maybe, by duplicating the assignment, it copied over something else that made it work.

Then I made a new assignment and didn't put a date on it. The first two had dates, so I was trying different things. This didn't work. I got a different error, though --- unauthorized. I went in to the assignment and added a date and it didn't make any difference, I was still unauthorized.

What finally worked for me was to use a different API call.  The Grade or comment on multiple submissions endpoint of the Submissions API worked. I then went back to the original call we were testing and tried it with a different student and I was still unauthorized, so it didn't flip whatever needed triggered to make it work. After a little bit, I tried the request you were making with the original student who I was able to successfully score and it worked. Then I tried it with a student I hadn't scored in either set of testing and it worked. In other words, I'm now back to where I started the first two times I tried something with it working.

Is it possible that you had recently created this assignment and that Canvas hadn't had time to add all of the submissions in the background for it yet? It appears to be a timing issue with the PUT call. Also, are you doing this in the production instance or the beta instance of Canvas? I have problems with the beta over the weekend as they reset it.


To test the timing theory, I went back and created a new assignment (test number 4) and the single PUT call worked where I was getting unauthorized before.

I have not yet been able to get the POST to fail, but I'm having trouble duplicating the failure on the PUT, so that may not mean anything. It has the benefit of allowing more than one student's grade to be posted at the same time. I would try using it and see if it works for you

POST /api/v1/courses/:course_id/assignments/:assignment_id/submissions/update_grades

The payload for the POST looks like this for student's with IDs 123456 and 654321.

{
  "grade_data": {
    "123456": {
      "posted_grade": 9
    },
    "654321": {
      "posted_grade": 8
    }
  }
}

By the way, neither of these is the call that Canvas makes from the WebUI in SpeedGrader. It uses an undocumented internal POST to /courses/:course_id/gradebook/update_submission. I can't find the equivalent of that in the API documentation, but we know that the API has to support it since you can grade from the teacher's app and the mobile apps use the API, not internal undocumented calls.  Try the update multiple grades I referred to and let us know if that fixes it.

View solution in original post

2 Replies
James
Community Champion

 @jtheaton  

I tried this and it worked for me. It worked on one assignment, but then I realized I had gone into SpeedGrader and made a manual assignment so I could see what call was being made by Canvas and that might have messed up things. I tried it again by duplicating the first assignment and it worked, too. Then I thought that maybe, by duplicating the assignment, it copied over something else that made it work.

Then I made a new assignment and didn't put a date on it. The first two had dates, so I was trying different things. This didn't work. I got a different error, though --- unauthorized. I went in to the assignment and added a date and it didn't make any difference, I was still unauthorized.

What finally worked for me was to use a different API call.  The Grade or comment on multiple submissions endpoint of the Submissions API worked. I then went back to the original call we were testing and tried it with a different student and I was still unauthorized, so it didn't flip whatever needed triggered to make it work. After a little bit, I tried the request you were making with the original student who I was able to successfully score and it worked. Then I tried it with a student I hadn't scored in either set of testing and it worked. In other words, I'm now back to where I started the first two times I tried something with it working.

Is it possible that you had recently created this assignment and that Canvas hadn't had time to add all of the submissions in the background for it yet? It appears to be a timing issue with the PUT call. Also, are you doing this in the production instance or the beta instance of Canvas? I have problems with the beta over the weekend as they reset it.


To test the timing theory, I went back and created a new assignment (test number 4) and the single PUT call worked where I was getting unauthorized before.

I have not yet been able to get the POST to fail, but I'm having trouble duplicating the failure on the PUT, so that may not mean anything. It has the benefit of allowing more than one student's grade to be posted at the same time. I would try using it and see if it works for you

POST /api/v1/courses/:course_id/assignments/:assignment_id/submissions/update_grades

The payload for the POST looks like this for student's with IDs 123456 and 654321.

{
  "grade_data": {
    "123456": {
      "posted_grade": 9
    },
    "654321": {
      "posted_grade": 8
    }
  }
}

By the way, neither of these is the call that Canvas makes from the WebUI in SpeedGrader. It uses an undocumented internal POST to /courses/:course_id/gradebook/update_submission. I can't find the equivalent of that in the API documentation, but we know that the API has to support it since you can grade from the teacher's app and the mobile apps use the API, not internal undocumented calls.  Try the update multiple grades I referred to and let us know if that fixes it.

View solution in original post

jtheaton
Community Participant

Hello  @James ,

Thank you for your very helpful answer.  I changed my API call to the one you suggested and I can now post grades to both students with/without submissions.

Some additional information.

  1. This is a production install of Canvas at Washington University in St. Louis.
  2. The assignment was created during the summer (maybe 1.5 months ago), when I only had a few students assigned to the course.  
  3. For some reason only around 10 of my students have the system generated submissions, the rest do not.  I am not sure, but maybe new students adding (after the assignment is created) do not get the initial generated submission.  Or perhaps the reverse.