Skip to content

Commit fc35590

Browse files
authored
Merge pull request #3056 from TechnologyEnhancedLearning/Develop/Features/TD-5096-HidethelinktotheDSATreportftheadminuserisinacategorythatdoesn'tmatch
TD-5096 Hide the link to the DSAT report if the admin user is in a category that doesn't match
2 parents d363e89 + 3f0ec0d commit fc35590

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using System.Threading.Tasks;
1616
using Microsoft.Extensions.Configuration;
1717
using DigitalLearningSolutions.Data.Extensions;
18+
using DigitalLearningSolutions.Web.Services;
1819

1920
[FeatureGate(FeatureFlags.RefactoredTrackingSystem)]
2021
[Authorize(Policy = CustomPolicies.UserCentreAdmin)]
@@ -30,11 +31,13 @@ public class SelfAssessmentReportsController : Controller
3031
private readonly string tableauSiteName;
3132
private readonly string workbookName;
3233
private readonly string viewName;
34+
private readonly ISelfAssessmentService selfAssessmentService;
3335
public SelfAssessmentReportsController(
3436
ISelfAssessmentReportService selfAssessmentReportService,
3537
ITableauConnectionHelperService tableauConnectionHelper,
3638
IClockUtility clockUtility,
37-
IConfiguration config
39+
IConfiguration config,
40+
ISelfAssessmentService selfAssessmentService
3841
)
3942
{
4043
this.selfAssessmentReportService = selfAssessmentReportService;
@@ -44,12 +47,14 @@ IConfiguration config
4447
tableauSiteName = config.GetTableauSiteName();
4548
workbookName = config.GetTableauWorkbookName();
4649
viewName = config.GetTableauViewName();
50+
this.selfAssessmentService = selfAssessmentService;
4751
}
4852
public IActionResult Index()
4953
{
5054
var centreId = User.GetCentreId();
51-
var categoryId = User.GetAdminCategoryId();
52-
var model = new SelfAssessmentReportsViewModel(selfAssessmentReportService.GetSelfAssessmentsForReportList((int)centreId, categoryId));
55+
var adminCategoryId = User.GetAdminCategoryId();
56+
var categoryId = this.selfAssessmentService.GetSelfAssessmentCategoryId(1);
57+
var model = new SelfAssessmentReportsViewModel(selfAssessmentReportService.GetSelfAssessmentsForReportList((int)centreId, adminCategoryId), adminCategoryId, categoryId);
5358
return View(model);
5459
}
5560
[HttpGet]

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66
public class SelfAssessmentReportsViewModel
77
{
88
public SelfAssessmentReportsViewModel(
9-
IEnumerable<SelfAssessmentSelect> selfAssessmentSelects
9+
IEnumerable<SelfAssessmentSelect> selfAssessmentSelects, int? adminCategoryId, int categoryId
1010
)
1111
{
1212
SelfAssessmentSelects = selfAssessmentSelects;
13+
AdminCategoryId = adminCategoryId;
14+
CategoryId = categoryId;
1315
}
1416
public IEnumerable<SelfAssessmentSelect> SelfAssessmentSelects { get; set; }
17+
public int? AdminCategoryId { get; set; }
18+
public int CategoryId { get; set; }
1519
}
1620
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@
2828
<h2>Excel learner activity reports</h2>
2929
<p class="nhsuk-lede-text">Download Excel competency self assessments activity reports for your centre.</p>
3030
<ul>
31+
@if((Model.AdminCategoryId == null) || (Model.AdminCategoryId == Model.CategoryId))
32+
{
3133
<li>
3234
<a asp-controller="SelfAssessmentReports" asp-action="DownloadDigitalCapabilityToExcel">Digital Skills Assessment Tool - Download report</a>
3335

3436
</li>
37+
}
3538
@if (Model.SelfAssessmentSelects.Any())
3639
{
3740
@foreach (var report in Model.SelfAssessmentSelects)

0 commit comments

Comments
 (0)