diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 1f2f84414..d74e66d31 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -41,14 +41,8 @@ class ExerciseUserPdfService # aa = File.open(Rails.root.join("public/123.html"),"w+") # aa.syswrite(kit.source) #正式需删掉------- - Rails.logger.info("##################_______________________file_name___________5555555555__________###########") - file = Tempfile.new(filename) - Rails.logger.info("##################_______________________file_name___________66666666__________###########") - kit.to_pdf(file.path) - Rails.logger.info("##################_______________________file_name___________7777777777__________###########") - file end diff --git a/app/services/export_exercises_service.rb b/app/services/export_exercises_service.rb index c450f6247..12b5501f9 100644 --- a/app/services/export_exercises_service.rb +++ b/app/services/export_exercises_service.rb @@ -14,29 +14,15 @@ class ExportExercisesService end def ex_zip - Rails.logger.info("##################_______________________file_name___________11111__________###########") - zip_file = Tempfile.new(filename) - Rails.logger.info("##################_______________________file_name___________2222222__________###########") - pdfs = [] Zip::File.open(zip_file.path, Zip::File::CREATE) do |zip| - Rails.logger.info("##################_______________________file_name___________3333333__________###########") - ex_users.each do |ex_user| export = ExerciseUserPdfService.new(exercise, ex_user) - Rails.logger.info("##################_______________________file_name___________444444__________###########") - pdf = export.ex_pdf - Rails.logger.info("##################_______________________file_name___________888888888__________###########") - pdfs << pdf - Rails.logger.info("##################_______________________file_name___________999999999__________###########") - begin zip.add(export.filename, pdf.path) - Rails.logger.info("##################_______________________file_name___________10000000000000__________###########") - rescue => ex Rails.logger.error(ex.message) zip.get_output_stream('FILE_NOTICE.txt'){|os| os.write("文件重复:#{export.filename}") } diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 088ff1fd4..d769ca0f0 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -1,353 +1 @@ - - -
- - - - -- <%= @exercise.try(:exercise_description).nil? ? "" : @exercise.try(:exercise_description)&.html_safe %> -
-- <% if @exercise_single_ques_count > 0 %> - 单选题<%= @exercise_single_ques_count %>题, - 共<%= @exercise_single_ques_scores %>分 - <% end %> - <% if @exercise_double_ques_count > 0 %> - 多选题<%= @exercise_double_ques_count %>题, - 共<%= @exercise_double_ques_scores %>分 - <% end %> - <% if @exercise_ques_judge_count > 0 %> - 判断题<%= @exercise_ques_judge_count %>题, - 共<%= @exercise_ques_judge_scores %>分 - <% end %> - <% if @exercise_ques_null_count > 0 %> - 填空题<%= @exercise_ques_null_count %>题, - 共<%= @exercise_ques_null_scores %>分 - <% end %> - <% if @exercise_ques_main_count > 0 %> - 主观题<%= @exercise_ques_main_count %>题, - 共<%= @exercise_ques_main_scores %>分 - <% end %> - <% if @exercise_ques_shixun_count > 0 %> - 实训题<%= @exercise_ques_shixun_count %>题, - 共<%= @exercise_ques_shixun_scores %>分 - <% end %> - - <% if @exercise_ques_count > 0 %> - - 共<%= @exercise_ques_scores %>分 - - - 合计<%= @exercise_ques_count %>题 - - <% end %> -
-- 客观题 - 正确 - 错误 - 部分得分 - 总分:<%= @exercise_user.score %>分 -
-- 主观题 - 已评 - 未评 - 开始答题时间:<%= @exercise_user.start_at.present? ? @exercise_user.start_at.strftime("%Y-%m-%d %H:%M") : "--" %> -
-- - <%= convert_to_char((index+1).to_s)%><%= s.choice_text%> -
- <% end %> - <% elsif q_type == 1 %> - <% q.exercise_choices.each_with_index do |s,index| %> - <% check_answer = (user_answer.present? && (user_answer.pluck(:exercise_choice_id).include?(s.id))) ? true : false %> -- <% if check_answer %> - - <% else %> - - <% end %> - <%= convert_to_char((index+1).to_s)%><%= s.choice_text%> -
- <% end %> - <% elsif q_type == 2 %> -- <% q.exercise_choices.each do |s| %> - <% if user_answer.present? && (s.id == user_answer.first.exercise_choice_id) %> - <% check_answer = 'choose-answer' %> - <% else %> - <% check_answer = '' %> - <% end %> - - - <%= s.choice_text %> - - <% end %> -
- <% elsif q_type == 3 %> - <% st_counts = q.exercise_standard_answers.pluck(:exercise_choice_id).uniq %> - <% st_counts.each_with_index do |s,index| %> - <% if user_answer.present? && user_answer.where(exercise_choice_id:s).present? %> - <% check_answer = user_answer.where(exercise_choice_id:s).first.answer_text %> - <% else %> - <% check_answer = "--" %> - <% end %> -- 答案(填空<%= index+1 %>): - <%= check_answer&.html_safe %> -
- <% end %> - <% elsif q_type == 4 %> - <% check_answer = (user_answer.present? ? user_answer.first.answer_text : '--') %> -- <%= check_answer&.html_safe %> -
- <% else %> -- 阶段成绩 -
-关卡 | -任务名称 | -评测次数 | -完成时间 | -耗时 | -经验值 | -得分/满分 | - - - <% if @games.size > 0 %> - <% @games.each_with_index do |game, index| %> - <% user_score = q.exercise_shixun_answers.where(exercise_shixun_challenge_id:game.challenge.id,user_id: @ex_user_user.id) %> - <% game_score = q.exercise_shixun_challenges.where(challenge_id:game.challenge.id) %> -
---|---|---|---|---|---|---|
<%= index + 1 %> | -- <%= game.challenge.subject %> - | -<%= game.evaluate_count %> | -<%= game.end_time.present? ? game.end_time.strftime("%Y-%m-%d %H:%M") : "--" %> | -<%= ApplicationController.helpers.time_consuming game %> | -<%= game.final_score %> / <%= game.challenge.all_score %> | -<%= user_score.present? ? user_score.first.score : 0.0 %> / <%= game_score.present? ? game_score.first.question_score : 0.0 %> | -
<%= index + 1 %> | -- <%= game.challenge.subject %> - | -0 | --- | --- | -0.0 / <%= game.challenge.all_score %> | -0.0 / <%= game_score.present? ? game_score.first.question_score : 0.0 %> | -
- 实训详情 -
- <% @games.each_with_index do |game, index| %> -- 第<%= index+1 %>关<%= game.challenge.subject %> -
-评测次数 | -评测信息 | - - - <% outputs = game.outputs.group("query_index") %> - <% outputs.reverse.try(:each) do |output| %> -
---|---|
<%= "第#{output.query_index}次" %> | -<%= output_detail(game, output) %> | -
- - 最近通过的代码 - <%= game.challenge.path %> - -
-<%= ques_user.real_name %><%= ques_comment.first.updated_at.strftime('%Y-%m-%d %H:%M') %>
-<%= ques_comment.first.comment %>
-