完成消息所有逻辑功能

This commit is contained in:
huang 2015-09-08 14:14:49 +08:00
parent 4c73e00eaf
commit ae2aa2fedd
1 changed files with 13 additions and 4 deletions

View File

@ -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