From 649e2a7ba62041622a7c6f44b13267ad65a462d7 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 12 Mar 2019 21:36:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ec_courses_controller.rb | 10 ++--- app/controllers/ec_years_controller.rb | 50 +++++++++++------------- 2 files changed, 26 insertions(+), 34 deletions(-) diff --git a/app/controllers/ec_courses_controller.rb b/app/controllers/ec_courses_controller.rb index 9a3d491d..43fed5cb 100644 --- a/app/controllers/ec_courses_controller.rb +++ b/app/controllers/ec_courses_controller.rb @@ -102,13 +102,9 @@ class EcCoursesController < ApplicationController end def ec_course_support_setting_data - respond_to do |format| - format.json { - course_targets = @ec_course.ec_course_targets.includes(:ec_graduation_subitems) - json_data = target_list_data(course_targets) - render :json => json_data - } - end + course_targets = @ec_course.ec_course_targets.includes(:ec_graduation_subitems) + json_data = target_list_data(course_targets) + render :json => json_data end # 课程目标配置的更新操作() diff --git a/app/controllers/ec_years_controller.rb b/app/controllers/ec_years_controller.rb index 0a8a67a8..d6896157 100644 --- a/app/controllers/ec_years_controller.rb +++ b/app/controllers/ec_years_controller.rb @@ -58,38 +58,34 @@ class EcYearsController < ApplicationController end def student_lists_data - respond_to do |format| - format.json { - template_file = EcTemplate.find_by_name "学生列表导入模板" - if template_file.present? - file = template_file.attachments.first - template_url = "/attachments/download/#{file.id}/#{file.filename}" - else - template_url = "javascript:void(0);" - end + template_file = EcTemplate.find_by_name "学生列表导入模板" + if template_file.present? + file = template_file.attachments.first + template_url = "/attachments/download/#{file.id}/#{file.filename}" + else + template_url = "javascript:void(0);" + end - students = @year.ec_year_students - show_name = @year.ec_year_students.where(:name => nil).count == 0 + students = @year.ec_year_students + show_name = @year.ec_year_students.where(:name => nil).count == 0 - page = params[:page] || 1 - total_student = students.count - total_page = (total_student / 50.0).ceil - students = paginateHelper students, 50 + page = params[:page] || 1 + total_student = students.count + total_page = (total_student / 50.0).ceil + students = paginateHelper students, 50 - ec_students = [] - students.each_with_index do |student, index| - student = {index: (50*(page.to_i - 1) + index + 1), - student_name: student.name, - student_id: student.student_id} - ec_students << student - end + ec_students = [] + students.each_with_index do |student, index| + student = {index: (50*(page.to_i - 1) + index + 1), + student_name: student.name, + student_id: student.student_id} + ec_students << student + end - import_url = "/ec_major_schools/#{@ec_major_school.id}/academic_years/#{@year.id}/import_students" + import_url = "/ec_major_schools/#{@ec_major_school.id}/academic_years/#{@year.id}/import_students" - render :json => {template_url: template_url, ec_students: ec_students, total_page: total_page, import_url: import_url, - show_name: show_name, :total_student => total_student, :is_manager => @template_major} - } - end + render :json => {template_url: template_url, ec_students: ec_students, total_page: total_page, import_url: import_url, + show_name: show_name, :total_student => total_student, :is_manager => @template_major} end # DELETE: /ec_major_schools/:major_id/academic_years/:year_id/destroy_students