diff --git a/app/helpers/student_works_helper.rb b/app/helpers/student_works_helper.rb index 93a1a3f9a..682bfbf81 100644 --- a/app/helpers/student_works_helper.rb +++ b/app/helpers/student_works_helper.rb @@ -41,7 +41,7 @@ module StudentWorksHelper def student_efficiency(homework_common, work) myshixun_ids = homework_common.student_works.pluck(:myshixun_id) - myshixuns = Myshixun.where(id: myshixun_ids).includes(games: [:outputs]) + myshixuns = Myshixun.where(id: myshixun_ids).includes(:games) #student_works_user_id = homework_common.student_works.pluck(:user_id).uniq #shixun = homework_common.shixuns.first #logger.info("#########shixun_id: ###{shixun.id}") @@ -54,13 +54,13 @@ module StudentWorksHelper objects = myshixuns.map do |myshixun| # 评测次数 - evaluate_count = myshixun.games.inject(0) {|sum, g| sum + g.outputs.pluck(:query_index).first.to_i} + evaluate_count = myshixun.games.sum(:evaluate_count) # 获取最大评测次数 max_evaluate_count = (evaluate_count > max_evaluate_count ? evaluate_count : max_evaluate_count) # 通关耗时 pass_consume_time = (myshixun.games.where(status: 2).pluck(:cost_time).sum / 60.0) # 总耗时 - all_time = (myshixun.games.pluck(:cost_time).sum / 60.0) + all_time = (myshixun.games.sum(:cost_time) / 60.0) # 通关得分 user_total_score = myshixun.total_score.to_i # 耗时,保留2位小数,