|
|
|
@ -9,9 +9,29 @@ module ExercisesHelper
|
|
|
|
|
@ex_obj_array = []
|
|
|
|
|
exercise_obj_status.each do |q|
|
|
|
|
|
if q.question_type == 5
|
|
|
|
|
ques_score = q.exercise_shixun_answers.search_shixun_answers("user_id",user_id).pluck(:score).sum
|
|
|
|
|
answers_content = q.exercise_shixun_answers.search_shixun_answers("user_id",user_id)
|
|
|
|
|
else
|
|
|
|
|
ques_score = q.exercise_answers.search_answer_users("user_id",user_id).score_reviewed.pluck(:score).sum
|
|
|
|
|
answers_content = q.exercise_answers.search_answer_users("user_id",user_id)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if q.question_type <= 2
|
|
|
|
|
if answers_content.present? #学生有回答时
|
|
|
|
|
answer_choice_array = []
|
|
|
|
|
answers_content.each do |a|
|
|
|
|
|
answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置
|
|
|
|
|
end
|
|
|
|
|
user_answer_content = answer_choice_array.sort
|
|
|
|
|
standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个
|
|
|
|
|
if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分
|
|
|
|
|
ques_score = q.question_score
|
|
|
|
|
else
|
|
|
|
|
ques_score = 0.0
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
ques_score = 0.0
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
ques_score = answers_content.select(:score).pluck(:score).sum
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if ques_score >= q.question_score #满分作答为正确
|
|
|
|
@ -370,7 +390,8 @@ module ExercisesHelper
|
|
|
|
|
standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个
|
|
|
|
|
if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分
|
|
|
|
|
if standard_answer.count > 0
|
|
|
|
|
q_score_1 = (q.question_score.to_f / standard_answer.count) #当多选答案正确时,每个answer的分数均摊。
|
|
|
|
|
q_score_1 = q.question_score
|
|
|
|
|
# q_score_1 = (q.question_score.to_f / standard_answer.count) #当多选答案正确时,每个answer的分数均摊。
|
|
|
|
|
else
|
|
|
|
|
q_score_1 = 0.0
|
|
|
|
|
end
|
|
|
|
@ -641,6 +662,7 @@ module ExercisesHelper
|
|
|
|
|
user_score = nil
|
|
|
|
|
shixun_type = 0
|
|
|
|
|
question_comment = []
|
|
|
|
|
# user_score_pre = nil
|
|
|
|
|
if ques_type == 5
|
|
|
|
|
exercise_answers = q.exercise_shixun_answers.search_shixun_answers("user_id",ex_answerer_id)
|
|
|
|
|
else
|
|
|
|
@ -648,10 +670,26 @@ module ExercisesHelper
|
|
|
|
|
end
|
|
|
|
|
if student_status == 2 #当前为老师,或为学生且已提交
|
|
|
|
|
user_score_pre = exercise_answers.score_reviewed
|
|
|
|
|
if ques_type == 4 && user_score_pre.blank? #主观题时,且没有大于0的分数时,为空
|
|
|
|
|
user_score = nil
|
|
|
|
|
else
|
|
|
|
|
if ques_type == 4 #主观题时,且没有大于0的分数时,为空
|
|
|
|
|
user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : nil
|
|
|
|
|
elsif ques_type == 5 || ques_type == 3
|
|
|
|
|
user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : 0.0
|
|
|
|
|
else
|
|
|
|
|
if exercise_answers.present? #判断题和选择题时,
|
|
|
|
|
answer_choice_array = []
|
|
|
|
|
exercise_answers.each do |a|
|
|
|
|
|
answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置
|
|
|
|
|
end
|
|
|
|
|
user_answer_content = answer_choice_array.sort
|
|
|
|
|
standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个
|
|
|
|
|
if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分
|
|
|
|
|
user_score = q.question_score
|
|
|
|
|
else
|
|
|
|
|
user_score = 0.0
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
user_score = 0.0
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -659,9 +697,9 @@ module ExercisesHelper
|
|
|
|
|
user_score = q.question_score
|
|
|
|
|
end
|
|
|
|
|
if ques_type <= 2
|
|
|
|
|
answered_content = exercise_answers.pluck(:exercise_choice_id)
|
|
|
|
|
answered_content = exercise_answers&.pluck(:exercise_choice_id)
|
|
|
|
|
elsif ques_type == 3
|
|
|
|
|
exercise_answers.each do |a|
|
|
|
|
|
exercise_answers&.each do |a|
|
|
|
|
|
u_answer = {
|
|
|
|
|
"choice_id":a.exercise_choice_id,
|
|
|
|
|
"answer_text": a.answer_text
|
|
|
|
@ -669,7 +707,7 @@ module ExercisesHelper
|
|
|
|
|
answered_content.push(u_answer)
|
|
|
|
|
end
|
|
|
|
|
elsif ques_type == 4
|
|
|
|
|
answered_content = exercise_answers.pluck(:answer_text)
|
|
|
|
|
answered_content = exercise_answers&.pluck(:answer_text)
|
|
|
|
|
end
|
|
|
|
|
if ques_type == 5 #存在实训题,及已经做了实训题的
|
|
|
|
|
if ex_status == 3 || is_teacher_or == 1 #如果试卷已截止,则可以看到分数,否则不能查看分数
|
|
|
|
|