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
Expand Up @@ -1007,6 +1007,8 @@ public void GetDelegatesOnCourseForExport_returns_expected_values()
// Given
var expectedFirstRecord = new CourseDelegateForExport
{
CustomisationName = "Standard",
ApplicationName = "Entry Level - Win XP, Office 2003/07 OLD",
IsDelegateActive = true,
CandidateNumber = "PC97",
CompleteBy = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class CourseDelegatesDownloadFileServiceTests
{
new CourseDelegateForExport
{
ApplicationName = "Course One",
CustomisationName = "v1",
CandidateNumber = "TM68",
DelegateFirstName = "Philip",
DelegateLastName = "Barber",
Expand Down Expand Up @@ -54,6 +56,8 @@ public class CourseDelegatesDownloadFileServiceTests
},
new CourseDelegateForExport
{
ApplicationName = "Course One",
CustomisationName = "v1",
CandidateNumber = "ES1",
DelegateFirstName = "Jonathan",
DelegateLastName = "Bennett",
Expand Down Expand Up @@ -82,6 +86,8 @@ public class CourseDelegatesDownloadFileServiceTests
},
new CourseDelegateForExport
{
ApplicationName = "Course One",
CustomisationName = "v1",
CandidateNumber = "NB8",
DelegateFirstName = "Erik",
DelegateLastName = "Griffin",
Expand All @@ -108,6 +114,66 @@ public class CourseDelegatesDownloadFileServiceTests
Duration = 1,
DiagnosticScore = 0,
},
new CourseDelegateForExport
{
ApplicationName = "Course Two",
CustomisationName = "v1",
CandidateNumber = "TM68",
DelegateFirstName = "Philip",
DelegateLastName = "Barber",
DelegateEmail = "mtc@.o",
IsDelegateActive = true,
IsProgressLocked = false,
LastUpdated = new DateTime(2018, 03, 08),
Enrolled = new DateTime(2012, 05, 24),
CompleteBy = null,
RemovedDate = null,
Completed = null,
AllAttempts = 1,
AttemptsPassed = 0,
RegistrationAnswer1 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
RegistrationAnswer2 = "xxxxxxx",
RegistrationAnswer3 = null,
RegistrationAnswer4 = null,
RegistrationAnswer5 = null,
RegistrationAnswer6 = null,
Answer1 = null,
Answer2 = null,
Answer3 = null,
LoginCount = 2,
Duration = 0,
DiagnosticScore = 0,
},
new CourseDelegateForExport
{
ApplicationName = "Course Two",
CustomisationName = "v1",
CandidateNumber = "ES1",
DelegateFirstName = "Jonathan",
DelegateLastName = "Bennett",
DelegateEmail = "slumrdaiehn.b@g",
IsDelegateActive = true,
IsProgressLocked = false,
LastUpdated = new DateTime(2018, 03, 08),
Enrolled = new DateTime(2010, 09, 22),
CompleteBy = null,
RemovedDate = null,
Completed = new DateTime(2018, 03, 08),
AllAttempts = 1,
AttemptsPassed = 1,
RegistrationAnswer1 = "Senior Implementation and Business Change Manager",
RegistrationAnswer2 = "test2",
RegistrationAnswer3 = null,
RegistrationAnswer4 = null,
RegistrationAnswer5 = null,
RegistrationAnswer6 = null,
Answer1 = null,
Answer2 = null,
Answer3 = null,
LoginCount = 2,
Duration = 0,
DiagnosticScore = 0,
},
};

private ICourseAdminFieldsService courseAdminFieldsService = null!;
Expand Down Expand Up @@ -143,7 +209,7 @@ public void GetDelegateDownloadFileForCourse_returns_expected_excel_data()
);

A.CallTo(() => courseDataService.GetDelegatesOnCourseForExport(customisationId, centreId))
.Returns(courseDelegates);
.Returns(courseDelegates.Where(c => c.ApplicationName == "Course One"));

var centreRegistrationPrompts = new List<CentreRegistrationPrompt>
{
Expand Down Expand Up @@ -193,17 +259,17 @@ public void GetCourseDelegateDownloadFile_returns_expected_excel_data()
Courses = new[]
{
new CourseStatisticsWithAdminFieldResponseCounts
{ ApplicationName = "Course One", CustomisationId = 1 },
{ ApplicationName = "Course One", CustomisationName = "v1", CustomisationId = 1 },
new CourseStatisticsWithAdminFieldResponseCounts
{ ApplicationName = "Course Two", CustomisationId = 2 },
{ ApplicationName = "Course Two", CustomisationName = "v1", CustomisationId = 2 },
},
}
);

A.CallTo(() => courseDataService.GetDelegatesOnCourseForExport(1, centreId))
.Returns(courseDelegates);
.Returns(courseDelegates.Where(c => c.ApplicationName == "Course One"));
A.CallTo(() => courseDataService.GetDelegatesOnCourseForExport(2, centreId))
.Returns(courseDelegates.Where(c => c.CandidateNumber != "NB8"));
.Returns(courseDelegates.Where(c => c.ApplicationName == "Course Two"));

var centreRegistrationPrompts = new List<CentreRegistrationPrompt>
{
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ AND Progress.SubmittedTime > @threeMonthsAgo
AND Applications.DefaultContentTypeID <> 4
GROUP BY Applications.ApplicationID",
new
{ brandId, threeMonthsAgo }
{ brandId, threeMonthsAgo }
);
return query.ToDictionary<dynamic?, int, int>(
entry => entry.ApplicationID,
Expand Down Expand Up @@ -812,6 +812,8 @@ public IEnumerable<CourseDelegateForExport> GetDelegatesOnCourseForExport(int cu
{
return connection.Query<CourseDelegateForExport>(
$@"SELECT
ap.ApplicationName,
cu.CustomisationName,
ca.CandidateID AS DelegateId,
ca.CandidateNumber,
ca.FirstName AS DelegateFirstName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public byte[] GetCourseDelegateDownloadFile(

public class CourseDelegatesDownloadFileService : ICourseDelegatesDownloadFileService
{
private const string CourseName = "Course name";
private const string LastName = "Last name";
private const string FirstName = "First name";
private const string Email = "Email";
Expand Down Expand Up @@ -321,7 +322,7 @@ DataTable dataTable
)
{
dataTable.Columns.AddRange(
new[] { new DataColumn(LastName), new DataColumn(FirstName), new DataColumn(Email) }
new[] { new DataColumn(CourseName), new DataColumn(LastName), new DataColumn(FirstName), new DataColumn(Email) }
);

foreach (var prompt in registrationRegistrationPrompts.CustomPrompts)
Expand Down Expand Up @@ -397,6 +398,7 @@ private static void SetCommonRowValues(
DataRow row
)
{
row[CourseName] = courseDelegate.CourseName;
row[LastName] = courseDelegate.DelegateLastName;
row[FirstName] = courseDelegate.DelegateFirstName;
row[Email] = courseDelegate.DelegateEmail;
Expand All @@ -414,7 +416,6 @@ DataRow row
courseDelegate.DelegateRegistrationPrompts[prompt.RegistrationField.Id - 1];
}
}

row[DelegateId] = courseDelegate.CandidateNumber;
row[Enrolled] = courseDelegate.Enrolled.Date;
row[LastAccessed] = courseDelegate.LastUpdated.Date;
Expand Down