From e24de765e13b28363a47da10f1f9be7c10fea281 Mon Sep 17 00:00:00 2001 From: kevwhitt-hee Date: Thu, 9 Feb 2023 07:42:53 +0000 Subject: [PATCH 1/3] TD-1098 Implements basic models, services and views for self assessment reports --- .../SelfAsssessmentReportDataService.cs | 129 ++++++++++++++++++ .../Export/SelfAssessmentReportData.cs | 24 ++++ .../SelfAssessments/SelfAssessmentSelect.cs | 8 ++ .../Services/SelfAssessmentReportService.cs | 33 ++++- .../SelfAssessmentReportsController.cs | 22 ++- .../DigitalLearningSolutions.Web.csproj | 4 + DigitalLearningSolutions.Web/Startup.cs | 1 + .../SelfAssessmentReportsViewModel.cs | 18 +++ .../Centre/SelfAssessmentReports/Index.cshtml | 16 ++- 9 files changed, 246 insertions(+), 9 deletions(-) create mode 100644 DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAsssessmentReportDataService.cs create mode 100644 DigitalLearningSolutions.Data/Models/SelfAssessments/Export/SelfAssessmentReportData.cs create mode 100644 DigitalLearningSolutions.Data/Models/SelfAssessments/SelfAssessmentSelect.cs create mode 100644 DigitalLearningSolutions.Web/ViewModels/TrackingSystem/Centre/SelfAssessmentReports/SelfAssessmentReportsViewModel.cs diff --git a/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAsssessmentReportDataService.cs b/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAsssessmentReportDataService.cs new file mode 100644 index 0000000000..3870489b34 --- /dev/null +++ b/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAsssessmentReportDataService.cs @@ -0,0 +1,129 @@ +namespace DigitalLearningSolutions.Data.DataServices.SelfAssessmentDataService +{ + using Dapper; + using DigitalLearningSolutions.Data.Models.SelfAssessments.Export; + using DigitalLearningSolutions.Data.Models.SelfAssessments; + using Microsoft.Extensions.Logging; + using System.Collections.Generic; + using System.Data; + + public interface ISelfAssessmentReportDataService + { + IEnumerable GetSelfAssessmentsForReportList(int centreId, int? categoryId); + IEnumerable GetSelfAssessmentReportDataForCentre(int centreId, int selfAssessmentId); + } + public partial class SelfAssessmentReportDataService : ISelfAssessmentReportDataService + { + private readonly IDbConnection connection; + private readonly ILogger logger; + + public SelfAssessmentReportDataService(IDbConnection connection, ILogger logger) + { + this.connection = connection; + this.logger = logger; + } + + public IEnumerable GetSelfAssessmentsForReportList(int centreId, int? categoryId) + { + return connection.Query( + @"SELECT csa.SelfAssessmentID AS Id, sa.Name + FROM CentreSelfAssessments AS csa INNER JOIN + SelfAssessments AS sa ON csa.SelfAssessmentID = sa.ID + WHERE (csa.CentreID = @centreId) AND (sa.CategoryID = @categoryId) AND (sa.SupervisorResultsReview = 1) AND (sa.ArchivedDate IS NULL) OR + (csa.CentreID = @centreId) AND (sa.CategoryID = @categoryId) AND (sa.SupervisorSelfAssessmentReview = 1) AND (sa.ArchivedDate IS NULL) OR + (csa.CentreID = @centreId) AND (@categoryId = 0) AND (sa.SupervisorResultsReview = 1) AND (sa.ArchivedDate IS NULL) OR + (csa.CentreID = @centreId) AND (@categoryId = 0) AND (sa.SupervisorSelfAssessmentReview = 1) AND (sa.ArchivedDate IS NULL)", + new { centreId, categoryId=categoryId??=0 } + ); + } + + public IEnumerable GetSelfAssessmentReportDataForCentre(int centreId, int selfAssessmentId) + { + return connection.Query( + @"WITH LatestAssessmentResults AS + ( + SELECT s.CandidateID + , CASE WHEN COALESCE (rr.LevelRAG, 0) = 3 THEN s.ID ELSE 0 END AS SelfAssessed + , CASE WHEN sv.Verified IS NOT NULL AND sv.SignedOff = 1 AND COALESCE (rr.LevelRAG, 0) = 3 THEN s.ID ELSE 0 END AS Confirmed + , CASE WHEN sas.Optional = 1 THEN s.CompetencyID ELSE 0 END AS Optional + FROM SelfAssessmentResults AS s INNER JOIN + (SELECT MAX(ID) AS ID + FROM SelfAssessmentResults as sar1 INNER JOIN + Candidates as ca1 on sar1.CandidateID = ca1.CandidateID AND ca1.CentreID = @centreId + WHERE (SelfAssessmentID = @selfAssessmentId) + GROUP BY ca1.CandidateID, CompetencyID, AssessmentQuestionID) AS t ON s.ID = t.ID INNER JOIN + SelfAssessmentStructure AS sas ON s.SelfAssessmentID = sas.SelfAssessmentID AND s.CompetencyID = sas.CompetencyID LEFT OUTER JOIN + SelfAssessmentResultSupervisorVerifications AS sv ON s.ID = sv.SelfAssessmentResultId AND sv.Superceded = 0 LEFT OUTER JOIN + CompetencyAssessmentQuestionRoleRequirements AS rr ON s.CompetencyID = rr.CompetencyID AND s.AssessmentQuestionID = rr.AssessmentQuestionID AND s.SelfAssessmentID = rr.SelfAssessmentID AND s.Result = rr.LevelValue + WHERE (s.SelfAssessmentID = @selfAssessmentId) + ) + SELECT + sa.Name AS SelfAssessment + , can.LastName + ', ' + can.FirstName AS Learner + , can.ProfessionalRegistrationNumber AS PRN + , jg.JobGroupName AS JobGroup + , CASE WHEN c.CustomField1PromptID = 10 THEN can.Answer1 WHEN c.CustomField2PromptID = 10 THEN can.Answer2 WHEN c.CustomField3PromptID = 10 THEN can.Answer3 WHEN c.CustomField4PromptID = 10 THEN can.Answer4 WHEN c.CustomField5PromptID = 10 THEN can.Answer5 WHEN c.CustomField6PromptID = 10 THEN can.Answer6 ELSE '' END AS 'ProgrammeCourse' + , CASE WHEN c.CustomField1PromptID = 4 THEN can.Answer1 WHEN c.CustomField2PromptID = 4 THEN can.Answer2 WHEN c.CustomField3PromptID = 4 THEN can.Answer3 WHEN c.CustomField4PromptID = 4 THEN can.Answer4 WHEN c.CustomField5PromptID = 4 THEN can.Answer5 WHEN c.CustomField6PromptID = 4 THEN can.Answer6 ELSE '' END AS 'Organisation' + , CASE WHEN c.CustomField1PromptID = 1 THEN can.Answer1 WHEN c.CustomField2PromptID = 1 THEN can.Answer2 WHEN c.CustomField3PromptID = 1 THEN can.Answer3 WHEN c.CustomField4PromptID = 1 THEN can.Answer4 WHEN c.CustomField5PromptID = 1 THEN can.Answer5 WHEN c.CustomField6PromptID = 1 THEN can.Answer6 ELSE '' END AS 'DepartmentTeam' + , CASE + WHEN au.AdminID IS NULL THEN 'Learner' + WHEN au.IsCentreManager = 1 THEN 'Centre Manager' + WHEN au.CentreAdmin = 1 AND au.IsCentreManager = 0 THEN 'Centre Admin' + WHEN au.Supervisor = 1 THEN 'Supervisor' + WHEN au.NominatedSupervisor = 1 THEN 'Nominated supervisor' + END AS DLSRole + , can.DateRegistered AS Registered + , ca.StartedDate AS Started + , ca.LastAccessed + , COALESCE(COUNT(DISTINCT LAR.Optional), 0) AS [OptionalProficiencies] + , COALESCE(COUNT(DISTINCT LAR.SelfAssessed),0) AS [SelfAssessedAchieved] + , COALESCE(COUNT(DISTINCT LAR.Confirmed), 0) AS [ConfirmedResults] + , max(casv.Requested) AS SignOffRequested + , max(1*casv.SignedOff) AS SignOffAchieved + , min(casv.Verified) AS ReviewedDate + FROM + CandidateAssessments AS ca INNER JOIN + Candidates AS can ON ca.CandidateID = can.CandidateID AND can.CentreID = @centreId INNER JOIN + SelfAssessments AS sa INNER JOIN + CentreSelfAssessments AS csa ON sa.ID = csa.SelfAssessmentID INNER JOIN + Centres AS c ON csa.CentreID = c.CentreID ON can.CentreID = c.CentreID AND ca.SelfAssessmentID = sa.ID INNER JOIN + JobGroups AS jg ON can.JobGroupID = jg.JobGroupID LEFT OUTER JOIN + AdminUsers AS au ON can.EmailAddress = au.Email AND can.CentreID = au.CentreID LEFT OUTER JOIN + CandidateAssessmentSupervisors AS cas ON ca.ID = cas.CandidateAssessmentID left JOIN + CandidateAssessmentSupervisorVerifications AS casv ON casv.CandidateAssessmentSupervisorID = cas.ID LEFT JOIN + SupervisorDelegates AS sd ON cas.SupervisorDelegateId = sd.ID + LEFT OUTER JOIN LatestAssessmentResults AS LAR ON LAR.CandidateID = can.CandidateID + WHERE + (sa.ID = @SelfAssessmentID) AND (sa.ArchivedDate IS NULL) AND (c.Active = 1) AND (ca.RemovedDate IS NULL) AND (ca.StartedDate > CONVERT(DATETIME, '2022-07-31 00:00:00', 102)) + Group by sa.Name + , can.LastName + ', ' + can.FirstName + , can.ProfessionalRegistrationNumber + , c.CustomField1PromptID + , c.CustomField2PromptID + , c.CustomField3PromptID + , c.CustomField4PromptID + , c.CustomField5PromptID + , c.CustomField6PromptID + , jg.JobGroupName + , can.CandidateID + , can.Answer1 + , can.Answer2 + , can.Answer3 + , can.Answer4 + , can.Answer5 + , can.Answer6 + , can.DateRegistered + , au.AdminID + , au.IsCentreManager + , au.CentreAdmin + , au.Supervisor + , au.NominatedSupervisor + , ca.StartedDate + , ca.LastAccessed + ORDER BY + SelfAssessment, can.LastName + ', ' + can.FirstName", + new { centreId, selfAssessmentId } + ); + } + } +} diff --git a/DigitalLearningSolutions.Data/Models/SelfAssessments/Export/SelfAssessmentReportData.cs b/DigitalLearningSolutions.Data/Models/SelfAssessments/Export/SelfAssessmentReportData.cs new file mode 100644 index 0000000000..bf0071aaa7 --- /dev/null +++ b/DigitalLearningSolutions.Data/Models/SelfAssessments/Export/SelfAssessmentReportData.cs @@ -0,0 +1,24 @@ +namespace DigitalLearningSolutions.Data.Models.SelfAssessments.Export +{ + using System; + public class SelfAssessmentReportData + { + public string? SelfAssessment { get; set; } + public string? Learner { get; set; } + public string? PRN { get; set; } + public string? JobGroup { get; set; } + public string? ProgrammeCourse { get; set; } + public string? Organisation { get; set; } + public string? DepartmentTeam { get; set; } + public string? DLSRole { get; set; } + public DateTime? Registered { get; set; } + public DateTime? Started { get; set; } + public DateTime? LastAccessed { get; set; } + public int? OptionalProficiencies { get; set; } + public int? SelfAssessedAchieved { get; set; } + public int? ConfirmedResults { get; set; } + public DateTime? SignOffRequested { get; set; } + public bool SignOffAchieved { get; set; } + public DateTime? ReviewedDate { get; set; } + } +} diff --git a/DigitalLearningSolutions.Data/Models/SelfAssessments/SelfAssessmentSelect.cs b/DigitalLearningSolutions.Data/Models/SelfAssessments/SelfAssessmentSelect.cs new file mode 100644 index 0000000000..bd869f00ed --- /dev/null +++ b/DigitalLearningSolutions.Data/Models/SelfAssessments/SelfAssessmentSelect.cs @@ -0,0 +1,8 @@ +namespace DigitalLearningSolutions.Data.Models.SelfAssessments +{ + public class SelfAssessmentSelect + { + public int Id { get; set; } + public string? Name { get; set; } + } +} diff --git a/DigitalLearningSolutions.Data/Services/SelfAssessmentReportService.cs b/DigitalLearningSolutions.Data/Services/SelfAssessmentReportService.cs index dadc3bfb98..dfebf4f71d 100644 --- a/DigitalLearningSolutions.Data/Services/SelfAssessmentReportService.cs +++ b/DigitalLearningSolutions.Data/Services/SelfAssessmentReportService.cs @@ -2,6 +2,7 @@ { using ClosedXML.Excel; using DigitalLearningSolutions.Data.DataServices.SelfAssessmentDataService; + using DigitalLearningSolutions.Data.Models.SelfAssessments; using System.Collections.Generic; using System.IO; using System.Linq; @@ -9,17 +10,30 @@ public interface ISelfAssessmentReportService { byte[] GetDigitalCapabilityExcelExportForCentre(int centreId); + byte[] GetSelfAssessmentExcelExportForCentre(int centreId, int selfAssessmentId); + IEnumerable GetSelfAssessmentsForReportList(int centreId, int? categoryId); } public class SelfAssessmentReportService : ISelfAssessmentReportService { private readonly IDCSAReportDataService dcsaReportDataService; + private readonly ISelfAssessmentReportDataService selfAssessmentReportDataService; public SelfAssessmentReportService( - IDCSAReportDataService dcsaReportDataService + IDCSAReportDataService dcsaReportDataService, + ISelfAssessmentReportDataService selfAssessmentReportDataService ) { this.dcsaReportDataService = dcsaReportDataService; + this.selfAssessmentReportDataService = selfAssessmentReportDataService; } + private static void AddSheetToWorkbook(IXLWorkbook workbook, string sheetName, IEnumerable? dataObjects) + { + var sheet = workbook.Worksheets.Add(sheetName); + var table = sheet.Cell(1, 1).InsertTable(dataObjects); + table.Theme = XLTableTheme.TableStyleLight9; + sheet.Columns().AdjustToContents(); + } + public byte[] GetDigitalCapabilityExcelExportForCentre(int centreId) { var delegateCompletionStatus = dcsaReportDataService.GetDelegateCompletionStatusForCentre(centreId); @@ -71,12 +85,19 @@ public byte[] GetDigitalCapabilityExcelExportForCentre(int centreId) workbook.SaveAs(stream); return stream.ToArray(); } - private static void AddSheetToWorkbook(IXLWorkbook workbook, string sheetName, IEnumerable? dataObjects) + public IEnumerable GetSelfAssessmentsForReportList(int centreId, int? categoryId) { - var sheet = workbook.Worksheets.Add(sheetName); - var table = sheet.Cell(1, 1).InsertTable(dataObjects); - table.Theme = XLTableTheme.TableStyleLight9; - sheet.Columns().AdjustToContents(); + return selfAssessmentReportDataService.GetSelfAssessmentsForReportList(centreId, categoryId); + } + + public byte[] GetSelfAssessmentExcelExportForCentre(int centreId, int selfAssessmentId) + { + var selfAssessmentReportData = selfAssessmentReportDataService.GetSelfAssessmentReportDataForCentre(centreId, selfAssessmentId); + using var workbook = new XLWorkbook(); + AddSheetToWorkbook(workbook, "SelfAssessmentLearners", selfAssessmentReportData); + using var stream = new MemoryStream(); + workbook.SaveAs(stream); + return stream.ToArray(); } } } diff --git a/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Centre/SelfAssessmentReports/SelfAssessmentReportsController.cs b/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Centre/SelfAssessmentReports/SelfAssessmentReportsController.cs index 61920d8649..23a8047f38 100644 --- a/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Centre/SelfAssessmentReports/SelfAssessmentReportsController.cs +++ b/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Centre/SelfAssessmentReports/SelfAssessmentReportsController.cs @@ -9,6 +9,8 @@ using DigitalLearningSolutions.Web.Models.Enums; using DigitalLearningSolutions.Data.Enums; using System; + using DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Centre.SelfAssessmentReports; + [FeatureGate(FeatureFlags.RefactoredTrackingSystem)] [Authorize(Policy = CustomPolicies.UserCentreAdmin)] [SetDlsSubApplication(nameof(DlsSubApplication.TrackingSystem))] @@ -26,10 +28,13 @@ ISelfAssessmentReportService selfAssessmentReportService } public IActionResult Index() { - return View(); + var centreId = User.GetCentreId(); + var categoryId = User.GetAdminCourseCategoryFilter(); + var model = new SelfAssessmentReportsViewModel(selfAssessmentReportService.GetSelfAssessmentsForReportList(centreId, categoryId)); + return View(model); } [HttpGet] - [Route("Download")] + [Route("DownloadDcsa")] public IActionResult DownloadDigitalCapabilityToExcel() { var centreId = User.GetCentreId(); @@ -41,5 +46,18 @@ public IActionResult DownloadDigitalCapabilityToExcel() fileName ); } + [HttpGet] + [Route("DownloadReport")] + public IActionResult DownloadSelfAssessmentReport(int selfAssessmentId) + { + var centreId = User.GetCentreId(); + var dataFile = selfAssessmentReportService.GetSelfAssessmentExcelExportForCentre(centreId, selfAssessmentId); + var fileName = $"Competency Self Assessment Report - Centre {centreId} - downloaded {DateTime.Today:yyyy-MM-dd}.xlsx"; + return File( + dataFile, + FileHelper.GetContentTypeFromFileName(fileName), + fileName + ); } + } } diff --git a/DigitalLearningSolutions.Web/DigitalLearningSolutions.Web.csproj b/DigitalLearningSolutions.Web/DigitalLearningSolutions.Web.csproj index 049bd39d97..4804535af2 100644 --- a/DigitalLearningSolutions.Web/DigitalLearningSolutions.Web.csproj +++ b/DigitalLearningSolutions.Web/DigitalLearningSolutions.Web.csproj @@ -133,6 +133,10 @@ + + + + diff --git a/DigitalLearningSolutions.Web/Startup.cs b/DigitalLearningSolutions.Web/Startup.cs index 76644bf407..4bf763d8d8 100644 --- a/DigitalLearningSolutions.Web/Startup.cs +++ b/DigitalLearningSolutions.Web/Startup.cs @@ -280,6 +280,7 @@ private static void RegisterDataServices(IServiceCollection services) services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); } private static void RegisterHelpers(IServiceCollection services) diff --git a/DigitalLearningSolutions.Web/ViewModels/TrackingSystem/Centre/SelfAssessmentReports/SelfAssessmentReportsViewModel.cs b/DigitalLearningSolutions.Web/ViewModels/TrackingSystem/Centre/SelfAssessmentReports/SelfAssessmentReportsViewModel.cs new file mode 100644 index 0000000000..1c43af0114 --- /dev/null +++ b/DigitalLearningSolutions.Web/ViewModels/TrackingSystem/Centre/SelfAssessmentReports/SelfAssessmentReportsViewModel.cs @@ -0,0 +1,18 @@ +namespace DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Centre.SelfAssessmentReports +{ + using DigitalLearningSolutions.Data.Models.SelfAssessments; + using System.Collections; + using System.Collections.Generic; + + public class SelfAssessmentReportsViewModel + { + public SelfAssessmentReportsViewModel( + IEnumerable selfAssessmentSelects + ) + { + SelfAssessmentSelects = selfAssessmentSelects; + } + + public IEnumerable SelfAssessmentSelects { get; set; } + } +} diff --git a/DigitalLearningSolutions.Web/Views/TrackingSystem/Centre/SelfAssessmentReports/Index.cshtml b/DigitalLearningSolutions.Web/Views/TrackingSystem/Centre/SelfAssessmentReports/Index.cshtml index 0aef62e87f..d8797d7aeb 100644 --- a/DigitalLearningSolutions.Web/Views/TrackingSystem/Centre/SelfAssessmentReports/Index.cshtml +++ b/DigitalLearningSolutions.Web/Views/TrackingSystem/Centre/SelfAssessmentReports/Index.cshtml @@ -1,4 +1,6 @@ @using DigitalLearningSolutions.Web.Models.Enums +@using DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Centre.SelfAssessmentReports +@model SelfAssessmentReportsViewModel @{ ViewData["Title"] = "Self assessment reports"; } @@ -18,5 +20,17 @@

This page will be used to provide access to comprehensive competency framework self assessment reports for your centre. For now, it provides access to temporary reports for specific self assessments.

- + @if(Model.SelfAssessmentSelects.Any()) + { +

Supervised self assessment reports

+ @foreach (var report in Model.SelfAssessmentSelects) + { + var routeParamsForActionLink = new Dictionary { + { + "selfAssessmentId", report.Id.ToString() }, + }; + + } + } + From d7476e955f84eb86f0ed9eacb5c8e513653a267c Mon Sep 17 00:00:00 2001 From: kevwhitt-hee Date: Thu, 9 Feb 2023 11:38:30 +0000 Subject: [PATCH 2/3] TD-1098 Removes date limiter, tidies up interface and adds count of learners to list of assessments --- .../SelfAsssessmentReportDataService.cs | 11 +++-- .../SelfAssessments/SelfAssessmentSelect.cs | 1 + .../Services/SelfAssessmentReportService.cs | 24 +++++++++- .../Centre/SelfAssessmentReports/Index.cshtml | 45 +++++++++++-------- 4 files changed, 59 insertions(+), 22 deletions(-) diff --git a/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAsssessmentReportDataService.cs b/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAsssessmentReportDataService.cs index 3870489b34..77fdc568fe 100644 --- a/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAsssessmentReportDataService.cs +++ b/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAsssessmentReportDataService.cs @@ -26,13 +26,18 @@ public SelfAssessmentReportDataService(IDbConnection connection, ILogger GetSelfAssessmentsForReportList(int centreId, int? categoryId) { return connection.Query( - @"SELECT csa.SelfAssessmentID AS Id, sa.Name + @"SELECT csa.SelfAssessmentID AS Id, sa.Name, + (SELECT COUNT(*) FROM + CandidateAssessments ca1 INNER JOIN + Candidates c1 ON ca1.CandidateID = c1.CandidateID + WHERE c1.CentreID = @centreId AND ca1.SelfAssessmentID = sa.ID AND ca1.RemovedDate IS NULL) AS LearnerCount FROM CentreSelfAssessments AS csa INNER JOIN SelfAssessments AS sa ON csa.SelfAssessmentID = sa.ID WHERE (csa.CentreID = @centreId) AND (sa.CategoryID = @categoryId) AND (sa.SupervisorResultsReview = 1) AND (sa.ArchivedDate IS NULL) OR (csa.CentreID = @centreId) AND (sa.CategoryID = @categoryId) AND (sa.SupervisorSelfAssessmentReview = 1) AND (sa.ArchivedDate IS NULL) OR (csa.CentreID = @centreId) AND (@categoryId = 0) AND (sa.SupervisorResultsReview = 1) AND (sa.ArchivedDate IS NULL) OR - (csa.CentreID = @centreId) AND (@categoryId = 0) AND (sa.SupervisorSelfAssessmentReview = 1) AND (sa.ArchivedDate IS NULL)", + (csa.CentreID = @centreId) AND (@categoryId = 0) AND (sa.SupervisorSelfAssessmentReview = 1) AND (sa.ArchivedDate IS NULL) + ORDER BY sa.Name", new { centreId, categoryId=categoryId??=0 } ); } @@ -94,7 +99,7 @@ SelfAssessments AS sa INNER JOIN SupervisorDelegates AS sd ON cas.SupervisorDelegateId = sd.ID LEFT OUTER JOIN LatestAssessmentResults AS LAR ON LAR.CandidateID = can.CandidateID WHERE - (sa.ID = @SelfAssessmentID) AND (sa.ArchivedDate IS NULL) AND (c.Active = 1) AND (ca.RemovedDate IS NULL) AND (ca.StartedDate > CONVERT(DATETIME, '2022-07-31 00:00:00', 102)) + (sa.ID = @SelfAssessmentID) AND (sa.ArchivedDate IS NULL) AND (c.Active = 1) AND (ca.RemovedDate IS NULL) Group by sa.Name , can.LastName + ', ' + can.FirstName , can.ProfessionalRegistrationNumber diff --git a/DigitalLearningSolutions.Data/Models/SelfAssessments/SelfAssessmentSelect.cs b/DigitalLearningSolutions.Data/Models/SelfAssessments/SelfAssessmentSelect.cs index bd869f00ed..e893bef979 100644 --- a/DigitalLearningSolutions.Data/Models/SelfAssessments/SelfAssessmentSelect.cs +++ b/DigitalLearningSolutions.Data/Models/SelfAssessments/SelfAssessmentSelect.cs @@ -4,5 +4,6 @@ public class SelfAssessmentSelect { public int Id { get; set; } public string? Name { get; set; } + public int LearnerCount { get; set; } } } diff --git a/DigitalLearningSolutions.Data/Services/SelfAssessmentReportService.cs b/DigitalLearningSolutions.Data/Services/SelfAssessmentReportService.cs index dfebf4f71d..89ac2fd244 100644 --- a/DigitalLearningSolutions.Data/Services/SelfAssessmentReportService.cs +++ b/DigitalLearningSolutions.Data/Services/SelfAssessmentReportService.cs @@ -93,8 +93,30 @@ public IEnumerable GetSelfAssessmentsForReportList(int cen public byte[] GetSelfAssessmentExcelExportForCentre(int centreId, int selfAssessmentId) { var selfAssessmentReportData = selfAssessmentReportDataService.GetSelfAssessmentReportDataForCentre(centreId, selfAssessmentId); + var reportData = selfAssessmentReportData.Select( + x => new + { + x.SelfAssessment, + x.Learner, + x.PRN, + x.JobGroup, + x.ProgrammeCourse, + x.Organisation, + x.DepartmentTeam, + x.DLSRole, + x.Registered, + x.Started, + x.LastAccessed, + x.OptionalProficiencies, + x.SelfAssessedAchieved, + x.ConfirmedResults, + x.SignOffRequested, + x.SignOffAchieved, + x.ReviewedDate + } + ); using var workbook = new XLWorkbook(); - AddSheetToWorkbook(workbook, "SelfAssessmentLearners", selfAssessmentReportData); + AddSheetToWorkbook(workbook, "SelfAssessmentLearners", reportData); using var stream = new MemoryStream(); workbook.SaveAs(stream); return stream.ToArray(); diff --git a/DigitalLearningSolutions.Web/Views/TrackingSystem/Centre/SelfAssessmentReports/Index.cshtml b/DigitalLearningSolutions.Web/Views/TrackingSystem/Centre/SelfAssessmentReports/Index.cshtml index d8797d7aeb..3c1d2d4fe0 100644 --- a/DigitalLearningSolutions.Web/Views/TrackingSystem/Centre/SelfAssessmentReports/Index.cshtml +++ b/DigitalLearningSolutions.Web/Views/TrackingSystem/Centre/SelfAssessmentReports/Index.cshtml @@ -13,24 +13,33 @@

- + Beta - - + - @ViewData["Title"] -

-

This page will be used to provide access to comprehensive competency framework self assessment reports for your centre. For now, it provides access to temporary reports for specific self assessments.

- - @if(Model.SelfAssessmentSelects.Any()) - { -

Supervised self assessment reports

- @foreach (var report in Model.SelfAssessmentSelects) - { - var routeParamsForActionLink = new Dictionary { - { - "selfAssessmentId", report.Id.ToString() }, - }; - - } - } -
+ +

Use this page to download Excel learner activity reports for competency self assessments at your centre.

+ + From 848644a53b3e876187bf9bb10580988a6a361e65 Mon Sep 17 00:00:00 2001 From: kevwhitt-hee Date: Thu, 9 Feb 2023 11:44:40 +0000 Subject: [PATCH 3/3] IDE formatter changes --- .../SelfAsssessmentReportDataService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAsssessmentReportDataService.cs b/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAsssessmentReportDataService.cs index 77fdc568fe..b19ef7d4e3 100644 --- a/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAsssessmentReportDataService.cs +++ b/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAsssessmentReportDataService.cs @@ -38,7 +38,7 @@ FROM CentreSelfAssessments AS csa INNER JOIN (csa.CentreID = @centreId) AND (@categoryId = 0) AND (sa.SupervisorResultsReview = 1) AND (sa.ArchivedDate IS NULL) OR (csa.CentreID = @centreId) AND (@categoryId = 0) AND (sa.SupervisorSelfAssessmentReview = 1) AND (sa.ArchivedDate IS NULL) ORDER BY sa.Name", - new { centreId, categoryId=categoryId??=0 } + new { centreId, categoryId = categoryId ??= 0 } ); }