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
1.0 KiB
30 lines
1.0 KiB
5 years ago
|
# 作业的一键评阅
|
||
|
class HomeworkBatchCommentJob < ApplicationJob
|
||
|
queue_as :default
|
||
|
|
||
|
def perform(comment, hidden_comment, work_ids, homework_id, user_id)
|
||
|
# Do something later
|
||
|
homework = HomeworkCommon.find_by(id: homework_id)
|
||
|
return if homework.blank?
|
||
|
|
||
|
attrs = %i[student_work_id challenge_id user_id comment hidden_comment]
|
||
|
|
||
|
same_attrs = {
|
||
|
challenge_id: 0, user_id: user_id, container_type: 'Exercise',
|
||
|
parent_container_id: exercise.id, parent_container_type: 'ExercisePublish',
|
||
|
belong_container_id: exercise.course_id, belong_container_type: 'Course',
|
||
|
viewed: 0, tiding_type: 'Exercise'
|
||
|
}
|
||
|
|
||
|
StudentWork.bulk_insert(*attrs) do |worker|
|
||
|
student_ids.each do |user_id|
|
||
|
same_attrs = {user_id: user_id}
|
||
|
course.homework_commons.where(homework_type: %i[normal group practice]).each do |homework|
|
||
|
next if StudentWork.where(user_id: user_id, homework_common_id: homework.id).any?
|
||
|
worker.add same_attrs.merge(homework_common_id: homework.id)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|