Is there a way to associate a rubric with an assignment using the API?

I would like to create a single page where I can quickly associate already created rubrics with assignments. This page would list all of the assignments and then next to each assignment title there would be a dropdown list with all of the rubrics. I'd choose the rubric from the list for each assignment. Also, it would default as use_rubric_for_grading=true. Then I'd hit submit, and Bob's your uncle, the rubric id is associated with the assignment. This would save me some time having to open each assignment and going through all of the click.

My issue is that after going through all of the documentation I can't see a way to make this association. I would have thought that there would be a request parameter of something like assignment[rubric_id]=1234, but I don't see anything like that in the documentation. So if it isn't in the documentation, does that pretty much mean it's not possible, or is there a super-secret set of parameters that I'm hopefully missing out on and if I pass some kind of initiation a whole set of request parameters will open up to me? :-)

To go along with what Daniel Grobani wrote, who I suspect is right, one thing to look for is the existence of the functionality within the mobile apps. I don't have my iPad with me to check right now, but if you cannot do something -- like associating a rubric with an assignment -- the chance that the existence of that functionality in the API goes down.

Another thing to do is open the developer tools (usually F12) in the browser and watch the network traffic when you do something in the web interface. In this case, when you attach a rubric to an assignment, it makes a non-API call to the rubric_associations page.

Here's the call it made when I tested it. Notice the lack of /api/v1 in there.

The rubric_association[association_id] = 3938359 is the assignment ID because the association_type is "Assignment".

And it gets a response that contains a rubric and rubric_association object. Of particular note is the rubric_association, which contains information like this:

If I then edit the rubric to turn back on the Use for grading (this was a rubric that I used the find rubric for), it made another non-API call to the rubric itself.

https://richland.beta.instructure.com/courses/896851/rubrics/542712

This sent a full rubric and some other information, part of which was:

Note that the rubric_association_id of 2370293 is the id from the rubric_association that was created earlier.

If it's a brand new rubric instead of an existing one, then you leave the rubric_association_id stuff blank and Canvas will assign it with the returned response. Here's part of what a new rubric sends (as opposed to updating an existing one).

But none of those are API calls. Sometimes there are undocumented features in the API, but those are normally when everything else works except for one part, not when whole sections are missing, so I wouldn't count on it.

What you could do is write some JavaScript to fake the form that Canvas sends. I did this when I wrote Importing Rubrics from a Spreadsheet. It allowed you to copy/paste information from a spreadsheet into a dialog box and then processed it like it was a rubric created within Canvas. You could also explore a headless browser scenario.

To go along with what Daniel Grobani wrote, who I suspect is right, one thing to look for is the existence of the functionality within the mobile apps. I don't have my iPad with me to check right now, but if you cannot do something -- like associating a rubric with an assignment -- the chance that the existence of that functionality in the API goes down.

Another thing to do is open the developer tools (usually F12) in the browser and watch the network traffic when you do something in the web interface. In this case, when you attach a rubric to an assignment, it makes a non-API call to the rubric_associations page.

Here's the call it made when I tested it. Notice the lack of /api/v1 in there.

The rubric_association[association_id] = 3938359 is the assignment ID because the association_type is "Assignment".

And it gets a response that contains a rubric and rubric_association object. Of particular note is the rubric_association, which contains information like this:

If I then edit the rubric to turn back on the Use for grading (this was a rubric that I used the find rubric for), it made another non-API call to the rubric itself.

https://richland.beta.instructure.com/courses/896851/rubrics/542712

This sent a full rubric and some other information, part of which was:

Note that the rubric_association_id of 2370293 is the id from the rubric_association that was created earlier.

If it's a brand new rubric instead of an existing one, then you leave the rubric_association_id stuff blank and Canvas will assign it with the returned response. Here's part of what a new rubric sends (as opposed to updating an existing one).

But none of those are API calls. Sometimes there are undocumented features in the API, but those are normally when everything else works except for one part, not when whole sections are missing, so I wouldn't count on it.

What you could do is write some JavaScript to fake the form that Canvas sends. I did this when I wrote Importing Rubrics from a Spreadsheet. It allowed you to copy/paste information from a spreadsheet into a dialog box and then processed it like it was a rubric created within Canvas. You could also explore a headless browser scenario.