|
|
|
@ -120,21 +120,7 @@ module ExercisesHelper
|
|
|
|
|
if ex.question_type > Exercise::COMPLETION #当为主观题和实训题时,
|
|
|
|
|
ex_answered_scores = effictive_users.score_reviewed.pluck(:score).sum #该问题的全部得分
|
|
|
|
|
percent = (ex_total_score == 0.0 ? 0.0 : (ex_answered_scores / ex_total_score.to_f).round(3) * 100) #正确率
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# if ex.question_type != Exercise::MULTIPLE
|
|
|
|
|
# ex_answered_scores = effictive_users.score_reviewed.pluck(:score).sum #该问题的全部得分
|
|
|
|
|
# percent = (ex_total_score == 0.0 ? 0.0 : (ex_answered_scores / ex_total_score.to_f).round(3) * 100) #正确率
|
|
|
|
|
# else
|
|
|
|
|
# multiple_score = 0
|
|
|
|
|
# user_ids.each do |user_id|
|
|
|
|
|
# ex_answer_score = ex_answers.select{|answer| answer.user_id == user_id}&.first&.score.to_f
|
|
|
|
|
# multiple_score += ex_answer_score
|
|
|
|
|
# end
|
|
|
|
|
# percent = (ex_total_score == 0.0 ? 0.0 : (multiple_score / ex_total_score.to_f).round(3) * 100) #正确率
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
question_answer_infos = []
|
|
|
|
|
if ex.question_type <= Exercise::JUDGMENT #选择题和判断题
|
|
|
|
|
ex_choices = ex.exercise_choices
|
|
|
|
@ -178,19 +164,22 @@ module ExercisesHelper
|
|
|
|
|
question_answer_infos.push(answer_option)
|
|
|
|
|
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
|
|
|
|
|
null_stand_text = null_standard_answer.pluck(:answer_text).reject(&:blank?)
|
|
|
|
|
null_stand_text = null_standard_answer.pluck(:answer_text)
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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.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,
|
|
|
|
@ -212,7 +201,7 @@ module ExercisesHelper
|
|
|
|
|
user_count = cycled_stand["#{stand}"]
|
|
|
|
|
calculate_user_count = 0
|
|
|
|
|
else
|
|
|
|
|
user_count = user_count + effictive_users.select{|answer| answer.answer_text == stand }.size
|
|
|
|
|
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
|
|
|
|
|