|
|
@ -84,12 +84,12 @@ module ExercisesHelper
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#试卷的统计结果页面计算各题的
|
|
|
|
#试卷的统计结果页面计算各题的
|
|
|
|
def exercise_commit_result(questions,user_ids,commit_users)
|
|
|
|
def exercise_commit_result(questions,user_ids)
|
|
|
|
question_infos = []
|
|
|
|
question_infos = []
|
|
|
|
percent = 0.0
|
|
|
|
percent = 0.0
|
|
|
|
questions.each do |ex|
|
|
|
|
questions.each do |ex|
|
|
|
|
ex_total_score = user_ids.count * ex&.question_score #该试卷的已回答的总分
|
|
|
|
ex_total_score = user_ids.count * ex&.question_score #该试卷的已回答的总分
|
|
|
|
ex_answers = ex.exercise_answers
|
|
|
|
ex_answers = ex.exercise_answers.includes(:exercise_choice)
|
|
|
|
if ex.question_type != Exercise::PRACTICAL
|
|
|
|
if ex.question_type != Exercise::PRACTICAL
|
|
|
|
ques_title = ex.question_title
|
|
|
|
ques_title = ex.question_title
|
|
|
|
ques_less_title = nil
|
|
|
|
ques_less_title = nil
|
|
|
@ -115,14 +115,15 @@ module ExercisesHelper
|
|
|
|
right_users_count = 0 #该问题的回答正确的人数
|
|
|
|
right_users_count = 0 #该问题的回答正确的人数
|
|
|
|
|
|
|
|
|
|
|
|
#计算每个问题的答案人数
|
|
|
|
#计算每个问题的答案人数
|
|
|
|
commit_users.transaction do
|
|
|
|
# commit_users.transaction do
|
|
|
|
commit_users.each do |user|
|
|
|
|
#
|
|
|
|
answer_choice_array = effictive_users.select(:user_id,:exercise_choice_id).where(user_id:user.user_id)&.map {|s| s.exercise_choice.choice_position}.uniq
|
|
|
|
# end
|
|
|
|
|
|
|
|
user_ids.each do |user_id|
|
|
|
|
|
|
|
|
answer_choice_array = effictive_users.select(:user_id,:exercise_choice_id).find(user_id:user_id)&.map {|s| s.exercise_choice.choice_position}.uniq
|
|
|
|
if answer_choice_array.sort == standard_answer
|
|
|
|
if answer_choice_array.sort == standard_answer
|
|
|
|
right_users_count += 1
|
|
|
|
right_users_count += 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
percent = effictive_users_count > 0 ? (right_users_count / effictive_users_count.to_f).round(3)*100 : 0.0
|
|
|
|
percent = effictive_users_count > 0 ? (right_users_count / effictive_users_count.to_f).round(3)*100 : 0.0
|
|
|
|
ex.exercise_choices.each do |c|
|
|
|
|
ex.exercise_choices.each do |c|
|
|
|
|
right_answer = standard_answer.include?(c.choice_position) #选项的标准答案为选项的位置
|
|
|
|
right_answer = standard_answer.include?(c.choice_position) #选项的标准答案为选项的位置
|
|
|
|