|
|
|
@ -1354,7 +1354,7 @@ class HomeworkCommonsController < ApplicationController
|
|
|
|
|
if results.status == 0
|
|
|
|
|
code_info = results.code_info
|
|
|
|
|
homework_challenge_settings = @homework.homework_challenge_settings
|
|
|
|
|
@challenges = @shixun.challenges.where(id: homework_challenge_settings.pluck(:challenge_id), st: 0).includes(:games)
|
|
|
|
|
@challenges = @shixun.challenges.where(id: homework_challenge_settings.pluck(:challenge_id), st: 0)
|
|
|
|
|
@challenges =
|
|
|
|
|
@challenges.map do |challenge|
|
|
|
|
|
code_rate = 0
|
|
|
|
@ -1368,24 +1368,8 @@ class HomeworkCommonsController < ApplicationController
|
|
|
|
|
game = challenge.games.find_by(user_id: @user.id)
|
|
|
|
|
end_time = game.end_time
|
|
|
|
|
# 用户关卡的得分
|
|
|
|
|
all_score = homework_challenge_settings.find_by(challenge_id: challenge.id).try(:score)
|
|
|
|
|
final_score =
|
|
|
|
|
if @student_work.challenge_work_scores.where(challenge_id: challenge.id).last.present?
|
|
|
|
|
@student_work.challenge_work_scores.where(:challenge_id => game.challenge_id).last.score
|
|
|
|
|
else
|
|
|
|
|
if game.status == 2 && ((game.end_time && game.end_time < @homework.end_time) ||
|
|
|
|
|
(@homework.allow_late && (@course.end_date.nil? ||
|
|
|
|
|
(game.end_time && game.end_time < @course.end_date.end_of_day))))
|
|
|
|
|
answer_open_evaluation = @homework.homework_detail_manual.answer_open_evaluation
|
|
|
|
|
# 设置了查看答案也获得满分的话就取总分。否则取关卡的百分比分支
|
|
|
|
|
if answer_open_evaluation.present?
|
|
|
|
|
all_score
|
|
|
|
|
else
|
|
|
|
|
# 关卡的百分比 * 作业设置的分数 = 总得分
|
|
|
|
|
((game.final_score) / challenge.score) * all_score
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
all_score = homework_challenge_settings.find_by(challenge_id: challenge.id).try(:score).to_f
|
|
|
|
|
final_score = @student_work.work_challenge_score game, all_score
|
|
|
|
|
# 抄袭用户
|
|
|
|
|
copy_user = User.find_by_id(game_codes[0].target_user_id)
|
|
|
|
|
copy_end_time = copy_user.games.find_by(challenge_id: challenge.id).try(:end_time) if copy_user.present?
|
|
|
|
|