don't overwrite assignment group settings on initial bp sync
test plan: - create assignment groups with group weights / drop rules in Course B, a blueprint course - add some assignments to the groups - create assignment groups with the same names but different properties in Course C, a new course - put some different assignments there - associate Course C with Course B and wait for the initial sync to run - Course C should keep its original assignment group weights and drop rules, and the assignments in both groups should be merged - repeat with a new course but _don't_ set any assignment group rules in the target course. it should inherit the blueprint course's assignment group rules flag = none fixes LS-1109 Change-Id: I0e290e2a85d83031d3c44437df5a6fe5d46c6b7d Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/242828 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: James Williams <jamesw@instructure.com> QA-Review: Robin Kuss <rkuss@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
parent
c329da5755
commit
5fb82817b4
|
@ -75,7 +75,7 @@ module Importers
|
|||
return nil if hash[:migration_id] && hash[:assignment_groups_to_import] && !hash[:assignment_groups_to_import][hash[:migration_id]]
|
||||
item ||= AssignmentGroup.where(context_id: context, context_type: context.class.to_s, id: hash[:id]).first
|
||||
item ||= AssignmentGroup.where(context_id: context, context_type: context.class.to_s, migration_id: hash[:migration_id]).first if hash[:migration_id]
|
||||
item ||= context.assignment_groups.where(name: hash[:title], migration_id: nil).first
|
||||
item ||= match_assignment_group_by_name(context, migration, hash[:title])
|
||||
item ||= context.assignment_groups.temp_record
|
||||
migration.add_imported_item(item)
|
||||
item.saved_by = :migration
|
||||
|
@ -106,5 +106,21 @@ module Importers
|
|||
item.save!
|
||||
item
|
||||
end
|
||||
|
||||
def self.match_assignment_group_by_name(context, migration, name)
|
||||
ag = context.assignment_groups.where(name: name, migration_id: nil).first
|
||||
if ag && migration.for_master_course_import?
|
||||
# prevent overwriting assignment group settings in a pre-existing group that was matched by name
|
||||
downstream_changes = []
|
||||
downstream_changes << 'group_weight' if ag.group_weight&.> 0
|
||||
downstream_changes << 'rules' if ag.rules.present?
|
||||
if downstream_changes.any?
|
||||
tag = migration.master_course_subscription&.content_tag_for(ag)
|
||||
tag.downstream_changes |= downstream_changes
|
||||
tag.save!
|
||||
end
|
||||
end
|
||||
ag
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -584,6 +584,27 @@ describe MasterCourses::MasterMigration do
|
|||
expect(ag1_to.rules).to eq "drop_lowest:3\n"
|
||||
end
|
||||
|
||||
it "doesn't overwrite weights and rules of an assignment group with a similar name on initial sync" do
|
||||
@copy_to = course_factory
|
||||
sub = @template.add_child_course!(@copy_to)
|
||||
|
||||
ag1 = @copy_from.assignment_groups.create!(:name => "group1", :group_weight => 50)
|
||||
a1 = @copy_from.assignments.create!(:title => "assmt1", :assignment_group => ag1)
|
||||
ag1.update_attribute(:rules, "drop_lowest:1\nnever_drop:#{a1.id}\n")
|
||||
|
||||
ag1_assimilation_target = @copy_to.assignment_groups.create!(:name => "group1", :group_weight => 33)
|
||||
ag1_assimilation_target.update_attribute(:rules, "drop_highest:1\n")
|
||||
|
||||
run_master_migration
|
||||
|
||||
ag1_to = @copy_to.assignment_groups.where(:migration_id => mig_id(ag1)).first
|
||||
expect(ag1_to).to eq ag1_assimilation_target
|
||||
expect(ag1_to.group_weight).to eq 33
|
||||
expect(ag1_to.rules).to eq "drop_highest:1\n"
|
||||
a1_to = ag1_to.assignments.first
|
||||
expect(a1_to).to be
|
||||
end
|
||||
|
||||
it "should sync unpublished quiz points possible" do
|
||||
@copy_to = course_factory
|
||||
sub = @template.add_child_course!(@copy_to)
|
||||
|
|
Loading…
Reference in New Issue