fix copy ec year issue

pre_develop
p31729568 6 years ago
parent fb353c39ab
commit 38fe8a2f9e

@ -226,6 +226,8 @@
to_relate.ec_course_target_id = course_target_map[relate.ec_course_target_id]
to_relate.ec_course_evaluation_subitem_id = course_target_map[relate.ec_course_evaluation_subitem_id]
to_relate.save!
achievement_evaluation_relates_map[relate.id] = to_relate.id
end
end
@ -258,14 +260,16 @@
end
def copy_year_students!
students = from_year.ec_year_students.includes(:ec_student_achievements)
students = from_year.ec_year_students.includes(:ec_student_achievements, :ec_course_student_scores, :ec_student_score_targets)
students.each do |student|
to_student = to_year.ec_year_students.new
to_student.attributes = student.attributes.except('id', 'ec_year_id', 'created_at', 'updated')
to_student.attributes = student.attributes.except('id', 'ec_year_id', 'created_at', 'updated_at')
to_student.save!
copy_student_achievements!(student, to_student)
copy_course_student_scores!(student, to_student)
copy_student_score_targets!(student, to_student)
end
end
@ -280,6 +284,31 @@
end
end
def copy_course_student_scores!(student, to_student)
student.ec_course_student_scores.each do |score|
to_score = to_student.ec_course_student_scores.new
to_score.attributes = score.attributes.except('id', 'ec_year_student_id', 'ec_course_id', 'created_at', 'updated_at')
to_score.ec_course_id = course_map[score.ec_course_id]
to_score.save!
course_student_score_map[score.id] = to_score.id
end
end
def copy_student_score_targets!(student, to_student)
student.ec_student_score_targets.each do |target|
to_target = to_student.ec_student_score_targets.new
to_target.attributes = target.attributes.except('id', 'ec_course_id', 'ec_course_student_score_id',
'ec_course_target_id', 'ec_year_student_id', 'eaer_id',
'created_at', 'updated_at')
to_target.ec_course_id = course_map[target.ec_course_id]
to_target.ec_course_student_score_id = course_student_score_map[target.ec_course_student_score_id]
to_target.ec_course_target_id = course_target_map[target.ec_course_target_id]
to_target.eaer_id = achievement_evaluation_relates_map[target.eaer_id]
to_target.save!
end
end
def graduation_requirement_map
@_graduation_requirement_map ||= {}
end
@ -300,7 +329,15 @@
@_course_evaluation_subitem_map ||= {}
end
def achievement_evaluation_relates_map
@_achievement_evaluation_relates_map ||= {}
end
def course_target_map
@_course_target_map ||= {}
end
def course_student_score_map
@_course_student_score_map ||= {}
end
end
Loading…
Cancel
Save