#阶段成绩
json.stage_list do
  json.array! games do |game|
    json.position game.challenge.position
    json.name  game.challenge.subject
    json.evaluate_count game.evaluate_count
    json.finished_time finished_time game.end_time
    json.time_consuming time_consuming game
    json.myself_experience game.final_score < 0 ? 0 : game.final_score  #经验值
    json.experience game.challenge.all_score  #经验值
    json.user_score user_score.round(1).to_s  #用户获得的分数
    json.game_score game_score.round(1).to_s #该关卡的总分数
  end
end

# 实训详情
json.shixun_detail do
  json.array! games do |game|
    json.position game.challenge.position
    json.game_identifier game.identifier
    json.path game.challenge.path
    json.st game.challenge.st
    json.name game.challenge.subject
    json.outputs game.distinct_query_index do |output|
      json.position output.query_index
      json.output_detail output_detail game, output
    end

    latest_code = nil
    if shixun_challenge.challenge&.path.present?
      if game.try(:lastest_code).blank?
        cha_path = challenge_path(shixun_challenge.challenge&.path)
        latest_code = git_fle_content(game.myshixun.repo_path,cha_path)
      else
        latest_code = game.try(:lastest_code)
      end
    end

    json.passed_code latest_code
  end
end