@ -372,11 +372,11 @@ class HomeworkAttachController < ApplicationController
def show
def show
if User . current . admin? || User . current . member_of_course? ( @homework . bid . courses . first )
if User . current . admin? || User . current . member_of_course? ( @homework . bid . courses . first )
# 打分统计
# 打分统计
stars_reates = @homework . rates ( :quality )
#stars_reates = @homework. rates(:quality )
#是否已经进行过评价
#是否已经进行过评价
temp = HomeworkAttach . find_by_sql ( " SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = #{ @homework . id } AND rater_id = #{ User . current . id } " ) . first
temp = HomeworkAttach . find_by_sql ( " SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = #{ @homework . id } AND rater_id = #{ User . current . id } " ) . first
@m_score = temp . nil? ? 0 :temp . stars
@m_score = temp . nil? ? 0 :temp . stars
@has_evaluation = stars_reates . where ( " rater_id = ? " , User . current ) . count > 0
@has_evaluation = @homework . has_rated? ( User . current , :quality )
#@jours留言 is null条件用以兼容历史数据
#@jours留言 is null条件用以兼容历史数据
@jours = @homework . journals_for_messages . where ( " is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null " ) . order ( " created_on DESC " )
@jours = @homework . journals_for_messages . where ( " is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null " ) . order ( " created_on DESC " )
@cur_page = params [ :cur_page ] || 1
@cur_page = params [ :cur_page ] || 1
@ -385,13 +385,17 @@ class HomeworkAttachController < ApplicationController
teachers = searchTeacherAndAssistant @course
teachers = searchTeacherAndAssistant @course
@comprehensive_evaluation = [ ]
@comprehensive_evaluation = [ ]
#JourForMessage的is_comprehensive_evaluation字段:
#1: 老师评价
#2: 学生评价
#3 || null: 学生留言
teachers . each do | teacher |
teachers . each do | teacher |
temp = @homework . journals_for_messages . where ( " is_comprehensive_evaluation = 1 and user_id = #{ teacher . user_id } " ) . order ( " created_on DESC " ) . first
temp = @homework . journals_for_messages . where ( " is_comprehensive_evaluation = 1 and user_id = #{ teacher . user_id } " ) . order ( " created_on DESC " ) . first
@comprehensive_evaluation << temp if temp
@comprehensive_evaluation << temp if temp
end
end
annymous_users = @homework . homework_evaluations . map ( & :user )
annymous_users = @homework . homework_evaluations . map { | homework_evaluation | homework_evaluation . user . id } . join ( ',' )
unless annymous_users . nil? || annymous_users . count == 0
unless annymous_users . nil? || annymous_users == " "
@anonymous_comments = @homework . journals_for_messages . where ( " is_comprehensive_evaluation = 2 and user_id in #{ convert_array( annymous_users) } " ) . order ( " created_on DESC " )
@anonymous_comments = @homework . journals_for_messages . where ( " is_comprehensive_evaluation = 2 and user_id in ( #{ annymous_users} ) " ) . order ( " created_on DESC " )
end
end
#@totle_score = score_for_homework @homework
#@totle_score = score_for_homework @homework
#@teaher_score = teacher_score_for_homework @homework
#@teaher_score = teacher_score_for_homework @homework