老师将课程成员拉入或者移出项目时,给出相应的消息通知
This commit is contained in:
parent
f8931ea78f
commit
b11aaa545a
|
@ -159,6 +159,14 @@ class MembersController < ApplicationController
|
|||
if role && (role.name == "学生" || role.name == "Student")
|
||||
StudentsForCourse.create(:student_id => user_id, :course_id =>@course.id)
|
||||
end
|
||||
|
||||
#给新成员和老师发送加入课程的消息,发送者id放在CourseMessage的course_message_id字段中
|
||||
#course_message_type设置为JoinCourse
|
||||
#status = 0 表示给学生发,status = 1表示给老师发
|
||||
course_join = CourseMessage.new(:user_id =>user_id, :course_message_id=>User.current.id,:course_id => @course.id,:course_message_type=>"JoinCourse", :viewed => false, :status => 0)
|
||||
course_join.save
|
||||
CourseMessage.create(:user_id => User.current.id, :course_message_id => user_id, :course_id => @course.id, :course_message_type => "JoinCourse", :viewed => false, status => 1)
|
||||
|
||||
members << member
|
||||
#user_grades << UserGrade.new(:user_id => user_id, :course_id => @course.id)
|
||||
if (params[:membership][:role_ids])
|
||||
|
@ -305,7 +313,8 @@ class MembersController < ApplicationController
|
|||
grade.destroy
|
||||
end
|
||||
end
|
||||
ForgeMessage.create(:user_id => @member.user_id, :project_id => @project.id, :forge_message_type => "RemoveFromProject", :viewed => false, :forge_message_id => User.current.id)
|
||||
#移出项目发送消息
|
||||
ForgeMessage.create(:user_id => @member.user_id, :project_id => @project.id, :forge_message_type => "RemoveFromProject", :viewed => false, :forge_message_id => User.current.id)
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html { redirect_to_settings_in_projects }
|
||||
|
@ -333,6 +342,8 @@ class MembersController < ApplicationController
|
|||
end
|
||||
@roles = Role.givable.all[3..5]
|
||||
@members = @course.member_principals.includes(:roles, :principal).all.sort
|
||||
#移出课程发送消息
|
||||
CourseMessage.create(:user_id => @member.user_id, :course_id => @course.id, :course_message_type => "RemoveFromCourse", :viewed => false, :course_message_id => User.current.id)
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html { redirect_to_settings_in_courses }
|
||||
|
|
|
@ -503,4 +503,64 @@
|
|||
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<!--被老师拉入课程-->
|
||||
<% if ma.course_message_type == "JoinCourse" %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl">
|
||||
<a href="javascript:void(0);"><%=link_to image_tag(url_to_avatar(User.find(ma.course_message_id)), :width => "30", :height => "30"), user_path(ma.course_message_id) %></a>
|
||||
</li>
|
||||
<li class="homepageNewsPubType fl">
|
||||
<%=link_to User.find(ma.course_message_id), user_path(User.find(ma.course_message_id)), :class => "newsBlue homepageNewsPublisher" %>
|
||||
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">将您加入了课程:</span>
|
||||
</li>
|
||||
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
|
||||
<%= link_to ma.course.name, course_member_path(ma.course), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
|
||||
:onmouseover => "message_titile_show($(this),event)",
|
||||
:onmouseout => "message_titile_hide($(this))" %></a>
|
||||
</li>
|
||||
<div style="display: none" class="message_title_red system_message_style">
|
||||
<% if ma.course.is_public? || User.current.member_of_course?(ma.course) || User.current.admin? %>
|
||||
<p>课程名称:<%= ma.course.name %>(<%= ma.course.time.to_s + '年'+ ma.course.term %>)</p>
|
||||
<p>课程描述:<%= ma.course.description.blank? ? '无':ma.course.description %></p>
|
||||
<p>课时总数:<%= ma.course.class_period %></p>
|
||||
<% else %>
|
||||
<p>
|
||||
您已经被移出该私有课程,非课程成员没有权限访问私有课程
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<!-被老师移出课程-->
|
||||
<% if ma.course_message_type == "RemoveFromCourse" %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl">
|
||||
<a href="javascript:void(0);"><%=link_to image_tag(url_to_avatar(User.find(ma.course_message_id)), :width => "30", :height => "30"), user_path(ma.course_message_id) %></a>
|
||||
</li>
|
||||
<li class="homepageNewsPubType fl">
|
||||
<%=link_to User.find(ma.course_message_id), user_path(User.find(ma.course_message_id)), :class => "newsBlue homepageNewsPublisher" %>
|
||||
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">将您移出了课程:</span>
|
||||
</li>
|
||||
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
|
||||
<%= link_to ma.course.name, member_course_path(ma.course), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
|
||||
:onmouseover => "message_titile_show($(this),event)",
|
||||
:onmouseout => "message_titile_hide($(this))" %></a>
|
||||
</li>
|
||||
<div style="display: none" class="message_title_red system_message_style">
|
||||
<% if ma.course.is_public? || User.current.member_of?(ma.course) || User.current.admin? %>
|
||||
<p>课程名称:<%= ma.course.name %>(<%= ma.course.time.to_s + '年'+ ma.course.term %>)</p>
|
||||
<p>课程描述:<%= ma.course.description.blank? ? '无' : ma.course.description %></p>
|
||||
<p>学时总数:<%= ma.course.class_period %></p>
|
||||
<% else %>
|
||||
<p>
|
||||
您已经被移出该私有课程,非课程成员没有权限访问私有课程
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
Loading…
Reference in New Issue