|
|
@ -50,10 +50,11 @@ module ZipService
|
|
|
|
bid_homework_path = []
|
|
|
|
bid_homework_path = []
|
|
|
|
digests = []
|
|
|
|
digests = []
|
|
|
|
members = exercise.course.members
|
|
|
|
members = exercise.course.members
|
|
|
|
exercise_users.each do |exercise_user|
|
|
|
|
exercise_users.each_with_index do |exercise_user, index|
|
|
|
|
member = members.where(:user_id => exercise_user.user_id).first
|
|
|
|
member = members.where(:user_id => exercise_user.user_id).first
|
|
|
|
group_name = member.try(:course_group_id).to_i == 0 ? '未分班' : member.course_group.name
|
|
|
|
group_name = member.try(:course_group_id).to_i == 0 ? '未分班' : member.course_group.name
|
|
|
|
export_file_name = "#{group_name}-#{exercise.course_id}-#{exercise.exercise_name}-#{exercise_user.user.user_extensions.student_id}-#{exercise_user.user.show_real_name}" + ".pdf"
|
|
|
|
# export_file_name = "#{group_name}-#{exercise.course_id}-#{exercise.exercise_name}-#{exercise_user.user.user_extensions.student_id}-#{exercise_user.user.show_real_name}" + ".pdf"
|
|
|
|
|
|
|
|
export_file_name = "#{exercise.id}-#{exercise_user.user.user_extensions.student_id}-#{index}" + ".pdf"
|
|
|
|
out_file = export_user_exercise(exercise, exercise_user, export_file_name)
|
|
|
|
out_file = export_user_exercise(exercise, exercise_user, export_file_name)
|
|
|
|
file_name = File::expand_path(out_file)
|
|
|
|
file_name = File::expand_path(out_file)
|
|
|
|
|
|
|
|
|
|
|
@ -183,6 +184,7 @@ module ZipService
|
|
|
|
|
|
|
|
|
|
|
|
def export_user_exercise exercise, exercise_user, file_name
|
|
|
|
def export_user_exercise exercise, exercise_user, file_name
|
|
|
|
url = Setting.protocol + "://" + Setting.host_name + "/exercise/" + exercise.id.to_s + "/show_student_result?user_id=#{exercise_user.user_id}&pdf=1"
|
|
|
|
url = Setting.protocol + "://" + Setting.host_name + "/exercise/" + exercise.id.to_s + "/show_student_result?user_id=#{exercise_user.user_id}&pdf=1"
|
|
|
|
|
|
|
|
Rails.logger.info("#########################url: #{url}")
|
|
|
|
kit = PDFKit.new(url, :page_size => "A4")
|
|
|
|
kit = PDFKit.new(url, :page_size => "A4")
|
|
|
|
# kit.to_pdf # inline PDF
|
|
|
|
# kit.to_pdf # inline PDF
|
|
|
|
# file_name = "#{exercise.course_id}-#{exercise.exercise_name}-#{exercise_user.user.user_extensions.student_id}-#{exercise_user.user.show_real_name}" + ".pdf"
|
|
|
|
# file_name = "#{exercise.course_id}-#{exercise.exercise_name}-#{exercise_user.user.user_extensions.student_id}-#{exercise_user.user.show_real_name}" + ".pdf"
|
|
|
@ -191,8 +193,8 @@ module ZipService
|
|
|
|
Rails.logger.info("###################file_name: #{file_name}")
|
|
|
|
Rails.logger.info("###################file_name: #{file_name}")
|
|
|
|
kit.to_file("#{OUTPUT_FOLDER}/#{file_name}")
|
|
|
|
kit.to_file("#{OUTPUT_FOLDER}/#{file_name}")
|
|
|
|
out_file = "#{OUTPUT_FOLDER}/#{file_name}"
|
|
|
|
out_file = "#{OUTPUT_FOLDER}/#{file_name}"
|
|
|
|
out_file
|
|
|
|
|
|
|
|
Rails.logger.info("#################out_file_file_name: #{out_file}")
|
|
|
|
Rails.logger.info("#################out_file_file_name: #{out_file}")
|
|
|
|
|
|
|
|
out_file
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def export_user_shixun_work homework, student_work, file_name
|
|
|
|
def export_user_shixun_work homework, student_work, file_name
|
|
|
|