Skip to content

Commit b40a0b6

Browse files
Merge pull request #1340 from TechnologyEnhancedLearning/Develop/Feature-Revised-My-Learning-implementation
TD-5711: My Learning page redesign
2 parents e2f2749 + 85c1a42 commit b40a0b6

File tree

19 files changed

+1972
-729
lines changed

19 files changed

+1972
-729
lines changed

LearningHub.Nhs.WebUI/Controllers/MyLearningController.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ public async Task<IActionResult> LearningHistory(MyLearningUserActivitiesViewMod
458458
Viewed = learningRequest.Viewed,
459459
Launched = learningRequest.Launched,
460460
CertificateEnabled = learningRequest.CertificateEnabled,
461+
Courses = learningRequest.Courses,
461462
};
462463

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

631+
/// <summary>
632+
/// Function to export activity report to pdf.
633+
/// </summary>
634+
/// <param name="myLearningRequestModel">myLearningRequestModel.</param>
635+
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
636+
[Route("/MyLearning/DownloadActivities")]
637+
[HttpPost]
638+
public async Task<IActionResult> DownloadActivities(MyLearningRequestModel myLearningRequestModel)
639+
{
640+
var filter = myLearningRequestModel;
641+
filter.Skip = 0;
642+
filter.Take = 999;
643+
var userDetails = await this.userService.GetCurrentUserBasicDetailsAsync();
644+
var response = new MyLearningUserActivitiesViewModel();
645+
var result = await this.myLearningService.GetUserLearningHistory(filter);
646+
if (result != null)
647+
{
648+
response.TotalCount = result.TotalCount;
649+
response.Activities = result.Activities;
650+
}
651+
652+
Tuple<UserBasicViewModel, MyLearningUserActivitiesViewModel> modelData = Tuple.Create(userDetails, response);
653+
var renderedViewHTML = RenderRazorViewToString(this, "DownloadActivityRecords", modelData);
654+
ReportStatusModel reportStatusModel = new ReportStatusModel();
655+
var pdfReportResponse = await this.pdfReportService.PdfReport(renderedViewHTML, userDetails.Id);
656+
if (pdfReportResponse != null)
657+
{
658+
do
659+
{
660+
reportStatusModel = await this.pdfReportService.PdfReportStatus(pdfReportResponse);
661+
}
662+
while (reportStatusModel.Id == 1);
663+
664+
var pdfReportFile = await this.pdfReportService.GetPdfReportFile(pdfReportResponse);
665+
if (pdfReportFile != null)
666+
{
667+
var fileName = "ActivityReport.pdf";
668+
return this.File(pdfReportFile, FileHelper.GetContentTypeFromFileName(fileName), fileName);
669+
}
670+
}
671+
672+
return this.View(new Tuple<UserBasicViewModel, MyLearningUserActivitiesViewModel>(userDetails, response));
673+
}
674+
630675
/// <summary>
631676
/// Gets the played segment data for the progress modal in My Learning screen.
632677
/// </summary>

LearningHub.Nhs.WebUI/Controllers/MyRecentLearningController.cs

Lines changed: 0 additions & 495 deletions
This file was deleted.

LearningHub.Nhs.WebUI/Interfaces/IMyLearningService.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,12 @@ public interface IMyLearningService
4848
/// <param name="userId">The userId.</param>
4949
/// <returns>The <see cref="Task"/>.</returns>
5050
Task<Tuple<int, MyLearningDetailedItemViewModel>> GetResourceCertificateDetails(int resourceReferenceId, int? majorVersion = 0, int? minorVersion = 0, int? userId = 0);
51+
52+
/// <summary>
53+
/// Gets the resource URL for a given resource reference ID.
54+
/// </summary>
55+
/// <param name="resourceReferenceId">resourceReferenceId.</param>
56+
/// <returns>The <see cref="Task"/>.</returns>
57+
string GetResourceUrl(int resourceReferenceId);
5158
}
5259
}

LearningHub.Nhs.WebUI/Models/MyLearningUserActivitiesViewModel.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,55 @@ public MyLearningUserActivitiesViewModel(MyLearningRequestModel requestModel)
6868
/// Gets or sets the learning result paging.
6969
/// </summary>
7070
public PagingViewModel MyLearningPaging { get; set; }
71+
72+
/// <summary>
73+
/// sets the list of certificate checkboxes.
74+
/// </summary>
75+
/// <returns>The <see cref="List{CheckboxListItemViewModel}"/>.</returns>
76+
public List<CheckboxListItemViewModel> CertificateFilterCheckbox()
77+
{
78+
var checkboxes = new List<CheckboxListItemViewModel>()
79+
{
80+
new CheckboxListItemViewModel("CertificateEnabled", "Certificate", null),
81+
};
82+
return checkboxes;
83+
}
84+
85+
/// <summary>
86+
/// sets the list of status checkboxes.
87+
/// </summary>
88+
/// <returns>The <see cref="List{CheckboxListItemViewModel}"/>.</returns>
89+
public List<CheckboxListItemViewModel> StatusFilterCheckbox()
90+
{
91+
var checkboxes = new List<CheckboxListItemViewModel>()
92+
{
93+
new CheckboxListItemViewModel("Complete", "Completed", null),
94+
new CheckboxListItemViewModel("Incomplete", "In progress", null),
95+
};
96+
return checkboxes;
97+
}
98+
99+
/// <summary>
100+
/// sets the list of type checkboxes.
101+
/// </summary>
102+
/// <returns>The <see cref="List{CheckboxListItemViewModel}"/>.</returns>
103+
public List<CheckboxListItemViewModel> TypeFilterCheckbox()
104+
{
105+
var checkboxes = new List<CheckboxListItemViewModel>()
106+
{
107+
new CheckboxListItemViewModel("Article", "Article", null),
108+
new CheckboxListItemViewModel("Assessment", "Assessment", null),
109+
new CheckboxListItemViewModel("Audio", "Audio", null),
110+
new CheckboxListItemViewModel("Case", "Case", null),
111+
new CheckboxListItemViewModel("Elearning", "elearning", null),
112+
new CheckboxListItemViewModel("File", "File", null),
113+
new CheckboxListItemViewModel("Html", "HTML", null),
114+
new CheckboxListItemViewModel("Image", "Image", null),
115+
new CheckboxListItemViewModel("Video", "Video", null),
116+
new CheckboxListItemViewModel("Weblink", "Weblink", null),
117+
new CheckboxListItemViewModel("Courses", "Courses", null),
118+
};
119+
return checkboxes;
120+
}
71121
}
72122
}

LearningHub.Nhs.WebUI/Services/MyLearningService.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,30 @@
77
using System.Threading.Tasks;
88
using elfhHub.Nhs.Models.Common;
99
using LearningHub.Nhs.Models.MyLearning;
10+
using LearningHub.Nhs.WebUI.Configuration;
1011
using LearningHub.Nhs.WebUI.Interfaces;
1112
using Microsoft.Extensions.Logging;
13+
using Microsoft.Extensions.Options;
1214
using Newtonsoft.Json;
1315

1416
/// <summary>
1517
/// The MyLearningService.
1618
/// </summary>
1719
public class MyLearningService : BaseService<MyLearningService>, IMyLearningService
1820
{
21+
private readonly Settings settings;
22+
1923
/// <summary>
2024
/// Initializes a new instance of the <see cref="MyLearningService"/> class.
2125
/// </summary>
2226
/// <param name="learningHubHttpClient">The learningHubHttpClient.</param>
2327
/// <param name="openApiHttpClient">The Open Api Http Client.</param>
2428
/// <param name="logger">The logger.</param>
25-
public MyLearningService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, ILogger<MyLearningService> logger)
29+
/// <param name="settings">The settings.</param>
30+
public MyLearningService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, ILogger<MyLearningService> logger, IOptions<Settings> settings)
2631
: base(learningHubHttpClient, openApiHttpClient, logger)
2732
{
33+
this.settings = settings.Value;
2834
}
2935

3036
/// <summary>
@@ -182,5 +188,15 @@ public async Task<Tuple<int, MyLearningDetailedItemViewModel>> GetResourceCertif
182188

183189
return viewModel;
184190
}
191+
192+
/// <summary>
193+
/// GetCourseUrl.
194+
/// </summary>
195+
/// <param name="resourceReferenceId">resourceReference Id. </param>
196+
/// <returns>return course URL.</returns>
197+
public string GetResourceUrl(int resourceReferenceId)
198+
{
199+
return this.settings.LearningHubWebUiUrl.Trim() + "Resource/" + resourceReferenceId + "/Item";
200+
}
185201
}
186202
}

0 commit comments

Comments
 (0)