|
|
|
@ -631,16 +631,35 @@ class StudentWorksController < ApplicationController
|
|
|
|
|
|
|
|
|
|
# 查重作品调分
|
|
|
|
|
def adjust_review_score
|
|
|
|
|
if params[:score].nil? || params[:challenge_id].nil? || params[:code_rate].nil? || params[:copy_user_id].nil?
|
|
|
|
|
tip_exception("缺少type参数") if params[:type].blank? || ["review", "report"].include?(params[:type])
|
|
|
|
|
if params[:type] == "review" && (params[:score].nil? || params[:challenge_id].nil? || params[:code_rate].nil? || params[:copy_user_id].nil?)
|
|
|
|
|
tip_exception("参数错误,score和challenge_id和code_rate和copy_user_id不能为空")
|
|
|
|
|
elsif params[:type] == "report" && (params[:score].nil? || params[:challenge_id].nil?)
|
|
|
|
|
tip_exception("参数错误,score和challenge_id")
|
|
|
|
|
end
|
|
|
|
|
challenge_setting = @homework.homework_challenge_settings.find_by(challenge_id: params[:challenge_id])
|
|
|
|
|
challenge = challenge_setting&.challenge
|
|
|
|
|
tip_exception("不能小于零") if params[:score] < 0
|
|
|
|
|
tip_exception("不能大于关卡分值:#{challenge_setting.score}分") if challenge_setting.score < params[:score]
|
|
|
|
|
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
begin
|
|
|
|
|
if params[:type] == "review"
|
|
|
|
|
copy_user = User.find params[:copy_user_id]
|
|
|
|
|
comment = "代码查重结果显示与#{copy_user.try(:show_real_name)}的代码相似度#{params[:code_rate]}%"
|
|
|
|
|
@work.challenge_work_scores.create(challenge_id: params[:challenge_id], user_id: current_user.id, score: params[:score],
|
|
|
|
|
else
|
|
|
|
|
comment = "根据实训报告中最终提交的代码调整第#{challenge.position}关分数"
|
|
|
|
|
end
|
|
|
|
|
challenge_score = @work.challenge_work_scores.create(challenge_id: params[:challenge_id], user_id: current_user.id, score: params[:score],
|
|
|
|
|
comment: comment)
|
|
|
|
|
HomeworksService.new.set_shixun_final_score(@work)
|
|
|
|
|
@work_score = @homework.student_works.find_by(id: @work.id).try(:work_score)
|
|
|
|
|
|
|
|
|
|
challenge_score.create_tiding current_user.id
|
|
|
|
|
HomeworksService.new.update_myshixun_work_score @work, @work&.myshixun, @work&.myshixun&.games, @homework, @homework.homework_challenge_settings
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
uid_logger(e.message)
|
|
|
|
|
tip_exception(e.message)
|
|
|
|
|
raise ActiveRecord::Rollback
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|