Skip to content

Commit dcc033d

Browse files
authored
Merge pull request #3338 from TechnologyEnhancedLearning/Develop/Features/TD-4088-SupervisorTableauLink
TD-4088 supervisor tableau link
2 parents 048acfd + 8bebdc6 commit dcc033d

File tree

8 files changed

+40
-12
lines changed

8 files changed

+40
-12
lines changed

DigitalLearningSolutions.Web.Tests/Controllers/SupervisorController/SupervisorControllerTests.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using Microsoft.AspNetCore.Mvc;
1717
using Microsoft.Extensions.Configuration;
1818
using Microsoft.Extensions.Logging;
19+
using Microsoft.FeatureManagement;
1920
using NUnit.Framework;
2021
using System.Collections.Generic;
2122
using System.Linq;
@@ -49,6 +50,7 @@ public class SupervisorControllerTests
4950
private IPdfService pdfService = null!;
5051
private SupervisorController controller = null!;
5152
private ICourseCategoriesService courseCategoriesService = null!;
53+
private IFeatureManager featureManager = null!;
5254

5355
[SetUp]
5456
public void Setup()
@@ -73,6 +75,7 @@ public void Setup()
7375
candidateAssessmentDownloadFileService = A.Fake<ICandidateAssessmentDownloadFileService>();
7476
pdfService = A.Fake<IPdfService>();
7577
courseCategoriesService = A.Fake<ICourseCategoriesService>();
78+
featureManager = A.Fake<IFeatureManager>();
7679
A.CallTo(() => candidateAssessmentDownloadFileService.GetCandidateAssessmentDownloadFileForCentre(A<int>._, A<int>._, A<bool>._))
7780
.Returns(new byte[] { });
7881

@@ -108,7 +111,8 @@ public void Setup()
108111
candidateAssessmentDownloadFileService,
109112
clockUtility,
110113
pdfService,
111-
courseCategoriesService
114+
courseCategoriesService,
115+
featureManager
112116
);
113117
controller.ControllerContext = new ControllerContext
114118
{ HttpContext = new DefaultHttpContext { User = user } };
@@ -140,7 +144,8 @@ public void ExportCandidateAssessment_should_return_file_object_with_file_name_i
140144
candidateAssessmentDownloadFileService,
141145
clockUtility,
142146
pdfService,
143-
courseCategoriesService
147+
courseCategoriesService,
148+
featureManager
144149
);
145150
string expectedFileName = $"{((selfAssessmentName.Length > 30) ? selfAssessmentName.Substring(0, 30) : selfAssessmentName)} - {delegateName} - {clockUtility.UtcNow:yyyy-MM-dd}.xlsx";
146151

DigitalLearningSolutions.Web/Controllers/SupervisorController/Supervisor.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,23 @@
2727

2828
public partial class SupervisorController
2929
{
30-
public IActionResult Index()
30+
public async Task<IActionResult> IndexAsync()
3131
{
3232
var adminId = GetAdminId();
3333
var dashboardData = supervisorService.GetDashboardDataForAdminId(adminId);
3434
var signOffRequests = supervisorService.GetSupervisorDashboardToDoItemsForRequestedSignOffs(adminId);
3535
var reviewRequests = supervisorService.GetSupervisorDashboardToDoItemsForRequestedReviews(adminId);
3636
var supervisorDashboardToDoItems = Enumerable.Concat(signOffRequests, reviewRequests);
3737
var bannerText = GetBannerText();
38+
var tableauFlag = await featureManager.IsEnabledAsync(FeatureFlags.TableauSelfAssessmentDashboards);
39+
var tableauQueryOverride = string.Equals(Request.Query["tableaulink"], "true", StringComparison.OrdinalIgnoreCase);
40+
var showTableauLink = tableauFlag || tableauQueryOverride;
3841
var model = new SupervisorDashboardViewModel()
3942
{
4043
DashboardData = dashboardData,
4144
SupervisorDashboardToDoItems = supervisorDashboardToDoItems,
42-
BannerText = bannerText
45+
BannerText = bannerText,
46+
ShowTableauLink = showTableauLink
4347
};
4448
return View(model);
4549
}

DigitalLearningSolutions.Web/Controllers/SupervisorController/SupervisorController.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Microsoft.AspNetCore.Mvc;
99
using Microsoft.Extensions.Configuration;
1010
using Microsoft.Extensions.Logging;
11+
using Microsoft.FeatureManagement;
1112

1213
[Authorize(Policy = CustomPolicies.UserSupervisor)]
1314
public partial class SupervisorController : Controller
@@ -28,7 +29,7 @@ public partial class SupervisorController : Controller
2829
private readonly IClockUtility clockUtility;
2930
private readonly IPdfService pdfService;
3031
private readonly ICourseCategoriesService courseCategoriesService;
31-
32+
private readonly IFeatureManager featureManager;
3233
public SupervisorController(
3334
ISupervisorService supervisorService,
3435
ICommonService commonService,
@@ -49,7 +50,8 @@ public SupervisorController(
4950
ICandidateAssessmentDownloadFileService candidateAssessmentDownloadFileService,
5051
IClockUtility clockUtility,
5152
IPdfService pdfService,
52-
ICourseCategoriesService courseCategoriesService
53+
ICourseCategoriesService courseCategoriesService,
54+
IFeatureManager featureManager
5355
)
5456
{
5557
this.supervisorService = supervisorService;
@@ -68,6 +70,7 @@ ICourseCategoriesService courseCategoriesService
6870
this.clockUtility = clockUtility;
6971
this.pdfService = pdfService;
7072
this.courseCategoriesService = courseCategoriesService;
73+
this.featureManager = featureManager;
7174
}
7275

7376
private int GetCentreId()

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ IFeatureManager featureManager
5353
this.selfAssessmentService = selfAssessmentService;
5454
this.featureManager = featureManager;
5555
}
56+
[Route("/TrackingSystem/Centre/Reports/SelfAssessments")]
5657
public async Task<IActionResult> IndexAsync()
5758
{
5859
var centreId = User.GetCentreId();
@@ -65,7 +66,7 @@ public async Task<IActionResult> IndexAsync()
6566
return View(model);
6667
}
6768
[HttpGet]
68-
[Route("DownloadDcsa")]
69+
[Route("/TrackingSystem/Centre/Reports/DownloadDcsa")]
6970
public IActionResult DownloadDigitalCapabilityToExcel()
7071
{
7172
var centreId = User.GetCentreIdKnownNotNull();
@@ -78,7 +79,7 @@ public IActionResult DownloadDigitalCapabilityToExcel()
7879
);
7980
}
8081
[HttpGet]
81-
[Route("DownloadReport")]
82+
[Route("/TrackingSystem/Centre/Reports/DownloadReport")]
8283
public IActionResult DownloadSelfAssessmentReport(int selfAssessmentId)
8384
{
8485
var centreId = User.GetCentreId();
@@ -92,15 +93,16 @@ public IActionResult DownloadSelfAssessmentReport(int selfAssessmentId)
9293
);
9394
}
9495
[HttpGet]
95-
[Route("TableauCompetencyDashboard")]
96-
public async Task<IActionResult> TableauCompetencyDashboardAsync()
96+
[Route("/{source}/Reports/TableauCompetencyDashboard")]
97+
public async Task<IActionResult> TableauCompetencyDashboardAsync(string source = "TrackingSystem")
9798
{
9899
var userEmail = User.GetUserPrimaryEmail();
99100
var adminId = User.GetAdminId();
100101
var jwt = tableauConnectionHelper.GetTableauJwt();
101102
var tableauFlag = await featureManager.IsEnabledAsync(FeatureFlags.TableauSelfAssessmentDashboards);
102103
var tableauQueryOverride = string.Equals(Request.Query["tableaulink"], "true", StringComparison.OrdinalIgnoreCase);
103104
var showTableauLink = tableauFlag || tableauQueryOverride;
105+
ViewBag.Source = source;
104106
ViewBag.Email = userEmail;
105107
ViewBag.AdminId = adminId;
106108
ViewBag.SiteName = tableauSiteName;

DigitalLearningSolutions.Web/ViewModels/Supervisor/SupervisorDashboardViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ public class SupervisorDashboardViewModel
88
public string? BannerText;
99
public DashboardData DashboardData { get; set; }
1010
public IEnumerable<SupervisorDashboardToDoItem> SupervisorDashboardToDoItems { get; set; }
11+
public bool ShowTableauLink { get; set; } = false;
1112
}
1213
}

DigitalLearningSolutions.Web/Views/Supervisor/Index.cshtml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
ViewData["Title"] = "Dashboard";
77
ViewData["Application"] = "Supervisor";
88
ViewData["HeaderPathName"] = "Supervisor";
9+
var routeData = (new Dictionary<string, string>() { { "source", "Supervisor" } });
10+
11+
if (string.Equals(Context.Request.Query["tableaulink"], "true", StringComparison.OrdinalIgnoreCase))
12+
{
13+
routeData["tableaulink"] = "true";
14+
}
915
}
1016
<link rel="stylesheet" href="@Url.Content("~/css/frameworks/frameworksShared.css")" asp-append-version="true">
1117
@section NavMenuItems {
@@ -96,3 +102,10 @@ else
96102
</li>
97103
</feature>
98104
</ul>
105+
106+
@if (Model.ShowTableauLink)
107+
{
108+
<h2>Progress reports</h2>
109+
<vc:action-link asp-controller="SelfAssessmentReports"
110+
asp-all-route-data="routeData" asp-action="TableauCompetencyDashboard" link-text="View supervised self assessments dashboard" />
111+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
@model SelfAssessmentReportsViewModel
55
@{
66
ViewData["Title"] = "Self assessment reports";
7-
var routeData = new Dictionary<string, string>();
7+
var routeData = (new Dictionary<string, string>() { { "source", "TrackingSystem" } });
88

99
if (string.Equals(Context.Request.Query["tableaulink"], "true", StringComparison.OrdinalIgnoreCase))
1010
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
ViewData["Title"] = "Supervised self assessments dashboard";
1212
}
1313
<div class="nhsuk-back-link">
14-
<a class="nhsuk-back-link__link" role="button" asp-action="Index">
14+
<a class="nhsuk-back-link__link" role="button" asp-controller="@(ViewBag.Source == "Supervisor" ? "Supervisor" : "SelfAssessmentReports")" asp-action="Index">
1515
<svg class="nhsuk-icon nhsuk-icon__chevron-left" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" height="24" width="24">
1616
<path d="M8.5 12c0-.3.1-.5.3-.7l5-5c.4-.4 1-.4 1.4 0s.4 1 0 1.4L10.9 12l4.3 4.3c.4.4.4 1 0 1.4s-1 .4-1.4 0l-5-5c-.2-.2-.3-.4-.3-.7z"></path>
1717
</svg>

0 commit comments

Comments
 (0)