Last active
October 3, 2024 12:15
-
-
Save defong/366a64eb8ae03cd5deebc6f8c2a6a784 to your computer and use it in GitHub Desktop.
[DfE] 1180-copy-over-courses-to-organisation.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set provider to lead school & set the URN | |
provider_to_copy_to = RecruitmentCycle.current.providers.find_by(provider_code: "L06") | |
provider_to_copy_to.provider_type = :lead_school | |
provider_to_copy_to.urn = 136451 | |
provider_to_copy_to.save | |
# Set the course accredited body code | |
course_to_change = provider_to_copy_to.courses.find_by(course_code: "V194") | |
course_to_change.accredited_body_code = "2N2" | |
course_to_change.save | |
# Copy the courses | |
courses = RecruitmentCycle.current.providers.find_by(provider_code: "1GV").courses | |
copier = Courses::CopyToProviderService.new(sites_copy_to_course: Sites::CopyToCourseService.new, enrichments_copy_to_course: Enrichments::CopyToCourseService.new, force: true) | |
courses.each do |course| | |
courses.study_sites = [] | |
copier.execute(course:, new_provider: provider_to_copy_to) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment