作业导出的修改2

master
SylorHuang 6 years ago
parent 78c164c08f
commit 43fb9b180b

@ -583,4 +583,8 @@ class ApplicationController < ActionController::Base
def render_parameter_missing
render json: { status: -1, message: '参数缺失' }
end
def set_export_cookies
cookies[:fileDownload] = true
end
end

@ -212,7 +212,7 @@ class HomeworkCommonsController < ApplicationController
else
respond_to do |format|
format.xlsx{
cookies[:fileDownload] = true
set_export_cookies
student_work_to_xlsx(@work_excel,@homework)
exercise_export_name = "#{current_user.real_name}_#{@course.name}_#{@homework.name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
render xlsx: "#{exercise_export_name.strip}",template: "homework_commons/works_list.xlsx.axlsx",locals:
@ -223,8 +223,6 @@ class HomeworkCommonsController < ApplicationController
elsif params[:format] == "zip"
if @user_course_identity >= Course::STUDENT
tip_exception(403, "无权限操作")
elsif params[:export].present? && params[:export]
normal_status(0,"正在下载中")
else
if @work_excel.present?
zip_works = @work_excel&.where("work_status > 0")
@ -234,14 +232,18 @@ class HomeworkCommonsController < ApplicationController
end
if status == 0
if params[:export].present? && params[:export]
normal_status(0,"正在下载中")
else
respond_to do |format|
format.zip{
cookies[:fileDownload] = true
set_export_cookies
zipfile = zip_homework_common @homework, zip_works
file = decode64(zipfile[0][:base64file])
send_file "#{OUTPUT_FOLDER}/#{file}", filename: filename_for_content_disposition(file), type: 'application/zip'
}
end
end
else
normal_status(status, status == -2 ? "500M" : "无附件可下载")
end

@ -11,7 +11,7 @@ class ZipsController < ApplicationController
if params[:export].present? && params[:export]
normal_status(0,"正在下载中")
else
cookies[:fileDownload] = true
set_export_cookies
send_file service.zip, filename: filename_, type: 'application/zip'
end

Loading…
Cancel
Save