diff --git a/app/controllers/ec_major_schools_controller.rb b/app/controllers/ec_major_schools_controller.rb index c47899f6..445ce70f 100644 --- a/app/controllers/ec_major_schools_controller.rb +++ b/app/controllers/ec_major_schools_controller.rb @@ -122,7 +122,7 @@ class EcMajorSchoolsController < ApplicationController requirement_vs_objective_url: "#{requirement_vs_objective_ec_major_school_ec_year_path(@year, :ec_major_school_id => @year.ec_major_school_id)}", requirement_vs_standard: "#{requirement_vs_standard_ec_major_school_ec_year_path(@year, :ec_major_school_id => @year.ec_major_school_id)}", requirement_vs_courses: "#{requirement_vs_courses_ec_major_school_ec_year_path(@year, :ec_major_school_id => @year.ec_major_school_id)}", - students_url: student_lists_ec_major_schools_ec_years_path(@year, ec_major_school_id: @year.ec_major_school_id), + students_url: student_lists_ec_major_school_ec_year_path(@year, ec_major_school_id: @year.ec_major_school_id), go_back_url: ec_major_school_path(major), ec_course_support_setting_url: ec_course_support_setting_url, ec_course_reach_setting_url: ec_course_reach_setting_url, diff --git a/app/services/copy_ec_year_service.rb b/app/services/copy_ec_year_service.rb index 7ad46c5f..31bac9f9 100644 --- a/app/services/copy_ec_year_service.rb +++ b/app/services/copy_ec_year_service.rb @@ -224,8 +224,11 @@ to_relate.attributes = relate.attributes.except('id', 'ec_course_achievement_method_id', 'ec_course_target_id', 'ec_course_evaluation_subitem_id', 'created_at', 'updated_at') 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] + # 可能不存在,所以为 -1 + to_relate.ec_course_evaluation_subitem_id = course_evaluation_subitem_map[relate.ec_course_evaluation_subitem_id] || -1 to_relate.save! + + achievement_evaluation_relates_map[relate.id] = to_relate.id end end @@ -258,14 +261,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 +285,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 +330,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 \ No newline at end of file diff --git a/app/views/common/index.html.erb b/app/views/common/index.html.erb index 82b976cb..5762eefe 100644 --- a/app/views/common/index.html.erb +++ b/app/views/common/index.html.erb @@ -1 +1 @@ -
+
<%= member.user.try(:show_name) %>
++ + <%= member.user.identity == "学生" ? "" : member.user.identity %> +
+ +<%= member.user.try(:show_name) %>
-- - <%= member.user.identity == "学生" ? "" : member.user.identity %> -
- -