试卷的填空题出现9.9

competitions
SylorHuang 5 years ago
parent 7a29209131
commit 49bf8e87c7

@ -800,8 +800,18 @@ module ExercisesHelper
user_score_pre = exercise_answers.select{|answer| answer.score >= 0.0}
if ques_type == 4 #主观题时且没有大于0的分数时为空
user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : nil
elsif ques_type == 5 || ques_type == 3
elsif ques_type == 5
user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : 0.0
elsif ques_type == 3 #填空题时需小心出现9.9分
user_score_pluck = user_score_pre.present? ? user_score_pre.pluck(:score).sum : 0.0
if user_score_pluck > 0.0
if user_score_pluck.to_s.split(".").last == "9"
user_score = user_score_pluck.to_f + 0.1
end
else
user_score = user_score_pluck
end
# user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : 0.0
else #选择题,判断题根据第一个记录查分
user_score = user_score_pre.present? ? user_score_pre.first.score : 0.0

Loading…
Cancel
Save