Skip to content
Closed
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -71,6 +72,8 @@ public void Setup()
clockUtility = A.Fake<IClockUtility>();
candidateAssessmentDownloadFileService = A.Fake<ICandidateAssessmentDownloadFileService>();
pdfService = A.Fake<IPdfService>();
courseCategoriesService = A.Fake<ICourseCategoriesService>();

A.CallTo(() => candidateAssessmentDownloadFileService.GetCandidateAssessmentDownloadFileForCentre(A<int>._, A<int>._, A<bool>._))
.Returns(new byte[] { });

Expand Down Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -1423,13 +1425,14 @@ public async Task<IActionResult> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,10 @@ public IActionResult SetCourseContent(SetCourseContentViewModel model)
}
else
{
data!.SectionContentData = null;
if (data!.SectionContentData == null)
{
data!.SectionContentData = null;
}
}

if (!ModelState.IsValid)
Expand Down Expand Up @@ -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")]
Expand Down Expand Up @@ -654,8 +666,14 @@ private IActionResult SaveSectionAndRedirect(SetSectionContentViewModel model)
{
data.SectionContentData = new List<SectionContentTempData>();
}

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)
Expand Down Expand Up @@ -727,6 +745,25 @@ private static IEnumerable<CourseStatisticsWithAdminFieldResponseCounts> UpdateC

return updatedCourses;
}
private IEnumerable<Tutorial> GetTutorialsFromSectionContentData(List<SectionContentTempData> sectionContentData, List<Tutorial> sectionTutorial)
{
if (sectionContentData == null || sectionTutorial == null) return new List<Tutorial>();
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;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<div class="nhsuk-summary-list__row">
<dt class="nhsuk-summary-list__key">
Enrolled
First enrolled
</dt>
<dd class="nhsuk-summary-list__value" data-name-for-sorting="started-date">
@Model.StartedDate.ToShortDateString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
<td role="cell" class="nhsuk-table__cell choose-centre-td">
<span class="nhsuk-table-responsive__heading">Roles: </span>
<div class="centre-role-tags">
@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)
{
<a asp-action="RedirectToAdmin" asp-route-AdminId="@admin.Id">Admin</a>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</div>
<div class="nhsuk-summary-list__row details-list-with-button__row">
<dt class="nhsuk-summary-list__key">
Enrolled
First enrolled
</dt>
<dd class="nhsuk-summary-list__value" data-name-for-sorting="enrolled-date">
@Model.Enrolled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<dl class="nhsuk-summary-list details-list-with-button word-break">
<div class="nhsuk-summary-list__row details-list-with-button__row">
<dt class="nhsuk-summary-list__key">
Enrolled
First enrolled
</dt>
<dd class="nhsuk-summary-list__value" data-name-for-sorting="enrolled-date">
@Model.StartedDate.ToString(DateHelper.StandardDateAndTimeFormat)
Expand Down
Loading