diff --git a/lib/tasks/exercise_publish.rake b/lib/tasks/exercise_publish.rake index aacd67c1f..a27c6a6fb 100644 --- a/lib/tasks/exercise_publish.rake +++ b/lib/tasks/exercise_publish.rake @@ -6,6 +6,10 @@ namespace :exercise_publish do exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now) exercises.each do |exercise| exercise.update_column('exercise_status', 2) + course = exercise.course + course.members.each do |m| + exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2) + end end end diff --git a/lib/tasks/exercise_publishtime.rake b/lib/tasks/exercise_publishtime.rake deleted file mode 100644 index 6cef511e2..000000000 --- a/lib/tasks/exercise_publishtime.rake +++ /dev/null @@ -1,22 +0,0 @@ -#coding=utf-8 - -namespace :exercise_publishtime do - desc "start publish exercise" - task :publish => :environment do - exercises = Exercise.where("date_format(publish_time,'%Y-%m-%d')= '#{Date.today}'") - exercises.each do |exercise| - if exercise.exercise_status == 1 #未发布 - exercise.update_column('exercise_status', 2) #改为发布 - course = exercise.course - course.members.each do |m| - exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2) - end - # if homework.course_acts.size == 0 - # homework.course_acts << CourseActivity.new(:user_id => homework.user_id,:course_id => homework.course_id) - # end - # 邮件通知 - #Mailer.run.homework_added(homework) - end - end - end -end \ No newline at end of file