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