diff --git a/DigitalLearningSolutions.Data.Tests/Services/RegistrationServiceTests.cs b/DigitalLearningSolutions.Data.Tests/Services/RegistrationServiceTests.cs index 630e9b58c1..cef287e062 100644 --- a/DigitalLearningSolutions.Data.Tests/Services/RegistrationServiceTests.cs +++ b/DigitalLearningSolutions.Data.Tests/Services/RegistrationServiceTests.cs @@ -287,34 +287,6 @@ public void Registering_delegate_should_not_update_any_SupervisorDelegate_record ).MustNotHaveHappened(); } - [Test] - public void Registering_delegate_should_send_SupervisorDelegate_email_for_matching_id_record_only() - { - // Given - const int supervisorDelegateId = 2; - var supervisorDelegateIds = new List { 1, 2, 3, 4, 5 }; - var model = RegistrationModelTestHelper.GetDefaultDelegateRegistrationModel(); - GivenPendingSupervisorDelegateIdsForEmailAre(supervisorDelegateIds); - - // When - registrationService.RegisterDelegate( - model, - string.Empty, - false, - supervisorDelegateId - ); - - // Then - A.CallTo(() => frameworkNotificationService.SendSupervisorDelegateAcceptance(supervisorDelegateId, 0)) - .MustHaveHappened(); - A.CallTo( - () => frameworkNotificationService.SendSupervisorDelegateAcceptance( - A.That.Matches(id => id != supervisorDelegateId), - A._ - ) - ).MustNotHaveHappened(); - } - [Test] public void Error_when_registering_delegate_returns_error_code() { @@ -630,23 +602,6 @@ public void RegisterDelegateByCentre_should_add_CandidateId_to_all_SupervisorDel ).MustHaveHappened(); } - [Test] - public void RegisterDelegateByCentre_should_not_send_SupervisorDelegate_email() - { - // Given - const string baseUrl = "base.com"; - var supervisorDelegateIds = new List { 1, 2, 3, 4, 5 }; - var model = RegistrationModelTestHelper.GetDefaultDelegateRegistrationModel(); - GivenPendingSupervisorDelegateIdsForEmailAre(supervisorDelegateIds); - - // When - registrationService.RegisterDelegateByCentre(model, baseUrl); - - // Then - A.CallTo(() => frameworkNotificationService.SendSupervisorDelegateAcceptance(A._, A._)) - .MustNotHaveHappened(); - } - [Test] public void RegisterDelegateByCentre_calls_data_service_to_set_prn() { diff --git a/DigitalLearningSolutions.Data/Services/FrameworkNotificationService.cs b/DigitalLearningSolutions.Data/Services/FrameworkNotificationService.cs index 5e150f31b2..380517fc27 100644 --- a/DigitalLearningSolutions.Data/Services/FrameworkNotificationService.cs +++ b/DigitalLearningSolutions.Data/Services/FrameworkNotificationService.cs @@ -14,10 +14,7 @@ public interface IFrameworkNotificationService void SendCommentNotifications(int adminId, int frameworkId, int commentId, string comment, int? replyToCommentId, string? parentComment); void SendReviewRequest(int id, int invitedByAdminId, bool required, bool reminder); void SendReviewOutcomeNotification(int reviewId); - void SendSupervisorDelegateInvite(int supervisorDelegateId, int adminId); - void SendSupervisorDelegateAcceptance(int supervisorDelegateId, int delegateId); - void SendSupervisorDelegateRejected(int supervisorDelegateId, int delegateIId); - void SendSupervisorDelegateConfirmed(int superviseDelegateId, int adminId, int delegateId); + void SendSupervisorDelegateInvite(int supervisorDelegateId, int adminId); void SendSupervisorResultReviewed(int adminId, int supervisorDelegateId, int candidateAssessmentId, int resultId); void SendSupervisorEnroledDelegate(int adminId, int supervisorDelegateId, int candidateAssessmentId, DateTime? completeByDate); void SendReminderDelegateSelfAssessment(int adminId, int supervisorDelegateId, int candidateAssessmentId); @@ -212,64 +209,9 @@ public void SendSupervisorDelegateInvite(int supervisorDelegateId, int adminId) You have been invited to register to access the NHS Health Education England, Digital Learning Solutions platform as a supervised delegate by {supervisorDelegate.SupervisorName} ({supervisorDelegate.SupervisorEmail}). To register, visit {dlsUrlBuilder.Uri.ToString()}. Registering using this link will confirm your acceptance of the invite. Your supervisor will then be able to assign role profile assessments and view and validate your self assessment results."; - builder.HtmlBody = $@"

Dear colleague,

You have been invited to register to access the NHS Health Education England, Digital Learning Solutions platform as a supervised delegate by {supervisorDelegate.SupervisorName}.

Click here to register and confirm your acceptance of the invite.

Your supervisor will then be able to assign role profile assessments and view and validate your self assessment results.

"; - } - else - { - dlsUrlBuilder.Path += $"LearningPortal/ConfirmSupervisor/{supervisorDelegateId}"; - builder.TextBody = $@"Dear {supervisorDelegate.FirstName}, - You have been identified as a supervised delegate by {supervisorDelegate.SupervisorName} ({supervisorDelegate.SupervisorEmail}) in the NHS Health Education England, Digital Learning Solutions (DLS) platform. - You are already registered as a delegate at the supervisor's DLS centre. To respond to their invite, please visit {dlsUrlBuilder.Uri.ToString()} (you may need to sign in using your existing DLS credentials). - Once you have accepted the invite, your supervisor will be able to assign role profile assessments and view and validate your self assessment results."; - builder.HtmlBody = $@"

Dear {supervisorDelegate.FirstName},

You have been identified as a supervised delegate by {supervisorDelegate.SupervisorName} in the NHS Health Education England, Digital Learning Solutions (DLS) platform.

You are already registered as a delegate at the supervisor's DLS centre. Click here to respond to their invite (you may need to sign in using your existing DLS credentials).

Once you have accepted the invite, your supervisor will be able to assign role profile assessments and view and validate your self assessment results.

"; - } - emailService.SendEmail(new Email(emailSubjectLine, builder, supervisorDelegate.DelegateEmail)); - } - - public void SendSupervisorDelegateAcceptance(int supervisorDelegateId, int delegateId) - { - var supervisorDelegate = supervisorService.GetSupervisorDelegateDetailsById(supervisorDelegateId, 0, delegateId); - var builder = new BodyBuilder(); - var dlsUrlBuilder = GetDLSUriBuilder(); - string emailSubjectLine = "Accepted Supervisor Invitation - Digital Learning Solutions"; - dlsUrlBuilder.Path += $"Supervisor/Staff/List"; - builder.TextBody = $@"Dear {supervisorDelegate.SupervisorName}, - {supervisorDelegate.FirstName} {supervisorDelegate.LastName} has accepted your invitation to become a member of your team in the NHS Health Education England, Digital Learning Solutions platform. -You are now confirmed as a supervisor for this delegate. -To manage their role profile assessments, please visit {dlsUrlBuilder.Uri.ToString()}."; - builder.HtmlBody = $@"

Dear {supervisorDelegate.SupervisorName}

{supervisorDelegate.FirstName} {supervisorDelegate.LastName} has accepted your invitation to become a member of your team in the NHS Health Education England, Digital Learning Solutions platform.

You are now confirmed as a supervisor for this delegate.

Click here to manage their role profile assessments.

"; - emailService.SendEmail(new Email(emailSubjectLine, builder, supervisorDelegate.SupervisorEmail)); - } - - public void SendSupervisorDelegateRejected(int supervisorDelegateId, int delegateId) - { - var supervisorDelegate = supervisorService.GetSupervisorDelegateDetailsById(supervisorDelegateId, 0, delegateId); - string emailSubjectLine = "REJECTED Supervisor Invitation - Digital Learning Solutions"; - var builder = new BodyBuilder(); - var dlsUrlBuilder = GetDLSUriBuilder(); - dlsUrlBuilder.Path += $"Supervisor/Staff/List"; - builder.TextBody = $@"Dear {supervisorDelegate.SupervisorName}, - {supervisorDelegate.FirstName} {supervisorDelegate.LastName} has rejected your invitation to become a member of your team in the NHS Health Education England, Digital Learning Solutions platform. -This delegate has been removed from your supervisor team. -To manage your team, please visit {dlsUrlBuilder.Uri.ToString()}."; - builder.HtmlBody = $@"

Dear {supervisorDelegate.SupervisorName}

{supervisorDelegate.FirstName} {supervisorDelegate.LastName} has rejected your invitation to become a member of your team in the NHS Health Education England, Digital Learning Solutions platform.

This delegate has been removed from your supervisor team.

Click here to manage your team.

"; - emailService.SendEmail(new Email(emailSubjectLine, builder, supervisorDelegate.SupervisorEmail)); - } - - public void SendSupervisorDelegateConfirmed(int supervisorDelegateId, int adminId, int delegateId) - { - var supervisorDelegate = supervisorService.GetSupervisorDelegateDetailsById(supervisorDelegateId, adminId, delegateId); - string emailSubjectLine = "Supervisor Confirmed - Digital Learning Solutions"; - var builder = new BodyBuilder(); - builder.TextBody = $@"Dear {supervisorDelegate.FirstName} -You have been identified as a supervised delegate by {supervisorDelegate.SupervisorName} ({supervisorDelegate.SupervisorEmail}) in the NHS Health Education England, Digital Learning Solutions (DLS) platform. - -You are already registered as a delegate at the supervisor's DLS centre so they can now assign competency self assessments and view and validate your self assessment results. - -If this looks like a mistake, please contact {supervisorDelegate.SupervisorName} ({supervisorDelegate.SupervisorEmail}) directly to correct."; - builder.HtmlBody = $@"

Dear {supervisorDelegate.FirstName}

{supervisorDelegate.SupervisorName} has accepted your request to be your supervisor for profile asessment activities in the NHS Health Education England, Digital Learning Solutions platform.

Click here to access your role profile assessments.

"; - string toEmail = (@adminId == 0 ? supervisorDelegate.DelegateEmail : supervisorDelegate.SupervisorEmail); - emailService.SendEmail(new Email(emailSubjectLine, builder, toEmail)); + builder.HtmlBody = $@"

Dear colleague,

You have been invited to register to access the NHS Health Education England, Digital Learning Solutions platform as a supervised delegate by {supervisorDelegate.SupervisorName}.

Click here to register and confirm your acceptance of the invite.

Your supervisor will then be able to assign role profile assessments and view and validate your self assessment results.

"; + emailService.SendEmail(new Email(emailSubjectLine, builder, supervisorDelegate.DelegateEmail)); + } } public void SendSupervisorResultReviewed(int adminId, int supervisorDelegateId, int candidateAssessmentId, int resultId) diff --git a/DigitalLearningSolutions.Data/Services/RegistrationService.cs b/DigitalLearningSolutions.Data/Services/RegistrationService.cs index d94d1eabca..f5a47d9b53 100644 --- a/DigitalLearningSolutions.Data/Services/RegistrationService.cs +++ b/DigitalLearningSolutions.Data/Services/RegistrationService.cs @@ -117,14 +117,6 @@ ILogger logger ); } - if (foundRecordForSupervisorDelegateId) - { - frameworkNotificationService.SendSupervisorDelegateAcceptance( - supervisorDelegateId!.Value, - delegateUser.Id - ); - } - if (!delegateRegistrationModel.Approved) { var contactInfo = centresDataService.GetCentreManagerDetails(delegateRegistrationModel.Centre); diff --git a/DigitalLearningSolutions.Data/Services/SupervisorService.cs b/DigitalLearningSolutions.Data/Services/SupervisorService.cs index eb3dd5d98b..06ff5bf3d3 100644 --- a/DigitalLearningSolutions.Data/Services/SupervisorService.cs +++ b/DigitalLearningSolutions.Data/Services/SupervisorService.cs @@ -33,7 +33,6 @@ public interface ISupervisorService SelfAssessmentResultSummary GetSelfAssessmentResultSummary(int candidateAssessmentId, int supervisorDelegateId); IEnumerable GetCandidateAssessmentSupervisorVerificationSummaries(int candidateAssessmentId); //UPDATE DATA - bool ConfirmSupervisorDelegateById(int supervisorDelegateId, int candidateId, int adminId); bool RemoveSupervisorDelegateById(int supervisorDelegateId, int candidateId, int adminId); bool UpdateSelfAssessmentResultSupervisorVerifications(int selfAssessmentResultSupervisorVerificationId, string? comments, bool signedOff, int adminId); bool RemoveCandidateAssessment(int candidateAssessmentId); @@ -202,22 +201,6 @@ public SupervisorDelegateDetail GetSupervisorDelegateDetailsById(int supervisorD ).FirstOrDefault(); } - public bool ConfirmSupervisorDelegateById(int supervisorDelegateId, int candidateId, int adminId) - { - var numberOfAffectedRows = connection.Execute( - @"UPDATE SupervisorDelegates SET Confirmed = getUTCDate() - WHERE ID = @supervisorDelegateId AND Confirmed IS NULL AND Removed IS NULL AND (CandidateID = @candidateId OR SupervisorAdminID = @adminId)", - new { supervisorDelegateId, candidateId, adminId }); - if (numberOfAffectedRows < 1) - { - logger.LogWarning( - $"Not confirming SupervisorDelegate as db update failed. supervisorDelegateId: {supervisorDelegateId}, candidateId: {candidateId}, adminId: {adminId}" - ); - return false; - } - return true; - } - public bool RemoveSupervisorDelegateById(int supervisorDelegateId, int candidateId, int adminId) { var numberOfAffectedRows = connection.Execute( diff --git a/DigitalLearningSolutions.Web/Controllers/LearningPortalController/ConfirmSupervisor.cs b/DigitalLearningSolutions.Web/Controllers/LearningPortalController/ConfirmSupervisor.cs deleted file mode 100644 index 026b82c36b..0000000000 --- a/DigitalLearningSolutions.Web/Controllers/LearningPortalController/ConfirmSupervisor.cs +++ /dev/null @@ -1,48 +0,0 @@ -namespace DigitalLearningSolutions.Web.Controllers.LearningPortalController -{ - using DigitalLearningSolutions.Web.Helpers; - using Microsoft.AspNetCore.Mvc; - using Microsoft.Extensions.Logging; - - public partial class LearningPortalController - { - [Route("/LearningPortal/ConfirmSupervisor/{supervisorDelegateId}")] - public IActionResult ConfirmSupervisor(int supervisorDelegateId) - { - var candidateId = User.GetCandidateIdKnownNotNull(); - var supervisorDelegate = - supervisorService.GetSupervisorDelegateDetailsById(supervisorDelegateId, 0, candidateId); - if (supervisorDelegate.CandidateID != candidateId | supervisorDelegate.Removed != null) - { - logger.LogWarning( - $"Attempt to display confirm supervisor screen for where candidate id ({candidateId}) did not match supervise delegate candidate id ({supervisorDelegate.CandidateID}). SuperviseDelegateID: {supervisorDelegateId}" - ); - return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 }); - } - - return View("ConfirmSupervisor", supervisorDelegate); - } - - public IActionResult AcceptSupervisorDelegateInvite(int supervisorDelegateId) - { - var candidateId = User.GetCandidateIdKnownNotNull(); - if (supervisorService.ConfirmSupervisorDelegateById(supervisorDelegateId, candidateId, 0)) - { - frameworkNotificationService.SendSupervisorDelegateAcceptance(supervisorDelegateId, candidateId); - } - - return RedirectToAction("Current"); - } - - public IActionResult RejectSupervisorDelegateInvite(int supervisorDelegateId) - { - var candidateId = User.GetCandidateIdKnownNotNull(); - if (supervisorService.RemoveSupervisorDelegateById(supervisorDelegateId, candidateId, 0)) - { - frameworkNotificationService.SendSupervisorDelegateRejected(supervisorDelegateId, candidateId); - } - - return RedirectToAction("Current"); - } - } -} diff --git a/DigitalLearningSolutions.Web/Controllers/LearningPortalController/SelfAssessment.cs b/DigitalLearningSolutions.Web/Controllers/LearningPortalController/SelfAssessment.cs index f2ed237edc..2b5aa675de 100644 --- a/DigitalLearningSolutions.Web/Controllers/LearningPortalController/SelfAssessment.cs +++ b/DigitalLearningSolutions.Web/Controllers/LearningPortalController/SelfAssessment.cs @@ -758,26 +758,6 @@ public IActionResult SendSupervisorReminder(int selfAssessmentId, int supervisor return RedirectToAction("ManageSupervisors", new { selfAssessmentId }); } - public IActionResult ConfirmSupervisor(int supervisorDelegateId, int selfAssessmentId) - { - supervisorService.ConfirmSupervisorDelegateById(supervisorDelegateId, GetCandidateId(), 0); - frameworkNotificationService.SendSupervisorDelegateConfirmed( - supervisorDelegateId, - 0, - User.GetCandidateIdKnownNotNull() - ); - return RedirectToAction("ManageSupervisors", new { selfAssessmentId }); - } - - public IActionResult RejectSupervisor(int supervisorDelegateId, int selfAssessmentId) - { - supervisorService.RemoveSupervisorDelegateById(supervisorDelegateId, GetCandidateId(), 0); - frameworkNotificationService.SendSupervisorDelegateRejected( - supervisorDelegateId, - User.GetCandidateIdKnownNotNull() - ); - return RedirectToAction("ManageSupervisors", new { selfAssessmentId }); - } public IActionResult StartRequestVerification(int selfAssessmentId) { diff --git a/DigitalLearningSolutions.Web/Controllers/SupervisorController/Supervisor.cs b/DigitalLearningSolutions.Web/Controllers/SupervisorController/Supervisor.cs index 768e41ea9d..979897bb75 100644 --- a/DigitalLearningSolutions.Web/Controllers/SupervisorController/Supervisor.cs +++ b/DigitalLearningSolutions.Web/Controllers/SupervisorController/Supervisor.cs @@ -153,17 +153,6 @@ int centreId } } - public IActionResult ConfirmSupervise(int supervisorDelegateId) - { - var adminId = GetAdminID(); - if (supervisorService.ConfirmSupervisorDelegateById(supervisorDelegateId, 0, adminId)) - { - frameworkNotificationService.SendSupervisorDelegateConfirmed(supervisorDelegateId, adminId, 0); - } - - return RedirectToAction("MyStaffList"); - } - [Route("/Supervisor/Staff/{supervisorDelegateId}/Remove")] public IActionResult RemoveSupervisorDelegateConfirm(int supervisorDelegateId, ReturnPageQuery returnPageQuery) { diff --git a/DigitalLearningSolutions.Web/Views/LearningPortal/ConfirmSupervisor.cshtml b/DigitalLearningSolutions.Web/Views/LearningPortal/ConfirmSupervisor.cshtml deleted file mode 100644 index 99540227ad..0000000000 --- a/DigitalLearningSolutions.Web/Views/LearningPortal/ConfirmSupervisor.cshtml +++ /dev/null @@ -1,37 +0,0 @@ -@using DigitalLearningSolutions.Data.Models.Supervisor; -@using Microsoft.Extensions.Configuration -@model SupervisorDelegateDetail; -@inject IConfiguration Configuration; -@{ - ViewData["Application"] = "Learning Portal"; - ViewData["Title"] = "Learning Portal - Confirm Supervisor"; - ViewData["HeaderPath"] = $"{Configuration["AppRootPath"]}/LearningPortal/Current"; - ViewData["HeaderPathName"] = "My Current Activities"; -} -@section NavMenuItems { - -} -
-
-

Confirm Supervisor

-
-
-
- Supervisor: -
-
-
- @Model.SupervisorName (@Model.SupervisorEmail) -
-
-

You have been invited by the above supervisor to be a member of their team in the DLS platform. Once you accept, they will be able to assign profile self assessmentsto you and review and confirm profile self-assessments that you complete.

-

You can have multiple supervisors in the DLS system, accepting this invite will not remove previous supervisors.

-

You should only reject this invitation if you don't recognise the supervisor identified above. Please contact the supervisor for clarification before rejecting their invitation.

- - Accept invite - - - Reject invite - -
-
diff --git a/DigitalLearningSolutions.Web/Views/LearningPortal/SelfAssessments/ManageSupervisors.cshtml b/DigitalLearningSolutions.Web/Views/LearningPortal/SelfAssessments/ManageSupervisors.cshtml index afaa0a6fe1..39b6c3dc58 100644 --- a/DigitalLearningSolutions.Web/Views/LearningPortal/SelfAssessments/ManageSupervisors.cshtml +++ b/DigitalLearningSolutions.Web/Views/LearningPortal/SelfAssessments/ManageSupervisors.cshtml @@ -31,9 +31,6 @@ Name/role - - Status - Action @@ -48,30 +45,11 @@ @supervisor.SupervisorName, @supervisor.RoleName - - Status - @if (supervisor.Confirmed == null) - { - Unconfirmed - } - else - { - Confirmed - } - Actions @if (supervisor.AddedByDelegate) { Remove - @if (supervisor.Confirmed == null && supervisor.NotificationSent.ToShortDateString() != DateTime.UtcNow.ToShortDateString()) - { - Send reminder - } - } - else if (supervisor.Confirmed == null) - { - Confirm Reject } diff --git a/DigitalLearningSolutions.Web/Views/Supervisor/Shared/_StaffMemberCard.cshtml b/DigitalLearningSolutions.Web/Views/Supervisor/Shared/_StaffMemberCard.cshtml index 939aa263f7..7bd0609acd 100644 --- a/DigitalLearningSolutions.Web/Views/Supervisor/Shared/_StaffMemberCard.cshtml +++ b/DigitalLearningSolutions.Web/Views/Supervisor/Shared/_StaffMemberCard.cshtml @@ -92,14 +92,4 @@ View self assessments (@Model.SupervisorDelegateDetail.CandidateAssessmentCount) } - else if (Model.SupervisorDelegateDetail.AddedByDelegate) - { - - Confirm - - }