diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb index f4a072a4b..7e23443d2 100644 --- a/app/controllers/student_works_controller.rb +++ b/app/controllers/student_works_controller.rb @@ -429,10 +429,17 @@ class StudentWorksController < ApplicationController def shixun_work_report @user = @work.user @shixun = @homework.shixuns.take - @games = @work.myshixun.games.includes(:challenge, :game_codes, :outputs) if @work.myshixun + # 提示: 这里如果includes outputs表的话: sum(:evaluate_count)会出现错误 + @games = @work.myshixun.games if @work.myshixun # 用户最大评测次数 - @user_evaluate_count = @games.sum(:evaluate_count) if @games + if @games + @user_evaluate_count = @games.sum(:evaluate_count) + @games = @games.includes(:challenge, :game_codes, :outputs) + else + @user_evaluate_count = 0 + end + # 图形效率图的数据 @echart_data = student_efficiency(@homework, @work) end diff --git a/app/models/game.rb b/app/models/game.rb index c08884afb..ba6664d5c 100644 --- a/app/models/game.rb +++ b/app/models/game.rb @@ -115,9 +115,9 @@ class Game < ApplicationRecord end # 评测次数 - def evaluate_count - self.outputs.pluck(:query_index).first - end + #def evaluate_count + # self.outputs.pluck(:query_index).first + #end # 用户关卡得分 def get_user_final_score