fix updating unpublished quiz points_possible

test plan:
* have an unpublished quiz in a course
 with a quiz question
* copy the course
* update the original quiz question's points
 (which should update the original quiz points
 on the quiz index)
* re-copy the course
* confirm that the copied course's quiz index
 shows the updated points for the quiz

closes #ADMIN-302

Change-Id: I5399ab9e97aee36679e4698e4236d0d0c1d31f93
Reviewed-on: https://gerrit.instructure.com/132226
Reviewed-by: Jon Willesen <jonw+gerrit@instructure.com>
QA-Review: Heath Hales <hhales@instructure.com>
Tested-by: Jenkins
Product-Review: James Williams  <jamesw@instructure.com>
This commit is contained in:
James Williams 2017-11-08 11:13:22 -07:00
parent ad558431e5
commit 22a088b172
2 changed files with 30 additions and 0 deletions

View File

@ -289,6 +289,7 @@ module Importers
item.assignment.points_possible = item.points_possible
end
item.root_entries(true) if !item.available? && !item.survey? # reload items so we get accurate points
item.save
item.assignment.save if item.assignment && item.assignment.changed?

View File

@ -321,6 +321,35 @@ describe MasterCourses::MasterMigration do
expect(qq3_to.reload).to_not be_deleted
end
it "should sync unpublished quiz points possible" do
@copy_to = course_factory
sub = @template.add_child_course!(@copy_to)
quiz = @copy_from.quizzes.create!(:workflow_state => "unpublished")
qq = quiz.quiz_questions.create!(:question_data => {'question_name' => 'test question', 'question_type' => 'essay_question', 'points_possible' => 1})
quiz.root_entries(true)
quiz.save!
run_master_migration
quiz_to = @copy_to.quizzes.where(:migration_id => mig_id(quiz)).first
expect(quiz_to.points_possible).to eq 1
qq_to = quiz_to.quiz_questions.where(:migration_id => mig_id(qq)).first
new_text = "new text"
Timecop.freeze(2.minutes.from_now) do
qq.update_attribute(:question_data, qq.question_data.merge(:points_possible => 2))
quiz.root_entries(true)
quiz.save!
expect(quiz.points_possible).to eq 2
end
run_master_migration
expect(qq_to.reload.question_data["points_possible"]).to eq 2
expect(quiz_to.reload.points_possible).to eq 2
end
it "tracks creations and updates in selective migrations" do
@copy_to = course_factory
@template.add_child_course!(@copy_to)