diff --git a/DigitalLearningSolutions.Web/Controllers/CompetencyAssessmentsController/CompetencyAssessments.cs b/DigitalLearningSolutions.Web/Controllers/CompetencyAssessmentsController/CompetencyAssessments.cs index 2581f964b9..d59f39d44b 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()); + 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.SendCompetencyAssessmentsReviewOutcomeNotification(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.SendReviewRequestForCompetencyAssessment(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.SendReviewRequestForCompetencyAssessment(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 87fc45f709..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 SendReviewRequestForCompetencyAssessment(int id, int invitedByAdminId, bool required, bool reminder, int centreId); - void SendCompetencyAssessmentsReviewOutcomeNotification(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 SendReviewRequestForCompetencyAssessment(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 competencyAssessmentUrl = GetDLSUriBuilder(); - - competencyAssessmentUrl.Path += id != null - ? $"CompetencyAssessments/{selfAssessmentID}/{id}/{actionName}" - : $"CompetencyAssessments/{selfAssessmentID}/{actionName}"; - return competencyAssessmentUrl.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 SendCompetencyAssessmentsReviewOutcomeNotification(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 = $"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 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}). - {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.", - HtmlBody = $@" -

Dear {outcomeNotification.OwnerFirstName},

-

Your competency 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.

- ", - }; - 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 c235893c37..fefe3b03ad 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,7 +43,7 @@ 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 { @@ -52,7 +58,68 @@ public void SendCompetencyAssessmentCollaboratorInvite(int id, int invitedByAdmi }; 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); + } } } 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)