Skip to content

Commit

Permalink
TD-4751 Mark the Non Reportable flag as true when the user Id of the …
Browse files Browse the repository at this point in the history
…delegate matches the user Id of the admin record of the supervisor being selected.
  • Loading branch information
ABSinhaa committed Oct 22, 2024
1 parent 7eef360 commit e4eba69
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
25 changes: 22 additions & 3 deletions DigitalLearningSolutions.Data/DataServices/CourseDataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ IEnumerable<CourseDelegateForExport> GetCourseDelegatesForExport(string searchSt
int customisationId, int centreId, bool? isDelegateActive, bool? isProgressLocked, bool? removed, bool? hasCompleted, string? answer1, string? answer2, string? answer3);

int EnrolOnActivitySelfAssessment(int selfAssessmentId, int candidateId, int supervisorId, string adminEmail,
int selfAssessmentSupervisorRoleId, DateTime? completeByDate, int delegateUserId, int centreId, int? enrolledByAdminId);
int selfAssessmentSupervisorRoleId, DateTime? completeByDate, int delegateUserId, int centreId, int? enrolledByAdminId, int? adminUserId);

bool IsCourseCompleted(int candidateId, int customisationId);
bool IsCourseCompleted(int candidateId, int customisationId, int progressID);
Expand Down Expand Up @@ -442,7 +442,7 @@ public void RemoveCurrentCourse(int progressId, int candidateId, RemovalMethod r
}

public int EnrolOnActivitySelfAssessment(int selfAssessmentId, int candidateId, int supervisorId, string adminEmail,
int selfAssessmentSupervisorRoleId, DateTime? completeByDate, int delegateUserId, int centreId, int? enrolledByAdminId)
int selfAssessmentSupervisorRoleId, DateTime? completeByDate, int delegateUserId, int centreId, int? enrolledByAdminId, int? adminUserId)
{
IClockUtility clockUtility = new ClockUtility();
DateTime startedDate = clockUtility.UtcNow;
Expand Down Expand Up @@ -541,7 +541,9 @@ LEFT OUTER JOIN UserCentreDetails AS UCD ON
new { candidateAssessmentId, enrolmentMethodId, completeByDateDynamic }
);
}
if (candidateAssessmentId > 1 && supervisorDelegateId !=0)

if (candidateAssessmentId > 1 && supervisorDelegateId !=0)

{
string sqlQuery = $@"
BEGIN TRANSACTION
Expand All @@ -558,6 +560,23 @@ BEGIN TRANSACTION
, new { candidateAssessmentId, selfAssessmentSupervisorRoleId, enrolmentMethodId, completeByDateDynamic });
}

if (supervisorId > 0)
{

adminUserId = Convert.ToInt32(connection.ExecuteScalar(@"SELECT UserID FROM AdminAccounts WHERE (AdminAccounts.ID = @supervisorId)",
new { supervisorId })
);

if (delegateUserId == adminUserId)
{
connection.Execute(
@"UPDATE CandidateAssessments SET NonReportable = 1 WHERE ID = @candidateAssessmentId",
new { candidateAssessmentId }
);

}
}

if (candidateAssessmentId < 1)
{
logger.LogWarning(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public IActionResult EnrolDelegateSummary()
sessionEnrol.CompleteByDate,
(int)sessionEnrol.DelegateUserID,
centreId,
GetAdminID()
GetAdminID(),0
);

}
Expand Down
7 changes: 4 additions & 3 deletions DigitalLearningSolutions.Web/Services/EnrolService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ int EnrolOnActivitySelfAssessment(
DateTime? completeByDate,
int delegateUserId,
int centreId,
int? enrolledByAdminId
int? enrolledByAdminId,
int? adminUserId
);
}
public class EnrolService : IEnrolService
Expand Down Expand Up @@ -184,9 +185,9 @@ by the system because a previous course completion has expired.</p>
return new Email(EnrolEmailSubject, body, emailAddress);
}

public int EnrolOnActivitySelfAssessment(int selfAssessmentId, int candidateId, int supervisorId, string adminEmail, int selfAssessmentSupervisorRoleId, DateTime? completeByDate, int delegateUserId, int centreId, int? enrolledByAdminId)
public int EnrolOnActivitySelfAssessment(int selfAssessmentId, int candidateId, int supervisorId, string adminEmail, int selfAssessmentSupervisorRoleId, DateTime? completeByDate, int delegateUserId, int centreId, int? enrolledByAdminId, int? adminUserId)
{
return courseDataService.EnrolOnActivitySelfAssessment(selfAssessmentId, candidateId, supervisorId, adminEmail, selfAssessmentSupervisorRoleId, completeByDate, delegateUserId, centreId, enrolledByAdminId);
return courseDataService.EnrolOnActivitySelfAssessment(selfAssessmentId, candidateId, supervisorId, adminEmail, selfAssessmentSupervisorRoleId, completeByDate, delegateUserId, centreId, enrolledByAdminId, adminUserId);
}
}
}

0 comments on commit e4eba69

Please sign in to comment.