完成课程讨论区消息回复方法
This commit is contained in:
parent
4013ff486a
commit
2cb5292dc1
|
@ -197,6 +197,54 @@ class Message < ActiveRecord::Base
|
|||
self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.board.course_id)
|
||||
end
|
||||
end
|
||||
|
||||
# 课程讨论区添加消息
|
||||
# 老师发帖所有人都能收到消息
|
||||
# 学生发帖,有人回复则给该学生消息,没回复则不给其它人发送消息
|
||||
# 帖子被回复的可以收到消息通知
|
||||
def act_as_course_message
|
||||
if self.course
|
||||
if self.parent_id.nil? #主贴
|
||||
self.course.members.each do |m|
|
||||
if self.author.allowed_to?(:as_teacher, self.course) # 老师
|
||||
if m.user_id != self.author_id # 自己的帖子不给自己发送消息
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
else # 回帖
|
||||
#if self.author.allowed_to?(:as_teacher, self.course) # 老师
|
||||
self.course.members.each do |m|
|
||||
if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
#end
|
||||
end
|
||||
end
|
||||
# if self.author.allowed_to?(:as_teacher, self.course) # 如果发帖人是老师
|
||||
# self.course.members.each do |m|
|
||||
# if self.parent_id.nil? # 主贴
|
||||
# if m.user_id != self.author_id # 自己的帖子不给自己发送消息
|
||||
# self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
|
||||
# end
|
||||
# else # 回帖只针对主贴发送消息
|
||||
# if m.user_id == Message.find(self.parent_id).author_id
|
||||
# self.course_messages << CourseMessage.new(:user_id => self.parent_id, :course_id => self.board.course_id, :viewed => false)
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# else # 学生只针对主贴回复
|
||||
# unless self.parent_id.nil?
|
||||
# self.course.members.each do |m|
|
||||
# if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息
|
||||
# self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#end
|
||||
end
|
||||
|
||||
#更新用户分数 -by zjc
|
||||
def be_user_score
|
||||
|
|
|
@ -50,6 +50,15 @@
|
|||
<li class="homepageNewsTime fl"><%= time_tag(ucm.course_message.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% if ucm.course_message_type == "Message" %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><img src="images/newsPortrait.png" width="35" height="35" /></a></li>
|
||||
<li class="homepageNewsPublisher fl"><a href="javascript:void(0);" class="newsBlue"><%= ucm.course_message.author %></a></li>
|
||||
<li class="homepageNewsType fl">发布帖子</li>
|
||||
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey"><%= ucm.course_message.subject %></a></li>
|
||||
<li class="homepageNewsTime fl"><%= time_tag(ucm.course_message.created_on).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue