|
|
@ -382,19 +382,19 @@ class HomeworkAttachController < ApplicationController
|
|
|
|
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)
|
|
|
|
stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count
|
|
|
|
#stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count
|
|
|
|
stars_status = stars_reates.select("stars, count(*) as scount").group("stars")
|
|
|
|
#stars_status = stars_reates.select("stars, count(*) as scount").group("stars")
|
|
|
|
@stars_status_map = Hash.new(0.0)
|
|
|
|
#@stars_status_map = Hash.new(0.0)
|
|
|
|
stars_status.each do |star_status|
|
|
|
|
#stars_status.each do |star_status|
|
|
|
|
percent = (star_status.scount * 1.0/ stars_reates_count) * 100.to_f
|
|
|
|
# percent = (star_status.scount * 1.0/ stars_reates_count) * 100.to_f
|
|
|
|
percent_m = format("%.2f", percent)
|
|
|
|
# percent_m = format("%.2f", percent)
|
|
|
|
@stars_status_map["star#{star_status.stars.to_i}".to_sym] =
|
|
|
|
# @stars_status_map["star#{star_status.stars.to_i}".to_sym] =
|
|
|
|
percent_m.to_s + "%"
|
|
|
|
# percent_m.to_s + "%"
|
|
|
|
end
|
|
|
|
#end
|
|
|
|
#是否已经进行过评价
|
|
|
|
#是否已经进行过评价
|
|
|
|
@has_evaluation = stars_reates.where("rater_id = ?",User.current).count > 0
|
|
|
|
@has_evaluation = stars_reates.where("rater_id = ?",User.current).count > 0
|
|
|
|
#是否开启互评功能
|
|
|
|
#是否开启互评功能
|
|
|
|
@is_evaluation = @homework.bid.is_evaluation == 1 || @homework.bid.is_evaluation == nil
|
|
|
|
#@is_evaluation = @homework.bid.is_evaluation == 1 || @homework.bid.is_evaluation == nil
|
|
|
|
#@limit = 10
|
|
|
|
#@limit = 10
|
|
|
|
#@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")
|
|
|
|