parent
21408f3843
commit
3f6d64877a
|
@ -40,9 +40,9 @@ class HomeworkCommon < ActiveRecord::Base
|
||||||
def act_as_course_message
|
def act_as_course_message
|
||||||
if self.course
|
if self.course
|
||||||
self.course.members.each do |m|
|
self.course.members.each do |m|
|
||||||
if m.user_id != self.user_id
|
# if m.user_id != self.user_id
|
||||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false)
|
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false)
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,16 +53,17 @@ class Mailer < ActionMailer::Base
|
||||||
recipients ||= []
|
recipients ||= []
|
||||||
course.members.each do |member|
|
course.members.each do |member|
|
||||||
user = User.find(member.user_id)
|
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')
|
@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_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
|
||||||
@anonymous_comment_close_name = homework_common.name
|
@anonymous_comment_close_name = homework_common.name
|
||||||
@author = homework_common.user
|
@author = homework_common.user
|
||||||
#收件人邮箱
|
#收件人邮箱
|
||||||
|
|
||||||
recipients << user.mail
|
recipients << user.mail
|
||||||
end
|
end
|
||||||
mail :to => recipients,
|
mail :to => recipients,
|
||||||
:subject => "[#{l(:mail_homework)}#{homework_common.name}] #{l(:mail_anonymous_comment_open)}"
|
:subject => @subject
|
||||||
end
|
end
|
||||||
|
|
||||||
# 作业匿评关闭
|
# 作业匿评关闭
|
||||||
|
@ -71,7 +72,7 @@ class Mailer < ActionMailer::Base
|
||||||
recipients ||= []
|
recipients ||= []
|
||||||
course.members.each do |member|
|
course.members.each do |member|
|
||||||
user = User.find(member.user_id)
|
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_close)}"
|
||||||
@token = Token.get_token_from_user(user, 'autologin')
|
@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_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
|
||||||
@anonymous_comment_close_name = homework_common.name
|
@anonymous_comment_close_name = homework_common.name
|
||||||
|
@ -80,7 +81,7 @@ class Mailer < ActionMailer::Base
|
||||||
recipients << user.mail
|
recipients << user.mail
|
||||||
end
|
end
|
||||||
mail :to => recipients,
|
mail :to => recipients,
|
||||||
:subject => "[#{l(:mail_homework)}#{homework_common.name}] #{l(:mail_anonymous_comment_open)}"
|
:subject => @subject
|
||||||
end
|
end
|
||||||
|
|
||||||
# 匿评失败给老师发送邮件通知
|
# 匿评失败给老师发送邮件通知
|
||||||
|
@ -89,19 +90,23 @@ class Mailer < ActionMailer::Base
|
||||||
recipients ||= []
|
recipients ||= []
|
||||||
# 只给该课程的老师发送邮件提醒
|
# 只给该课程的老师发送邮件提醒
|
||||||
course.members.each do |member|
|
course.members.each do |member|
|
||||||
if m.user.allowed_to?(:as_teacher,course)
|
if member.user.allowed_to?(:as_teacher,course)
|
||||||
user = User.find(member.user_id)
|
user = User.find(member.user_id)
|
||||||
#@subject = "[#{l(:mail_homework)} #{homework_common.name}] #{l(:mail_anonymous_comment_failed)}"
|
@subject = "[#{l(:mail_homework)} #{homework_common.name}] #{l(:mail_anonymous_comment_failed)}"
|
||||||
@token = Token.get_token_from_user(user, 'autologin')
|
@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_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
|
||||||
@anonymous_comment_fail_name = homework_common.name
|
@anonymous_comment_fail_name = homework_common.name
|
||||||
@author = homework_common.user
|
@author = homework_common.user
|
||||||
#收件人邮箱
|
#收件人邮箱
|
||||||
|
puts "######################"
|
||||||
|
puts homework_common.id
|
||||||
|
puts recipients
|
||||||
|
puts "######################"
|
||||||
recipients << user.mail
|
recipients << user.mail
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
mail :to => recipients,
|
mail :to => recipients,
|
||||||
:subject => "[#{l(:mail_homework)} #{homework_common.name}] #{l(:mail_anonymous_comment_failed)}"
|
:subject => @subject
|
||||||
end
|
end
|
||||||
|
|
||||||
# author: alan
|
# author: alan
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace :homework_evaluation do
|
||||||
homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2)
|
homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2)
|
||||||
end
|
end
|
||||||
# 邮件通知
|
# 邮件通知
|
||||||
Mailer.send_mail_anonymous_comment_close(homework_common).deliver
|
Mailer.send_mail_anonymous_comment_open(homework_common).deliver
|
||||||
else
|
else
|
||||||
#作业数小于2,启动失败, 只给老师发
|
#作业数小于2,启动失败, 只给老师发
|
||||||
# status==4 发送失败
|
# status==4 发送失败
|
||||||
|
@ -65,7 +65,10 @@ namespace :homework_evaluation do
|
||||||
end
|
end
|
||||||
homework_detail_manual.update_column('comment_status', 3)
|
homework_detail_manual.update_column('comment_status', 3)
|
||||||
# 匿评关闭消息通知 给所有人发
|
# 匿评关闭消息通知 给所有人发
|
||||||
send_message_anonymous_comment(homework_common, 3)
|
course = homework_common.course
|
||||||
|
course.members.each do |m|
|
||||||
|
homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 3)
|
||||||
|
end
|
||||||
# 邮件通知
|
# 邮件通知
|
||||||
Mailer.send_mail_anonymous_comment_close(homework_common).deliver
|
Mailer.send_mail_anonymous_comment_close(homework_common).deliver
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue