fix changing quiz with overrides to ungraded
test plan: - create a graded quiz - set a due date for it for a specific student - change the quiz to ungraded - the quiz should save successfully - the override should still appear on the quiz page and the quiz edit page - you should be able to remove the override and later assign the student to a different override fixes ADMIN-1058 Change-Id: Ia8f0d3d581ab897046ba91b692d9cbcc1639d0ed Reviewed-on: https://gerrit.instructure.com/150912 Tested-by: Jenkins Reviewed-by: Mysti Sadler <mysti@instructure.com> Product-Review: Mysti Sadler <mysti@instructure.com> QA-Review: Mysti Sadler <mysti@instructure.com>
This commit is contained in:
parent
e52c908707
commit
cff999fab6
|
@ -475,7 +475,10 @@ class Quizzes::QuizzesController < ApplicationController
|
|||
@quiz.assignment.save
|
||||
end
|
||||
|
||||
perform_batch_update_assignment_overrides(@quiz, prepared_batch) unless overrides.nil?
|
||||
unless overrides.nil?
|
||||
update_quiz_and_assignment_versions(@quiz, prepared_batch) # to prevent undoing Quiz#link_assignment_overrides
|
||||
perform_batch_update_assignment_overrides(@quiz, prepared_batch)
|
||||
end
|
||||
|
||||
# quiz.rb restricts all assignment broadcasts if notify_of_update is
|
||||
# false, so we do the same here
|
||||
|
@ -494,7 +497,7 @@ class Quizzes::QuizzesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
if @overrides_affected.to_i > 0 || cached_due_dates_changed
|
||||
if @quiz.assignment && (@overrides_affected.to_i > 0 || cached_due_dates_changed)
|
||||
DueDateCacher.recompute(@quiz.assignment, update_grades: true)
|
||||
end
|
||||
|
||||
|
@ -1005,4 +1008,11 @@ class Quizzes::QuizzesController < ApplicationController
|
|||
def get_quiz_params
|
||||
params[:quiz] ? params[:quiz].permit(API_ALLOWED_QUIZ_INPUT_FIELDS[:only]) : {}
|
||||
end
|
||||
|
||||
def update_quiz_and_assignment_versions(quiz, prepared_batch)
|
||||
params = { quiz_id: quiz.id, quiz_version: quiz.version_number,
|
||||
assignment_id: quiz.assignment_id, assignment_version: quiz.assignment&.version_number }
|
||||
prepared_batch[:overrides_to_create].each { |override| override.assign_attributes(params) }
|
||||
prepared_batch[:overrides_to_update].each { |override| override.assign_attributes(params) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1466,6 +1466,28 @@ describe Quizzes::QuizzesController do
|
|||
expect(overrides.length).to eq 1
|
||||
end
|
||||
|
||||
it "can change a graded quiz with overrides into an ungraded quiz" do
|
||||
user_session(@teacher)
|
||||
quiz = @course.quizzes.create!(:title => 'blah', :quiz_type => 'assignment')
|
||||
override = create_adhoc_override_for_assignment(quiz, @student)
|
||||
post 'update', :params => {
|
||||
:course_id => @course.id,
|
||||
:id => quiz.id,
|
||||
:quiz => {
|
||||
:quiz_type => 'survey',
|
||||
:assignment_overrides => [{
|
||||
:id => override.id,
|
||||
:assignment_id => quiz.assignment.id,
|
||||
:title => '1 student',
|
||||
:student_ids => [@student.id]
|
||||
}]
|
||||
}
|
||||
}
|
||||
expect(quiz.reload.assignment_id).to be_nil
|
||||
expect(override.reload.assignment_id).to be_nil
|
||||
expect(override.quiz_id).to eq quiz.id
|
||||
end
|
||||
|
||||
describe "DueDateCacher" do
|
||||
before :each do
|
||||
user_session(@teacher)
|
||||
|
|
Loading…
Reference in New Issue