Integrate OSA helper with Learning Outcome Group Children

closes OUT-5468
flag=outcome_alignment_summary_with_new_quizzes

Test plan:
- Start Canvas, Quiz API, Quiz LTI and Outcomes-Service
- Go to Account > Courses and create course with two outcomes
- Create an assignment and a rubric, align one of the outcomes
to the rubric and align the rubric to the assignment
- Create a new quiz and align the other outcome to
the new quiz at the quiz level
- Click on Alignments tab and select "With Alignments"
- Verify that both outcomes are displayed
- Search for a keyword that both outcomes have and
verify that search results include both outcomes
- Select "Without Alignments" and verify that
no results are displayed

Note: this PS does not update the number with/without
alignments that is displayed in the filter dropdown

Change-Id: I9271a4be16be73b7e5a58521bc1e7986abcf8f75
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/314304
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Product-Review: Kyle Rosenbaum <krosenbaum@instructure.com>
Reviewed-by: Wilmer Corrales <wilmer.corrales@instructure.com>
QA-Review: Wilmer Corrales <wilmer.corrales@instructure.com>
This commit is contained in:
Martin Yosifov 2023-03-31 15:18:45 -07:00 committed by Kyle Rosenbaum
parent fd1c695b58
commit 278d618978
4 changed files with 58 additions and 13 deletions

View File

@ -26,4 +26,8 @@ module OutcomesFeaturesHelper
def improved_outcomes_management_enabled?(context) def improved_outcomes_management_enabled?(context)
context&.root_account&.feature_enabled?(:improved_outcomes_management) context&.root_account&.feature_enabled?(:improved_outcomes_management)
end end
def outcome_alignment_summary_with_new_quizzes_enabled?(context)
context&.feature_enabled?(:outcome_alignment_summary_with_new_quizzes)
end
end end

View File

@ -21,6 +21,7 @@
module Outcomes module Outcomes
class LearningOutcomeGroupChildren class LearningOutcomeGroupChildren
include OutcomesFeaturesHelper include OutcomesFeaturesHelper
include OutcomesServiceAlignmentsHelper
attr_reader :context attr_reader :context
SHORT_DESCRIPTION = "coalesce(learning_outcomes.short_description, '')" SHORT_DESCRIPTION = "coalesce(learning_outcomes.short_description, '')"
@ -133,6 +134,16 @@ module Outcomes
.map(&:learning_outcome_id) .map(&:learning_outcome_id)
.uniq .uniq
if outcome_alignment_summary_with_new_quizzes_enabled?(@context)
outcomes_with_alignments_in_os = get_os_aligned_outcomes(@context)
if outcomes_with_alignments_in_os
outcomes_with_alignments_in_context
.concat(outcomes_with_alignments_in_os.keys.map(&:to_i))
.uniq
end
end
return relation.where(content_id: outcomes_with_alignments_in_context) if filter == "WITH_ALIGNMENTS" return relation.where(content_id: outcomes_with_alignments_in_context) if filter == "WITH_ALIGNMENTS"
return relation.where.not(content_id: outcomes_with_alignments_in_context) if filter == "NO_ALIGNMENTS" return relation.where.not(content_id: outcomes_with_alignments_in_context) if filter == "NO_ALIGNMENTS"
end end

View File

@ -95,5 +95,17 @@ describe OutcomesFeaturesHelper do
expect(improved_outcomes_management_enabled?(@global_outcome.context)).to eq nil expect(improved_outcomes_management_enabled?(@global_outcome.context)).to eq nil
end end
end end
describe "#outcome_alignment_summary_with_new_quizzes_enabled?" do
it "returns true when outcome_alignment_summary_with_new_quizzes FF is enabled" do
@context.enable_feature!(:outcome_alignment_summary_with_new_quizzes)
expect(outcome_alignment_summary_with_new_quizzes_enabled?(@course_outcome.context)).to eq true
end
it "returns false when outcome_alignment_summary_with_new_quizzes FF is disabled" do
@context.disable_feature!(:outcome_alignment_summary_with_new_quizzes)
expect(outcome_alignment_summary_with_new_quizzes_enabled?(@course_outcome.context)).to eq false
end
end
end end
end end

View File

@ -515,19 +515,19 @@ describe Outcomes::LearningOutcomeGroupChildren do
cg1.add_outcome o4 cg1.add_outcome o4
end end
it "filters out outcomes with alignments" do it "filters outcomes without alignments in Canvas" do
outcomes = subject.suboutcomes_by_group_id(cg1.id, { filter: "NO_ALIGNMENTS" }) outcomes = subject.suboutcomes_by_group_id(cg1.id, { filter: "NO_ALIGNMENTS" })
.map(&:learning_outcome_content).map(&:id) .map(&:learning_outcome_content).map(&:id)
expect(outcomes).to eql([o4.id, o8.id]) expect(outcomes).to eql([o4.id, o8.id])
end end
it "filters out outcomes with no alignments" do it "filters outcomes with alignments in Canvas" do
outcomes = subject.suboutcomes_by_group_id(cg1.id, { filter: "WITH_ALIGNMENTS" }) outcomes = subject.suboutcomes_by_group_id(cg1.id, { filter: "WITH_ALIGNMENTS" })
.map(&:learning_outcome_content).map(&:id) .map(&:learning_outcome_content).map(&:id)
expect(outcomes).to eql([o3.id]) expect(outcomes).to eql([o3.id])
end end
it "filters out outcomes with no alignments and with search" do it "filters outcomes without alignments in Canvas and with search" do
outcomes = subject.suboutcomes_by_group_id(cg1.id, { search_query: "4.1", filter: "NO_ALIGNMENTS" }) outcomes = subject.suboutcomes_by_group_id(cg1.id, { search_query: "4.1", filter: "NO_ALIGNMENTS" })
.map(&:learning_outcome_content).map(&:id) .map(&:learning_outcome_content).map(&:id)
expect(outcomes).to eql([o4.id]) expect(outcomes).to eql([o4.id])
@ -545,17 +545,35 @@ describe Outcomes::LearningOutcomeGroupChildren do
.map(&:learning_outcome_content).map(&:id) .map(&:learning_outcome_content).map(&:id)
expect(outcomes).to eql([o3.id, o4.id, o8.id]) expect(outcomes).to eql([o3.id, o4.id, o8.id])
end end
end
end
describe "#clear_total_outcomes_cache" do context "when Outcome Alignment Summary with NQ FF is enabled" do
it "clears the cache" do let!(:os_aligned_outcomes_mock) { { o8.id => [] } }
enable_cache do
expect(ContentTag).to receive(:active).and_call_original.twice before do
expect(subject.total_outcomes(g0.id)).to eq 12 cg1.add_outcome o5
subject.clear_total_outcomes_cache course.enable_feature!(:outcome_alignment_summary_with_new_quizzes)
instance = described_class.new(context) allow_any_instance_of(OutcomesServiceAlignmentsHelper)
expect(instance.total_outcomes(g0.id)).to eq 12 .to receive(:get_os_aligned_outcomes)
.and_return(os_aligned_outcomes_mock)
end
it "filters outcomes without alignments in Canvas or Outcomes-Service" do
outcomes = subject.suboutcomes_by_group_id(cg1.id, { filter: "NO_ALIGNMENTS" })
.map(&:learning_outcome_content).map(&:id)
expect(outcomes).to eql([o4.id, o5.id])
end
it "filters outcomes with alignments in Canvas or Outcomes-Service" do
outcomes = subject.suboutcomes_by_group_id(cg1.id, { filter: "WITH_ALIGNMENTS" })
.map(&:learning_outcome_content).map(&:id)
expect(outcomes).to eql([o3.id, o8.id])
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(&:learning_outcome_content).map(&:id)
expect(outcomes).to eql([o4.id])
end
end end
end end
end end