Link an outcome to a rubric via the API

maguire
Community Champion

I have created a set of outcomes using the API (thus saving a lot of copy an paste into the user interface). Now I just want to have a rubric for an assignment use a specific outcome.

If I look at an assignment that has a rubric that is based on an outcome I see:

'rubric': [{'id': '_2958',
'points': 5.0,
'description': 'Pres1',
'long_description': '<p><strong><em>Demonstrate the ability to, in English, clearly present and discuss his or her conclusions and the knowledge and arguments on which they are based in speech and writing to different audiences.</em></strong></p>',
'ignore_for_scoring': False,
'criterion_use_range': False,
'ratings': [{'id': 'blank', 'points': 5.0,
'description': 'Exceeds Expectations', 'long_description': ''},
{'id': '_3187', 'points': 3.0,
'description': 'Meets Expectations', 'long_description': ''},
{'id': 'blank_2', 'points': 0.0,
'description': 'Does Not Meet Expectations',
'long_description': ''}
],
'outcome_id': 1081,
'vendor_guid': None}],
'rubric_settings': {'id': 932,
'title': 'Presentation rubric',
'points_possible': 5.0,
'free_form_criterion_comments': False},‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

However, I do not understand how to pass the outcome_id into the rubric. For example, the following payload is used

    payload={'rubric': {'title': name,
'description': description,
'free_form_criterion_comments': 'false'},
'rubric_association_id': outcome_id,
'rubric_association': {
'association_type': 'Assignment',
'association_id': assignment_id,
'purpose': 'grading'}
}

r = requests.post(url, headers = header, json=payload)

The result of creating the rubric is:
{"rubric":{"id":935,"user_id":29,"rubric_id":null,"context_id":12682,"context_type":"Course","data":[],"points_possible":null,"title":"Presentation outcome","description":null,"created_at":"2019-02-10T18:37:11Z","updated_at":"2019-02-10T18:37:11Z","reusable":false,"public":false,"read_only":false,"association_count":1,"free_form_criterion_comments":false,"context_code":"course_12682","migration_id":null,"hide_score_total":null,"workflow_state":"active","criteria":[],"permissions":{"read":true,"create":true,"delete_associations":true,"update":true,"delete":true}},"rubric_association":{"id":1618,"rubric_id":935,"association_id":85644,"association_type":"Assignment","use_for_grading":false,"created_at":"2019-02-10T18:37:11Z","updated_at":"2019-02-10T18:37:11Z","title":"Presentationsseminarium/Presentation seminar","summary_data":null,"purpose":"grading","url":null,"context_id":12682,"context_type":"Course","hide_score_total":null,"bookmarked":true,"context_code":"course_12682","hide_points":false,"hide_outcome_results":false,"assessment_requests":[],"permissions":{"update":true,"delete":true,"manage":true,"submit":false,"view_rubric_assessments":true},"skip_updating_points_possible":false}}

It makes an outcome, but there is no outcome_id. Thus it appears that my attempt to pass the outcome_id in via the rubric_association_id is not correct. The documentation is rather incomplete for this API, as it says "The id of the object with which this rubric is associated" for both the rubric_association_id and rubric_association[association_id].

So how does one pass in the outcome_id via an API?

I note that  @James  when he imports rubrics from a spreadsheet (Importing Rubrics from a Spreadsheet ) use TamperMokey to pass in the outcome_id via "learning_outcome_id" in the form and a similar approach is used spec/controllers/rubrics_controller_spec.rb.