|
|
@ -6817,68 +6817,70 @@ end
|
|
|
|
|
|
|
|
|
|
|
|
# 用户评测时更新实训作业成绩
|
|
|
|
# 用户评测时更新实训作业成绩
|
|
|
|
def update_myshixun_work_score myshixun
|
|
|
|
def update_myshixun_work_score myshixun
|
|
|
|
student_works = myshixun.student_works
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
#logger.info("#############student_works_count: #{student_works.count}")
|
|
|
|
student_works = myshixun.student_works
|
|
|
|
if student_works.count > 0
|
|
|
|
#logger.info("#############student_works_count: #{student_works.count}")
|
|
|
|
student_works.each do |work|
|
|
|
|
if student_works.count > 0
|
|
|
|
homework = work.homework_common
|
|
|
|
student_works.each do |work|
|
|
|
|
member = Member.find_by_sql("select course_group_id from members where course_id = #{homework.course_id} and user_id = #{User.current.id}").first
|
|
|
|
homework = work.homework_common
|
|
|
|
#logger.info("#############member_course_group_id: #{member.try(:course_group_id)}")
|
|
|
|
member = Member.find_by_sql("select course_group_id from members where course_id = #{homework.course_id} and user_id = #{User.current.id}").first
|
|
|
|
setting_time = homework_group_setting homework, member.try(:course_group_id)
|
|
|
|
#logger.info("#############member_course_group_id: #{member.try(:course_group_id)}")
|
|
|
|
if setting_time.end_time.present? && (setting_time.end_time > Time.now || (homework.allow_late && !homework.course.is_end))
|
|
|
|
setting_time = homework_group_setting homework, member.try(:course_group_id)
|
|
|
|
#logger.info("#############setting_time: #{setting_time.end_time}")
|
|
|
|
if setting_time.end_time.present? && (setting_time.end_time > Time.now || (homework.allow_late && !homework.course.is_end))
|
|
|
|
|
|
|
|
#logger.info("#############setting_time: #{setting_time.end_time}")
|
|
|
|
user_total_score = 0
|
|
|
|
|
|
|
|
pass_consume_time = 0
|
|
|
|
user_total_score = 0
|
|
|
|
final_score = 0
|
|
|
|
pass_consume_time = 0
|
|
|
|
homework.homework_challenge_settings.each do |setting|
|
|
|
|
final_score = 0
|
|
|
|
game = myshixun.games.where(:challenge_id => setting.challenge_id, :status => 2).first
|
|
|
|
homework.homework_challenge_settings.each do |setting|
|
|
|
|
unless game.nil?
|
|
|
|
game = myshixun.games.where(:challenge_id => setting.challenge_id, :status => 2).first
|
|
|
|
pass_consume_time += (game.cost_time / 60.0).to_f
|
|
|
|
unless game.nil?
|
|
|
|
user_total_score += game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i
|
|
|
|
pass_consume_time += (game.cost_time / 60.0).to_f
|
|
|
|
adjust_score = work.challenge_work_scores.where(:challenge_id => setting.challenge_id).last
|
|
|
|
user_total_score += game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i
|
|
|
|
final_score += adjust_score.present? ? adjust_score.score : (homework.homework_detail_manual.answer_open_evaluation ? setting.score : (game.final_score >= 0 ? setting.score : 0))
|
|
|
|
adjust_score = work.challenge_work_scores.where(:challenge_id => setting.challenge_id).last
|
|
|
|
|
|
|
|
final_score += adjust_score.present? ? adjust_score.score : (homework.homework_detail_manual.answer_open_evaluation ? setting.score : (game.final_score >= 0 ? setting.score : 0))
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
if work.work_status == 0
|
|
|
|
|
|
|
|
is_complete = myshixun.is_complete? && (myshixun.done_time < setting_time.end_time)
|
|
|
|
|
|
|
|
work.work_status = setting_time.end_time > Time.now ? 1 : (is_complete ? 1 : 2)
|
|
|
|
|
|
|
|
work.late_penalty = setting_time.end_time > Time.now ? 0 : (is_complete ? 0 : homework.late_penalty)
|
|
|
|
|
|
|
|
work.commit_time = myshixun.created_at > setting_time.publish_time ? setting_time.publish_time : myshixun.created_at
|
|
|
|
|
|
|
|
work.myshixun_id = myshixun.id
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if work.work_status == 0
|
|
|
|
|
|
|
|
is_complete = myshixun.is_complete? && (myshixun.done_time < setting_time.end_time)
|
|
|
|
|
|
|
|
work.work_status = setting_time.end_time > Time.now ? 1 : (is_complete ? 1 : 2)
|
|
|
|
|
|
|
|
work.late_penalty = setting_time.end_time > Time.now ? 0 : (is_complete ? 0 : homework.late_penalty)
|
|
|
|
|
|
|
|
work.commit_time = myshixun.created_at > setting_time.publish_time ? setting_time.publish_time : myshixun.created_at
|
|
|
|
|
|
|
|
work.myshixun_id = myshixun.id
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
efficiency = (pass_consume_time == 0 ? 0 : Math.log((user_total_score / pass_consume_time.to_f) + 1.0))
|
|
|
|
efficiency = (pass_consume_time == 0 ? 0 : Math.log((user_total_score / pass_consume_time.to_f) + 1.0))
|
|
|
|
work.efficiency = format("%.2f", efficiency)
|
|
|
|
work.efficiency = format("%.2f", efficiency)
|
|
|
|
|
|
|
|
|
|
|
|
games = myshixun.games.where(:challenge_id => homework.homework_challenge_settings.map(&:challenge_id))
|
|
|
|
games = myshixun.games.where(:challenge_id => homework.homework_challenge_settings.map(&:challenge_id))
|
|
|
|
myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil
|
|
|
|
myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil
|
|
|
|
if myshixun_endtime.present?
|
|
|
|
if myshixun_endtime.present?
|
|
|
|
min_efficiency_changed = min_efficiency_changed.present? ? min_efficiency_changed : false
|
|
|
|
min_efficiency_changed = min_efficiency_changed.present? ? min_efficiency_changed : false
|
|
|
|
work.compelete_status = 1
|
|
|
|
work.compelete_status = 1
|
|
|
|
work.cost_time = myshixun_endtime.to_i - setting_time.publish_time.to_i
|
|
|
|
work.cost_time = myshixun_endtime.to_i - setting_time.publish_time.to_i
|
|
|
|
|
|
|
|
|
|
|
|
# 计算作品的效率分(已完成才计算)
|
|
|
|
# 计算作品的效率分(已完成才计算)
|
|
|
|
if homework.work_efficiency
|
|
|
|
if homework.work_efficiency
|
|
|
|
# 如果作业的最大效率值有变更则更新所有作品的效率分
|
|
|
|
# 如果作业的最大效率值有变更则更新所有作品的效率分
|
|
|
|
if homework.max_efficiency < work.efficiency
|
|
|
|
if homework.max_efficiency < work.efficiency
|
|
|
|
homework.max_efficiency = work.efficiency
|
|
|
|
homework.max_efficiency = work.efficiency
|
|
|
|
homework.update_column("max_efficiency", homework.max_efficiency)
|
|
|
|
homework.update_column("max_efficiency", homework.max_efficiency)
|
|
|
|
update_student_eff_score homework
|
|
|
|
update_student_eff_score homework
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
eff_score = homework.max_efficiency == 0 ? 0 : work.efficiency / homework.max_efficiency * homework.eff_score
|
|
|
|
|
|
|
|
work.eff_score = format("%.2f", eff_score)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
eff_score = homework.max_efficiency == 0 ? 0 : work.efficiency / homework.max_efficiency * homework.eff_score
|
|
|
|
|
|
|
|
work.eff_score = format("%.2f", eff_score)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
work.update_time = Time.now
|
|
|
|
work.update_time = Time.now
|
|
|
|
|
|
|
|
|
|
|
|
# 为迁移的数据做特殊处理, 若分数小于当前通关分数则不更新
|
|
|
|
# 为迁移的数据做特殊处理, 若分数小于当前通关分数则不更新
|
|
|
|
work.final_score = final_score if work.final_score.nil? || final_score > work.final_score
|
|
|
|
work.final_score = final_score if work.final_score.nil? || final_score > work.final_score
|
|
|
|
score = work.final_score + work.eff_score - work.late_penalty
|
|
|
|
score = work.final_score + work.eff_score - work.late_penalty
|
|
|
|
work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) unless work.ultimate_score
|
|
|
|
work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) unless work.ultimate_score
|
|
|
|
#logger.info("#############work_score: #{score}")
|
|
|
|
#logger.info("#############work_score: #{score}")
|
|
|
|
work.save!
|
|
|
|
work.save!
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|