From fd3f85aa93123c7e02a4cc3c8824a6c0eb24d4f2 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 16:50:35 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/discuss.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/discuss.rb b/app/models/discuss.rb index 8d8dc0163..93f0d62cd 100644 --- a/app/models/discuss.rb +++ b/app/models/discuss.rb @@ -33,11 +33,11 @@ class Discuss < ApplicationRecord "/tasks/#{game&.identifier}" end - def contents(shixun, user) - return content unless hidden? - - shixun.has_manager?(user) ? content : '' - end + # def contents(shixun, user) + # return content unless hidden? + # + # shixun.has_manager?(user) ? content : '' + # end def child_discuss(user) user.admin? ? From 4e7098a3397586c464c2bc52468ff51c8d35f25e Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 16:50:44 +0800 Subject: [PATCH 2/6] fix bug --- app/controllers/exercises_controller.rb | 2 +- app/services/exercise_user_pdf_service.rb | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index e1e8e226b..720f8f593 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1512,7 +1512,7 @@ class ExercisesController < ApplicationController end def get_exercise_question_counts #获取试卷的问题数及总分数 - exercise_questions = @exercise.exercise_questions.all + 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 diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 28857dff9..8ee1d0cd4 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 @@ -81,7 +81,6 @@ 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 From b65f8bc0a532a391094f5f0ddbfc39f0b0085009 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 16:51:59 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/discusses/_discuss.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/discusses/_discuss.json.jbuilder b/app/views/discusses/_discuss.json.jbuilder index da1ca5a6c..e7e6e425f 100644 --- a/app/views/discusses/_discuss.json.jbuilder +++ b/app/views/discusses/_discuss.json.jbuilder @@ -2,7 +2,7 @@ json.author do json.partial! 'users/user', user: discuss.user end json.id discuss.id -json.content discuss.contents +json.content discuss.content json.time time_from_now(discuss.created_at) json.position discuss.position json.shixun_id discuss.dis_id From a43f0b64e935980ba7b1833e3f045653563da0c6 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 16:53:44 +0800 Subject: [PATCH 4/6] fix bug --- app/controllers/exercises_controller.rb | 19 +++++++++++-------- app/services/exercise_user_pdf_service.rb | 17 +++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 720f8f593..9a46aa09b 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1512,39 +1512,42 @@ class ExercisesController < ApplicationController end def get_exercise_question_counts #获取试卷的问题数及总分数 - 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_questions = @exercise.exercise_questions + @exercise_ques_count = exercise_questions.size # 全部的题目数 @exercise_ques_scores = exercise_questions.pluck(:question_score).sum #单选题的数量及分数 exercise_single_ques = exercise_questions.find_by_custom("question_type",0) - @exercise_single_ques_count = exercise_single_ques.all.count + @exercise_single_ques_count = exercise_single_ques.size @exercise_single_ques_scores = exercise_single_ques.pluck(:question_score).sum #多选题的数量及分数 exercise_double_ques = exercise_questions.find_by_custom("question_type",1) - @exercise_double_ques_count = exercise_double_ques.all.count + @exercise_double_ques_count = exercise_double_ques.size @exercise_double_ques_scores = exercise_double_ques.pluck(:question_score).sum # 判断题数量及分数 exercise_ques_judge = exercise_questions.find_by_custom("question_type",2) - @exercise_ques_judge_count = exercise_ques_judge.all.count + @exercise_ques_judge_count = exercise_ques_judge.size @exercise_ques_judge_scores = exercise_ques_judge.pluck(:question_score).sum #填空题数量及分数 exercise_ques_null = exercise_questions.find_by_custom("question_type",3) - @exercise_ques_null_count = exercise_ques_null.all.count + @exercise_ques_null_count = exercise_ques_null.size @exercise_ques_null_scores = exercise_ques_null.pluck(:question_score).sum #简答题数量及分数 exercise_ques_main = exercise_questions.find_by_custom("question_type",4) - @exercise_ques_main_count = exercise_ques_main.all.count + @exercise_ques_main_count = exercise_ques_main.size @exercise_ques_main_scores = exercise_ques_main.pluck(:question_score).sum #实训题数量及分数 exercise_ques_shixun = exercise_questions.find_by_custom("question_type",5) - @exercise_ques_shixun_count = exercise_ques_shixun.all.count + @exercise_ques_shixun_count = exercise_ques_shixun.size @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) + end #获取用户有权限的分班 diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 8ee1d0cd4..63fbb5a1d 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -47,40 +47,41 @@ 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_ques_count = @exercise_questions.count # 全部的题目数 + @exercise_questions = exercise.exercise_questions + @exercise_ques_count = @exercise_questions.size # 全部的题目数 @exercise_ques_scores = @exercise_questions.pluck(:question_score).sum #单选题的数量及分数 exercise_single_ques = @exercise_questions.find_by_custom("question_type",0) - @exercise_single_ques_count = exercise_single_ques.all.count + @exercise_single_ques_count = exercise_single_ques.size @exercise_single_ques_scores = exercise_single_ques.pluck(:question_score).sum #多选题的数量及分数 exercise_double_ques = @exercise_questions.find_by_custom("question_type",1) - @exercise_double_ques_count = exercise_double_ques.all.count + @exercise_double_ques_count = exercise_double_ques.size @exercise_double_ques_scores = exercise_double_ques.pluck(:question_score).sum # 判断题数量及分数 exercise_ques_judge = @exercise_questions.find_by_custom("question_type",2) - @exercise_ques_judge_count = exercise_ques_judge.all.count + @exercise_ques_judge_count = exercise_ques_judge.size @exercise_ques_judge_scores = exercise_ques_judge.pluck(:question_score).sum #填空题数量及分数 exercise_ques_null = @exercise_questions.find_by_custom("question_type",3) - @exercise_ques_null_count = exercise_ques_null.all.count + @exercise_ques_null_count = exercise_ques_null.size @exercise_ques_null_scores = exercise_ques_null.pluck(:question_score).sum #简答题数量及分数 exercise_ques_main = @exercise_questions.find_by_custom("question_type",4) - @exercise_ques_main_count = exercise_ques_main.all.count + @exercise_ques_main_count = exercise_ques_main.size @exercise_ques_main_scores = exercise_ques_main.pluck(:question_score).sum #实训题数量及分数 exercise_ques_shixun = @exercise_questions.find_by_custom("question_type",5) - @exercise_ques_shixun_count = exercise_ques_shixun.all.count + @exercise_ques_shixun_count = exercise_ques_shixun.size @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 From 28b39b94f4cae61a7bf9deb8e932434e25d484ed Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 16:58:12 +0800 Subject: [PATCH 5/6] fix bug --- app/controllers/exercises_controller.rb | 2 +- app/services/exercise_user_pdf_service.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 9a46aa09b..4b96afc85 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1546,7 +1546,7 @@ class ExercisesController < ApplicationController @exercise_ques_shixun_count = exercise_ques_shixun.size @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) + @exercise_questions = @exercise_questions&.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) end diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 63fbb5a1d..22804092e 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -81,7 +81,7 @@ class ExerciseUserPdfService @exercise_ques_shixun_count = exercise_ques_shixun.size @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) + @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 From 7c1635f157fbb73172de7b5e91e9580df4993db9 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 17:02:47 +0800 Subject: [PATCH 6/6] 1 --- app/controllers/homework_commons_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 83bfd29fc..2f63f3ab9 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -1233,7 +1233,7 @@ class HomeworkCommonsController < ApplicationController # 代码查重届结果 def code_review_results # 如果有未获取结果的查重操作 则先读取结果 - get_new_code_reviews_result @homework + #get_new_code_reviews_result @homework @current_user = current_user # 列表数据