Fix grouping issue in DiscussionTopic#visible_ids_by_user
flag = differentiated_modules Test plan: - Create 2 ungraded topics, leave 1 alone and assign the other to a student - Add both topics to a module - As the assigned student, expect to see both topics in modules - As an unassigned student, expect to just see the one topic Change-Id: I3809ce0dfc2650eddad29a63b74b8d1344f96ebf Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/349304 Reviewed-by: Robin Kuss <rkuss@instructure.com> QA-Review: Robin Kuss <rkuss@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Product-Review: Jackson Howe <jackson.howe@instructure.com>
This commit is contained in:
parent
bdbb25b150
commit
86ca99002b
|
@ -2011,8 +2011,10 @@ class DiscussionTopic < ActiveRecord::Base
|
|||
ids_visible_to_sections = topic_ids_per_user
|
||||
|
||||
if Account.site_admin.feature_enabled?(:differentiated_modules)
|
||||
visible_discussion_topics = UngradedDiscussionVisibility::UngradedDiscussionVisibilityService.discussion_topics_visible_to_students_in_courses(user_ids: opts[:user_id], course_ids: opts[:course_id]).map { |visibility| [visibility.discussion_topic_id, visibility.user_id] }
|
||||
ungraded_differentiated_topic_ids_per_user = DiscussionTopic.where(id: visible_discussion_topics.map(&:first)).where(assignment_id: nil).where.not(is_section_specific: true).pluck(:id).group_by { |id| visible_discussion_topics.find { |visibility| visibility.first == id }.last }
|
||||
visible_topic_user_id_pairs = UngradedDiscussionVisibility::UngradedDiscussionVisibilityService.discussion_topics_visible_to_students_in_courses(user_ids: opts[:user_id], course_ids: opts[:course_id]).map { |visibility| [visibility.discussion_topic_id, visibility.user_id] }
|
||||
eligible_topic_ids = DiscussionTopic.where(id: visible_topic_user_id_pairs.map(&:first)).where(assignment_id: nil).where.not(is_section_specific: true).pluck(:id)
|
||||
eligible_visible_topic_user_id_pairs = visible_topic_user_id_pairs.select { |discussion_topic_id, _user_id| eligible_topic_ids.include?(discussion_topic_id) }
|
||||
ungraded_differentiated_topic_ids_per_user = eligible_visible_topic_user_id_pairs.group_by(&:last).transform_values { |pairs| pairs.map(&:first) }
|
||||
else
|
||||
# Ungraded discussions are *normally* visible to all -- the exception is
|
||||
# section-specific discussions, so here get the ones visible to everyone in the
|
||||
|
|
|
@ -3331,6 +3331,7 @@ describe DiscussionTopic do
|
|||
|
||||
describe "differentiated topics" do
|
||||
before :once do
|
||||
Account.site_admin.enable_feature! :differentiated_modules
|
||||
@course = course_factory(active_course: true)
|
||||
|
||||
@item_without_assignment = discussion_topic_model(user: @teacher)
|
||||
|
|
Loading…
Reference in New Issue