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 @@ -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);
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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 });
}
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = $@"<body style= 'font-family: Calibri; font-size: small;'><p>Dear colleague,</p><p>You have been requested to review the self-assessment, {collaboratorNotification?.CompetencyAssessmentName}, by <a href='mailto:{collaboratorNotification?.InvitedByEmail}'>{collaboratorNotification?.InvitedByName} ({centreName})</a>.</p><p><a href='{competencyAssessmentUrl}'>Click here</a> to review the self-assessment. Click the Review self-assessment button to submit your review and, if appropriate, sign-off the self-assessment.</p><p>{signOffRequired}</p><p>You will need to be registered on the Digital Learning Solutions platform to view the self-assessment.</p></body>"
};
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();
Expand Down Expand Up @@ -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 = "<p>" + outcomeNotification.ReviewerFirstName + (outcomeNotification.Comment != null ? " left the following review comment:</p><hr/><p>" + outcomeNotification.Comment + "</p><hr/>" : " did not leave a review comment.</p>");
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 = $@"<body style= 'font-family: Calibri; font-size: small;'>
<p>Dear {outcomeNotification.OwnerFirstName},</p>
<p>Your competency assessment, {outcomeNotification.SelfAssessmentName}, has been reviewed by <a href='mailto:{outcomeNotification.UserEmail}'>{reviewerFullName} ({centreName})</a>.</p>
<p>{approvalStatus}</p>
{commentsHtml}
<p><a href='{competencyAssessmentUrl}'>Click here</a> 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.</p>
<p>You will need to login to the Digital Learning Solutions platform to access the competency assessment.</p>
</body>",
};
emailService.SendEmail(new Email(emailSubjectLine, builder, outcomeNotification.OwnerEmail, outcomeNotification.UserEmail));
}

public void SendSupervisorDelegateInvite(int supervisorDelegateId, int adminId, int centreId)
{

Expand Down
Loading
Loading