master courses: fix updating question bank questions

test plan:
* create a blueprint course
* create a question bank with a question
* create a quiz with a group linked to the bank
 and lock the quiz

* sync to associated course
* in the associated course,
 update a question in the question bank
* preview the quiz
* it should not kersplode

closes #ADMIN-328

Change-Id: Ib2c611dc16472c83acc8c590b0584c0820ef2317
Reviewed-on: https://gerrit.instructure.com/131591
Tested-by: Jenkins
Reviewed-by: Mysti Sadler <mysti@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
This commit is contained in:
James Williams 2017-11-02 07:08:05 -06:00
parent edf8a46d70
commit a2cca04924
3 changed files with 9 additions and 8 deletions

View File

@ -48,9 +48,9 @@ module MasterCourses::CollectionRestrictor
end
end
def check_restrictions_on_creation?
def check_restrictions?
if self.is_a?(Quizzes::QuizQuestion)
!self.generated?
!self.generated? # allow updating through the bank even though it's technically locked... shhh don't tell anybody
else
true
end

View File

@ -65,8 +65,7 @@ module MasterCourses::Restrictor
end
def check_for_restricted_column_changes
return true if @importing_migration || !is_child_content?
return true if new_record? && !self.check_restrictions_on_creation? # shouldn't be able to create new collection items if owner is locked
return true if @importing_migration || !is_child_content? || !self.check_restrictions?
restrictions = nil
locked_columns = []
@ -101,8 +100,8 @@ module MasterCourses::Restrictor
end
end
def check_restrictions_on_creation?
false
def check_restrictions?
!self.new_record?
end
def mark_downstream_changes(changed_columns=nil)

View File

@ -64,12 +64,14 @@ describe MasterCourses::CollectionRestrictor do
expect(new_aq.errors[:base].first.to_s).to include("locked by Master Course")
end
it "should allow quiz questions to be generated" do
it "should allow quiz questions to be generated and updated" do
original_quiz = @copy_from.quizzes.create!
quiz_tag = @template.create_content_tag_for!(original_quiz, :restrictions => {:content => true})
quiz_copy = @copy_to.quizzes.create!(:migration_id => quiz_tag.migration_id)
quiz_copy.quiz_questions.create!(:question_data => {'some data' => '1'}, :workflow_state => "generated")
qq = quiz_copy.quiz_questions.create!(:question_data => {'some data' => '1'}, :workflow_state => "generated")
qq.update_attribute(:question_data, {'some other data' => '1'})
end
end