diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index f86ade58f..442881df2 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -147,7 +147,7 @@ class ShixunsController < ApplicationController ## 实训详情 def show # 当前用户开启的实训 - can_fork = current_user.is_certification_teacher || current_user.admin? + can_fork = current_user.is_certification_teacher || current_user.admin_or_business? unless can_fork @can_fork = {can_fork: "已经职业认证的教师才能fork实训", certi_url: "/account/certification"} diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb index d71ca8037..0b7874299 100644 --- a/app/controllers/student_works_controller.rb +++ b/app/controllers/student_works_controller.rb @@ -529,7 +529,7 @@ class StudentWorksController < ApplicationController @echart_data = student_efficiency(@homework, @work) @myself_eff = @echart_data[:efficiency_list].find { |item| item.last == @user.id } @myself_consume = @echart_data[:consume_list].find { |item| item.last == @user.id } - filename_ = "#{@user&.student_id}_#{@user&.real_name}_#{@shixun&.name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}.pdf" + filename_ = "#{@homework.course&.user_group_name(@work.user_id)}_#{@user&.student_id}_#{@user&.real_name}_#{@shixun&.name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}.pdf" filename = filename_.strip.tr("+/", "-_") stylesheets = %w(shixun_work/shixun_work.css shared/codemirror.css) if params[:export].present? && params[:export] diff --git a/app/services/export_shixun_report_service.rb b/app/services/export_shixun_report_service.rb index 57b955762..b75f031c0 100644 --- a/app/services/export_shixun_report_service.rb +++ b/app/services/export_shixun_report_service.rb @@ -10,7 +10,7 @@ class ExportShixunReportService end def filename - @_filename ||= "#{work.user&.student_id}_#{work.user.real_name}_#{homework.name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}.pdf".gsub(' ', '-').gsub('/', '_') + @_filename ||= "#{homework.course&.user_group_name(work.user_id)}_#{work.user&.student_id}_#{work.user.real_name}_#{homework.name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}.pdf".gsub(' ', '-').gsub('/', '_') end def prepare_binding @@ -43,6 +43,7 @@ class ExportShixunReportService @user = @work.user @shixun = homework.shixuns.take @games = @work.myshixun.games.includes(:challenge, :game_codes,:outputs) if @work.myshixun + @challenges = @shixun.challenges if @shixun # 用户最大评测次数 @user_evaluate_count = @games.pluck(:evaluate_count).sum if @games diff --git a/lib/tasks/zip_pack.rake b/lib/tasks/zip_pack.rake new file mode 100644 index 000000000..7eb757f08 --- /dev/null +++ b/lib/tasks/zip_pack.rake @@ -0,0 +1,50 @@ +# 执行示例 bundle exec rake zip_pack:shixun_pack args=123,2323 +namespace :zip_pack do + desc "手工打包作品" + OUTPUT_FOLDER = "#{Rails.root}/files/archiveZip" + + task :shixun_pack => :environment do + + if ENV['args'] + homework_ids = ENV['args'].split(",").map(&:to_i) + homeworks = HomeworkCommon.where(id: homework_ids) + homeworks.includes(:score_student_works).each do |homework| + out_file_name = "#{Time.now.strftime("%Y%m%d%H%M%S").to_s}-#{homework.course_id}-#{homework.name}.zip" + out_file_name.gsub!(" ", "-") + out_file_name.gsub!("/", "_") + + zipfile_name = "#{OUTPUT_FOLDER}/#{out_file_name}" + Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name)) + + student_works = homework.score_student_works + + if student_works.size > 0 + Zip::File.open(zipfile_name, Zip::File::CREATE) do |zip| + student_works.find_each.map do |student_work| + export = ExportShixunReportService.new(homework, student_work) + pdf = export.to_pdf + # pdfs << pdf + begin + zip.add(export.filename, pdf.path) + rescue => ex + Rails.logger.error(ex.message) + + zip.get_output_stream('FILE_NOTICE.txt'){|os| os.write("文件重复:#{export.filename}") } + next + end + end + end + zipfile = zipfile_name + else + zipfile = {:message => "no file"} + end + puts "out: #{zipfile}" + + end + end + end + + def filename_for_content_disposition(name) + request.env['HTTP_USER_AGENT'] =~ %r{MSIE|Trident|Edge} ? ERB::Util.url_encode(name) : name + end +end \ No newline at end of file diff --git a/public/react/src/modules/page/component/monaco/TPIMonaco.css b/public/react/src/modules/page/component/monaco/TPIMonaco.css index 75fe4ae8a..368ed5c8f 100644 --- a/public/react/src/modules/page/component/monaco/TPIMonaco.css +++ b/public/react/src/modules/page/component/monaco/TPIMonaco.css @@ -143,4 +143,18 @@ /* 选中行边框 */ .monaco-editor .view-overlays .current-line { border-width: 1px !important; +} + +.monaco-editor .margin, +.monaco-editor .margin-view-overlays{ + width: 54px !important; + text-align: center !important; +} + +.monaco-editor .monaco-scrollable-element{ + left: 54px !important; +} + +.monaco-editor .margin-view-overlays .line-numbers{ + text-align: center !important; } \ No newline at end of file