Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
using Microsoft.FeatureManagement;
using Microsoft.FeatureManagement.Mvc;
using System;
using System.Linq;
using System.Threading.Tasks;

[FeatureGate(FeatureFlags.RefactoredTrackingSystem)]
[Authorize(Policy = CustomPolicies.UserCentreAdmin)]
[SetDlsSubApplication(nameof(DlsSubApplication.TrackingSystem))]
Expand All @@ -33,13 +33,15 @@ public class SelfAssessmentReportsController : Controller
private readonly string workbookName;
private readonly string viewName;
private readonly ISelfAssessmentService selfAssessmentService;
private readonly ICentreSelfAssessmentsService centreSelfAssessmentsService;
private readonly IFeatureManager featureManager;
public SelfAssessmentReportsController(
ISelfAssessmentReportService selfAssessmentReportService,
ITableauConnectionHelperService tableauConnectionHelper,
IClockUtility clockUtility,
IConfiguration config,
ISelfAssessmentService selfAssessmentService,
ICentreSelfAssessmentsService centreSelfAssessmentsService,
IFeatureManager featureManager
)
{
Expand All @@ -51,6 +53,7 @@ IFeatureManager featureManager
workbookName = config.GetTableauWorkbookName();
viewName = config.GetTableauViewName();
this.selfAssessmentService = selfAssessmentService;
this.centreSelfAssessmentsService = centreSelfAssessmentsService;
this.featureManager = featureManager;
}
[Route("/TrackingSystem/Centre/Reports/SelfAssessments")]
Expand All @@ -59,10 +62,12 @@ public async Task<IActionResult> IndexAsync()
var centreId = User.GetCentreId();
var adminCategoryId = User.GetAdminCategoryId();
var categoryId = this.selfAssessmentService.GetSelfAssessmentCategoryId(1);
var selfAssessments = centreSelfAssessmentsService.GetCentreSelfAssessments(centreId.Value);
var dSATreportIsPublish = selfAssessments.Any(x => x.SelfAssessmentId == 1);
var tableauFlag = await featureManager.IsEnabledAsync(FeatureFlags.TableauSelfAssessmentDashboards);
var tableauQueryOverride = string.Equals(Request.Query["tableaulink"], "true", StringComparison.OrdinalIgnoreCase);
var showTableauLink = tableauFlag || tableauQueryOverride;
var model = new SelfAssessmentReportsViewModel(selfAssessmentReportService.GetSelfAssessmentsForReportList((int)centreId, adminCategoryId), adminCategoryId, categoryId, showTableauLink);
var model = new SelfAssessmentReportsViewModel(selfAssessmentReportService.GetSelfAssessmentsForReportList((int)centreId, adminCategoryId), adminCategoryId, categoryId, dSATreportIsPublish, showTableauLink);
return View(model);
}
[HttpGet]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@
public class SelfAssessmentReportsViewModel
{
public SelfAssessmentReportsViewModel(
IEnumerable<SelfAssessmentSelect> selfAssessmentSelects, int? adminCategoryId, int categoryId, bool showTableauLink
IEnumerable<SelfAssessmentSelect> selfAssessmentSelects, int? adminCategoryId, int categoryId, bool dSATreportIsPublish, bool showTableauLink
)
{
SelfAssessmentSelects = selfAssessmentSelects;
AdminCategoryId = adminCategoryId;
CategoryId = categoryId;
DSATreportIsPublish = dSATreportIsPublish;
ShowTableauLink = showTableauLink;
}
public IEnumerable<SelfAssessmentSelect> SelfAssessmentSelects { get; set; }
public int? AdminCategoryId { get; set; }
public int CategoryId { get; set; }
public bool DSATreportIsPublish { get; set; }
public bool ShowTableauLink { get; set; } = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<h2>Excel learner activity reports</h2>
<p class="nhsuk-lede-text">Download Excel competency self assessments activity reports for your centre.</p>
<ul>
@if ((Model.AdminCategoryId == null) || (Model.AdminCategoryId == Model.CategoryId))
@if ((Model.DSATreportIsPublish) && ((Model.AdminCategoryId == null) || (Model.AdminCategoryId == Model.CategoryId)))
{
<li>
<a asp-controller="SelfAssessmentReports" asp-action="DownloadDigitalCapabilityToExcel">Digital Skills Assessment Tool - Download report</a>
Expand Down
Loading