diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 89d53e73c..4396f5936 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -26,7 +26,7 @@ class ApplicationController < ActionController::Base unless Rails.env.development? Rails.logger.info("66666 #{params}") suffix = request.url.split(".").last.split("?").first - suffix_arr = ["xls", "xlsx", "pdf"] # excel文件先注释 + suffix_arr = ["xls", "xlsx", "pdf", "zip"] # excel文件先注释 unless suffix_arr.include?(suffix) if params[:client_key].present? randomcode = params[:randomcode] 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/public/css/edu-all.css b/public/react/public/css/edu-all.css index 66adaf482..061cee521 100644 --- a/public/react/public/css/edu-all.css +++ b/public/react/public/css/edu-all.css @@ -174,7 +174,7 @@ em.vertical-line{display: inline-block;width: 2px;background: #999;height: 10px} .user_navlist_white a:hover{color: #4cacff} .headIcon{height: 100%;box-sizing: border-box; margin: 0px!important;} .black_nav_list{padding: 4px 0px;box-sizing: border-box;height: 100%;} -.black_nav_list li{line-height: 42px;height: 42px;color: #fff;cursor: pointer;} +.black_nav_list li{line-height: 40px;height: 40px;color: #fff;cursor: pointer;} .black_nav_span{display: block;margin:0px 20px;border-bottom: 1px solid #4B4B4B;padding-left: 8px;color: #FAFAFA} .welcome_shixun_index:last-child .black_nav_span{border-bottom: none} .black_nav_list li:hover{background: #fff;} diff --git a/public/react/src/modules/courses/exercise/new/SingleDisplay.js b/public/react/src/modules/courses/exercise/new/SingleDisplay.js index 4b8d9ee95..6b84df8ce 100644 --- a/public/react/src/modules/courses/exercise/new/SingleDisplay.js +++ b/public/react/src/modules/courses/exercise/new/SingleDisplay.js @@ -102,7 +102,7 @@ class SingleDisplay extends Component{ display: "flex", flexDirection:"row", }} key={optionIndex}> - {prefix} + {prefix} @@ -116,7 +116,7 @@ class SingleDisplay extends Component{ display: "flex", flexDirection:"row", }} key={optionIndex}> - {prefix} + {prefix} 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 diff --git a/public/react/src/modules/page/main/CodeEvaluateView.js b/public/react/src/modules/page/main/CodeEvaluateView.js index e70d02008..346b8797e 100644 --- a/public/react/src/modules/page/main/CodeEvaluateView.js +++ b/public/react/src/modules/page/main/CodeEvaluateView.js @@ -318,6 +318,7 @@ class CodeEvaluateView extends Component { */ const _arrowClasses = isCollapse ? 'iconfont icon-xiajiantou btn-arrow' : 'iconfont icon-shangjiantou btn-arrow'; + return (