|
|
@ -369,11 +369,11 @@ module ExercisesHelper
|
|
|
|
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.count > 0
|
|
|
|
multi_each_score = (q.question_score / standard_answer.count) #当多选答案正确时,每个answer的分数均摊。
|
|
|
|
q_score_1 = (q.question_score.to_f / standard_answer.count) #当多选答案正确时,每个answer的分数均摊。
|
|
|
|
else
|
|
|
|
else
|
|
|
|
multi_each_score = 0.0
|
|
|
|
q_score_1 = 0.0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
answers_content.update_all(:score => multi_each_score)
|
|
|
|
answers_content.update_all(:score => q_score_1)
|
|
|
|
score1 = score1 + q.question_score
|
|
|
|
score1 = score1 + q.question_score
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -461,13 +461,13 @@ module ExercisesHelper
|
|
|
|
"q_type":q.question_type,
|
|
|
|
"q_type":q.question_type,
|
|
|
|
"q_position":q.question_number, #该问题的位置
|
|
|
|
"q_position":q.question_number, #该问题的位置
|
|
|
|
"stand_status":stand_answer, #该问题是否正确,1为正确,0为错误
|
|
|
|
"stand_status":stand_answer, #该问题是否正确,1为正确,0为错误
|
|
|
|
"user_score":user_scores #每个问题的总得分
|
|
|
|
"user_score":user_scores.round(1) #每个问题的总得分
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ques_stand.push(ques_option)
|
|
|
|
ques_stand.push(ques_option)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
total_score = score1 + score2 + score5
|
|
|
|
total_score = score1 + score2 + score5
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"total_score":total_score,
|
|
|
|
"total_score":total_score.round(1),
|
|
|
|
"stand_status":ques_stand
|
|
|
|
"stand_status":ques_stand
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -687,7 +687,7 @@ module ExercisesHelper
|
|
|
|
exercise_user = exercise.exercise_users.find_by(user_id:user.id)
|
|
|
|
exercise_user = exercise.exercise_users.find_by(user_id:user.id)
|
|
|
|
time_mill = ex_time * 60 #转为秒
|
|
|
|
time_mill = ex_time * 60 #转为秒
|
|
|
|
exercise_end_time = exercise.end_time.present? ? exercise.end_time.to_i : 0
|
|
|
|
exercise_end_time = exercise.end_time.present? ? exercise.end_time.to_i : 0
|
|
|
|
exercise_user_start = exercise_user.present? ? exercise_user.start_at.to_i : 0
|
|
|
|
exercise_user_start = exercise_user&.start_at.present? ? exercise_user.start_at.to_i : 0
|
|
|
|
#用户未开始答题时,即exercise_user_start为0
|
|
|
|
#用户未开始答题时,即exercise_user_start为0
|
|
|
|
if exercise_user_start == 0
|
|
|
|
if exercise_user_start == 0
|
|
|
|
if (exercise_end_time - time_now_i) > time_mill
|
|
|
|
if (exercise_end_time - time_now_i) > time_mill
|
|
|
|