commit
beaf3fcd4f
@ -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
@ -0,0 +1,2 @@
|
|||||||
|
// Place all the behaviors and hooks related to the matching controller here.
|
||||||
|
// All this logic will automatically be available in application.js.
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,3 @@
|
|||||||
|
// Place all the styles related to the subject_lists controller here.
|
||||||
|
// They will automatically be included in application.css.
|
||||||
|
// You can use Sass (SCSS) here: http://sass-lang.com/
|
@ -0,0 +1,6 @@
|
|||||||
|
class Ecs::GraduationSubitemsController < Ecs::BaseController
|
||||||
|
def index
|
||||||
|
subitems = current_year.ec_graduation_subitems.reorder('ec_graduation_requirements.position ASC, ec_graduation_subitems.position ASC')
|
||||||
|
@graduation_subitems = subitems.includes(:ec_graduation_requirement)
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,22 @@
|
|||||||
|
class Ecs::UsersController < Ecs::BaseController
|
||||||
|
skip_before_action :check_user_permission!
|
||||||
|
before_action :check_manager_permission!
|
||||||
|
|
||||||
|
def index
|
||||||
|
users = UserQuery.call(params)
|
||||||
|
|
||||||
|
@count = users.count
|
||||||
|
@users = paginate users.includes(user_extension: [:school, :department])
|
||||||
|
@manager_ids = current_major_school.ec_major_school_users.pluck(:user_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def current_major_school
|
||||||
|
@_ec_major_school ||= EcMajorSchool.find(params[:ec_major_school_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def current_school
|
||||||
|
@_current_school ||= current_major_school.school
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,6 @@
|
|||||||
|
class LibraryTagsController < ApplicationController
|
||||||
|
def index
|
||||||
|
library_tags = LibraryTag.all
|
||||||
|
render_ok(library_tags: library_tags.as_json(only: %i[id name]), count: library_tags.size)
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,10 @@
|
|||||||
|
class SubjectListsController < ApplicationController
|
||||||
|
def index
|
||||||
|
@results = SubjectSearchService.call(search_params)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def search_params
|
||||||
|
params.permit(:keyword, :type, :page, :limit, :order, :sort)
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,22 @@
|
|||||||
|
module Ecs::EcYearsHelper
|
||||||
|
def achieved_graduation_course_count(ec_year)
|
||||||
|
return 0 if ec_year.ec_courses.count.zero?
|
||||||
|
|
||||||
|
course_ids = ec_year.ec_courses.map(&:id)
|
||||||
|
target_count_map = EcCourseTarget.where(ec_course_id: course_ids).group(:ec_course_id).count
|
||||||
|
|
||||||
|
ec_year.ec_courses.sum { |course| course.complete_target_count == target_count_map[course.id] ? 1 : 0 }
|
||||||
|
end
|
||||||
|
|
||||||
|
def achieved_graduation_objective_count(ec_year)
|
||||||
|
return 0 if ec_year.ec_graduation_subitems.count.zero?
|
||||||
|
|
||||||
|
subitem_ids = ec_year.ec_graduation_subitems.reorder(nil).pluck(:id)
|
||||||
|
|
||||||
|
relations = EcGraduationRequirementCalculation.joins(:ec_course_support).where(ec_course_supports: { ec_graduation_subitem_id: subitem_ids })
|
||||||
|
|
||||||
|
reached_map = relations.where(status: true).group('ec_graduation_subitem_id').count
|
||||||
|
|
||||||
|
reached_map.keys.size
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,2 @@
|
|||||||
|
module SubjectListsHelper
|
||||||
|
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
|
@ -1,7 +1,6 @@
|
|||||||
class EcCourseStudentScore < ApplicationRecord
|
class EcCourseStudentScore < ApplicationRecord
|
||||||
belongs_to :ec_year_student
|
belongs_to :ec_year_student
|
||||||
belongs_to :ec_course
|
belongs_to :ec_course
|
||||||
belongs_to :ec_course_target
|
|
||||||
|
|
||||||
has_many :ec_student_score_targets, dependent: :delete_all
|
has_many :ec_student_score_targets, dependent: :delete_all
|
||||||
end
|
end
|
@ -0,0 +1,4 @@
|
|||||||
|
class SubjectAppointment < ApplicationRecord
|
||||||
|
belongs_to :subject
|
||||||
|
belongs_to :user
|
||||||
|
end
|
@ -0,0 +1,28 @@
|
|||||||
|
class UserQuery < ApplicationQuery
|
||||||
|
attr_reader :params
|
||||||
|
|
||||||
|
def initialize(params)
|
||||||
|
@params = params
|
||||||
|
end
|
||||||
|
|
||||||
|
def call
|
||||||
|
users = User.where(type: 'User')
|
||||||
|
|
||||||
|
# 真实姓名
|
||||||
|
if name = strip_param(:name)
|
||||||
|
users = users.where('LOWER(CONCAT(users.lastname, users.firstname)) LIKE ?', "%#{name.downcase}%")
|
||||||
|
end
|
||||||
|
|
||||||
|
# 单位名称
|
||||||
|
if school = strip_param(:school)
|
||||||
|
users = users.joins(user_extension: :school).where('schools.name LIKE ?', "%#{school}%")
|
||||||
|
end
|
||||||
|
|
||||||
|
# 职业
|
||||||
|
if (identity = strip_param(:identity)) && UserExtension.identities.keys.include?(identity)
|
||||||
|
users = users.joins(:user_extension).where(user_extensions: { identity: identity })
|
||||||
|
end
|
||||||
|
|
||||||
|
users
|
||||||
|
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
|
@ -0,0 +1,42 @@
|
|||||||
|
class SubjectSearchService < ApplicationService
|
||||||
|
include ElasticsearchAble
|
||||||
|
|
||||||
|
attr_reader :params
|
||||||
|
|
||||||
|
def initialize(params)
|
||||||
|
@params = params
|
||||||
|
end
|
||||||
|
|
||||||
|
def call
|
||||||
|
# 全部实训/我的实训
|
||||||
|
type = params[:type] || "all"
|
||||||
|
|
||||||
|
if type == "mine"
|
||||||
|
@subjects = User.current.shixuns.visible.unhidden
|
||||||
|
else
|
||||||
|
@subjects = Subject.visible.unhidden
|
||||||
|
end
|
||||||
|
|
||||||
|
Subject.search(keyword, search_options)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def search_options
|
||||||
|
model_options = {
|
||||||
|
includes: [ user: { user_extension: :school } ]
|
||||||
|
}
|
||||||
|
model_options.merge!(where: { id: @subjects.pluck(:id) })
|
||||||
|
model_options.merge!(order: {sort_type => sort_str})
|
||||||
|
model_options.merge!(default_options)
|
||||||
|
model_options
|
||||||
|
end
|
||||||
|
|
||||||
|
def sort_str
|
||||||
|
params[:order] || "desc"
|
||||||
|
end
|
||||||
|
|
||||||
|
def sort_type
|
||||||
|
params[:sort] || "myshixuns_count"
|
||||||
|
end
|
||||||
|
end
|
@ -1 +1 @@
|
|||||||
json.course_evaluations @course_evaluations, partial: 'shared/ec_course_evaluation', as: :ec_course_evaluation
|
json.course_evaluations @course_evaluations, partial: 'ecs/course_evaluations/shared/ec_course_evaluation', as: :ec_course_evaluation
|
||||||
|
@ -1 +1 @@
|
|||||||
json.partial! 'shared/ec_course_evaluation', ec_course_evaluation: @course_evaluation
|
json.partial! 'ecs/course_evaluations/shared/ec_course_evaluation', ec_course_evaluation: @course_evaluation
|
||||||
|
@ -1 +1 @@
|
|||||||
json.course_evaluations @course_evaluations, partial: 'shared/ec_course_evaluation_slim', as: :ec_course_evaluation
|
json.course_evaluations @course_evaluations, partial: 'ecs/course_evaluations/shared/ec_course_evaluation_slim', as: :ec_course_evaluation
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue