Skip to content

Commit ed4d1d7

Browse files
committed
Merge branch 'release-v1.0.0' into Develop/Fix/TD-4787-NominatedSupervisors-change-role-Assessor
2 parents 7da62dd + a8682c5 commit ed4d1d7

File tree

29 files changed

+349
-282
lines changed

29 files changed

+349
-282
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace DigitalLearningSolutions.Data.Migrations
2+
{
3+
using FluentMigrator;
4+
5+
[Migration(202409300912)]
6+
public class AlterConstraintForCandidateAssessmentsAddUtcDate : Migration
7+
{
8+
public override void Up()
9+
{
10+
Execute.Sql(@$"ALTER TABLE [dbo].[CandidateAssessments] DROP CONSTRAINT [DF_CandidateAssessments_StartedDate];
11+
ALTER TABLE [dbo].[CandidateAssessments] ADD CONSTRAINT [DF_CandidateAssessments_StartedDate] DEFAULT (GETUTCDATE()) FOR [StartedDate];");
12+
}
13+
public override void Down()
14+
{
15+
Execute.Sql(@$"ALTER TABLE [dbo].[CandidateAssessments] DROP CONSTRAINT [DF_CandidateAssessments_StartedDate];
16+
ALTER TABLE [dbo].[CandidateAssessments] ADD CONSTRAINT [DF_CandidateAssessments_StartedDate] DEFAULT (GETDATE()) FOR [StartedDate];");
17+
}
18+
19+
}
20+
}

DigitalLearningSolutions.Data/DataServices/ActivityDataService.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ int currentRun
143143
c.CustomisationName,
144144
u.FirstName,
145145
u.LastName,
146-
CASE WHEN COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%@%' THEN COALESCE(ucd.Email, u.PrimaryEmail) ELSE '' END AS EmailAddress,
146+
COALESCE(ucd.Email, u.PrimaryEmail) AS EmailAddress,
147147
da.CandidateNumber AS DelegateId,
148148
da.Answer1,
149149
da.Answer2,
@@ -166,7 +166,8 @@ Users AS u INNER JOIN
166166
al.CustomisationID = @customisationId) AND (@courseCategoryId IS NULL OR
167167
al.CourseCategoryID = @courseCategoryId) AND (al.Registered = 1 OR
168168
al.Completed = 1 OR
169-
al.Evaluated = 1) AND EXISTS
169+
al.Evaluated = 1) AND
170+
(u.PrimaryEmail like '%_@_%' OR ucd.Email IS NOT NULL) AND EXISTS
170171
(SELECT ApplicationID
171172
FROM Applications AS ap
172173
WHERE (ApplicationID = al.ApplicationID) AND (DefaultContentTypeID <> 4))

DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/CompetencyDataService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,8 @@ public IEnumerable<Competency> GetCandidateAssessmentOptionalCompetencies(int se
456456
CG.ID AS CompetencyGroupID,
457457
'Capability' AS Vocabulary,
458458
SAS.Optional,
459-
COALESCE (CAOC.IncludedInSelfAssessment, 0) AS IncludedInSelfAssessment
459+
COALESCE (CAOC.IncludedInSelfAssessment, 0) AS IncludedInSelfAssessment,
460+
SAS.GroupOptionalCompetencies
460461
FROM Competencies AS C
461462
INNER JOIN CandidateAssessments AS CA
462463
ON CA.SelfAssessmentID = @selfAssessmentId AND CA.DelegateUserID = @delegateUserId AND CA.RemovedDate IS NULL

DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAssessmentDataService.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,8 +672,19 @@ LEFT JOIN UserCentreDetails AS ucd WITH (NOLOCK) ON ucd.UserID = da.UserID AND u
672672
public void RemoveDelegateSelfAssessment(int candidateAssessmentsId)
673673
{
674674
connection.Execute(
675-
@"UPDATE CandidateAssessments SET RemovedDate = GETUTCDATE(), RemovalMethodID =2
676-
WHERE ID = @candidateAssessmentsId",
675+
@"BEGIN TRY
676+
BEGIN TRANSACTION
677+
UPDATE CandidateAssessments SET RemovedDate = GETUTCDATE(), RemovalMethodID = 2
678+
WHERE ID = @candidateAssessmentsId AND RemovedDate IS NULL
679+
680+
UPDATE CandidateAssessmentSupervisors SET Removed = GETUTCDATE()
681+
WHERE CandidateAssessmentID = @candidateAssessmentsId AND Removed IS NULL
682+
683+
COMMIT TRANSACTION
684+
END TRY
685+
BEGIN CATCH
686+
ROLLBACK TRANSACTION
687+
END CATCH",
677688
new { candidateAssessmentsId }
678689
);
679690
}

DigitalLearningSolutions.Data/DataServices/SupervisorDataService.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -263,16 +263,6 @@ FROM SupervisorDelegates sd
263263
}
264264
else
265265
{
266-
if (supervisorAdminId == null)
267-
{
268-
supervisorAdminId = (int?)connection.ExecuteScalar(
269-
@"SELECT AdminID FROM AdminUsers WHERE Email = @supervisorEmail AND Active = 1 AND CentreID = @centreId", new { supervisorEmail, centreId }
270-
);
271-
}
272-
if (supervisorAdminId != null)
273-
{
274-
connection.Execute(@"UPDATE AdminUsers SET Supervisor = 1 WHERE AdminID = @supervisorAdminId AND Supervisor = 0", new { supervisorAdminId });
275-
}
276266
var numberOfAffectedRows = connection.Execute(
277267
@"INSERT INTO SupervisorDelegates (SupervisorAdminID, DelegateEmail, DelegateUserID, SupervisorEmail, AddedByDelegate)
278268
VALUES (@supervisorAdminId, @delegateEmail, @delegateUserId, @supervisorEmail, @addedByDelegate)",

DigitalLearningSolutions.Data/Models/SelfAssessments/Competency.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class Competency
1616
public string CompetencyGroupDescription { get; set; } = string.Empty;
1717
public string? Vocabulary { get; set; }
1818
public bool Optional { get; set; }
19+
public bool GroupOptionalCompetencies { get; set; }
1920
public bool AlwaysShowDescription { get; set; }
2021
public bool IncludedInSelfAssessment { get; set; }
2122
public DateTime? Verified { get; set; }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace DigitalLearningSolutions.Data.Models.SelfAssessments
8+
{
9+
public class CompetencySummary
10+
{
11+
public int VerifiedCount { get; set; }
12+
public int QuestionsCount { get; set; }
13+
public bool CanViewCertificate { get; set; }
14+
}
15+
}

DigitalLearningSolutions.Data/Models/TrackingSystem/ActivityLogDetail.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class ActivityLogDetail
99
public string? CustomisationName { get; set; }
1010
public string? FirstName { get; set; }
1111
public string? LastName { get; set; }
12-
public string? PrimaryEmail { get; set; }
12+
public string? EmailAddress { get; set; }
1313
public string? DelegateId { get; set; }
1414
public string? Answer1 { get; set; }
1515
public string? Answer2 { get; set; }

DigitalLearningSolutions.Web.Tests/Controllers/SupervisorController/SupervisorControllerTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class SupervisorControllerTests
3131
private IEmailService emailService = null!;
3232
private IClockUtility clockUtility = null!;
3333
private ICandidateAssessmentDownloadFileService candidateAssessmentDownloadFileService = null!;
34+
private IPdfService pdfService = null!;
3435

3536
[SetUp]
3637
public void Setup()
@@ -53,7 +54,7 @@ public void Setup()
5354
emailService = A.Fake<IEmailService>();
5455
clockUtility = A.Fake<IClockUtility>();
5556
candidateAssessmentDownloadFileService = A.Fake<ICandidateAssessmentDownloadFileService>();
56-
57+
pdfService = A.Fake<IPdfService>();
5758
A.CallTo(() => candidateAssessmentDownloadFileService.GetCandidateAssessmentDownloadFileForCentre(A<int>._, A<int>._, A<bool>._))
5859
.Returns(new byte[] { });
5960
}
@@ -81,7 +82,8 @@ public void ExportCandidateAssessment_should_return_file_object_with_file_name_i
8182
emailGenerationService,
8283
emailService,
8384
candidateAssessmentDownloadFileService,
84-
clockUtility
85+
clockUtility,
86+
pdfService
8587
);
8688
string expectedFileName = $"{((selfAssessmentName.Length > 30) ? selfAssessmentName.Substring(0, 30) : selfAssessmentName)} - {delegateName} - {clockUtility.UtcNow:yyyy-MM-dd}.xlsx";
8789

DigitalLearningSolutions.Web.Tests/Services/ActivityServiceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ public void GetActivityDataFileForCentre_returns_expected_excel_data()
436436

437437
var filterData = new ActivityFilterData(
438438
DateTime.Parse("2020-9-1"),
439-
DateTime.Parse("2021-9-1"),
439+
DateTime.Parse("2021-9-30"),
440440
null,
441441
null,
442442
null,

0 commit comments

Comments
 (0)