|
|
|
@ -165,7 +165,6 @@ module ExercisesHelper
|
|
|
|
|
end
|
|
|
|
|
elsif ex.question_type == Exercise::COMPLETION #填空题
|
|
|
|
|
effictive_users_count = effictive_users.pluck(:user_id).uniq.size
|
|
|
|
|
|
|
|
|
|
ex_ordered = ex.is_ordered
|
|
|
|
|
null_standard_answer = ex.exercise_standard_answers
|
|
|
|
|
null_stand_choice = null_standard_answer.pluck(:exercise_choice_id) #一个exercise_choice_id可能对应多个answer_text
|
|
|
|
@ -178,7 +177,7 @@ module ExercisesHelper
|
|
|
|
|
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.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.pluck(:user_id).uniq.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 = {
|
|
|
|
@ -196,19 +195,7 @@ module ExercisesHelper
|
|
|
|
|
# cycled_stand = {}
|
|
|
|
|
null_stand_text.uniq.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 }.pluck(:user_id).uniq.size
|
|
|
|
|
# cycled_stand.store(stand, user_count)
|
|
|
|
|
# calculate_user_count = user_count
|
|
|
|
|
# end
|
|
|
|
|
user_count = user_count + effictive_users.select{|answer| answer.answer_text == stand }.pluck(:user_id).uniq.size
|
|
|
|
|
# cycled_stand.store(stand, user_count)
|
|
|
|
|
# calculate_user_count = user_count
|
|
|
|
|
|
|
|
|
|
user_count = user_count + effictive_users.where("answer_text = ?",stand).pluck(:user_id).uniq.size
|
|
|
|
|
answer_percent = ((effictive_users_count == 0) ? 0.0 : (user_count / effictive_users_count.to_f ).round(3))
|
|
|
|
|
answer_option = {
|
|
|
|
|
:choice_position => index+1,
|
|
|
|
@ -227,7 +214,7 @@ module ExercisesHelper
|
|
|
|
|
|
|
|
|
|
# percent = commit_user_ids > 0 ? (all_user_count / commit_user_ids.to_f).round(3)*100 : 0.0
|
|
|
|
|
|
|
|
|
|
user_wrong_count = (effictive_users_count - all_user_count)
|
|
|
|
|
user_wrong_count = effictive_users.where("score < 0").size
|
|
|
|
|
|
|
|
|
|
if effictive_users_count > 0 && user_wrong_count >= 0
|
|
|
|
|
wrong_percent = (user_wrong_count / effictive_users_count.to_f ).round(3)
|
|
|
|
|