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
45 changes: 45 additions & 0 deletions LearningHub.Nhs.WebUI/Controllers/MyLearningController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ public async Task<IActionResult> LearningHistory(MyLearningUserActivitiesViewMod
Viewed = learningRequest.Viewed,
Launched = learningRequest.Launched,
CertificateEnabled = learningRequest.CertificateEnabled,
Courses = learningRequest.Courses,
};

if (myLearningDashboard != null)
Expand Down Expand Up @@ -627,6 +628,50 @@ public async Task<IActionResult> ExportToPDF(MyLearningRequestModel myLearningRe
return this.View(new Tuple<UserBasicViewModel, MyLearningViewModel>(userDetails, response));
}

/// <summary>
/// Function to export activity report to pdf.
/// </summary>
/// <param name="myLearningRequestModel">myLearningRequestModel.</param>
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
[Route("/MyLearning/DownloadActivities")]
[HttpPost]
public async Task<IActionResult> DownloadActivities(MyLearningRequestModel myLearningRequestModel)
{
var filter = myLearningRequestModel;
filter.Skip = 0;
filter.Take = 999;
var userDetails = await this.userService.GetCurrentUserBasicDetailsAsync();
var response = new MyLearningUserActivitiesViewModel();
var result = await this.myLearningService.GetUserLearningHistory(filter);
if (result != null)
{
response.TotalCount = result.TotalCount;
response.Activities = result.Activities;
}

Tuple<UserBasicViewModel, MyLearningUserActivitiesViewModel> modelData = Tuple.Create(userDetails, response);
var renderedViewHTML = RenderRazorViewToString(this, "DownloadActivityRecords", modelData);
ReportStatusModel reportStatusModel = new ReportStatusModel();
var pdfReportResponse = await this.pdfReportService.PdfReport(renderedViewHTML, userDetails.Id);
if (pdfReportResponse != null)
{
do
{
reportStatusModel = await this.pdfReportService.PdfReportStatus(pdfReportResponse);
}
while (reportStatusModel.Id == 1);

var pdfReportFile = await this.pdfReportService.GetPdfReportFile(pdfReportResponse);
if (pdfReportFile != null)
{
var fileName = "ActivityReport.pdf";
return this.File(pdfReportFile, FileHelper.GetContentTypeFromFileName(fileName), fileName);
}
}

return this.View(new Tuple<UserBasicViewModel, MyLearningUserActivitiesViewModel>(userDetails, response));
}

/// <summary>
/// Gets the played segment data for the progress modal in My Learning screen.
/// </summary>
Expand Down
495 changes: 0 additions & 495 deletions LearningHub.Nhs.WebUI/Controllers/MyRecentLearningController.cs

This file was deleted.

7 changes: 7 additions & 0 deletions LearningHub.Nhs.WebUI/Interfaces/IMyLearningService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,12 @@ public interface IMyLearningService
/// <param name="userId">The userId.</param>
/// <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 resource URL for a given resource reference ID.
/// </summary>
/// <param name="resourceReferenceId">resourceReferenceId.</param>
/// <returns>The <see cref="Task"/>.</returns>
string GetResourceUrl(int resourceReferenceId);
}
}
50 changes: 50 additions & 0 deletions LearningHub.Nhs.WebUI/Models/MyLearningUserActivitiesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,55 @@ public MyLearningUserActivitiesViewModel(MyLearningRequestModel requestModel)
/// Gets or sets the learning result paging.
/// </summary>
public PagingViewModel MyLearningPaging { get; set; }

/// <summary>
/// sets the list of certificate checkboxes.
/// </summary>
/// <returns>The <see cref="List{CheckboxListItemViewModel}"/>.</returns>
public List<CheckboxListItemViewModel> CertificateFilterCheckbox()
{
var checkboxes = new List<CheckboxListItemViewModel>()
{
new CheckboxListItemViewModel("CertificateEnabled", "Certificate", null),
};
return checkboxes;
}

/// <summary>
/// sets the list of status checkboxes.
/// </summary>
/// <returns>The <see cref="List{CheckboxListItemViewModel}"/>.</returns>
public List<CheckboxListItemViewModel> StatusFilterCheckbox()
{
var checkboxes = new List<CheckboxListItemViewModel>()
{
new CheckboxListItemViewModel("Complete", "Completed", null),
new CheckboxListItemViewModel("Incomplete", "In progress", null),
};
return checkboxes;
}

/// <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;
}
}
}
18 changes: 17 additions & 1 deletion LearningHub.Nhs.WebUI/Services/MyLearningService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,30 @@
using System.Threading.Tasks;
using elfhHub.Nhs.Models.Common;
using LearningHub.Nhs.Models.MyLearning;
using LearningHub.Nhs.WebUI.Configuration;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;

/// <summary>
/// The MyLearningService.
/// </summary>
public class MyLearningService : BaseService<MyLearningService>, IMyLearningService
{
private readonly Settings settings;

/// <summary>
/// Initializes a new instance of the <see cref="MyLearningService"/> class.
/// </summary>
/// <param name="learningHubHttpClient">The learningHubHttpClient.</param>
/// <param name="openApiHttpClient">The Open Api Http Client.</param>
/// <param name="logger">The logger.</param>
public MyLearningService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, ILogger<MyLearningService> logger)
/// <param name="settings">The settings.</param>
public MyLearningService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, ILogger<MyLearningService> logger, IOptions<Settings> settings)
: base(learningHubHttpClient, openApiHttpClient, logger)
{
this.settings = settings.Value;
}

/// <summary>
Expand Down Expand Up @@ -182,5 +188,15 @@ public async Task<Tuple<int, MyLearningDetailedItemViewModel>> GetResourceCertif

return viewModel;
}

/// <summary>
/// GetCourseUrl.
/// </summary>
/// <param name="resourceReferenceId">resourceReference Id. </param>
/// <returns>return course URL.</returns>
public string GetResourceUrl(int resourceReferenceId)
{
return this.settings.LearningHubWebUiUrl.Trim() + "Resource/" + resourceReferenceId + "/Item";
}
}
}
Loading
Loading