Skip to content

Commit e0433d5

Browse files
committed
TD-937 Implements course provider filter and link to report from main page
1 parent 5636eae commit e0433d5

File tree

10 files changed

+53
-21
lines changed

10 files changed

+53
-21
lines changed

DigitalLearningSolutions.Data/DataServices/PlatformReportsDataService.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ public class PlatformReportsDataService : IPlatformReportsDataService
4242
private readonly IDbConnection connection;
4343
private readonly ILogger<PlatformReportsDataService> logger;
4444
private readonly string selectSelfAssessmentActivity = @"SELECT al.ActivityDate, al.Enrolled, al.Submitted | al.SignedOff AS Completed
45-
FROM ReportSelfAssessmentActivityLog AS al INNER JOIN
46-
Centres AS ce ON al.CentreID = ce.CentreID INNER JOIN
47-
SelfAssessments AS sa ON sa.ID = al.SelfAssessmentID
45+
FROM ReportSelfAssessmentActivityLog AS al WITH (NOLOCK) INNER JOIN
46+
Centres AS ce WITH (NOLOCK) ON al.CentreID = ce.CentreID INNER JOIN
47+
SelfAssessments AS sa WITH (NOLOCK) ON sa.ID = al.SelfAssessmentID
4848
WHERE (@endDate IS NULL OR al.ActivityDate <= @endDate) AND
4949
(al.ActivityDate >= @startDate) AND
5050
(sa.[National] = 1) AND
@@ -136,8 +136,8 @@ public DateTime GetSelfAssessmentActivityStartDate(bool supervised)
136136
var whereClause = GetSelfAssessmentWhereClause(supervised);
137137
return connection.QuerySingleOrDefault<DateTime>(
138138
$@"SELECT MIN(al.ActivityDate) AS StartDate
139-
FROM ReportSelfAssessmentActivityLog AS al INNER JOIN
140-
SelfAssessments AS sa ON sa.ID = al.SelfAssessmentID
139+
FROM ReportSelfAssessmentActivityLog AS al WITH (NOLOCK) INNER JOIN
140+
SelfAssessments AS sa WITH (NOLOCK) ON sa.ID = al.SelfAssessmentID
141141
WHERE {whereClause}"
142142
);
143143
}
@@ -199,7 +199,7 @@ Centres AS ce WITH(NOLOCK) ON al.CentreID = ce.CentreID
199199
{
200200
return connection.QuerySingleOrDefault<DateTime?>(
201201
@"SELECT MIN(LogDate)
202-
FROM tActivityLog"
202+
FROM tActivityLog WITH (NOLOCK)"
203203
);
204204
}
205205
}

DigitalLearningSolutions.Web/Controllers/SuperAdmin/PlatformReports/CourseUsageReport.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public IActionResult CourseUsageReport()
1818
var filterData = Request.Cookies.RetrieveFilterDataFromCookie("SuperAdminCourseUsageReportFilterCookie", null);
1919
Response.Cookies.SetReportsFilterCookie("SuperAdminCourseUsageReportFilterCookie", filterData, clockUtility.UtcNow);
2020
var activity = platformReportsService.GetFilteredCourseActivity(filterData);
21-
var (regionName, centreTypeName, centreName, jobGroupName, brandName, categoryName, courseName) = reportFilterService.GetSuperAdminCourseFilterNames(filterData);
21+
var (regionName, centreTypeName, centreName, jobGroupName, brandName, categoryName, courseName, courseProviderName) = reportFilterService.GetSuperAdminCourseFilterNames(filterData);
2222
var courseUsageReportFilterModel = new CourseUsageReportFilterModel(
2323
filterData,
2424
regionName,
@@ -28,6 +28,7 @@ public IActionResult CourseUsageReport()
2828
brandName,
2929
categoryName,
3030
courseName,
31+
courseProviderName,
3132
true
3233
);
3334
var model = new CourseUsageReportViewModel(
@@ -65,7 +66,8 @@ public IActionResult CourseUsageEditFilters(CourseUsageEditFiltersViewModel mode
6566
{
6667
if (!ModelState.IsValid)
6768
{
68-
var filterOptions = GetDropdownValues(false);
69+
var filterOptions = GetCourseFilterDropdownValues();
70+
model.SetUpDropdowns(filterOptions, null);
6971
model.DataStart = platformReportsService.GetStartOfCourseActivity();
7072
return View("CourseUsageEditFilters", model);
7173
}
@@ -82,7 +84,7 @@ public IActionResult CourseUsageEditFilters(CourseUsageEditFiltersViewModel mode
8284
null,
8385
model.CentreTypeId,
8486
model.BrandId,
85-
model.CoreContent,
87+
model.CoreContent.HasValue ? (model.CoreContent.Value != 0) : (bool?)null,
8688
model.FilterType,
8789
model.ReportInterval
8890
);

DigitalLearningSolutions.Web/Controllers/SuperAdmin/PlatformReports/IndependentSelfAssessmentReport.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public IActionResult IndependentSelfAssessmentsEditFilters(SelfAssessmentsEditFi
6363
if (!ModelState.IsValid)
6464
{
6565
var filterOptions = GetDropdownValues(false);
66+
model.SetUpDropdowns(filterOptions, null);
6667
model.DataStart = platformReportsService.GetSelfAssessmentActivityStartDate(false);
6768
return View("SelfAssessmentsEditFilters", model);
6869
}

DigitalLearningSolutions.Web/Controllers/SuperAdmin/PlatformReports/SupervisedSelfAssessmentReport.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public IActionResult SupervisedSelfAssessmentsEditFilters(SelfAssessmentsEditFil
6666
if (!ModelState.IsValid)
6767
{
6868
var filterOptions = GetDropdownValues(true);
69+
model.SetUpDropdowns(filterOptions, null);
6970
model.DataStart = platformReportsService.GetSelfAssessmentActivityStartDate(true);
7071
return View("SelfAssessmentsEditFilters", model);
7172
}

DigitalLearningSolutions.Web/Services/ReportFilterService.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public interface IReportFilterService
1313
(string jobGroupName, string courseCategoryName, string courseName) GetFilterNames(
1414
ActivityFilterData filterData
1515
);
16-
(string regionName, string centreTypeName, string centreName, string jobGroupName, string brandName, string categoryName, string courseName) GetSuperAdminCourseFilterNames(
16+
(string regionName, string centreTypeName, string centreName, string jobGroupName, string brandName, string categoryName, string courseName, string courseProviderName) GetSuperAdminCourseFilterNames(
1717
ActivityFilterData filterData
1818
);
1919
(string regionName, string centreTypeName, string centreName, string jobGroupName, string brandName, string categoryName, string selfAssessmentName) GetSelfAssessmentFilterNames(
@@ -59,18 +59,20 @@ ActivityFilterData filterData
5959
GetCourseCategoryNameForActivityFilter(filterData.CourseCategoryId),
6060
GetCourseNameForActivityFilter(filterData.CustomisationId));
6161
}
62-
public (string regionName, string centreTypeName, string centreName, string jobGroupName, string brandName, string categoryName, string courseName) GetSuperAdminCourseFilterNames(
62+
public (string regionName, string centreTypeName, string centreName, string jobGroupName, string brandName, string categoryName, string courseName, string courseProviderName) GetSuperAdminCourseFilterNames(
6363
ActivityFilterData filterData
6464
)
65-
{
65+
{
6666
return (
6767
GetRegionNameForActivityFilter(filterData.RegionId),
6868
GetCentreTypeNameForActivityFilter(filterData.CentreTypeId),
6969
GetCentreNameForActivityFilter(filterData.CentreId),
7070
GetJobGroupNameForActivityFilter(filterData.JobGroupId),
7171
GetBrandNameForActivityFilter(filterData.BrandId),
7272
GetCourseCategoryNameForActivityFilter(filterData.CourseCategoryId),
73-
GetApplicationNameForActivityFilter(filterData.ApplicationId));
73+
GetApplicationNameForActivityFilter(filterData.ApplicationId),
74+
filterData.CoreContent.HasValue ? (filterData.CoreContent.Value ? "NHS England TEL" : "External") : "All"
75+
);
7476
}
7577
public (string regionName, string centreTypeName, string centreName, string jobGroupName, string brandName, string categoryName, string selfAssessmentName) GetSelfAssessmentFilterNames(
7678
ActivityFilterData filterData

DigitalLearningSolutions.Web/ViewModels/SuperAdmin/PlatformReports/CourseActivityTableViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public CourseUsageReportFilterModel(
106106
string brandName,
107107
string categoryName,
108108
string courseName,
109+
string courseProviderName,
109110
bool userManagingAllCourses
110111
)
111112
{
@@ -116,6 +117,7 @@ bool userManagingAllCourses
116117
BrandName = brandName;
117118
CategoryName = categoryName;
118119
CourseName = courseName;
120+
CourseProviderName = courseProviderName;
119121
ReportIntervalName = Enum.GetName(typeof(ReportInterval), filterData.ReportInterval)!;
120122
StartDate = filterData.StartDate.ToString(DateHelper.StandardDateFormat);
121123
EndDate = filterData.EndDate?.ToString(DateHelper.StandardDateFormat) ?? "Today";
@@ -139,6 +141,7 @@ bool userManagingAllCourses
139141
public string BrandName { get; set; }
140142
public string CategoryName { get; set; }
141143
public string CourseName { get; set; }
144+
public string CourseProviderName { get; set; }
142145
public string StartDate { get; set; }
143146
public string EndDate { get; set; }
144147
public string ReportIntervalName { get; set; }

DigitalLearningSolutions.Web/ViewModels/SuperAdmin/PlatformReports/CourseUsageEditFiltersViewModel.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public CourseUsageEditFiltersViewModel(
4040
CentreTypeId = filterData.CentreTypeId;
4141
CategoryId = filterData.CourseCategoryId;
4242
BrandId = filterData.BrandId;
43-
CoreContent = filterData.CoreContent;
43+
CoreContent = filterData.CoreContent.HasValue ? (filterData.CoreContent.Value ? 1 : 0) : (int?)null;
4444
ApplicationId = filterData.ApplicationId;
4545
StartDay = filterData.StartDate.Day;
4646
StartMonth = filterData.StartDate.Month;
@@ -56,7 +56,7 @@ public CourseUsageEditFiltersViewModel(
5656
public int? RegionId { get; set; }
5757
public int? CentreId { get; set; }
5858
public int? BrandId { get; set; }
59-
public bool? CoreContent { get; set; }
59+
public int? CoreContent { get; set; }
6060
public int? CentreTypeId { get; set; }
6161
public int? JobGroupId { get; set; }
6262
public CourseFilterType FilterType { get; set; }
@@ -79,6 +79,7 @@ public CourseUsageEditFiltersViewModel(
7979
public IEnumerable<SelectListItem> BrandOptions { get; set; } = new List<SelectListItem>();
8080
public IEnumerable<SelectListItem> CentreOptions { get; set; } = new List<SelectListItem>();
8181
public IEnumerable<SelectListItem> RegionOptions { get; set; } = new List<SelectListItem>();
82+
public IEnumerable<SelectListItem> CourseProviderOptions { get; set; } = new List<SelectListItem>();
8283

8384
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
8485
{
@@ -96,6 +97,8 @@ public IEnumerable<ValidationResult> Validate(ValidationContext validationContex
9697

9798
public void SetUpDropdowns(CourseUsageReportFilterOptions filterOptions, int? userCategoryFilter)
9899
{
100+
IEnumerable<(int, string)> courseProviderList = new List<(int, string)> { (0, "External"), (1, "NHS England TEL") };
101+
CourseProviderOptions = SelectListHelper.MapOptionsToSelectListItems(courseProviderList, CoreContent);
99102
CentreOptions = SelectListHelper.MapOptionsToSelectListItems(filterOptions.Centres, CentreId);
100103
CentreTypeOptions = SelectListHelper.MapOptionsToSelectListItems(filterOptions.CentreTypes, CentreTypeId);
101104
RegionOptions = SelectListHelper.MapOptionsToSelectListItems(filterOptions.Regions, RegionId);

DigitalLearningSolutions.Web/Views/SuperAdmin/PlatformReports/CourseUsageEditFilters.cshtml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,24 @@
6666
css-class="nhsuk-u-width-one-half"
6767
default-option="All"
6868
select-list-options="@Model.JobGroupOptions" />
69+
<vc:select-list asp-for="@nameof(Model.CoreContent)"
70+
label="Choose course provider filter"
71+
value="@Model.CoreContent.ToString()"
72+
hint-text=""
73+
required="false"
74+
css-class="nhsuk-u-width-one-half"
75+
default-option="All"
76+
select-list-options="@Model.CourseProviderOptions" />
6977
<vc:select-list asp-for="@nameof(Model.BrandId)"
70-
label="Choose activity brand filter"
78+
label="Choose course brand filter"
7179
value="@Model.BrandId.ToString()"
7280
hint-text=""
7381
required="false"
7482
css-class="nhsuk-u-width-one-half"
7583
default-option="All"
7684
select-list-options="@Model.BrandOptions" />
7785
<vc:select-list asp-for="@nameof(Model.CategoryId)"
78-
label="Choose activity category filter"
86+
label="Choose course category filter"
7987
value="@Model.CategoryId.ToString()"
8088
hint-text=""
8189
required="false"

DigitalLearningSolutions.Web/Views/SuperAdmin/PlatformReports/Index.cshtml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@
9898

9999
</div>
100100
</dl>
101+
<div class="nhsuk-u-text-align-right">
102+
<a asp-controller="PlatformReports" asp-action="CourseUsageReport">View <span class="nhsuk-u-visually-hidden">course usage</span> report</a>
103+
</div>
101104
</div>
102105
</div>
103106
</div>
@@ -130,7 +133,7 @@
130133
</div>
131134
</dl>
132135
<div class="nhsuk-u-text-align-right">
133-
<a asp-controller="PlatformReports" asp-action="IndependentSelfAssessmentsReport">View report</a>
136+
<a asp-controller="PlatformReports" asp-action="IndependentSelfAssessmentsReport">View <span class="nhsuk-u-visually-hidden">independent self assessment</span> report</a>
134137
</div>
135138
</div>
136139
</div>
@@ -165,7 +168,7 @@
165168
</div>
166169
</dl>
167170
<div class="nhsuk-u-text-align-right">
168-
<a asp-controller="PlatformReports" asp-action="SupervisedSelfAssessmentsReport">View report</a>
171+
<a asp-controller="PlatformReports" asp-action="SupervisedSelfAssessmentsReport">View <span class="nhsuk-u-visually-hidden">supervised self assessment</span> report</a>
169172
</div>
170173
</div>
171174
</div>

DigitalLearningSolutions.Web/Views/SuperAdmin/PlatformReports/_CourseFilterDisplayCard.cshtml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,20 @@
4141
<partial name="_SummaryFieldValue" model="@Model.JobGroupName" />
4242
</div>
4343
}
44+
@if (Model.CourseProviderName != "All")
45+
{
46+
<div class="nhsuk-summary-list__row details-list-with-button__row">
47+
<dt class="nhsuk-summary-list__key">
48+
Course provider
49+
</dt>
50+
<partial name="_SummaryFieldValue" model="@Model.CourseProviderName" />
51+
</div>
52+
}
4453
@if (Model.BrandName != "All")
4554
{
4655
<div class="nhsuk-summary-list__row details-list-with-button__row">
4756
<dt class="nhsuk-summary-list__key">
48-
Activity brand
57+
Course brand
4958
</dt>
5059
<partial name="_SummaryFieldValue" model="@Model.BrandName" />
5160
</div>
@@ -54,7 +63,7 @@
5463
{
5564
<div class="nhsuk-summary-list__row details-list-with-button__row">
5665
<dt class="nhsuk-summary-list__key">
57-
Activity category
66+
Course category
5867
</dt>
5968
<partial name="_SummaryFieldValue" model="@Model.CategoryName" />
6069
</div>

0 commit comments

Comments
 (0)