|
|
|
@ -464,6 +464,7 @@ class StudentWorksController < ApplicationController
|
|
|
|
|
@shixun = @homework.shixuns.take
|
|
|
|
|
# 提示: 这里如果includes outputs表的话: sum(:evaluate_count)会出现错误
|
|
|
|
|
@games = @work.myshixun.games.joins(:challenge).reorder("challenges.position asc") if @work.myshixun
|
|
|
|
|
@challenges = @shixun.challenges if @shixun
|
|
|
|
|
@comment = @work.shixun_work_comments.find_by(challenge_id: 0)
|
|
|
|
|
|
|
|
|
|
# 用户最大评测次数
|
|
|
|
@ -517,6 +518,7 @@ class StudentWorksController < ApplicationController
|
|
|
|
|
@user = @work.user
|
|
|
|
|
@shixun = @homework.shixuns.take
|
|
|
|
|
@games = @work.myshixun.games.includes(:challenge, :game_codes, :outputs) if @work.myshixun
|
|
|
|
|
@challenges = @shixun.challenges if @shixun
|
|
|
|
|
|
|
|
|
|
# 用户最大评测次数
|
|
|
|
|
@user_evaluate_count = @games.pluck(:evaluate_count).sum if @games
|
|
|
|
@ -727,7 +729,11 @@ class StudentWorksController < ApplicationController
|
|
|
|
|
challenge_score = @work.challenge_work_scores.create(challenge_id: params[:challenge_id], user_id: current_user.id, score: params[:score],
|
|
|
|
|
comment: comment)
|
|
|
|
|
challenge_score.create_tiding current_user.id
|
|
|
|
|
HomeworksService.new.update_myshixun_work_score @work, @work&.myshixun, @work&.myshixun&.games, @homework, @homework.homework_challenge_settings
|
|
|
|
|
if @work.work_status != 0 && @work.myshixun
|
|
|
|
|
HomeworksService.new.update_myshixun_work_score @work, @work.myshixun, @work.myshixun&.games, @homework, @homework.homework_challenge_settings
|
|
|
|
|
else
|
|
|
|
|
update_none_commit_work @work, @homework
|
|
|
|
|
end
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
uid_logger(e.message)
|
|
|
|
|
tip_exception(e.message)
|
|
|
|
@ -855,4 +861,20 @@ class StudentWorksController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def update_none_commit_work work, homework
|
|
|
|
|
if work.work_status == 0
|
|
|
|
|
work.work_status = 1
|
|
|
|
|
work.commit_time = homework.end_time
|
|
|
|
|
work.update_time = Time.now
|
|
|
|
|
end
|
|
|
|
|
final_score = 0
|
|
|
|
|
homework.homework_challenge_settings.each do |cha_setting|
|
|
|
|
|
adjust_score = work.challenge_work_scores.select{|work_score| work_score.challenge_id == cha_setting.challenge_id}.last
|
|
|
|
|
final_score += adjust_score.score if adjust_score.present?
|
|
|
|
|
end
|
|
|
|
|
work.final_score = final_score
|
|
|
|
|
work.work_score = final_score
|
|
|
|
|
work.save!
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|