From 538efef33aa40d3483da58d57bd933c569e1a48d Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 29 Jun 2019 11:18:59 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9F=A5=E9=87=8D?= =?UTF-8?q?=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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 2a1dfb14a..c3bd777ae 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -1326,7 +1326,7 @@ class HomeworkCommonsController < ApplicationController # 代码查重届结果 def code_review_results # 如果有未获取结果的查重操作 则先读取结果 - #get_new_code_reviews_result @homework + get_new_code_reviews_result @homework @current_user = current_user # 列表数据 From 9d7d609bb5ebfa4d573dc6be55582653f445a0d3 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 11:28:36 +0800 Subject: [PATCH 2/7] fix bug --- app/helpers/exercises_helper.rb | 11 ++++++----- .../_exercise_questions.json.jbuilder | 6 +++++- app/views/exercises/_shixun_details.json.jbuilder | 13 ++++++++----- .../exercises/_user_exercise_info.json.jbuilder | 2 +- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 6ec6cd601..68f6574ee 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -429,11 +429,9 @@ module ExercisesHelper answer_status = 1 end ex_shixun_answer_content = answers_content&.where(exercise_shixun_challenge_id: exercise_cha.id) - if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里 - logger.info("############_________exercise_cha.challenge&.path___________###############{exercise_cha.challenge&.path}") + code = nil + if exercise_cha.challenge&.path.present? cha_path = challenge_path(exercise_cha.challenge&.path) - logger.info("############_________cha_path___________###############{cha_path}") - game_challenge = game.game_codes.search_challenge_path(cha_path)&.first if game_challenge.present? game_code = game_challenge @@ -441,6 +439,9 @@ module ExercisesHelper else code = git_fle_content(game.myshixun.repo_path,cha_path) end + end + if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里 + ### Todo 实训题的_shixun_details里的代码是不是直接从这里取出就可以了?涉及到code的多个版本库的修改 sx_option = { :exercise_question_id => q.id, :exercise_shixun_challenge_id => exercise_cha.id, @@ -451,7 +452,7 @@ module ExercisesHelper } ExerciseShixunAnswer.create(sx_option) else - ex_shixun_answer_content.first.update_column('score',exercise_cha_score) + ex_shixun_answer_content.first.update_attributes(score:exercise_cha_score.round(1),answer_text:code) end score5 += exercise_cha_score else diff --git a/app/views/exercise_questions/_exercise_questions.json.jbuilder b/app/views/exercise_questions/_exercise_questions.json.jbuilder index 4e05ffb7a..4cdd97f3c 100644 --- a/app/views/exercise_questions/_exercise_questions.json.jbuilder +++ b/app/views/exercise_questions/_exercise_questions.json.jbuilder @@ -1,6 +1,10 @@ json.question_id question.id # json.question_number question.question_number -json.q_position ques_position.present? ? ques_position : question.question_number +q_positon = question.question_number +if ques_position.present? + q_positon = ques_position +end +json.q_position q_positon json.question_title question.question_title json.question_type question.question_type json.question_score question.question_score.round(1).to_s diff --git a/app/views/exercises/_shixun_details.json.jbuilder b/app/views/exercises/_shixun_details.json.jbuilder index 85bf532e1..4a73a9bbb 100644 --- a/app/views/exercises/_shixun_details.json.jbuilder +++ b/app/views/exercises/_shixun_details.json.jbuilder @@ -27,11 +27,14 @@ json.shixun_detail do json.output_detail output_detail game, output end - if game.try(:lastest_code).blank? - cha_path = challenge_path(shixun_challenge.challenge&.path) - latest_code = git_fle_content(game.myshixun.repo_path,cha_path) - else - latest_code = game.try(:lastest_code) + latest_code = nil + if shixun_challenge.challenge&.path.present? + if game.try(:lastest_code).blank? + cha_path = challenge_path(shixun_challenge.challenge&.path) + latest_code = git_fle_content(game.myshixun.repo_path,cha_path) + else + latest_code = game.try(:lastest_code) + end end json.passed_code latest_code diff --git a/app/views/exercises/_user_exercise_info.json.jbuilder b/app/views/exercises/_user_exercise_info.json.jbuilder index 1ff929897..cba07fb3f 100644 --- a/app/views/exercises/_user_exercise_info.json.jbuilder +++ b/app/views/exercises/_user_exercise_info.json.jbuilder @@ -62,7 +62,7 @@ json.exercise_questions do exercise_type: ex_type, user_answer: user_ques_answers[:answered_content], shixun_type: user_ques_answers[:shixun_type], - ques_position:nil + ques_position: nil if user_ques_comments.count > 0 json.question_comments do json.partial! "exercises/exercise_comments", question_comment:user_ques_answers[:question_comment].first From 16dba624008e84859976f2223f4b094faea942a9 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 11:31:54 +0800 Subject: [PATCH 3/7] fix bug --- app/views/exercise_questions/_exercise_questions.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/exercise_questions/_exercise_questions.json.jbuilder b/app/views/exercise_questions/_exercise_questions.json.jbuilder index 4cdd97f3c..ce8d0f1f2 100644 --- a/app/views/exercise_questions/_exercise_questions.json.jbuilder +++ b/app/views/exercise_questions/_exercise_questions.json.jbuilder @@ -4,7 +4,7 @@ q_positon = question.question_number if ques_position.present? q_positon = ques_position end -json.q_position q_positon +json.q_position question.question_number json.question_title question.question_title json.question_type question.question_type json.question_score question.question_score.round(1).to_s From 0ec0e612fa4d568db685c4c5b4df884ddff5d6dd Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 11:41:10 +0800 Subject: [PATCH 4/7] fix bug --- app/views/exercise_questions/_exercise_questions.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/exercise_questions/_exercise_questions.json.jbuilder b/app/views/exercise_questions/_exercise_questions.json.jbuilder index ce8d0f1f2..4cdd97f3c 100644 --- a/app/views/exercise_questions/_exercise_questions.json.jbuilder +++ b/app/views/exercise_questions/_exercise_questions.json.jbuilder @@ -4,7 +4,7 @@ q_positon = question.question_number if ques_position.present? q_positon = ques_position end -json.q_position question.question_number +json.q_position q_positon json.question_title question.question_title json.question_type question.question_type json.question_score question.question_score.round(1).to_s From da2c9c97c263743af8c3a6238ff63f9cede3a36b Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 12:29:14 +0800 Subject: [PATCH 5/7] fix bug --- app/helpers/exercises_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 68f6574ee..72fbc9486 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -642,7 +642,7 @@ module ExercisesHelper end if student_status == 2 #当前为老师,或为学生且已提交 user_score_pre = exercise_answers.score_reviewed - user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : nil + user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : "0.0" end if user_score.present? && (user_score > q.question_score) From 8dd42b59a7237468f4c0c72487032e9293f82b2c Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 12:30:32 +0800 Subject: [PATCH 6/7] fix bug --- app/helpers/exercises_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 72fbc9486..04890954b 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -642,7 +642,7 @@ module ExercisesHelper end if student_status == 2 #当前为老师,或为学生且已提交 user_score_pre = exercise_answers.score_reviewed - user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : "0.0" + user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : 0.0 end if user_score.present? && (user_score > q.question_score) From 079d757021b4678302f9e34832117f6222baf709 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 29 Jun 2019 14:17:43 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 035b43955..8629083dd 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -260,12 +260,12 @@ class MyshixunsController < ApplicationController unless @hide_code # 远程版本库文件内容 last_content = GitService.file_content(repo_path: @repo_path, path: path)["content"] - - content = if @myshixun.mirror_name.select{|a| a.include?("MachineLearning") || a.include?("Python")}.present? && params[:content].present? - params[:content].gsub(/\t/, ' ') - else - params[:content] - end + content = params[:content] + # content = if @myshixun.mirror_name.select{|a| a.include?("MachineLearning") || a.include?("Python")}.present? && params[:content].present? + # params[:content].gsub(/\t/, ' ') + # else + # params[:content] + # end if content != last_content @content_modified = 1