Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Update Apprenticeship courses #4780

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions app/controllers/publish/courses/outcome_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,12 @@ def handle_qualification_update
@course.ensure_site_statuses_match_full_time
end

redirect_to details_publish_provider_recruitment_cycle_course_path(
redirect_to funding_type_publish_provider_recruitment_cycle_course_path(
@course.provider_code,
@course.recruitment_cycle_year,
@course.course_code
@course.course_code,
course: { qualification: "undergraduate_degree_with_qts" }
)

course_updated_message('Qualification')
end
end

Expand Down
8 changes: 6 additions & 2 deletions app/decorators/course_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def is_send?

def funding
{
'salary' => 'Salary',
'apprenticeship' => 'Teaching apprenticeship - with salary',
'salary' => 'School direct - with salary',
'apprenticeship' => 'Teaching degree apprenticeship (TDA) - with salary',
'fee' => 'Fee - no salary'
}[object.funding]
end
Expand Down Expand Up @@ -153,6 +153,10 @@ def apprenticeship?
object.funding.to_s == 'apprenticeship'
end

def teacher_degree_apprenticeship?
object.funding.to_s == 'apprenticeship' && object.qualification == 'undergraduate_degree_with_qts'
end

def apprenticeship
apprenticeship? ? 'Yes' : 'No'
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ def qualification_options
def qualifications_with_qts
qts_list = Course.qualifications.keys.grep(/qts/)

qts_list -= %w[undergraduate_degree_with_qts] if non_tda_published?
qts_list -= %w[qts]

qts_list
end

def non_tda_published?
!teacher_degree_apprenticeship? && is_published?
end

def qualifications_without_qts
Course.qualifications.keys.reject do |qualification|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module CourseBasicDetailConcern
def back; end

def new
@course.funding = nil if @course.present?
authorize(@provider, :can_create_course?)
end

Expand Down
4 changes: 4 additions & 0 deletions app/models/course.rb
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ def self.entry_requirement_options_without_nil_choice
validates :is_send, inclusion: { in: [true, false] }, on: %i[new create publish]
# TODO: validates :master_subject_id ?

def primary_or_secondary_level?
%w[primary secondary].include?(level)
end

def is_engineers_teach_physics?
master_subject_id == SecondarySubject.physics.id && engineers_teach_physics?
end
Expand Down
14 changes: 12 additions & 2 deletions app/services/courses/creation_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def new_course

def build_new_course
course = provider.courses.new
course.assign_attributes(course_attributes.except(:subjects_ids, :study_mode))
course.assign_attributes(filtered_course_attributes)

if course_attributes[:master_subject_id].blank? && course_attributes[:subordinate_subject_id].present?
course.errors.add(:subjects, :course_creation)
Expand All @@ -35,7 +35,7 @@ def build_new_course
update_study_mode(course)
update_sites(course)
update_study_sites(course)
course.accrediting_provider = course.provider.accrediting_providers.first if course.provider.accredited_bodies.length == 1
course.accrediting_provider = course.provider.accrediting_providersdef .first if course.provider.accredited_bodies.length == 1
course.course_code = provider.next_available_course_code if next_available_course_code

Publish::Courses::AssignTdaAttributesService.new(course).call if course.undergraduate_degree_with_qts?
Expand All @@ -51,6 +51,16 @@ def course_attributes
@course_attributes ||= course_params.to_h.symbolize_keys.slice(*permitted_new_course_attributes)
end

def filtered_course_attributes
attributes = course_attributes.except(:subjects_ids, :study_mode)
return attributes unless course_attributes[:funding] == 'teacher_degree_apprenticeship'

attributes.merge(
program_type: 'teacher_degree_apprenticeship',
qualification: 'undergraduate_degree_with_qts'
).except(:funding)
end

def permitted_new_course_attributes
@permitted_new_course_attributes ||= CoursePolicy.new(nil, new_course).permitted_new_course_attributes
end
Expand Down
2 changes: 2 additions & 0 deletions app/services/workflow_step_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def teacher_degree_apprenticeship_school_direct_workflow_steps
modern_languages
age_range
outcome
funding_type
school
study_site
accredited_provider
Expand All @@ -50,6 +51,7 @@ def teacher_degree_apprenticeship_scitt_workflow_steps
modern_languages
age_range
outcome
funding_type
school
study_site
applications_open
Expand Down
19 changes: 16 additions & 3 deletions app/views/publish/courses/funding_type/_form_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"salary",
class: "govuk-radios__input", checked: course.salary? %>
<%= form.label :funding,
"Salary",
"School direct - with salary",
value: "salary",
class: "govuk-label govuk-radios__label",
data: { qa: "course__funding_type_salary" } %>
Expand All @@ -40,13 +40,26 @@
"apprenticeship",
class: "govuk-radios__input", checked: course.apprenticeship? %>
<%= form.label :funding,
"Teaching apprenticeship - with salary",
"Postgraduate teaching apprenticeship (PGTA) - with salary",
value: "apprenticeship",
class: "govuk-label govuk-radios__label",
data: { qa: "course__funding_type_apprenticeship" } %>
</div>

<% if params.dig(:course, :qualification) == "undergraduate_degree_with_qts" %>
<div class="govuk-radios__item">
<%= form.radio_button :funding,
"apprenticeship",
class: "govuk-radios__input", checked: course.teacher_degree_apprenticeship? %>
<%= form.label :funding,
"Teacher degree apprenticeship (TDA) with salary",
value: "teacher_degree_apprenticeship",
class: "govuk-label govuk-radios__label",
data: { qa: "course__funding_type_teacher_degree_apprenticeship" } %>
</div>
<% end %>
</div>

<%= form.hidden_field :previous_tda_course, value: params[:previous_tda_course] %>
<%= form.hidden_field :previous_tda_course, value: params[:previous_tda_course] %>
</fieldset>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<%= legend %>
<%= render "publish/shared/error_messages", error_keys: [field] %>
<div class="govuk-radios govuk-!-margin-top-2">
<% if course.primary_or_secondary_level? %>
<p class="govuk-body">If your course is an apprenticeship, you will be able to select this on the next page.</p>
<% end %>
<% @course.edit_course_options[key].sort.each_with_index do |value| %>
<% help = t("edit_options.#{key}.#{value}.help") %>
<% label = t("edit_options.#{key}.#{value}.label") %>
Expand Down
16 changes: 8 additions & 8 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ en:
qts: QTS
undergraduate_degree_with_qts: Teacher degree apprenticeship with QTS
pgce_with_qts: QTS with PGCE
pgde_with_qts: QTS with PGDE
pgde_with_qts: PGDE with QTS
pgce: PGCE
pgde: PGDE
description:
Expand Down Expand Up @@ -180,8 +180,8 @@ en:
label: "PGDE only (without QTS)"
help: "Postgraduate diploma in education"
pgde_with_qts:
label: "QTS with PGDE"
help: "Qualified teacher status with a postgraduate diploma in education"
label: "PGDE with QTS"
help: "Postgraduate diploma in education with qualified teacher status"
age_range_in_years:
other:
label: "Another age range"
Expand Down Expand Up @@ -435,7 +435,7 @@ en:
qts: "QTS"
pgce_with_qts: "QTS with PGCE"
pgce: "PGCE"
pgde_with_qts: "QTS with PGDE"
pgde_with_qts: "PGDE with QTS"
pgde: "PGDE"
entry_requirements:
must_have_qualification_at_application_time: "Must have the GCSE"
Expand Down Expand Up @@ -1319,11 +1319,11 @@ en:
label: "PGDE only (without QTS)"
help: "Postgraduate diploma in education"
pgde_with_qts:
label: "QTS with PGDE"
help: "Qualified teacher status with a postgraduate diploma in education"
label: "PGDE with QTS"
help: "Postgraduate diploma in education with qualified teacher status"
undergraduate_degree_with_qts:
label: "Teacher degree apprenticeship (TDA) with QTS"
help: "Teacher degree apprenticeship with qualified teacher status"
label: "QTS"
help: "Qualified teacher status"
age_range_in_years:
other:
label: "Another age range"
Expand Down
Loading