From f755a2dca8aacaba6d1b5f74d502c9f3d7776a93 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 14:07:24 +0800 Subject: [PATCH 1/6] fix export exercise pdf --- app/controllers/accounts_controller.rb | 1 - app/services/exercise_user_pdf_service.rb | 6 +++--- app/templates/exercise_export/exercise_export.css | 2 +- app/templates/exercise_export/exercise_user.html.erb | 7 ++++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index c3333c912..0d32926e4 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -83,7 +83,6 @@ class AccountsController < ApplicationController email = params[:login] verifi_code = VerificationCode.where(email: email, code: code, code_type: 3).last user = User.find_by_mail(email) #这里有问题,应该是为email,而不是mail 6.13-hs - end check_code = (verifi_code.try(:code) == code.strip && (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60) unless check_code diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index d74e66d31..663d8b042 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -47,7 +47,7 @@ class ExerciseUserPdfService end def load_data - @exercise_questions = exercise.exercise_questions + @exercise_questions = exercise.exercise_questions.joins(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments) @exercise_ques_count = @exercise_questions.count # 全部的题目数 @exercise_ques_scores = @exercise_questions.pluck(:question_score).sum @@ -81,9 +81,9 @@ class ExerciseUserPdfService @exercise_ques_shixun_count = exercise_ques_shixun.all.count @exercise_ques_shixun_scores = exercise_ques_shixun.pluck(:question_score).sum - challenge_ids = @exercise_questions.joins(:exercise_shixun_challenges).pluck("exercise_shixun_challenges.challenge_id") + challenge_ids = @exercise_questions.pluck("exercise_shixun_challenges.challenge_id") get_each_student_exercise(exercise.id,@exercise_questions,@ex_user_user.id) - @games = @exercise_user.user.games.ch_games(challenge_ids) + # @games = @exercise_user.user.games.ch_games(challenge_ids) end end \ No newline at end of file diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 59be4f1bd..e04f77035 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -231,7 +231,7 @@ p{ position: absolute; display: inline-block; bottom: 9px; - left: 1px; + left: 2px; } .circle-right:after{ color:#fff; diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 193a25301..c81f45d68 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -112,6 +112,7 @@
<% @exercise_questions.each do |q| %> <% q_type = q.question_type %> + <% games =( q_type == 5 ? @ex_user_user.games.ch_games(q.exercise_shixun_challenges.pluck(:challenge_id)) : nil) %> <% 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} %> @@ -247,8 +248,8 @@ 得分/满分 - <% if @games.size > 0 %> - <% @games.each_with_index do |game, index| %> + <% if games.present? %> + <% games&.each_with_index do |game, index| %> <% game_score = q.exercise_shixun_challenges.where(challenge_id:game.challenge.id) %> <% user_score = q.exercise_shixun_answers.where(exercise_shixun_challenge_id: game_score&.first&.id,user_id: @ex_user_user.id) %> @@ -286,7 +287,7 @@

实训详情

- <% @games.each_with_index do |game, index| %> + <% games&.each_with_index do |game, index| %>

第<%= index+1 %>关<%= game.challenge.subject %> From 3eadedc9ad3ec611e67016d761870fe42f312f78 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 14:11:38 +0800 Subject: [PATCH 2/6] fix bug --- app/services/exercise_user_pdf_service.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 663d8b042..d76e792c4 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -47,7 +47,7 @@ class ExerciseUserPdfService end def load_data - @exercise_questions = exercise.exercise_questions.joins(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments) + @exercise_questions = exercise.exercise_questions @exercise_ques_count = @exercise_questions.count # 全部的题目数 @exercise_ques_scores = @exercise_questions.pluck(:question_score).sum @@ -80,8 +80,9 @@ class ExerciseUserPdfService exercise_ques_shixun = @exercise_questions.find_by_custom("question_type",5) @exercise_ques_shixun_count = exercise_ques_shixun.all.count @exercise_ques_shixun_scores = exercise_ques_shixun.pluck(:question_score).sum + @exercise_questions = @exercise_questions.joins(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) - challenge_ids = @exercise_questions.pluck("exercise_shixun_challenges.challenge_id") + # challenge_ids = @exercise_questions.pluck("exercise_shixun_challenges.challenge_id") get_each_student_exercise(exercise.id,@exercise_questions,@ex_user_user.id) # @games = @exercise_user.user.games.ch_games(challenge_ids) From d89a9138d15975ecafc33c0b6adf234c934e8a03 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 14:13:27 +0800 Subject: [PATCH 3/6] fix bug --- app/services/exercise_user_pdf_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index d76e792c4..ae90f60bf 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -80,7 +80,7 @@ class ExerciseUserPdfService exercise_ques_shixun = @exercise_questions.find_by_custom("question_type",5) @exercise_ques_shixun_count = exercise_ques_shixun.all.count @exercise_ques_shixun_scores = exercise_ques_shixun.pluck(:question_score).sum - @exercise_questions = @exercise_questions.joins(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) + # @exercise_questions = @exercise_questions.joins(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) # challenge_ids = @exercise_questions.pluck("exercise_shixun_challenges.challenge_id") From ca172d57e796a813a65d581fcebe1fcd47fb09e1 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 14:19:15 +0800 Subject: [PATCH 4/6] fix exprot exercise bugs 2 --- app/services/exercise_user_pdf_service.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index ae90f60bf..422c3ad5f 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -47,7 +47,7 @@ class ExerciseUserPdfService end def load_data - @exercise_questions = exercise.exercise_questions + @exercise_questions = exercise.exercise_questions.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) @exercise_ques_count = @exercise_questions.count # 全部的题目数 @exercise_ques_scores = @exercise_questions.pluck(:question_score).sum @@ -80,11 +80,7 @@ class ExerciseUserPdfService exercise_ques_shixun = @exercise_questions.find_by_custom("question_type",5) @exercise_ques_shixun_count = exercise_ques_shixun.all.count @exercise_ques_shixun_scores = exercise_ques_shixun.pluck(:question_score).sum - # @exercise_questions = @exercise_questions.joins(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) - - # challenge_ids = @exercise_questions.pluck("exercise_shixun_challenges.challenge_id") get_each_student_exercise(exercise.id,@exercise_questions,@ex_user_user.id) - # @games = @exercise_user.user.games.ch_games(challenge_ids) end end \ No newline at end of file From 6e36cc24ab8b803028f99cad4d90ce6198b8c859 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 14:22:04 +0800 Subject: [PATCH 5/6] fix bug --- app/services/exercise_user_pdf_service.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 422c3ad5f..28857dff9 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -47,7 +47,7 @@ class ExerciseUserPdfService end def load_data - @exercise_questions = exercise.exercise_questions.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) + @exercise_questions = exercise.exercise_questions @exercise_ques_count = @exercise_questions.count # 全部的题目数 @exercise_ques_scores = @exercise_questions.pluck(:question_score).sum @@ -81,6 +81,8 @@ class ExerciseUserPdfService @exercise_ques_shixun_count = exercise_ques_shixun.all.count @exercise_ques_shixun_scores = exercise_ques_shixun.pluck(:question_score).sum + @exercise_questions = @exercise_questions.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) get_each_student_exercise(exercise.id,@exercise_questions,@ex_user_user.id) + end end \ No newline at end of file From 28c641510c13cd7a6477df4c8176ac6dbec0292d Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 14:32:05 +0800 Subject: [PATCH 6/6] fix bug --- app/controllers/exercises_controller.rb | 2 +- app/templates/exercise_export/exercise_export.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 44b694239..e1e8e226b 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1334,7 +1334,7 @@ class ExercisesController < ApplicationController #导出空白试卷 def export_exercise - @exercise_questions = @exercise.exercise_questions.order("question_number ASC") + @exercise_questions = @exercise.exercise_questions.includes(:exercise_choices).order("question_number ASC") filename = "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.current.strftime('%Y%m%d%H%M%S')}.pdf" stylesheets = "#{Rails.root}/app/templates/exercise_export/exercise_export.css" render pdf: 'exercise_export/blank_exercise', filename: filename, stylesheets: stylesheets diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index e04f77035..9190e9251 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -156,7 +156,7 @@ p{ position: absolute; display: inline-block; bottom: 6px; - /*left: 1px;*/ + left: 1px; } .line-line {