Skip to content

Commit cfea661

Browse files
TD-4238 Launching few courses from 'Current activities' or from 'Course set up' seeing back link as 'Completed activities'
1 parent 31427b8 commit cfea661

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

DigitalLearningSolutions.Data/DataServices/CourseDataService.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ int EnrolOnActivitySelfAssessment(int selfAssessmentId, int candidateId, int sup
137137
public IEnumerable<CourseStatistics> GetDelegateCourseStatisticsAtCentre(string searchString, int centreId, int? categoryId, bool allCentreCourses, bool? hideInLearnerPortal, string isActive, string categoryName, string courseTopic, string hasAdminFields);
138138

139139
public IEnumerable<DelegateAssessmentStatistics> GetDelegateAssessmentStatisticsAtCentre(string searchString, int centreId, string categoryName, string isActive);
140+
bool IsCourseCurrent(int candidateId, int customisationId);
140141
}
141142

142143
public class CourseDataService : ICourseDataService
@@ -1821,6 +1822,22 @@ ELSE CAST(0 AS BIT) END",
18211822
);
18221823
}
18231824

1825+
public bool IsCourseCurrent(int candidateId, int customisationId)
1826+
{
1827+
return connection.ExecuteScalar<bool>(
1828+
@"SELECT CASE WHEN EXISTS (
1829+
SELECT p.Completed
1830+
FROM Progress AS p INNER JOIN
1831+
Customisations AS cu ON p.CustomisationID = cu.CustomisationID INNER JOIN
1832+
Applications AS a ON cu.ApplicationID = a.ApplicationID
1833+
WHERE (p.CandidateID = @candidateId) AND (p.CustomisationID = @customisationId)
1834+
AND ((p.Completed IS NULL)))
1835+
THEN CAST(1 AS BIT)
1836+
ELSE CAST(0 AS BIT) END",
1837+
new { candidateId, customisationId }
1838+
);
1839+
}
1840+
18241841
public IEnumerable<Course> GetApplicationsAvailableToCentre(int centreId)
18251842
{
18261843
return connection.Query<Course>(

DigitalLearningSolutions.Web/Controllers/LearningMenuController/LearningMenuController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -599,11 +599,11 @@ private async Task IncreaseAuthenticatedUserExpiry()
599599

600600
private void SetTempData(int candidateId, int customisationId)
601601
{
602-
var isCompleted = courseService.IsCourseCompleted(candidateId, customisationId);
603-
if (isCompleted)
604-
TempData["LearningActivity"] = "Completed";
602+
var isCurrent = courseService.IsCourseCurrent(candidateId, customisationId);
603+
if (isCurrent)
604+
TempData["LearningActivity"] = "Current";
605605
else
606-
TempData["LearningActivity"] = "Current";
606+
TempData["LearningActivity"] = "Completed";
607607
}
608608

609609
private bool UniqueIdManipulationDetected(int candidateId, int customisationId)

DigitalLearningSolutions.Web/Services/CourseService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ int diagCompletionThreshold
132132
void EnrolOnSelfAssessment(int selfAssessmentId, int delegateUserId, int centreId);
133133
int GetNumberOfActiveCoursesAtCentreFilteredByCategory(int centreId, int? categoryId);
134134
public IEnumerable<Course> GetApplicationsAvailableToCentre(int centreId);
135+
bool IsCourseCurrent(int candidateId, int customisationId);
135136
}
136137

137138
public class CourseService : ICourseService
@@ -619,5 +620,10 @@ public IEnumerable<Course> GetApplicationsAvailableToCentre(int centreId)
619620
{
620621
return courseDataService.GetApplicationsAvailableToCentre(centreId);
621622
}
623+
624+
public bool IsCourseCurrent(int candidateId, int customisationId)
625+
{
626+
return courseDataService.IsCourseCurrent(candidateId,customisationId);
627+
}
622628
}
623629
}

0 commit comments

Comments
 (0)