export the course's grading_standard too
The course.grading_standard isn't necessarily included in course.grading_standards -- I think because in the old course copy code, we just copied the id over and the standard was still owned by the old course. This change makes it so we export+import that standard, as well. Note there is a difference still here, the old course copy was a copy by ref rather than copy by value, so updating the standard in one place updated it everywhere. That's not true of the new export/import workflow. closes #9197 test plan: make a course that has a grading_standard_id pointing to a standard owned by another course (or find one already in the db). copy that course, and verify that the new course correctly has the standard as well. Change-Id: I74272db46f511cc329c68493962ef35aedfeba5d Reviewed-on: https://gerrit.instructure.com/12000 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
This commit is contained in:
parent
31ec2fb58d
commit
3596e85083
|
@ -18,7 +18,8 @@
|
|||
module CC
|
||||
module GradingStandards
|
||||
def create_grading_standards(document=nil)
|
||||
return nil unless @course.grading_standards.count > 0
|
||||
standards_to_copy = (@course.grading_standards.to_a + [@course.grading_standard]).compact
|
||||
return nil unless standards_to_copy.size > 0
|
||||
|
||||
if document
|
||||
standards_file = nil
|
||||
|
@ -35,7 +36,7 @@ module CC
|
|||
"xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance",
|
||||
"xsi:schemaLocation"=> "#{CCHelper::CANVAS_NAMESPACE} #{CCHelper::XSD_URI}"
|
||||
) do |standards_node|
|
||||
@course.grading_standards.each do |standard|
|
||||
standards_to_copy.each do |standard|
|
||||
migration_id = CCHelper.create_key(standard)
|
||||
standards_node.gradingStandard(:identifier=>migration_id, :version=>standard.version) do |standard_node|
|
||||
standard_node.title standard.title unless standard.title.blank?
|
||||
|
|
|
@ -166,6 +166,19 @@ describe ContentMigration do
|
|||
@copy_to.grading_standard.should == gs
|
||||
end
|
||||
|
||||
it "should copy a course grading standard not owned by the copy_from course" do
|
||||
@other_course = course_model
|
||||
gs = make_grading_standard(@other_course)
|
||||
@copy_from.grading_standard = gs
|
||||
@copy_from.grading_standard_enabled = true
|
||||
@copy_from.save!
|
||||
|
||||
run_course_copy
|
||||
|
||||
@copy_to.grading_standard_enabled.should be_true
|
||||
@copy_to.grading_standard.data.should == gs.data
|
||||
end
|
||||
|
||||
it "should create a warning if an account grading standard can't be found" do
|
||||
gs = make_grading_standard(@copy_from.root_account)
|
||||
@copy_from.grading_standard = gs
|
||||
|
|
Loading…
Reference in New Issue