rake命令的消息通知
This commit is contained in:
parent
0a1a250e92
commit
259cb67c58
|
@ -1,21 +0,0 @@
|
|||
namespace :delete_evalution do
|
||||
desc "delete evaluation"
|
||||
task :delete => :environment do
|
||||
homework = HomeworkCommon.where("id = 844").first
|
||||
homework_detail_manual = homework.homework_detail_manual
|
||||
homework_detail_manual.update_column('comment_status', 3)
|
||||
student_work_score = StudentWorksScore.where("student_work_id = 28088 and user_id = 9263").first
|
||||
student_work_score.destroy
|
||||
student_work_9203 = StudentWork.where("id = 28088").first
|
||||
student_work_9263 = StudentWork.where("homework_common_id = 844 and user_id = 9263").first
|
||||
student_work_9203.update_column("student_score",91)
|
||||
student_work_9203.update_column("final_score",91)
|
||||
student_work_9263.update_column("absence_penalty",student_work_9263.absence_penalty+homework_detail_manual.absence_penalty)
|
||||
work_ids = "(" + homework.student_works.map(&:id).join(",") + ")"
|
||||
homework.student_works.each do |student_work|
|
||||
absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count
|
||||
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0
|
||||
student_work.save
|
||||
end
|
||||
end
|
||||
end
|
|
@ -52,7 +52,7 @@ namespace :homework_evaluation do
|
|||
|
||||
#自动关闭匿评的任务
|
||||
task :end_evaluation => :environment do
|
||||
homework_detail_manuals = HomeworkDetailManual.where("evaluation_end <= '#{Date.today}'")
|
||||
homework_detail_manuals = HomeworkDetailManual.where("evaluation_end = '#{Date.today}'")
|
||||
homework_detail_manuals.each do |homework_detail_manual|
|
||||
homework_common = homework_detail_manual.homework_common
|
||||
if homework_common.anonymous_comment == 0 && homework_detail_manual.comment_status == 2 #开启匿评状态才可关闭匿评
|
||||
|
@ -65,12 +65,12 @@ 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
|
||||
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
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace :homework_publishtime do
|
|||
end
|
||||
|
||||
task :end => :environment do
|
||||
homework_commons = HomeworkCommon.where("end_time < '#{Date.today}'")
|
||||
homework_commons = HomeworkCommon.where("end_time = '#{Date.today}'")
|
||||
homework_commons.each do |homework|
|
||||
if homework.anonymous_comment == 1
|
||||
homework_detail_manual = homework.homework_detail_manual
|
||||
|
|
Loading…
Reference in New Issue