Skip to content

Commit 35c8e07

Browse files
authored
Merge pull request #3293 from TechnologyEnhancedLearning/Develop/Fixes/TD-5683-IssueshowingselfassessmentreportsonTrackingsystemwhicharenotpublishedatthecentre
TD-5683 Issue showing self assessment reports on Tracking system which are not published at the centre
2 parents accd0ae + 7221ade commit 35c8e07

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

DigitalLearningSolutions.Web/Controllers/TrackingSystem/Centre/SelfAssessmentReports/SelfAssessmentReportsController.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
using Microsoft.FeatureManagement;
1717
using Microsoft.FeatureManagement.Mvc;
1818
using System;
19+
using System.Linq;
1920
using System.Threading.Tasks;
20-
2121
[FeatureGate(FeatureFlags.RefactoredTrackingSystem)]
2222
[Authorize(Policy = CustomPolicies.UserCentreAdmin)]
2323
[SetDlsSubApplication(nameof(DlsSubApplication.TrackingSystem))]
@@ -33,13 +33,15 @@ public class SelfAssessmentReportsController : Controller
3333
private readonly string workbookName;
3434
private readonly string viewName;
3535
private readonly ISelfAssessmentService selfAssessmentService;
36+
private readonly ICentreSelfAssessmentsService centreSelfAssessmentsService;
3637
private readonly IFeatureManager featureManager;
3738
public SelfAssessmentReportsController(
3839
ISelfAssessmentReportService selfAssessmentReportService,
3940
ITableauConnectionHelperService tableauConnectionHelper,
4041
IClockUtility clockUtility,
4142
IConfiguration config,
4243
ISelfAssessmentService selfAssessmentService,
44+
ICentreSelfAssessmentsService centreSelfAssessmentsService,
4345
IFeatureManager featureManager
4446
)
4547
{
@@ -51,6 +53,7 @@ IFeatureManager featureManager
5153
workbookName = config.GetTableauWorkbookName();
5254
viewName = config.GetTableauViewName();
5355
this.selfAssessmentService = selfAssessmentService;
56+
this.centreSelfAssessmentsService = centreSelfAssessmentsService;
5457
this.featureManager = featureManager;
5558
}
5659
[Route("/TrackingSystem/Centre/Reports/SelfAssessments")]
@@ -59,10 +62,12 @@ public async Task<IActionResult> IndexAsync()
5962
var centreId = User.GetCentreId();
6063
var adminCategoryId = User.GetAdminCategoryId();
6164
var categoryId = this.selfAssessmentService.GetSelfAssessmentCategoryId(1);
65+
var selfAssessments = centreSelfAssessmentsService.GetCentreSelfAssessments(centreId.Value);
66+
var dSATreportIsPublish = selfAssessments.Any(x => x.SelfAssessmentId == 1);
6267
var tableauFlag = await featureManager.IsEnabledAsync(FeatureFlags.TableauSelfAssessmentDashboards);
6368
var tableauQueryOverride = string.Equals(Request.Query["tableaulink"], "true", StringComparison.OrdinalIgnoreCase);
6469
var showTableauLink = tableauFlag || tableauQueryOverride;
65-
var model = new SelfAssessmentReportsViewModel(selfAssessmentReportService.GetSelfAssessmentsForReportList((int)centreId, adminCategoryId), adminCategoryId, categoryId, showTableauLink);
70+
var model = new SelfAssessmentReportsViewModel(selfAssessmentReportService.GetSelfAssessmentsForReportList((int)centreId, adminCategoryId), adminCategoryId, categoryId, dSATreportIsPublish, showTableauLink);
6671
return View(model);
6772
}
6873
[HttpGet]

DigitalLearningSolutions.Web/ViewModels/TrackingSystem/Centre/Reports/SelfAssessmentReportsViewModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@
66
public class SelfAssessmentReportsViewModel
77
{
88
public SelfAssessmentReportsViewModel(
9-
IEnumerable<SelfAssessmentSelect> selfAssessmentSelects, int? adminCategoryId, int categoryId, bool showTableauLink
9+
IEnumerable<SelfAssessmentSelect> selfAssessmentSelects, int? adminCategoryId, int categoryId, bool dSATreportIsPublish, bool showTableauLink
1010
)
1111
{
1212
SelfAssessmentSelects = selfAssessmentSelects;
1313
AdminCategoryId = adminCategoryId;
1414
CategoryId = categoryId;
15+
DSATreportIsPublish = dSATreportIsPublish;
1516
ShowTableauLink = showTableauLink;
1617
}
1718
public IEnumerable<SelfAssessmentSelect> SelfAssessmentSelects { get; set; }
1819
public int? AdminCategoryId { get; set; }
1920
public int CategoryId { get; set; }
21+
public bool DSATreportIsPublish { get; set; }
2022
public bool ShowTableauLink { get; set; } = false;
2123
}
2224
}

DigitalLearningSolutions.Web/Views/TrackingSystem/Centre/SelfAssessmentReports/Index.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<h2>Excel learner activity reports</h2>
3434
<p class="nhsuk-lede-text">Download Excel competency self assessments activity reports for your centre.</p>
3535
<ul>
36-
@if ((Model.AdminCategoryId == null) || (Model.AdminCategoryId == Model.CategoryId))
36+
@if ((Model.DSATreportIsPublish) && ((Model.AdminCategoryId == null) || (Model.AdminCategoryId == Model.CategoryId)))
3737
{
3838
<li>
3939
<a asp-controller="SelfAssessmentReports" asp-action="DownloadDigitalCapabilityToExcel">Digital Skills Assessment Tool - Download report</a>

0 commit comments

Comments
 (0)