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

Canvas API to update rubric doesn't honour free-form argument

Jump to solution

I'm having some issues with the Canvas API for rubrics. I'm trying to assign, to an assignment, a rubric that has free-form criterion comments, but the option is never accepted. I send a POST request to https://MY_UNIVERSITY_CANVAS_HOST/api/v1/courses/COURSEID/rubrics with the following body:

{"rubric": {"title": "Lab Assignment 1: Numbers and Memory", "free_form_criterion_comments": true,
"criteria": {"0": {"description": "Q1", "long_description": "Q1: 4-Byte, little-endian value at location",
"id": "Q1", "criterion_use_range": true, "points": 4.0, "ratings": {"0": {"points": 4.0,
"description": "Full Marks", "criterion_id": "Q1", "id": "Q1YES"}, "1": {"points": 0,
"description": "No Marks", "criterion_id": "Q1", "id": "Q1NO"}}}, "1": {"description": "Q2",
"long_description": "Q2: 8-byte, big-endian value at location", "id": "Q2", "criterion_use_range": true,
"points": 4.0, "ratings": {"0": {"points": 4.0, "description": "Full Marks", "criterion_id": "Q2",
"id": "Q2YES"}, "1": {"points": 0, "description": "No Marks", "criterion_id": "Q2", "id": "Q2NO"}}}}},
"rubric_association": {"association_id": 522692, "association_type": "Assignment", "use_for_grading": true,
"purpose": "grading", "free_form_criterion_comments": true}, "free_form_criterion_comments": true}

As you can see I tried to set "free_form_criteria_comments" to true in several levels, but neither of them works. The rubric is properly created and assigned to the corresponding assignment, the criteria are properly loaded, but there is nothing I can do that will set the free-form criterion comments argument to True. Has anyone found the same issue?

1 Solution

Accepted Solutions
James
Community Champion

 @jonatan  

When I can't figure out an API call, I sometimes like to see what Canvas is sending. I do this by opening the browser's developer tools (normally F12) and going to the network tab. Then I click the button in Canvas to do whatever I want to do and see what it's sending.

It's not using the Rubric API, but an internal AJAX call, that Canvas is using, but the formats should be similar.

{
"rubric":{
"title":"Lab Assignment 1: Numbers and Memory",
"points_possible":"8",
"free_form_criterion_comments":"1",
"criteria":{
"0":{
"description":"Q1",
"points":"4",
"learning_outcome_id":"",
"long_description":"Q1: 4-Byte, little-endian value at location",
"id":"",
"criterion_use_range":"false",
"ratings":{
"0":{
"description":"Full Marks",
"long_description":"",
"points":"4",
"id":"blank"
},
"1":{
"description":"No Marks",
"long_description":"",
"points":"0",
"id":"blank_2"
}
}
},
"1":{
"description":"Q2",
"points":"4",
"learning_outcome_id":"",
"long_description":"Q2: 8-byte, big-endian value at location",
"id":"",
"criterion_use_range":"false",
"ratings":{
"0":{
"description":"Full Marks",
"long_description":"",
"points":"4",
"id":"blank"
},
"1":{
"description":"No Marks",
"long_description":"",
"points":"0",
"id":"blank_2"
}
}
}
}
},
"rubric_association":{
"use_for_grading":"1",
"hide_score_total":"0",
"hide_points":"0",
"hide_outcome_results":"0",
"id":"",
"association_type":"Assignment",
"association_id":"26447437",
"purpose":"grading"
},
"rubric_association_id":"",
"title":"Lab Assignment 1: Numbers and Memory",
"points_possible":"8",
"rubric_id":"new",
"skip_updating_points_possible":"true"
}

As documented, the free_form_criteria_comments is a property of the rubric object.

Since I want to use the API and sometimes things differ, I did test the API with that payload.  I deleted the rubric from within Canvas and then made the API call with exactly information above. It created the rubric and configured it with free form comments.

You will, of course, need to change the association_id to match yours.

View solution in original post

3 Replies
James
Community Champion

 @jonatan  

When I can't figure out an API call, I sometimes like to see what Canvas is sending. I do this by opening the browser's developer tools (normally F12) and going to the network tab. Then I click the button in Canvas to do whatever I want to do and see what it's sending.

It's not using the Rubric API, but an internal AJAX call, that Canvas is using, but the formats should be similar.

{
"rubric":{
"title":"Lab Assignment 1: Numbers and Memory",
"points_possible":"8",
"free_form_criterion_comments":"1",
"criteria":{
"0":{
"description":"Q1",
"points":"4",
"learning_outcome_id":"",
"long_description":"Q1: 4-Byte, little-endian value at location",
"id":"",
"criterion_use_range":"false",
"ratings":{
"0":{
"description":"Full Marks",
"long_description":"",
"points":"4",
"id":"blank"
},
"1":{
"description":"No Marks",
"long_description":"",
"points":"0",
"id":"blank_2"
}
}
},
"1":{
"description":"Q2",
"points":"4",
"learning_outcome_id":"",
"long_description":"Q2: 8-byte, big-endian value at location",
"id":"",
"criterion_use_range":"false",
"ratings":{
"0":{
"description":"Full Marks",
"long_description":"",
"points":"4",
"id":"blank"
},
"1":{
"description":"No Marks",
"long_description":"",
"points":"0",
"id":"blank_2"
}
}
}
}
},
"rubric_association":{
"use_for_grading":"1",
"hide_score_total":"0",
"hide_points":"0",
"hide_outcome_results":"0",
"id":"",
"association_type":"Assignment",
"association_id":"26447437",
"purpose":"grading"
},
"rubric_association_id":"",
"title":"Lab Assignment 1: Numbers and Memory",
"points_possible":"8",
"rubric_id":"new",
"skip_updating_points_possible":"true"
}

As documented, the free_form_criteria_comments is a property of the rubric object.

Since I want to use the API and sometimes things differ, I did test the API with that payload.  I deleted the rubric from within Canvas and then made the API call with exactly information above. It created the rubric and configured it with free form comments.

You will, of course, need to change the association_id to match yours.

View solution in original post

jonatan
Community Participant

Yes, that was it. The problem was that it wasn't accepting the true value, but it accepted '1'. This seems like a problem with the documentation that lists the field as a boolean, even though it's not accepting the boolean. Thank you very much for your help.

James
Community Champion

I'm glad you got it working.

It's strange if that's the issue. According to the very top page of the API documentation:

All boolean parameters can be passed as true/false, t/f, yes/no, y/n, on/off, or 1/0. When using JSON format, a literal true/false is preferred, rather than as a string.