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