Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> { 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<int>.That.Matches(id => id != supervisorDelegateId),
A<int>._
)
).MustNotHaveHappened();
}

[Test]
public void Error_when_registering_delegate_returns_error_code()
{
Expand Down Expand Up @@ -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<int> { 1, 2, 3, 4, 5 };
var model = RegistrationModelTestHelper.GetDefaultDelegateRegistrationModel();
GivenPendingSupervisorDelegateIdsForEmailAre(supervisorDelegateIds);

// When
registrationService.RegisterDelegateByCentre(model, baseUrl);

// Then
A.CallTo(() => frameworkNotificationService.SendSupervisorDelegateAcceptance(A<int>._, A<int>._))
.MustNotHaveHappened();
}

[Test]
public void RegisterDelegateByCentre_calls_data_service_to_set_prn()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 = $@"<body style= 'font-family: Calibri; font-size: small;'><p>Dear colleague,</p><p>You have been invited to register to access the NHS Health Education England, Digital Learning Solutions platform as a supervised delegate by <a href='mailto:{supervisorDelegate.SupervisorEmail}'>{supervisorDelegate.SupervisorName}</a>.</p><p><a href='{dlsUrlBuilder.Uri.ToString()}'>Click here</a> to register and confirm your acceptance of the invite.</p><p>Your supervisor will then be able to assign role profile assessments and view and validate your self assessment results.</p></body>";
}
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 = $@"<body style= 'font-family: Calibri; font-size: small;'><p>Dear {supervisorDelegate.FirstName},</p><p>You have been identified as a supervised delegate by <a href='mailto:{supervisorDelegate.SupervisorEmail}'>{supervisorDelegate.SupervisorName}</a> in the NHS Health Education England, Digital Learning Solutions (DLS) platform.</p><p>You are already registered as a delegate at the supervisor's DLS centre. <a href='{dlsUrlBuilder.Uri.ToString()}'>Click here</a> to respond to their invite (you may need to sign in using your existing DLS credentials).</p><p>Once you have accepted the invite, your supervisor will be able to assign role profile assessments and view and validate your self assessment results.</p></body>";
}
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 = $@"<body style= 'font-family: Calibri; font-size: small;'><p>Dear {supervisorDelegate.SupervisorName}</p><p>{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.</p><p>You are now confirmed as a supervisor for this delegate.</p><p><a href='{dlsUrlBuilder.Uri.ToString()}'>Click here</a> to manage their role profile assessments.</p></body>";
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 = $@"<body style= 'font-family: Calibri; font-size: small;'><p>Dear {supervisorDelegate.SupervisorName}</p><p>{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.</p><p>This delegate has been removed from your supervisor team.</p><p><a href='{dlsUrlBuilder.Uri.ToString()}'>Click here</a> to manage your team.</p></body>";
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 = $@"<body style= 'font-family: Calibri; font-size: small;'><p>Dear {supervisorDelegate.FirstName}</p><p>{supervisorDelegate.SupervisorName} has accepted your request to be your supervisor for profile asessment activities in the NHS Health Education England, Digital Learning Solutions platform.</p><p><a href='{GetCurrentActivitiesUrl()}'>Click here</a> to access your role profile assessments.</p></body>";
string toEmail = (@adminId == 0 ? supervisorDelegate.DelegateEmail : supervisorDelegate.SupervisorEmail);
emailService.SendEmail(new Email(emailSubjectLine, builder, toEmail));
builder.HtmlBody = $@"<body style= 'font-family: Calibri; font-size: small;'><p>Dear colleague,</p><p>You have been invited to register to access the NHS Health Education England, Digital Learning Solutions platform as a supervised delegate by <a href='mailto:{supervisorDelegate.SupervisorEmail}'>{supervisorDelegate.SupervisorName}</a>.</p><p><a href='{dlsUrlBuilder.Uri.ToString()}'>Click here</a> to register and confirm your acceptance of the invite.</p><p>Your supervisor will then be able to assign role profile assessments and view and validate your self assessment results.</p></body>";
emailService.SendEmail(new Email(emailSubjectLine, builder, supervisorDelegate.DelegateEmail));
}
}

public void SendSupervisorResultReviewed(int adminId, int supervisorDelegateId, int candidateAssessmentId, int resultId)
Expand Down
8 changes: 0 additions & 8 deletions DigitalLearningSolutions.Data/Services/RegistrationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,6 @@ ILogger<RegistrationService> logger
);
}

if (foundRecordForSupervisorDelegateId)
{
frameworkNotificationService.SendSupervisorDelegateAcceptance(
supervisorDelegateId!.Value,
delegateUser.Id
);
}

if (!delegateRegistrationModel.Approved)
{
var contactInfo = centresDataService.GetCentreManagerDetails(delegateRegistrationModel.Centre);
Expand Down
17 changes: 0 additions & 17 deletions DigitalLearningSolutions.Data/Services/SupervisorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public interface ISupervisorService
SelfAssessmentResultSummary GetSelfAssessmentResultSummary(int candidateAssessmentId, int supervisorDelegateId);
IEnumerable<CandidateAssessmentSupervisorVerificationSummary> 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);
Expand Down Expand Up @@ -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(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Loading