create_course_messages=@course.course_messages.where("user_id =? and course_message_type =? and course_id =? and viewed =?",User.current.id,'Course',@course.id,0)
join_project_messages=ForgeMessage.where("user_id =? and project_id =? and forge_message_type=?",user,project,"JoinProject")
join_project_messages.eachdo|join_project|
join_project.update_attribute(:viewed,true)
end
#更新被移出项目消息的viewed字段
remove_project_messages=ForgeMessage.where("user_id =? and project_id =? and forge_message_type=?",user,project,"RemoveFromProject")
remove_project_messages.update_all(:viewed=>true)
# 更新加入项目消息
project__messages=ForgeMessage.where("forge_message_type in ('ProjectInvite', 'JoinProject', 'RemoveFromProject') and user_id =? and project_id =? ",user,project)
student_work_messages=CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?",User.current.id,@homework.course,StudentWork.name,0)
student_work_messages.eachdo|message|
message.update_attribute(:viewed,true)
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.eachdo|studentworks_score|
@ -230,12 +351,12 @@ class StudentWorkController < ApplicationController
render_403
return
end
@student_work_count=(search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").order("#{@order}#{@b_sort}"),@name).count
end
@score=@b_sort=="desc"?"asc":"desc"
# 消息传过来的ID
@message_student_work_id=params[:student_work_id]
respond_todo|format|
format.js
format.html
@ -369,6 +490,8 @@ class StudentWorkController < ApplicationController
# sql = "SELECT distinct c.* FROM `courses` c, tags t, taggings ts where t.id = ts.tag_id and ts.taggable_id = c.id and c.is_excellent = 1 and is_delete = 0 and
# ts.taggable_type = 'Course' and t.name like '%#{keywords}%'"
OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and org_subfield_id = #{field_id} and parent_id is null order by updated_at desc limit 8;")
end
defget_message_reply_org(org_id,ids)
# OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and parent_id is not null order by updated_at desc limit 1;")
OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and parent_id in (#{ids}) order by updated_at desc limit 1;")
end
defget_attach_org(field_id)
Attachment.find_by_sql("SELECT * FROM `attachments` where container_id =#{field_id} and container_type = 'OrgSubfield' and is_public =1 order by created_on limit 6;")
# Attachment.find_by_sql("SELECT * FROM `attachments` where container_id =#{field_id} and container_type = 'OrgSubfield' and is_public =1 order by created_on limit 6;")
UserExtensions.find_by_sql("SELECT * FROM user_extensions WHERE occupation = '#{school.name}' AND identity = '1'").count
end
defteacher_numschool
UserExtensions.find_by_sql("SELECT * FROM user_extensions AS ue, schools AS s WHERE ue.school_id = s.id AND s.name = '#{school.name}' AND ue.identity = '0'").count
course_count=CourseMessage.where("user_id =? and viewed =? and created_at >?",User.current.id,0,User.current.onclick_time.onclick_time).count
forge_count=ForgeMessage.where("user_id =? and viewed =? and created_at >?",User.current.id,0,User.current.onclick_time.onclick_time).count
user_feedback_count=UserFeedbackMessage.where("user_id =? and viewed =? and created_at >?",User.current.id,0,User.current.onclick_time.onclick_time).count
user_memo_count=MemoMessage.where("user_id =? and viewed =? and created_at >?",User.current.id,0,User.current.onclick_time.onclick_time).count