Skip to content

Commit a2522dc

Browse files
authored
Merge pull request #2730 from TechnologyEnhancedLearning/Develop/Fix/TD-4279-Re-enrol-deleted-self-assessment
TD-4279- Re-enrolling a self assessment for the existing delegates not showing the 'remove' button
2 parents 3dd2e02 + 3d4257f commit a2522dc

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

DigitalLearningSolutions.Data/DataServices/CourseDataService.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ public int EnrolOnActivitySelfAssessment(int selfAssessmentId, int candidateId,
436436
DateTime startedDate = clockUtility.UtcNow;
437437
DateTime? lastAccessed = null;
438438
dynamic? completeByDateDynamic = null;
439-
int enrolmentMethodId = 2;
439+
int enrolmentMethodId = (int)EnrolmentMethod.AdminOrSupervisor;
440440
if (completeByDate == null || completeByDate.GetValueOrDefault().Year > 1753)
441441
{
442442
completeByDateDynamic = completeByDate!;
@@ -526,7 +526,7 @@ LEFT OUTER JOIN UserCentreDetails AS UCD ON
526526
{
527527
string sqlQuery = $@"
528528
BEGIN TRANSACTION
529-
UPDATE CandidateAssessments SET RemovedDate = NULL
529+
UPDATE CandidateAssessments SET RemovedDate = NULL, EnrolmentMethodId = @enrolmentMethodId
530530
WHERE ID = @candidateAssessmentId
531531
532532
UPDATE CandidateAssessmentSupervisors SET Removed = NULL
@@ -536,7 +536,7 @@ BEGIN TRANSACTION
536536
COMMIT TRANSACTION";
537537

538538
connection.Execute(sqlQuery
539-
, new { candidateAssessmentId, selfAssessmentSupervisorRoleId });
539+
, new { candidateAssessmentId, selfAssessmentSupervisorRoleId, enrolmentMethodId });
540540
}
541541

542542
if (candidateAssessmentId < 1)
@@ -552,6 +552,7 @@ BEGIN TRANSACTION
552552

553553
public void EnrolOnSelfAssessment(int selfAssessmentId, int delegateUserId, int centreId)
554554
{
555+
int enrolmentMethodId = (int)EnrolmentMethod.Self;
555556
var enrolmentExists = Convert.ToInt32(connection.ExecuteScalar(
556557
@"SELECT COALESCE
557558
((SELECT ID
@@ -573,9 +574,9 @@ FROM CandidateAssessments
573574
{
574575
connection.Execute(
575576
@"UPDATE CandidateAssessments
576-
SET RemovedDate = NULL
577+
SET RemovedDate = NULL, EnrolmentMethodId = @enrolmentMethodId
577578
WHERE ID = @enrolmentExists",
578-
new { enrolmentExists }
579+
new { enrolmentExists, enrolmentMethodId }
579580
);
580581
}
581582
}
@@ -869,8 +870,8 @@ public IEnumerable<CourseStatistics> GetNonArchivedCourseStatisticsAtCentreFilte
869870

870871
public IEnumerable<DelegateCourseInfo> GetDelegateCoursesInfo(int delegateId)
871872
{
872-
return connection.Query<DelegateCourseInfo>(
873-
$@"{selectDelegateCourseInfoQuery}
873+
return connection.Query<DelegateCourseInfo>(
874+
$@"{selectDelegateCourseInfoQuery}
874875
WHERE pr.CandidateID = @delegateId
875876
AND pr.RemovedDate IS NULL
876877
AND ap.DefaultContentTypeID <> 4
@@ -914,8 +915,8 @@ AND ap.DefaultContentTypeID <> 4
914915
u.ProfessionalRegistrationNumber,
915916
da.CentreID,
916917
ap.ArchivedDate",
917-
new { delegateId }
918-
);
918+
new { delegateId }
919+
);
919920
}
920921

921922
public DelegateCourseInfo? GetDelegateCourseInfoByProgressId(int progressId)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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.Enums
8+
{
9+
public enum EnrolmentMethod
10+
{
11+
Self = 1,
12+
AdminOrSupervisor,
13+
Group,
14+
System
15+
}
16+
}

0 commit comments

Comments
 (0)