From 48bf9693d87b9f21a819bc210cb752a010c40376 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 09:19:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=9E=E8=AE=AD=E9=A2=98?= =?UTF-8?q?=E6=9C=AA=E9=80=9A=E5=85=B3=E6=98=BE=E7=A4=BA=E5=85=B3=E5=8D=A1?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_questions_controller.rb | 2 +- .../exercise_questions/_exercise_questions.json.jbuilder | 2 +- app/views/exercises/_shixun_details.json.jbuilder | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb index dd0247f70..79d671605 100644 --- a/app/controllers/exercise_questions_controller.rb +++ b/app/controllers/exercise_questions_controller.rb @@ -640,7 +640,7 @@ class ExerciseQuestionsController < ApplicationController if @exercise.exercise_status != 1 question_score = @exercise_question.question_score #原来的分数 update_question_score = params[:question_score].to_f.round(1) #传入的分数 - choices_count = @exercise_question.exercise_choices.count #原来的选项个数 + choices_count = @exercise_question.exercise_choices.size #原来的选项个数 exercise_choice_ids = @exercise_question.exercise_standard_answers.pluck(:exercise_choice_id).uniq standard_answers_text = @exercise_question.exercise_standard_answers.pluck(:answer_text).uniq update_choices_count = params[:question_choices].present? ? params[:question_choices].count : choices_count #传入的选项个数 diff --git a/app/views/exercise_questions/_exercise_questions.json.jbuilder b/app/views/exercise_questions/_exercise_questions.json.jbuilder index 9445862ba..4e05ffb7a 100644 --- a/app/views/exercise_questions/_exercise_questions.json.jbuilder +++ b/app/views/exercise_questions/_exercise_questions.json.jbuilder @@ -86,7 +86,7 @@ elsif question.question_type == 5 user_get_score = games_score[:s_score].present? ? games_score[:s_score] : 0.0 json.shixun_challenge_id s.id if games_score[:games].count > 0 - json.partial! "exercises/shixun_details",games: games_score[:games], user_score: user_get_score,game_score: games_score[:game_score] + json.partial! "exercises/shixun_details",games: games_score[:games], user_score: user_get_score,game_score: games_score[:game_score],shixun_challenge:s else json.partial! "exercises/shixun_undo",games: [s], user_score: user_get_score ,game_score: s.question_score end diff --git a/app/views/exercises/_shixun_details.json.jbuilder b/app/views/exercises/_shixun_details.json.jbuilder index c788b8c1c..a28bf4145 100644 --- a/app/views/exercises/_shixun_details.json.jbuilder +++ b/app/views/exercises/_shixun_details.json.jbuilder @@ -26,6 +26,13 @@ json.shixun_detail do json.position output.query_index json.output_detail output_detail game, output end - json.passed_code game.try(:lastest_code) + + if game.try(:lastest_code).blank? + cha_path = challenge_path(shixun_challenge.challenge&.path) + latest_code = git_fle_content(shixun_challenge.shixun&.repo_path,cha_path) + else + latest_code = game.try(:lastest_code) + end + json.passed_code latest_code end end \ No newline at end of file