禁用匿评的作业在截止时作业状态变为3

This commit is contained in:
cxt 2015-11-12 14:53:12 +08:00
parent 8fa790dd6b
commit 3f60893591
1 changed files with 13 additions and 1 deletions

View File

@ -1,7 +1,7 @@
#coding=utf-8
namespace :homework_publishtime do
desc "start publish homework"
desc "start publish homework and end homework"
task :publish => :environment do
homework_commons = HomeworkCommon.where("publish_time = '#{Date.today}'")
homework_commons.each do |homework|
@ -20,4 +20,16 @@ namespace :homework_publishtime do
end
end
end
task :end => :environment do
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
if homework_detail_manual.comment_status == 1
homework_detail_manual.update_column('comment_status', 3)
end
end
end
end
end