Skip to content

Commit

Permalink
Add low-fi induction recoreding for ABs
Browse files Browse the repository at this point in the history
  • Loading branch information
peteryates committed Oct 3, 2024
1 parent fce595b commit d066ec4
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module AppropriateBodies
module Teachers
class RecordOutcomeController < AppropriateBodiesController
def new
@teacher = Teacher.find(params[:ab_teacher_id])

@pending_induction_submission = PendingInductionSubmission.new
end

def create
@teacher = Teacher.find(params[:ab_teacher_id])
@pending_induction_submission = PendingInductionSubmission.new(
**pending_induction_submission_params,
**pending_induction_submission_attributes
)

record_outcome = AppropriateBodies::RecordOutcome.new(appropriate_body: @appropriate_body, pending_induction_submission: @pending_induction_submission)

PendingInductionSubmission.transaction do
if @pending_induction_submission.save(context: :record_outcome) && record_outcome.record_outcome!
redirect_to ab_teacher_record_outcome_path(@teacher)
else
render :new
end
end
end

def show
@teacher = Teacher.find(params[:ab_teacher_id])
end

private

def pending_induction_submission_params
params.require(:pending_induction_submission).permit(:finished_on, :number_of_terms, :outcome)
end

def pending_induction_submission_attributes
{ appropriate_body_id: @appropriate_body.id, trn: @teacher.trn }
end
end
end
end
17 changes: 17 additions & 0 deletions app/services/appropriate_bodies/record_outcome.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module AppropriateBodies
class RecordOutcome
def initialize(appropriate_body:, pending_induction_submission:)
@appropriate_body = appropriate_body
@pending_induction_submission = pending_induction_submission
end

def record_outcome!
# FIXME: implement a proper release process here,
# it needs to close the open inductoin
# period and send an update to TRS with the
# outcome and finish date

true
end
end
end
28 changes: 28 additions & 0 deletions app/views/appropriate_bodies/teachers/record_outcome/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<% page_data(title: "Record outcome for #{Teachers::Name.new(@teacher).full_name}", error: @pending_induction_submission.errors.any?) %>
<%= form_with(model: @pending_induction_submission, url: ab_teacher_record_outcome_path(@teacher), method: 'post') do |form| %>
<%= form.govuk_error_summary %>
<%=
form.govuk_date_field :finished_on,
legend: {
text: "When did #{Teachers::Name.new(@teacher).full_name} finish their induction with you?"
}
%>
<%=
form.govuk_number_field :number_of_terms,
width: 4,
label: {
size: 'm',
text: "How many terms of induction did #{Teachers::Name.new(@teacher).full_name} spend with you?"
}
%>
<%=
form.govuk_collection_radio_buttons :outcome, induction_outcome_choices, :identifier, :name,
legend: { text: "What was the outcome of #{Teachers::Name.new(@teacher).full_name}'s induction?", size: 'm' }
%>
<%= form.govuk_submit %>
<% end %>
10 changes: 10 additions & 0 deletions app/views/appropriate_bodies/teachers/record_outcome/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<% page_data(
title: "#{Teachers::Name.new(@teacher).full_name}'s induction outcome has been recorded",
header: false)
%>
<%=
govuk_panel(title_text: "Success", text: "#{Teachers::Name.new(@teacher).full_name} has finished their induction")
%>
<%= govuk_button_link_to("Return to the homepage", ab_path, secondary: true) %>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% page_data(title: "Release #{Teachers::Name.new(@teacher).full_name}", error: false) %>
<% page_data(title: "Release #{Teachers::Name.new(@teacher).full_name}", error: @pending_induction_submission.errors.any?) %>
<%= form_with(model: @pending_induction_submission, url: ab_teacher_release_ect_path(@teacher), method: 'post') do |form| %>
<%= form.govuk_error_summary %>
Expand All @@ -17,7 +17,7 @@
size: 'm',
text: "How many terms of induction did #{Teachers::Name.new(@teacher).full_name} spend with you?"
}
%>
%>
<%= form.govuk_submit %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/appropriate_bodies/teachers/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div class="govuk-button-group">
<%= govuk_button_link_to("Release ECT", new_ab_teacher_release_ect_path(@teacher), secondary: true) %>
<%= govuk_button_link_to("Record induction outcome", "#", secondary: true) %>
<%= govuk_button_link_to("Record induction outcome", new_ab_teacher_record_outcome_path(@teacher), secondary: true) %>
</div>

<h2 class="govuk-heading-m">Early career teacher<h2>
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
collection do
resources :teachers, only: %i[show], controller: 'appropriate_bodies/teachers', as: 'ab_teachers' do
resource :release_ect, only: %i[new create show], path: 'release', controller: 'appropriate_bodies/teachers/release_ect'
resource :record_outcome, only: %i[new create show], path: 'record-outcome', controller: 'appropriate_bodies/teachers/release_ect'
resource :record_outcome, only: %i[new create show], path: 'record-outcome', controller: 'appropriate_bodies/teachers/record_outcome'
end
end
namespace :claim_an_ect, path: 'claim-an-ect' do
Expand Down

0 comments on commit d066ec4

Please sign in to comment.