From 68646e5585fc23cfd55926a25da1b36c3c51ebde Mon Sep 17 00:00:00 2001 From: sherif-olaboye <123654949+sherif-olaboye@users.noreply.github.com> Date: Mon, 18 May 2026 15:36:09 +0100 Subject: [PATCH 1/2] TD-6941 Changing competencyAssessment to selfAssessment --- .../CompetencyAssessments.cs | 8 ++--- .../Services/FrameworkNotificationService.cs | 32 +++++++++---------- .../Views/Frameworks/Index.cshtml | 10 +----- 3 files changed, 21 insertions(+), 29 deletions(-) diff --git a/DigitalLearningSolutions.Web/Controllers/CompetencyAssessmentsController/CompetencyAssessments.cs b/DigitalLearningSolutions.Web/Controllers/CompetencyAssessmentsController/CompetencyAssessments.cs index 9bb96419db..e6bd06aed1 100644 --- a/DigitalLearningSolutions.Web/Controllers/CompetencyAssessmentsController/CompetencyAssessments.cs +++ b/DigitalLearningSolutions.Web/Controllers/CompetencyAssessmentsController/CompetencyAssessments.cs @@ -1501,7 +1501,7 @@ public IActionResult SendForReview(SendForReviewViewModel send) { var required = send.SignOffRequiredChecked.IndexOf(collaborator) != -1; competencyAssessmentService.InsertSelfAssessmentReview(send.CompetencyAssessmentID, collaborator, required); - frameworkNotificationService.SendReviewRequestForCompetencyAssessment(collaborator, adminId, required, false, User.GetCentreIdKnownNotNull()); + frameworkNotificationService.SendReviewRequestForSelfAssessment(collaborator, adminId, required, false, User.GetCentreIdKnownNotNull()); } competencyAssessmentService.UpdateCompetencyAssessmentPublishStatus(send.CompetencyAssessmentID, 2, adminId); var taskStatus = competencyAssessmentService.GetCompetencyAssessmentTaskStatus(send.CompetencyAssessmentID, null); @@ -1588,7 +1588,7 @@ public IActionResult SubmitReview(SubmitReviewViewModel submit) } commentId = competencyAssessmentService.InsertComment(submit.CompetencyAssessmentID, adminId, submit.SelfAssessmentReview.Comment, null); competencyAssessmentService.UpdateSelfAssessmentReview(submit.CompetencyAssessmentID, submit.SelfAssessmentReview.ID, submit.SelfAssessmentReview.SignedOff, commentId); - frameworkNotificationService.SendCompetencyAssessmentsReviewOutcomeNotification(submit.SelfAssessmentReview.ID, centreId); + frameworkNotificationService.SendSelfAssessmentsReviewOutcomeNotification(submit.SelfAssessmentReview.ID, centreId); return RedirectToAction("ManageCompetencyAssessment", new { competencyAssessmentId = submit.CompetencyAssessmentID }); } [HttpGet] @@ -1620,7 +1620,7 @@ public IActionResult PublishSelfAssesment(int competencyAssessmentId) public IActionResult ResendRequest(int reviewId, int competencyAssessmentId, int competencyAssessmentCollaboratorId, bool required) { var adminId = GetAdminID(); - frameworkNotificationService.SendReviewRequestForCompetencyAssessment(competencyAssessmentCollaboratorId, adminId, required, true, User.GetCentreIdKnownNotNull()); + frameworkNotificationService.SendReviewRequestForSelfAssessment(competencyAssessmentCollaboratorId, adminId, required, true, User.GetCentreIdKnownNotNull()); competencyAssessmentService.UpdateReviewRequestedDate(reviewId); return RedirectToAction("PublishReview", new { competencyAssessmentId }); } @@ -1630,7 +1630,7 @@ public IActionResult RequestReReview(int competencyAssessmentId, int reviewId) competencyAssessmentService.InsertCompetencySelfAssessmentReview(reviewId); var review = competencyAssessmentService.GetSelfAssessmentReviewNotification(reviewId); if (review == null) return StatusCode(404); - frameworkNotificationService.SendReviewRequestForCompetencyAssessment(review.SelfAssessmentCollaboratorID, adminId, review.SignOffRequired, false, User.GetCentreIdKnownNotNull()); + frameworkNotificationService.SendReviewRequestForSelfAssessment(review.SelfAssessmentCollaboratorID, adminId, review.SignOffRequired, false, User.GetCentreIdKnownNotNull()); return RedirectToAction("PublishReview", new { competencyAssessmentId }); } public IActionResult RemoveRequest(int competencyAssessmentId, int reviewId) diff --git a/DigitalLearningSolutions.Web/Services/FrameworkNotificationService.cs b/DigitalLearningSolutions.Web/Services/FrameworkNotificationService.cs index 87fc45f709..c224fdb975 100644 --- a/DigitalLearningSolutions.Web/Services/FrameworkNotificationService.cs +++ b/DigitalLearningSolutions.Web/Services/FrameworkNotificationService.cs @@ -25,8 +25,8 @@ public interface IFrameworkNotificationService void SendSignOffRequest(int candidateAssessmentSupervisorId, int selfAssessmentID, int delegateUserId, int centreId); void SendProfileAssessmentSignedOff(int supervisorDelegateId, int candidateAssessmentId, string? supervisorComments, bool signedOff, int adminId, int centreId); void SendSupervisorDelegateReminder(int supervisorDelegateId, int adminId, int centreId); - void SendReviewRequestForCompetencyAssessment(int id, int invitedByAdminId, bool required, bool reminder, int centreId); - void SendCompetencyAssessmentsReviewOutcomeNotification(int reviewId, int centreId); + void SendReviewRequestForSelfAssessment(int id, int invitedByAdminId, bool required, bool reminder, int centreId); + void SendSelfAssessmentsReviewOutcomeNotification(int reviewId, int centreId); } public class FrameworkNotificationService : IFrameworkNotificationService @@ -142,7 +142,7 @@ public void SendReviewRequest(int id, int invitedByAdminId, bool required, bool }; emailService.SendEmail(new Email(emailSubjectLine, builder, collaboratorNotification.UserEmail, collaboratorNotification.InvitedByEmail)); } - public void SendReviewRequestForCompetencyAssessment(int id, int invitedByAdminId, bool required, bool reminder, int centreId) + public void SendReviewRequestForSelfAssessment(int id, int invitedByAdminId, bool required, bool reminder, int centreId) { string centreName = GetCentreName(centreId); var collaboratorNotification = competencyAssessmentService.GetCollaboratorNotification(id, invitedByAdminId); @@ -170,12 +170,12 @@ public string GetFrameworkUrl(int frameworkId, string tab) } public string GetCompetencyAssessmentUrl(int selfAssessmentID, string actionName, int? id = null) { - var competencyAssessmentUrl = GetDLSUriBuilder(); + var selfAssessmentUrl = GetDLSUriBuilder(); - competencyAssessmentUrl.Path += id != null - ? $"CompetencyAssessments/{selfAssessmentID}/{id}/{actionName}" - : $"CompetencyAssessments/{selfAssessmentID}/{actionName}"; - return competencyAssessmentUrl.Uri.ToString(); + selfAssessmentUrl.Path += id != null + ? $"Self-Assessment/{selfAssessmentID}/{id}/{actionName}" + : $"Self-Assessment/{selfAssessmentID}/{actionName}"; + return selfAssessmentUrl.Uri.ToString(); } public string GetCurrentActivitiesUrl() { @@ -234,7 +234,7 @@ public void SendReviewOutcomeNotification(int reviewId, int centreId) }; emailService.SendEmail(new Email(emailSubjectLine, builder, outcomeNotification.OwnerEmail, outcomeNotification.UserEmail)); } - public void SendCompetencyAssessmentsReviewOutcomeNotification(int reviewId, int centreId) + public void SendSelfAssessmentsReviewOutcomeNotification(int reviewId, int centreId) { string centreName = GetCentreName(centreId); var outcomeNotification = competencyAssessmentService.GetSelfAssessmentReviewNotification(reviewId); @@ -243,25 +243,25 @@ public void SendCompetencyAssessmentsReviewOutcomeNotification(int reviewId, int throw new NotificationDataException($"No record found when trying to fetch review outcome Data. reviewId: {reviewId}"); } var competencyAssessmentUrl = GetCompetencyAssessmentUrl(outcomeNotification.SelfAssessmentID, "PublishReview"); - string emailSubjectLine = $"Competency Assessment Review Outcome - {(outcomeNotification.SignedOff ? "Approved" : "Rejected")} - Digital Learning Solutions"; - string approvalStatus = outcomeNotification.ReviewerFirstName + (outcomeNotification.SignedOff ? " approved the competency assessment for publishing." : " did not approve the competency assessment for publishing."); + string emailSubjectLine = $"Self-assessment Review Outcome - {(outcomeNotification.SignedOff ? "Approved" : "Rejected")} - Digital Learning Solutions"; + string approvalStatus = outcomeNotification.ReviewerFirstName + (outcomeNotification.SignedOff ? " approved the self-assessment for publishing." : " did not approve the self-assessment for publishing."); string commentsText = outcomeNotification.ReviewerFirstName + (outcomeNotification.Comment != null ? " left the following review comment: " + outcomeNotification.Comment : " did not leave a review comment."); string commentsHtml = "

" + outcomeNotification.ReviewerFirstName + (outcomeNotification.Comment != null ? " left the following review comment:


" + outcomeNotification.Comment + "


" : " did not leave a review comment.

"); string reviewerFullName = $"{outcomeNotification.ReviewerFirstName} {outcomeNotification.ReviewerLastName} {(outcomeNotification.ReviewerActive == true ? "" : " (inactive)")}"; var builder = new BodyBuilder { TextBody = $@"Dear {outcomeNotification.OwnerFirstName}, - Your competency assessment, {outcomeNotification.SelfAssessmentName}, has been reviewed by {reviewerFullName} ({outcomeNotification.UserEmail}) ({centreName}). + Your self-assessment, {outcomeNotification.SelfAssessmentName}, has been reviewed by {reviewerFullName} ({outcomeNotification.UserEmail}) ({centreName}). {approvalStatus} {commentsText} - The full competency assessment review status, can be viewed by visiting: {competencyAssessmentUrl}. Once all of the required reviewers have approved the competency assessment, you may publish it. You will need to login to the Digital Learning Solutions platform to access the competency assessment.", + The full self-assessment review status, can be viewed by visiting: {competencyAssessmentUrl}. Once all of the required reviewers have approved the self-assessment, you may publish it. You will need to login to the Digital Learning Solutions platform to access the self-assessment.", HtmlBody = $@"

Dear {outcomeNotification.OwnerFirstName},

-

Your competency assessment, {outcomeNotification.SelfAssessmentName}, has been reviewed by {reviewerFullName} ({centreName}).

+

Your self-assessment, {outcomeNotification.SelfAssessmentName}, has been reviewed by {reviewerFullName} ({centreName}).

{approvalStatus}

{commentsHtml} -

Click here to view the full review status for the competency assessment. Once all of the required reviewers have approved the competency assessment, you may publish it.

-

You will need to login to the Digital Learning Solutions platform to access the competency assessment.

+

Click here to view the full review status for the self-assessment. Once all of the required reviewers have approved the self-assessment, you may publish it.

+

You will need to login to the Digital Learning Solutions platform to access the self-assessment.

", }; emailService.SendEmail(new Email(emailSubjectLine, builder, outcomeNotification.OwnerEmail, outcomeNotification.UserEmail)); diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Index.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Index.cshtml index 607499f026..1666c23e6a 100644 --- a/DigitalLearningSolutions.Web/Views/Frameworks/Index.cshtml +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Index.cshtml @@ -11,15 +11,7 @@ @section NavMenuItems { } -@section NavBreadcrumbs { - -} +

Frameworks dashboard

Your to do list

@if (Model.DashboardToDoItems.Count() > 0) From ee082583b769d2f7147dad430520bf9f09cfd0e0 Mon Sep 17 00:00:00 2001 From: sherif-olaboye <123654949+sherif-olaboye@users.noreply.github.com> Date: Tue, 19 May 2026 09:30:46 +0100 Subject: [PATCH 2/2] TD-6941 Moving the Self-assessment notification method from the FrameworkNotificationService to SelfAssessmentNotificationService.cs --- .../CompetencyAssessments.cs | 8 +- .../Services/FrameworkNotificationService.cs | 66 +-------------- .../SelfAssessmentNotificationService.cs | 82 +++++++++++++++++-- 3 files changed, 82 insertions(+), 74 deletions(-) diff --git a/DigitalLearningSolutions.Web/Controllers/CompetencyAssessmentsController/CompetencyAssessments.cs b/DigitalLearningSolutions.Web/Controllers/CompetencyAssessmentsController/CompetencyAssessments.cs index e6bd06aed1..42f0a0e998 100644 --- a/DigitalLearningSolutions.Web/Controllers/CompetencyAssessmentsController/CompetencyAssessments.cs +++ b/DigitalLearningSolutions.Web/Controllers/CompetencyAssessmentsController/CompetencyAssessments.cs @@ -1501,7 +1501,7 @@ public IActionResult SendForReview(SendForReviewViewModel send) { var required = send.SignOffRequiredChecked.IndexOf(collaborator) != -1; competencyAssessmentService.InsertSelfAssessmentReview(send.CompetencyAssessmentID, collaborator, required); - frameworkNotificationService.SendReviewRequestForSelfAssessment(collaborator, adminId, required, false, User.GetCentreIdKnownNotNull()); + selfAssessmentNotificationService.SendReviewRequestForSelfAssessment(collaborator, adminId, required, false, User.GetCentreIdKnownNotNull()); } competencyAssessmentService.UpdateCompetencyAssessmentPublishStatus(send.CompetencyAssessmentID, 2, adminId); var taskStatus = competencyAssessmentService.GetCompetencyAssessmentTaskStatus(send.CompetencyAssessmentID, null); @@ -1588,7 +1588,7 @@ public IActionResult SubmitReview(SubmitReviewViewModel submit) } commentId = competencyAssessmentService.InsertComment(submit.CompetencyAssessmentID, adminId, submit.SelfAssessmentReview.Comment, null); competencyAssessmentService.UpdateSelfAssessmentReview(submit.CompetencyAssessmentID, submit.SelfAssessmentReview.ID, submit.SelfAssessmentReview.SignedOff, commentId); - frameworkNotificationService.SendSelfAssessmentsReviewOutcomeNotification(submit.SelfAssessmentReview.ID, centreId); + selfAssessmentNotificationService.SendSelfAssessmentsReviewOutcomeNotification(submit.SelfAssessmentReview.ID, centreId); return RedirectToAction("ManageCompetencyAssessment", new { competencyAssessmentId = submit.CompetencyAssessmentID }); } [HttpGet] @@ -1620,7 +1620,7 @@ public IActionResult PublishSelfAssesment(int competencyAssessmentId) public IActionResult ResendRequest(int reviewId, int competencyAssessmentId, int competencyAssessmentCollaboratorId, bool required) { var adminId = GetAdminID(); - frameworkNotificationService.SendReviewRequestForSelfAssessment(competencyAssessmentCollaboratorId, adminId, required, true, User.GetCentreIdKnownNotNull()); + selfAssessmentNotificationService.SendReviewRequestForSelfAssessment(competencyAssessmentCollaboratorId, adminId, required, true, User.GetCentreIdKnownNotNull()); competencyAssessmentService.UpdateReviewRequestedDate(reviewId); return RedirectToAction("PublishReview", new { competencyAssessmentId }); } @@ -1630,7 +1630,7 @@ public IActionResult RequestReReview(int competencyAssessmentId, int reviewId) competencyAssessmentService.InsertCompetencySelfAssessmentReview(reviewId); var review = competencyAssessmentService.GetSelfAssessmentReviewNotification(reviewId); if (review == null) return StatusCode(404); - frameworkNotificationService.SendReviewRequestForSelfAssessment(review.SelfAssessmentCollaboratorID, adminId, review.SignOffRequired, false, User.GetCentreIdKnownNotNull()); + selfAssessmentNotificationService.SendReviewRequestForSelfAssessment(review.SelfAssessmentCollaboratorID, adminId, review.SignOffRequired, false, User.GetCentreIdKnownNotNull()); return RedirectToAction("PublishReview", new { competencyAssessmentId }); } public IActionResult RemoveRequest(int competencyAssessmentId, int reviewId) diff --git a/DigitalLearningSolutions.Web/Services/FrameworkNotificationService.cs b/DigitalLearningSolutions.Web/Services/FrameworkNotificationService.cs index c224fdb975..2645225e6e 100644 --- a/DigitalLearningSolutions.Web/Services/FrameworkNotificationService.cs +++ b/DigitalLearningSolutions.Web/Services/FrameworkNotificationService.cs @@ -25,8 +25,6 @@ public interface IFrameworkNotificationService void SendSignOffRequest(int candidateAssessmentSupervisorId, int selfAssessmentID, int delegateUserId, int centreId); void SendProfileAssessmentSignedOff(int supervisorDelegateId, int candidateAssessmentId, string? supervisorComments, bool signedOff, int adminId, int centreId); void SendSupervisorDelegateReminder(int supervisorDelegateId, int adminId, int centreId); - void SendReviewRequestForSelfAssessment(int id, int invitedByAdminId, bool required, bool reminder, int centreId); - void SendSelfAssessmentsReviewOutcomeNotification(int reviewId, int centreId); } public class FrameworkNotificationService : IFrameworkNotificationService @@ -142,41 +140,14 @@ public void SendReviewRequest(int id, int invitedByAdminId, bool required, bool }; emailService.SendEmail(new Email(emailSubjectLine, builder, collaboratorNotification.UserEmail, collaboratorNotification.InvitedByEmail)); } - public void SendReviewRequestForSelfAssessment(int id, int invitedByAdminId, bool required, bool reminder, int centreId) - { - string centreName = GetCentreName(centreId); - var collaboratorNotification = competencyAssessmentService.GetCollaboratorNotification(id, invitedByAdminId); - if (collaboratorNotification == null) - { - throw new NotificationDataException($"No record found when trying to fetch collaboratorNotification Data. id: {id}, invitedByAdminId: {invitedByAdminId}"); - } - var competencyAssessmentUrl = GetCompetencyAssessmentUrl(collaboratorNotification.SelfAssessmentID, "Review", collaboratorNotification.SelfAssessmentReviewID); - string emailSubjectLine = (reminder ? " REMINDER: " : "") + "Self-assessment Review Request - Digital Learning Solutions"; - string signOffRequired = required ? "You are required to sign-off this self-assessment before it can be published." : "You are not required to sign-off this self-assessment before it is published."; - var builder = new BodyBuilder - { - TextBody = $@"Dear colleague, - You have been requested to review the self-assessment, {collaboratorNotification?.CompetencyAssessmentName}, by {collaboratorNotification?.InvitedByName} ({collaboratorNotification?.InvitedByEmail}) ({centreName}). - To review the self-assessment, visit this url: {competencyAssessmentUrl}. Click the Review self-assessment button to submit your review and, if appropriate, sign-off the self-assessment. {signOffRequired}. You will need to be registered on the Digital Learning Solutions platform to review the self-assessment.", - HtmlBody = $@"

Dear colleague,

You have been requested to review the self-assessment, {collaboratorNotification?.CompetencyAssessmentName}, by {collaboratorNotification?.InvitedByName} ({centreName}).

Click here to review the self-assessment. Click the Review self-assessment button to submit your review and, if appropriate, sign-off the self-assessment.

{signOffRequired}

You will need to be registered on the Digital Learning Solutions platform to view the self-assessment.

" - }; - emailService.SendEmail(new Email(emailSubjectLine, builder, collaboratorNotification.UserEmail, collaboratorNotification.InvitedByEmail)); - } + public string GetFrameworkUrl(int frameworkId, string tab) { var frameworkUrl = GetDLSUriBuilder(); frameworkUrl.Path += $"Framework/{frameworkId}/{tab}/"; return frameworkUrl.Uri.ToString(); } - public string GetCompetencyAssessmentUrl(int selfAssessmentID, string actionName, int? id = null) - { - var selfAssessmentUrl = GetDLSUriBuilder(); - - selfAssessmentUrl.Path += id != null - ? $"Self-Assessment/{selfAssessmentID}/{id}/{actionName}" - : $"Self-Assessment/{selfAssessmentID}/{actionName}"; - return selfAssessmentUrl.Uri.ToString(); - } + public string GetCurrentActivitiesUrl() { var dlsUrlBuilder = GetDLSUriBuilder(); @@ -234,39 +205,6 @@ public void SendReviewOutcomeNotification(int reviewId, int centreId) }; emailService.SendEmail(new Email(emailSubjectLine, builder, outcomeNotification.OwnerEmail, outcomeNotification.UserEmail)); } - public void SendSelfAssessmentsReviewOutcomeNotification(int reviewId, int centreId) - { - string centreName = GetCentreName(centreId); - var outcomeNotification = competencyAssessmentService.GetSelfAssessmentReviewNotification(reviewId); - if (outcomeNotification == null) - { - throw new NotificationDataException($"No record found when trying to fetch review outcome Data. reviewId: {reviewId}"); - } - var competencyAssessmentUrl = GetCompetencyAssessmentUrl(outcomeNotification.SelfAssessmentID, "PublishReview"); - string emailSubjectLine = $"Self-assessment Review Outcome - {(outcomeNotification.SignedOff ? "Approved" : "Rejected")} - Digital Learning Solutions"; - string approvalStatus = outcomeNotification.ReviewerFirstName + (outcomeNotification.SignedOff ? " approved the self-assessment for publishing." : " did not approve the self-assessment for publishing."); - string commentsText = outcomeNotification.ReviewerFirstName + (outcomeNotification.Comment != null ? " left the following review comment: " + outcomeNotification.Comment : " did not leave a review comment."); - string commentsHtml = "

" + outcomeNotification.ReviewerFirstName + (outcomeNotification.Comment != null ? " left the following review comment:


" + outcomeNotification.Comment + "


" : " did not leave a review comment.

"); - string reviewerFullName = $"{outcomeNotification.ReviewerFirstName} {outcomeNotification.ReviewerLastName} {(outcomeNotification.ReviewerActive == true ? "" : " (inactive)")}"; - var builder = new BodyBuilder - { - TextBody = $@"Dear {outcomeNotification.OwnerFirstName}, - Your self-assessment, {outcomeNotification.SelfAssessmentName}, has been reviewed by {reviewerFullName} ({outcomeNotification.UserEmail}) ({centreName}). - {approvalStatus} - {commentsText} - The full self-assessment review status, can be viewed by visiting: {competencyAssessmentUrl}. Once all of the required reviewers have approved the self-assessment, you may publish it. You will need to login to the Digital Learning Solutions platform to access the self-assessment.", - HtmlBody = $@" -

Dear {outcomeNotification.OwnerFirstName},

-

Your self-assessment, {outcomeNotification.SelfAssessmentName}, has been reviewed by {reviewerFullName} ({centreName}).

-

{approvalStatus}

- {commentsHtml} -

Click here to view the full review status for the self-assessment. Once all of the required reviewers have approved the self-assessment, you may publish it.

-

You will need to login to the Digital Learning Solutions platform to access the self-assessment.

- ", - }; - emailService.SendEmail(new Email(emailSubjectLine, builder, outcomeNotification.OwnerEmail, outcomeNotification.UserEmail)); - } - public void SendSupervisorDelegateInvite(int supervisorDelegateId, int adminId, int centreId) { diff --git a/DigitalLearningSolutions.Web/Services/SelfAssessmentNotificationService.cs b/DigitalLearningSolutions.Web/Services/SelfAssessmentNotificationService.cs index ccca71d0ea..a87dbbde83 100644 --- a/DigitalLearningSolutions.Web/Services/SelfAssessmentNotificationService.cs +++ b/DigitalLearningSolutions.Web/Services/SelfAssessmentNotificationService.cs @@ -10,6 +10,8 @@ public interface ISelfAssessmentNotificationService { void SendCompetencyAssessmentCollaboratorInvite(int id, int invitedByAdminId); + void SendReviewRequestForSelfAssessment(int id, int invitedByAdminId, bool required, bool reminder, int centreId); + void SendSelfAssessmentsReviewOutcomeNotification(int reviewId, int centreId); } public class SelfAssessmentNotificationService : ISelfAssessmentNotificationService @@ -18,15 +20,19 @@ public class SelfAssessmentNotificationService : ISelfAssessmentNotificationServ private readonly IConfigDataService configDataService; private readonly IEmailService emailService; private readonly ICompetencyAssessmentService competencyAssessmentService; + private readonly ICentresDataService centresDataService; + public SelfAssessmentNotificationService( ICompetencyAssessmentService competencyAssessmentService, IConfigDataService configDataService, - IEmailService emailService + IEmailService emailService, + ICentresDataService centresDataService ) { this.competencyAssessmentService = competencyAssessmentService; this.configDataService = configDataService; this.emailService = emailService; + this.centresDataService = centresDataService; } public void SendCompetencyAssessmentCollaboratorInvite(int id, int invitedByAdminId) { @@ -37,22 +43,83 @@ public void SendCompetencyAssessmentCollaboratorInvite(int id, int invitedByAdmi } var competencyAssessmentUrl = GetCompetencyAssessmentkUrl(collaboratorNotification.SelfAssessmentID, "Manage"); - string emailSubjectLine = $"Competency assessment {collaboratorNotification.CompetencyAssessmentRole} Invitation - Digital Learning Solutions"; + string emailSubjectLine = $"Self-assessment {collaboratorNotification.CompetencyAssessmentRole} Invitation - Digital Learning Solutions"; var builder = new BodyBuilder { TextBody = $@"Dear colleague, - You have been identified as a {collaboratorNotification.CompetencyAssessmentRole} for the competency assessment, {collaboratorNotification.CompetencyAssessmentName} by {collaboratorNotification.InvitedByName} ({collaboratorNotification.InvitedByEmail}). - To access the competency assessment, visit this url: {competencyAssessmentUrl}. You must be registered on the Digital Learning Solutions platform to view the self-assessment.", + You have been identified as a {collaboratorNotification.CompetencyAssessmentRole} for the self-assessment, {collaboratorNotification.CompetencyAssessmentName} by {collaboratorNotification.InvitedByName} ({collaboratorNotification.InvitedByEmail}). + To access the self-assessment, visit this url: {competencyAssessmentUrl}. You must be registered on the Digital Learning Solutions platform to view the self-assessment.", HtmlBody = $@"

Dear colleague,

-

You have been identified as a {collaboratorNotification.CompetencyAssessmentRole} for the competency assessment {collaboratorNotification.CompetencyAssessmentName}, by {collaboratorNotification.InvitedByName}.

+

You have been identified as a {collaboratorNotification.CompetencyAssessmentRole} for the self-assessment {collaboratorNotification.CompetencyAssessmentName}, by {collaboratorNotification.InvitedByName}.

Use this link to access the self-assessment. You must be registered on the Digital Learning Solutions platform to view the self-assessment.

", }; emailService.SendEmail(new Email(emailSubjectLine, builder, collaboratorNotification.UserEmail, collaboratorNotification.InvitedByEmail)); } + public void SendReviewRequestForSelfAssessment(int id, int invitedByAdminId, bool required, bool reminder, int centreId) + { + string centreName = GetCentreName(centreId); + var collaboratorNotification = this.competencyAssessmentService.GetCollaboratorNotification(id, invitedByAdminId); + if (collaboratorNotification == null) + { + throw new NotificationDataException($"No record found when trying to fetch collaboratorNotification Data. id: {id}, invitedByAdminId: {invitedByAdminId}"); + } + var competencyAssessmentUrl = GetSelfAssessmentUrl(collaboratorNotification.SelfAssessmentID, "Review", collaboratorNotification.SelfAssessmentReviewID); + string emailSubjectLine = (reminder ? " REMINDER: " : "") + "Self-assessment Review Request - Digital Learning Solutions"; + string signOffRequired = required ? "You are required to sign-off this self-assessment before it can be published." : "You are not required to sign-off this self-assessment before it is published."; + var builder = new BodyBuilder + { + TextBody = $@"Dear colleague, + You have been requested to review the self-assessment, {collaboratorNotification?.CompetencyAssessmentName}, by {collaboratorNotification?.InvitedByName} ({collaboratorNotification?.InvitedByEmail}) ({centreName}). + To review the self-assessment, visit this url: {competencyAssessmentUrl}. Click the Review self-assessment button to submit your review and, if appropriate, sign-off the self-assessment. {signOffRequired}. You will need to be registered on the Digital Learning Solutions platform to review the self-assessment.", + HtmlBody = $@"

Dear colleague,

You have been requested to review the self-assessment, {collaboratorNotification?.CompetencyAssessmentName}, by {collaboratorNotification?.InvitedByName} ({centreName}).

Click here to review the self-assessment. Click the Review self-assessment button to submit your review and, if appropriate, sign-off the self-assessment.

{signOffRequired}

You will need to be registered on the Digital Learning Solutions platform to view the self-assessment.

" + }; + emailService.SendEmail(new Email(emailSubjectLine, builder, collaboratorNotification.UserEmail, collaboratorNotification.InvitedByEmail)); + } + public void SendSelfAssessmentsReviewOutcomeNotification(int reviewId, int centreId) + { + string centreName = GetCentreName(centreId); + var outcomeNotification = this.competencyAssessmentService.GetSelfAssessmentReviewNotification(reviewId); + if (outcomeNotification == null) + { + throw new NotificationDataException($"No record found when trying to fetch review outcome Data. reviewId: {reviewId}"); + } + var competencyAssessmentUrl = GetSelfAssessmentUrl(outcomeNotification.SelfAssessmentID, "PublishReview"); + string emailSubjectLine = $"Self-assessment Review Outcome - {(outcomeNotification.SignedOff ? "Approved" : "Rejected")} - Digital Learning Solutions"; + string approvalStatus = outcomeNotification.ReviewerFirstName + (outcomeNotification.SignedOff ? " approved the self-assessment for publishing." : " did not approve the self-assessment for publishing."); + string commentsText = outcomeNotification.ReviewerFirstName + (outcomeNotification.Comment != null ? " left the following review comment: " + outcomeNotification.Comment : " did not leave a review comment."); + string commentsHtml = "

" + outcomeNotification.ReviewerFirstName + (outcomeNotification.Comment != null ? " left the following review comment:


" + outcomeNotification.Comment + "


" : " did not leave a review comment.

"); + string reviewerFullName = $"{outcomeNotification.ReviewerFirstName} {outcomeNotification.ReviewerLastName} {(outcomeNotification.ReviewerActive == true ? "" : " (inactive)")}"; + var builder = new BodyBuilder + { + TextBody = $@"Dear {outcomeNotification.OwnerFirstName}, + Your self-assessment, {outcomeNotification.SelfAssessmentName}, has been reviewed by {reviewerFullName} ({outcomeNotification.UserEmail}) ({centreName}). + {approvalStatus} + {commentsText} + The full self-assessment review status, can be viewed by visiting: {competencyAssessmentUrl}. Once all of the required reviewers have approved the self-assessment, you may publish it. You will need to login to the Digital Learning Solutions platform to access the self-assessment.", + HtmlBody = $@" +

Dear {outcomeNotification.OwnerFirstName},

+

Your self-assessment, {outcomeNotification.SelfAssessmentName}, has been reviewed by {reviewerFullName} ({centreName}).

+

{approvalStatus}

+ {commentsHtml} +

Click here to view the full review status for the self-assessment. Once all of the required reviewers have approved the self-assessment, you may publish it.

+

You will need to login to the Digital Learning Solutions platform to access the self-assessment.

+ ", + }; + emailService.SendEmail(new Email(emailSubjectLine, builder, outcomeNotification.OwnerEmail, outcomeNotification.UserEmail)); + } + public string GetSelfAssessmentUrl(int selfAssessmentID, string actionName, int? id = null) + { + var selfAssessmentUrl = GetDLSUriBuilder(); + + selfAssessmentUrl.Path += id != null + ? $"Self-Assessment/{selfAssessmentID}/{id}/{actionName}" + : $"Self-Assessment/{selfAssessmentID}/{actionName}"; + return selfAssessmentUrl.Uri.ToString(); + } public string GetCompetencyAssessmentkUrl(int competencyAssessmentID, string tab) { var competencyAssessmentUrl = GetDLSUriBuilder(); @@ -65,6 +132,9 @@ public UriBuilder GetDLSUriBuilder() throw new ConfigValueMissingException(configDataService.GetConfigValueMissingExceptionMessage("AppBaseUrl")); return new UriBuilder(trackingSystemBaseUrl); } - + public string GetCentreName(int centreId) + { + return centresDataService.GetCentreName(centreId); + } } }