diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index d74e66d31..6dbb11c83 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -42,6 +42,7 @@ class ExerciseUserPdfService # aa.syswrite(kit.source) #正式需删掉------- file = Tempfile.new(filename) + logger.info("###########__________________file.path_______________########################{file.path}") kit.to_pdf(file.path) file end diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index d769ca0f0..70c023d26 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -1 +1,353 @@ -11111111111111 \ No newline at end of file + + + + + + + +
+
+
+
+

<%= @exercise.try(:exercise_name) %>

+
+
+

+ <%= @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 %> +

+
+
+
+ <% if @ex_obj_array.size > 0 %> +
+

+ 客观题 + 正确 + 错误 + 部分得分 + 总分:<%= @exercise_user&.score %>分 +

+
+
+ <% @ex_obj_array.each do |s| %> + <% if s[:stand_status] == 1 %> +
+ <%= s[:q_position] %> +
+ <% elsif s[:stand_status] == 0 %> +
+ <%= s[:q_position] %> +
+ <% else %> +
+ <%= s[:q_position] %> +
+ <% end %> + <% end %> +
+ <% end %> + <% if @ex_sub_array.size > 0 %> +
+

+ 主观题 + 已评 + 未评 + 开始答题时间:<%= @exercise_user.start_at.present? ? @exercise_user.start_at.strftime("%Y-%m-%d %H:%M") : "--" %> +

+
+
+ <% @ex_sub_array.each do |s| %> + <% if s[:stand_status] == 0 %> +
+ <%= s[:q_position] %> +
+ <% else %> +
+ <%= s[:q_position] %> +
+ <% end %> + <% end %> +
+ <% end %> +
+
+ <% @exercise_questions.each do |q| %> + <% q_type = q.question_type %> + <% user_answer = (q_type == 5 ? q.exercise_shixun_answers.where(user_id: @ex_user_user.id) : q.exercise_answers.where(user_id: @ex_user_user.id)) %> + <% this_ques_status = @ex_obj_array.detect{|f| f[:q_id] == q.id} %> + <% main_ques_status = @ex_sub_array.detect{|f| f[:q_id] == q.id} %> + <% ques_comment = q.exercise_answer_comments.where("exercise_answer_id",user_answer.first&.id) %> +
+
+
+
+ <%= q.question_number %>、  + + <%= q.question_type_name %> + + (<%= q&.question_score %>分) + <% if q_type == 5 %> + + <% if this_ques_status.present? && this_ques_status[:stand_status] == 1 %> + + <%= this_ques_status[:user_score] %>分 + <% elsif this_ques_status.present? && this_ques_status[:stand_status] == 2 %> + + <%= this_ques_status[:user_score] %>分 + <% else %> + + 0.0分 + <% end %> + + <% elsif q_type == 4 %> + + <% if main_ques_status.present? && main_ques_status[:stand_status] == 1 %> + + <%= main_ques_status[:user_score] %>分 + <% elsif main_ques_status.present? && main_ques_status[:stand_status] == 2 %> + + <%= main_ques_status[:user_score] %>分 + <% else %> + 未批 + <% end %> + + <% else %> + + <% if this_ques_status.present? && this_ques_status[:stand_status] == 1 %> + + <%= this_ques_status[:user_score] %>分 + <% elsif this_ques_status.present? && this_ques_status[:stand_status] == 2 %> + + <%= this_ques_status[:user_score] %>分 + <% else %> + + 0.0分 + <% end %> + + <% end %> +
+
+ <% if q_type == 5 %> + <%= q.shixun_name&.html_safe %> +
+ <%= q.question_title&.html_safe %> +
+ <% elsif q_type == 4 %> + <%= q.question_title&.html_safe %> + <% else %> + <%= q.question_title&.html_safe %> + <% end %> +
+
+
+ <% if q_type == 0 %> + <% q.exercise_choices.each_with_index do |s,index| %> + <% check_answer = (user_answer.present? && (s.id == user_answer.first.exercise_choice_id)) ? "choose-answer" : '' %> +

+ + <%= 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) %> + + + + + + + + + + <% end %> + <% else %> + <% q.exercise_shixun_challenges.each_with_index do |game, index| %> + <% game_score = q.exercise_shixun_challenges.where(challenge_id:game.challenge.id) %> + + + + + + + + + + <% end %> + <% end %> + +
关卡任务名称评测次数完成时间耗时经验值得分/满分
<%= 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 %> +

+
+ <% if game.outputs.present? %> + + + + + + + <% outputs = game.outputs.group("query_index") %> + <% outputs.reverse.try(:each) do |output| %> + + + + + <% end %> + +
评测次数评测信息
<%= "第#{output.query_index}次" %><%= output_detail(game, output) %>
+ <% end %> + <% if game.try(:lastest_code).present? && game.challenge.st == 0 %> + <% con_rows = content_line(game.lastest_code) %> +
+

+ + 最近通过的代码 + <%= game.challenge.path %> + +

+
+ +
+
+ <% end %> +
+
+ <% end %> +
+ <% end %> +
+
+
+ <% if ques_comment.present? && ques_comment.first.comment.present? %> + <% ques_user = ques_comment.first.user %> +
+
+
+ +
+
+

<%= ques_user.real_name %><%= ques_comment.first.updated_at.strftime('%Y-%m-%d %H:%M') %>

+

<%= ques_comment.first.comment %>

+
+
+
+ <% end %> + <% end %> +
+
+
+ +