RubricAssociation using API

Jump to solution
a1063023
Community Explorer

I feel like I'm missing something simple here. I have a rubric in a course, and I'm trying to use the API to assign it to an assignment. I can look up the assignments and find the assignment ID I need, and I can look up the rubrics and find the rubric ID to associate it with.

My resulting API call is something like:

«canvas URL»/api/v1/courses/50277/rubric_associations?rubric_association[rubric_id]=12166&rubric_association[use_for_grading]=true&rubric_association[purpose]=grading&rubric_association[association_type]=Course&rubric_association[association_id]=148286

But this appears to be failing spectacularly. Am I missing something? Do I completely misunderstand how to link a rubric to an assignment?

On a related note, I would also like to be able to create rubrics using the API, but I'm not sure where to start with a rubric[criteria] "Hash". Does this need something more fancy than plain old HTML url strings like the above example?

Regards,

Will

The University of Adelaide

0 Likes
1 Solution
a1063023
Community Explorer
Author

Both of my problems here ended up being related to how my input data was being translated into JSON as the payload. IMO it's quite a good workflow to first create a rubric, and then associate it to things. The second step is much easier than the first so I'll cover that first; the JSON payload needs to look like this:

HTTP POST REQUEST: https://myuni.adelaide.edu.au/api/v1/courses/12345/rubric_associations

JSON payload:

{"rubric_association":{"association_id":111222,"association_type":"Assignment","purpose":"grading","rubric_id":445566,"use_for_grading":true}}

I was rather confused by the API documentation writing this in syntax like rubric_association[association_id]=111222 . I'm assuming if you're reading here that using GET statements to find Assignment IDs and Rubric IDs is easy enough...

The first step is to create the rubric with the API. This is done with a JSON payload that looks like this:

HTTP POST REQUEST: https://myuni.adelaide.edu.au/api/v1/courses/12345/rubrics

JSON payload:

{"rubric":{"criteria":{"0":{"description":"descr 0","long_description":"description criterion 0","points":1,"ratings":{"0":{"description":"foo","points":1},"1":{"description":"bar","points":0}}}},"description":"this is a foo rubric","free_form_criterion_comments":false,"title":"foo rubric"}}

It's really important to note that when creating a rubric like this, it will be INVISIBLE in the Canvas UI until it is associated with an Assignment. So if you need to be able to view it you probably want to create a dummy assignment for that purpose. Once associated the rubric will appear in the Outcomes > Rubrics interface.

View solution in original post

0 Likes