dev_forum
SylorHuang 5 years ago
parent c3087d7b4e
commit 733e782723

@ -17,7 +17,7 @@ class ZipsController < ApplicationController
end
def export_exercises
exercises = ExportExercisesService.new(@exercise,@ex_users,@request_url)
exercises = ExportExercisesService.new(@exercise,@ex_users)
file_name = filename_for_content_disposition(exercises.filename)
send_file exercises.ex_zip, filename: file_name, type: 'application/zip'
@ -41,7 +41,6 @@ class ZipsController < ApplicationController
ActiveRecord::Base.transaction do
begin
@exercise = Exercise.includes(:exercise_users,:exercise_questions).find_by(id:params[:exercise_id])
@request_url = request.base_url
group_id = params[:exercise_group_id]
if @exercise.blank?
normal_status(-1,"试卷不存在")

@ -334,6 +334,7 @@ module ApplicationHelper
raw arr.join('')
end
# 导出pdf时转化markdown为html
def to_markdown(text)
request_url = request.base_url

@ -5,10 +5,9 @@ class ExerciseUserPdfService
attr_reader :exercise, :ex_user
def initialize(exercise, ex_user,request_url)
def initialize(exercise, ex_user)
@exercise = exercise
@ex_user = ex_user
@request_url = request_url
@ex_user_user = @ex_user.user
@course = @exercise.course
end

@ -3,10 +3,9 @@ class ExportExercisesService
include StudentWorksHelper
attr_reader :exercise, :ex_users
def initialize(exercise, ex_users,request_url)
def initialize(exercise, ex_users)
@exercise = exercise
@ex_users = ex_users
@request_url = request_url
end
def filename
@ -19,7 +18,7 @@ class ExportExercisesService
pdfs = []
Zip::File.open(zip_file.path, Zip::File::CREATE) do |zip|
ex_users.each do |ex_user|
export = ExerciseUserPdfService.new(exercise, ex_user,@request_url)
export = ExerciseUserPdfService.new(exercise, ex_user)
pdf = export.ex_pdf
pdfs << pdf
begin

Loading…
Cancel
Save