|
|
|
@ -175,16 +175,18 @@ module ExercisesHelper
|
|
|
|
|
all_user_count = 0
|
|
|
|
|
|
|
|
|
|
if ex_ordered
|
|
|
|
|
all_null_stand_choice = null_standard_answer.pluck(:exercise_choice_id,:answer_text)
|
|
|
|
|
all_null_stand_choice.each_with_index do |s,index|
|
|
|
|
|
# s_choice_text = null_stand_text[index]
|
|
|
|
|
all_user_answers = effictive_users.pluck(:answer_text)
|
|
|
|
|
null_stand_choice.each_with_index do |s,index|
|
|
|
|
|
s_choice_text = null_stand_text[index]
|
|
|
|
|
user_count = 0
|
|
|
|
|
user_count = user_count + effictive_users.where("exercise_choice_id = ? and answer_text = ?",s[0],s[1]).pluck(:user_id).uniq.size
|
|
|
|
|
user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.size
|
|
|
|
|
|
|
|
|
|
# user_count = user_count + effictive_users.where("exercise_choice_id = ? and answer_text = ?",s,s_choice_text).pluck(:user_id).uniq.size
|
|
|
|
|
# user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.size
|
|
|
|
|
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[1],
|
|
|
|
|
:choice_text => s_choice_text,
|
|
|
|
|
:choice_users_count => user_count,
|
|
|
|
|
:choice_percent => answer_percent.round(2).to_s,
|
|
|
|
|
:right_answer => true
|
|
|
|
@ -192,6 +194,7 @@ module ExercisesHelper
|
|
|
|
|
question_answer_infos.push(answer_option)
|
|
|
|
|
all_user_count += user_count
|
|
|
|
|
standard_answer_count += 1
|
|
|
|
|
all_user_answers = all_user_answers - [s]
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
# cycled_stand = {}
|
|
|
|
|