@@ -408,24 +408,26 @@ class UserService implements IUserService {
408
408
}
409
409
410
410
async getCompletedModules ( learner : LearnerDTO ) : Promise < Set < string > > {
411
- let completedModules = new Set < string > ( ) ;
411
+ const completedModules = new Set < string > ( ) ;
412
412
413
+ // eslint-disable-next-line no-restricted-syntax
413
414
for ( const unitsMap of learner . activitiesCompleted . values ( ) ) {
415
+ // eslint-disable-next-line no-restricted-syntax
414
416
for ( const [
415
417
moduleId ,
416
418
activitiesCompletedInModule ,
417
419
] of unitsMap . entries ( ) ) {
418
420
try {
421
+ // eslint-disable-next-line no-await-in-loop
419
422
const module = await courseModuleService . getCourseModule ( moduleId ) ;
420
423
const moduleActivities = module . pages . filter (
421
424
( page ) => page . type === "Activity" ,
422
425
) ;
423
426
if ( activitiesCompletedInModule . length === moduleActivities . length ) {
424
427
completedModules . add ( moduleId ) ;
425
428
}
426
- } catch ( error ) {
427
- console . error ( `Error finding module ${ moduleId } :` , error ) ;
428
- }
429
+ // eslint-disable-next-line no-empty
430
+ } catch ( error ) { }
429
431
}
430
432
}
431
433
@@ -446,38 +448,62 @@ class UserService implements IUserService {
446
448
return modifiedCount ;
447
449
}
448
450
449
- private async getNextPage ( unitId : string , moduleId : string , pageId : string ) : Promise < string | null > {
450
- const module = await courseModuleService . getCourseModule ( moduleId ) ;
451
- const curPageIndex = module . pages . findIndex ( ( page ) => page . id === pageId ) ;
452
- const nextPage = module . pages [ curPageIndex + 1 ] ;
451
+ private async getNextPage (
452
+ unitId : string ,
453
+ moduleId : string ,
454
+ pageId : string ,
455
+ ) : Promise < string | null > {
456
+ const curModule = await courseModuleService . getCourseModule ( moduleId ) ;
457
+ const curPageIndex = curModule . pages . findIndex (
458
+ ( page ) => page . id === pageId ,
459
+ ) ;
460
+ const nextPage = curModule . pages [ curPageIndex + 1 ] ;
453
461
if ( nextPage ) {
454
462
return nextPage . id ;
455
463
}
456
464
const unit = await courseUnitService . getCourseUnit ( unitId ) ;
457
- const curModuleIndex = unit . modules . findIndex ( ( module ) => module === moduleId ) ;
465
+ const curModuleIndex = unit . modules . findIndex (
466
+ ( module ) => module === moduleId ,
467
+ ) ;
458
468
const nextModuleId = unit . modules [ curModuleIndex + 1 ] ;
459
469
if ( nextModuleId ) {
460
470
try {
461
- const nextModule = await courseModuleService . getCourseModule ( nextModuleId ) ;
471
+ const nextModule = await courseModuleService . getCourseModule (
472
+ nextModuleId ,
473
+ ) ;
462
474
if ( nextModule && nextModule . pages . length > 0 ) {
463
475
return nextModule . pages [ 0 ] . id ;
464
476
}
477
+ // eslint-disable-next-line no-empty
465
478
} catch ( error ) { }
466
479
}
467
- const nextUnit = await courseunitMgmodel . findOne ( { displayIndex : unit . displayIndex + 1 } ) ;
480
+ const nextUnit = await courseunitMgmodel . findOne ( {
481
+ displayIndex : unit . displayIndex + 1 ,
482
+ } ) ;
468
483
if ( nextUnit ) {
469
- const nextModule = await courseModuleService . getCourseModule ( nextUnit . modules [ 0 ] . toString ( ) ) ;
484
+ const nextModule = await courseModuleService . getCourseModule (
485
+ nextUnit . modules [ 0 ] . toString ( ) ,
486
+ ) ;
470
487
if ( nextModule && nextModule . pages . length > 0 ) {
471
488
return nextModule . pages [ 0 ] . id ;
472
489
}
473
490
}
474
491
return null ;
475
492
}
476
493
477
- async updateNextPage ( learnerId : string , justViewed : { unitId : string , moduleId : string , pageId : string } ) : Promise < Learner | null > {
478
- const nextPageId = await this . getNextPage ( justViewed . unitId , justViewed . moduleId , justViewed . pageId ) ;
494
+ async updateNextPage (
495
+ learnerId : string ,
496
+ justViewed : { unitId : string ; moduleId : string ; pageId : string } ,
497
+ ) : Promise < Learner | null > {
498
+ const nextPageId = await this . getNextPage (
499
+ justViewed . unitId ,
500
+ justViewed . moduleId ,
501
+ justViewed . pageId ,
502
+ ) ;
479
503
if ( ! nextPageId ) {
480
- Logger . warn ( `No next page found for learner ${ learnerId } after viewing ${ justViewed . pageId } in module ${ justViewed . moduleId } of unit ${ justViewed . unitId } ` ) ;
504
+ Logger . warn (
505
+ `No next page found for learner ${ learnerId } after viewing ${ justViewed . pageId } in module ${ justViewed . moduleId } of unit ${ justViewed . unitId } ` ,
506
+ ) ;
481
507
return null ;
482
508
}
483
509
const updatedUser = await LearnerModel . findByIdAndUpdate (
0 commit comments