|
|
|
@ -9,11 +9,32 @@ module ExercisesHelper
|
|
|
|
|
@ex_obj_array = []
|
|
|
|
|
exercise_obj_status.each do |q|
|
|
|
|
|
if q.question_type == 5
|
|
|
|
|
ques_score = q.exercise_shixun_answers.search_shixun_answers("user_id",user_id).pluck(:score).sum
|
|
|
|
|
answers_content = q.exercise_shixun_answers.search_shixun_answers("user_id",user_id)
|
|
|
|
|
else
|
|
|
|
|
ques_score = q.exercise_answers.search_answer_users("user_id",user_id).score_reviewed.pluck(:score).sum
|
|
|
|
|
answers_content = q.exercise_answers.includes(:exercise_choices).search_answer_users("user_id",user_id)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if q.question_type <= 2
|
|
|
|
|
if answers_content.present? #学生有回答时
|
|
|
|
|
answer_choice_array = []
|
|
|
|
|
answers_content.each do |a|
|
|
|
|
|
answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置
|
|
|
|
|
end
|
|
|
|
|
user_answer_content = answer_choice_array.sort
|
|
|
|
|
standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个
|
|
|
|
|
if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分
|
|
|
|
|
ques_score = q.question_score
|
|
|
|
|
else
|
|
|
|
|
ques_score = 0.0
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
ques_score = 0.0
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
ques_score = answers_content.select(:score).pluck(:score).sum
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ques_score >= q.question_score #满分作答为正确
|
|
|
|
|
ques_score = q.question_score
|
|
|
|
|
stand_answer = 1
|
|
|
|
@ -370,7 +391,8 @@ module ExercisesHelper
|
|
|
|
|
standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个
|
|
|
|
|
if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分
|
|
|
|
|
if standard_answer.count > 0
|
|
|
|
|
q_score_1 = (q.question_score.to_f / standard_answer.count) #当多选答案正确时,每个answer的分数均摊。
|
|
|
|
|
q_score_1 = q.question_score
|
|
|
|
|
# q_score_1 = (q.question_score.to_f / standard_answer.count) #当多选答案正确时,每个answer的分数均摊。
|
|
|
|
|
else
|
|
|
|
|
q_score_1 = 0.0
|
|
|
|
|
end
|
|
|
|
|