From 733e7827234ddf4055f9932d20f3db6115597dc4 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 14:03:03 +0800 Subject: [PATCH] fix bug --- app/controllers/zips_controller.rb | 3 +-- app/helpers/application_helper.rb | 1 + app/services/exercise_user_pdf_service.rb | 3 +-- app/services/export_exercises_service.rb | 5 ++--- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index 77a41d065..4de85ec64 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -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,"试卷不存在") diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e6bc84f20..f0cac79b9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -334,6 +334,7 @@ module ApplicationHelper raw arr.join('') end + # 导出pdf时,转化markdown为html def to_markdown(text) request_url = request.base_url diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 9b96cd70c..be048c4c2 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -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 diff --git a/app/services/export_exercises_service.rb b/app/services/export_exercises_service.rb index 48bfc9519..12b5501f9 100644 --- a/app/services/export_exercises_service.rb +++ b/app/services/export_exercises_service.rb @@ -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