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
jours=@homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC")#jours留言 is null条件用以兼容历史数据
@jour=paginateHelperjours,5#留言
@cur_page=params[:cur_page]||1
@cur_type=params[:cur_type]||5
@jour=paginateHelper@jours,5
teachers=searchTeacherAndAssistant@course
@comprehensive_evaluation=[]
#JourForMessage的is_comprehensive_evaluation字段:
#1:老师评价
#2:学生评价
#3 || null:学生留言
teachers.eachdo|teacher|
temp=@homework.journals_for_messages.where("is_comprehensive_evaluation = 1 and user_id = #{teacher.user_id}").order("created_on DESC").first
@anonymous_comments=@homework.journals_for_messages.where("is_comprehensive_evaluation = 2 and user_id in (#{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
elsif@is_comprehensive_evaluation==1
teachers=searchTeacherAndAssistant@course
@comprehensive_evaluation=[]
teachers.eachdo|teacher|
temp=@homework.journals_for_messages.where("is_comprehensive_evaluation = 1 and user_id = #{teacher.user_id}").order("created_on DESC").first
@teacher_stars=@stars_reates.where("rater_id in (#{teachers})")#老师评分列表
@student_stars=@stars_reates.where("rater_id not in (#{teachers})")#学生评分列表
jours=@homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC")#jours留言 is null条件用以兼容历史数据
@anonymous_comments=@homework.journals_for_messages.where("is_comprehensive_evaluation = 2 and user_id in (#{annymous_users})").order("created_on DESC")
end
@m_score=params[:stars_value].to_i
elsif@cur_is_comprehensive_evaluation=="1"
@comprehensive_evaluation=[]
teachers.eachdo|teacher|
temp=@homework.journals_for_messages.where("is_comprehensive_evaluation = 1 and user_id = #{teacher.user_id}").order("created_on DESC").first
@teacher_stars=@stars_reates.where("rater_id in (#{teachers})")#老师评分列表
@student_stars=@stars_reates.where("rater_id not in (#{teachers})")#学生评分列表
jours=@homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC")#jours留言 is null条件用以兼容历史数据
(SELECTAVG(stars)FROMseems_rateable_ratesWHERErateable_type='HomeworkAttach'ANDrateable_id=homework_attaches.idANDrater_idIN(#{teachers_str}) and stars IS NOT NULL) AS t_score,
(SELECTAVG(stars)FROMseems_rateable_ratesWHERErateable_type='HomeworkAttach'ANDrateable_id=homework_attaches.idANDrater_idNOTIN(#{teachers_str})) AS s_score
(SELECTAVG(stars)FROMseems_rateable_ratesWHERErateable_type='HomeworkAttach'ANDrateable_id=homework_attaches.idANDrater_idIN(#{teachers}) and stars IS NOT NULL) AS t_score,
(SELECTAVG(stars)FROMseems_rateable_ratesWHERErateable_type='HomeworkAttach'ANDrateable_id=homework_attaches.idANDrater_idNOTIN(#{teachers})) AS s_score
(SELECTAVG(stars)FROMseems_rateable_ratesWHERErateable_type='HomeworkAttach'ANDrateable_id=homework_attaches.idANDrater_idin(#{teachers_str})) AS t_score,
(SELECTAVG(stars)FROMseems_rateable_ratesWHERErateable_type='HomeworkAttach'ANDrateable_id=homework_attaches.idANDrater_idnotin(#{teachers_str})) AS s_score
(SELECTAVG(stars)FROMseems_rateable_ratesWHERErateable_type='HomeworkAttach'ANDrateable_id=homework_attaches.idANDrater_idin(#{teachers})) AS t_score,
(SELECTAVG(stars)FROMseems_rateable_ratesWHERErateable_type='HomeworkAttach'ANDrateable_id=homework_attaches.idANDrater_idnotin(#{teachers})) AS s_score
(SELECTAVG(stars)FROMseems_rateable_ratesWHERErateable_type='HomeworkAttach'ANDrateable_id=homework_attaches.idANDrater_idIN(#{teachers_str})) AS t_score,
(SELECTAVG(stars)FROMseems_rateable_ratesWHERErateable_type='HomeworkAttach'ANDrateable_id=homework_attaches.idANDrater_idNOTIN(#{teachers_str})) AS s_score,
(SELECTAVG(stars)FROMseems_rateable_ratesWHERErateable_type='HomeworkAttach'ANDrateable_id=homework_attaches.idANDrater_idIN(#{teachers})) AS t_score,
(SELECTAVG(stars)FROMseems_rateable_ratesWHERErateable_type='HomeworkAttach'ANDrateable_id=homework_attaches.idANDrater_idNOTIN(#{teachers})) AS s_score,
(SELECTstarsFROMseems_rateable_ratesWHERErateable_type='HomeworkAttach'ANDrateable_id=homework_attaches.idANDrater_id=#{User.current.id}) AS m_score
FROMhomework_attaches
WHEREhomework_attaches.id=#{@homework.id}").first
else#其他的不用管
end
respond_todo|format|
format.js
end
@ -622,5 +568,10 @@ class HomeworkAttachController < ApplicationController