dev_forum
SylorHuang 6 years ago
parent e30854131c
commit 804fc5eea2

@ -1385,7 +1385,7 @@ class ExercisesController < ApplicationController
@paging_type = params[:sort].to_s
end
ques_result_all = exercise_commit_result(@exercise_questions,@exercise_commit_user_ids)
ques_result_all = exercise_commit_result(@exercise_questions,@exercise_commit_user_ids,@exercise_commit_users)
if @paging_type == "percent"
@question_result_hash = ques_result_all.sort_by{|s| s[:percent]}

@ -84,7 +84,7 @@ module ExercisesHelper
end
#试卷的统计结果页面计算各题的
def exercise_commit_result(questions,user_ids)
def exercise_commit_result(questions,user_ids,commit_users)
question_infos = []
percent = 0.0
questions.each do |ex|
@ -115,9 +115,9 @@ module ExercisesHelper
right_users_count = 0 #该问题的回答正确的人数
#计算每个问题的答案人数
effictive_users.transaction do
user_ids.each do |user_id|
answer_choice_array = effictive_users.where(user_id:user_id)&.map {|s| s.exercise_choice.choice_position}.uniq
commit_users.transaction do
commit_users.each do |user|
answer_choice_array = effictive_users.select(:user_id).where(user_id:user.user_id)&.map {|s| s.exercise_choice.choice_position}.uniq
if answer_choice_array.sort == standard_answer
right_users_count += 1
end

Loading…
Cancel
Save