Skip to content

Commit d7ef4fa

Browse files
author
Derek DeVries
committed
allow deletion of quizzes with student submissions
fixes CNVS-9050 test plan: - create a quiz - take the quiz as a student - as a teacher try to delete the quiz - the quiz should successfully delete Change-Id: Id53a0482217d1a185d15d60358e8bd41680b5a6b Reviewed-on: https://gerrit.instructure.com/25546 Reviewed-by: Stanley Stuart <stanley@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> QA-Review: Caleb Guanzon <cguanzon@instructure.com> Product-Review: Derek DeVries <ddevries@instructure.com>
1 parent bdac03f commit d7ef4fa

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

app/models/quiz.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def update_assignment
310310
a.assignment_group_id = self.assignment_group_id
311311
a.saved_by = :quiz
312312
a.workflow_state = 'published' if a.deleted?
313-
if context.draft_state_enabled?
313+
if context.draft_state_enabled? && !deleted?
314314
a.workflow_state = self.published? ? 'published' : 'unpublished'
315315
end
316316
a.notify_of_update = @notify_of_update

spec/models/quiz_spec.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,31 @@
10981098
end
10991099
end
11001100

1101+
context "#destroy" do
1102+
it "should logical delete published quiz" do
1103+
quiz = @course.quizzes.create(title: 'test quiz')
1104+
quiz.context.root_account.enable_draft!
1105+
quiz.stubs(:has_student_submissions? => true)
1106+
quiz.publish!
1107+
quiz.assignment.stubs(:has_student_submissions? => true)
1108+
1109+
quiz.destroy
1110+
quiz.deleted?.should be_true
1111+
end
1112+
1113+
it "should logical delete the published quiz's associated assignment" do
1114+
quiz = @course.quizzes.create(title: 'test quiz')
1115+
quiz.context.root_account.enable_draft!
1116+
quiz.stubs(:has_student_submissions?).returns true
1117+
quiz.publish!
1118+
assignment = quiz.assignment
1119+
assignment.stubs(:has_student_submissions?).returns true
1120+
1121+
quiz.destroy
1122+
assignment.deleted?.should be_true
1123+
end
1124+
end
1125+
11011126
context "draft_state" do
11021127

11031128
it "updates the assignment's workflow state" do

0 commit comments

Comments
 (0)