From ae2aa2feddcfe8f1d1f0ea89c2a047d15198b936 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 8 Sep 2015 14:14:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=B6=88=E6=81=AF=E6=89=80?= =?UTF-8?q?=E6=9C=89=E9=80=BB=E8=BE=91=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 9bc7b52ed..3ed5eb914 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -69,12 +69,21 @@ class StudentWorkController < ApplicationController def index # 作业消息状态更新 @homework.course_messages.each do |homework_message| - if User.current.id == homework_message.user_id - homework_message.update_attributes(:viewed => true) + if User.current.id == homework_message.user_id && homework_message.viewed == 0 + homework_message.update_attributes(:viewed => true) if homework_message.viewed == 0 end end - # 作品消息状态更新 - + # 作品打分消息状态更新 + studentworks_scores = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "StudentWorksScore", 0) + studentworks_scores.each do |studentworks_score| + studentworks_score.update_attributes(:viewed => true) if studentworks_score.viewed == 0 + end + # 作品评论消息状态更新 + journals_for_teacher = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "JournalsForMessage", 0) + journals_for_teacher.each do |journal_for_teacher| + journal_for_teacher.update_attributes(:viewed => true) + end + # 作品留言 # 消息end #设置作业对应的forge_messages表的viewed字段 query_student_work = @homework.course_messages