diff --git a/app/controllers/ec_years_controller.rb b/app/controllers/ec_years_controller.rb index 7a847c7b..12ad6212 100644 --- a/app/controllers/ec_years_controller.rb +++ b/app/controllers/ec_years_controller.rb @@ -397,6 +397,23 @@ class EcYearsController < ApplicationController new_eto.attributes = pre_eto.attributes.dup.except("id", "ec_year_id") new_eto.ec_year_id = ec_year.id new_eto.save! + + # 复制 "毕业要去 vs 培养目标" + pre_ervsos = EcRequirementVsObjective.where(:ec_training_objective_id => pre_eto.id) + pre_ervsos.each do |ervso| + new_ervso = EcRequirementVsObjective.new + new_ervso.attributes = ervso.attributes.dup.except("id", "ec_training_objective_id", "ec_graduation_requirement_id") + new_ervso.ec_training_objective_id = new_eto.id + new_egr_id = -1 + egr_record.each do |egr_id| + if egr_id[0] == ervso.id + new_egr_id = egr_id[1] + end + end + raise("找不对应的毕业要求") if new_egr_id == -1 + new_ervso.ec_graduation_requirement_id = new_egr_id + end + # 复制 "培养目标分项" pre_eto.ec_training_subitems.try(:each) do |pre_ets| new_ets = EcTrainingSubitem.new diff --git a/app/models/user.rb b/app/models/user.rb index dea1b72d..8f7f49b0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -245,6 +245,8 @@ class User < Principal has_many :ec_major_schools, :through => :ec_major_school_users has_many :ec_major_school_users, :dependent => :destroy + has_many :ec_course_users + ##### scope :logged, lambda { where("#{User.table_name}.status <> #{STATUS_ANONYMOUS}") } @@ -344,6 +346,14 @@ class User < Principal end end } + + # 工程认证的学校 + def ec_school + school_id = self.ec_school_users.pluck(:school_id).first || + self.ec_major_schools.pluck(:school_id).first || + (self.ec_course_users.first && self.ec_course_users.first.try(:ec_course).try(:ec_year).try(:ec_major_school).try(:school_id)) + end + def challenge_tags games = self.games.where(:id => self.experiences.map(&:container_id), :status => 2) challenge_tags = ChallengeTag.where(:challenge_id => games.map(&:challenge_id)).where("name != ''") diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index ee3a571d..b4e2999d 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -18,9 +18,10 @@