实训作品列表增加查看答案关卡数

problem_set
cxt 5 years ago
parent e6dec1d215
commit 5e562405b8

@ -83,6 +83,11 @@ class Myshixun < ApplicationRecord
self.games.select{|game| game.status == 2}.size
end
# 查看答案的关卡数
def view_answer_count
self.games.select{|game| game.status == 2 && game.answer_open != 0}.size
end
# 通关时间
def passed_time
self.status == 1 ? self.games.select{|game| game.status == 2}.map(&:end_time).max : "--"

@ -41,6 +41,7 @@ elsif @user_course_identity == Course::STUDENT
json.efficiency work_score_format(@work.efficiency, true, @score_open)
json.eff_score work_score_format(@work.eff_score, true, @score_open)
json.complete_count @work.myshixun.try(:passed_count)
json.view_answer_count @work.myshixun.try(:view_answer_count)
else
json.(@work, :id, :work_status, :update_time, :ultimate_score)
@ -95,6 +96,7 @@ if @homework.homework_type == "practice"
json.cost_time work.myshixun.try(:total_spend_time)
json.complete_count work.myshixun.try(:passed_count)
json.view_answer_count work.myshixun.try(:view_answer_count)
json.user_login work.user.try(:login)
json.user_name work.user.try(:real_name)
json.student_id work.user.try(:student_id)

Loading…
Cancel
Save