查重详情页的接口调整

dev_forum
cxt 5 years ago
parent f807675b99
commit ddf679dd36

@ -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?

@ -1,21 +1,5 @@
module HomeworkCommonsHelper
# 实训作品的单个关卡得分
def work_challenge_score student_work, game, score, homework
result = 0
adjust_score = student_work.challenge_work_scores.where(challenge_id: game.challenge_id).last
if adjust_score.present?
result = adjust_score.score
else
setting = homework.homework_group_setting student_work.user_id
if game.status == 2 && ((game.end_time && game.end_time < setting.end_time) || (homework.allow_late && game.end_time && game.end_time < homework.late_time))
answer_open_evaluation = homework.homework_detail_manual.answer_open_evaluation
result = answer_open_evaluation ? score : (game.final_score > 0 ? game.real_score(score) : 0)
end
end
result
end
# 未发布时非老师角色不能访问,发布后非课堂成员不能访问未公开的作业,学生需要考虑分班设置的作业是否已发布
def homework_publish
if (@user_course_identity >= Course::STUDENT && (@homework.publish_time.nil? || @homework.publish_time > Time.now)) ||

@ -193,4 +193,19 @@ class StudentWork < ApplicationRecord
def scored?
student_works_scores.where.not(reviewer_role: 3).exists?
end
def work_challenge_score game, score
game_score = 0
adjust_score = challenge_work_scores.where(challenge_id: game.challenge_id).last
if adjust_score.present?
game_score = adjust_score.score
else
setting = homework.homework_group_setting user_id
if game.status == 2 && ((game.end_time && game.end_time < setting.end_time) || (homework.allow_late && game.end_time && game.end_time < homework.late_time))
answer_open_evaluation = homework.homework_detail_manual.answer_open_evaluation
game_score = answer_open_evaluation ? score : (game.final_score > 0 ? game.real_score(score) : 0)
end
end
game_score
end
end

@ -8,12 +8,19 @@ json.user_id @user.id
json.user_login @user.login
json.work_score @student_work.work_score
if @student_work.ultimate_score
json.adjust_score @student_work.work_score < 0 ? 0 : number_with_precision(@student_work.work_score, precision: 1)
else
json.final_score @student_work.final_score
json.late_penalty @student_work.late_penalty
json.score @student_work.work_score < 0 ? 0 : number_with_precision(@student_work.work_score, precision: 1)
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, precision: 1
json.challenge_score_full number_with_precision (100 - @homework.eff_score), precision: 1
json.challenge_score number_with_precision @work.final_score, precision: 1
end
end
json.challenge_list do

@ -13,9 +13,9 @@ if @shixun
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 @work.eff_score
json.eff_score number_with_precision @work.eff_score, precision: 1
json.challenge_score_full number_with_precision (100 - @homework.eff_score), precision: 1
json.challenge_score @work.final_score
json.challenge_score number_with_precision @work.final_score, precision: 1
end
# 阶段成绩
@ -33,7 +33,7 @@ if @shixun
json.challenge_id game.challenge_id
challenge_score = @homework.challenge_score game.challenge_id
json.game_score_full challenge_score
json.game_score work_challenge_score @work, game, challenge_score, @homework
json.game_score @work.work_challenge_score game, challenge_score
end
end

Loading…
Cancel
Save