Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 10 additions & 3 deletions LearningHub.Nhs.WebUI/Controllers/ResourceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,13 @@ public async Task<IActionResult> UnpublishConfirm(ResourceUnpublishConfirmViewMo
/// View HTML resource content.
/// </summary>
/// <param name="resourceReferenceId">Resource reference id.</param>
/// <param name="currentResourceVersionId">Resource version id.</param>
/// <param name="path">Html resource content relative path.</param>
/// <returns>The file content.</returns>
[HttpGet]
[Authorize]
[Route("resource/html/{resourceReferenceId}/{*path}")]
public async Task<IActionResult> HtmlResourceContent(int resourceReferenceId, string path)
[Route("resource/html/{resourceReferenceId}/{CurrentResourceVersionId}/{*path}")]
public async Task<IActionResult> HtmlResourceContent(int resourceReferenceId, int currentResourceVersionId, string path)
{
if (resourceReferenceId == 0 || string.IsNullOrWhiteSpace(path))
{
Expand All @@ -452,8 +453,14 @@ public async Task<IActionResult> HtmlResourceContent(int resourceReferenceId, st
var userId = this.User.Identity.GetCurrentUserId();
var cacheKey = $"HtmlContent:{userId}:{resourceReferenceId}";
var (cacheExists, cacheValue) = await this.cacheService.TryGetAsync<string>(cacheKey);
var oldresourceVersionId = 0;
if (cacheExists)
{
var cachesplits = cacheValue.Split(":");
oldresourceVersionId = int.Parse(cachesplits[0]);
}

if (!cacheExists)
if (!cacheExists || (oldresourceVersionId != currentResourceVersionId))
{
var resource = await this.resourceService.GetItemByIdAsync(resourceReferenceId);

Expand Down
2 changes: 1 addition & 1 deletion LearningHub.Nhs.WebUI/Views/Resource/_ResourceItem.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
{
<div id="resourcePg" class="nhsuk-card nhsuk-bg-light-blue">
<div class="nhsuk-card__content">
<a v-on:click=checkUserCertificateAvailability(@resourceItem.Id) href="@($"{Context.Request.Scheme}://{Context.Request.Host}/resource/html/{resourceItem.Id}/index.html")"
<a v-on:click=checkUserCertificateAvailability(@resourceItem.Id) href="@($"{Context.Request.Scheme}://{Context.Request.Host}/resource/html/{resourceItem.Id}/{resourceItem.ResourceVersionId}/index.html")"
onclick="@($"window.open(this.href, 'scormDebugWindow', 'status=no,location=no,toolbar=no,menubar=no,dependent=no,width={resourceItem.HtmlDetails.PopupWidth},height={resourceItem.HtmlDetails.PopupHeight}'); return false;")">
<button class="nhsuk-button">
Launch HTML resource
Expand Down