Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

competitions
杨树林 5 years ago
commit d59072e755

@ -112,9 +112,24 @@ module ExercisesHelper
effictive_users_count = effictive_users.size #有效回答数可能有重复的用户id这里仅统计是否回答这个问题的全部人数
#
if ex.question_type > Exercise::COMPLETION #当为主观题和实训题时,
# 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 = []
@ -123,19 +138,19 @@ module ExercisesHelper
standard_answer = ex.exercise_standard_answers.pluck(:exercise_choice_id).sort #标准答案的位置
# right_users_count = 0
# 该问题的正确率
if ex.question_type == Exercise::MULTIPLE #多选题
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
right_user_ids = right_user_ids & effictive_users.select{|answer| answer.exercise_choice_id == standard_answer_choice_id}.pluck(:user_id)
end
right_users_count = right_user_ids.size
else #单选题和判断题
standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == standard_answer.first}.first&.id
right_users_count = effictive_users.select{|answer| answer.exercise_choice_id == standard_answer_choice_id}.size
end
# if ex.question_type == Exercise::MULTIPLE #多选题
# 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
# right_user_ids = right_user_ids & effictive_users.select{|answer| answer.exercise_choice_id == standard_answer_choice_id}.pluck(:user_id)
# end
# # right_users_count = right_user_ids.size
# else #单选题和判断题
# standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == standard_answer.first}.first&.id
# # right_users_count = effictive_users.select{|answer| answer.exercise_choice_id == standard_answer_choice_id}.size
# end
percent = commit_user_ids > 0 ? (right_users_count / commit_user_ids.to_f).round(3)*100 : 0.0
# percent = commit_user_ids > 0 ? (right_users_count / commit_user_ids.to_f).round(3)*100 : 0.0
#每个选项的正确率
ex_choices.each do |c|
@ -181,7 +196,7 @@ module ExercisesHelper
all_user_count += user_count
standard_answer_count += 1
end
percent = commit_user_ids > 0 ? (all_user_count / commit_user_ids.to_f).round(3)*100 : 0.0
# 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 )

Loading…
Cancel
Save