|
|
@ -89,7 +89,7 @@ module ExercisesHelper
|
|
|
|
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
|
|
|
@ -113,23 +113,27 @@ module ExercisesHelper
|
|
|
|
if ex.question_type <= Exercise::JUDGMENT #选择题和判断题
|
|
|
|
if ex.question_type <= Exercise::JUDGMENT #选择题和判断题
|
|
|
|
standard_answer = ex.exercise_standard_answers.pluck(:exercise_choice_id).sort #标准答案的位置
|
|
|
|
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|
|
|
|
|
user_ids.each do |user_id|
|
|
|
|
answer_choice_array = effictive_users.select(:user_id,:exercise_choice_id).where(user_id:user_id)&.map {|s| s.exercise_choice.choice_position}.uniq
|
|
|
|
user_an_choice = ex_answers.where(user_id:user_id)
|
|
|
|
if answer_choice_array.sort == standard_answer
|
|
|
|
answer_choice_array = []
|
|
|
|
right_users_count += 1
|
|
|
|
user_an_choice.each do |a|
|
|
|
|
end
|
|
|
|
answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if answer_choice_array == standard_answer
|
|
|
|
else #单选题和判断题
|
|
|
|
right_users_count += 1
|
|
|
|
user_ids.each do |user_id|
|
|
|
|
|
|
|
|
answer_choice_array = effictive_users.select(:user_id,:exercise_choice_id).find_by(user_id:user_id)&.exercise_choice&.choice_position
|
|
|
|
|
|
|
|
if [answer_choice_array] == standard_answer
|
|
|
|
|
|
|
|
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) #选项的标准答案为选项的位置
|
|
|
|
answer_this_choice = effictive_users.search_exercise_answer("exercise_choice_id",c.id)
|
|
|
|
answer_this_choice = effictive_users.search_exercise_answer("exercise_choice_id",c.id)
|
|
|
|
answer_users_count = answer_this_choice.count
|
|
|
|
answer_users_count = answer_this_choice.size
|
|
|
|
if effictive_users_count == 0
|
|
|
|
if effictive_users_count == 0
|
|
|
|
answer_percent = 0.0
|
|
|
|
answer_percent = 0.0
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -170,7 +174,6 @@ module ExercisesHelper
|
|
|
|
else
|
|
|
|
else
|
|
|
|
answer_percent = (user_count / effictive_users_count.to_f ).round(3)
|
|
|
|
answer_percent = (user_count / effictive_users_count.to_f ).round(3)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
answer_option = {
|
|
|
|
answer_option = {
|
|
|
|
:choice_position => index+1,
|
|
|
|
:choice_position => index+1,
|
|
|
|
:choice_text => s_choice_text,
|
|
|
|
:choice_text => s_choice_text,
|
|
|
@ -200,9 +203,9 @@ module ExercisesHelper
|
|
|
|
question_answer_infos.push(wrong_answer_position)
|
|
|
|
question_answer_infos.push(wrong_answer_position)
|
|
|
|
elsif ex.question_type == Exercise::SUBJECTIVE #主观题
|
|
|
|
elsif ex.question_type == Exercise::SUBJECTIVE #主观题
|
|
|
|
ex_score = ex&.question_score
|
|
|
|
ex_score = ex&.question_score
|
|
|
|
full_scores = effictive_users.search_exercise_answer("score",ex_score).count #满分人数
|
|
|
|
full_scores = effictive_users.search_exercise_answer("score",ex_score).size #满分人数
|
|
|
|
no_full_scores = effictive_users.exercise_no_full_scores(ex_score).count #部分分数人数
|
|
|
|
no_full_scores = effictive_users.exercise_no_full_scores(ex_score).size #部分分数人数
|
|
|
|
zero_scores = effictive_users.search_exercise_answer("score",0.0).count #包含为0分的,及未评阅的
|
|
|
|
zero_scores = effictive_users.search_exercise_answer("score",0.0).size #包含为0分的,及未评阅的
|
|
|
|
un_review_scores = effictive_users_count - full_scores - no_full_scores - zero_scores #未评阅数
|
|
|
|
un_review_scores = effictive_users_count - full_scores - no_full_scores - zero_scores #未评阅数
|
|
|
|
if un_review_scores < 0
|
|
|
|
if un_review_scores < 0
|
|
|
|
un_review_scores = 0
|
|
|
|
un_review_scores = 0
|
|
|
@ -415,7 +418,7 @@ module ExercisesHelper
|
|
|
|
user_answer_content = answer_choice_array.sort
|
|
|
|
user_answer_content = answer_choice_array.sort
|
|
|
|
standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个
|
|
|
|
standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个
|
|
|
|
if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分
|
|
|
|
if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分
|
|
|
|
if standard_answer.count > 0
|
|
|
|
if standard_answer.size > 0
|
|
|
|
q_score_1 = q.question_score
|
|
|
|
q_score_1 = q.question_score
|
|
|
|
# q_score_1 = (q.question_score.to_f / standard_answer.count) #当多选答案正确时,每个answer的分数均摊。
|
|
|
|
# q_score_1 = (q.question_score.to_f / standard_answer.count) #当多选答案正确时,每个answer的分数均摊。
|
|
|
|
else
|
|
|
|
else
|
|
|
|