实训报告页面的调分

dev_forum
cxt 5 years ago
parent 4f3a696ea7
commit cade029fc1

@ -1,5 +1,21 @@
module HomeworkCommonsHelper 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 def homework_publish
if (@user_course_identity >= Course::STUDENT && (@homework.publish_time.nil? || @homework.publish_time > Time.now)) || if (@user_course_identity >= Course::STUDENT && (@homework.publish_time.nil? || @homework.publish_time > Time.now)) ||

@ -260,4 +260,8 @@ class HomeworkCommon < ApplicationRecord
self.homework_group_settings.where("end_time is not null").pluck(:end_time).max self.homework_group_settings.where("end_time is not null").pluck(:end_time).max
end end
def challenge_score challenge_id
homework_challenge_settings.find_by(challenge_id: challenge_id)&.score.to_f
end
end end

@ -8,9 +8,15 @@ if @shixun
json.myself_experience @work.myshixun.try(:total_score) json.myself_experience @work.myshixun.try(:total_score)
json.total_experience @shixun.all_score json.total_experience @shixun.all_score
json.work_score number_with_precision @work.work_score, precision: 1 json.work_score number_with_precision @work.work_score, precision: 1
json.all_work_score 100 json.all_work_score number_with_precision 100, precision: 1
json.time_consuming @work.myshixun_consume json.time_consuming @work.myshixun_consume
json.evaluate_count @user_evaluate_count.to_i 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.challenge_score_full number_with_precision (100 - @homework.eff_score), precision: 1
json.challenge_score @work.final_score
end
# 阶段成绩 # 阶段成绩
json.stage_list do json.stage_list do
@ -25,6 +31,9 @@ if @shixun
json.experience game.challenge.all_score json.experience game.challenge.all_score
json.complete_status game_status(game, @homework) json.complete_status game_status(game, @homework)
json.challenge_id game.challenge_id 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
end end
end end

Loading…
Cancel
Save