|
|
|
@ -207,19 +207,23 @@ class HomeworkCommonsController < ApplicationController
|
|
|
|
|
tip_exception(403, "无权限操作")
|
|
|
|
|
elsif @work_excel.blank? || @work_excel.size == 0
|
|
|
|
|
normal_status(-1,"暂无用户提交!")
|
|
|
|
|
elsif params[:export].present? && params[:export]
|
|
|
|
|
normal_status(0,"正在下载中")
|
|
|
|
|
else
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.xlsx{
|
|
|
|
|
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:
|
|
|
|
|
{table_columns: @work_head_cells,task_users: @work_cells_column}
|
|
|
|
|
{table_columns: @work_head_cells,task_users: @work_cells_column},cookies:{fileDownload:true,HttpOnly:false}
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
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")
|
|
|
|
@ -233,7 +237,7 @@ class HomeworkCommonsController < ApplicationController
|
|
|
|
|
format.zip{
|
|
|
|
|
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'
|
|
|
|
|
send_file "#{OUTPUT_FOLDER}/#{file}", filename: filename_for_content_disposition(file), type: 'application/zip',cookies:{fileDownload:true,HttpOnly:false}
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|