From 38ba47f8c8b799b88777d615fddd74515a379333 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 24 Sep 2015 16:16:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A8=E8=AE=BA=E5=8C=BA=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E4=BB=BB=E5=8A=A1=E4=B8=AD=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=EF=BC=9A=E8=87=AA=E5=8A=A8=E5=BC=80=E5=90=AF/?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E5=8C=BF=E8=AF=84=E6=B6=88=E6=81=AF=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=20=E5=8C=BF=E8=AF=84=E5=BC=80=E5=90=AF=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/messages_controller.rb | 1 + .../20150924063215_add_reply_id_to_message.rb | 5 ++++ lib/tasks/homework_evaluation.rake | 28 +++++++++++++++++-- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20150924063215_add_reply_id_to_message.rb diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index f9b5b7d32..8d2cb63aa 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -160,6 +160,7 @@ class MessagesController < ApplicationController @reply.safe_attributes = params[:reply] @reply.content = @quote + @reply.content @reply.subject = "RE: #{@topic.subject}" unless params[:reply][:subject] + @reply.reply_id = @message.author @topic.children << @reply user_activity = UserActivity.where("act_type='Message' and act_id =#{@topic.id}").first user_activity.updated_at = Time.now diff --git a/db/migrate/20150924063215_add_reply_id_to_message.rb b/db/migrate/20150924063215_add_reply_id_to_message.rb new file mode 100644 index 000000000..b55449ad7 --- /dev/null +++ b/db/migrate/20150924063215_add_reply_id_to_message.rb @@ -0,0 +1,5 @@ +class AddReplyIdToMessage < ActiveRecord::Migration + def change + add_column :messages, :reply_id, :integer + end +end diff --git a/lib/tasks/homework_evaluation.rake b/lib/tasks/homework_evaluation.rake index af833448d..75166391d 100644 --- a/lib/tasks/homework_evaluation.rake +++ b/lib/tasks/homework_evaluation.rake @@ -25,9 +25,25 @@ namespace :homework_evaluation do end 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 + # 邮件通知 + Mailer.send_mail_anonymous_comment_close(homework_common).deliver else - #作业数小于2,启动失败 + #作业数小于2,启动失败, 只给老师发 + # status==4 发送失败 + # 匿评开启消息邮件通知,# 所有人 + course = homework_common.course + course.members.each do |m| + if m.user.allowed_to?(:as_teacher,course) + homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 4) + end + end + # 邮件通知 + # Mailer.send_mail_anonymous_comment_close(homework_common).deliver end end end @@ -47,7 +63,13 @@ namespace :homework_evaluation do student_work.save 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 + # 邮件通知 + Mailer.send_mail_anonymous_comment_close(homework_common).deliver end end end