diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index f0ab50001..35373730c 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -20,6 +20,7 @@ class ZipsController < ApplicationController exercises = ExportExercisesService.new(@exercise,@ex_users) file_name = filename_for_content_disposition(exercises.filename) + logger.info("##################_______________________file_name_____________________############{file_name}") send_file exercises.ex_zip, filename: file_name, type: 'application/zip' rescue Exception => e normal_status(-1, e.message) @@ -39,14 +40,14 @@ class ZipsController < ApplicationController def get_exercise ActiveRecord::Base.transaction do begin - @exercise = Exercise.find_by(id:params[:exercise_id]) + @exercise = Exercise.includes(:exercise_users).find_by(id:params[:exercise_id]) group_id = params[:exercise_group_id] if @exercise.blank? normal_status(-1,"试卷不存在") else @course = @exercise.course - default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed.limit 2 + default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed default_ex_users_size = default_ex_users.size @ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。 #可以分班选择 diff --git a/config/initializers/pdfkit.rb b/config/initializers/pdfkit.rb index 556076f4b..0cd80c9c7 100644 --- a/config/initializers/pdfkit.rb +++ b/config/initializers/pdfkit.rb @@ -1,7 +1,8 @@ PDFKit.configure do |config| - # config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || 'wkhtmltopdf' - config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || '/usr/bin/wkhtmltopdf' + config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || 'wkhtmltopdf' + # config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || '/usr/bin/wkhtmltopdf' config.default_options = { + encoding: "UTF-8", page_size: 'A4', print_media_type: true, dpi: 300,