Add sis_source_id to assignment_groups json object

WHY:  For Pinnacle grade pass back, we need to find/create
assignment_groups in Pinnacle using the sis_source_id.  This changeset
exposes that attribute through sis_assignments api.

Test Plan:

In your browser, go to
http://canvas.docker/api/sis/courses/:course_id/assignments

For each assignment you should see a sis_source_id in the
assignment_group

Example:
"assignment_group":
  {"id":4,"name":"quizes","sis_source_id":"0.958053570925386"}

Change-Id: Id62ba0c821a5bbaaeefc4ec1c5fe087397ab1061
Fixes: SIS-2128
Reviewed-on: https://gerrit.instructure.com/82423
Tested-by: Jenkins
Reviewed-by: Jayce Higgins <jhiggins@instructure.com>
Reviewed-by: Josh Simpson <jsimpson@instructure.com>
Reviewed-by: Brad Humphrey <brad@instructure.com>
QA-Review: Steven Shepherd <sshepherd@instructure.com>
Product-Review: Oxana
This commit is contained in:
Stewie (Nicholas Stewart) 2016-06-13 16:15:45 -06:00 committed by Stewie aka Nicholas Stewart
parent f54c5f8e36
commit 75646af86f
3 changed files with 18 additions and 2 deletions

View File

@ -20,7 +20,13 @@ class AssignmentGroup < ActiveRecord::Base
include Workflow
attr_accessible :name, :rules, :assignment_weighting_scheme, :group_weight, :position, :default_assignment_name
attr_accessible :assignment_weighting_scheme,
:default_assignment_name,
:group_weight,
:name,
:position,
:rules,
:sis_source_id
attr_readonly :context_id, :context_type
belongs_to :context, polymorphic: [:course]

View File

@ -25,7 +25,7 @@ module Api::V1::SisAssignment
}.freeze
API_SIS_ASSIGNMENT_GROUP_JSON_OPTS = {
only: %i(id name).freeze
only: %i(id name sis_source_id).freeze
}.freeze
API_SIS_ASSIGNMENT_COURSE_SECTION_JSON_OPTS = {

View File

@ -75,6 +75,16 @@ describe Api::V1::SisAssignment do
course_sections.stubs(:association).returns(OpenStruct.new(:loaded? => true))
end
it "assignment groups have name and sis_source_id" do
ag_name = 'chumba choo choo'
sis_source_id = "my super unique goo-id"
assignment_group = AssignmentGroup.new(name: ag_name, sis_source_id: sis_source_id)
assignment_1.stubs(:assignment_group).returns(assignment_group)
result = subject.sis_assignments_json([assignment_1])
expect(result[0]["assignment_group"]["name"]).to eq(ag_name)
expect(result[0]["assignment_group"]["sis_source_id"]).to eq(sis_source_id)
end
it "returns an empty hash for 0 assignments" do
assignments = []
expect(subject.sis_assignments_json(assignments)).to eq([])