From 7ed93c1d808599efc25957c458076e6c1259af13 Mon Sep 17 00:00:00 2001 From: huang Date: Sat, 29 Aug 2015 19:26:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=80=BB=E8=A1=A8=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20150829024549_course_messages.rb | 57 +++++++++---------- .../20150829081822_update_message_time.rb | 2 +- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/db/migrate/20150829024549_course_messages.rb b/db/migrate/20150829024549_course_messages.rb index a26a5a281..666ccdaeb 100644 --- a/db/migrate/20150829024549_course_messages.rb +++ b/db/migrate/20150829024549_course_messages.rb @@ -76,35 +76,34 @@ class CourseMessages < ActiveRecord::Migration end # 作品评阅 - course.homework_commons.each do |homework_common| - if homework_common.student_works - homework_common.student_works.each do |student_work| - if student_work.student_works_scores - student_work.student_works_scores.each do |student_works_score| - receiver = student_works_score.student_work.user - if student_works_score.created_at == student_works_score.updated_at - if student_works_score.comment.nil? - student_works_score.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => course.id, - :viewed => true, :content => "作业评分:#{student_works_score.score}", :status=> true) - else - student_works_score.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => course.id, - :viewed => true, :content => "作业评分:#{student_works_score.score}    评语:#{student_works_score.comment}", :status=> true) - end - else # 更新 - if student_works_score.comment.nil? - student_works_score.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => course.id, - :viewed => true, :content => "作业评分:#{student_works_score.score}", :status=> true) - else - student_works_score.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => course.id, - :viewed => true, :content => "作业评分:#{student_works_score.score}    评语:#{student_works_score.comment}", :status=> true) - end - end - end - end - end - end - end - + # course.homework_commons.each do |homework_common| + # if homework_common.student_works + # homework_common.student_works.each do |student_work| + # if student_work.student_works_scores + # student_work.student_works_scores.each do |student_works_score| + # receiver = student_works_score.student_work.user + # if student_works_score.created_at == student_works_score.updated_at + # if student_works_score.comment.nil? + # student_works_score.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => course.id, + # :viewed => true, :content => "作业评分:#{student_works_score.score}", :status=> true) + # else + # student_works_score.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => course.id, + # :viewed => true, :content => "作业评分:#{student_works_score.score}    评语:#{student_works_score.comment}", :status=> true) + # end + # else # 更新 + # if student_works_score.comment.nil? + # student_works_score.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => course.id, + # :viewed => true, :content => "作业评分:#{student_works_score.score}", :status=> true) + # else + # student_works_score.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => course.id, + # :viewed => true, :content => "作业评分:#{student_works_score.score}    评语:#{student_works_score.comment}", :status=> true) + # end + # end + # end + # end + # end + # end + # end # 作品讨论 end diff --git a/db/migrate/20150829081822_update_message_time.rb b/db/migrate/20150829081822_update_message_time.rb index 0bbc4458c..31dcb0b4f 100644 --- a/db/migrate/20150829081822_update_message_time.rb +++ b/db/migrate/20150829081822_update_message_time.rb @@ -20,7 +20,7 @@ class UpdateMessageTime < ActiveRecord::Migration end end - forge_count = ForgeMessage.all.count / 30 + 2 + forge_count = ForgeMessage.all.count / 30 + 1 transaction do for i in 1 ... forge_count do i ForgeMessage.page(i).per(30).each do |fmessage|