作业开启/关闭匿评邮件通知
This commit is contained in:
parent
fb76bc8f9a
commit
810c0d8fe5
|
@ -206,7 +206,8 @@ class HomeworkCommonController < ApplicationController
|
|||
end
|
||||
@homework_detail_manual.update_column('comment_status', 2)
|
||||
@statue = 1
|
||||
# send_message_homework(@homework)
|
||||
send_message_anonymous_comment(@homework, open=true)
|
||||
Mailer.send_mail_anonymous_comment_open(@homework).deliver
|
||||
else
|
||||
@statue = 2
|
||||
end
|
||||
|
@ -225,21 +226,21 @@ class HomeworkCommonController < ApplicationController
|
|||
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0
|
||||
student_work.save
|
||||
end
|
||||
# send_message_homework(@homework)
|
||||
send_message_anonymous_comment(@homework, open = false)
|
||||
Mailer.send_mail_anonymous_comment_close(@homework).deliver
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
# 开启/关闭匿评消息通知
|
||||
# def send_message_homework(homework)
|
||||
# # status 标记匿评状态 1为关闭 0为开启
|
||||
# course = @homework.course
|
||||
# course.student.each do |st|
|
||||
# @homework.course_messages << CourseMessage.new(:user_id => st.user_id, :course_id => course.id, :viewed => false, :status => false)
|
||||
# end
|
||||
# end
|
||||
|
||||
def send_message_anonymous_comment(homework, open)
|
||||
# status 标记匿评状态 1为关闭 0为开启
|
||||
course = @homework.course
|
||||
course.student.each do |st|
|
||||
@homework.course_messages << CourseMessage.new(:user_id => st.user_id, :course_id => course.id, :viewed => false, :status => open ? true : false)
|
||||
end
|
||||
end
|
||||
#提示
|
||||
def alert_anonymous_comment
|
||||
@cur_size = 0
|
||||
|
|
|
@ -47,6 +47,40 @@ class Mailer < ActionMailer::Base
|
|||
MailerProxy.new(self)
|
||||
end
|
||||
|
||||
# 作业匿评开启
|
||||
def send_mail_anonymous_comment_open(homework_common)
|
||||
course = homework_common.course
|
||||
course.student.each do |student|
|
||||
user = student.user
|
||||
@subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_open)}"
|
||||
@token = Token.get_token_from_user(user, 'autologin')
|
||||
@anonymous_comment_close_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
|
||||
@anonymous_comment_close_name = homework_common.name
|
||||
@author = homework_common.user
|
||||
#收件人邮箱
|
||||
recipient = user.mail
|
||||
mail :to => recipient,
|
||||
:subject => @subject
|
||||
end
|
||||
end
|
||||
|
||||
# 作业匿评关闭
|
||||
def send_mail_anonymous_comment_close(homework_common)
|
||||
course = homework_common.course
|
||||
course.student.each do |student|
|
||||
user = student.user
|
||||
@subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_open)}"
|
||||
@token = Token.get_token_from_user(user, 'autologin')
|
||||
@anonymous_comment_close_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
|
||||
@anonymous_comment_close_name = homework_common.name
|
||||
@author = homework_common.user
|
||||
#收件人邮箱
|
||||
recipient = user.mail
|
||||
mail :to => recipient,
|
||||
:subject => @subject
|
||||
end
|
||||
end
|
||||
|
||||
# author: alan
|
||||
# 邀请未注册用户加入项目
|
||||
# 功能: 在加入项目的同时自动注册用户
|
||||
|
@ -82,13 +116,13 @@ class Mailer < ActionMailer::Base
|
|||
@token = Token.get_token_from_user(user, 'autologin')
|
||||
@project_url = url_for(:controller => 'projects', :action => 'member', :id => project.id, :user_id => user.id, :mail => true, :token => @token.value)
|
||||
# 发送消息邀请
|
||||
send_message(user,project)
|
||||
send_message_request_member(user,project)
|
||||
# end
|
||||
mail :to => email, :subject => @subject
|
||||
end
|
||||
|
||||
# 邀请信息消息 注:forge_message_id 为邀请人ID(特殊情况)
|
||||
def send_message(user, project)
|
||||
def send_message_request_member(user, project)
|
||||
key = newpass(6).to_s
|
||||
ForgeMessage.create(:user_id => user.id, :project_id => project.id, :forge_message_type => "ProjectInvite",:forge_message_id => User.current.id, :viewed => false, :secret_key =>key)
|
||||
end
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<div class="mail_box" style="border:1px solid #c8c8c8; width:570px; height: auto; padding:15px; margin-top:10px; margin-bottom:10px;">
|
||||
<ul style="list-style-type:none; margin:0; padding:0;">
|
||||
<li style="list-style-type:none; margin:0; padding:0;"><span style="float: left;"><strong><%= l(:mail_issue_content)%></strong></span>
|
||||
<span style="float: left; width: 526px">
|
||||
<p><%=link_to @author, user_url(@author) %> 发布的作业:<%=link_to @homework_endtime_name, @homework_endtime_url%> <span style="color: red; padding-left: 10px;">已经关闭了匿评!</span></p>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="cl" style="margin-top: 30px; clear:both; overflow:hidden;"></div>
|
||||
</div>
|
|
@ -0,0 +1,10 @@
|
|||
<div class="mail_box" style="border:1px solid #c8c8c8; width:570px; height: auto; padding:15px; margin-top:10px; margin-bottom:10px;">
|
||||
<ul style="list-style-type:none; margin:0; padding:0;">
|
||||
<li style="list-style-type:none; margin:0; padding:0;"><span style="float: left;"><strong><%= l(:mail_issue_content)%></strong></span>
|
||||
<span style="float: left; width: 526px">
|
||||
<p><%=link_to @author, user_url(@author) %> 发布的作业:<%=link_to @homework_endtime_name, @homework_endtime_url%> <span style="color: red; padding-left: 10px;">已经开启匿评了!</span></p>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="cl" style="margin-top: 30px; clear:both; overflow:hidden;"></div>
|
||||
</div>
|
|
@ -25,4 +25,6 @@ zh:
|
|||
mail_course_homework_active: "中发布了作业"
|
||||
mail_attention: "请您关注!"
|
||||
mail_homework_endtime: "作业截止时间快到了!"
|
||||
mail_homework: "作业:"
|
||||
mail_homework: "作业:"
|
||||
mail_anonymous_comment_close: "作业匿评已经关闭!"
|
||||
mail_anonymous_comment_open: "作业匿评已经开启!"
|
Loading…
Reference in New Issue