Skip to content

Commit 4fc772c

Browse files
committed
TD-Added confirmation screen and related change in controller
1 parent b2322ba commit 4fc772c

File tree

5 files changed

+167
-0
lines changed

5 files changed

+167
-0
lines changed

DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAssessmentDataService.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public interface ISelfAssessmentDataService
1616
{
1717
//Self Assessments
1818
string? GetSelfAssessmentNameById(int selfAssessmentId);
19+
SelfAssessment? GetSelfAssessmentById(int selfAssessmentId);
1920

2021
// CompetencyDataService
2122
IEnumerable<int> GetCompetencyIdsForSelfAssessment(int selfAssessmentId);
@@ -204,6 +205,56 @@ FROM SelfAssessments
204205
return name;
205206
}
206207

208+
public SelfAssessment? GetSelfAssessmentById(int selfAssessmentId)
209+
{
210+
return connection.Query<SelfAssessment?>(
211+
@"SELECT [ID]
212+
,[Name]
213+
,[Description]
214+
,[IncludesSignposting]
215+
,[BrandID]
216+
,[CreatedDate]
217+
,[CreatedByCentreID]
218+
,[CreatedByAdminID]
219+
,[ArchivedDate]
220+
,[ArchivedByAdminID]
221+
,[IncludeDevelopment]
222+
,[ParentSelfAssessmentID]
223+
,[NRPProfessionalGroupID]
224+
,[NRPSubGroupID]
225+
,[NRPRoleID]
226+
,[PublishStatusID]
227+
,[UpdatedByAdminID]
228+
,[National]
229+
,[Public]
230+
,[Archived]
231+
,[LastEdit]
232+
,[SupervisorSelfAssessmentReview]
233+
,[SupervisorResultsReview]
234+
,[RAGResults]
235+
,[LinearNavigation]
236+
,[CategoryID]
237+
,[UseDescriptionExpanders]
238+
,[ManageOptionalCompetenciesPrompt]
239+
,[Vocabulary]
240+
,[SignOffRequestorStatement]
241+
,[SignOffSupervisorStatement]
242+
,[QuestionLabel]
243+
,[DescriptionLabel]
244+
,[EnforceRoleRequirementsForSignOff]
245+
,[ReviewerCommentsLabel]
246+
,[ManageSupervisorsDescription]
247+
,[IncludeRequirementsFilters]
248+
,[MinimumOptionalCompetencies]
249+
,[RetirementDate]
250+
,[EnrolmentCutoffDate]
251+
,[RetirementReason]
252+
FROM SelfAssessments
253+
WHERE ID = @selfAssessmentId",
254+
new { selfAssessmentId }
255+
).SingleOrDefault();
256+
}
257+
207258
public (IEnumerable<SelfAssessmentDelegate>, int) GetSelfAssessmentDelegates(string searchString, int offSet, int itemsPerPage, string sortBy, string sortDirection,
208259
int? selfAssessmentId, int centreId, bool? isDelegateActive, bool? removed, bool? submitted, bool? signedOff)
209260
{

DigitalLearningSolutions.Web/Controllers/SupervisorController/Supervisor.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,18 @@ public IActionResult EnrolSetRoleProfile(int supervisorDelegateId, int selfAsses
780780
};
781781
return View("EnrolDelegateOnProfileAssessment", model);
782782
}
783+
var retirementDate = selfAssessmentService.GetSelfAssessmentById(selfAssessmentID).RetirementDate;
784+
if (retirementDate?.Date is DateTime date && date >= DateTime.Today &&
785+
date <= DateTime.Today.AddDays(14))
786+
{
787+
var model = new RetiringSelfAssessmentViewModel()
788+
{
789+
SelfAssessmentID = selfAssessmentID,
790+
SupervisorDelegateID = supervisorDelegateId,
791+
RetirementDate = retirementDate
792+
};
793+
return View("ConfirmRetiringSelfAssessment", model);
794+
}
783795

784796
sessionEnrolOnRoleProfile.SelfAssessmentID = selfAssessmentID;
785797
multiPageFormService.SetMultiPageFormData(
@@ -794,6 +806,34 @@ public IActionResult EnrolSetRoleProfile(int supervisorDelegateId, int selfAsses
794806
);
795807
}
796808

809+
[HttpPost]
810+
public IActionResult RetiringSelfAssessmentConfirmed(RetiringSelfAssessmentViewModel retiringSelfAssessment)
811+
{
812+
if (ModelState.IsValid && retiringSelfAssessment.ActionConfirmed)
813+
{
814+
var sessionEnrolOnRoleProfile = multiPageFormService.GetMultiPageFormData<SessionEnrolOnRoleProfile>(
815+
MultiPageFormDataFeature.EnrolDelegateOnProfileAssessment,
816+
TempData
817+
).GetAwaiter().GetResult();
818+
819+
sessionEnrolOnRoleProfile.SelfAssessmentID = retiringSelfAssessment.SelfAssessmentID;
820+
multiPageFormService.SetMultiPageFormData(
821+
sessionEnrolOnRoleProfile,
822+
MultiPageFormDataFeature.EnrolDelegateOnProfileAssessment,
823+
TempData
824+
);
825+
return RedirectToAction(
826+
"EnrolDelegateCompleteBy",
827+
"Supervisor",
828+
new { supervisorDelegateId = retiringSelfAssessment.SupervisorDelegateID }
829+
);
830+
}
831+
else
832+
{
833+
return View("ConfirmRetiringSelfAssessment", retiringSelfAssessment);
834+
}
835+
}
836+
797837
[Route("/Supervisor/Staff/{supervisorDelegateId}/ProfileAssessment/Enrol/CompleteBy")]
798838
[ResponseCache(CacheProfileName = "Never")]
799839
[TypeFilter(

DigitalLearningSolutions.Web/Services/SelfAssessmentService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public interface ISelfAssessmentService
1414
{
1515
//Self Assessments
1616
string? GetSelfAssessmentNameById(int selfAssessmentId);
17+
SelfAssessment? GetSelfAssessmentById(int selfAssessmentId);
1718
// Candidate Assessments
1819
IEnumerable<CurrentSelfAssessment> GetSelfAssessmentsForCandidate(int delegateUserId, int centreId, int? adminIdCategoryID);
1920
IEnumerable<CurrentSelfAssessment> GetSelfAssessmentsForCandidate(int delegateUserId, int centreId);
@@ -466,6 +467,11 @@ public void RemoveEnrolment(int selfAssessmentId, int delegateUserId)
466467
return selfAssessmentDataService.GetSelfAssessmentNameById(selfAssessmentId);
467468
}
468469

470+
public SelfAssessment? GetSelfAssessmentById(int selfAssessmentId)
471+
{
472+
return selfAssessmentDataService.GetSelfAssessmentById(selfAssessmentId);
473+
}
474+
469475
public (SelfAssessmentDelegatesData, int?) GetSelfAssessmentDelegatesPerPage(string searchString, int offSet, int itemsPerPage, string sortBy, string sortDirection,
470476
int? selfAssessmentId, int centreId, bool? isDelegateActive, bool? removed, bool? submitted, bool? signedOff, int? adminCategoryId)
471477
{
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace DigitalLearningSolutions.Web.ViewModels.Supervisor
2+
{
3+
using DigitalLearningSolutions.Web.Attributes;
4+
using System;
5+
6+
public class RetiringSelfAssessmentViewModel
7+
{
8+
public int SelfAssessmentID { get; set; }
9+
public int SupervisorDelegateID { get; set; }
10+
public DateTime? RetirementDate { get; set; }
11+
[BooleanMustBeTrue(ErrorMessage = "Please tick the checkbox to confirm you wish to perform this action")]
12+
public bool ActionConfirmed { get; set; }
13+
}
14+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
@using DigitalLearningSolutions.Web.Extensions
2+
@using DigitalLearningSolutions.Web.ViewModels.Supervisor
3+
@using Microsoft.Extensions.Configuration
4+
@model RetiringSelfAssessmentViewModel;
5+
@inject IConfiguration Configuration;
6+
@{
7+
var errorHasOccurred = !ViewData.ModelState.IsValid;
8+
ViewData["Title"] = (errorHasOccurred ? "Error: " : "") + "Enrol on Profile Assessment";
9+
ViewData["Application"] = "Supervisor";
10+
ViewData["HeaderPathName"] = "Supervisor";
11+
}
12+
13+
@section NavMenuItems {
14+
<partial name="Shared/_NavMenuItems" />
15+
}
16+
17+
<div class="nhsuk-grid-row">
18+
<div class="nhsuk-grid-column-full word-break">
19+
@if (errorHasOccurred)
20+
{
21+
<vc:error-summary order-of-property-names="@(new[] { nameof(Model.ActionConfirmed) })" />
22+
}
23+
<h1 class="nhsuk-u-padding-bottom-3" id="page-heading">Confirm Enrolment</h1>
24+
<p class="nhsuk-body-m">You are about to enrol learners on a retiring self-assessment.</p>
25+
<p class="nhsuk-body-m nhsuk-u-font-weight-bold">Retirement date: @Model.RetirementDate?.ToString("dd/MM/yyyy")</p>
26+
<p class="nhsuk-body-m">After this date, this self-assessment will no longer be available for use.</p>
27+
<p class="nhsuk-body-m">Please note:</p>
28+
<ul>
29+
<li>Learners may not have enough time to complete the self-assessment before it is retired</li>
30+
<li>You may wish to consider enrolling them on an updated version, if available</li>
31+
</ul>
32+
<p class="nhsuk-body-m">To continue, you must acknowledge that you understand the self-assessment is being retired and you still wish to proceed.</p>
33+
<form method="post" asp-controller="Supervisor">
34+
<div class="nhsuk-checkboxes__item">
35+
<vc:single-checkbox asp-for="@nameof(Model.ActionConfirmed)"
36+
label=" I understand this self-assessment is being retired and I still want to enrol learners."
37+
hint-text="" />
38+
</div>
39+
<button type="submit" class="nhsuk-button nhsuk-button nhsuk-u-margin-top-4" asp-action="RetiringSelfAssessmentConfirmed">
40+
Continue
41+
</button>
42+
@Html.HiddenFor(m => m.SelfAssessmentID)
43+
@Html.HiddenFor(m => m.SupervisorDelegateID)
44+
@Html.HiddenFor(m => m.RetirementDate)
45+
</form>
46+
<div class="nhsuk-back-link">
47+
<a class="nhsuk-back-link__link" asp-controller="Supervisor"
48+
asp-action="DelegateProfileAssessments" asp-route-supervisorDelegateId="@Model.SupervisorDelegateID">
49+
<svg class="nhsuk-icon nhsuk-icon__chevron-left" focusable='false' xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
50+
<path d="M13.41 12l5.3-5.29a1 1 0 1 0-1.42-1.42L12 10.59l-5.29-5.3a1 1 0 0 0-1.42 1.42l5.3 5.29-5.3 5.29a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l5.29-5.3 5.29 5.3a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42z"></path>
51+
</svg>
52+
Cancel
53+
</a>
54+
</div>
55+
</div>
56+
</div>

0 commit comments

Comments
 (0)