Display only outcomes with active workflow_state
closes OUT-4964 flag=improved_outcomes_management test plan: - Navigate to Account > Outcomes - Create an outcome - In the rails console, find the outcome you just created and set the workflow_state to 'deleted' - Refresh Canvas - Observe that the outcome no longer shows in the UI and that the outcome count for that group is correct Change-Id: If5d528c544c64103b90f559f692c013f8689f928 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/287168 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Product-Review: Brian Watson <bwatson@instructure.com> Reviewed-by: Brian Watson <bwatson@instructure.com> Reviewed-by: Chrystal Langston <chrystal.langston@instructure.com> QA-Review: Chrystal Langston <chrystal.langston@instructure.com>
This commit is contained in:
parent
e6dab06173
commit
83610dd74d
|
@ -79,11 +79,9 @@ module Outcomes
|
|||
end
|
||||
|
||||
def suboutcomes_by_group_id(learning_outcome_group_id, args = {})
|
||||
learning_outcome_groups_ids = children_ids_with_self(learning_outcome_group_id)
|
||||
relation = ContentTag.active.learning_outcome_links
|
||||
.where(associated_asset_id: learning_outcome_groups_ids)
|
||||
.joins(:learning_outcome_content)
|
||||
.joins("INNER JOIN #{LearningOutcomeGroup.quoted_table_name} AS logs
|
||||
relation = outcome_links(learning_outcome_group_id)
|
||||
relation = relation.joins(:learning_outcome_content)
|
||||
.joins("INNER JOIN #{LearningOutcomeGroup.quoted_table_name} AS logs
|
||||
ON logs.id = content_tags.associated_asset_id")
|
||||
|
||||
if args[:search_query]
|
||||
|
@ -112,7 +110,11 @@ module Outcomes
|
|||
|
||||
def outcome_links(learning_outcome_group_id)
|
||||
group_ids = children_ids_with_self(learning_outcome_group_id)
|
||||
ContentTag.active.learning_outcome_links.where(associated_asset_id: group_ids)
|
||||
relation = ContentTag.active.learning_outcome_links
|
||||
.where(associated_asset_id: group_ids)
|
||||
# Check that the LearningOutcome the content tag is aligned to is not deleted
|
||||
tag_ids = relation.reject { |tag| LearningOutcome.find(tag.content_id).workflow_state == "deleted" }.map(&:id)
|
||||
ContentTag.where(id: tag_ids)
|
||||
end
|
||||
|
||||
def total_outcomes_for(learning_outcome_group_id, args = {})
|
||||
|
|
|
@ -154,6 +154,23 @@ describe Outcomes::LearningOutcomeGroupChildren do
|
|||
end
|
||||
end
|
||||
|
||||
context "when outcome is marked as deleted, but content tag is still active" do
|
||||
before do
|
||||
o4.workflow_state = "deleted"
|
||||
o4.save!
|
||||
end
|
||||
|
||||
it "returns the total outcomes for a learning outcome group without the deleted outcomes" do
|
||||
expect(subject.total_outcomes(g0.id)).to eq 11
|
||||
expect(subject.total_outcomes(g1.id)).to eq 8
|
||||
expect(subject.total_outcomes(g2.id)).to eq 2
|
||||
expect(subject.total_outcomes(g3.id)).to eq 5
|
||||
expect(subject.total_outcomes(g4.id)).to eq 1
|
||||
expect(subject.total_outcomes(g5.id)).to eq 1
|
||||
expect(subject.total_outcomes(g6.id)).to eq 3
|
||||
end
|
||||
end
|
||||
|
||||
context "when context is nil" do
|
||||
subject { described_class.new }
|
||||
|
||||
|
|
Loading…
Reference in New Issue