From 67660ed8f0bc9ad82a2e9789047cb94a2764f588 Mon Sep 17 00:00:00 2001 From: James Williams Date: Mon, 29 Apr 2013 08:42:39 -0600 Subject: [PATCH] fix non-integer rubric point values in course copy test plan: * create a rubric using non-decimal point values (e.g. '1.5') * copy the course * should retain the same values fixes #CNVS-1625 Change-Id: I23031bdf10c8ea2932bdd7c770ece14fddc3a12e Reviewed-on: https://gerrit.instructure.com/20150 Tested-by: Jenkins Reviewed-by: Bracken Mosbacker Product-Review: Bracken Mosbacker QA-Review: Adam Phillipps --- lib/cc/importer/canvas/rubrics_converter.rb | 6 +++--- spec/models/content_migration_spec.rb | 12 +++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/cc/importer/canvas/rubrics_converter.rb b/lib/cc/importer/canvas/rubrics_converter.rb index 7ba5989f39e..8d553293dee 100644 --- a/lib/cc/importer/canvas/rubrics_converter.rb +++ b/lib/cc/importer/canvas/rubrics_converter.rb @@ -41,8 +41,8 @@ module CC::Importer::Canvas crit[:id] = get_node_val(c_node, 'criterion_id') crit[:description] = get_node_val(c_node, 'description') crit[:long_description] = get_val_if_child(c_node, 'long_description') - crit[:points] = get_int_val(c_node, 'points') - crit[:mastery_points] = get_int_val(c_node, 'mastery_points') + crit[:points] = get_float_val(c_node, 'points') + crit[:mastery_points] = get_float_val(c_node, 'mastery_points') crit[:learning_outcome_migration_id] = get_node_val(c_node, 'learning_outcome_identifierref') crit[:title] = get_node_val(c_node, 'description') crit[:ratings] = [] @@ -51,7 +51,7 @@ module CC::Importer::Canvas rating[:description] = get_node_val(rat_node, 'description') rating[:id] = get_node_val(rat_node, 'id') rating[:criterion_id] = get_node_val(rat_node, 'criterion_id') - rating[:points] = get_int_val(rat_node, 'points') + rating[:points] = get_float_val(rat_node, 'points') crit[:ratings] << rating end diff --git a/spec/models/content_migration_spec.rb b/spec/models/content_migration_spec.rb index a6c438ee3c1..aa976b368f2 100644 --- a/spec/models/content_migration_spec.rb +++ b/spec/models/content_migration_spec.rb @@ -868,7 +868,7 @@ describe ContentMigration do def create_rubric_asmnt @rubric = @copy_from.rubrics.new @rubric.title = "Rubric" - @rubric.data = [{:ratings=>[{:criterion_id=>"309_6312", :points=>5, :description=>"Full Marks", :id=>"blank", :long_description=>""}, {:criterion_id=>"309_6312", :points=>0, :description=>"No Marks", :id=>"blank_2", :long_description=>""}], :points=>5, :description=>"Description of criterion", :id=>"309_6312", :long_description=>""}] + @rubric.data = [{:ratings=>[{:criterion_id=>"309_6312", :points=>5.5, :description=>"Full Marks", :id=>"blank", :long_description=>""}, {:criterion_id=>"309_6312", :points=>0, :description=>"No Marks", :id=>"blank_2", :long_description=>""}], :points=>5.5, :description=>"Description of criterion", :id=>"309_6312", :long_description=>""}] @rubric.save! @assignment = @copy_from.assignments.create!(:title => "some assignment", :points_possible => 12) @@ -887,6 +887,16 @@ describe ContentMigration do rub = @copy_to.rubrics.find_by_migration_id(mig_id(@rubric)) rub.should_not be_nil + + [:description, :id, :points].each do |k| + rub.data.first[k].should == @rubric.data.first[k] + end + [:criterion_id, :description, :id, :points].each do |k| + rub.data.first[:ratings].each_with_index do |criterion, i| + criterion[k].should == @rubric.data.first[:ratings][i][k] + end + end + asmnt2 = @copy_to.assignments.find_by_migration_id(mig_id(@assignment)) asmnt2.rubric.id.should == rub.id asmnt2.rubric_association.use_for_grading.should == true