cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
kyle-naber
Community Member

How can one get the criterion ID from an API call?

You can update rubric grades and comments through an API call, but it requires you to give the criterion ID. When you use the API to return a rubric, however, it doesn't contain the IDs, so how can one obtain this information through API calls?

For reference:

Submissions - Canvas LMS REST API Documentation 

Under the 'Grade or comment on a submission' section, it says you can use a rubric_assessment, which would look as follows:

rubric_assessment[criterion_id][points]

Then it goes on to give some example JSON of how the rubric may look:

[  {    'id': 'crit1',    'points': 10,    'description': 'Criterion 1',    'ratings':    [      { 'description': 'Good', 'points': 10 },      { 'description': 'Poor', 'points': 3 }    ]  },  {    'id': 'crit2',    'points': 5,    'description': 'Criterion 2',    'ratings':    [      { 'description': 'Complete', 'points': 5 },      { 'description': 'Incomplete', 'points': 0 }    ]  }]

I'm wondering what API call will return to me this example JSON. I can't seem to find it in the documentation.

4 Replies
James
Community Champion

 @kyle-naber ‌

One way is to get a submission and add the query parameter include[]=rubric_assessment

Here's a rubric assessment from Canvas

219233_pastedImage_3.png

Here's that rubric assessment returned through the API

219232_pastedImage_2.png

The criteria IDs are the values "590403_9111".

The 590403 is the rubric ID and can be looked up using GET /courses/:course_id/rubrics/590403

That returns the rubric, but not the criteria within the rubric.

219234_pastedImage_4.png

And then there's another issue ...

This method only works if you have a submission that has been graded using that rubric. It does not show up for students who have not submitted the assignment. It does not show up for students who have submitted the assignment but the rubric has not been used for scoring. I guess that's why it's called a rubric assessment instead of just a rubric.

The good news is that you can get this before any students do by going into SpeedGrader and filling out the Rubric for the Test Student. Then you can do the query to get the rubric criterion.

There's other ways -- although not particularly friendly to automation.

If you're willing, or forced, to go outside the API, you can get the values from within Canvas.

There's another potential gotcha here. Do you see the context ID in the rubric -- 1655780. That's not the course that I used the rubric in. I copied that rubric from a master course into my section and it's referring to the master course ID. So, if I want to do this next part, I need to go to that course to do the next step. That rubric does not show up in my rubrics for the course that they were being used within. Btw - I've since learned to recreate my rubrics with each course rather than importing them as it seems to minimize the issues.

Go to the Outcomes navigation tab and then click the ... to get Manage Rubrics

219235_pastedImage_6.png

Then click on the rubric.  This one was "Discussion Rubric - Enhanced".

I get this

219236_pastedImage_7.png

Press F12 to open the Developer Tools (this is Firefox, but Chrome works similarly) and click on the pick tool from the top left

219237_pastedImage_8.png

You can also right click somewhere on the page and choose Inspect Element

Then mouse over one of the rows in the table. I would try to stick as close to the left side as you can as it will make it easier to find things.

In the inspector window (source code) of the Developer Tools, you want to find the start of the table row <tr> at the beginning of the section you picked. In the example below, I clicked on the "Follow-Up Quality" criterion.

219239_pastedImage_10.png

It has an id of "criterion_590403_824". The "590403_824" is the criterion ID.

Depending on your comfort level, there's actually an easier way. Instead of mousing of the rubric inside Canvas and then reading the criterion from the Developer Tools, you can mouse over the code in the Inspector Window and see the ID in the Canvas Window.

If you do it this way, you don't need to click on the Pick tool in the top left, just mouse through the code and you'll see it highlighted in Canvas.

Make sure you mouse over the <tr> portion to get this.

219240_pastedImage_11.png

Perhaps the easiest way using this technique though is to collapse the rows.

When you first clicked, it probably looked something like this:

219241_pastedImage_12.png

Find the <tbody> and then start collapsing the <tr> that come right after it. After I collapsed things, I got

219242_pastedImage_13.png

Now it's easy to get all 4 criteria at once. Notice that there is a blank one at the bottom in case people want to add a new criterion. That should be ignored.

Note that you can also get this information from the assignment if the rubric has been attached to an assignment. That will save you from having to go to Outcomes > Manage Rubrics of the correct course to find it.

Among other things, I've been working on a rubric downloader to go along with my rubric importer. The goal was to get the information from Canvas into a way that the rubric importer could use it, so I was not saving the criteria IDs since that's not needed when you create a new rubric. That script basically goes through and scans the information on the page looking for the pieces so that people don't have to do it manually using the DOM inspector. Once that's finished, it shouldn't be too hard for someone to add the criteria to it. I may even make it available because I hadn't considered the need for it before now.

Unfortunately, Canvas Data isn't going to be able to provide you with the information -- at least not currently. And the rubric information is transmitted as part of the page, not loaded through the API. When you open up SpeedGrader for an assignment, the rubric is already there. That's an indicator that the information is not available through the API. While it's possible to have the information available through the API and still deliver it through the web page, the chances of being available through the API go down when that happens. In all of my research while working on the rubric sorter and the rubric importer and now the rubric downloader, I've never come across anything API related, it's all been through undocumented AJAX calls.

Sorry I don't have an easy answer for you, but hopefully this will get you headed in the right direction.

chofer
Community Coach
Community Coach

Hello  @kyle-naber ‌...

I noticed that there hasn't been any new activity in this particular discussion topic since you first posted this question and also received a reply from  @James ‌ later that day.  So, I thought I would check in with you.  While I don't have an answer myself, has the above response from James helped to answer your question?  Or, are you still seeking some assistance with your question?  If you feel that James' response is "Correct", please go ahead and mark it as such.  However, if you are still seeking assistance with your original question, please let us know that by posting a message below so that members of the Canvas Community can continue to help you.  For now, I am going to mark your question as "Assumed Answered" because there hasn't been any new activity in this thread for over a month.  However, that won't prevent you or others from posting additional replies below.  I hope that's okay with you.  Looking forward to hearing from you soon, Kyle!

tdelillo
Community Champion

A use case came up today that would make a rubric downloader very, very useful. We often have faculty going back through old courses to gather data for program reviews, accreditation, etc., and we happen to have one right now who insists that they need not just the student grades but the rubric criteria they were scored on. They're doing this student by student, which is painful. So I'm eager to see what a rubric download Canvancement would look like Smiley Happy

James
Community Champion

One concern is that while the point values fit into a download easily, I'm not sure that incorporating the text with the points does.One possibility would be a rubric downloader that gave you just the rubric, so that you could turn around and import it back in with the rubric importer and then have a separate one that would download the actual scores for each student.

Another possibility would be a Google Sheet approach where the rubric was on one page and the results were on another.