|
|
|
@ -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
|
|
|
|
|