File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
WebAPI/LearningHub.Nhs.Services Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -272,12 +272,22 @@ public async Task<List<MyLearningDetailedItemViewModel>> PopulateMyLearningDetai
272272 }
273273 else
274274 {
275- expectedActivity = latestActivityCheck . Where ( x => x . Id == resourceActivity . Id && ( x . ActivityStatusId == ( ( int ) ActivityStatusEnum . Completed ) || x . ActivityStatusId == ( ( int ) ActivityStatusEnum . Incomplete ) || x . ActivityStatusId == ( ( int ) ActivityStatusEnum . Passed ) || x . ActivityStatusId == ( ( int ) ActivityStatusEnum . Downloaded ) ) ) . OrderByDescending ( x => x . ActivityStart ) . FirstOrDefault ( ) ;
275+ expectedActivity = latestActivityCheck . Where ( x => x . Id == resourceActivity . Id && ( x . ActivityStatusId == ( ( int ) ActivityStatusEnum . Completed ) || x . ActivityStatusId == ( ( int ) ActivityStatusEnum . Passed ) || x . ActivityStatusId == ( ( int ) ActivityStatusEnum . Downloaded ) ) ) . OrderByDescending ( x => x . ActivityStart ) . FirstOrDefault ( ) ;
276276 }
277277
278- if ( latestActivityCheck . Any ( ) && expectedActivity != null && resourceActivity . ResourceVersion . CertificateEnabled == true )
278+ if ( latestActivityCheck . Any ( ) && expectedActivity != null )
279279 {
280- viewModel . CertificateEnabled = true ;
280+ bool isExpectedActivityIdMatched = false ;
281+ if ( resourceActivity . Resource . ResourceTypeEnum == ResourceTypeEnum . Audio || resourceActivity . Resource . ResourceTypeEnum == ResourceTypeEnum . Video )
282+ {
283+ isExpectedActivityIdMatched = latestActivityCheck . OrderByDescending ( x => x . ActivityStart ) . FirstOrDefault ( ) . Id == expectedActivity . LaunchResourceActivityId ;
284+ }
285+ else
286+ {
287+ isExpectedActivityIdMatched = latestActivityCheck . OrderByDescending ( x => x . ActivityStart ) . FirstOrDefault ( ) . Id == expectedActivity . Id ;
288+ }
289+
290+ viewModel . CertificateEnabled = isExpectedActivityIdMatched && resourceActivity . ResourceVersion . CertificateEnabled . GetValueOrDefault ( false ) ;
281291 }
282292 else
283293 {
You can’t perform that action at this time.
0 commit comments