|
|
|
@ -541,6 +541,7 @@ class ExerciseQuestionsController < ApplicationController
|
|
|
|
|
ex_answer_old = ex_answers.score_reviewed.pluck(:score).sum #每一关的得分总和
|
|
|
|
|
each_right_score = (@c_score / ex_answers.count.to_f) #调分后,平均每关的分数
|
|
|
|
|
new_obj_score = ex_obj_score - ex_answer_old + @c_score
|
|
|
|
|
ex_answers.update_all(:score => each_right_score) #所有的正确选项需重新更新
|
|
|
|
|
else #如果学生未答,则创建新的答题记录
|
|
|
|
|
answer_option = {
|
|
|
|
|
:user_id => @user_id,
|
|
|
|
@ -549,7 +550,7 @@ class ExerciseQuestionsController < ApplicationController
|
|
|
|
|
:answer_text => ""
|
|
|
|
|
}
|
|
|
|
|
ExerciseAnswer.create(answer_option)
|
|
|
|
|
new_obj_score = ex_subj_score + @c_score
|
|
|
|
|
new_obj_score = ex_obj_score + @c_score
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
total_scores = new_obj_score + ex_subj_score
|
|
|
|
@ -558,7 +559,6 @@ class ExerciseQuestionsController < ApplicationController
|
|
|
|
|
:score => total_scores
|
|
|
|
|
}
|
|
|
|
|
@exercise_current_user.update_attributes(ex_scores)
|
|
|
|
|
ex_answers.update_all(:score => each_right_score) #所有的正确选项需重新更新
|
|
|
|
|
elsif @exercise_question.question_type == Exercise::SUBJECTIVE #当为主观题时
|
|
|
|
|
if ex_answers.exists?
|
|
|
|
|
ex_answers_old_score = ex_answers.first.score > 0.0 ? ex_answers.first.score : 0.0 #原分数小于0,取0
|
|
|
|
|