diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index ca76ee953..22adf3005 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -850,7 +850,7 @@ module ExportHelper def make_zip_name(work, file_name="") Rails.logger.info("######################file_name: #{file_name}") # name = file_name === "" ? "" : (file_name[0, file_name.rindex('.')]+"_") - "#{work&.user&.student_id}_#{work&.user&.real_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" + "#{work&.homework_common.course&.user_group_name(work.user_id)}_#{work&.user&.student_id}_#{work&.user&.real_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" end def zipping(zip_name_refer, files_paths, output_path, is_attachment=false, not_exist_file=[]) diff --git a/lib/tasks/zip_pack.rake b/lib/tasks/zip_pack.rake index c1a080e36..393f7ab3c 100644 --- a/lib/tasks/zip_pack.rake +++ b/lib/tasks/zip_pack.rake @@ -46,6 +46,21 @@ namespace :zip_pack do end end + task :homework_attach_pack => :environment do + include ExportHelper + if ENV['args'] + homework_id = ENV['args'] + homework = HomeworkCommon.find homework_id + zip_works = homework.student_works.where("work_status > 0") + if zip_works.size > 0 + zipfile = zip_homework_common homework, zip_works + else + zipfile = {:message => "no file"} + end + puts "out: #{zipfile}" + end + end + def filename_for_content_disposition(name) request.env['HTTP_USER_AGENT'] =~ %r{MSIE|Trident|Edge} ? ERB::Util.url_encode(name) : name end