Skip to content

Commit 4008ae6

Browse files
authored
Merge pull request #3340 from TechnologyEnhancedLearning/Develop/feature/TD-5616-Enrolling-on-retiring-self-assessment
TD-5616-Supervisor enrolling learners onto a retiring self assessment
2 parents 7166042 + b36f76c commit 4008ae6

File tree

5 files changed

+166
-0
lines changed

5 files changed

+166
-0
lines changed

DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAssessmentDataService.cs

Lines changed: 50 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
SelfAssessment GetSelfAssessmentRetirementDateById(int selfAssessmentId);
2021

2122
// CompetencyDataService
@@ -205,6 +206,55 @@ FROM SelfAssessments
205206
return name;
206207
}
207208

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

DigitalLearningSolutions.Web/Controllers/SupervisorController/Supervisor.cs

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

788800
sessionEnrolOnRoleProfile.SelfAssessmentID = selfAssessmentID;
789801
multiPageFormService.SetMultiPageFormData(
@@ -798,6 +810,34 @@ public IActionResult EnrolSetRoleProfile(int supervisorDelegateId, int selfAsses
798810
);
799811
}
800812

813+
[HttpPost]
814+
public IActionResult RetiringSelfAssessmentConfirmed(RetiringSelfAssessmentViewModel retiringSelfAssessment)
815+
{
816+
if (ModelState.IsValid && retiringSelfAssessment.ActionConfirmed)
817+
{
818+
var sessionEnrolOnRoleProfile = multiPageFormService.GetMultiPageFormData<SessionEnrolOnRoleProfile>(
819+
MultiPageFormDataFeature.EnrolDelegateOnProfileAssessment,
820+
TempData
821+
).GetAwaiter().GetResult();
822+
823+
sessionEnrolOnRoleProfile.SelfAssessmentID = retiringSelfAssessment.SelfAssessmentID;
824+
multiPageFormService.SetMultiPageFormData(
825+
sessionEnrolOnRoleProfile,
826+
MultiPageFormDataFeature.EnrolDelegateOnProfileAssessment,
827+
TempData
828+
);
829+
return RedirectToAction(
830+
"EnrolDelegateCompleteBy",
831+
"Supervisor",
832+
new { supervisorDelegateId = retiringSelfAssessment.SupervisorDelegateID }
833+
);
834+
}
835+
else
836+
{
837+
return View("ConfirmRetiringSelfAssessment", retiringSelfAssessment);
838+
}
839+
}
840+
801841
[Route("/Supervisor/Staff/{supervisorDelegateId}/ProfileAssessment/Enrol/CompleteBy")]
802842
[ResponseCache(CacheProfileName = "Never")]
803843
[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);
@@ -467,6 +468,11 @@ public void RemoveEnrolment(int selfAssessmentId, int delegateUserId)
467468
return selfAssessmentDataService.GetSelfAssessmentNameById(selfAssessmentId);
468469
}
469470

471+
public SelfAssessment? GetSelfAssessmentById(int selfAssessmentId)
472+
{
473+
return selfAssessmentDataService.GetSelfAssessmentById(selfAssessmentId);
474+
}
475+
470476
public (SelfAssessmentDelegatesData, int?) GetSelfAssessmentDelegatesPerPage(string searchString, int offSet, int itemsPerPage, string sortBy, string sortDirection,
471477
int? selfAssessmentId, int centreId, bool? isDelegateActive, bool? removed, bool? submitted, bool? signedOff, int? adminCategoryId)
472478
{
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)