|
|
|
@ -816,7 +816,7 @@ class ExercisesController < ApplicationController
|
|
|
|
|
|
|
|
|
|
ex_user_ids = exercise_users.pluck(:id)
|
|
|
|
|
|
|
|
|
|
EndExerciseCalculateJob.perform_later(ex_user_ids, exercise, Time.now.to_s)
|
|
|
|
|
EndExerciseCalculateJob.perform_later(ex_user_ids, exercise, Time.now.to_s, true, 4)
|
|
|
|
|
# exercise_users.each do |user|
|
|
|
|
|
# if user.commit_status == 0 && user.start_at.present?
|
|
|
|
|
# objective_score = calculate_student_score(exercise,user.user)[:total_score]
|
|
|
|
@ -982,11 +982,17 @@ class ExercisesController < ApplicationController
|
|
|
|
|
@shixun_undo = 0
|
|
|
|
|
@ques_undo = 0
|
|
|
|
|
ex_answer_time = @exercise.time.to_i
|
|
|
|
|
exercise_user = @exercise.exercise_users.find_by(user_id: current_user.id)
|
|
|
|
|
if ex_answer_time > 0 #有剩余时间的时候
|
|
|
|
|
user_left_time = get_exercise_left_time(@exercise, current_user)
|
|
|
|
|
@ex_end_time = Time.now + user_left_time.to_i.seconds
|
|
|
|
|
|
|
|
|
|
# 提交用户试卷
|
|
|
|
|
commit_exercise_user @exercise, exercise_user if user_left_time.nil?
|
|
|
|
|
else
|
|
|
|
|
@ex_end_time = @exercise.get_exercise_end_time(current_user.id)
|
|
|
|
|
|
|
|
|
|
commit_exercise_user @exercise, exercise_user if @ex_end_time < Time.now
|
|
|
|
|
end
|
|
|
|
|
# @ex_end_time = @exercise.get_exercise_end_time(current_user.id)
|
|
|
|
|
# if ex_answer_time > 0
|
|
|
|
@ -1033,20 +1039,7 @@ class ExercisesController < ApplicationController
|
|
|
|
|
can_commit_exercise = true
|
|
|
|
|
end
|
|
|
|
|
if can_commit_exercise
|
|
|
|
|
objective_score = calculate_student_score(@exercise, current_user, Time.now)[:total_score]
|
|
|
|
|
subjective_score = @answer_committed_user.subjective_score
|
|
|
|
|
total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score
|
|
|
|
|
total_score = objective_score + total_score_subjective_score
|
|
|
|
|
commit_option = {
|
|
|
|
|
:status => 1,
|
|
|
|
|
:commit_status => 1,
|
|
|
|
|
:end_at => Time.now,
|
|
|
|
|
:objective_score => objective_score,
|
|
|
|
|
:score => total_score,
|
|
|
|
|
:subjective_score => subjective_score,
|
|
|
|
|
:commit_method => @answer_committed_user&.commit_method.to_i > 0 ? @answer_committed_user&.commit_method.to_i : params[:commit_method].to_i
|
|
|
|
|
}
|
|
|
|
|
@answer_committed_user.update!(commit_option)
|
|
|
|
|
commit_exercise_user @exercise, @answer_committed_user, Time.now
|
|
|
|
|
CommitExercsieNotifyJobJob.perform_later(@exercise.id, current_user.id)
|
|
|
|
|
normal_status(0, "试卷提交成功!")
|
|
|
|
|
else
|
|
|
|
@ -1197,10 +1190,19 @@ class ExercisesController < ApplicationController
|
|
|
|
|
|
|
|
|
|
@exercise_users_size = @exercise_users_list.size
|
|
|
|
|
|
|
|
|
|
if @exercise.time > 0
|
|
|
|
|
start_time = Time.current - @exercise.time * 60
|
|
|
|
|
ex_user_ids = @exercise_users_list.where("start_at <= '#{Time.at(start_time)}' and commit_status = 0").pluck(:user_id)
|
|
|
|
|
if ex_user_ids.size > 0
|
|
|
|
|
EndExerciseCalculateJob.perform_later(ex_user_ids, @exercise, Time.now.to_s, false, 2)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 分页
|
|
|
|
|
@page = params[:page] || 1
|
|
|
|
|
@limit = params[:limit] || 20
|
|
|
|
|
@exercise_users_list = @exercise_users_list.page(@page).per(@limit)
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
@exercise_users_list = []
|
|
|
|
|
@export_ex_users = @exercise_users_list
|
|
|
|
|