parent
2873412d1a
commit
ba569403c3
|
@ -148,9 +148,9 @@ class HomeworkCommonController < ApplicationController
|
|||
# 开启/关闭匿评消息通知
|
||||
def send_message_anonymous_comment(homework, m_status )
|
||||
# status 标记匿评状态 1为关闭 0为开启
|
||||
course = @homework.course
|
||||
course.student.each do |st|
|
||||
@homework.course_messages << CourseMessage.new(:user_id => st.student_id, :course_id => course.id, :viewed => false, :status => m_status)
|
||||
course = homework.course
|
||||
course.members.each do |m|
|
||||
@homework.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => m_status)
|
||||
end
|
||||
end
|
||||
#提示
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
class CourseMessage < ActiveRecord::Base
|
||||
# status说明: status在课程不同的类型,区分不同的功能
|
||||
# HomeworkCommon:status:
|
||||
# nil:发布了作业; 1:作业截止时间到了提醒!;2:开启匿评; 3:关闭匿评; 4:匿评开始失败
|
||||
attr_accessible :course_id, :course_message_id, :course_message_type, :user_id, :viewed, :content, :status
|
||||
|
||||
# 多态 虚拟关联
|
||||
|
|
|
@ -51,8 +51,8 @@ class Mailer < ActionMailer::Base
|
|||
def send_mail_anonymous_comment_open(homework_common)
|
||||
course = homework_common.course
|
||||
recipients ||= []
|
||||
course.student.each do |student|
|
||||
user = User.find(student.student_id)
|
||||
course.members.each do |member|
|
||||
user = User.find(member.user_id)
|
||||
@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))
|
||||
|
@ -69,8 +69,8 @@ class Mailer < ActionMailer::Base
|
|||
def send_mail_anonymous_comment_close(homework_common)
|
||||
course = homework_common.course
|
||||
recipients ||= []
|
||||
course.student.each do |student|
|
||||
user = User.find(student.student_id)
|
||||
course.members.each do |member|
|
||||
user = User.find(member.user_id)
|
||||
@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))
|
||||
|
|
|
@ -26,10 +26,7 @@ namespace :homework_evaluation do
|
|||
end
|
||||
homework_detail_manual.update_column('comment_status', 2)
|
||||
# 匿评开启消息邮件通知,# 所有人
|
||||
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 => 2)
|
||||
end
|
||||
send_message_anonymous_comment(homework_common, 2)
|
||||
# 邮件通知
|
||||
Mailer.send_mail_anonymous_comment_close(homework_common).deliver
|
||||
else
|
||||
|
@ -64,10 +61,7 @@ namespace :homework_evaluation do
|
|||
end
|
||||
homework_detail_manual.update_column('comment_status', 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
|
||||
send_message_anonymous_comment(homework_common, 3)
|
||||
# 邮件通知
|
||||
Mailer.send_mail_anonymous_comment_close(homework_common).deliver
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue