|
|
|
@ -88,8 +88,8 @@ module ExercisesHelper
|
|
|
|
|
question_infos = []
|
|
|
|
|
percent = 0.0
|
|
|
|
|
questions.includes(:exercise_choices).each do |ex|
|
|
|
|
|
ex_total_score = user_ids.count * ex&.question_score #该试卷的已回答的总分
|
|
|
|
|
ex_answers = ex.exercise_answers
|
|
|
|
|
ex_total_score = user_ids.count * ex&.question_score.to_f #该试卷的已回答的总分
|
|
|
|
|
# ex_answers = ex.exercise_answers
|
|
|
|
|
if ex.question_type != Exercise::PRACTICAL
|
|
|
|
|
ques_title = ex.question_title
|
|
|
|
|
ques_less_title = nil
|
|
|
|
@ -98,23 +98,23 @@ module ExercisesHelper
|
|
|
|
|
else
|
|
|
|
|
ques_title = ex.shixun.name
|
|
|
|
|
ques_less_title = ex.question_title
|
|
|
|
|
effictive_users = ex.exercise_shixun_answers.search_shixun_answers("user_id",user_ids)
|
|
|
|
|
ex_answers = ex.exercise_shixun_answers
|
|
|
|
|
effictive_users = ex_answers.search_shixun_answers("user_id",user_ids)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
effictive_users_count = effictive_users.size #有效回答数,可能有重复的用户id,这里仅统计是否回答这个问题的全部人数
|
|
|
|
|
ex_answered_scores = effictive_users.score_reviewed.pluck(:score).sum #该问题的全部得分
|
|
|
|
|
|
|
|
|
|
if ex.question_type > Exercise::COMPLETION #当为主观题和实训题时,
|
|
|
|
|
if ex_total_score != 0.0
|
|
|
|
|
percent = (ex_answered_scores / ex_total_score.to_f).round(3) * 100 #正确率
|
|
|
|
|
end
|
|
|
|
|
percent = (ex_total_score == 0.0 ? 0.0 : (ex_answered_scores / ex_total_score.to_f).round(3) * 100) #正确率
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
question_answer_infos = []
|
|
|
|
|
if ex.question_type <= Exercise::JUDGMENT #选择题和判断题
|
|
|
|
|
ex_choices = ex.exercise_choices
|
|
|
|
|
standard_answer = ex.exercise_standard_answers.pluck(:exercise_choice_id).sort #标准答案的位置
|
|
|
|
|
right_users_count = 0 #该问题的回答正确的人数
|
|
|
|
|
right_users_count = 0
|
|
|
|
|
#该问题的正确率
|
|
|
|
|
if ex.question_type == Exercise::MULTIPLE #多选题
|
|
|
|
|
user_ids.each do |user_id|
|
|
|
|
|
ex_choice_ids = effictive_users.map{|e| e.exercise_choice_id if e.user_id == user_id}.reject(&:blank?).uniq
|
|
|
|
@ -129,15 +129,14 @@ module ExercisesHelper
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
percent = effictive_users_count > 0 ? (right_users_count / effictive_users_count.to_f).round(3)*100 : 0.0
|
|
|
|
|
|
|
|
|
|
#每个选项的正确率
|
|
|
|
|
ex_choices.each do |c|
|
|
|
|
|
right_answer = standard_answer.include?(c.choice_position) #选项的标准答案为选项的位置
|
|
|
|
|
answer_this_choice = effictive_users.search_exercise_answer("exercise_choice_id",c.id)
|
|
|
|
|
answer_users_count = answer_this_choice.size
|
|
|
|
|
if effictive_users_count == 0
|
|
|
|
|
answer_percent = 0.0
|
|
|
|
|
else
|
|
|
|
|
answer_percent = (answer_users_count / effictive_users_count.to_f ).round(3)
|
|
|
|
|
end
|
|
|
|
|
answer_users_count = effictive_users.select{|answer| answer.exercise_choice_id == c.id}.size
|
|
|
|
|
|
|
|
|
|
answer_percent = (effictive_users_count == 0 ? 0.0 : (answer_users_count / effictive_users_count.to_f ).round(3))
|
|
|
|
|
|
|
|
|
|
answer_option = {
|
|
|
|
|
:choice_position => c.choice_position,
|
|
|
|
|
:choice_text => c.choice_text,
|
|
|
|
@ -150,7 +149,7 @@ module ExercisesHelper
|
|
|
|
|
elsif ex.question_type == Exercise::COMPLETION #填空题
|
|
|
|
|
ex_ordered = ex.is_ordered
|
|
|
|
|
null_standard_answer = ex.exercise_standard_answers
|
|
|
|
|
null_stand_choice = null_standard_answer.pluck(:exercise_choice_id)
|
|
|
|
|
null_stand_choice = null_standard_answer.pluck(:exercise_choice_id) #一个exercise_choice_id可能对应多个answer_text
|
|
|
|
|
null_stand_text = null_standard_answer.pluck(:answer_text)
|
|
|
|
|
standard_answer_count = 0
|
|
|
|
|
all_user_count = 0
|
|
|
|
@ -159,20 +158,17 @@ module ExercisesHelper
|
|
|
|
|
s_choice_text = null_stand_text[index]
|
|
|
|
|
if ex_ordered #有序排列
|
|
|
|
|
user_ids.each do |u|
|
|
|
|
|
user_answers = ex_answers.search_answer_users("user_id",u).search_answer_users("exercise_choice_id",s)
|
|
|
|
|
user_answers_choice = user_answers.present? ? user_answers.first.answer_text : ""
|
|
|
|
|
user_answers = ex_answers.where(user_id:u,exercise_choice_id:s).select(:answer_text)
|
|
|
|
|
user_answers_choice = user_answers.exists? ? user_answers&.first&.answer_text.to_s : ""
|
|
|
|
|
if s_choice_text == user_answers_choice
|
|
|
|
|
user_count += 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
user_count = user_count + effictive_users.search_exercise_answer("answer_text",s_choice_text).count #回答了标准答案的用户
|
|
|
|
|
end
|
|
|
|
|
if effictive_users_count == 0
|
|
|
|
|
answer_percent = 0.0
|
|
|
|
|
else
|
|
|
|
|
answer_percent = (user_count / effictive_users_count.to_f ).round(3)
|
|
|
|
|
user_count = user_count + effictive_users.select{|answer| answer.answer_text == s_choice_text }.size #回答了标准答案的用户
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
answer_percent = ((effictive_users_count == 0) ? 0.0 : (user_count / effictive_users_count.to_f ).round(3))
|
|
|
|
|
answer_option = {
|
|
|
|
|
:choice_position => index+1,
|
|
|
|
|
:choice_text => s_choice_text,
|
|
|
|
@ -237,22 +233,13 @@ module ExercisesHelper
|
|
|
|
|
all_zero_scores = cha_shixun_answer.search_shixun_keys("score",0.0).size #零分人数
|
|
|
|
|
shixun_scores = user_ids.count * cha_score
|
|
|
|
|
shixun_answered_scores = cha_shixun_answer.score_reviewed.pluck(:score).sum #该问题的全部得分
|
|
|
|
|
|
|
|
|
|
if shixun_answered_scores == 0.0
|
|
|
|
|
game_percent = 0.0
|
|
|
|
|
else
|
|
|
|
|
game_percent = (shixun_answered_scores / shixun_scores.to_f).round(3) * 100 #正确率
|
|
|
|
|
end
|
|
|
|
|
game_percent = (shixun_answered_scores == 0.0 ? 0.0 : (shixun_answered_scores / shixun_scores.to_f).round(3) * 100) #正确率
|
|
|
|
|
|
|
|
|
|
shixun_score_array = [full_scores,no_full_scores,all_zero_scores]
|
|
|
|
|
shixun_chas = []
|
|
|
|
|
shixun_score_array.each_with_index do |s,index|
|
|
|
|
|
right_answer = (index == 0)
|
|
|
|
|
if effictive_users_count == 0
|
|
|
|
|
score_percent = 0.0
|
|
|
|
|
else
|
|
|
|
|
score_percent = (s.to_i / effictive_users_count.to_f ).round(3)
|
|
|
|
|
end
|
|
|
|
|
score_percent = (effictive_users_count == 0 ? 0.0 : (s.to_i / effictive_users_count.to_f ).round(3))
|
|
|
|
|
answer_option = {
|
|
|
|
|
:choice_position => index+1,
|
|
|
|
|
:choice_text => index+1,
|
|
|
|
|