This commit is contained in:
cxt 2015-10-27 09:45:33 +08:00
commit 7c34927b3a
9 changed files with 40 additions and 3 deletions

View File

@ -381,6 +381,11 @@ class ApplicationController < ActionController::Base
if allowed if allowed
true true
else else
if params[:action] == 'show'
#更新申请结果反馈消息的状态
messages = CourseMessage.where("course_message_type =? and course_id =? and user_id =? and viewed =?", 'CourseRequestDealResult', @course.id, User.current.id, false)
messages.update_all(:viewed => true)
end
if @course && @course.archived? if @course && @course.archived?
render_403 :message => :notice_not_authorized_archived_project render_403 :message => :notice_not_authorized_archived_project
else else

View File

@ -37,6 +37,7 @@ class CoursesController < ApplicationController
join = cs.join_course params,@user join = cs.join_course params,@user
@state = join[:state] @state = join[:state]
@course = join[:course] @course = join[:course]
Mailer.run.join_course_request(@course, User.current, params[:role])
# else # else
# @course = Course.find_by_id params[:object_id] # @course = Course.find_by_id params[:object_id]
# CourseMessage.create(:user_id => @course.tea_id, :course_id => @course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest') # CourseMessage.create(:user_id => @course.tea_id, :course_id => @course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest')
@ -617,6 +618,10 @@ class CoursesController < ApplicationController
create_course_messages = @course.course_messages.where("user_id =? and course_message_type =? and course_id =? and viewed =?", User.current.id, 'Course', @course.id, 0) create_course_messages = @course.course_messages.where("user_id =? and course_message_type =? and course_id =? and viewed =?", User.current.id, 'Course', @course.id, 0)
create_course_messages.update_all(:viewed => true) create_course_messages.update_all(:viewed => true)
#更新申请结果反馈消息的状态
course_request_messages = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @course.id, 'CourseRequestDealResult', false)
course_request_messages.update_all(:viewed => true)
course_activities = @course.course_activities course_activities = @course.course_activities
@canShowRealName = User.current.member_of_course? @course @canShowRealName = User.current.member_of_course? @course
@page = params[:page] ? params[:page].to_i + 1 : 0 @page = params[:page] ? params[:page].to_i + 1 : 0

View File

@ -918,6 +918,12 @@ class UsersController < ApplicationController
end end
def show def show
#更新用户申请成为课程老师或教辅消息的状态
if params[:course_id] != nil
join_course_messages = CourseMessage.where("course_id =? and course_message_type =? and user_id =? and course_message_id =? and viewed =?",
params[:course_id], 'JoinCourseRequest', User.current.id, @user.id, false)
join_course_messages.update_all(:viewed => true)
end
@page = params[:page] ? params[:page].to_i + 1 : 0 @page = params[:page] ? params[:page].to_i + 1 : 0
user_project_ids = @user.projects.visible.empty? ? "(-1)" : "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")" user_project_ids = @user.projects.visible.empty? ? "(-1)" : "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")"
user_course_ids = @user.courses.visible.empty? ? "(-1)" : "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" user_course_ids = @user.courses.visible.empty? ? "(-1)" : "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")"

View File

@ -1009,6 +1009,16 @@ class Mailer < ActionMailer::Base
end end
end end
def join_course_request(course, user, role)
@receive = User.find(course.tea_id)
@course = course
@user = user
@role = role
@subject = "#{@user.show_name} #{l(:label_apply_join_course)} #{@course.name} "
mail :to => @receive.mail,
:subject => @subject
end
private private
@ -1066,4 +1076,5 @@ class Mailer < ActionMailer::Base
1.upto(len) { |i| newpass << chars[rand(chars.size-1)] } 1.upto(len) { |i| newpass << chars[rand(chars.size-1)] }
return newpass return newpass
end end
end end

View File

@ -317,6 +317,7 @@ class CoursesService
elsif current_user.allowed_to?(:as_teacher,course) elsif current_user.allowed_to?(:as_teacher,course)
@state = 3 @state = 3
else else
Mailer.run.join_course_request(course, User.current, params[:role])
#如果加入角色为教师或者教辅 #如果加入角色为教师或者教辅
CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0) CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0)
@state = 6 @state = 6
@ -337,6 +338,7 @@ class CoursesService
if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = #{params[:role]} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0").count != 0 if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = #{params[:role]} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0").count != 0
@state = 7 @state = 7
else else
Mailer.run.join_course_request(course, User.current, params[:role])
CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0) CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0)
@state = 6 @state = 6
end end

View File

@ -0,0 +1,4 @@
<p>
<%= @user.show_name %>申请成为课程<%= @course.name %>的<%= @role.eql?('9') ? '老师': '教辅' %>
<%=link_to user_message_url(@receive),user_message_url(@receive)%>
</p>

View File

@ -0,0 +1,4 @@
<%= @user.show_name %>申请成为课程<%= @course.name %>的<%= @role.eql?('9') ? '老师': '教辅' %>
<%=link_to user_message_url(@receive),user_message_url(@receive)%>

View File

@ -309,7 +309,7 @@
<% content = ma.content.gsub("作业评分:","").split("&nbsp;&nbsp;&nbsp; 评语:")%> <% content = ma.content.gsub("作业评分:","").split("&nbsp;&nbsp;&nbsp; 评语:")%>
<li>作品评分:<span style="color:Red;"><%= content[0] %>分</span></li> <li>作品评分:<span style="color:Red;"><%= content[0] %>分</span></li>
<% if content.size > 1 %> <% if content.size > 1 %>
<div class="fl"><li>作品评语:</li></div> <div class="fl" style="width:74px;"><li>作品评语:</li></div>
<div style="margin-left:74px"><span style="color:Red;"><%= content[1] %></span></div> <div style="margin-left:74px"><span style="color:Red;"><%= content[1] %></span></div>
<% end %> <% end %>
</ul> </ul>
@ -442,7 +442,7 @@
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">您有了新的课程成员申请:</span> <span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">您有了新的课程成员申请:</span>
</li> </li>
<li class="homepageHomeworkContent fl"><a href="javascript:void(0);" class="newsGrey"> <li class="homepageHomeworkContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to User.find(ma.course_message_id).name+"申请成为课程\""+"#{Course.find(ma.course_id).name}"+"\"的"+"#{ma.content == '9' ? "教师" : "教辅"}", user_path(User.find(ma.course_message_id)), <%= link_to User.find(ma.course_message_id).name+"申请成为课程\""+"#{Course.find(ma.course_id).name}"+"\"的"+"#{ma.content == '9' ? "教师" : "教辅"}", user_path(User.find(ma.course_message_id), :course_id => ma.course_id),
:class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
:onmouseover => "message_titile_show($(this),event)", :onmouseover => "message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %></a> :onmouseout => "message_titile_hide($(this))" %></a>

View File

@ -27,7 +27,7 @@ zh:
# 资源库 (课程、项目按类型分) # 资源库 (课程、项目按类型分)
label_course_file: 资源库 label_course_file: 资源库
label_upload_files: 上传资源 label_upload_files: 上传资源
label_apply_join_course: 申请加入课程
# #
# 课程托管平台主页 # 课程托管平台主页
# #