填空题调分

dev_cs
cxt 5 years ago
parent a10910824e
commit 905c5b9d53

@ -515,7 +515,15 @@ class ExerciseQuestionsController < ApplicationController
else # 新多选题只需取第一条答题记录的得分
ex_answer_old = ex_answers.first.score > 0 ? ex_answers.first.score : 0
end
ex_answers.update_all(:score => @c_score) #所有的正确选项需重新更新
else
answer_option = {
:user_id => @user_id,
:exercise_question_id => @exercise_question.id,
:score => @c_score,
:answer_text => ""
}
ExerciseAnswer.create(answer_option)
ex_answer_old = 0
end
@ -526,12 +534,24 @@ class ExerciseQuestionsController < ApplicationController
:score => total_scores
}
@exercise_current_user.update_attributes(ex_scores)
ex_answers.update_all(:score => @c_score) #所有的正确选项需重新更新
elsif @exercise_question.question_type == Exercise::COMPLETION #当为填空题,更新问题的总分,
if ex_answers.exists?
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
else #如果学生未答,则创建新的答题记录
answer_option = {
:user_id => @user_id,
:exercise_question_id => @exercise_question.id,
:score => @c_score,
:answer_text => ""
}
ExerciseAnswer.create(answer_option)
new_obj_score = ex_subj_score + @c_score
end
total_scores = new_obj_score + ex_subj_score
ex_scores = {
:objective_score => new_obj_score,

Loading…
Cancel
Save