diff --git a/LearningHub.Nhs.WebUI/Views/Reports/_ReportTable.cshtml b/LearningHub.Nhs.WebUI/Views/Reports/_ReportTable.cshtml
index 492abdc0..a5aa336c 100644
--- a/LearningHub.Nhs.WebUI/Views/Reports/_ReportTable.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Reports/_ReportTable.cshtml
@@ -43,19 +43,19 @@
Username
- First Name
+ First name
- Last Name
+ Last name
- Email Address
+ Email address
- Medical Council No
+ Medical council no
- Medical Council Name
+ Medical council name
Role
@@ -67,10 +67,13 @@
Location
- Programme Name
+ Programme name
- Course Learning Path Name
+ Course learning path name
+
+
+ Status
@@ -85,27 +88,27 @@
- First Name
+ First name
@entry.FirstName
- Last Name
+ Last name
@entry.LastName
- Email Address
+ Email address
@entry.Email
- Medical Council No
+ Medical council no
@entry.MedicalCouncilNo
- Medical Council Name
+ Medical council name
@entry.MedicalCouncilName
@@ -125,15 +128,20 @@
- Programme Name
+ Programme name
@entry.Programme
- Course Learning Path Name
+ Course learning path name
@entry.Course
+
+ Status
+ @entry.CourseStatus
+
+
diff --git a/LearningHub.Nhs.WebUI/Views/Shared/Components/DynamicCheckboxes/Default.cshtml b/LearningHub.Nhs.WebUI/Views/Shared/Components/DynamicCheckboxes/Default.cshtml
index 3f4ad4c5..a8512bcf 100644
--- a/LearningHub.Nhs.WebUI/Views/Shared/Components/DynamicCheckboxes/Default.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Shared/Components/DynamicCheckboxes/Default.cshtml
@@ -14,12 +14,21 @@
}
+ @if (!ViewData.ModelState.IsValid && Model.SelectedValues.Count() == 0)
+ {
+
+
+ @Model.ErrorMessage
+
+
+ }
+
@for (int i = 0; i < Model.Checkboxes.Count; i++)
{
var checkbox = Model.Checkboxes[i];
var inputId = i == 0 ? propertyName : $"{propertyName}_{i}";
-
+
-
+
diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Repositories.Interface/LearningHub.Nhs.OpenApi.Repositories.Interface.csproj b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories.Interface/LearningHub.Nhs.OpenApi.Repositories.Interface.csproj
index e7e92397..d8e3b864 100644
--- a/OpenAPI/LearningHub.Nhs.OpenApi.Repositories.Interface/LearningHub.Nhs.OpenApi.Repositories.Interface.csproj
+++ b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories.Interface/LearningHub.Nhs.OpenApi.Repositories.Interface.csproj
@@ -17,7 +17,7 @@
-
+
diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/LearningHub.Nhs.OpenApi.Repositories.csproj b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/LearningHub.Nhs.OpenApi.Repositories.csproj
index 0ee6fa49..c3cd8419 100644
--- a/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/LearningHub.Nhs.OpenApi.Repositories.csproj
+++ b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/LearningHub.Nhs.OpenApi.Repositories.csproj
@@ -24,7 +24,7 @@
-
+
diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/LearningHub.Nhs.OpenApi.Services.Interface.csproj b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/LearningHub.Nhs.OpenApi.Services.Interface.csproj
index 99e4fe96..2c4e458f 100644
--- a/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/LearningHub.Nhs.OpenApi.Services.Interface.csproj
+++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/LearningHub.Nhs.OpenApi.Services.Interface.csproj
@@ -17,7 +17,7 @@
-
+
diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/Messaging/IEmailSenderService.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/Messaging/IEmailSenderService.cs
index 794a55ae..3e4a3f47 100644
--- a/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/Messaging/IEmailSenderService.cs
+++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/Messaging/IEmailSenderService.cs
@@ -54,5 +54,13 @@ public interface IEmailSenderService
/// The isUserRoleUpgrade.
/// The task.
Task SendEmailVerifiedEmail(int userId, SendEmailModel model, bool isUserRoleUpgrade);
+
+ ///
+ /// Sends report generation completion email to user.
+ ///
+ /// The userId sending the email.
+ /// The model.
+ /// The task.
+ Task SendReportProcessedEmail(int userId, SendEmailModel model);
}
}
diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/Messaging/IEmailTemplateService.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/Messaging/IEmailTemplateService.cs
index 7e75ae57..9f676fcd 100644
--- a/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/Messaging/IEmailTemplateService.cs
+++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/Messaging/IEmailTemplateService.cs
@@ -56,5 +56,13 @@ public interface IEmailTemplateService
/// The isUserRoleUpgrade.
/// The subject and body.
EmailDetails GetEmailVerificationEmail(SendEmailModel emailModel, bool isUserRoleUpgrade);
+
+
+ ///
+ /// The GetCatalogueAccessRequestFailure.
+ ///
+ /// The email model.
+ /// The subject and body.
+ EmailDetails GetReportProcessed(SendEmailModel emailModel);
}
}
diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services/LearningHub.Nhs.OpenApi.Services.csproj b/OpenAPI/LearningHub.Nhs.OpenApi.Services/LearningHub.Nhs.OpenApi.Services.csproj
index 7c534adf..bc739639 100644
--- a/OpenAPI/LearningHub.Nhs.OpenApi.Services/LearningHub.Nhs.OpenApi.Services.csproj
+++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services/LearningHub.Nhs.OpenApi.Services.csproj
@@ -30,7 +30,7 @@
-
+
diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/DatabricksService.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/DatabricksService.cs
index ad5baef8..17c3325b 100644
--- a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/DatabricksService.cs
+++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/DatabricksService.cs
@@ -20,6 +20,10 @@
using LearningHub.Nhs.Models.Enums;
using System.Text.Json;
using LearningHub.Nhs.Models.Entities;
+using LearningHub.Nhs.OpenApi.Services.Interface.Services.Messaging;
+using elfhHub.Nhs.Models.Entities;
+using LearningHub.Nhs.Models.Email.Models;
+using LearningHub.Nhs.Models.Email;
namespace LearningHub.Nhs.OpenApi.Services.Services
{
@@ -35,8 +39,10 @@ public class DatabricksService : IDatabricksService
private readonly IQueueCommunicatorService queueCommunicatorService;
private readonly ICachingService cachingService;
private readonly INotificationService notificationService;
+ private readonly IEmailSenderService emailSenderService;
private readonly IUserNotificationService userNotificationService;
private readonly IMoodleApiService moodleApiService;
+ private readonly IUserProfileService userProfileService;
private readonly IMapper mapper;
///
@@ -51,7 +57,9 @@ public class DatabricksService : IDatabricksService
/// notificationService.
/// userNotificationService.
/// moodleApiService.
- public DatabricksService(IOptions databricksConfig,IOptions learningHubConfig, IReportHistoryRepository reportHistoryRepository, IMapper mapper, IQueueCommunicatorService queueCommunicatorService, ICachingService cachingService, INotificationService notificationService, IUserNotificationService userNotificationService, IMoodleApiService moodleApiService)
+ /// emailSenderService.
+ /// userProfileService.
+ public DatabricksService(IOptions databricksConfig,IOptions learningHubConfig, IReportHistoryRepository reportHistoryRepository, IMapper mapper, IQueueCommunicatorService queueCommunicatorService, ICachingService cachingService, INotificationService notificationService, IUserNotificationService userNotificationService, IMoodleApiService moodleApiService, IEmailSenderService emailSenderService, IUserProfileService userProfileService)
{
this.databricksConfig = databricksConfig;
this.learningHubConfig = learningHubConfig;
@@ -62,6 +70,8 @@ public DatabricksService(IOptions databricksConfig,IOptions
@@ -388,20 +398,51 @@ public async Task UpdateDatabricksReport(int userId, DatabricksUpdateRequest dat
var courses = await moodleApiService.GetCoursesByCategoryIdAsync(learningHubConfig.Value.StatMandId);
- firstCourse = string.IsNullOrWhiteSpace(reportHistory.CourseFilter)
- ? courses.Courses.Select(c => c.Displayname).FirstOrDefault()
- : courses.Courses
+ if (string.IsNullOrWhiteSpace(reportHistory.CourseFilter))
+ {
+ firstCourse = "all courses";
+ }
+ else
+ {
+ var matched = courses.Courses
.Where(c => reportHistory.CourseFilter.Contains(c.Id.ToString()))
.Select(c => c.Displayname)
- .FirstOrDefault();
+ .ToList();
+ if (matched.Count == 1)
+ {
+ firstCourse = matched[0].ToLower();
+ }
+ else
+ {
+ firstCourse = $"{matched[0].ToLower()} and {matched.Count - 1} others";
+ }
+ }
- var notificationId = await this.notificationService.CreateReportNotificationAsync(userId, "Course Completion", firstCourse);
- if (notificationId > 0)
+ try
{
- await this.userNotificationService.CreateAsync(userId, new UserNotification { UserId = reportHistory.CreateUserId, NotificationId = notificationId });
+ var notificationId = await this.notificationService.CreateReportNotificationAsync(userId, "course progress", firstCourse);
+
+ if (notificationId > 0)
+ {
+ await this.userNotificationService.CreateAsync(userId, new UserNotification { UserId = reportHistory.CreateUserId, NotificationId = notificationId });
+ }
+ var user = await this.userProfileService.GetByIdAsync(reportHistory.CreateUserId);
+ var emailModel = new SendEmailModel(
+ new ReportSucessEmailModel
+ {
+ UserFirstName = user.FirstName,
+ ReportName = "course progress",
+ ReportTitle = firstCourse,
+ ReportUrl = $"{this.learningHubConfig.Value.BaseUrl.TrimEnd('/')}/{this.learningHubConfig.Value.ReportUrl.TrimStart('/')}"
+ });
+ emailModel.EmailAddress = user.EmailAddress;
+
+ await this.emailSenderService.SendReportProcessedEmail(userId, emailModel);
}
+ catch { }
+
}
else
{
diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/Messaging/EmailSenderService.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/Messaging/EmailSenderService.cs
index d7926033..614ffe2a 100644
--- a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/Messaging/EmailSenderService.cs
+++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/Messaging/EmailSenderService.cs
@@ -60,6 +60,19 @@ public async Task SendAccessRequestInviteEmail(int userId, SendEmailModel
+ /// Sends report generation completion email to user.
+ ///
+ /// The userId sending the email.
+ /// The model.
+ /// The task.
+ public async Task SendReportProcessedEmail(int userId, SendEmailModel model)
+ {
+ var template = emailTemplateService.GetReportProcessed(model);
+ await messageService.CreateEmailAsync(userId, template.Subject, template.Body, template.EmailAddress);
+ }
+
+
///
/// Sends email change confirmation email.
///
diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/Messaging/EmailTemplateService.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/Messaging/EmailTemplateService.cs
index dd485114..ca048f34 100644
--- a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/Messaging/EmailTemplateService.cs
+++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/Messaging/EmailTemplateService.cs
@@ -6,6 +6,7 @@
using LearningHub.Nhs.Models.Email;
using LearningHub.Nhs.Models.Email.Models;
using LearningHub.Nhs.Models.Enums;
+ using LearningHub.Nhs.OpenApi.Models.ViewModels;
using LearningHub.Nhs.OpenApi.Repositories.Interface.Repositories.Messaging;
using LearningHub.Nhs.OpenApi.Services.Interface.Services.Messaging;
@@ -140,6 +141,32 @@ public EmailDetails GetCatalogueAccessInvitation(SendEmailModel
+ /// The GetCatalogueAccessRequestFailure.
+ ///
+ /// The email model.
+ /// The subject and body.
+ public EmailDetails GetReportProcessed(SendEmailModel emailModel)
+ {
+ var emailTemplate = emailTemplateRepository.GetTemplate((int)EmailTemplates.ReportProcessed);
+ var emailBody = this.Replace(emailTemplate.EmailTemplateLayout.Body, new Dictionary
+ {
+ ["Content"] = emailTemplate.Body,
+ });
+ var model = emailModel.Model;
+ var replacementDict = new Dictionary
+ {
+ ["UserFirstName"] = model.UserFirstName,
+ ["ReportSection"] = model.ReportUrl,
+ ["ReportName"] = model.ReportName,
+ ["ReportContent"] = model.ReportTitle,
+ };
+
+ var subject = this.Replace(emailTemplate.Subject, replacementDict);
+ var body = Replace(emailBody, replacementDict);
+ return new EmailDetails { Body = body, Subject = subject, EmailAddress = emailModel.EmailAddress };
+ }
+
///
/// The GetEmailChangeConfirmationEmail.
///
diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Tests/LearningHub.Nhs.OpenApi.Tests.csproj b/OpenAPI/LearningHub.Nhs.OpenApi.Tests/LearningHub.Nhs.OpenApi.Tests.csproj
index 3ecb4d1a..0163d76c 100644
--- a/OpenAPI/LearningHub.Nhs.OpenApi.Tests/LearningHub.Nhs.OpenApi.Tests.csproj
+++ b/OpenAPI/LearningHub.Nhs.OpenApi.Tests/LearningHub.Nhs.OpenApi.Tests.csproj
@@ -11,7 +11,7 @@
-
+
diff --git a/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/ReportController.cs b/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/ReportController.cs
index faee4af0..091b3db5 100644
--- a/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/ReportController.cs
+++ b/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/ReportController.cs
@@ -40,19 +40,19 @@ public async Task GetReporterPermission()
}
///
- /// Get CourseCompletionReport from Databricks.
+ /// Get CourseProgressReport from Databricks.
///
/// requestModel.
/// Task.
[HttpPost]
- [Route("GetCourseCompletionReport")]
- public async Task CourseCompletionReport(DatabricksRequestModel requestModel)
+ [Route("GetCourseProgressReport")]
+ public async Task CourseProgressReport(DatabricksRequestModel requestModel)
{
return await this.databricksService.CourseCompletionReport(this.CurrentUserId.GetValueOrDefault(),requestModel);
}
///
- /// Get CourseCompletionReport from Databricks.
+ /// Get Report History from Databricks.
///
/// request.
/// Task.
diff --git a/OpenAPI/LearningHub.Nhs.OpenApi/LearningHub.NHS.OpenAPI.csproj b/OpenAPI/LearningHub.Nhs.OpenApi/LearningHub.NHS.OpenAPI.csproj
index cfc4572c..c2658181 100644
--- a/OpenAPI/LearningHub.Nhs.OpenApi/LearningHub.NHS.OpenAPI.csproj
+++ b/OpenAPI/LearningHub.Nhs.OpenApi/LearningHub.NHS.OpenAPI.csproj
@@ -19,7 +19,7 @@
-
+
diff --git a/OpenAPI/LearningHub.Nhs.OpenApi/appsettings.json b/OpenAPI/LearningHub.Nhs.OpenApi/appsettings.json
index 76d2bc5c..155a27dd 100644
--- a/OpenAPI/LearningHub.Nhs.OpenApi/appsettings.json
+++ b/OpenAPI/LearningHub.Nhs.OpenApi/appsettings.json
@@ -96,7 +96,7 @@
"ResourceReadonlyAccess": "You can continue to search for and access resources in the Learning Hub, however you cannot contribute to it.
If you have any questions about this, please contact the support team.
",
"ResourceContributeAccess": "You can now contribute to the Learning Hub and continue to search for and access resources.
If you have any questions about this, please contact the support team.
",
"ReportTitle": "[ReportName] report for [ReportContent] is ready",
- "Report": "Your report [ReportName] report for [ReportContent] is ready. You can view and download the report in the Reports Section
"
+ "Report": "Your report [ReportName] report for [ReportContent] is ready. You can view and download the report in the reports section
"
},
"MyContributionsUrl": "/my-contributions",
"MyLearningUrl": "/MyLearning",