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 # 列表数据 diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 24c5066e5..a4a3b7222 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -262,7 +262,6 @@ class MyshixunsController < ApplicationController unless @hide_code # 远程版本库文件内容 last_content = GitService.file_content(repo_path: @repo_path, path: path)["content"] - content = params[:content] if content != last_content diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 6ec6cd601..04890954b 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 @@ -641,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) 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