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
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
Expand Down
72 changes: 72 additions & 0 deletions LearningHub.Nhs.WebUI/Controllers/MyLearningController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,77 @@ public async Task<IActionResult> ViewProgress(int resourceId, int resourceRefere
return this.View(vm);
}

/// <summary>
/// Get user certificates.
/// </summary>
/// <param name="certificateRequest">The certificateRequest.</param>
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
[Route("mylearning/certificates")]
[HttpGet]
[HttpPost]
public async Task<IActionResult> Certificates(MyLearningUserCertificatesViewModel certificateRequest = null)
{
var myLearningRequestModel = new MyLearningRequestModel
{
SearchText = certificateRequest.SearchText?.Trim(),
Skip = certificateRequest.CurrentPageIndex * MyLearningPageSize,
Take = MyLearningPageSize,
File = certificateRequest.File,
Video = certificateRequest.Video,
Article = certificateRequest.Article,
Case = certificateRequest.Case,
Image = certificateRequest.Image,
Audio = certificateRequest.Audio,
Elearning = certificateRequest.Elearning,
Html = certificateRequest.Html,
Assessment = certificateRequest.Assessment,
Courses = certificateRequest.Courses,
};

switch (certificateRequest.MyLearningFormActionType)
{
case MyLearningFormActionTypeEnum.NextPageChange:
certificateRequest.CurrentPageIndex += 1;
myLearningRequestModel.Skip = certificateRequest.CurrentPageIndex * MyLearningPageSize;
break;

case MyLearningFormActionTypeEnum.PreviousPageChange:
certificateRequest.CurrentPageIndex -= 1;
myLearningRequestModel.Skip = certificateRequest.CurrentPageIndex * MyLearningPageSize;
break;
case MyLearningFormActionTypeEnum.BasicSearch:

myLearningRequestModel = new MyLearningRequestModel
{
SearchText = certificateRequest.SearchText?.Trim(),
Skip = certificateRequest.CurrentPageIndex * MyLearningPageSize,
Take = MyLearningPageSize,
};
break;
case MyLearningFormActionTypeEnum.ClearAllFilters:

myLearningRequestModel = new MyLearningRequestModel
{
SearchText = certificateRequest.SearchText?.Trim(),
Skip = certificateRequest.CurrentPageIndex * MyLearningPageSize,
Take = MyLearningPageSize,
};
break;
}

var result = await this.myLearningService.GetUserCertificateDetails(myLearningRequestModel);
var response = new MyLearningUserCertificatesViewModel(myLearningRequestModel);

if (result != null)
{
response.TotalCount = result.TotalCount;
response.UserCertificates = result.Certificates;
}

response.MyLearningPaging = new MyLearningPagingModel() { CurrentPage = certificateRequest.CurrentPageIndex, PageSize = MyLearningPageSize, TotalItems = response.TotalCount, HasItems = response.TotalCount > 0 };
return this.View(response);
}

/// <summary>
/// Gets the certificate details of an activity.
/// </summary>
Expand Down Expand Up @@ -784,6 +855,7 @@ public async Task<IActionResult> GetCertificateDetails(int resourceReferenceId,
/// <param name="minorVersion">The minorVersion.</param>
/// <param name="userId">The userId.</param>
/// <returns>The <see cref="IActionResult"/>.</returns>
[HttpGet]
[HttpPost]
[Route("mylearning/downloadcertificate")]
public async Task<IActionResult> DownloadCertificate(int resourceReferenceId, int? majorVersion = 0, int? minorVersion = 0, int? userId = 0)
Expand Down
1 change: 1 addition & 0 deletions LearningHub.Nhs.WebUI/Helpers/ViewActivityHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ public static Dictionary<string, string> GetActivityParameters(object model)
var routeData = model.GetType().GetProperties().ToDictionary(p => p.Name, p => p.GetValue(model)?.ToString());
routeData.Remove("MostRecentResources");
routeData.Remove("Activities");
routeData.Remove("UserCertificates");
routeData.Remove("TotalCount");
routeData.Remove("MyLearningPaging");
routeData.Remove("Skip");
Expand Down
7 changes: 7 additions & 0 deletions LearningHub.Nhs.WebUI/Interfaces/IMyLearningService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ public interface IMyLearningService
/// <returns>The <see cref="Task"/>.</returns>
Task<Tuple<int, MyLearningDetailedItemViewModel>> GetResourceCertificateDetails(int resourceReferenceId, int? majorVersion = 0, int? minorVersion = 0, int? userId = 0);

/// <summary>
/// Gets the user certificates.
/// </summary>
/// <param name="requestModel">The request model.</param>
/// <returns>The <see cref="Task"/>.</returns>
Task<MyLearningCertificatesDetailedViewModel> GetUserCertificateDetails(MyLearningRequestModel requestModel);

/// <summary>
/// Gets the resource URL for a given resource reference ID.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
namespace LearningHub.Nhs.WebUI.Models
{
using System.Collections.Generic;
using System.Reflection;
using LearningHub.Nhs.Models.MyLearning;
using LearningHub.Nhs.Models.Paging;
using LearningHub.Nhs.WebUI.Models.Learning;
using NHSUKViewComponents.Web.ViewModels;

/// <summary>
/// Defines the <see cref="MyLearningUserCertificatesViewModel" />.
/// </summary>
public class MyLearningUserCertificatesViewModel : MyLearningRequestModel
{
/// <summary>
/// Initializes a new instance of the <see cref="MyLearningUserCertificatesViewModel"/> class.
/// </summary>
public MyLearningUserCertificatesViewModel()
{
this.UserCertificates = new List<UserCertificateViewModel>();
}

/// <summary>
/// Initializes a new instance of the <see cref="MyLearningUserCertificatesViewModel"/> class.
/// </summary>
/// <param name="requestModel">MyLearningRequestModel.</param>
public MyLearningUserCertificatesViewModel(MyLearningRequestModel requestModel)
{
this.UserCertificates = new List<UserCertificateViewModel>();
foreach (PropertyInfo prop in requestModel.GetType().GetProperties())
{
this.GetType().GetProperty(prop.Name).SetValue(this, prop.GetValue(requestModel, null), null);
}
}

/// <summary>
/// Gets or sets the learning form event.
/// </summary>
public MyLearningFormActionTypeEnum MyLearningFormActionType { get; set; }

/// <summary>
/// Gets or sets the page item index.
/// </summary>
public int CurrentPageIndex { get; set; } = 0;

/// <summary>
/// Gets or sets the TotalCount.
/// </summary>
public int TotalCount { get; set; }

/// <summary>
/// Gets or sets the Activities.
/// </summary>
public List<UserCertificateViewModel> UserCertificates { get; set; }

/// <summary>
/// Gets or sets the learning result paging.
/// </summary>
public PagingViewModel MyLearningPaging { get; set; }

/// <summary>
/// sets the list of type checkboxes.
/// </summary>
/// <returns>The <see cref="List{CheckboxListItemViewModel}"/>.</returns>
public List<CheckboxListItemViewModel> TypeFilterCheckbox()
{
var checkboxes = new List<CheckboxListItemViewModel>()
{
new CheckboxListItemViewModel("Article", "Article", null),
new CheckboxListItemViewModel("Assessment", "Assessment", null),
new CheckboxListItemViewModel("Audio", "Audio", null),
new CheckboxListItemViewModel("Case", "Case", null),
new CheckboxListItemViewModel("Elearning", "elearning", null),
new CheckboxListItemViewModel("File", "File", null),
new CheckboxListItemViewModel("Html", "HTML", null),
new CheckboxListItemViewModel("Image", "Image", null),
new CheckboxListItemViewModel("Video", "Video", null),
new CheckboxListItemViewModel("Weblink", "Weblink", null),
new CheckboxListItemViewModel("Courses", "Courses", null),
};
return checkboxes;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static IEnumerable<SideNavigationGroup> GetGroupedMenus()
Text = "Certificates",
Controller = "MyLearning",
Action = "Certificates",
IsActive = route => MatchRoute(route, "Activity", "Certificates"),
IsActive = route => MatchRoute(route, "MyLearning", "Certificates"),
},
new SideNavigationItem
{
Expand Down
33 changes: 32 additions & 1 deletion LearningHub.Nhs.WebUI/Services/MyLearningService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using elfhHub.Nhs.Models.Common;
using LearningHub.Nhs.Models.MyLearning;
using LearningHub.Nhs.WebUI.Configuration;
using LearningHub.Nhs.WebUI.Interfaces;
Expand Down Expand Up @@ -189,6 +188,38 @@ public async Task<Tuple<int, MyLearningDetailedItemViewModel>> GetResourceCertif
return viewModel;
}

/// <summary>
/// Gets the user certificates.
/// </summary>
/// <param name="requestModel">The request model.</param>
/// <returns>The <see cref="Task"/>.</returns>
public async Task<MyLearningCertificatesDetailedViewModel> GetUserCertificateDetails(MyLearningRequestModel requestModel)
{
MyLearningCertificatesDetailedViewModel viewModel = null;

var json = JsonConvert.SerializeObject(requestModel);
var stringContent = new StringContent(json, Encoding.UTF8, "application/json");

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

var request = $"MyLearning/GetUserCertificateDetails";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);

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

return viewModel;
}

/// <summary>
/// GetCourseUrl.
/// </summary>
Expand Down
9 changes: 9 additions & 0 deletions LearningHub.Nhs.WebUI/Styles/nhsuk/pages/mylearning.scss
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,15 @@
}
}

.nhsuk-card--radius-6 {
border-radius: 6px;
overflow: hidden;
}

.nhsuk-card__heading.nhsuk-heading-m.nhsuk-font-weight-regular {
font-weight: 400 !important;
}

label {
font-family: $font-stack;
}
Expand Down
Loading
Loading