don't show discussion stream items to students in an unpublished course
Test Plan: * Create a course and don't publish it * Add a student to that course * Create a discussion topic as the teacher * Make sure there is no item for the topic in the student's stream ( make sure the student as at least one other active enrollment though because stream items don't show at all if a user has no enrollments at all) closes #6200 #5432 Change-Id: Ib993edf139d3c971197c7876a01e9f9592583704 Reviewed-on: https://gerrit.instructure.com/7221 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Jacob Fugal <jacob@instructure.com>
This commit is contained in:
parent
ee219b2b4a
commit
c4dcfe97c9
|
@ -88,13 +88,13 @@ class DiscussionEntry < ActiveRecord::Base
|
|||
# If the topic has been going for more than two weeks and it suddenly
|
||||
# got "popular" again, move it back up in user streams
|
||||
if !self.discussion_topic.for_assignment? && self.created_at && self.created_at > self.discussion_topic.created_at + 2.weeks && recent_entries.select{|e| e.created_at && e.created_at > 24.hours.ago }.length > 10
|
||||
self.discussion_topic.participants
|
||||
self.discussion_topic.active_participants
|
||||
# If the topic has beeng going for more than two weeks, only show
|
||||
# people who have been participating in the topic
|
||||
elsif self.created_at > self.discussion_topic.created_at + 2.weeks
|
||||
recent_entries.map(&:user_id).uniq
|
||||
else
|
||||
self.discussion_topic.participants
|
||||
self.discussion_topic.active_participants
|
||||
end
|
||||
else
|
||||
[]
|
||||
|
|
|
@ -240,13 +240,13 @@ class DiscussionTopic < ActiveRecord::Base
|
|||
|
||||
on_create_send_to_streams do
|
||||
if should_send_to_stream
|
||||
self.participants
|
||||
self.active_participants
|
||||
end
|
||||
end
|
||||
|
||||
on_update_send_to_streams do
|
||||
if should_send_to_stream && (@delayed_just_posted || @content_changed || changed_state(:active, :post_delayed))
|
||||
self.participants
|
||||
self.active_participants
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -419,7 +419,7 @@ class DiscussionTopic < ActiveRecord::Base
|
|||
|
||||
set_broadcast_policy do |p|
|
||||
p.dispatch :new_discussion_topic
|
||||
p.to { participants - [user] }
|
||||
p.to { active_participants - [user] }
|
||||
p.whenever { |record|
|
||||
record.context.available? and
|
||||
((record.just_created and not record.post_delayed?) || record.changed_state(:active, :post_delayed))
|
||||
|
@ -433,6 +433,14 @@ class DiscussionTopic < ActiveRecord::Base
|
|||
([self.user] + context.participants).uniq.select{|u| u}
|
||||
end
|
||||
|
||||
def active_participants
|
||||
if !self.context.available? && self.context.respond_to?(:participating_admins)
|
||||
self.context.participating_admins
|
||||
else
|
||||
self.participants
|
||||
end
|
||||
end
|
||||
|
||||
def posters
|
||||
users = self.discussion_entries.find(:all, :include => [:user]).map(&:user)
|
||||
users << self.user
|
||||
|
|
|
@ -317,6 +317,23 @@ describe DiscussionTopic do
|
|||
@parent_topic.should_send_to_stream.should be_true
|
||||
@subtopic.should_send_to_stream.should be_false
|
||||
end
|
||||
|
||||
it "should not send stream items to students if course isn't published'" do
|
||||
course
|
||||
course_with_teacher(:course => @course, :active_all => true)
|
||||
student_in_course(:course => @course, :active_all => true)
|
||||
|
||||
topic = @course.discussion_topics.create(:title => "secret topic", :user => @teacher)
|
||||
|
||||
StreamItem.for_user(@student).count.should == 0
|
||||
StreamItem.for_user(@teacher).count.should == 1
|
||||
|
||||
topic.discussion_entries.create!
|
||||
|
||||
StreamItem.for_user(@student).count.should == 0
|
||||
StreamItem.for_user(@teacher).count.should == 1
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "posting first to view" do
|
||||
|
|
Loading…
Reference in New Issue