Skip to content

Commit 9af7b56

Browse files
committed
#Safe part to merge first half
2 parents 98c04ea + 1323a4d commit 9af7b56

File tree

57 files changed

+798
-547
lines changed

Some content is hidden

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

57 files changed

+798
-547
lines changed

AdminUI/LearningHub.Nhs.AdminUI/Helpers/LearningActivityHelper.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ public static string GetResourceTypeVerb(this MyLearningDetailedItemViewModel my
116116
return "Played " + GetDurationText(myLearningDetailedItemViewModel.ActivityDurationSeconds * 1000);
117117
case ResourceTypeEnum.WebLink:
118118
return "Visited";
119+
case ResourceTypeEnum.Html:
120+
return "Viewed";
121+
case ResourceTypeEnum.Case:
122+
return "Accessed";
123+
case ResourceTypeEnum.Assessment:
124+
return "Accessed";
119125
default:
120126
return string.Empty;
121127
}

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.4.0" />
9191
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.2" />
92-
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.31" />
92+
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.33" />
9393
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
9494
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.0" />
9595
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0" />

AdminUI/LearningHub.Nhs.AdminUI/Views/Catalogue/Edit.cshtml

Lines changed: 383 additions & 366 deletions
Large diffs are not rendered by default.

LearningHub.Nhs.WebUI/Controllers/Api/ResourceController.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ public async Task<IActionResult> DownloadResourceAndRecordActivity(int resourceV
105105
ActivityStatus = ActivityStatusEnum.Completed,
106106
};
107107
await this.activityService.CreateResourceActivityAsync(activity);
108-
109108
return this.File(file.Content, file.ContentType, fileName);
110109
}
111110
else

LearningHub.Nhs.WebUI/Controllers/BookmarkController.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,16 @@ public async Task<IActionResult> BookmarkToggle(EditBookmarkViewModel bookmark,
276276
{
277277
if (!this.ModelState.IsValid)
278278
{
279+
this.ModelState.Remove(nameof(bookmark.Title));
280+
if (bookmark.BookmarkTypeId == 1)
281+
{
282+
this.ModelState.AddModelError(nameof(bookmark.Title), "You must enter a folder name");
283+
}
284+
else
285+
{
286+
this.ModelState.AddModelError(nameof(bookmark.Title), "You must enter a bookmark name");
287+
}
288+
279289
this.ViewBag.ReturnUrl = returnUrl;
280290
return this.View("Toggle", bookmark);
281291
}

LearningHub.Nhs.WebUI/Controllers/CatalogueController.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,6 @@ public async Task<IActionResult> IndexAsync(string reference, string tab, int? n
190190
CatalogueAccessRequestViewModel catalogueAccessRequest = null;
191191
if (this.ViewBag.UserAuthenticated)
192192
{
193-
var cacheKey = $"{this.CurrentUserId}:AllRolesWithPermissions";
194-
await this.cacheService.RemoveAsync(cacheKey);
195193
userGroups = await this.userGroupService.GetRoleUserGroupDetailAsync();
196194
catalogueAccessRequest = await this.catalogueService.GetLatestCatalogueAccessRequestAsync(catalogue.NodeId);
197195
}

LearningHub.Nhs.WebUI/Controllers/HomeController.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,17 @@ public async Task<IActionResult> Index(string myLearningDashboard = "my-in-progr
203203
this.Logger.LogInformation("User is authenticated: User is {fullname} and userId is: {lhuserid}", this.User.Identity.GetCurrentName(), this.User.Identity.GetCurrentUserId());
204204
if (this.User.IsInRole("Administrator") || this.User.IsInRole("BlueUser") || this.User.IsInRole("ReadOnly") || this.User.IsInRole("BasicUser"))
205205
{
206+
var learningTask = this.dashboardService.GetMyAccessLearningsAsync(myLearningDashboard, 1);
207+
var resourcesTask = this.dashboardService.GetResourcesAsync(resourceDashboard, 1);
208+
var cataloguesTask = this.dashboardService.GetCataloguesAsync(catalogueDashboard, 1);
209+
210+
await Task.WhenAll(learningTask, resourcesTask, cataloguesTask);
211+
206212
var model = new DashboardViewModel()
207213
{
208-
MyLearnings = await this.dashboardService.GetMyAccessLearningsAsync(myLearningDashboard, 1),
209-
Resources = await this.dashboardService.GetResourcesAsync(resourceDashboard, 1),
210-
Catalogues = await this.dashboardService.GetCataloguesAsync(catalogueDashboard, 1),
214+
MyLearnings = await learningTask,
215+
Resources = await resourcesTask,
216+
Catalogues = await cataloguesTask,
211217
};
212218

213219
if (!string.IsNullOrEmpty(this.Request.Query["preview"]) && Convert.ToBoolean(this.Request.Query["preview"]))
@@ -271,9 +277,13 @@ public async Task<IActionResult> LoadPage(string dashBoardTray = "my-learning",
271277
}
272278
else
273279
{
274-
model.MyLearnings = await this.dashboardService.GetMyAccessLearningsAsync(myLearningDashBoard, dashBoardTray == "my-learning" ? pageNumber : 1);
275-
model.Resources = await this.dashboardService.GetResourcesAsync(resourceDashBoard, dashBoardTray == "resources" ? pageNumber : 1);
276-
model.Catalogues = await this.dashboardService.GetCataloguesAsync(catalogueDashBoard, dashBoardTray == "catalogues" ? pageNumber : 1);
280+
var learningTask = this.dashboardService.GetMyAccessLearningsAsync(myLearningDashBoard, dashBoardTray == "my-learning" ? pageNumber : 1);
281+
var resourcesTask = this.dashboardService.GetResourcesAsync(resourceDashBoard, dashBoardTray == "resources" ? pageNumber : 1);
282+
var cataloguesTask = this.dashboardService.GetCataloguesAsync(catalogueDashBoard, dashBoardTray == "catalogues" ? pageNumber : 1);
283+
await Task.WhenAll(learningTask, resourcesTask, cataloguesTask);
284+
model.MyLearnings = await learningTask;
285+
model.Resources = await resourcesTask;
286+
model.Catalogues = await cataloguesTask;
277287
return this.View("Dashboard", model);
278288
}
279289
}

LearningHub.Nhs.WebUI/Controllers/ResourceController.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public async Task<IActionResult> Index(int resourceReferenceId, bool? acceptSens
123123

124124
var resource = await this.resourceService.GetItemByIdAsync(resourceReferenceId);
125125

126-
if (resource.Id == 0 || (resource.Catalogue != null && resource.Catalogue.Hidden))
126+
if ((resource == null && resource.Id == 0) || (resource.Catalogue != null && resource.Catalogue.Hidden))
127127
{
128128
this.ViewBag.SupportFormUrl = this.Settings.SupportUrls.SupportForm;
129129
return this.View("Unavailable");
@@ -147,7 +147,7 @@ public async Task<IActionResult> Index(int resourceReferenceId, bool? acceptSens
147147
var hasCatalogueAccess = false;
148148
if (resource.Catalogue.RestrictedAccess && this.User.Identity.IsAuthenticated)
149149
{
150-
var userGroups = await this.userGroupService.GetRoleUserGroupDetailForUserAsync(this.CurrentUserId);
150+
var userGroups = await this.userGroupService.GetRoleUserGroupDetailAsync();
151151

152152
hasCatalogueAccess = userGroups.Any(x => x.CatalogueNodeId == resource.Catalogue.NodeId &&
153153
(x.RoleEnum == RoleEnum.LocalAdmin || x.RoleEnum == RoleEnum.Editor || x.RoleEnum == RoleEnum.Reader)) || this.User.IsInRole("Administrator");
@@ -437,12 +437,13 @@ public async Task<IActionResult> UnpublishConfirm(ResourceUnpublishConfirmViewMo
437437
/// View HTML resource content.
438438
/// </summary>
439439
/// <param name="resourceReferenceId">Resource reference id.</param>
440+
/// <param name="currentResourceVersionId">Resource version id.</param>
440441
/// <param name="path">Html resource content relative path.</param>
441442
/// <returns>The file content.</returns>
442443
[HttpGet]
443444
[Authorize]
444-
[Route("resource/html/{resourceReferenceId}/{*path}")]
445-
public async Task<IActionResult> HtmlResourceContent(int resourceReferenceId, string path)
445+
[Route("resource/html/{resourceReferenceId}/{CurrentResourceVersionId}/{*path}")]
446+
public async Task<IActionResult> HtmlResourceContent(int resourceReferenceId, int currentResourceVersionId, string path)
446447
{
447448
if (resourceReferenceId == 0 || string.IsNullOrWhiteSpace(path))
448449
{
@@ -452,8 +453,14 @@ public async Task<IActionResult> HtmlResourceContent(int resourceReferenceId, st
452453
var userId = this.User.Identity.GetCurrentUserId();
453454
var cacheKey = $"HtmlContent:{userId}:{resourceReferenceId}";
454455
var (cacheExists, cacheValue) = await this.cacheService.TryGetAsync<string>(cacheKey);
456+
var oldresourceVersionId = 0;
457+
if (cacheExists)
458+
{
459+
var cachesplits = cacheValue.Split(":");
460+
oldresourceVersionId = int.Parse(cachesplits[0]);
461+
}
455462

456-
if (!cacheExists)
463+
if (!cacheExists || (oldresourceVersionId != currentResourceVersionId))
457464
{
458465
var resource = await this.resourceService.GetItemByIdAsync(resourceReferenceId);
459466

LearningHub.Nhs.WebUI/Helpers/ViewActivityHelper.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ public static string GetResourceTypeVerb(this ActivityDetailedItemViewModel acti
115115
return "Played " + GetDurationText(activityDetailedItemViewModel.ActivityDurationSeconds * 1000);
116116
case ResourceTypeEnum.WebLink:
117117
return "Visited";
118+
case ResourceTypeEnum.Html:
119+
return "Viewed";
120+
case ResourceTypeEnum.Case:
121+
return "Accessed";
122+
case ResourceTypeEnum.Assessment:
123+
return "Accessed";
118124
default:
119125
return string.Empty;
120126
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
<PackageReference Include="HtmlAgilityPack" Version="1.11.38" />
109109
<PackageReference Include="IdentityModel" Version="4.3.0" />
110110
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.0" />
111-
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.31" />
111+
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.33" />
112112
<PackageReference Include="linqtotwitter" Version="6.9.0" />
113113
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
114114
<PackageReference Include="Microsoft.ApplicationInsights.EventCounterCollector" Version="2.21.0" />

0 commit comments

Comments
 (0)