From 46ad0912ea895302ddc06ac70cec4d085f7a2bcd Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 18 Jan 2018 10:02:47 +0100 Subject: [PATCH] MOBILE-2310 course: Implement social format --- src/core/course/course.module.ts | 4 ++- .../singleactivity/providers/handler.ts | 2 +- .../formats/social/providers/handler.ts | 25 +++++++++++++++ .../course/formats/social/social.module.ts | 32 +++++++++++++++++++ 4 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 src/core/course/formats/social/providers/handler.ts create mode 100644 src/core/course/formats/social/social.module.ts diff --git a/src/core/course/course.module.ts b/src/core/course/course.module.ts index 489a7a128..1c74f500a 100644 --- a/src/core/course/course.module.ts +++ b/src/core/course/course.module.ts @@ -20,6 +20,7 @@ import { CoreCourseModuleDelegate } from './providers/module-delegate'; import { CoreCourseModulePrefetchDelegate } from './providers/module-prefetch-delegate'; import { CoreCourseFormatDefaultHandler } from './providers/default-format'; import { CoreCourseFormatSingleActivityModule } from './formats/singleactivity/singleactivity.module'; +import { CoreCourseFormatSocialModule } from './formats/social/social.module'; import { CoreCourseFormatTopicsModule} from './formats/topics/topics.module'; import { CoreCourseFormatWeeksModule } from './formats/weeks/weeks.module'; @@ -28,7 +29,8 @@ import { CoreCourseFormatWeeksModule } from './formats/weeks/weeks.module'; imports: [ CoreCourseFormatSingleActivityModule, CoreCourseFormatTopicsModule, - CoreCourseFormatWeeksModule + CoreCourseFormatWeeksModule, + CoreCourseFormatSocialModule ], providers: [ CoreCourseProvider, diff --git a/src/core/course/formats/singleactivity/providers/handler.ts b/src/core/course/formats/singleactivity/providers/handler.ts index 73ff60467..396c94971 100644 --- a/src/core/course/formats/singleactivity/providers/handler.ts +++ b/src/core/course/formats/singleactivity/providers/handler.ts @@ -17,7 +17,7 @@ import { CoreCourseFormatHandler } from '../../../providers/format-delegate'; import { CoreCourseFormatSingleActivityComponent } from '../components/format'; /** - * Handler to support weeks course format. + * Handler to support singleactivity course format. */ @Injectable() export class CoreCourseFormatSingleActivityHandler implements CoreCourseFormatHandler { diff --git a/src/core/course/formats/social/providers/handler.ts b/src/core/course/formats/social/providers/handler.ts new file mode 100644 index 000000000..25d942515 --- /dev/null +++ b/src/core/course/formats/social/providers/handler.ts @@ -0,0 +1,25 @@ +// (C) Copyright 2015 Martin Dougiamas +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { Injectable } from '@angular/core'; +import { CoreCourseFormatSingleActivityHandler } from '../../singleactivity/providers/handler'; + +/** + * Handler to support social course format. + * This format is like singleactivity in the mobile app, so we'll use the same implementation for both. + */ +@Injectable() +export class CoreCourseFormatSocialHandler extends CoreCourseFormatSingleActivityHandler { + name = 'social'; +} diff --git a/src/core/course/formats/social/social.module.ts b/src/core/course/formats/social/social.module.ts new file mode 100644 index 000000000..0ee3677fa --- /dev/null +++ b/src/core/course/formats/social/social.module.ts @@ -0,0 +1,32 @@ +// (C) Copyright 2015 Martin Dougiamas +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { NgModule } from '@angular/core'; +import { CoreCourseFormatSocialHandler } from './providers/handler'; +import { CoreCourseFormatDelegate } from '../../providers/format-delegate'; + +@NgModule({ + declarations: [], + imports: [ + ], + providers: [ + CoreCourseFormatSocialHandler + ], + exports: [] +}) +export class CoreCourseFormatSocialModule { + constructor(formatDelegate: CoreCourseFormatDelegate, handler: CoreCourseFormatSocialHandler) { + formatDelegate.registerHandler(handler); + } +}