云上实验室的选用实训、选用实践课程

dev_home
cxt 5 years ago
parent f4f85c36f0
commit 51b01b3b93

@ -9,7 +9,10 @@ class Laboratory < ApplicationRecord
has_many :portal_images, dependent: :destroy
has_many :laboratory_shixuns, dependent: :destroy
has_many :shixuns, through: :laboratory_shixuns, source: :shixun
has_many :laboratory_subjects, dependent: :destroy
has_many :subjects, through: :laboratory_subjects, source: :subject
has_many :courses, dependent: :destroy
has_many :competitions, dependent: :destroy

@ -35,6 +35,9 @@ class ShixunSearchService < ApplicationService
@shixuns = @shixuns.where(trainee: params[:diff])
end
laboratory = Laboratory.find_by_subdomain(request.subdomain)
@shixuns = @shixuns.where(id: laboratory.shixuns) if laboratory
Shixun.search(keyword, search_options)
end

@ -17,6 +17,9 @@ class SubjectSearchService < ApplicationService
@subjects = Subject.visible.unhidden
end
laboratory = Laboratory.find_by_subdomain(request.subdomain)
@subjects = @subjects.where(id: laboratory.subjects) if laboratory
Subject.search(keyword, search_options)
end

Loading…
Cancel
Save