diff --git a/DigitalLearningSolutions.Data.Migrations/Properties/Resources.Designer.cs b/DigitalLearningSolutions.Data.Migrations/Properties/Resources.Designer.cs index ea25a89b61..e121dbad25 100644 --- a/DigitalLearningSolutions.Data.Migrations/Properties/Resources.Designer.cs +++ b/DigitalLearningSolutions.Data.Migrations/Properties/Resources.Designer.cs @@ -2237,6 +2237,46 @@ internal static string TD_4634_Alter_GetCompletedCoursesForCandidate_UP { } } + /// + /// Looks up a localized string similar to /****** Object: StoredProcedure [dbo].[GetActivitiesForDelegateEnrolment] Script Date: 22/10/2024 16:55:08 ******/ + ///SET ANSI_NULLS ON + ///GO + /// + ///SET QUOTED_IDENTIFIER ON + ///GO + /// + ///-- ============================================= + ///-- Author: Kevin Whittaker + ///-- Create date: 24/01/2023 + ///-- Description: Returns active available for delegate enrolment based on original GetActiveAvailableCustomisationsForCentreFiltered_V6 sproc but adjusted for user account refactor and filters properly for category. + ///-- ========= [rest of string was truncated]";. + /// + internal static string TD_4878_Alter_GetActivitiesForDelegateEnrolment_Down { + get { + return ResourceManager.GetString("TD_4878_Alter_GetActivitiesForDelegateEnrolment_Down", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to /****** Object: StoredProcedure [dbo].[GetActivitiesForDelegateEnrolment] Script Date: 22/10/2024 16:55:08 ******/ + ///SET ANSI_NULLS ON + ///GO + /// + ///SET QUOTED_IDENTIFIER ON + ///GO + /// + ///-- ============================================= + ///-- Author: Kevin Whittaker + ///-- Create date: 24/01/2023 + ///-- Description: Returns active available for delegate enrolment based on original GetActiveAvailableCustomisationsForCentreFiltered_V6 sproc but adjusted for user account refactor and filters properly for category. + ///-- ========= [rest of string was truncated]";. + /// + internal static string TD_4878_Alter_GetActivitiesForDelegateEnrolment_Up { + get { + return ResourceManager.GetString("TD_4878_Alter_GetActivitiesForDelegateEnrolment_Up", resourceCulture); + } + } + /// /// Looks up a localized string similar to /****** Object: StoredProcedure [dbo].[GetAssessmentResultsByDelegate] Script Date: 07/11/2024 21:36:58 ******/ ///SET ANSI_NULLS ON diff --git a/DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs b/DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs index 06edcc938a..7539d73753 100644 --- a/DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs +++ b/DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs @@ -299,7 +299,7 @@ FROM CourseTopics private const string FrameworkTables = @"Frameworks AS FW LEFT OUTER JOIN - FrameworkCollaborators AS fwc ON fwc.FrameworkID = FW.ID AND fwc.AdminID = @adminId + FrameworkCollaborators AS fwc ON fwc.FrameworkID = FW.ID AND fwc.AdminID = @adminId AND COALESCE(IsDeleted, 0) = 0 LEFT OUTER JOIN FrameworkReviews AS fwr ON fwc.ID = fwr.FrameworkCollaboratorID AND fwr.Archived IS NULL AND fwr.ReviewComplete IS NULL"; private const string AssessmentQuestionFields = diff --git a/DigitalLearningSolutions.Web.Tests/Controllers/SupervisorController/SupervisorControllerTests.cs b/DigitalLearningSolutions.Web.Tests/Controllers/SupervisorController/SupervisorControllerTests.cs index 160ef190bf..eed0610ec0 100644 --- a/DigitalLearningSolutions.Web.Tests/Controllers/SupervisorController/SupervisorControllerTests.cs +++ b/DigitalLearningSolutions.Web.Tests/Controllers/SupervisorController/SupervisorControllerTests.cs @@ -48,6 +48,7 @@ public class SupervisorControllerTests private ICandidateAssessmentDownloadFileService candidateAssessmentDownloadFileService = null!; private IPdfService pdfService = null!; private SupervisorController controller = null!; + private ICourseCategoriesService courseCategoriesService = null!; [SetUp] public void Setup() @@ -71,6 +72,8 @@ public void Setup() clockUtility = A.Fake(); candidateAssessmentDownloadFileService = A.Fake(); pdfService = A.Fake(); + courseCategoriesService = A.Fake(); + A.CallTo(() => candidateAssessmentDownloadFileService.GetCandidateAssessmentDownloadFileForCentre(A._, A._, A._)) .Returns(new byte[] { }); @@ -137,7 +140,8 @@ public void ExportCandidateAssessment_should_return_file_object_with_file_name_i emailService, candidateAssessmentDownloadFileService, clockUtility, - pdfService + pdfService, + courseCategoriesService ); string expectedFileName = $"{((selfAssessmentName.Length > 30) ? selfAssessmentName.Substring(0, 30) : selfAssessmentName)} - {delegateName} - {clockUtility.UtcNow:yyyy-MM-dd}.xlsx"; diff --git a/DigitalLearningSolutions.Web/Controllers/SupervisorController/Supervisor.cs b/DigitalLearningSolutions.Web/Controllers/SupervisorController/Supervisor.cs index 81365a950b..98729aa8e3 100644 --- a/DigitalLearningSolutions.Web/Controllers/SupervisorController/Supervisor.cs +++ b/DigitalLearningSolutions.Web/Controllers/SupervisorController/Supervisor.cs @@ -59,7 +59,7 @@ public IActionResult MyStaffList( var supervisorEmail = GetUserEmail(); var loggedInAdminUser = userService.GetAdminUserById(adminId); var centreRegistrationPrompts = centreRegistrationPromptsService.GetCentreRegistrationPromptsByCentreId(centreId); - var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId); + var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId, loggedInAdminUser.CategoryId); var isSupervisor = User.GetCustomClaimAsBool(CustomClaimTypes.IsSupervisor) ?? false; var allSupervisorDelegateDetailViewModels = supervisorDelegateDetails.Select( supervisor => @@ -335,10 +335,11 @@ public IActionResult DelegateProfileAssessments(int supervisorDelegateId, int de public IActionResult AllStaffList() { var adminId = GetAdminId(); + var loggedInAdminUser = userService.GetAdminUserById(adminId); var centreId = GetCentreId(); var loggedInUserId = User.GetUserId(); var centreCustomPrompts = centreRegistrationPromptsService.GetCentreRegistrationPromptsByCentreId(centreId); - var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId) + var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId, loggedInAdminUser.CategoryId) .Select(supervisor => { return supervisor; @@ -1386,14 +1387,15 @@ public IActionResult ExportCandidateAssessment(int candidateAssessmentId, string [Route("/Supervisor/Staff/{supervisorDelegateId:int}/ProfileAssessment/{candidateAssessmentId:int}/Certificate")] public IActionResult CompetencySelfAssessmentCertificatesupervisor(int candidateAssessmentId, int supervisorDelegateId) { - var adminId = User.GetAdminId(); + var adminId = GetAdminId(); + var loggedInAdminUser = userService.GetAdminUserById(adminId); User.GetUserIdKnownNotNull(); var competencymaindata = selfAssessmentService.GetCompetencySelfAssessmentCertificate(candidateAssessmentId); if ((competencymaindata == null) || (candidateAssessmentId == 0)) { return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 }); } - var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value); + var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId, loggedInAdminUser.CategoryId); var checkSupervisorDelegate = supervisorDelegateDetails.Where(x => x.DelegateUserID == competencymaindata.LearnerId).FirstOrDefault(); if ((checkSupervisorDelegate == null)) { @@ -1423,13 +1425,14 @@ public async Task DownloadCertificate(int candidateAssessmentId) { PdfReportStatusResponse pdfReportStatusResponse = new PdfReportStatusResponse(); var delegateId = User.GetCandidateIdKnownNotNull(); - var adminId = User.GetAdminId(); + var adminId = GetAdminId(); + var loggedInAdminUser = userService.GetAdminUserById(adminId); var competencymaindata = selfAssessmentService.GetCompetencySelfAssessmentCertificate(candidateAssessmentId); if (competencymaindata == null || candidateAssessmentId == 0 || adminId == 0) { return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 }); } - var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value); + var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId, loggedInAdminUser.CategoryId); var checkSupervisorDelegate = supervisorDelegateDetails.Where(x => x.DelegateUserID == competencymaindata.LearnerId).FirstOrDefault(); if (checkSupervisorDelegate == null) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 }); var delegateUserId = competencymaindata.LearnerId; diff --git a/DigitalLearningSolutions.Web/Controllers/TrackingSystem/CourseSetup/CourseSetupController.cs b/DigitalLearningSolutions.Web/Controllers/TrackingSystem/CourseSetup/CourseSetupController.cs index 5eb4f688d5..59597441e5 100644 --- a/DigitalLearningSolutions.Web/Controllers/TrackingSystem/CourseSetup/CourseSetupController.cs +++ b/DigitalLearningSolutions.Web/Controllers/TrackingSystem/CourseSetup/CourseSetupController.cs @@ -429,7 +429,10 @@ public IActionResult SetCourseContent(SetCourseContentViewModel model) } else { - data!.SectionContentData = null; + if (data!.SectionContentData == null) + { + data!.SectionContentData = null; + } } if (!ModelState.IsValid) @@ -471,9 +474,18 @@ public IActionResult SetSectionContent(int sectionIndex) } var showDiagnostic = data.Application!.DiagAssess; - var model = new SetSectionContentViewModel(section, sectionIndex, showDiagnostic, tutorials); + if (data.SectionContentData != null && data.SectionContentData.Count >=3 ) + { + var tutorial = GetTutorialsFromSectionContentData(data.SectionContentData, tutorials); + var model = new SetSectionContentViewModel(section, sectionIndex, showDiagnostic, tutorial); + return View("AddNewCentreCourse/SetSectionContent", model); + } + else + { + var model = new SetSectionContentViewModel(section, sectionIndex, showDiagnostic, tutorials); + return View("AddNewCentreCourse/SetSectionContent", model); + } - return View("AddNewCentreCourse/SetSectionContent", model); } [HttpPost("AddCourse/SetSectionContent")] @@ -654,8 +666,14 @@ private IActionResult SaveSectionAndRedirect(SetSectionContentViewModel model) { data.SectionContentData = new List(); } - - data!.SectionContentData!.Add( + if (data.SectionContentData != null && data.SectionContentData.Count >= 3) + { + return RedirectToNextSectionOrSummary( + model.Index, + new SetCourseContentViewModel(data.CourseContentData!) + ); + } + data!.SectionContentData!.Add( new SectionContentTempData( model.Tutorials != null ? model.Tutorials.Select(GetCourseTutorialData) @@ -727,6 +745,25 @@ private static IEnumerable UpdateC return updatedCourses; } + private IEnumerable GetTutorialsFromSectionContentData(List sectionContentData, List sectionTutorial) + { + if (sectionContentData == null || sectionTutorial == null) return new List(); + var updatedRecords = sectionContentData + .SelectMany(data => data.Tutorials) + .Join(sectionTutorial, + tempData => new { tempData.TutorialId, tempData.TutorialName }, // Match on both TutorialId and TutorialName + index => new { index.TutorialId, index.TutorialName }, + (tempData, index) => new Tutorial + { + TutorialId = index.TutorialId, + TutorialName = index.TutorialName, + Status = tempData.LearningEnabled, // Updated from sectionContentData + DiagStatus = tempData.DiagnosticEnabled // Updated from sectionContentData + }) + .ToList(); + + return updatedRecords; + } } } diff --git a/DigitalLearningSolutions.Web/Views/LearningPortal/Shared/_Dates.cshtml b/DigitalLearningSolutions.Web/Views/LearningPortal/Shared/_Dates.cshtml index 935177900a..d99eb8994a 100644 --- a/DigitalLearningSolutions.Web/Views/LearningPortal/Shared/_Dates.cshtml +++ b/DigitalLearningSolutions.Web/Views/LearningPortal/Shared/_Dates.cshtml @@ -6,7 +6,7 @@
- Enrolled + First enrolled
@Model.StartedDate.ToShortDateString() diff --git a/DigitalLearningSolutions.Web/Views/SuperAdmin/Users/UserCentreAccounts.cshtml b/DigitalLearningSolutions.Web/Views/SuperAdmin/Users/UserCentreAccounts.cshtml index 7cd9d4950b..6781c6bf1c 100644 --- a/DigitalLearningSolutions.Web/Views/SuperAdmin/Users/UserCentreAccounts.cshtml +++ b/DigitalLearningSolutions.Web/Views/SuperAdmin/Users/UserCentreAccounts.cshtml @@ -52,11 +52,11 @@ Roles:
- @if (centreRow.IsActiveAdmin) + @if (Model.UserEntity.AdminAccounts.Any()) { foreach (var admin in Model.UserEntity.AdminAccounts) { - if (centreRow.CentreId==admin.CentreId) + if (centreRow.CentreId == admin.CentreId) { Admin } diff --git a/DigitalLearningSolutions.Web/Views/TrackingSystem/Delegates/Shared/_DelegateCourseProgressDetailsWithStatusTags.cshtml b/DigitalLearningSolutions.Web/Views/TrackingSystem/Delegates/Shared/_DelegateCourseProgressDetailsWithStatusTags.cshtml index 8faa2883b9..d11de651f1 100644 --- a/DigitalLearningSolutions.Web/Views/TrackingSystem/Delegates/Shared/_DelegateCourseProgressDetailsWithStatusTags.cshtml +++ b/DigitalLearningSolutions.Web/Views/TrackingSystem/Delegates/Shared/_DelegateCourseProgressDetailsWithStatusTags.cshtml @@ -36,7 +36,7 @@
- Enrolled + First enrolled
@Model.Enrolled diff --git a/DigitalLearningSolutions.Web/Views/TrackingSystem/Delegates/Shared/_DelegateSelfAssessmentProgressDetails.cshtml b/DigitalLearningSolutions.Web/Views/TrackingSystem/Delegates/Shared/_DelegateSelfAssessmentProgressDetails.cshtml index 81b836ab24..2b5caa35c2 100644 --- a/DigitalLearningSolutions.Web/Views/TrackingSystem/Delegates/Shared/_DelegateSelfAssessmentProgressDetails.cshtml +++ b/DigitalLearningSolutions.Web/Views/TrackingSystem/Delegates/Shared/_DelegateSelfAssessmentProgressDetails.cshtml @@ -5,7 +5,7 @@
- Enrolled + First enrolled
@Model.StartedDate.ToString(DateHelper.StandardDateAndTimeFormat)