You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
884 B
30 lines
884 B
5 years ago
|
class EndExerciseCalculateJob < ApplicationJob
|
||
|
|
||
|
include ExercisesHelper
|
||
|
include GitHelper
|
||
|
|
||
|
queue_as :default
|
||
|
|
||
|
def perform(ex_user_ids,exercise)
|
||
|
exercise_users = ExerciseUser.where(id: ex_user_ids)
|
||
|
exercise_users.each do |user|
|
||
|
if user.commit_status == 0 && user.start_at.present?
|
||
|
objective_score = calculate_student_score(exercise,user.user)[:total_score]
|
||
|
user_sub_score = user.subjective_score
|
||
|
subjective_score = user_sub_score < 0.0 ? 0.0 : user_sub_score
|
||
|
total_score = objective_score + subjective_score
|
||
|
commit_option = {
|
||
|
:status => 1,
|
||
|
:commit_status => 1,
|
||
|
:end_at => Time.now,
|
||
|
:objective_score => objective_score,
|
||
|
:score => total_score,
|
||
|
:subjective_score => user_sub_score
|
||
|
}
|
||
|
user.update_attributes(commit_option)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
end
|