copy all the rubrics when copying a course
Only the rubrics created directly in a course were being copied. This commit copies ones through rubric_associations to get everything. Test Plan: * Create a course with some rubrics * Make an assignment use a rubric associated with another course * Copy the course * The new course should have all the necessary rubrics closes #8266 Change-Id: Ib1e1b6c0cc053d53182c0825fe871eb8429ab734 Reviewed-on: https://gerrit.instructure.com/10266 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
This commit is contained in:
parent
c02556a4e1
commit
a3f3df935e
|
@ -43,10 +43,12 @@
|
|||
</ul>
|
||||
<% end %>
|
||||
|
||||
<% if @source_course.rubrics.active.length > 0 %>
|
||||
<% if @source_course.rubric_associations.length > 0 %>
|
||||
<h3><%= check_box :copy, :all_rubrics, :class => "copy_all", :checked => true %><%= label :copy, :all_rubrics, image_tag('flagged_question_dim.png') + " " + t('labels.rubrics', "Rubrics for %{course}", :course => @source_course.name) %></h3>
|
||||
<ul class="unstyled_list root_asset_list">
|
||||
<% @source_course.rubrics.active.each do |rub| %>
|
||||
<% @source_course.rubric_associations.each do |assoc|
|
||||
rub = assoc.rubric
|
||||
%>
|
||||
<li>
|
||||
<%= check_box "copy[rubrics]", mig_id(rub) %>
|
||||
<%= label "copy[rubrics]", mig_id(rub), rub.title %>
|
||||
|
|
|
@ -35,8 +35,9 @@ module CC
|
|||
"xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance",
|
||||
"xsi:schemaLocation"=> "#{CCHelper::CANVAS_NAMESPACE} #{CCHelper::XSD_URI}"
|
||||
) do |rubrics_node|
|
||||
@course.rubrics.active.each do |rubric|
|
||||
next unless export_object?(rubric)
|
||||
@course.rubric_associations.each do |assoc|
|
||||
rubric = assoc.rubric
|
||||
next unless rubric.active? && export_object?(rubric)
|
||||
migration_id = CCHelper.create_key(rubric)
|
||||
rubrics_node.rubric(:identifier=>migration_id) do |r_node|
|
||||
atts = [:read_only, :title, :reusable, :public, :points_possible,
|
||||
|
|
|
@ -89,10 +89,12 @@ describe "Common Cartridge exporting" do
|
|||
@rubric.title = "Rubric"
|
||||
@rubric.data = [{:ratings=>[{:criterion_id=>"309_6312", :points=>5, :description=>"Full Marks", :id=>"blank", :long_description=>""}], :points=>5, :description=>"Description of criterion", :id=>"309_6312", :long_description=>""}, {:ignore_for_scoring=>false, :mastery_points=>3, :learning_outcome_id=>@lo.id, :ratings=>[{:criterion_id=>"309_343", :points=>5, :description=>"Exceeds Expectations", :id=>"309_6516", :long_description=>""}], :points=>5, :description=>"Learning Outcome", :id=>"309_343", :long_description=>"<p>Outcome</p>"}]
|
||||
@rubric.save!
|
||||
@rubric.associate_with(@course, @course)
|
||||
@rubric2 = @course.rubrics.new
|
||||
@rubric2.title = "Rubric"
|
||||
@rubric2.data = [{:ratings=>[{:criterion_id=>"309_6312", :points=>5, :description=>"Full Marks", :id=>"blank", :long_description=>""}], :points=>5, :description=>"Description of criterion", :id=>"309_6312", :long_description=>""}, {:ignore_for_scoring=>false, :mastery_points=>3, :learning_outcome_id=>@lo.id, :ratings=>[{:criterion_id=>"309_343", :points=>5, :description=>"Exceeds Expectations", :id=>"309_6516", :long_description=>""}], :points=>5, :description=>"Learning Outcome", :id=>"309_343", :long_description=>"<p>Outcome</p>"}]
|
||||
@rubric2.save!
|
||||
@rubric2.associate_with(@course, @course)
|
||||
@cm = @course.context_modules.create!(:name => "some module")
|
||||
@cm1 = @course.context_modules.create!(:name => "another module")
|
||||
@att = Attachment.create!(:filename => 'first.txt', :uploaded_data => StringIO.new('ohai'), :folder => Folder.unfiled_folder(@course), :context => @course)
|
||||
|
|
|
@ -429,7 +429,17 @@ describe "Canvas Cartridge importing" do
|
|||
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=>""}, {:ignore_for_scoring=>false, :mastery_points=>3, :learning_outcome_id=>lo.id, :ratings=>[{:criterion_id=>"309_343", :points=>5, :description=>"Exceeds Expectations", :id=>"309_6516", :long_description=>""}, {:criterion_id=>"309_343", :points=>0, :description=>"Does Not Meet Expectations", :id=>"309_9962", :long_description=>""}], :points=>5, :description=>"Learning Outcome", :id=>"309_343", :long_description=>"<p>Outcome</p>"}]
|
||||
rubric.save!
|
||||
|
||||
rubric.associate_with(@copy_from, @copy_from)
|
||||
|
||||
#create a rubric in a different course to associate with
|
||||
new_course = course_model
|
||||
rubric2 = new_course.rubrics.build
|
||||
rubric2.title = "Rubric from different course"
|
||||
rubric2.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=>""}, {:ignore_for_scoring=>false, :mastery_points=>3, :learning_outcome_id=>lo.id, :ratings=>[{:criterion_id=>"309_343", :points=>5, :description=>"Exceeds Expectations", :id=>"309_6516", :long_description=>""}, {:criterion_id=>"309_343", :points=>0, :description=>"Does Not Meet Expectations", :id=>"309_9962", :long_description=>""}], :points=>5, :description=>"Learning Outcome", :id=>"309_343", :long_description=>"<p>Outcome</p>"}]
|
||||
rubric2.save!
|
||||
|
||||
assoc = RubricAssociation.create!(:context => @copy_from, :rubric => rubric2, :association => @copy_from, :title => rubric2.title, :purpose => 'bookmark')
|
||||
|
||||
#export to xml
|
||||
builder = Builder::XmlMarkup.new(:indent=>2)
|
||||
@resource.create_rubrics(builder)
|
||||
|
@ -438,15 +448,19 @@ describe "Canvas Cartridge importing" do
|
|||
hash = @converter.convert_rubrics(doc)
|
||||
#import json into new course
|
||||
hash[0] = hash[0].with_indifferent_access
|
||||
hash[1] = hash[1].with_indifferent_access
|
||||
Rubric.process_migration({'rubrics'=>hash}, @migration)
|
||||
@copy_to.save!
|
||||
|
||||
@copy_to.rubric_associations.count.should == 1
|
||||
|
||||
@copy_to.rubric_associations.count.should == 2
|
||||
lo_2 = @copy_to.learning_outcomes.find_by_migration_id(CC::CCHelper.create_key(lo))
|
||||
lo_2.should_not be_nil
|
||||
rubric_2 = @copy_to.rubrics.find_by_migration_id(CC::CCHelper.create_key(rubric))
|
||||
rubric_2.title.should == rubric.title
|
||||
rubric_2.data[1][:learning_outcome_id].should == lo_2.id
|
||||
|
||||
rubric2_2 = @copy_to.rubrics.find_by_migration_id(CC::CCHelper.create_key(rubric2))
|
||||
rubric2_2.title.should == rubric2.title
|
||||
end
|
||||
|
||||
it "should import modules" do
|
||||
|
|
|
@ -190,9 +190,11 @@ describe ContentMigration do
|
|||
rub1 = @copy_from.rubrics.build(:title => "rub1")
|
||||
rub1.data = data
|
||||
rub1.save!
|
||||
rub1.associate_with(@copy_from, @copy_from)
|
||||
rub2 = @copy_from.rubrics.build(:title => "rub2")
|
||||
rub1.data = data
|
||||
rub1.save!
|
||||
rub2.data = data
|
||||
rub2.save!
|
||||
rub2.associate_with(@copy_from, @copy_from)
|
||||
default = LearningOutcomeGroup.default_for(@copy_from)
|
||||
lo = @copy_from.learning_outcomes.new
|
||||
lo.context = @copy_from
|
||||
|
|
Loading…
Reference in New Issue