commit
913432aa22
@ -0,0 +1,12 @@
|
||||
$(document).on('turbolinks:load', function(){
|
||||
$(document).on('click', '.batch-all-check-box', function(){
|
||||
var $checkAll = $(this);
|
||||
|
||||
$('.batch-check-box').prop('checked', $checkAll.is(':checked'));
|
||||
})
|
||||
|
||||
$(document).on('click', '.batch-check-box', function(){
|
||||
var allChecked = $('.batch-check-box:checked').length === $('.batch-check-box').length
|
||||
$('.batch-all-check-box').prop('checked', allChecked);
|
||||
})
|
||||
});
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,22 @@
|
||||
# 删除课堂用户
|
||||
class CourseDeleteStudentNotifyJob < ApplicationJob
|
||||
queue_as :notify
|
||||
|
||||
def perform(course_id, student_ids, trigger_user_id)
|
||||
course = Course.find_by(id: course_id)
|
||||
return if course.blank?
|
||||
|
||||
attrs = %i[user_id trigger_user_id container_id container_type belong_container_id
|
||||
belong_container_type tiding_type created_at updated_at]
|
||||
|
||||
same_attrs = {
|
||||
trigger_user_id: trigger_user_id, container_id: course.id, container_type: 'DeleteCourseMember',
|
||||
belong_container_id: course.id, belong_container_type: 'Course', tiding_type: 'System'
|
||||
}
|
||||
Tiding.bulk_insert(*attrs) do |worker|
|
||||
student_ids.each do |user_id|
|
||||
worker.add same_attrs.merge(user_id: user_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,22 @@
|
||||
class CreateSubjectCourseStudentJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(course_id)
|
||||
course = Course.find_by(id: course_id)
|
||||
return if course.blank? || course.subject.blank?
|
||||
|
||||
attrs = %i[course_id user_id role created_at updated_at]
|
||||
same_attrs = {course_id: course.id, role: 4}
|
||||
|
||||
Rails.logger.info("1:course.students.count:##{course.students.count}")
|
||||
CourseMember.bulk_insert(*attrs) do |worker|
|
||||
course.subject.subject_appointments.each do |app|
|
||||
Rails.logger.info("##{course.students.where(user_id: app.user_id)}")
|
||||
next if course.students.where(user_id: app.user_id).any?
|
||||
worker.add same_attrs.merge(user_id: app.user_id)
|
||||
end
|
||||
end
|
||||
Rails.logger.info("2:course.students.count:##{course.students.count}")
|
||||
course.subject.subject_appointments.destroy_all
|
||||
end
|
||||
end
|
@ -0,0 +1,33 @@
|
||||
class ResubmitStudentWorkNotifyJob < ApplicationJob
|
||||
queue_as :notify
|
||||
|
||||
def perform(homework_id, student_ids)
|
||||
homework = HomeworkCommon.find_by(id: homework_id)
|
||||
return if homework.blank? || student_ids.blank?
|
||||
course = homework.course
|
||||
|
||||
attrs = %i[user_id trigger_user_id container_id container_type parent_container_id parent_container_type
|
||||
belong_container_id belong_container_type tiding_type viewed created_at updated_at]
|
||||
|
||||
same_attrs = {
|
||||
container_type: 'ResubmitStudentWork', parent_container_id: homework.id, parent_container_type: 'HomeworkCommon',
|
||||
belong_container_id: course.id, belong_container_type: 'Course', tiding_type: 'HomeworkCommon', viewed: 0
|
||||
}
|
||||
Tiding.bulk_insert(*attrs) do |worker|
|
||||
student_ids.each do |user_id|
|
||||
next unless User.exists?(id: user_id)
|
||||
|
||||
work = homework.student_works.find_by(user_id: user_id)
|
||||
next if work.blank?
|
||||
score_user_ids = work.student_works_scores.where.not(score: nil).where(reviewer_role: [1, 2]).pluck(user_id).uniq
|
||||
next if score_user_ids.blank?
|
||||
|
||||
attrs = same_attrs.merge(trigger_user_id: user_id, container_id: work.id)
|
||||
|
||||
score_user_ids.each do |user_id|
|
||||
worker.add attrs.merge(user_id: user_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,26 @@
|
||||
class Admins::IdentityAuths::RevokeApplyService < ApplicationService
|
||||
attr_reader :apply, :user
|
||||
|
||||
def initialize(apply)
|
||||
@apply = apply
|
||||
@user = apply.user
|
||||
end
|
||||
|
||||
def call
|
||||
ActiveRecord::Base.transaction do
|
||||
apply.revoke!
|
||||
user.update!(authentication: false)
|
||||
|
||||
deal_tiding!
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def deal_tiding!
|
||||
Tiding.create!(user_id: apply.user_id, trigger_user_id: 0,
|
||||
container_id: apply.id, container_type: 'CancelUserAuthentication',
|
||||
belong_container_id: apply.user_id, belong_container_type: 'User',
|
||||
status: 1, tiding_type: 'System')
|
||||
end
|
||||
end
|
@ -0,0 +1,26 @@
|
||||
class Admins::ProfessionalAuths::RevokeApplyService < ApplicationService
|
||||
attr_reader :apply, :user
|
||||
|
||||
def initialize(apply)
|
||||
@apply = apply
|
||||
@user = apply.user
|
||||
end
|
||||
|
||||
def call
|
||||
ActiveRecord::Base.transaction do
|
||||
apply.revoke!
|
||||
user.update!(professional_certification: false)
|
||||
|
||||
deal_tiding!
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def deal_tiding!
|
||||
Tiding.create!(user_id: apply.user_id, trigger_user_id: 0,
|
||||
container_id: apply.id, container_type: 'CancelUserProCertification',
|
||||
belong_container_id: apply.user_id, belong_container_type: 'User',
|
||||
status: 1, tiding_type: 'System')
|
||||
end
|
||||
end
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because one or more lines are too long
@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CourseDeleteStudentNotifyJob, type: :job do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CreateSubjectCourseStudentJob, type: :job do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ResubmitStudentWorkNotifyJob, type: :job do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in new issue