Skip to content

Commit e4eba69

Browse files
committed
TD-4751 Mark the Non Reportable flag as true when the user Id of the delegate matches the user Id of the admin record of the supervisor being selected.
1 parent 7eef360 commit e4eba69

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

DigitalLearningSolutions.Data/DataServices/CourseDataService.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ IEnumerable<CourseDelegateForExport> GetCourseDelegatesForExport(string searchSt
122122
int customisationId, int centreId, bool? isDelegateActive, bool? isProgressLocked, bool? removed, bool? hasCompleted, string? answer1, string? answer2, string? answer3);
123123

124124
int EnrolOnActivitySelfAssessment(int selfAssessmentId, int candidateId, int supervisorId, string adminEmail,
125-
int selfAssessmentSupervisorRoleId, DateTime? completeByDate, int delegateUserId, int centreId, int? enrolledByAdminId);
125+
int selfAssessmentSupervisorRoleId, DateTime? completeByDate, int delegateUserId, int centreId, int? enrolledByAdminId, int? adminUserId);
126126

127127
bool IsCourseCompleted(int candidateId, int customisationId);
128128
bool IsCourseCompleted(int candidateId, int customisationId, int progressID);
@@ -442,7 +442,7 @@ public void RemoveCurrentCourse(int progressId, int candidateId, RemovalMethod r
442442
}
443443

444444
public int EnrolOnActivitySelfAssessment(int selfAssessmentId, int candidateId, int supervisorId, string adminEmail,
445-
int selfAssessmentSupervisorRoleId, DateTime? completeByDate, int delegateUserId, int centreId, int? enrolledByAdminId)
445+
int selfAssessmentSupervisorRoleId, DateTime? completeByDate, int delegateUserId, int centreId, int? enrolledByAdminId, int? adminUserId)
446446
{
447447
IClockUtility clockUtility = new ClockUtility();
448448
DateTime startedDate = clockUtility.UtcNow;
@@ -541,7 +541,9 @@ LEFT OUTER JOIN UserCentreDetails AS UCD ON
541541
new { candidateAssessmentId, enrolmentMethodId, completeByDateDynamic }
542542
);
543543
}
544-
if (candidateAssessmentId > 1 && supervisorDelegateId !=0)
544+
545+
if (candidateAssessmentId > 1 && supervisorDelegateId !=0)
546+
545547
{
546548
string sqlQuery = $@"
547549
BEGIN TRANSACTION
@@ -558,6 +560,23 @@ BEGIN TRANSACTION
558560
, new { candidateAssessmentId, selfAssessmentSupervisorRoleId, enrolmentMethodId, completeByDateDynamic });
559561
}
560562

563+
if (supervisorId > 0)
564+
{
565+
566+
adminUserId = Convert.ToInt32(connection.ExecuteScalar(@"SELECT UserID FROM AdminAccounts WHERE (AdminAccounts.ID = @supervisorId)",
567+
new { supervisorId })
568+
);
569+
570+
if (delegateUserId == adminUserId)
571+
{
572+
connection.Execute(
573+
@"UPDATE CandidateAssessments SET NonReportable = 1 WHERE ID = @candidateAssessmentId",
574+
new { candidateAssessmentId }
575+
);
576+
577+
}
578+
}
579+
561580
if (candidateAssessmentId < 1)
562581
{
563582
logger.LogWarning(

DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/EnrolController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ public IActionResult EnrolDelegateSummary()
326326
sessionEnrol.CompleteByDate,
327327
(int)sessionEnrol.DelegateUserID,
328328
centreId,
329-
GetAdminID()
329+
GetAdminID(),0
330330
);
331331

332332
}

DigitalLearningSolutions.Web/Services/EnrolService.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ int EnrolOnActivitySelfAssessment(
4343
DateTime? completeByDate,
4444
int delegateUserId,
4545
int centreId,
46-
int? enrolledByAdminId
46+
int? enrolledByAdminId,
47+
int? adminUserId
4748
);
4849
}
4950
public class EnrolService : IEnrolService
@@ -184,9 +185,9 @@ by the system because a previous course completion has expired.</p>
184185
return new Email(EnrolEmailSubject, body, emailAddress);
185186
}
186187

187-
public int EnrolOnActivitySelfAssessment(int selfAssessmentId, int candidateId, int supervisorId, string adminEmail, int selfAssessmentSupervisorRoleId, DateTime? completeByDate, int delegateUserId, int centreId, int? enrolledByAdminId)
188+
public int EnrolOnActivitySelfAssessment(int selfAssessmentId, int candidateId, int supervisorId, string adminEmail, int selfAssessmentSupervisorRoleId, DateTime? completeByDate, int delegateUserId, int centreId, int? enrolledByAdminId, int? adminUserId)
188189
{
189-
return courseDataService.EnrolOnActivitySelfAssessment(selfAssessmentId, candidateId, supervisorId, adminEmail, selfAssessmentSupervisorRoleId, completeByDate, delegateUserId, centreId, enrolledByAdminId);
190+
return courseDataService.EnrolOnActivitySelfAssessment(selfAssessmentId, candidateId, supervisorId, adminEmail, selfAssessmentSupervisorRoleId, completeByDate, delegateUserId, centreId, enrolledByAdminId, adminUserId);
190191
}
191192
}
192193
}

0 commit comments

Comments
 (0)