dev_course
SylorHuang 5 years ago
parent c74f36f35d
commit 0ef3779b17

@ -1291,16 +1291,24 @@ class ExercisesController < ApplicationController
elsif (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
normal_status(-1,"暂无用户提交")
else
respond_to do |format|
format.xlsx{
get_export_users(@exercise,@course,@export_ex_users)
exercise_export_name_ =
"#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}"
exercise_export_name = Base64.urlsafe_encode64(exercise_export_name_.strip.first(30))
render xlsx: "#{exercise_export_name}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
}
end
get_export_users(@exercise,@course,@export_ex_users)
exercise_export_name = "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}"
ex_xlsx = render_to_string handlers: [:axlsx], formats: [:xlsx], template: "exercises/exercise_lists.xlsx.axlsx", locals: {table_columns:@table_columns,exercise_users:@user_columns}
zip_file = Tempfile.new(["#{exercise_export_name}","xlsx"],"/home/tmp")
zip_file.write(ex_xlsx)
zip_file.close
# render json{:status => 0,"file_name":"#{exercise_export_name}"}
render :json => { status: 0, file_name: "#{exercise_export_name}",file_path: "#{zip_file.path}" }
# respond_to do |format|
# format.xlsx{
# get_export_users(@exercise,@course,@export_ex_users)
# exercise_export_name_ =
# "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}"
# exercise_export_name = Base64.urlsafe_encode64(exercise_export_name_.strip.first(30))
#
# render xlsx: "#{exercise_export_name}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
# }
# end
end
end
rescue Exception => e

Loading…
Cancel
Save