[ARCHIVED] Creating a rubric using REST API

Jump to solution
boyland
Community Explorer

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 (2)
0 Likes
1 Solution
boyland
Community Explorer
Author

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