prevent checkpoints from creating their own discussion topics
closes VICE-4024 flag=discussion_topics Test Plan: - specs pass Change-Id: Id318d6e4dcbc977a1b4a1859bb397cd7088b6e9a Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/335836 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Keith Garner <kgarner@instructure.com> Reviewed-by: Omar Soto-Fortuño <omar.soto@instructure.com> Product-Review: Omar Soto-Fortuño <omar.soto@instructure.com> QA-Review: Chawn Neal <chawn.neal@instructure.com>
This commit is contained in:
parent
a9234623ee
commit
1c51d4ebe7
|
@ -1093,7 +1093,7 @@ class AbstractAssignment < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def delete_empty_abandoned_children
|
||||
if saved_change_to_submission_types?
|
||||
if governs_submittable? && saved_change_to_submission_types?
|
||||
each_submission_type do |submittable, type|
|
||||
unless self.submission_types == type.to_s
|
||||
submittable&.unlink!(:assignment)
|
||||
|
@ -1120,7 +1120,7 @@ class AbstractAssignment < ActiveRecord::Base
|
|||
def update_submittable
|
||||
# If we're updating the assignment's muted status as part of posting
|
||||
# grades, don't bother doing this
|
||||
return true if deleted? || grade_posting_in_progress
|
||||
return true if !governs_submittable? || deleted? || grade_posting_in_progress
|
||||
|
||||
if self.submission_types == "online_quiz" && @saved_by != :quiz
|
||||
quiz = Quizzes::Quiz.where(assignment_id: self).first || context.quizzes.build
|
||||
|
|
|
@ -86,4 +86,8 @@ class Assignment < AbstractAssignment
|
|||
def before_soft_delete
|
||||
sub_assignments.destroy_all
|
||||
end
|
||||
|
||||
def governs_submittable?
|
||||
true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1836,8 +1836,18 @@ class DiscussionTopic < ActiveRecord::Base
|
|||
return false unless assignment.present?
|
||||
|
||||
assignment.update!(has_sub_assignments: true)
|
||||
assignment.sub_assignments.create!(context:, sub_assignment_tag: CheckpointLabels::REPLY_TO_TOPIC, points_possible: reply_to_topic_points)
|
||||
assignment.sub_assignments.create!(context:, sub_assignment_tag: CheckpointLabels::REPLY_TO_ENTRY, points_possible: reply_to_entry_points)
|
||||
assignment.sub_assignments.create!(
|
||||
context:,
|
||||
sub_assignment_tag: CheckpointLabels::REPLY_TO_TOPIC,
|
||||
submission_types: "discussion_topic",
|
||||
points_possible: reply_to_topic_points
|
||||
)
|
||||
assignment.sub_assignments.create!(
|
||||
context:,
|
||||
sub_assignment_tag: CheckpointLabels::REPLY_TO_ENTRY,
|
||||
submission_types: "discussion_topic",
|
||||
points_possible: reply_to_entry_points
|
||||
)
|
||||
self.reply_to_entry_required_count = reply_to_entry_required_count
|
||||
|
||||
save
|
||||
|
|
|
@ -48,4 +48,8 @@ class SubAssignment < AbstractAssignment
|
|||
relevant_changes = tracked_attributes & previous_changes.keys
|
||||
relevant_changes.any?
|
||||
end
|
||||
|
||||
def governs_submittable?
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
module Submittable
|
||||
def self.included(klass)
|
||||
klass.belongs_to :assignment, inverse_of: klass.table_name.singularize, class_name: "AbstractAssignment"
|
||||
klass.belongs_to :assignment, inverse_of: klass.table_name.singularize, class_name: "Assignment"
|
||||
klass.belongs_to :old_assignment, class_name: "Assignment"
|
||||
klass.has_many :assignment_student_visibilities, through: :assignment
|
||||
|
||||
|
|
|
@ -3027,6 +3027,12 @@ describe DiscussionTopic do
|
|||
expect(@topic).to_not be_valid
|
||||
end
|
||||
|
||||
it "does not create a discussion topic per-checkpoint (instead, checkpoints belong to the topic through the parent)" do
|
||||
expect do
|
||||
@topic.create_checkpoints(reply_to_topic_points: 10, reply_to_entry_points: 15, reply_to_entry_required_count: 0)
|
||||
end.not_to change { DiscussionTopic.count }.from(1)
|
||||
end
|
||||
|
||||
describe "in place" do
|
||||
before do
|
||||
@course.root_account.enable_feature!(:discussion_checkpoints)
|
||||
|
|
Loading…
Reference in New Issue