cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
boyland
Community Participant

Creating a rubric using REST API

Jump to solution

I' trying to create rubrics using the REST API.  I have a number of questions, but most seriously, I seem unable to give non-zero points to a criterion.  Here's the JSON that I have used to successfully create a rubric with one criterion:

{"id":"1006",
 "rubric":{
     "title":"Small Rubric 6",
     "criteria":{"1":{"id":"1","description":"Criterion 1","criterion_points":1,"points":1}}},
 "rubric_association":{
     "association_type":"Course",
     "association_id":19297}}

The result is:

{"rubric":{"id":216915,"user_id":21489,"rubric_id":null,"context_id":19297,"context_type":"Course","data":[{"description":"Criterion 1","long_description":"","points":0,"id":"1","criterion_use_range":false,"ratings":[]}],"points_possible":0.0,"title":"Small Rubric 6","description":null,"created_at":"2021-08-19T14:39:03Z","updated_at":"2021-08-19T14:39:03Z","reusable":false,"public":false,"read_only":false,"association_count":0,"free_form_criterion_comments":null,"context_code":"course_19297","migration_id":null,"hide_score_total":null,"workflow_state":"active","root_account_id":1,"criteria":[{"description":"Criterion 1","long_description":"","points":0,"id":"1","criterion_use_range":false,"ratings":[]}],"permissions":{"read":true,"create":true,"delete_associations":true,"update":true,"delete":true}},"rubric_association":{"id":442656,"rubric_id":216915,"association_id":19297,"association_type":"Course","use_for_grading":false,"created_at":"2021-08-19T14:39:03Z","updated_at":"2021-08-19T14:39:03Z","title":"Blank - John Boyland - 1","summary_data":null,"purpose":"unknown","url":null,"context_id":19297,"context_type":"Course","hide_score_total":null,"bookmarked":true,"context_code":"course_19297","hide_points":false,"hide_outcome_results":false,"root_account_id":1,"workflow_state":"active","assessment_requests":[],"permissions":{"update":true,"delete":true,"manage":true,"submit":false,"view_rubric_assessments":true},"skip_updating_points_possible":false}}
  • Notice how the points for the criterion is set to zero. In the input JSON, I originally just had "points":0.  I later added "criterion_points" in a vain bid to try to find what key it actually is looking for (Apparently the REST API documentation sometimes gets the key wrong).  What does the REST API actually want?
  • Notice how the result has both "data" and "criteria"  (why?)
  • Why does POST want an id for the rubric?  It generated its own anyway.
  • Why do we need to use an id for each criterion in a "hash" rather than just using an array of criteria objects?

But most importantly: how do I specify the points fo the criterion?

Labels (1)
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
boyland
Community Participant

I've worked further and can answer some of my own questions (at least partly).  The following JSON creates a rubric with points:

{"rubric":{
    "title":"Small Rubric 12",
    "criteria":{
	"1":{
	     "description":"Criterion 1",
	     "ratings":{
		 "1":{
		      "description":"Full credit",
		      "points":1.0},
		 "2":{
		      "description":"No credit",
		      "points":0.0}
	     }}}},
 "rubric_association":{
     "association_type":"Course",
     "association_id":19297}}
  1. It seems that adding ratings with points is enough to get the criterion points.  The "points" field is apparently ignored.
  2. Still not sure why having both criteria and data is happening.
  3. The "id" field is not needed and is ignored (contra documentation)
  4. The criteria don't need ids, but apparently, we need an object with keys, not an array (though I though JavaScript treated the same?)

The result of the sample is

{"rubric":{"id":217021,"user_id":21489,"rubric_id":null,"context_id":19297,"context_type":"Course","data":[{"description":"Criterion 1","long_description":"","points":1.0,"id":"_1593","criterion_use_range":false,"ratings":[{"description":"Full credit","long_description":"","points":1.0,"criterion_id":"_1593","id":"_4031"},{"description":"No credit","long_description":"","points":0.0,"criterion_id":"_1593","id":"_8692"}]}],"points_possible":1.0,"title":"Small Rubric 12","description":null,"created_at":"2021-08-19T15:51:25Z","updated_at":"2021-08-19T15:51:25Z","reusable":false,"public":false,"read_only":false,"association_count":0,"free_form_criterion_comments":null,"context_code":"course_19297","migration_id":null,"hide_score_total":null,"workflow_state":"active","root_account_id":1,"criteria":[{"description":"Criterion 1","long_description":"","points":1.0,"id":"_1593","criterion_use_range":false,"ratings":[{"description":"Full credit","long_description":"","points":1.0,"criterion_id":"_1593","id":"_4031"},{"description":"No credit","long_description":"","points":0.0,"criterion_id":"_1593","id":"_8692"}]}],"permissions":{"read":true,"create":true,"delete_associations":true,"update":true,"delete":true}},"rubric_association":{"id":442842,"rubric_id":217021,"association_id":19297,"association_type":"Course","use_for_grading":false,"created_at":"2021-08-19T15:51:25Z","updated_at":"2021-08-19T15:51:25Z","title":"Blank - John Boyland - 1","summary_data":null,"purpose":"unknown","url":null,"context_id":19297,"context_type":"Course","hide_score_total":null,"bookmarked":true,"context_code":"course_19297","hide_points":false,"hide_outcome_results":false,"root_account_id":1,"workflow_state":"active","assessment_requests":[],"permissions":{"update":true,"delete":true,"manage":true,"submit":false,"view_rubric_assessments":true},"skip_updating_points_possible":false}}

View solution in original post

0 Kudos
2 Replies
boyland
Community Participant

I've worked further and can answer some of my own questions (at least partly).  The following JSON creates a rubric with points:

{"rubric":{
    "title":"Small Rubric 12",
    "criteria":{
	"1":{
	     "description":"Criterion 1",
	     "ratings":{
		 "1":{
		      "description":"Full credit",
		      "points":1.0},
		 "2":{
		      "description":"No credit",
		      "points":0.0}
	     }}}},
 "rubric_association":{
     "association_type":"Course",
     "association_id":19297}}
  1. It seems that adding ratings with points is enough to get the criterion points.  The "points" field is apparently ignored.
  2. Still not sure why having both criteria and data is happening.
  3. The "id" field is not needed and is ignored (contra documentation)
  4. The criteria don't need ids, but apparently, we need an object with keys, not an array (though I though JavaScript treated the same?)

The result of the sample is

{"rubric":{"id":217021,"user_id":21489,"rubric_id":null,"context_id":19297,"context_type":"Course","data":[{"description":"Criterion 1","long_description":"","points":1.0,"id":"_1593","criterion_use_range":false,"ratings":[{"description":"Full credit","long_description":"","points":1.0,"criterion_id":"_1593","id":"_4031"},{"description":"No credit","long_description":"","points":0.0,"criterion_id":"_1593","id":"_8692"}]}],"points_possible":1.0,"title":"Small Rubric 12","description":null,"created_at":"2021-08-19T15:51:25Z","updated_at":"2021-08-19T15:51:25Z","reusable":false,"public":false,"read_only":false,"association_count":0,"free_form_criterion_comments":null,"context_code":"course_19297","migration_id":null,"hide_score_total":null,"workflow_state":"active","root_account_id":1,"criteria":[{"description":"Criterion 1","long_description":"","points":1.0,"id":"_1593","criterion_use_range":false,"ratings":[{"description":"Full credit","long_description":"","points":1.0,"criterion_id":"_1593","id":"_4031"},{"description":"No credit","long_description":"","points":0.0,"criterion_id":"_1593","id":"_8692"}]}],"permissions":{"read":true,"create":true,"delete_associations":true,"update":true,"delete":true}},"rubric_association":{"id":442842,"rubric_id":217021,"association_id":19297,"association_type":"Course","use_for_grading":false,"created_at":"2021-08-19T15:51:25Z","updated_at":"2021-08-19T15:51:25Z","title":"Blank - John Boyland - 1","summary_data":null,"purpose":"unknown","url":null,"context_id":19297,"context_type":"Course","hide_score_total":null,"bookmarked":true,"context_code":"course_19297","hide_points":false,"hide_outcome_results":false,"root_account_id":1,"workflow_state":"active","assessment_requests":[],"permissions":{"update":true,"delete":true,"manage":true,"submit":false,"view_rubric_assessments":true},"skip_updating_points_possible":false}}

View solution in original post

0 Kudos
chofer
Community Coach
Community Coach

Hello there, @boyland ...

Full disclosure...  I have practically zero experience with REST API, and so I probably don't understand why you would want to use this method to create a rubric in Canvas.  (I'm sure there are reasons that I'm not thinking of...and would be interested to learn more.)  Have you ever tried the "Canvancement" (Canvas Enhancement) from @James Jones where you can create a rubric in an Excel spreadsheet and import it into a Canvas course?  I use it all the time, and it's fantastic!  Importing Rubrics from a Spreadsheet - Instructure Community

I know this isn't a direct answer to your question, but I thought I'd share this information with you in case you've not seen it before.  Hope is will be of some help/use to you.