|
|
|
@ -185,16 +185,19 @@ module ExercisesHelper
|
|
|
|
|
standard_answer_count = 0
|
|
|
|
|
each_null_score = null_stand_choice.size > 0 ? (ex&.question_score.to_f / null_stand_choice.uniq.size).round(3) : 0.0
|
|
|
|
|
all_user_count = 0
|
|
|
|
|
|
|
|
|
|
if ex_ordered
|
|
|
|
|
null_stand_choice.each_with_index do |s,index|
|
|
|
|
|
user_count = 0
|
|
|
|
|
if ex_ordered #有序排列
|
|
|
|
|
s_choice_text = null_stand_text[index]
|
|
|
|
|
user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.size
|
|
|
|
|
else
|
|
|
|
|
null_stand_text = null_stand_text.uniq
|
|
|
|
|
s_choice_text = null_stand_text[index]
|
|
|
|
|
user_count = user_count + effictive_users.select{|answer| answer.answer_text == s_choice_text }.size #回答了标准答案的用户
|
|
|
|
|
end
|
|
|
|
|
# if ex_ordered #有序排列,或者有重复答案的时候,不按无序排列
|
|
|
|
|
#
|
|
|
|
|
# else
|
|
|
|
|
# # null_stand_text = null_stand_text.uniq
|
|
|
|
|
# s_choice_text = null_stand_text[index]
|
|
|
|
|
# user_count = user_count + effictive_users.select{|answer| answer.answer_text == s_choice_text }.size #回答了标准答案的用户
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
answer_percent = ((effictive_users_count == 0) ? 0.0 : (user_count / effictive_users_count.to_f ).round(3))
|
|
|
|
|
answer_option = {
|
|
|
|
@ -208,6 +211,57 @@ module ExercisesHelper
|
|
|
|
|
all_user_count += user_count
|
|
|
|
|
standard_answer_count += 1
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
cycled_stand = {}
|
|
|
|
|
null_stand_text.each_with_index do |stand, index|
|
|
|
|
|
user_count = 0
|
|
|
|
|
if cycled_stand.length > 0 && cycled_stand.keys.include?(stand)
|
|
|
|
|
cycled_stand.store(stand, cycled_stand["#{stand}"])
|
|
|
|
|
user_count = cycled_stand["#{stand}"]
|
|
|
|
|
calculate_user_count = 0
|
|
|
|
|
else
|
|
|
|
|
user_count = user_count + effictive_users.select{|answer| answer.answer_text == stand }.size
|
|
|
|
|
cycled_stand.store(stand, user_count)
|
|
|
|
|
calculate_user_count = user_count
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
answer_percent = ((effictive_users_count == 0) ? 0.0 : (user_count / effictive_users_count.to_f ).round(3))
|
|
|
|
|
answer_option = {
|
|
|
|
|
:choice_position => index+1,
|
|
|
|
|
:choice_text => stand,
|
|
|
|
|
:choice_users_count => user_count,
|
|
|
|
|
:choice_percent => answer_percent.round(2).to_s,
|
|
|
|
|
:right_answer => true
|
|
|
|
|
}
|
|
|
|
|
question_answer_infos.push(answer_option)
|
|
|
|
|
all_user_count += calculate_user_count
|
|
|
|
|
standard_answer_count += 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# null_stand_choice.each_with_index do |s,index|
|
|
|
|
|
# user_count = 0
|
|
|
|
|
# if ex_ordered #有序排列,或者有重复答案的时候,不按无序排列
|
|
|
|
|
# s_choice_text = null_stand_text[index]
|
|
|
|
|
# user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.size
|
|
|
|
|
# else
|
|
|
|
|
# # null_stand_text = null_stand_text.uniq
|
|
|
|
|
# s_choice_text = null_stand_text[index]
|
|
|
|
|
# user_count = user_count + effictive_users.select{|answer| answer.answer_text == s_choice_text }.size #回答了标准答案的用户
|
|
|
|
|
# end
|
|
|
|
|
#
|
|
|
|
|
# answer_percent = ((effictive_users_count == 0) ? 0.0 : (user_count / effictive_users_count.to_f ).round(3))
|
|
|
|
|
# answer_option = {
|
|
|
|
|
# :choice_position => index+1,
|
|
|
|
|
# :choice_text => s_choice_text,
|
|
|
|
|
# :choice_users_count => user_count,
|
|
|
|
|
# :choice_percent => answer_percent.round(2).to_s,
|
|
|
|
|
# :right_answer => true
|
|
|
|
|
# }
|
|
|
|
|
# question_answer_infos.push(answer_option)
|
|
|
|
|
# all_user_count += user_count
|
|
|
|
|
# standard_answer_count += 1
|
|
|
|
|
# end
|
|
|
|
|
answer_user_score = all_user_count * each_null_score
|
|
|
|
|
percent = (ex_total_score == 0.0 ? 0.0 : (answer_user_score / ex_total_score.to_f).round(3) * 100) #正确率
|
|
|
|
|
|
|
|
|
|