diff --git a/app/controllers/module_assignment_overrides_controller.rb b/app/controllers/module_assignment_overrides_controller.rb index 2573cc1d1df..e35ecb9b498 100644 --- a/app/controllers/module_assignment_overrides_controller.rb +++ b/app/controllers/module_assignment_overrides_controller.rb @@ -171,6 +171,7 @@ class ModuleAssignmentOverridesController < ApplicationController delete_existing_overrides(override_ids_to_delete) update_existing_overrides(overrides_to_update) create_new_overrides(overrides_to_create) + @context_module.update_assignment_submissions end end diff --git a/app/models/context_module.rb b/app/models/context_module.rb index ef51e08ac66..765f87f7d8b 100644 --- a/app/models/context_module.rb +++ b/app/models/context_module.rb @@ -304,7 +304,7 @@ class ContextModule < ActiveRecord::Base ContentTag.where(context_module_id: self).where.not(workflow_state: "deleted").update(workflow_state: "deleted", updated_at: deleted_at) delay_if_production(n_strand: "context_module_update_downstreams", priority: Delayed::LOW_PRIORITY).update_downstreams save! - update_assignment_submissions(module_assignments_quizzes) + update_assignment_submissions(module_assignments_quizzes) if assignment_overrides.active.exists? true end @@ -987,8 +987,8 @@ class ContextModule < ActiveRecord::Base assignment_overrides end - def update_assignment_submissions(module_assignments_quizzes) - if Account.site_admin.feature_enabled?(:differentiated_modules) && assignment_overrides.active.exists? + def update_assignment_submissions(module_assignments_quizzes = current_assignments_and_quizzes) + if Account.site_admin.feature_enabled?(:differentiated_modules) SubmissionLifecycleManager.recompute_course(context, assignments: module_assignments_quizzes, update_grades: true) end end diff --git a/spec/controllers/module_assignment_overrides_controller_spec.rb b/spec/controllers/module_assignment_overrides_controller_spec.rb index 40eaca2e2b2..be322e06b1c 100644 --- a/spec/controllers/module_assignment_overrides_controller_spec.rb +++ b/spec/controllers/module_assignment_overrides_controller_spec.rb @@ -233,6 +233,19 @@ describe ModuleAssignmentOverridesController do expect(@module1.assignment_override_students.reload.to_a).to eq students end + it "updates the module's assignment submissions" do + assignment = @course.assignments.create!(title: "Assignment", points_possible: 10) + @module1.add_item(assignment) + @module1.update_assignment_submissions + expect(assignment.submissions.reload.pluck(:user_id)).to contain_exactly(@student1.id, @student2.id, @student3.id) + + put :bulk_update, params: { course_id: @course.id, + context_module_id: @module1.id, + overrides: [{ "id" => @adhoc_override2.id, "student_ids" => [@student3.id] }] } + expect(response).to have_http_status :no_content + expect(assignment.submissions.reload.pluck(:user_id)).to contain_exactly(@student3.id) + end + it "returns 400 if the overrides parameter is not a list" do put :bulk_update, params: { course_id: @course.id, context_module_id: @module1.id, overrides: "hello" } expect(response).to be_bad_request