|
|
|
@ -7,22 +7,13 @@ class HomeworkBatchCommentJob < ApplicationJob
|
|
|
|
|
homework = HomeworkCommon.find_by(id: homework_id)
|
|
|
|
|
return if homework.blank?
|
|
|
|
|
|
|
|
|
|
attrs = %i[student_work_id challenge_id user_id comment hidden_comment]
|
|
|
|
|
attrs = %i[student_work_id challenge_id user_id comment hidden_comment batch_comment created_at updated_at]
|
|
|
|
|
|
|
|
|
|
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'
|
|
|
|
|
}
|
|
|
|
|
same_attrs = {challenge_id: 0, user_id: user_id, comment: comment, hidden_comment: hidden_comment, batch_comment: 1}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
ShixunWorkComment.bulk_insert(*attrs) do |worker|
|
|
|
|
|
work_ids.each do |work_id|
|
|
|
|
|
worker.add same_attrs.merge(student_work_id: work_id)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|