|
|
|
@ -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,
|
|
|
|
|