Skip to content

Commit 2a9a54c

Browse files
authored
Merge pull request #1410 from TechnologyEnhancedLearning/Develop/Fixes/TD-6088-Refractor-recent-activity-tray-to-My-courses-and-elearning
TD-6088: Refractor recent activity tray to "My courses and elearning"
2 parents 3c75360 + e10ba18 commit 2a9a54c

File tree

53 files changed

+953
-129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+953
-129
lines changed

AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
<PackageReference Include="HtmlSanitizer" Version="6.0.453" />
9090
<PackageReference Include="IdentityModel" Version="4.6.0" />
9191
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.2" />
92-
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.52" />
92+
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.53" />
9393
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
9494
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.36" />
9595
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.36" />

LearningHub.Nhs.WebUI.AutomatedUiTests/LearningHub.Nhs.WebUI.AutomatedUiTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<ItemGroup>
1414
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.11" />
1515
<PackageReference Include="FluentAssertions" Version="6.12.0" />
16-
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.52" />
16+
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.53" />
1717
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.13" />
1818
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
1919
<PackageReference Include="Selenium.Axe" Version="4.0.19" />

LearningHub.Nhs.WebUI/Controllers/HomeController.cs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -203,38 +203,31 @@ public IActionResult HomepageWithAuthentication()
203203
/// <summary>
204204
/// Index.
205205
/// </summary>
206+
/// <param name="dashboardTrayLearningResourceType">The resource type.</param>
206207
/// <param name="myLearningDashboard">The my learning dashboard type.</param>
207208
/// <param name="resourceDashboard">The resource dashboard type.</param>
208209
/// <param name="catalogueDashboard">The catalogue dashboard type.</param>
209210
/// <returns>Home page.</returns>
210-
public async Task<IActionResult> Index(string myLearningDashboard = "my-in-progress", string resourceDashboard = "popular-resources", string catalogueDashboard = "popular-catalogues")
211+
public async Task<IActionResult> Index(string dashboardTrayLearningResourceType = "all", string myLearningDashboard = "my-in-progress", string resourceDashboard = "popular-resources", string catalogueDashboard = "popular-catalogues")
211212
{
212213
if (this.User?.Identity.IsAuthenticated == true)
213214
{
214215
this.Logger.LogInformation("User is authenticated: User is {fullname} and userId is: {lhuserid}", this.User.Identity.GetCurrentName(), this.User.Identity.GetCurrentUserId());
215216
if (this.User.IsInRole("Administrator") || this.User.IsInRole("BlueUser") || this.User.IsInRole("ReadOnly") || this.User.IsInRole("BasicUser"))
216217
{
217-
var learningTask = this.dashboardService.GetMyAccessLearningsAsync(myLearningDashboard, 1);
218+
var learningTask = this.dashboardService.GetMyCoursesAndElearning(dashboardTrayLearningResourceType, myLearningDashboard, 1);
218219
var resourcesTask = this.dashboardService.GetResourcesAsync(resourceDashboard, 1);
219220
var cataloguesTask = this.dashboardService.GetCataloguesAsync(catalogueDashboard, 1);
220221
var userGroupsTask = this.userGroupService.UserHasCatalogueContributionPermission();
221222

222-
var enrolledCoursesTask = Task.FromResult(new List<MoodleCourseResponseModel>());
223-
(bool enableMoodle, int currentMoodleUserId) = await this.GetMoodleFeatureStateAsync();
224-
225-
if (enableMoodle && myLearningDashboard == "my-enrolled-courses")
226-
{
227-
enrolledCoursesTask = this.dashboardService.GetEnrolledCoursesFromMoodleAsync(currentMoodleUserId, 1);
228-
}
229-
230223
await Task.WhenAll(learningTask, resourcesTask, cataloguesTask, userGroupsTask);
231224

232225
var model = new DashboardViewModel()
233226
{
234227
MyLearnings = await learningTask,
235228
Resources = await resourcesTask,
236229
Catalogues = await cataloguesTask,
237-
EnrolledCourses = await enrolledCoursesTask,
230+
DashboardTrayLearningResourceType = dashboardTrayLearningResourceType,
238231
};
239232
var userHasContributePermission = await userGroupsTask;
240233
this.ViewBag.userHasContributePermission = userHasContributePermission;
@@ -261,15 +254,16 @@ public async Task<IActionResult> Index(string myLearningDashboard = "my-in-progr
261254
/// <summary>
262255
/// Load the specified dashobard page.
263256
/// </summary>
257+
/// <param name="dashboardTrayLearningResourceType">dashboardTrayLearningResourceType.</param>
264258
/// <param name="dashBoardTray">dashBoardTray.</param>
265259
/// <param name="myLearningDashBoard">myLearningDashBoard.</param>
266260
/// <param name="resourceDashBoard">resourceDashBoard.</param>
267261
/// <param name="catalogueDashBoard">catalogueDashBoard.</param>
268262
/// <param name="pageNumber">pageNumber.</param>
269263
/// <returns>Dashboard page.</returns>
270264
[Authorize]
271-
[Route("/Home/loadpage/{dashBoardTray}/{myLearningDashBoard}/{resourceDashBoard}/{catalogueDashBoard}/{pageNumber:int}")]
272-
public async Task<IActionResult> LoadPage(string dashBoardTray = "my-learning", string myLearningDashBoard = "in-progress", string resourceDashBoard = "popular-resources", string catalogueDashBoard = "recent-catalogues", int pageNumber = 1)
265+
[Route("/Home/loadpage/{dashboardTrayLearningResourceType}/{dashBoardTray}/{myLearningDashBoard}/{resourceDashBoard}/{catalogueDashBoard}/{pageNumber:int}")]
266+
public async Task<IActionResult> LoadPage(string dashboardTrayLearningResourceType = "all", string dashBoardTray = "my-learning", string myLearningDashBoard = "in-progress", string resourceDashBoard = "popular-resources", string catalogueDashBoard = "recent-catalogues", int pageNumber = 1)
273267
{
274268
if (this.User.IsInRole("Administrator") || this.User.IsInRole("BlueUser") || this.User.IsInRole("ReadOnly") || this.User.IsInRole("BasicUser"))
275269
{
@@ -278,19 +272,18 @@ public async Task<IActionResult> LoadPage(string dashBoardTray = "my-learning",
278272
MyLearnings = new Nhs.Models.Dashboard.DashboardMyLearningResponseViewModel { Type = myLearningDashBoard },
279273
Resources = new Nhs.Models.Dashboard.DashboardResourceResponseViewModel { Type = resourceDashBoard },
280274
Catalogues = new Nhs.Models.Dashboard.DashboardCatalogueResponseViewModel { Type = catalogueDashBoard },
275+
DashboardTrayLearningResourceType = dashboardTrayLearningResourceType,
281276
};
282277

283-
(bool enableMoodle, int currentMoodleUserId) = await this.GetMoodleFeatureStateAsync();
284-
285278
bool isAjax = this.HttpContext.Request.Headers["X-Requested-With"] == "XMLHttpRequest";
286279

287280
if (isAjax)
288281
{
289282
switch (dashBoardTray)
290283
{
291284
case "my-learning":
292-
model.MyLearnings = await this.dashboardService.GetMyAccessLearningsAsync(myLearningDashBoard, pageNumber);
293-
return this.PartialView("_MyAccessedLearningTray", model);
285+
model.MyLearnings = await this.dashboardService.GetMyCoursesAndElearning(dashboardTrayLearningResourceType, myLearningDashBoard, pageNumber);
286+
return this.PartialView("_MyCoursesAndElearning", model);
294287
case "resources":
295288
model.Resources = await this.dashboardService.GetResourcesAsync(resourceDashBoard, pageNumber);
296289
return this.PartialView("_ResourceTray", model);
@@ -301,13 +294,14 @@ public async Task<IActionResult> LoadPage(string dashBoardTray = "my-learning",
301294
}
302295
else
303296
{
304-
var learningTask = this.dashboardService.GetMyAccessLearningsAsync(myLearningDashBoard, dashBoardTray == "my-learning" ? pageNumber : 1);
297+
var learningTask = this.dashboardService.GetMyCoursesAndElearning(dashboardTrayLearningResourceType, myLearningDashBoard, dashBoardTray == "my-learning" ? pageNumber : 1);
305298
var resourcesTask = this.dashboardService.GetResourcesAsync(resourceDashBoard, dashBoardTray == "resources" ? pageNumber : 1);
306299
var cataloguesTask = this.dashboardService.GetCataloguesAsync(catalogueDashBoard, dashBoardTray == "catalogues" ? pageNumber : 1);
307300
await Task.WhenAll(learningTask, resourcesTask, cataloguesTask);
308301
model.MyLearnings = await learningTask;
309302
model.Resources = await resourcesTask;
310303
model.Catalogues = await cataloguesTask;
304+
model.DashboardTrayLearningResourceType = dashboardTrayLearningResourceType;
311305
return this.View("Dashboard", model);
312306
}
313307
}

LearningHub.Nhs.WebUI/Interfaces/IDashboardService.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ public interface IDashboardService
1919
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
2020
Task<DashboardMyLearningResponseViewModel> GetMyAccessLearningsAsync(string dashboardType, int pageNumber);
2121

22+
/// <summary>
23+
/// GetResourcesAsync.
24+
/// </summary>
25+
/// <param name="dashboardTrayLearningResourceType">The dashboardTrayLearningResource type.</param>
26+
/// <param name="dashboardType">The dashboard type.</param>
27+
/// <param name="pageNumber">The page Number.</param>
28+
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
29+
Task<DashboardMyLearningResponseViewModel> GetMyCoursesAndElearning(string dashboardTrayLearningResourceType, string dashboardType, int pageNumber);
30+
2231
/// <summary>
2332
/// GetCataloguesAsync.
2433
/// </summary>

LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
<PackageReference Include="HtmlAgilityPack" Version="1.11.72" />
114114
<PackageReference Include="IdentityModel" Version="4.6.0" />
115115
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.0" />
116-
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.52" />
116+
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.53" />
117117
<PackageReference Include="linqtotwitter" Version="6.9.0" />
118118
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
119119
<PackageReference Include="Microsoft.ApplicationInsights.EventCounterCollector" Version="2.21.0" />

LearningHub.Nhs.WebUI/Models/DashBoard/DashBoardPagingViewModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ public class DashBoardPagingViewModel
5050
/// </summary>
5151
public int TotalCount { get; set; }
5252

53+
/// <summary>
54+
/// Gets or sets the dashboard tray Learning resource type.
55+
/// </summary>
56+
public string DashboardTrayLearningResourceType { get; set; }
57+
5358
/// <summary>
5459
/// Gets the display message.
5560
/// </summary>

LearningHub.Nhs.WebUI/Models/DashboardViewModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,10 @@ public DashboardViewModel()
3535
/// Gets or sets a list of enrolled courses to be displayed in the dashboard.
3636
/// </summary>
3737
public List<MoodleCourseResponseModel> EnrolledCourses { get; set; }
38+
39+
/// <summary>
40+
/// Gets or sets the dashboard tray Learning resource type.
41+
/// </summary>
42+
public string DashboardTrayLearningResourceType { get; set; }
3843
}
3944
}

LearningHub.Nhs.WebUI/Services/DashboardService.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,36 @@ public async Task<DashboardMyLearningResponseViewModel> GetMyAccessLearningsAsyn
6161
return viewmodel;
6262
}
6363

64+
/// <summary>
65+
/// GetCataloguesAsync.
66+
/// </summary>
67+
/// <param name="dashboardTrayLearningResourceType">The dashboard Tray Learning Resource type.</param>
68+
/// <param name="dashboardType">The dashboard type.</param>
69+
/// <param name="pageNumber">The page Number.</param>
70+
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
71+
public async Task<DashboardMyLearningResponseViewModel> GetMyCoursesAndElearning(string dashboardTrayLearningResourceType, string dashboardType, int pageNumber)
72+
{
73+
DashboardMyLearningResponseViewModel viewmodel = new DashboardMyLearningResponseViewModel { };
74+
75+
var client = await this.OpenApiHttpClient.GetClientAsync();
76+
77+
var request = $"dashboard/GetMyCoursesAndElearning/{dashboardTrayLearningResourceType}/{dashboardType}/{pageNumber}";
78+
var response = await client.GetAsync(request).ConfigureAwait(false);
79+
80+
if (response.IsSuccessStatusCode)
81+
{
82+
var result = response.Content.ReadAsStringAsync().Result;
83+
viewmodel = JsonConvert.DeserializeObject<DashboardMyLearningResponseViewModel>(result);
84+
}
85+
else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized ||
86+
response.StatusCode == System.Net.HttpStatusCode.Forbidden)
87+
{
88+
throw new Exception("AccessDenied");
89+
}
90+
91+
return viewmodel;
92+
}
93+
6494
/// <summary>
6595
/// GetCataloguesAsync.
6696
/// </summary>

LearningHub.Nhs.WebUI/Styles/nhsuk/layout.scss

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,32 @@ body {
2323
color: $color_nhsuk-white;
2424
}
2525

26+
.nhs-item-row {
27+
display: flex;
28+
justify-content: space-between;
29+
align-items: center;
30+
}
31+
.nhs-progress-container {
32+
display: flex;
33+
height: 10px;
34+
overflow: hidden;
35+
line-height: 0;
36+
font-size: 0.75rem;
37+
background-color: #e9ecef;
38+
border-radius: 0.25rem;
39+
}
2640

41+
.nhs-progress-bar {
42+
display: flex;
43+
flex-direction: column;
44+
justify-content: center;
45+
overflow: hidden;
46+
color: #fff;
47+
text-align: center;
48+
white-space: nowrap;
49+
background-color: $nhsuk-green;
50+
transition: width .6s ease;
51+
}
2752
.nhsuk-width-container.app-width-container {
2853
max-width: px2rem(1208);
2954
margin: 0 auto;

LearningHub.Nhs.WebUI/Views/Home/Dashboard.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
<div class="nhsuk-width-container app-width-container">
3636
<div id="my-learning">
37-
<partial name="_MyAccessedLearningTray" model="Model" />
37+
<partial name="_mycoursesandelearning" model="Model" />
3838
</div>
3939
</div>
4040
</div>

0 commit comments

Comments
 (0)