|
|
@ -1291,24 +1291,15 @@ class ExercisesController < ApplicationController
|
|
|
|
elsif (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
|
|
|
|
elsif (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
|
|
|
|
normal_status(-1,"暂无用户提交")
|
|
|
|
normal_status(-1,"暂无用户提交")
|
|
|
|
else
|
|
|
|
else
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
|
|
|
format.xlsx{
|
|
|
|
get_export_users(@exercise,@course,@export_ex_users)
|
|
|
|
get_export_users(@exercise,@course,@export_ex_users)
|
|
|
|
exercise_export_name = "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}"
|
|
|
|
exercise_export_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}
|
|
|
|
"#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
|
|
|
|
zip_file = Tempfile.new(exercise_export_name,"/home/tmp")
|
|
|
|
|
|
|
|
zip_file.write(ex_xlsx)
|
|
|
|
render xlsx: "#{exercise_export_name_.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
|
|
|
|
zip_file.close
|
|
|
|
}
|
|
|
|
# render json{:status => 0,"file_name":"#{exercise_export_name}"}
|
|
|
|
end
|
|
|
|
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
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue Exception => e
|
|
|
|
rescue Exception => e
|
|
|
@ -1323,10 +1314,9 @@ class ExercisesController < ApplicationController
|
|
|
|
def export_exercise
|
|
|
|
def export_exercise
|
|
|
|
@request_url = request.base_url
|
|
|
|
@request_url = request.base_url
|
|
|
|
@exercise_questions = @exercise.exercise_questions.includes(:exercise_choices).order("question_number ASC")
|
|
|
|
@exercise_questions = @exercise.exercise_questions.includes(:exercise_choices).order("question_number ASC")
|
|
|
|
filename_ = "#{@exercise.user.real_name}_#{@exercise.exercise_name}"
|
|
|
|
filename_ = "#{@exercise.user.real_name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
|
|
|
|
filename = Base64.urlsafe_encode64(filename_.strip.first(30))
|
|
|
|
|
|
|
|
stylesheets = "#{Rails.root}/app/templates/exercise_export/exercise_export.css"
|
|
|
|
stylesheets = "#{Rails.root}/app/templates/exercise_export/exercise_export.css"
|
|
|
|
render pdf: 'exercise_export/blank_exercise', filename: filename, stylesheets: stylesheets
|
|
|
|
render pdf: 'exercise_export/blank_exercise', filename: filename_.strip.first(30), stylesheets: stylesheets
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#空白试卷预览页面,仅供测试使用,无其他任何用途
|
|
|
|
#空白试卷预览页面,仅供测试使用,无其他任何用途
|
|
|
|