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
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<PackageReference Include="HtmlSanitizer" Version="6.0.453" />
<PackageReference Include="IdentityModel" Version="4.6.0" />
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.2" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.56" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.57" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.36" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.36" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ItemGroup>
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.11" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.56" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.57" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.13" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="Selenium.Axe" Version="4.0.19" />
Expand Down
16 changes: 16 additions & 0 deletions LearningHub.Nhs.WebUI/Helpers/ViewActivityHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using LearningHub.Nhs.Models.Enums;
using LearningHub.Nhs.Models.MyLearning;
Expand Down Expand Up @@ -405,6 +406,21 @@ public static bool CanViewProgress(this ActivityDetailedItemViewModel activityDe
return false;
}

/// <summary>
/// CanView Video Progress.
/// </summary>
/// <param name="activitiesViewModel">The MyLearningCombinedActivitiesViewModel.</param>
/// <returns>The <see cref="bool"/>bool.</returns>
public static bool CanViewVidoProgress(this MyLearningCombinedActivitiesViewModel activitiesViewModel)
{
if ((activitiesViewModel.ResourceType == ResourceTypeEnum.Video || activitiesViewModel.ResourceType == ResourceTypeEnum.Audio) && activitiesViewModel.ActivityStatus == ActivityStatusEnum.Incomplete && activitiesViewModel.IsCurrentResourceVersion && activitiesViewModel.IsMostRecent)
{
return true;
}

return false;
}

/// <summary>
/// GetDurationText.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
<PackageReference Include="HtmlAgilityPack" Version="1.11.72" />
<PackageReference Include="IdentityModel" Version="4.6.0" />
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.0" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.56" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.57" />
<PackageReference Include="linqtotwitter" Version="6.9.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
<PackageReference Include="Microsoft.ApplicationInsights.EventCounterCollector" Version="2.21.0" />
Expand Down
7 changes: 7 additions & 0 deletions LearningHub.Nhs.WebUI/Views/MyLearning/LearningHistory.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,13 @@
<div class="nhs-progress-bar" style="width: @(activity.ScorePercentage)%"></div>
</div>
}
else @if (ViewActivityHelper.CanViewVidoProgress(activity))
{
<div class="nhsuk-u-padding-top-1">
@activity.CompletionPercentage% complete
<a asp-controller="MyLearning" asp-action="ViewProgress" asp-route-resourceId="@activity.ResourceId" asp-route-version="@activity.MajorVersion" asp-route-maxTime="@activity.ResourceDurationMilliseconds" asp-route-returnUrl="@returnUrl" asp-route-resourceReferenceId="@activity.ResourceReferenceId">View Progress</a>
</div>
}


@if (ViewActivityHelper.CanCertificateawarded(activity))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.56" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.57" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.15.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.56" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.57" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.7" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<PackageReference Include="AutoMapper" Version="10.1.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
<PackageReference Include="IdentityModel" Version="4.6.0" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.56" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.57" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.20" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.20" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.20" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<ItemGroup>
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.11" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.56" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.57" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<PackageReference Include="Azure.Storage.Files.Shares" Version="12.8.0" />
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.0" />
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.11" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.56" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.57" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.1" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ public async Task<MyLearningActivitiesDetailedViewModel> GetMyInprogressLearning
ScorePercentage = Activity.ScorePercentage,
TotalActivities = 0,
CompletedActivities = 0,
IsMostRecent = false,
ResourceDurationMilliseconds = Activity.ResourceDurationMilliseconds,
CompletionPercentage = Activity.CompletionPercentage,
}).ToList();
}

Expand All @@ -258,6 +261,9 @@ public async Task<MyLearningActivitiesDetailedViewModel> GetMyInprogressLearning
ScorePercentage = Convert.ToInt32(course.ProgressPercentage.TrimEnd('%')),
TotalActivities = course.TotalActivities,
CompletedActivities = course.CompletedActivities,
IsMostRecent = false,
ResourceDurationMilliseconds = 0,
CompletionPercentage = 0,
}).ToList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ public async Task<MyLearningActivitiesDetailedViewModel> GetUserRecentMyLearning
ScorePercentage = Activity.ScorePercentage,
TotalActivities = 0,
CompletedActivities = 0,
IsMostRecent = false,
ResourceDurationMilliseconds = Activity.ResourceDurationMilliseconds,
CompletionPercentage = Activity.CompletionPercentage,
}).ToList();
}

Expand All @@ -209,11 +212,14 @@ public async Task<MyLearningActivitiesDetailedViewModel> GetUserRecentMyLearning
ScorePercentage = Convert.ToInt32(course.ProgressPercentage.TrimEnd('%')),
TotalActivities = course.TotalActivities,
CompletedActivities = course.CompletedActivities,
IsMostRecent = false,
ResourceDurationMilliseconds = 0,
CompletionPercentage=0,
}).ToList();
}

// Combine both result sets
combainedUserActivities = mappedMyLearningActivities.Concat(mappedEnrolledCourses).ToList();
combainedUserActivities = mappedMyLearningActivities.Concat(mappedEnrolledCourses).ToList();


var pagedResults = combainedUserActivities.OrderByDescending(activity => activity.ActivityDate).Skip(requestModel.Skip).Take(requestModel.Take).ToList();
Expand Down Expand Up @@ -272,6 +278,13 @@ public async Task<MyLearningActivitiesDetailedViewModel> GetUserLearningHistoryA

if (result != null)
{
// Step 1: Get most recent date per ResourceId
var mostRecentByResource = result
.GroupBy(a => a.ResourceId)
.ToDictionary(
g => g.Key,
g => g.Max(a => a.ActivityDate)
);
mappedMyLearningActivities = result.Select(activity => new MyLearningCombinedActivitiesViewModel
{
UserId = userId,
Expand All @@ -289,6 +302,12 @@ public async Task<MyLearningActivitiesDetailedViewModel> GetUserLearningHistoryA
ScorePercentage = activity.ScorePercentage,
TotalActivities = 0,
CompletedActivities = 0,

//Set IsMostRecent if this is the most recent activity for the ResourceId
IsMostRecent = mostRecentByResource.TryGetValue(activity.ResourceId, out var mostRecentDate)
&& activity.ActivityDate == mostRecentDate,
ResourceDurationMilliseconds = activity.ResourceDurationMilliseconds,
CompletionPercentage = activity.CompletionPercentage,
}).ToList();
}

Expand Down Expand Up @@ -324,6 +343,9 @@ public async Task<MyLearningActivitiesDetailedViewModel> GetUserLearningHistoryA
ScorePercentage = int.TryParse(course.ProgressPercentage.TrimEnd('%'), out var score) ? score : 0,
TotalActivities = course.TotalActivities,
CompletedActivities = course.CompletedActivities,
IsMostRecent = false,
ResourceDurationMilliseconds = 0,
CompletionPercentage = 0,
}).ToList();
}
}
Expand Down Expand Up @@ -399,8 +421,8 @@ public async Task<Tuple<int, MyLearningDetailedItemViewModel>> GetResourceCertif

if (assessmentType == AssessmentTypeEnum.Formal)
{
activityEntities = activityEntities.Where(x => x.AssessmentResourceActivity.FirstOrDefault() != null &&
x.AssessmentResourceActivity.First().Score.HasValue &&
activityEntities = activityEntities.Where(x => x.AssessmentResourceActivity.FirstOrDefault() != null &&
x.AssessmentResourceActivity.First().Score.HasValue &&
(int)Math.Round(x.AssessmentResourceActivity.First().Score.Value,
MidpointRounding.AwayFromZero) >= x.ResourceVersion.AssessmentResourceVersion.PassMark)
.ToList();
Expand Down Expand Up @@ -501,7 +523,6 @@ public async Task<List<MyLearningDetailedItemViewModel>> PopulateMyLearningDetai
latestActivityCheck.RemoveAll(x => x.Resource.ResourceTypeEnum == ResourceTypeEnum.Scorm && (x.ActivityStatusId == (int)ActivityStatusEnum.Downloaded || x.ActivityStatusId == (int)ActivityStatusEnum.Incomplete || x.ActivityStatusId == (int)ActivityStatusEnum.InProgress));
if (latestActivityCheck.Any() && latestActivityCheck.FirstOrDefault()?.Resource.ResourceTypeEnum == ResourceTypeEnum.Assessment)
{

latestActivityCheck = latestActivityCheck.Where(x => x.AssessmentResourceActivity.FirstOrDefault() != null && (x.ResourceVersion.AssessmentResourceVersion.AssessmentType == AssessmentTypeEnum.Formal && x.AssessmentResourceActivity.FirstOrDefault() != null && x.AssessmentResourceActivity.First().Score.HasValue && (int)Math.Round(x.AssessmentResourceActivity.First().Score.Value, MidpointRounding.AwayFromZero) >= x.ResourceVersion.AssessmentResourceVersion.PassMark) ||
(x.ResourceVersion.AssessmentResourceVersion.AssessmentType == AssessmentTypeEnum.Informal && x.AssessmentResourceActivity.FirstOrDefault() != null && x.AssessmentResourceActivity.First().Score.HasValue)).ToList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<ItemGroup>
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.11" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.56" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.57" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="NBuilder" Version="6.1.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PackageReference Include="AspNetCore.Authentication.ApiKey" Version="8.0.1" />
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.11" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.56" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.57" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
<PackageReference Include="Microsoft.ApplicationInsights.NLogTarget" Version="2.22.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.36" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<ItemGroup>
<PackageReference Include="Azure.Messaging.ServiceBus" Version="7.18.3" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.56" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.57" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.18.1" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.56" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.57" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Moq" Version="4.20.72" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PackageReference Include="AutoMapper" Version="10.1.1" />
<PackageReference Include="Azure.Messaging.ServiceBus" Version="7.18.3" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.23.0" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.56" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.57" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.36" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.56" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.57" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<ItemGroup>

<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.56" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.57" />

<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />

Expand Down
2 changes: 1 addition & 1 deletion WebAPI/LearningHub.Nhs.API/LearningHub.Nhs.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.11" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.0" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.56" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.57" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.36" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.11" />
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.0" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.56" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.57" />
<PackageReference Update="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.11" />
<PackageReference Include="FluentAssertions" Version="8.0.1" />
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.0" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.56" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.57" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Moq" Version="4.20.72" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ BEGIN
arv.PassMark AS PassMark,
asra.score AS AssesmentScore,
mar.SecondsPlayed AS SecondsPlayed,
mar.PercentComplete AS PercentComplete,
ISNULL( CAST(mar.PercentComplete AS INT) ,0) AS PercentComplete,
sa.CmiCoreLesson_status AS CmiCoreLessonstatus,
sa.CmiCoreScoreMax AS CmiCoreScoreMax,
sa.CmiCoreSession_time AS CmiCoreSessiontime,
Expand Down Expand Up @@ -77,9 +77,11 @@ SELECT Top 8 ActivityId,
ActivityStatus,
ActivityDate,
ActivityDurationSeconds,
ScorePercentage
ScorePercentage,
0 AS ResourceDurationMilliseconds,
PercentComplete AS CompletionPercentage
FROM CTERecentActivities
WHERE rn = 1 AND ActivityStatus IN (2,4,7)
order by ActivityDate desc;
WHERE rn = 1 AND ActivityStatus IN (2,4,7)
order by ActivityDate desc;

END
Loading
Loading