Merge branch 'develop' of https://bdgit.educoder.net/Hjqreturn/pgfqe6ch8 into develop
commit
0fc5fadcb9
@ -0,0 +1,8 @@
|
|||||||
|
class AddIndexToHomework < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_index :homework_detail_manuals, :homework_common_id
|
||||||
|
add_index :homework_commons_shixuns, :homework_common_id
|
||||||
|
add_index :student_works_evaluation_distributions, :student_work_id
|
||||||
|
add_index :tidings, :container_id
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,30 @@
|
|||||||
|
class MigrationShixunStudentWork < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
works = StudentWork.where("myshixun_id != 0 and myshixun_id not in (select id from myshixuns) and (work_score is null or work_score = 0)")
|
||||||
|
works.update_all(:myshixun_id => 0, :work_status => 0, :work_score => nil, :final_score => nil,
|
||||||
|
:cost_time => 0, :update_time => nil, :compelete_status => 0, :commit_time => nil)
|
||||||
|
|
||||||
|
shixun_works = StudentWork.where("myshixun_id != 0 and myshixun_id not in (select id from myshixuns) and work_score > 0")
|
||||||
|
shixun_works.each do |work|
|
||||||
|
if work.homework_common && work.homework_common.homework_commons_shixuns.try(:shixun)
|
||||||
|
shixun = work.homework_common.homework_commons_shixuns.try(:shixun)
|
||||||
|
|
||||||
|
# 创建新的myshixun和games
|
||||||
|
myshixun = nil
|
||||||
|
|
||||||
|
work_score = work.final_score
|
||||||
|
work.homework_common.homework_challenge_settings.each do |setting|
|
||||||
|
if work_score > 1
|
||||||
|
myshixun.games.where(:challenge_id => setting.challenge_id).first.update_attributes(:status => 2)
|
||||||
|
work_score -= setting.score
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
work.update_column("myshixun_id", myshixun.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in new issue