Skip to content

Commit 2b533ff

Browse files
authored
Merge pull request #202 from TechnologyEnhancedLearning/RC-14-03-2024
Merge Reticulum Changes to RC
2 parents a4246df + 8f4dfa4 commit 2b533ff

File tree

32 files changed

+230
-184
lines changed

32 files changed

+230
-184
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.4.0" />
9191
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.2" />
92-
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.25" />
92+
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.29" />
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" />

LearningHub.Nhs.WebUI/Controllers/AccountController.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace LearningHub.Nhs.WebUI.Controllers
66
{
7+
using System;
78
using System.Collections.Generic;
89
using System.Linq;
910
using System.Net;
@@ -1236,7 +1237,17 @@ private async Task<AccountCreationConfirmation> GetAccountConfirmationDetails(Ac
12361237
var employer = await this.locationService.GetByIdAsync(int.TryParse(accountCreationViewModel.LocationId, out int primaryEmploymentId) ? primaryEmploymentId : 0);
12371238
var region = await this.regionService.GetAllAsync();
12381239
var specialty = await this.specialtyService.GetSpecialtiesAsync();
1239-
var role = await this.jobRoleService.GetPagedFilteredAsync(accountCreationViewModel.CurrentRoleName, accountCreationViewModel.CurrentPageIndex, UserRegistrationContentPageSize);
1240+
var role = new Tuple<int, List<JobRoleBasicViewModel>>(0, null);
1241+
if (!string.IsNullOrEmpty(accountCreationViewModel.CurrentRoleName) && accountCreationViewModel.CurrentRoleName.Contains('/'))
1242+
{
1243+
string jobrole = accountCreationViewModel.CurrentRoleName.Replace("/", " ");
1244+
role = await this.jobRoleService.GetPagedFilteredAsync(jobrole, accountCreationViewModel.CurrentPageIndex, UserRegistrationContentPageSize);
1245+
}
1246+
else
1247+
{
1248+
role = await this.jobRoleService.GetPagedFilteredAsync(accountCreationViewModel.CurrentRoleName, accountCreationViewModel.CurrentPageIndex, UserRegistrationContentPageSize);
1249+
}
1250+
12401251
if (role.Item1 > 0)
12411252
{
12421253
accountCreationViewModel.CurrentRoleName = role.Item2.FirstOrDefault(x => x.Id == int.Parse(accountCreationViewModel.CurrentRole)).NameWithStaffGroup;

LearningHub.Nhs.WebUI/Controllers/ResourceController.cs

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ namespace LearningHub.Nhs.WebUI.Controllers
1010
using System.Threading.Tasks;
1111
using LearningHub.Nhs.Caching;
1212
using LearningHub.Nhs.Models.Common;
13-
using LearningHub.Nhs.Models.Entities.Hierarchy;
14-
using LearningHub.Nhs.Models.Entities.Resource;
1513
using LearningHub.Nhs.Models.Enums;
1614
using LearningHub.Nhs.Models.Extensions;
1715
using LearningHub.Nhs.Models.Resource;
@@ -353,15 +351,13 @@ public async Task<IActionResult> RateResource(ResourceRatingViewModel model)
353351
/// <summary>
354352
/// Ask user to confirm that they wish to edit a published resource.
355353
/// </summary>
356-
/// <param name="resourceId">The resourceId.</param>
357-
/// <param name="resourceReferenceId">The resourceReferenceId.</param>
358-
/// <param name="resourceTitle">The resourceTitle.</param>
354+
/// <param name="viewModel">The ResourceIndexViewModel.</param>
359355
/// <returns>The <see cref="IActionResult"/>.</returns>
360356
[Authorize]
361-
[Route("Resource/EditConfirm/{resourceId}/{resourceReferenceId}/{resourceTitle}")]
362-
public IActionResult EditConfirm(int resourceId, int resourceReferenceId, string resourceTitle)
357+
[Route("Resource/EditConfirm")]
358+
public IActionResult EditConfirm(ResourceIndexViewModel viewModel)
363359
{
364-
return this.View("EditConfirm", new ResourceEditConfirmViewModel { ResourceId = resourceId, ResourceReferenceId = resourceReferenceId, ResourceTitle = resourceTitle });
360+
return this.View("EditConfirm", new ResourceEditConfirmViewModel { ResourceId = viewModel.ResourceItem.ResourceId, ResourceReferenceId = viewModel.ResourceReferenceId, ResourceTitle = viewModel.ResourceItem.Title });
365361
}
366362

367363
/// <summary>
@@ -380,24 +376,20 @@ public IActionResult EditConfirm(ResourceEditConfirmViewModel viewModel)
380376
/// <summary>
381377
/// Ask user to confirm that they wish to unpublish a published resource.
382378
/// </summary>
383-
/// <param name="resourceVersionId">The resourceVersionId.</param>
384-
/// <param name="resourceReferenceId">The resourceReferenceId.</param>
385-
/// <param name="resourceType">The resourceType.</param>
386-
/// <param name="catalogueNodeVersionId"> The catalogueNodeVersionId.</param>
387-
/// <param name="resourceTitle">The resourceTitle.</param>
388-
/// <param name="scormEsrLinkType">The SCORM ESR link type.</param>
379+
/// <param name="viewModel">The ResourceIndexViewModel.</param>
389380
/// <returns>The <see cref="IActionResult"/>.</returns>
390381
[Authorize]
391-
[Route("Resource/UnpublishConfirm/{resourceVersionId}/{resourceReferenceId}/{resourceType}/{catalogueNodeVersionId}/{resourceTitle}/{scormEsrLinkType?}")]
392-
public IActionResult UnpublishConfirm(int resourceVersionId, int resourceReferenceId, int resourceType, int catalogueNodeVersionId, string resourceTitle, int scormEsrLinkType)
382+
[Route("Resource/UnpublishConfirm")]
383+
public IActionResult UnpublishConfirm(ResourceIndexViewModel viewModel)
393384
{
385+
int scormEsrLinkType = viewModel.ResourceItem.ResourceTypeEnum == ResourceTypeEnum.Scorm || viewModel.ResourceItem.ResourceTypeEnum == ResourceTypeEnum.GenericFile ? (int)viewModel.ExternalContentDetails.EsrLinkType : 0;
394386
return this.View("UnpublishConfirm", new ResourceUnpublishConfirmViewModel
395387
{
396-
ResourceVersionId = resourceVersionId,
397-
ResourceReferenceId = resourceReferenceId,
398-
ResourceType = (ResourceTypeEnum)resourceType,
399-
CatalogueNodeVersionId = catalogueNodeVersionId,
400-
ResourceTitle = resourceTitle,
388+
ResourceVersionId = viewModel.ResourceItem.ResourceVersionId,
389+
ResourceReferenceId = viewModel.ResourceReferenceId,
390+
ResourceType = (ResourceTypeEnum)(int)viewModel.ResourceItem.ResourceTypeEnum,
391+
CatalogueNodeVersionId = viewModel.ResourceItem.Catalogue.CatalogueNodeVersionId,
392+
ResourceTitle = viewModel.ResourceItem.Title,
401393
ScormEsrLinkType = (EsrLinkType)scormEsrLinkType,
402394
});
403395
}
@@ -494,15 +486,24 @@ public async Task<IActionResult> HtmlResourceContent(int resourceReferenceId, st
494486
contentType = "text/html";
495487
}
496488

497-
var file = await this.fileService.DownloadFileAsync(contentFilePath, path);
498-
if (file != null)
489+
if (contentType.Contains("video") || contentType.Contains("audio"))
499490
{
500-
return this.File(file.Content, contentType);
491+
var stream = await this.fileService.StreamFileAsync(contentFilePath, path);
492+
if (stream != null)
493+
{
494+
return this.File(stream, contentType, enableRangeProcessing: true);
495+
}
501496
}
502497
else
503498
{
504-
return this.Ok(this.Content("No file found"));
499+
var file = await this.fileService.DownloadFileAsync(contentFilePath, path);
500+
if (file != null)
501+
{
502+
return this.File(file.Content, contentType);
503+
}
505504
}
505+
506+
return this.Ok(this.Content("No file found"));
506507
}
507508
}
508509
}

LearningHub.Nhs.WebUI/Filters/OfflineCheckFilter.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,21 @@ public override async Task OnActionExecutionAsync(ActionExecutingContext context
4646

4747
var internalSystem = await this.internalSystemService.GetByIdAsync((int)InternalSystemType.LearningHub);
4848

49-
if (controller != "Offline"
50-
&& !(controller == "Home" && action == "Logout")
51-
&& internalSystem.IsOffline
52-
&& (!user.Identity.IsAuthenticated || !(await this.userGroupService.UserHasPermissionAsync("System_Offline_Bypass"))))
49+
if (internalSystem != null)
5350
{
54-
context.Result = new RedirectToRouteResult(
55-
new RouteValueDictionary
56-
{
51+
if (controller != "Offline"
52+
&& !(controller == "Home" && action == "Logout")
53+
&& internalSystem.IsOffline
54+
&& (!user.Identity.IsAuthenticated || !(await this.userGroupService.UserHasPermissionAsync("System_Offline_Bypass"))))
55+
{
56+
context.Result = new RedirectToRouteResult(
57+
new RouteValueDictionary
58+
{
5759
{ "Controller", "Offline" },
5860
{ "Action", "Index" },
59-
});
60-
executeNextAction = false;
61+
});
62+
executeNextAction = false;
63+
}
6164
}
6265

6366
if (executeNextAction)

LearningHub.Nhs.WebUI/Interfaces/IFileService.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ public interface IFileService
2929
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
3030
Task<ShareFileDownloadInfo> DownloadFileAsync(string filePath, string fileName);
3131

32+
/// <summary>
33+
/// The StreamFileAsync.
34+
/// </summary>
35+
/// <param name="filePath">The filePath.</param>
36+
/// <param name="fileName">The fileName.</param>
37+
/// <returns>The <see cref="Task{Stream}"/>.</returns>
38+
Task<Stream> StreamFileAsync(string filePath, string fileName);
39+
3240
/// <summary>
3341
/// The ProcessFile.
3442
/// </summary>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
<PackageReference Include="HtmlAgilityPack" Version="1.11.38" />
113113
<PackageReference Include="IdentityModel" Version="4.3.0" />
114114
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.0" />
115-
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.25" />
115+
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.29" />
116116
<PackageReference Include="linqtotwitter" Version="6.9.0" />
117117
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
118118
<PackageReference Include="Microsoft.ApplicationInsights.EventCounterCollector" Version="2.21.0" />

LearningHub.Nhs.WebUI/Scripts/vuesrc/contribute/ContentGenericFile.vue

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,9 @@
99
<file-panel :file-id="localGenericFileDetail.file.fileId" :file-description="localGenericFileDetail.file.fileName" :file-size="localGenericFileDetail.file.fileSizeKb" @changefile="changeFile"></file-panel>
1010
</div>
1111
<div v-if="scormOption" class="row mt-5">
12-
<div class="col-12">
12+
<div class="col-12 text-danger">
1313
<div>
14-
<label class="checkContainer">
15-
This is a SCORM/AICC elearning resource
16-
<input type="checkbox" v-model="localGenericFileDetail.scormAiccContent" @click="setProperty('scormAiccContent', $event.target.checked)">
17-
<span class="checkmark"></span>
18-
</label>
14+
Please choose the resource type as Elearning/HTML for the SCORM/AICC elearning or HTML resources.
1915
</div>
2016
</div>
2117
</div>

LearningHub.Nhs.WebUI/Scripts/vuesrc/models/contribute/contributeResourceModel.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ export class AttachedFileModel {
4141
export class GenericFileResourceModel {
4242
resourceVersionId: number = 0;
4343
file: ResourceFileModel = new ResourceFileModel();
44-
scormAiccContent: boolean = false;
4544
authoredYear: number = 0;
4645
authoredMonth: number = 0;
4746
authoredDayOfMonth: number = 0;

LearningHub.Nhs.WebUI/Scripts/vuesrc/resource/ResourceContent.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,11 @@
426426
window.location.pathname = './Home/Error';
427427
});
428428
}
429+
430+
if (interactionType == "ended") {
431+
setTimeout(() => { this.checkUserCertificateAvailability() }, 10000);
432+
await this.recordActivityComplete();
433+
}
429434
},
430435
async recordMediaPlayingEvent(): Promise<void> {
431436
let currentMediaTime = this.getMediaPlayerDisplayTime();

LearningHub.Nhs.WebUI/Services/FileService.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,29 @@ public async Task<ShareFileDownloadInfo> DownloadFileAsync(string filePath, stri
9898
return null;
9999
}
100100

101+
/// <summary>
102+
/// The StreamFileAsync.
103+
/// </summary>
104+
/// <param name="filePath">The filePath.</param>
105+
/// <param name="fileName">The fileName.</param>
106+
/// <returns>The <see cref="Task{Stream}"/>.</returns>
107+
public async Task<Stream> StreamFileAsync(string filePath, string fileName)
108+
{
109+
var directory = this.ShareClient.GetDirectoryClient(filePath);
110+
111+
if (await directory.ExistsAsync())
112+
{
113+
var file = directory.GetFileClient(fileName);
114+
115+
if (await file.ExistsAsync())
116+
{
117+
return await file.OpenReadAsync();
118+
}
119+
}
120+
121+
return null;
122+
}
123+
101124
/// <summary>
102125
/// The ProcessFile.
103126
/// </summary>

0 commit comments

Comments
 (0)