From d2e449782132a8aab5fb4551741a67771c8e4949 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 12 Sep 2019 16:47:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=84=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exercise_questions_controller.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb index 14d2bdbd0..bb28fff54 100644 --- a/app/controllers/exercise_questions_controller.rb +++ b/app/controllers/exercise_questions_controller.rb @@ -494,6 +494,7 @@ class ExerciseQuestionsController < ApplicationController def adjust_score ActiveRecord::Base.transaction do begin + ex_all_scores = @exercise.exercise_questions.pluck(:question_score).sum ex_obj_score = @exercise_current_user.objective_score #全部客观题得分 ex_subj_score = @exercise_current_user.subjective_score < 0.0 ? 0.0 : @exercise_current_user.subjective_score #全部主观题得分 ex_answers = @exercise_question.exercise_answers.search_answer_users("user_id",@user_id) #当前用户答案的得分 @@ -537,8 +538,8 @@ class ExerciseQuestionsController < ApplicationController total_scores = new_obj_score + ex_subj_score if total_scores < 0.0 total_scores = 0.0 - elsif total_scores > @exercise.score - total_scores = @exercise.score + elsif total_scores > ex_all_scores + total_scores = ex_all_scores end ex_scores = { :objective_score => new_obj_score, @@ -567,8 +568,8 @@ class ExerciseQuestionsController < ApplicationController total_scores = new_obj_score + ex_subj_score if total_scores < 0.0 total_scores = 0.0 - elsif total_scores > @exercise.score - total_scores = @exercise.score + elsif total_scores > ex_all_scores + total_scores = ex_all_scores end ex_scores = { :objective_score => new_obj_score, @@ -593,8 +594,8 @@ class ExerciseQuestionsController < ApplicationController total_scores = ex_obj_score + new_sub_score if total_scores < 0.0 total_scores = 0.0 - elsif total_scores > @exercise.score - total_scores = @exercise.score + elsif total_scores > ex_all_scores + total_scores = ex_all_scores end ex_scores = { :subjective_score => new_sub_score, @@ -623,8 +624,8 @@ class ExerciseQuestionsController < ApplicationController total_scores = new_obj_score + ex_subj_score if total_scores < 0.0 total_scores = 0.0 - elsif total_scores > @exercise.score - total_scores = @exercise.score + elsif total_scores > ex_all_scores + total_scores = ex_all_scores end ex_scores = { :objective_score => new_obj_score,