override Quiz#context_module_tags to find both content_types
test plan: - have a quiz that was added to a module prior to the Quizzes::Quiz refactor (or manually update the ContentTag's content_type to 'Quiz') - set up a completion requirement (must submit, or must score) - verify that a student can complete the requirement fixes CNVS-11613 Change-Id: I2bb5271e6b263173d98c9df8913044640698e7fb Reviewed-on: https://gerrit.instructure.com/31424 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Derek DeVries <ddevries@instructure.com> QA-Review: Matt Fairbourn <mfairbourn@instructure.com> Reviewed-by: Bracken Mosbacker <bracken@instructure.com> Product-Review: Bracken Mosbacker <bracken@instructure.com>
This commit is contained in:
parent
4a30de5e3c
commit
08efec0541
|
@ -98,6 +98,10 @@ class Quizzes::Quiz < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def context_module_tags
|
||||
ContentTag.where("content_id=? AND content_type IN ('Quiz', 'Quizzes::Quiz') AND tag_type='context_module' AND workflow_state<>'deleted'", self.id).includes(:context_module => [:content_tags])
|
||||
end
|
||||
|
||||
# This callback is listed here in order for the :link_assignment_overrides
|
||||
# method to be called after the simply_versioned callbacks. We want the
|
||||
# overrides to reflect the most recent version of the quiz.
|
||||
|
|
|
@ -708,6 +708,22 @@ describe ContextModule do
|
|||
@quiz.locked_for?(@user).should be_false
|
||||
@assignment.locked_for?(@user).should be_false
|
||||
end
|
||||
|
||||
it "should progress on pre-refactor quiz tags" do
|
||||
course_module
|
||||
student_in_course course: @course, active_all: true
|
||||
@quiz = @course.quizzes.build(title: "some quiz")
|
||||
@quiz.workflow_state = 'available'
|
||||
@quiz.save!
|
||||
@tag = @module.add_item({id: @quiz.id, type: 'quiz'})
|
||||
ContentTag.where(id: @tag).update_all(content_type: 'Quiz')
|
||||
@module.completion_requirements = {@tag.id => {type: 'must_submit'}}
|
||||
@module.save!
|
||||
@submission = @quiz.generate_submission(@student)
|
||||
@submission.workflow_state = 'complete'
|
||||
@submission.save!
|
||||
@module.evaluate_for(@student).requirements_met.should be_include({id: @tag.id, type: 'must_submit'})
|
||||
end
|
||||
end
|
||||
|
||||
context 'unpublished completion requirements' do
|
||||
|
|
|
@ -1514,4 +1514,17 @@ describe Quizzes::Quiz do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#context_module_tags' do
|
||||
it "finds both namespaced and non-namespaced content tags" do
|
||||
quiz = @course.quizzes.create! title: 'Test Quiz'
|
||||
mod = @course.context_modules.create! name: 'Test Module'
|
||||
tag1 = mod.add_item id: quiz.id, type: 'quiz'
|
||||
tag2 = mod.add_item id: quiz.id, type: 'quiz'
|
||||
tag3 = mod.add_item id: quiz.id, type: 'quiz'
|
||||
ContentTag.where(id: tag2).update_all(content_type: 'Quiz')
|
||||
tag3.destroy
|
||||
quiz.context_module_tags.pluck(:id).sort.should eql [tag1.id, tag2.id].sort
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue