diff --git a/app/controllers/ec_course_achievement_methods_controller.rb b/app/controllers/ec_course_achievement_methods_controller.rb index 39b42de4..ecc74a67 100644 --- a/app/controllers/ec_course_achievement_methods_controller.rb +++ b/app/controllers/ec_course_achievement_methods_controller.rb @@ -2,6 +2,7 @@ class EcCourseAchievementMethodsController < ApplicationController before_filter :find_target, :only => [:edit_course_target, :create_evaluation_methods] skip_before_filter :verify_authenticity_token, :only => [:create_evaluation_methods, :sync_course_data] + before_filter :find_ec_course, :only => [:index] include ApplicationHelper @@ -59,11 +60,9 @@ class EcCourseAchievementMethodsController < ApplicationController ############################################################### def index achievement_list = [] - # 具体工程课程 - ec_course = EcCourse.find params[:ec_course_id] # 课程的所有目标 - targets = ec_course.ec_course_targets + targets = @ec_course.ec_course_targets targets.each do |target| evaluate_data = [] # 评价环节 @@ -95,7 +94,7 @@ class EcCourseAchievementMethodsController < ApplicationController end achievement_list << {target_id: target.id, target_evaluate_data: evaluate_data} end - render :json => {achievement_list: achievement_list} + render :json => {achievement_list: achievement_list, is_manager: @is_manager} end @@ -306,4 +305,13 @@ class EcCourseAchievementMethodsController < ApplicationController @target = EcCourseTarget.find params[:ec_course_target_id] end + def find_ec_course + @ec_course = EcCourse.find(params[:ec_course_id]) + @year = @ec_course.ec_year + @ec_major_school = @year.ec_major_school + @template_major = User.current.admin? || @ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) || + @ec_major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id) + @is_manager = @template_major || @ec_course.ec_course_users.pluck(:user_id).include?(User.current.id) + end + end diff --git a/app/controllers/ec_course_supports_controller.rb b/app/controllers/ec_course_supports_controller.rb index 337c183a..3e64f2db 100644 --- a/app/controllers/ec_course_supports_controller.rb +++ b/app/controllers/ec_course_supports_controller.rb @@ -47,6 +47,8 @@ class EcCourseSupportsController < ApplicationController course_support_data = [] max_support_count = 0 subitems_count = 0 + major_school = @year.ec_major_school + is_manager = User.current.admin? || major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) || major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id) ec_graduation_requirements.each_with_index do |gr, i| logger.info("#############index:#{i}#####_ec_gradiation_reqiorements: #{gr.id}") subitems_count += gr.ec_graduation_subitems.count @@ -74,7 +76,8 @@ class EcCourseSupportsController < ApplicationController subitems_url: "#{graduation_requirement_ec_major_school_ec_year_path(@year, :ec_major_school_id => @year.ec_major_school_id)}", course_count: @year.ec_courses.count, course_url: "#{ec_course_setting_ec_major_school_ec_year_path(@year, :ec_major_school_id => @year.ec_major_school_id)}", - max_support_count: max_support_count} + max_support_count: max_support_count, + is_manager: is_manager} end # 毕业要求vs课程体系 详情页面 diff --git a/app/controllers/ec_courses_controller.rb b/app/controllers/ec_courses_controller.rb index 0ad029f4..5eb29b73 100644 --- a/app/controllers/ec_courses_controller.rb +++ b/app/controllers/ec_courses_controller.rb @@ -429,7 +429,7 @@ class EcCoursesController < ApplicationController {score: 70, level: "中"}, {score: 60, level: "差"}] end - render :json => {levels: ls} + render :json => {levels: ls, is_manager: @is_manager} } end end diff --git a/app/views/ec_graduation_requirements/_requirement_lists.html.erb b/app/views/ec_graduation_requirements/_requirement_lists.html.erb index 8f1edce5..623e910a 100644 --- a/app/views/ec_graduation_requirements/_requirement_lists.html.erb +++ b/app/views/ec_graduation_requirements/_requirement_lists.html.erb @@ -26,7 +26,7 @@ <% end %> <% end %> -<% else %> +<% elsif @template_major %>

diff --git a/app/views/ec_years/_sub_training_objectives.html.erb b/app/views/ec_years/_sub_training_objectives.html.erb index f86bc5d5..4df8f96b 100644 --- a/app/views/ec_years/_sub_training_objectives.html.erb +++ b/app/views/ec_years/_sub_training_objectives.html.erb @@ -13,7 +13,7 @@ <% end %> -<% elsif @ec_training_objective.present? %> +<% elsif @ec_training_objective.present? && @template_major && @ec_training_objective && @sub_training_objectives.count > 0 %>

-<% else %> +<% elsif @template_major && @ec_training_objective && @sub_training_objectives.count > 0 %>