试卷统计结果页面的多选题标准答案的显示

issues25489
SylorHuang 5 years ago
parent 9306fa3378
commit 25b4a07315

@ -142,6 +142,9 @@ module ExercisesHelper
right_users_count = 0
#该问题的正确率
if ex.question_type == Exercise::MULTIPLE #多选题
if standard_answer.size == 1 #以前的多选题答案存在一个表里
standard_answer = standard_answer.first.to_s.split("").map(&:to_i)
end
right_user_ids = user_ids
standard_answer.each do |choice_position|
standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == choice_position}.first&.id
@ -160,12 +163,7 @@ module ExercisesHelper
#每个选项的正确率
ex_choices.each do |c|
Rails.logger.info("######________c__________#############{c}")
Rails.logger.info("######________standard_answer__________#############{standard_answer}")
right_answer = standard_answer.include?(c.choice_position) #选项的标准答案为选项的位置
Rails.logger.info("######_______right_answer__________#############{right_answer}")
answer_users_count = effictive_users.select{|answer| answer.exercise_choice_id == c.id}.size
answer_percent = (effictive_users_count == 0 ? 0.0 : (answer_users_count / effictive_users_count.to_f ).round(3))

Loading…
Cancel
Save