dev_cs
SylorHuang 5 years ago
parent d42b73ce26
commit d2e4497821

@ -494,6 +494,7 @@ class ExerciseQuestionsController < ApplicationController
def adjust_score def adjust_score
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
ex_all_scores = @exercise.exercise_questions.pluck(:question_score).sum
ex_obj_score = @exercise_current_user.objective_score #全部客观题得分 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_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) #当前用户答案的得分 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 total_scores = new_obj_score + ex_subj_score
if total_scores < 0.0 if total_scores < 0.0
total_scores = 0.0 total_scores = 0.0
elsif total_scores > @exercise.score elsif total_scores > ex_all_scores
total_scores = @exercise.score total_scores = ex_all_scores
end end
ex_scores = { ex_scores = {
:objective_score => new_obj_score, :objective_score => new_obj_score,
@ -567,8 +568,8 @@ class ExerciseQuestionsController < ApplicationController
total_scores = new_obj_score + ex_subj_score total_scores = new_obj_score + ex_subj_score
if total_scores < 0.0 if total_scores < 0.0
total_scores = 0.0 total_scores = 0.0
elsif total_scores > @exercise.score elsif total_scores > ex_all_scores
total_scores = @exercise.score total_scores = ex_all_scores
end end
ex_scores = { ex_scores = {
:objective_score => new_obj_score, :objective_score => new_obj_score,
@ -593,8 +594,8 @@ class ExerciseQuestionsController < ApplicationController
total_scores = ex_obj_score + new_sub_score total_scores = ex_obj_score + new_sub_score
if total_scores < 0.0 if total_scores < 0.0
total_scores = 0.0 total_scores = 0.0
elsif total_scores > @exercise.score elsif total_scores > ex_all_scores
total_scores = @exercise.score total_scores = ex_all_scores
end end
ex_scores = { ex_scores = {
:subjective_score => new_sub_score, :subjective_score => new_sub_score,
@ -623,8 +624,8 @@ class ExerciseQuestionsController < ApplicationController
total_scores = new_obj_score + ex_subj_score total_scores = new_obj_score + ex_subj_score
if total_scores < 0.0 if total_scores < 0.0
total_scores = 0.0 total_scores = 0.0
elsif total_scores > @exercise.score elsif total_scores > ex_all_scores
total_scores = @exercise.score total_scores = ex_all_scores
end end
ex_scores = { ex_scores = {
:objective_score => new_obj_score, :objective_score => new_obj_score,

Loading…
Cancel
Save