json.homework_common_id @homework.id
json.category @homework.category_info
json.course_name @course.name
json.work_id @work.id
json.work_efficiency @homework.work_efficiency
json.has_commit @work.myshixun.present?
json.work_status @work.work_status
if @shixun
  json.shixun_name @shixun.name
# 总体评价
  json.overall_appraisal @work.overall_appraisal
  json.myself_experience @work.myshixun.try(:total_score).to_i
  json.total_experience @shixun.all_score
  json.work_score number_with_precision @work.work_score.to_f.round(2), precision: 1
  json.all_work_score number_with_precision @homework.total_score, precision: 1
  json.time_consuming @work.myshixun_consume
  json.evaluate_count @user_evaluate_count.to_i
  if @homework.work_efficiency
    json.eff_score_full number_with_precision @homework.eff_score, precision: 1
    json.eff_score number_with_precision @work.eff_score.to_f.round(2), precision: 1
    json.challenge_score_full number_with_precision (@homework.total_score - @homework.eff_score), precision: 1
    json.challenge_score number_with_precision @work.final_score.to_f.round(2), precision: 1
  end

# 阶段成绩
  json.stage_list do
    json.array! @challenges do |challenge|
      json.name challenge.subject
      game = @games.select{|game| game.challenge_id == challenge.id}.first if @games
      json.is_delay game ? student_work_is_delay?(@homework, game) : false
      json.open_time myshixun_open_time game
      json.evaluate_count game ? game&.evaluate_count : 0
      json.finished_time game ? finished_time(game.end_time) : "--"
      json.time_consuming time_consuming game
      json.myself_experience game ? game&.final_score : 0
      json.experience challenge.all_score
      json.complete_status game ? game_status(game, @homework) : 0
      json.challenge_id challenge.id
      challenge_score = @homework.challenge_score challenge.id
      json.game_score_full challenge_score
      json.game_score @work.work_challenge_score game, challenge_score, challenge.id
      challenge_comment = @work.shixun_work_comments.find_by(challenge_id: challenge.id)
      json.challenge_comment challenge_comment&.comment
      json.challenge_comment_hidden @user_course_identity < Course::STUDENT ? challenge_comment&.hidden_comment : nil
      json.comment_id challenge_comment&.id
      json.view_answer game ? game.view_answer : false
    end
  end

# 个人总结
  json.work_description @work.description

# 用户信息
  json.user_id @user.id
  json.username @user.real_name
  json.student_id @user.student_id
  json.image_url url_to_avatar(@user)
  json.complete_count @work.myshixun&.passed_count.to_i
  json.challenges_count @shixun.challenges_count
  json.efficiency @homework.work_efficiency ? number_with_precision(@work.efficiency, precision: 2) : nil
  json.max_efficiency @homework.work_efficiency ? number_with_precision(@homework.max_efficiency, precision: 2) : nil
  json.passed_time @work.myshixun&.passed_time

  # 评阅信息
  json.work_comment @comment&.comment
  json.work_comment_hidden @user_course_identity < Course::STUDENT ? @comment&.hidden_comment : nil
  json.comment_id @comment&.id

# 图形统计
# 1： 效率
  json.echart_data @echart_data

# 实训详情
  json.shixun_detail do
    json.array! @games do |game|
      json.game_identifier game.identifier
      json.st game.challenge.st
      json.position game.challenge.position
      json.path game.challenge.path
      json.subject game.challenge.subject
      json.outputs game.distinct_query_index do |output|
        json.position output.query_index
        json.output_detail output_detail game, output
      end
      json.passed_code game.try(:lastest_code)
    end
  end
end


