Modules page doesn't show duplicating/failed_to_duplicate assignments

Launching duplicating/failed_to_duplicate new quizzes assignments
provides no value as the assignments do not yet exist, and is actually
destructive as it will create a blank assignment on the new quizzes
side with no connection to its parent assignment.

closes QUIZ-10828
flag=none

Test Plan:
- Create a BP parent course with a new quizzes assignment.
- ADD THE NQ ASSIGNMENT TO A MODULE.
- Create a child course.
- Ensure your live events are turned off and/or quiz lti is turned off.
- In the canvas rails console run this:
    Setting.set("quizzes_next_timeout_minutes", "1")
- Run a BPS.
- Check the child course.
  1. The Assignments/Quizzes list should have a spinner for the quiz.
  2. The modules list should have no entries.
- Wait 1 minute, then in the Canvas rails console run:
    Assignment.clean_up_duplicating_assignments
- Check the child course.
  1. The assignments/quizzes list should have an 'Oops!' entry for the quiz.
  2. The modules list should have no entries.
- Turn on quiz lti and your canvas live event streams.
- Run another BPS.
- Check the child course.
  1. The assignments/quizzes list should have a valid entry for the quiz.
  2. The modules list should have a valid entry for the quiz.

Change-Id: I971173ebca77e9ecfb152677092bd7f48f789d2b
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/311411
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Product-Review: Marissa Pio Roda <marissa.pioroda@instructure.com>
QA-Review: Weston Dransfield <wdransfield@instructure.com>
Reviewed-by: Stephen Kacsmark <skacsmark@instructure.com>
This commit is contained in:
James Logan 2023-02-16 17:01:25 -06:00
parent b3055bea55
commit 3fa8ec3567
5 changed files with 75 additions and 1 deletions

View File

@ -133,9 +133,14 @@ module ContextModulesHelper
def process_module_data(mod, is_student = false, current_user = nil, session = nil) def process_module_data(mod, is_student = false, current_user = nil, session = nil)
# pre-calculated module view data can be added here # pre-calculated module view data can be added here
items = mod.content_tags_visible_to(@current_user)
items = items.reject do |item|
item.content.respond_to?(:hide_on_modules_view?) && item.content.hide_on_modules_view?
end
module_data = { module_data = {
published_status: mod.published? ? "published" : "unpublished", published_status: mod.published? ? "published" : "unpublished",
items: mod.content_tags_visible_to(@current_user) items: items
} }
if cyoe_enabled?(@context) if cyoe_enabled?(@context)

View File

@ -3919,6 +3919,10 @@ class Assignment < ActiveRecord::Base
end end
end end
def hide_on_modules_view?
["duplicating", "failed_to_duplicate"].include?(workflow_state)
end
private private
def grading_type_requires_points? def grading_type_requires_points?

View File

@ -242,6 +242,17 @@ describe ContextModulesHelper do
expect(item_data[:show_cyoe_placeholder]).to eq false expect(item_data[:show_cyoe_placeholder]).to eq false
end end
end end
it "does not return items that are hide_on_modules_view? == true" do
course = course_factory(active_all: true)
test_module = course.context_modules.create! name: "test module"
hidden_assignment = course.assignments.create!(workflow_state: "failed_to_duplicate")
test_module.add_item(type: "assignment", id: hidden_assignment.id)
module_data = process_module_data(test_module, true, @student, @session)
expect(module_data[:items]).to be_empty
end
end end
describe "add_mastery_paths_to_cache_key" do describe "add_mastery_paths_to_cache_key" do

View File

@ -62,4 +62,30 @@ describe Assignment do
expect(first_student_position).to eq(initial_student_first ? 1 : 2) expect(first_student_position).to eq(initial_student_first ? 1 : 2)
end end
end end
describe "#hide_on_modules_view?" do
before(:once) do
@course = Course.create!
end
it "returns true when the assignment is in the failed_to_duplicate state" do
assignment = @course.assignments.create!(workflow_state: "failed_to_duplicate", **assignment_valid_attributes)
expect(assignment.hide_on_modules_view?).to eq true
end
it "returns true when the assignment is in the duplicating state" do
assignment = @course.assignments.create!(workflow_state: "duplicating", **assignment_valid_attributes)
expect(assignment.hide_on_modules_view?).to eq true
end
it "returns false when the assignment is in the published state" do
assignment = @course.assignments.create!(workflow_state: "published", **assignment_valid_attributes)
expect(assignment.hide_on_modules_view?).to eq false
end
it "returns false when the assignment is in the unpublished state" do
assignment = @course.assignments.create!(workflow_state: "unpublished", **assignment_valid_attributes)
expect(assignment.hide_on_modules_view?).to eq false
end
end
end end

View File

@ -80,6 +80,34 @@ describe "context_modules/index" do
expect(page.css("#context_module_item_#{module_item.id}").length).to eq 0 expect(page.css("#context_module_item_#{module_item.id}").length).to eq 0
end end
it "does not show failed_to_duplicate content_tags" do
course_factory
context_module = @course.context_modules.create!
assignment = @course.assignments.create!(workflow_state: "failed_to_duplicate")
module_item = context_module.add_item(type: "assignment", id: assignment.id)
view_context(@course, @user)
assign(:modules, @course.context_modules.active)
render "context_modules/index"
expect(response).not_to be_nil
page = Nokogiri("<document>" + response.body + "</document>")
expect(page.css("#context_module_item_#{module_item.id}").length).to eq 0
end
it "does not show duplicating content_tags" do
course_factory
context_module = @course.context_modules.create!
assignment = @course.assignments.create!(workflow_state: "duplicating")
module_item = context_module.add_item(type: "assignment", id: assignment.id)
view_context(@course, @user)
assign(:modules, @course.context_modules.active)
render "context_modules/index"
expect(response).not_to be_nil
page = Nokogiri("<document>" + response.body + "</document>")
expect(page.css("#context_module_item_#{module_item.id}").length).to eq 0
end
it "shows download course content if settings are enabled" do it "shows download course content if settings are enabled" do
course_factory course_factory
acct = @course.root_account acct = @course.root_account