Filter Out Alignments to Deleted Quizzes in Alignments Summary

closes OUT-5932
flag=outcome_alignment_summary_with_new_quizzes

Test plan:
- Start Canvas, Outcomes-Service, Quiz LTI and Quiz API
- Create course with outcome
- Create new quiz and align the outcome to the quiz
- Select Alignment Summary and filter "With Alignments"
- Verify that outcome is displayed with 1 alignment
- Stop sqs2outcomes container in Outcomes-Service
- Delete the Quiz from Canvas
- Select Alignment Summary and filter "With Alignments"
- Verify that outcome is not displayed
- Select Alignment Summary and filter "Without Alignments"
- Verify that the outcome is displayed with 0 alignments

Change-Id: I2513377c7aab1ea4a983302fecd8af80196ad3d6
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/329320
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Angela Gomba <angela.gomba@instructure.com>
QA-Review: Angela Gomba <angela.gomba@instructure.com>
Product-Review: Kyle Rosenbaum <krosenbaum@instructure.com>
This commit is contained in:
Martin Yosifov 2023-09-29 15:40:52 -07:00 committed by Kyle Rosenbaum
parent bd6abef01f
commit 3745e60679
2 changed files with 53 additions and 4 deletions

View File

@ -135,7 +135,7 @@ module Outcomes
.uniq
if outcome_alignment_summary_with_new_quizzes_enabled?(@context)
outcomes_with_alignments_in_os = get_os_aligned_outcomes(@context)
outcomes_with_alignments_in_os = get_active_os_alignments(@context)
if outcomes_with_alignments_in_os
outcomes_with_alignments_in_context

View File

@ -18,6 +18,8 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
require_relative "../../outcome_alignments_spec_helper"
describe Outcomes::LearningOutcomeGroupChildren do
subject { described_class.new(context) }
@ -208,6 +210,45 @@ describe Outcomes::LearningOutcomeGroupChildren do
expect(subject.total_outcomes(cg0.id, { filter: "WITH_ALIGNMENTS" })).to eq 3
expect(subject.total_outcomes(cg0.id, { filter: "NO_ALIGNMENTS" })).to eq 3
end
context "when outcome is aligned to New Quizzes" do
before do
@new_quiz = course.assignments.create!(title: "new quiz - aligned in OS", submission_types: "external_tool")
allow_any_instance_of(OutcomesServiceAlignmentsHelper)
.to receive(:get_os_aligned_outcomes)
.and_return(OutcomeAlignmentsSpecHelper.mock_os_aligned_outcomes([o8], @new_quiz.id))
end
context "when Outcome Alignment Summary with NQ FF is enabled" do
before do
course.enable_feature!(:outcome_alignment_summary_with_new_quizzes)
end
it "returns the total outcomes aligned in Canvas and Outcomes-Service based on filter argument" do
expect(subject.total_outcomes(cg0.id, { filter: "WITH_ALIGNMENTS" })).to eq 2
expect(subject.total_outcomes(cg0.id, { filter: "NO_ALIGNMENTS" })).to eq 1
end
context "when new quiz aligned to outcome is deleted in Canvas but not in Outcomes-Service" do
it "returns the total outcomes aligned in Canvas and Outcomes-Service and filters out alignments to deleted quizzes" do
@new_quiz.destroy!
expect(subject.total_outcomes(cg0.id, { filter: "WITH_ALIGNMENTS" })).to eq 1
expect(subject.total_outcomes(cg0.id, { filter: "NO_ALIGNMENTS" })).to eq 2
end
end
end
context "when Outcome Alignment Summary with NQ FF is disabled" do
before do
course.disable_feature!(:outcome_alignment_summary_with_new_quizzes)
end
it "returns the total outcomes only aligned in Canvas based on filter argument" do
expect(subject.total_outcomes(cg0.id, { filter: "WITH_ALIGNMENTS" })).to eq 1
expect(subject.total_outcomes(cg0.id, { filter: "NO_ALIGNMENTS" })).to eq 2
end
end
end
end
context "when outcomes are aligned in account context and imported in a course" do
@ -591,14 +632,13 @@ describe Outcomes::LearningOutcomeGroupChildren do
end
context "when Outcome Alignment Summary with NQ FF is enabled" do
let!(:os_aligned_outcomes_mock) { { o8.id => [] } }
before do
cg1.add_outcome o5
course.enable_feature!(:outcome_alignment_summary_with_new_quizzes)
@new_quiz = course.assignments.create!(title: "new quiz - aligned in OS", submission_types: "external_tool")
allow_any_instance_of(OutcomesServiceAlignmentsHelper)
.to receive(:get_os_aligned_outcomes)
.and_return(os_aligned_outcomes_mock)
.and_return(OutcomeAlignmentsSpecHelper.mock_os_aligned_outcomes([o8], @new_quiz.id))
end
it "filters outcomes without alignments in Canvas or Outcomes-Service" do
@ -613,6 +653,15 @@ describe Outcomes::LearningOutcomeGroupChildren do
expect(outcomes).to eql([o3.id, o8.id])
end
context "when new quiz aligned to outcome is deleted in Canvas but not in Outcomes-Service" do
it "filters outcomes with alignments in Canvas or Outcomes-Service and filters out alignments to deleted quizzes" do
@new_quiz.destroy!
outcomes = subject.suboutcomes_by_group_id(cg1.id, { filter: "WITH_ALIGNMENTS" })
.map { |o| o.learning_outcome_content.id }
expect(outcomes).to eql([o3.id])
end
end
it "filters outcomes without alignments in Canvas or Outcomes-Service and with search" do
outcomes = subject.suboutcomes_by_group_id(cg1.id, { search_query: "4.1", filter: "NO_ALIGNMENTS" })
.map { |o| o.learning_outcome_content.id }