dev_course
SylorHuang 6 years ago
parent 25ef08118c
commit 0be306704c

@ -369,11 +369,11 @@ module ExercisesHelper
standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个
if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分
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
multi_each_score = 0.0
q_score_1 = 0.0
end
answers_content.update_all(:score => multi_each_score)
answers_content.update_all(:score => q_score_1)
score1 = score1 + q.question_score
end
else
@ -461,13 +461,13 @@ module ExercisesHelper
"q_type":q.question_type,
"q_position":q.question_number, #该问题的位置
"stand_status":stand_answer, #该问题是否正确,1为正确0为错误
"user_score":user_scores #每个问题的总得分
"user_score":user_scores.round(1) #每个问题的总得分
}
ques_stand.push(ques_option)
end
total_score = score1 + score2 + score5
{
"total_score":total_score,
"total_score":total_score.round(1),
"stand_status":ques_stand
}
end
@ -687,7 +687,7 @@ module ExercisesHelper
exercise_user = exercise.exercise_users.find_by(user_id:user.id)
time_mill = ex_time * 60 #转为秒
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
if exercise_user_start == 0
if (exercise_end_time - time_now_i) > time_mill

@ -23,7 +23,8 @@ if @exercises_count > 0
ex_index = exercise_index_show(exercise,@course,@is_teacher_or,@current_user_)
json.extract! exercise, :id, :exercise_name,:is_public,:created_at
if @is_teacher_or == 2
json.time get_exercise_left_time(exercise,@current_user_)
second_left = get_exercise_left_time(exercise,@current_user_)
json.time second_left.present? ? (second_left / 60) : nil
end
json.exercise_status ex_index[:ex_status]

Loading…
Cancel
Save