|
|
|
@ -28,7 +28,13 @@ class Admins::ShixunSettingsController < Admins::BaseController
|
|
|
|
|
format.html
|
|
|
|
|
format.xls{
|
|
|
|
|
filename = "实训详情_#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}.xls"
|
|
|
|
|
send_data(shixun_list_xls(shixun_settings), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
|
|
|
|
|
export_url =
|
|
|
|
|
if params[:base_data].present?
|
|
|
|
|
shixun_base_list_xls(shixun_settings)
|
|
|
|
|
else
|
|
|
|
|
shixun_list_xls(shixun_settings)
|
|
|
|
|
end
|
|
|
|
|
send_data(export_url, :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -91,6 +97,34 @@ class Admins::ShixunSettingsController < Admins::BaseController
|
|
|
|
|
xls_report.string
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def shixun_base_list_xls shixuns
|
|
|
|
|
xls_report = StringIO.new
|
|
|
|
|
book = Spreadsheet::Workbook.new
|
|
|
|
|
sheet1 = book.create_worksheet :name => "sheet"
|
|
|
|
|
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
|
|
|
|
|
sheet1.row(0).default_format = blue
|
|
|
|
|
sheet1.row(0).concat(["实训ID","实训名称","技术平台", "Fork源", "状态","创建者", "单位", "职业", "关卡序号","关卡名称"])
|
|
|
|
|
count_row = 1
|
|
|
|
|
shixuns.includes(:mirror_repositories, :challenges, user: [user_extension: :school]).find_each do |shixun|
|
|
|
|
|
sheet1[count_row, 0] = shixun.identifier
|
|
|
|
|
sheet1[count_row, 1] = shixun.name
|
|
|
|
|
sheet1[count_row, 2] = shixun.mirror_repositories.select{|mr| mr.main_type == "1"}.first&.type_name
|
|
|
|
|
sheet1[count_row, 3] = shixun.fork_from
|
|
|
|
|
sheet1[count_row, 4] = shixun.shixun_status
|
|
|
|
|
sheet1[count_row, 5] = shixun.user.show_real_name
|
|
|
|
|
sheet1[count_row, 6] = shixun.user.school_name
|
|
|
|
|
sheet1[count_row, 7] = shixun.user.identity
|
|
|
|
|
shixun.challenges.each do |challenge|
|
|
|
|
|
sheet1[count_row, 8] = "第#{challenge.position}关"
|
|
|
|
|
sheet1[count_row, 9] = challenge.subject
|
|
|
|
|
count_row += 1
|
|
|
|
|
end
|
|
|
|
|
count_row += 1
|
|
|
|
|
end
|
|
|
|
|
book.write xls_report
|
|
|
|
|
xls_report.string
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def setting_params
|
|
|
|
|
params.permit(:use_scope,:excute_time,:close,:status,:can_copy,:webssh,:hidden,:homepage_show,:task_pass,:code_hidden,:page_no, :id,tag_repertoires:[])
|
|
|
|
|
end
|
|
|
|
|