|
|
@ -6,7 +6,7 @@ class ExercisePublishTask
|
|
|
|
Rails.logger.info("log--------------------------------exercise_publish start")
|
|
|
|
Rails.logger.info("log--------------------------------exercise_publish start")
|
|
|
|
puts "--------------------------------exercise_publish start"
|
|
|
|
puts "--------------------------------exercise_publish start"
|
|
|
|
exercises = Exercise.includes(:exercise_users).where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now)
|
|
|
|
exercises = Exercise.includes(:exercise_users).where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now)
|
|
|
|
exercises.each do |exercise|
|
|
|
|
exercises&.each do |exercise|
|
|
|
|
exercise.update_column('exercise_status', 2)
|
|
|
|
exercise.update_column('exercise_status', 2)
|
|
|
|
course = exercise.course
|
|
|
|
course = exercise.course
|
|
|
|
tid_str = ""
|
|
|
|
tid_str = ""
|
|
|
@ -45,7 +45,7 @@ class ExercisePublishTask
|
|
|
|
|
|
|
|
|
|
|
|
# 分组设置发布时间的测验
|
|
|
|
# 分组设置发布时间的测验
|
|
|
|
exercise_group_settings = ExerciseGroupSetting.where("publish_time < ? and publish_time > ?", Time.now + 900, Time.now - 900)
|
|
|
|
exercise_group_settings = ExerciseGroupSetting.where("publish_time < ? and publish_time > ?", Time.now + 900, Time.now - 900)
|
|
|
|
exercise_group_settings.each do |exercise_group|
|
|
|
|
exercise_group_settings&.each do |exercise_group|
|
|
|
|
exercise = exercise_group.exercise
|
|
|
|
exercise = exercise_group.exercise
|
|
|
|
if exercise.present?
|
|
|
|
if exercise.present?
|
|
|
|
course = exercise.course
|
|
|
|
course = exercise.course
|
|
|
@ -71,11 +71,12 @@ class ExercisePublishTask
|
|
|
|
puts "--------------------------------exercise_end start"
|
|
|
|
puts "--------------------------------exercise_end start"
|
|
|
|
# 1。统一设置的试卷
|
|
|
|
# 1。统一设置的试卷
|
|
|
|
exercises = Exercise.includes(:exercise_users,:exercise_questions).where("exercise_status = 2 AND unified_setting = true AND end_time <= ?",Time.now + 900)
|
|
|
|
exercises = Exercise.includes(:exercise_users,:exercise_questions).where("exercise_status = 2 AND unified_setting = true AND end_time <= ?",Time.now + 900)
|
|
|
|
exercises.each do |exercise|
|
|
|
|
exercises&.each do |exercise|
|
|
|
|
ex_type = exercise.exercise_questions.pluck(:question_type).uniq
|
|
|
|
ex_type = exercise.exercise_questions.pluck(:question_type).uniq
|
|
|
|
exercise.update_column('exercise_status', 3)
|
|
|
|
exercise.update_column('exercise_status', 3)
|
|
|
|
exercise.exercise_users.each do |exercise_user|
|
|
|
|
exercise.exercise_users&.each do |exercise_user|
|
|
|
|
if exercise_user&.commit_status == 0 && exercise_user&.start_at.present?
|
|
|
|
begin
|
|
|
|
|
|
|
|
if (exercise_user&.commit_status == 0) && (exercise_user&.start_at.present?)
|
|
|
|
s_score = calculate_student_score(exercise, exercise_user.user)[:total_score]
|
|
|
|
s_score = calculate_student_score(exercise, exercise_user.user)[:total_score]
|
|
|
|
if ex_type.include?(4) #是否包含主观题
|
|
|
|
if ex_type.include?(4) #是否包含主观题
|
|
|
|
subjective_score = exercise_user.subjective_score
|
|
|
|
subjective_score = exercise_user.subjective_score
|
|
|
@ -94,6 +95,11 @@ class ExercisePublishTask
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exercise_user.update_attributes(commit_option)
|
|
|
|
exercise_user.update_attributes(commit_option)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
|
|
|
Rails.logger.info("rescue errors ___________________________#{e}")
|
|
|
|
|
|
|
|
next
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -101,17 +107,17 @@ class ExercisePublishTask
|
|
|
|
all_exercises = Exercise.includes(:exercise_group_settings,:exercise_users,:exercise_questions).where("unified_setting = false AND exercise_status = 2 AND end_time > ?",Time.now + 900)
|
|
|
|
all_exercises = Exercise.includes(:exercise_group_settings,:exercise_users,:exercise_questions).where("unified_setting = false AND exercise_status = 2 AND end_time > ?",Time.now + 900)
|
|
|
|
exercise_ids = all_exercises.blank? ? "(-1)" : "(" + all_exercises.map(&:id).join(",") + ")"
|
|
|
|
exercise_ids = all_exercises.blank? ? "(-1)" : "(" + all_exercises.map(&:id).join(",") + ")"
|
|
|
|
ex_group_settings = ExerciseGroupSetting.where("end_time <= '#{Time.now}' and exercise_id in #{exercise_ids}")
|
|
|
|
ex_group_settings = ExerciseGroupSetting.where("end_time <= '#{Time.now}' and exercise_id in #{exercise_ids}")
|
|
|
|
ex_group_settings.each do |exercise_setting|
|
|
|
|
ex_group_settings&.each do |exercise_setting|
|
|
|
|
exercise = exercise_setting.exercise
|
|
|
|
exercise = exercise_setting.exercise
|
|
|
|
if exercise&.end_time <= Time.now
|
|
|
|
if exercise.end_time <= Time.now
|
|
|
|
exercise.update_column('exercise_status', 3)
|
|
|
|
exercise.update_column('exercise_status', 3)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
ex_types = exercise.exercise_questions.pluck(:question_type).uniq
|
|
|
|
ex_types = exercise.exercise_questions.pluck(:question_type).uniq
|
|
|
|
users = exercise.course.students.where(:course_group_id => exercise_setting.course_group_id)
|
|
|
|
users = exercise.course.students.where(:course_group_id => exercise_setting.course_group_id)
|
|
|
|
exercise_users = exercise.exercise_users.where(:user_id => users.pluck(:user_id))
|
|
|
|
exercise_users = exercise.exercise_users.where(:user_id => users.pluck(:user_id))
|
|
|
|
|
|
|
|
exercise_users&.each do |exercise_user|
|
|
|
|
exercise_users.each do |exercise_user|
|
|
|
|
begin
|
|
|
|
if exercise_user.commit_status == 0 && !exercise_user.start_at.nil?
|
|
|
|
if exercise_user.commit_status == 0 && !exercise_user.start_at.nil?
|
|
|
|
if ex_types.include?(4) #是否包含主观题
|
|
|
|
if ex_types.include?(4) #是否包含主观题
|
|
|
|
subjective_score = exercise_user.subjective_score
|
|
|
|
subjective_score = exercise_user.subjective_score
|
|
|
@ -131,6 +137,11 @@ class ExercisePublishTask
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exercise_user.update_attributes(commit_option)
|
|
|
|
exercise_user.update_attributes(commit_option)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
|
|
|
Rails.logger.info("unified_setting_false_rescue errors ___________________________#{e}")
|
|
|
|
|
|
|
|
next
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
Rails.logger.info("log--------------------------------exercise_end end")
|
|
|
|
Rails.logger.info("log--------------------------------exercise_end end")
|
|
|
|