pre_develop
parent
1c051ba24d
commit
dc0cc0beb8
@ -1,19 +1,22 @@
|
||||
class MigrateShixunStudentWorkScore < ActiveRecord::Migration
|
||||
class MigrateShixunStudentWorkScore2 < ActiveRecord::Migration
|
||||
def up
|
||||
homeworks = HomeworkCommon.where(id: [18615, 18614, 18617, 18616, 25901, 25902])
|
||||
homeworks.each do |homework|
|
||||
transaction do
|
||||
challeng_ids = homework.homework_challenge_settings.map(&:challenge_id)
|
||||
homework.student_works.where("work_status > 0").each do |work|
|
||||
myshixun = work.myshixun
|
||||
games = myshixun.games.where(:challenge_id => challeng_ids)
|
||||
myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil
|
||||
if myshixun_endtime.present? && myshixun_endtime < homework.end_time
|
||||
if homework.end_time > Time.now
|
||||
work.work_status = 1
|
||||
work.late_penalty = 0
|
||||
else
|
||||
work.work_status = 2
|
||||
work.late_penalty = homework.late_penalty
|
||||
else
|
||||
myshixun = work.myshixun
|
||||
|
||||
if myshixun.status == 1 && myshixun.try(:done_time) < homework.end_time
|
||||
work.work_status = 1
|
||||
work.late_penalty = 0
|
||||
else
|
||||
work.work_status = 2
|
||||
work.late_penalty = homework.late_penalty
|
||||
end
|
||||
end
|
||||
score = work.final_score.to_f + work.eff_score.to_f - work.late_penalty.to_f
|
||||
work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score
|
Loading…
Reference in new issue