From ca5f03f2ea5aa89264ea1003d21d9a558940c14b Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 12 May 2016 14:13:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=9B=9E=E5=A4=8D=E7=9A=84?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5=EF=BC=8C=E8=AF=84=E9=98=85?= =?UTF-8?q?=E4=BD=9C=E5=93=81=E7=9A=84=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/journals_for_message.rb | 5 +++++ app/models/student_works_score.rb | 16 +++++++++++++-- app/views/users/_user_message_course.html.erb | 20 +++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 10971d46f..4b5ac227f 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -256,6 +256,11 @@ class JournalsForMessage < ActiveRecord::Base end end if self.jour_type == 'HomeworkCommon' + if self.m_parent_id.nil? + if self.user_id != self.jour.user_id + self.course_messages << CourseMessage.new(:user_id => self.jour.user_id,:course_id => self.jour.course.id, :viewed => false) + end + end count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.jour.user_id} and shield_type='Course' and shield_id=#{self.jour.course_id}").count if count == 0 ws = WechatService.new diff --git a/app/models/student_works_score.rb b/app/models/student_works_score.rb index aa38c5dcd..b2fc4fdcd 100644 --- a/app/models/student_works_score.rb +++ b/app/models/student_works_score.rb @@ -18,17 +18,29 @@ class StudentWorksScore < ActiveRecord::Base receiver = self.student_work.user # 判断是第一次评阅还是更新 status:0 新建;1 更新 if self.created_at == self.updated_at - if self.comment.nil? + if self.comment.nil? && self.score self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id, :viewed => false, :content => "作业评分:#{self.score}", :status=> false) + elsif self.score.nil? && self.comment + self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id, + :viewed => false, :content => "评语:#{self.comment}", :status=> false) + elsif self.comment.nil? && self.score.nil? + self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id, + :viewed => false, :content => "上传了批阅附件", :status=> false) else self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id, :viewed => false, :content => "作业评分:#{self.score}    评语:#{self.comment}", :status=> false) end else # 更新 - if self.comment.nil? + if self.comment.nil? && self.score self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id, :viewed => false, :content => "作业评分:#{self.score}", :status=> true) + elsif self.score.nil? && self.comment + self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id, + :viewed => false, :content => "评语:#{self.comment}", :status=> true) + elsif self.comment.nil? && self.score.nil? + self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id, + :viewed => false, :content => "上传了批阅附件", :status=> true) else self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id, :viewed => false, :content => "作业评分:#{self.score}    评语:#{self.comment}", :status=> true) diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index f8e6655d9..6736b1de2 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -409,6 +409,26 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> + <% elsif ma.course_message.jour_type == 'HomeworkCommon' %> + <% else %>