Merge branch 'dev_hjq' of http://repository.trustie.net/xianbo/trustie2 into dev_hjq
This commit is contained in:
commit
073761781d
|
@ -53,7 +53,7 @@ class Mailer < ActionMailer::Base
|
|||
recipients ||= []
|
||||
course.members.each do |member|
|
||||
user = User.find(member.user_id)
|
||||
@subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_open)}"
|
||||
# @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
|
||||
|
@ -62,7 +62,7 @@ class Mailer < ActionMailer::Base
|
|||
recipients << user.mail
|
||||
end
|
||||
mail :to => recipients,
|
||||
:subject => @subject
|
||||
:subject => "[#{l(:mail_homework)}#{homework_common.name}] #{l(:mail_anonymous_comment_open)}"
|
||||
end
|
||||
|
||||
# 作业匿评关闭
|
||||
|
@ -71,7 +71,7 @@ class Mailer < ActionMailer::Base
|
|||
recipients ||= []
|
||||
course.members.each do |member|
|
||||
user = User.find(member.user_id)
|
||||
@subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_open)}"
|
||||
#@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
|
||||
|
@ -80,12 +80,28 @@ class Mailer < ActionMailer::Base
|
|||
recipients << user.mail
|
||||
end
|
||||
mail :to => recipients,
|
||||
:subject => @subject
|
||||
:subject => "[#{l(:mail_homework)}#{homework_common.name}] #{l(:mail_anonymous_comment_open)}"
|
||||
end
|
||||
|
||||
# 匿评失败给老师发送邮件通知
|
||||
def send_mail_anonymous_comment_fail
|
||||
|
||||
def send_mail_anonymous_comment_fail(homework_common)
|
||||
course = homework_common.course
|
||||
recipients ||= []
|
||||
# 只给该课程的老师发送邮件提醒
|
||||
course.members.each do |member|
|
||||
if m.user.allowed_to?(:as_teacher,course)
|
||||
user = User.find(member.user_id)
|
||||
#@subject = "[#{l(:mail_homework)} #{homework_common.name}] #{l(:mail_anonymous_comment_failed)}"
|
||||
@token = Token.get_token_from_user(user, 'autologin')
|
||||
@anonymous_comment_fail_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
|
||||
@anonymous_comment_fail_name = homework_common.name
|
||||
@author = homework_common.user
|
||||
#收件人邮箱
|
||||
recipients << user.mail
|
||||
end
|
||||
end
|
||||
mail :to => recipients,
|
||||
:subject => "[#{l(:mail_homework)} #{homework_common.name}] #{l(:mail_anonymous_comment_failed)}"
|
||||
end
|
||||
|
||||
# author: alan
|
||||
|
@ -269,7 +285,7 @@ class Mailer < ActionMailer::Base
|
|||
#收件人邮箱
|
||||
recipient = user.mail
|
||||
mail :to => recipient,
|
||||
:subject => "#{l(:mail_homework)}#{homework_common.name}#{l(:mail_homework_endtime)} "
|
||||
:subject => @subject
|
||||
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 @anonymous_comment_fail_name, @anonymous_comment_fail_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>
|
|
@ -27,4 +27,5 @@ zh:
|
|||
mail_homework_endtime: "作业截止时间快到了!"
|
||||
mail_homework: "作业:"
|
||||
mail_anonymous_comment_close: "作业匿评已经关闭!"
|
||||
mail_anonymous_comment_open: "作业匿评已经开启!"
|
||||
mail_anonymous_comment_open: "作业匿评已经开启!"
|
||||
mail_anonymous_comment_failed: "作业匿评开启失败!"
|
|
@ -3,16 +3,14 @@
|
|||
namespace :homework_endtime do
|
||||
desc "send a message for Job deadline"
|
||||
task :message => :environment do
|
||||
current_day = Date.today.day
|
||||
homework_commons = HomeworkCommon.where("end_time >=?",Date.today)
|
||||
contrast_time = Time.now - 86400
|
||||
homework_commons = HomeworkCommon.where("end_time >=? and end_time <=?",contrast_time, Time.now)
|
||||
homework_commons.each do |homework_common|
|
||||
if CourseMessage.where("course_message_type =? and course_message_id =? and status =?", "HomeworkCommon", homework_common.id, 1).first.nil?
|
||||
if homework_common.end_time.day - Date.today.day < 2 && homework_common.end_time.year == Date.today.year
|
||||
homework_common.course.student.each do |s|
|
||||
homework_common.course_messages << CourseMessage.new(:user_id => s.student_id, :course_id => homework_common.course_id, :viewed => false, :status => true)
|
||||
# 发送邮件通知
|
||||
Mailer.homework_endtime__added(homework_common, s.student_id).deliver
|
||||
end
|
||||
homework_common.course.student.each do |s|
|
||||
homework_common.course_messages << CourseMessage.new(:user_id => s.student_id, :course_id => homework_common.course_id, :viewed => false, :status => true)
|
||||
# 发送邮件通知
|
||||
Mailer.homework_endtime__added(homework_common, s.student_id).deliver
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace :homework_evaluation do
|
|||
end
|
||||
end
|
||||
# 邮件通知
|
||||
# Mailer.send_mail_anonymous_comment_close(homework_common).deliver
|
||||
Mailer.send_mail_anonymous_comment_fail(homework_common).deliver
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue