Skip to content
Merged

Rc #307

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4935eb1
Apply additional corrections for TD3162 and TD3163
akdalin-hee Apr 16, 2024
c3a2983
TD-3023 unpublished and deleted draft resource file refactor
OluwatobiAwe Apr 16, 2024
3c9eae8
Merge pull request #288 from TechnologyEnhancedLearning/Develop/Fixes…
OluwatobiAwe Apr 16, 2024
27b6cfa
TD-3023 limit the removal of output content to scorm and html resourc…
OluwatobiAwe Apr 17, 2024
bfa29c6
Merge pull request #289 from TechnologyEnhancedLearning/Develop/Fixes…
OluwatobiAwe Apr 17, 2024
c1a4545
Merge pull request #287 from TechnologyEnhancedLearning/TD-3162-TD-31…
AnjuJose011 Apr 17, 2024
0a9403e
TD-3741 - LMS server issue related to active content cache is null.
Swapnamol Apr 17, 2024
28ec872
Merge pull request #292 from TechnologyEnhancedLearning/Develop/Fixes…
Swapnamol Apr 17, 2024
011e9c0
TD-4047: Duplicate records appearing in Mylearning page. Brought back…
sarathlal-sarangadharan Apr 17, 2024
1292930
Merge pull request #294 from TechnologyEnhancedLearning/Develop/Fixes…
sarathlal-sarangadharan Apr 17, 2024
9a81d19
Corrected the naming convention for uniformity
Swapnamol Apr 17, 2024
6ac60ae
Merge pull request #295 from TechnologyEnhancedLearning/Develop/Fixes…
Swapnamol Apr 17, 2024
a9dd7fe
TD-3955 : Reverted the changes related to the Scorm commit
Swapnamol Apr 17, 2024
f7ab65d
Merge pull request #296 from TechnologyEnhancedLearning/Develop/Fixes…
Swapnamol Apr 17, 2024
fc75b25
TD-1325: Reverted the changes as it is causing some LMS server issues
Swapnamol Apr 17, 2024
904086b
Merge pull request #298 from TechnologyEnhancedLearning/Develop/Fixes…
Swapnamol Apr 17, 2024
6cb0c53
TD-4052 bugfix
OluwatobiAwe Apr 18, 2024
88fa9f8
Merge pull request #299 from TechnologyEnhancedLearning/Develop/Fixes…
OluwatobiAwe Apr 18, 2024
497c23d
TD-4057: Limited the characters to 3000 to findwise
sarathlal-sarangadharan Apr 19, 2024
8979d3a
Replace search button text to Search. Correct catalogue alt name. Rem…
akdalin-hee Apr 19, 2024
390de0f
Merge pull request #302 from TechnologyEnhancedLearning/TD-3162-TD-31…
akdalin-hee Apr 19, 2024
da05f67
Merge pull request #300 from TechnologyEnhancedLearning/Develop/Featu…
binon Apr 19, 2024
4944fb5
TD-3023 move deleted case resource files to archive
OluwatobiAwe Apr 22, 2024
1b4752c
Merge pull request #301 from TechnologyEnhancedLearning/Develop/Featu…
sarathlal-sarangadharan Apr 22, 2024
27b2cb9
Correct Skipped headiing issue for catalogue folders
akdalin-hee Apr 22, 2024
56208e5
Merge pull request #303 from TechnologyEnhancedLearning/Develop/Fixes…
OluwatobiAwe Apr 22, 2024
f300e25
Merge pull request #304 from TechnologyEnhancedLearning/TD-3162-TD-31…
akdalin-hee Apr 22, 2024
aad3163
Merge pull request #306 from TechnologyEnhancedLearning/Develop/Featu…
binon Apr 22, 2024
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
120 changes: 118 additions & 2 deletions LearningHub.Nhs.WebUI/Controllers/Api/ContributeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Web;
using LearningHub.Nhs.Models.Enums;
using LearningHub.Nhs.Models.Resource;
using LearningHub.Nhs.Models.Resource.Blocks;
using LearningHub.Nhs.Models.Resource.Contribute;
using LearningHub.Nhs.Models.Resource.Files;
using LearningHub.Nhs.WebUI.Interfaces;
Expand Down Expand Up @@ -224,11 +225,14 @@ public async Task<ActionResult> DeleteResourceKeywordAsync([FromBody] KeywordDel
[Route("DeleteResourceVersion/{resourceversionId}")]
public async Task<ActionResult> DeleteResourceVersion(int resourceVersionId)
{
var associatedFile = await this.resourceService.GetResourceVersionExtendedAsync(resourceVersionId);
var associatedFile = await this.resourceService.GetObsoleteResourceFile(resourceVersionId, true);
var validationResult = await this.contributeService.DeleteResourceVersionAsync(resourceVersionId);
if (validationResult.IsValid)
{
_ = Task.Run(async () => { await this.fileService.PurgeResourceFile(associatedFile); });
if (associatedFile != null && associatedFile.Any())
{
_ = Task.Run(async () => { await this.fileService.PurgeResourceFile(null, associatedFile); });
}
}

return this.Ok(validationResult);
Expand Down Expand Up @@ -338,7 +342,19 @@ public ActionResult GetSettings()
[Route("PublishResourceVersion")]
public async Task<ActionResult> PublishResourceVersionAsync([FromBody] PublishViewModel publishViewModel)
{
var associatedResource = await this.resourceService.GetResourceVersionExtendedAsync(publishViewModel.ResourceVersionId);
var validationResult = await this.contributeService.SubmitResourceVersionForPublishAsync(publishViewModel);
if (validationResult.IsValid)
{
if (associatedResource.ResourceTypeEnum != ResourceTypeEnum.Scorm && associatedResource.ResourceTypeEnum != ResourceTypeEnum.Html)
{
var obsoleteFiles = await this.resourceService.GetObsoleteResourceFile(publishViewModel.ResourceVersionId);
if (obsoleteFiles != null && obsoleteFiles.Any())
{
await this.fileService.PurgeResourceFile(null, obsoleteFiles);
}
}
}

return this.Ok(validationResult);
}
Expand Down Expand Up @@ -475,7 +491,9 @@ public async Task<ActionResult> SaveWeblinkDetailAsync([FromBody] WebLinkViewMod
[Route("SaveCaseDetail")]
public async Task<ActionResult> SaveCaseDetailAsync([FromBody] CaseViewModel request)
{
var existingResourceState = await this.resourceService.GetResourceVersionExtendedAsync(request.ResourceVersionId);
int resourceVersionId = await this.contributeService.SaveCaseDetailAsync(request);
this.RemoveDeletedCaseFiles(existingResourceState?.CaseDetails, request);
return this.Ok(resourceVersionId);
}

Expand Down Expand Up @@ -608,5 +626,103 @@ private async Task<bool> UserCanEditCatalogue(int catalogueId)
{
return await this.catalogueService.CanCurrentUserEditCatalogue(catalogueId);
}

private void RemoveDeletedCaseFiles(CaseViewModel existingResource, CaseViewModel newResource)
{
try
{
var filePaths = new List<string>();
if (existingResource != null && existingResource.BlockCollection != null)
{
var allBlocks = existingResource.BlockCollection.Blocks.ToList();
var newBlocks = newResource.BlockCollection.Blocks.ToList();
if (allBlocks.Any())
{
var existingAttachements = allBlocks.Where(x => x.BlockType == BlockType.Media && x.MediaBlock != null && x.MediaBlock.MediaType == MediaType.Attachment && x.MediaBlock.Attachment != null).ToList();
if (existingAttachements.Any())
{
foreach (var oldblock in existingAttachements)
{
var entry = newBlocks.FirstOrDefault(x => x.BlockType == BlockType.Media && x.MediaBlock != null && x.MediaBlock.MediaType == MediaType.Attachment && x.MediaBlock.Attachment != null && x.MediaBlock.Attachment.File?.FileId == oldblock.MediaBlock.Attachment?.File?.FileId);
if (entry == null)
{
filePaths.Add(oldblock.MediaBlock.Attachment?.File?.FilePath);
}
}
}

var existingVideos = allBlocks.Where(x => x.BlockType == BlockType.Media && x.MediaBlock != null && x.MediaBlock.MediaType == MediaType.Video && x.MediaBlock.Video != null).ToList();
if (existingVideos.Any())
{
foreach (var oldblock in existingVideos)
{
var entry = newBlocks.FirstOrDefault(x => x.BlockType == BlockType.Media && x.MediaBlock != null && x.MediaBlock.MediaType == MediaType.Video && x.MediaBlock.Video != null && x.MediaBlock.Video.VideoFile?.File?.FileId == oldblock.MediaBlock?.Video?.VideoFile?.File?.FileId);
if (entry == null)
{
filePaths.Add(oldblock.MediaBlock.Video?.VideoFile?.File?.FilePath);
if (oldblock.MediaBlock?.Video?.VideoFile?.TranscriptFile?.File?.FilePath != null)
{
filePaths.Add(oldblock.MediaBlock.Video?.VideoFile?.TranscriptFile?.File?.FilePath);
}
}
}
}

var existingImages = allBlocks.Where(x => x.BlockType == BlockType.Media && x.MediaBlock != null && x.MediaBlock.MediaType == MediaType.Image && x.MediaBlock.Image != null).ToList();
if (existingImages.Any())
{
foreach (var oldblock in existingImages)
{
var entry = newBlocks.FirstOrDefault(x => x.BlockType == BlockType.Media && x.MediaBlock != null && x.MediaBlock.MediaType == MediaType.Image && x.MediaBlock.Image != null && x.MediaBlock?.Image?.File?.FileId == oldblock.MediaBlock?.Image?.File?.FileId);
if (entry == null)
{
filePaths.Add(oldblock?.MediaBlock?.Image?.File?.FilePath);
}
}
}

var existingImageCarousel = allBlocks.Where(x => x.BlockType == BlockType.ImageCarousel && x.ImageCarouselBlock != null && x.ImageCarouselBlock.ImageBlockCollection != null && x.ImageCarouselBlock.ImageBlockCollection.Blocks != null).ToList();
if (existingImageCarousel.Any())
{
foreach (var imageBlock in existingImageCarousel)
{
foreach (var oldblock in imageBlock?.ImageCarouselBlock?.ImageBlockCollection?.Blocks)
{
var entry = newBlocks.FirstOrDefault(x => x.BlockType == BlockType.ImageCarousel && x.ImageCarouselBlock != null && x.ImageCarouselBlock.ImageBlockCollection != null && x.ImageCarouselBlock.ImageBlockCollection.Blocks != null && x.ImageCarouselBlock.ImageBlockCollection.Blocks.Where(x => x.MediaBlock?.Image?.File?.FileId == oldblock.MediaBlock?.Image?.File?.FileId).Any());
if (entry == null)
{
filePaths.Add(oldblock.MediaBlock?.Image?.File?.FilePath);
}
}
}
}

var existingWholeSlideImages = allBlocks.Where(x => x.WholeSlideImageBlock != null && x.WholeSlideImageBlock.WholeSlideImageBlockItems.Any()).ToList();
if (existingWholeSlideImages.Any())
{
foreach (var wsi in existingWholeSlideImages)
{
foreach (var oldblock in wsi?.WholeSlideImageBlock?.WholeSlideImageBlockItems)
{
var entry = newBlocks.FirstOrDefault(x => x.WholeSlideImageBlock != null && x.WholeSlideImageBlock.WholeSlideImageBlockItems.Where(x => x.WholeSlideImage?.File?.FileId == oldblock.WholeSlideImage?.File?.FileId).Any());
if (entry == null)
{
filePaths.Add(oldblock.WholeSlideImage?.File?.FilePath);
}
}
}
}
}
}

if (filePaths != null && filePaths.Any())
{
_ = Task.Run(async () => { await this.fileService.PurgeResourceFile(null, filePaths); });
}
}
catch (Exception ex)
{
}
}
}
}
4 changes: 0 additions & 4 deletions LearningHub.Nhs.WebUI/Controllers/Api/ScormController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,6 @@ private async Task<bool> Commit(SCO scoObject)

// Persist update.
await this.activityService.UpdateScormActivityAsync(scoObject);
if (scoObject.LessonStatusId == ScormLessionStatus.ActivityStatusId(ScormLessionStatus.Completed) || scoObject.LessonStatusId == ScormLessionStatus.ActivityStatusId(ScormLessionStatus.Passed))
{
await this.activityService.CompleteScormActivity(scoObject);
}

return true;
}
Expand Down
6 changes: 5 additions & 1 deletion LearningHub.Nhs.WebUI/Controllers/ResourceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,11 @@ public async Task<IActionResult> UnpublishConfirm(ResourceUnpublishConfirmViewMo

if (validationResult.IsValid)
{
_ = Task.Run(async () => { await this.fileService.PurgeResourceFile(associatedFile); });
if (associatedFile.ScormDetails != null || associatedFile.HtmlDetails != null)
{
_ = Task.Run(async () => { await this.fileService.PurgeResourceFile(associatedFile, null); });
}

if (viewModel.CatalogueNodeVersionId == 1)
{
return this.Redirect("/my-contributions/unpublished");
Expand Down
3 changes: 2 additions & 1 deletion LearningHub.Nhs.WebUI/Interfaces/IFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public interface IFileService
/// The PurgeResourceFile.
/// </summary>
/// <param name="vm">The vm.<see cref="ResourceVersionExtendedViewModel"/>.</param>
/// <param name="filePaths">.</param>
/// <returns>The <see cref="Task"/>.</returns>
Task PurgeResourceFile(ResourceVersionExtendedViewModel vm);
Task PurgeResourceFile(ResourceVersionExtendedViewModel vm = null, List<string> filePaths = null);
}
}
8 changes: 8 additions & 0 deletions LearningHub.Nhs.WebUI/Interfaces/IResourceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,5 +282,13 @@ public interface IResourceService
/// <param name="resourceVersionId">resource version id.</param>
/// <returns>The <see cref="Task"/>.</returns>
Task<LearningHubValidationResult> DeleteAllResourceVersionProviderAsync(int resourceVersionId);

/// <summary>
/// The GetObsoleteResourceFile.
/// </summary>
/// <param name="resourceVersionId">The resourceVersionId.</param>
/// <param name="deletedResource">.</param>
/// <returns>The <see cref="T:Task{List{FileTypeViewModel}}"/>.</returns>
Task<List<string>> GetObsoleteResourceFile(int resourceVersionId, bool deletedResource = false);
}
}
2 changes: 1 addition & 1 deletion LearningHub.Nhs.WebUI/Models/MyLearningViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public List<CheckboxListItemViewModel> StatusFilterCheckbox()
var checkboxes = new List<CheckboxListItemViewModel>()
{
new CheckboxListItemViewModel("Complete", "Completed", null),
new CheckboxListItemViewModel("Incomplete", "In Progress", null),
new CheckboxListItemViewModel("Incomplete", "In progress", null),
new CheckboxListItemViewModel("Passed", "Passed", null),
new CheckboxListItemViewModel("Failed", "Failed", null),
new CheckboxListItemViewModel("Downloaded", "Downloaded", null),
Expand Down
51 changes: 47 additions & 4 deletions LearningHub.Nhs.WebUI/Services/FileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using LearningHub.Nhs.Models.Resource;
using LearningHub.Nhs.WebUI.Configuration;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.Options;

Expand Down Expand Up @@ -88,13 +87,13 @@ private ShareClient InputArchiveShareClient

this.archiveShareClient = new ShareClient(this.settings.AzureSourceArchiveStorageConnectionString, this.settings.AzureFileStorageResourceShareName, options);

if (!this.shareClient.Exists())
if (!this.archiveShareClient.Exists())
{
throw new Exception($"Unable to access azure file storage resource {this.settings.AzureFileStorageResourceShareName}");
}
}

return this.shareClient;
return this.archiveShareClient;
}
}

Expand Down Expand Up @@ -129,6 +128,7 @@ public async Task DeleteChunkDirectory(string directoryRef, int chunks)
public async Task<ShareFileDownloadInfo> DownloadFileAsync(string filePath, string fileName)
{
var directory = this.ShareClient.GetDirectoryClient(filePath);
var sourceDirectory = this.InputArchiveShareClient.GetDirectoryClient(filePath);

if (await directory.ExistsAsync())
{
Expand All @@ -139,6 +139,15 @@ public async Task<ShareFileDownloadInfo> DownloadFileAsync(string filePath, stri
return await file.DownloadAsync();
}
}
else if (await sourceDirectory.ExistsAsync())
{
var file = sourceDirectory.GetFileClient(fileName);

if (await file.ExistsAsync())
{
return await file.DownloadAsync();
}
}

return null;
}
Expand Down Expand Up @@ -201,9 +210,17 @@ public async Task<string> ProcessFile(Stream fileBytes, string fileName, string
/// The PurgeResourceFile.
/// </summary>
/// <param name="vm">The vm.<see cref="ResourceVersionExtendedViewModel"/>.</param>
/// <param name="filePaths">.</param>
/// <returns>The <see cref="Task"/>.</returns>
public async Task PurgeResourceFile(ResourceVersionExtendedViewModel vm)
public async Task PurgeResourceFile(ResourceVersionExtendedViewModel vm = null, List<string> filePaths = null)
{
if (filePaths != null
&& filePaths.Any())
{
await this.MoveInPutDirectoryToArchive(filePaths);
return;
}

if (vm != null)
{
var allContentPath = new List<string>();
Expand Down Expand Up @@ -235,7 +252,29 @@ public async Task PurgeResourceFile(ResourceVersionExtendedViewModel vm)
}
}
}
else if (vm.CaseDetails != null)
{
var blockCollection = vm.CaseDetails.BlockCollection;
foreach (var entry in blockCollection.Blocks)
{
if (entry.ImageCarouselBlock != null)
{
foreach (var item in entry.ImageCarouselBlock?.ImageBlockCollection?.Blocks)
{
allFilePath.Add(item?.MediaBlock?.Image?.File.FilePath);
}
}
else if (entry.WholeSlideImageBlock != null)
{
foreach (var item in entry.WholeSlideImageBlock.WholeSlideImageBlockItems)
{
allFilePath.Add(item?.WholeSlideImage?.File.FilePath);
}
}
}
}

// audio and video to be added
await this.MoveInPutDirectoryToArchive(allFilePath);
await this.MoveOutPutDirectoryToArchive(allContentPath);
}
Expand Down Expand Up @@ -374,6 +413,10 @@ private async Task MoveInPutDirectoryToArchive(List<string> allDirectoryRef)
{
var directory = this.ShareClient.GetDirectoryClient(directoryRef);
var archiveDirectory = this.InputArchiveShareClient.GetDirectoryClient(directoryRef);
if (!directory.Exists())
{
continue;
}

await foreach (var fileItem in directory.GetFilesAndDirectoriesAsync())
{
Expand Down
30 changes: 30 additions & 0 deletions LearningHub.Nhs.WebUI/Services/ResourceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1274,5 +1274,35 @@ public async Task<LearningHubValidationResult> DeleteAllResourceVersionProviderA

return apiResponse.ValidationResult;
}

/// <summary>
/// The GetObsoleteResourceFile.
/// </summary>
/// <param name="resourceVersionId">The resourceVersionId.</param>
/// <param name="deletedResource">.</param>
/// <returns>The <see cref="T:Task{List{FileTypeViewModel}}"/>.</returns>
public async Task<List<string>> GetObsoleteResourceFile(int resourceVersionId, bool deletedResource = false)
{
List<string> filePaths = null;

var client = await this.LearningHubHttpClient.GetClientAsync();

var request = $"Resource/GetObsoleteResourceFile/{resourceVersionId}/{deletedResource}";
var response = await client.GetAsync(request).ConfigureAwait(false);

if (response.IsSuccessStatusCode)
{
var result = response.Content.ReadAsStringAsync().Result;
filePaths = JsonConvert.DeserializeObject<List<string>>(result);
}
else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized
||
response.StatusCode == System.Net.HttpStatusCode.Forbidden)
{
throw new Exception("AccessDenied");
}

return filePaths;
}
}
}
2 changes: 1 addition & 1 deletion LearningHub.Nhs.WebUI/Styles/nhsuk/pages/bookmark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ a.cancel-link:visited {
}
}

.folder-title {
div.folder-title {
font-weight: bold;
}

Expand Down
13 changes: 12 additions & 1 deletion LearningHub.Nhs.WebUI/Styles/nhsuk/pages/catalogue.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ textarea {
}
}

@media(min-width: 40.0625em) {
.folder-title {
font-size: 24px;
font-size: 1.5rem;
}
}

.folder-title_empty {
display: flex;

Expand Down Expand Up @@ -91,9 +98,13 @@ textarea {
padding: 20px 0 32px 0;
border-bottom: 1px solid $nhsuk-grey-light;

p, h3 {
p, h2, h3 {
margin: 0;
}

h2.nhsuk-u-reading-width {
font-size: x-large;
}
}

.personal-details-table {
Expand Down
Loading