Skip to content

Commit

Permalink
MOBILE-4272 workshop: Rollback async handlers
Browse files Browse the repository at this point in the history
There is a bug with missing optional methods in async handlers. If their existence is checked before initialization, they always exist but fail on execution. That should be refactored into asynchronous and type-safe code, but we decided to do it in the next version.
  • Loading branch information
NoelDeMartin committed Oct 3, 2023
1 parent 2ec215e commit 53e902c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import { APP_INITIALIZER, NgModule } from '@angular/core';
import { AddonWorkshopAssessmentStrategyDelegate } from '../../services/assessment-strategy-delegate';
import { CoreSharedModule } from '@/core/shared.module';
import { getAssessmentStrategyHandlerInstance } from '@addons/mod/workshop/assessment/accumulative/services/handler';
import {
AddonModWorkshopAssessmentStrategyAccumulativeHandler,
} from '@addons/mod/workshop/assessment/accumulative/services/handler-lazy';

@NgModule({
imports: [
Expand All @@ -26,7 +28,12 @@ import { getAssessmentStrategyHandlerInstance } from '@addons/mod/workshop/asses
provide: APP_INITIALIZER,
multi: true,
useValue: () => {
AddonWorkshopAssessmentStrategyDelegate.registerHandler(getAssessmentStrategyHandlerInstance());
// TODO use async instances
// AddonWorkshopAssessmentStrategyDelegate.registerHandler(getAssessmentStrategyHandlerInstance());

AddonWorkshopAssessmentStrategyDelegate.registerHandler(
AddonModWorkshopAssessmentStrategyAccumulativeHandler.instance,
);
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import { CoreSharedModule } from '@/core/shared.module';
import { APP_INITIALIZER, NgModule } from '@angular/core';
import { AddonWorkshopAssessmentStrategyDelegate } from '../../services/assessment-strategy-delegate';
import { getAssessmentStrategyHandlerInstance } from './services/handler';
import { AddonModWorkshopAssessmentStrategyCommentsHandler } from '@addons/mod/workshop/assessment/comments/services/handler-lazy';

@NgModule({
imports: [
Expand All @@ -26,7 +26,10 @@ import { getAssessmentStrategyHandlerInstance } from './services/handler';
provide: APP_INITIALIZER,
multi: true,
useValue: () => {
AddonWorkshopAssessmentStrategyDelegate.registerHandler(getAssessmentStrategyHandlerInstance());
// TODO use async instances
// AddonWorkshopAssessmentStrategyDelegate.registerHandler(getAssessmentStrategyHandlerInstance());

AddonWorkshopAssessmentStrategyDelegate.registerHandler(AddonModWorkshopAssessmentStrategyCommentsHandler.instance);
},
},
],
Expand Down
11 changes: 9 additions & 2 deletions src/addons/mod/workshop/assessment/numerrors/numerrors.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import { CoreSharedModule } from '@/core/shared.module';
import { APP_INITIALIZER, NgModule } from '@angular/core';
import { AddonWorkshopAssessmentStrategyDelegate } from '../../services/assessment-strategy-delegate';
import { getAssessmentStrategyHandlerInstance } from './services/handler';
import {
AddonModWorkshopAssessmentStrategyNumErrorsHandler,
} from '@addons/mod/workshop/assessment/numerrors/services/handler-lazy';

@NgModule({
imports: [
Expand All @@ -26,7 +28,12 @@ import { getAssessmentStrategyHandlerInstance } from './services/handler';
provide: APP_INITIALIZER,
multi: true,
useValue: () => {
AddonWorkshopAssessmentStrategyDelegate.registerHandler(getAssessmentStrategyHandlerInstance());
// TODO use async instances
// AddonWorkshopAssessmentStrategyDelegate.registerHandler(getAssessmentStrategyHandlerInstance());

AddonWorkshopAssessmentStrategyDelegate.registerHandler(
AddonModWorkshopAssessmentStrategyNumErrorsHandler.instance,
);
},
},
],
Expand Down
7 changes: 5 additions & 2 deletions src/addons/mod/workshop/assessment/rubric/rubric.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import { CoreSharedModule } from '@/core/shared.module';
import { APP_INITIALIZER, NgModule } from '@angular/core';
import { AddonWorkshopAssessmentStrategyDelegate } from '../../services/assessment-strategy-delegate';
import { getAssessmentStrategyHandlerInstance } from './services/handler';
import { AddonModWorkshopAssessmentStrategyRubricHandler } from '@addons/mod/workshop/assessment/rubric/services/handler-lazy';

@NgModule({
imports: [
Expand All @@ -26,7 +26,10 @@ import { getAssessmentStrategyHandlerInstance } from './services/handler';
provide: APP_INITIALIZER,
multi: true,
useValue: () => {
AddonWorkshopAssessmentStrategyDelegate.registerHandler(getAssessmentStrategyHandlerInstance());
// TODO use async instances
// AddonWorkshopAssessmentStrategyDelegate.registerHandler(getAssessmentStrategyHandlerInstance());

AddonWorkshopAssessmentStrategyDelegate.registerHandler(AddonModWorkshopAssessmentStrategyRubricHandler.instance);
},
},
],
Expand Down
12 changes: 8 additions & 4 deletions src/addons/mod/workshop/workshop.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import { AddonModWorkshopIndexLinkHandler } from './services/handlers/index-link
import { AddonModWorkshopListLinkHandler } from './services/handlers/list-link';
import { AddonModWorkshopModuleHandler } from './services/handlers/module';
import { ADDON_MOD_WORKSHOP_COMPONENT, ADDON_MOD_WORKSHOP_PAGE_NAME } from '@addons/mod/workshop/constants';
import { getCronHandlerInstance } from '@addons/mod/workshop/services/handlers/sync-cron';
import { getPrefetchHandlerInstance } from '@addons/mod/workshop/services/handlers/prefetch';
import { AddonModWorkshopPrefetchHandler } from '@addons/mod/workshop/services/handlers/prefetch-lazy';
import { AddonModWorkshopSyncCronHandler } from '@addons/mod/workshop/services/handlers/sync-cron-lazy';

/**
* Get workshop services.
Expand Down Expand Up @@ -85,9 +85,13 @@ const routes: Routes = [
provide: APP_INITIALIZER,
multi: true,
useValue: () => {
// TODO use async instances
// CoreCourseModulePrefetchDelegate.registerHandler(getPrefetchHandlerInstance());
// CoreCronDelegate.register(getCronHandlerInstance());

CoreCourseModuleDelegate.registerHandler(AddonModWorkshopModuleHandler.instance);
CoreCourseModulePrefetchDelegate.registerHandler(getPrefetchHandlerInstance());
CoreCronDelegate.register(getCronHandlerInstance());
CoreCourseModulePrefetchDelegate.registerHandler(AddonModWorkshopPrefetchHandler.instance);
CoreCronDelegate.register(AddonModWorkshopSyncCronHandler.instance);
CoreContentLinksDelegate.registerHandler(AddonModWorkshopIndexLinkHandler.instance);
CoreContentLinksDelegate.registerHandler(AddonModWorkshopListLinkHandler.instance);

Expand Down

0 comments on commit 53e902c

Please sign in to comment.