From c3df04a9ac58c6aa35435b7e9d4a4d7788cdbd62 Mon Sep 17 00:00:00 2001 From: dpalou Date: Thu, 18 Oct 2018 11:04:04 +0200 Subject: [PATCH] MOBILE-1874 modules: Implement plugin_supports for modules --- .../mod/assign/providers/module-handler.ts | 16 +++++++ .../mod/book/providers/module-handler.ts | 13 +++++ .../mod/chat/providers/module-handler.ts | 12 +++++ .../mod/choice/providers/module-handler.ts | 13 +++++ .../mod/data/providers/module-handler.ts | 15 ++++++ .../mod/feedback/providers/module-handler.ts | 13 +++++ .../mod/folder/providers/module-handler.ts | 13 +++++ .../mod/forum/providers/module-handler.ts | 15 ++++++ .../mod/glossary/providers/module-handler.ts | 15 ++++++ .../mod/imscp/providers/module-handler.ts | 13 +++++ .../mod/label/providers/module-handler.ts | 14 ++++++ .../mod/lesson/providers/module-handler.ts | 13 +++++ src/addon/mod/lti/providers/module-handler.ts | 12 +++++ .../mod/page/providers/module-handler.ts | 13 +++++ .../mod/quiz/providers/module-handler.ts | 15 ++++++ .../mod/resource/providers/module-handler.ts | 12 +++++ .../mod/scorm/providers/module-handler.ts | 13 +++++ .../mod/survey/providers/module-handler.ts | 13 +++++ src/addon/mod/url/providers/module-handler.ts | 12 +++++ .../mod/wiki/providers/module-handler.ts | 14 ++++++ .../mod/workshop/providers/module-handler.ts | 12 +++++ src/core/constants.ts | 27 +++++++++++ src/core/course/providers/module-delegate.ts | 47 +++++++++++++++++++ 23 files changed, 355 insertions(+) diff --git a/src/addon/mod/assign/providers/module-handler.ts b/src/addon/mod/assign/providers/module-handler.ts index 4de424c27..5cd335bff 100644 --- a/src/addon/mod/assign/providers/module-handler.ts +++ b/src/addon/mod/assign/providers/module-handler.ts @@ -18,6 +18,7 @@ import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/cour import { CoreCourseProvider } from '@core/course/providers/course'; import { AddonModAssignProvider } from './assign'; import { AddonModAssignIndexComponent } from '../components/index/index'; +import { CoreConstants } from '@core/constants'; /** * Handler to support assign modules. @@ -27,6 +28,21 @@ export class AddonModAssignModuleHandler implements CoreCourseModuleHandler { name = 'AddonModAssign'; modName = 'assign'; + supportedFeatures = { + [CoreConstants.FEATURE_GROUPS]: true, + [CoreConstants.FEATURE_GROUPINGS]: true, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, + [CoreConstants.FEATURE_COMPLETION_HAS_RULES]: true, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: true, + [CoreConstants.FEATURE_GRADE_OUTCOMES]: true, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true, + [CoreConstants.FEATURE_ADVANCED_GRADING]: true, + [CoreConstants.FEATURE_PLAGIARISM]: true, + [CoreConstants.FEATURE_COMMENT]: true + }; + constructor(private courseProvider: CoreCourseProvider, private assignProvider: AddonModAssignProvider) { } /** diff --git a/src/addon/mod/book/providers/module-handler.ts b/src/addon/mod/book/providers/module-handler.ts index 7cae479c6..bffbf8038 100644 --- a/src/addon/mod/book/providers/module-handler.ts +++ b/src/addon/mod/book/providers/module-handler.ts @@ -18,6 +18,7 @@ import { AddonModBookProvider } from './book'; import { AddonModBookIndexComponent } from '../components/index/index'; import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/course/providers/module-delegate'; import { CoreCourseProvider } from '@core/course/providers/course'; +import { CoreConstants } from '@core/constants'; /** * Handler to support book modules. @@ -27,6 +28,18 @@ export class AddonModBookModuleHandler implements CoreCourseModuleHandler { name = 'AddonModBook'; modName = 'book'; + supportedFeatures = { + [CoreConstants.FEATURE_MOD_ARCHETYPE]: CoreConstants.MOD_ARCHETYPE_RESOURCE, + [CoreConstants.FEATURE_GROUPS]: false, + [CoreConstants.FEATURE_GROUPINGS]: false, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: false, + [CoreConstants.FEATURE_GRADE_OUTCOMES]: false, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true + }; + constructor(protected bookProvider: AddonModBookProvider, private courseProvider: CoreCourseProvider) { } /** diff --git a/src/addon/mod/chat/providers/module-handler.ts b/src/addon/mod/chat/providers/module-handler.ts index 848ed156e..9b29145c0 100644 --- a/src/addon/mod/chat/providers/module-handler.ts +++ b/src/addon/mod/chat/providers/module-handler.ts @@ -17,6 +17,7 @@ import { NavController, NavOptions } from 'ionic-angular'; import { AddonModChatIndexComponent } from '../components/index/index'; import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/course/providers/module-delegate'; import { CoreCourseProvider } from '@core/course/providers/course'; +import { CoreConstants } from '@core/constants'; /** * Handler to support chat modules. @@ -26,6 +27,17 @@ export class AddonModChatModuleHandler implements CoreCourseModuleHandler { name = 'AddonModChat'; modName = 'chat'; + supportedFeatures = { + [CoreConstants.FEATURE_GROUPS]: true, + [CoreConstants.FEATURE_GROUPINGS]: true, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: false, + [CoreConstants.FEATURE_GRADE_OUTCOMES]: true, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true + }; + constructor(private courseProvider: CoreCourseProvider) { } /** diff --git a/src/addon/mod/choice/providers/module-handler.ts b/src/addon/mod/choice/providers/module-handler.ts index 402f5555f..f9a26b2b9 100644 --- a/src/addon/mod/choice/providers/module-handler.ts +++ b/src/addon/mod/choice/providers/module-handler.ts @@ -17,6 +17,7 @@ import { NavController, NavOptions } from 'ionic-angular'; import { AddonModChoiceIndexComponent } from '../components/index/index'; import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/course/providers/module-delegate'; import { CoreCourseProvider } from '@core/course/providers/course'; +import { CoreConstants } from '@core/constants'; /** * Handler to support choice modules. @@ -26,6 +27,18 @@ export class AddonModChoiceModuleHandler implements CoreCourseModuleHandler { name = 'AddonModChoice'; modName = 'choice'; + supportedFeatures = { + [CoreConstants.FEATURE_GROUPS]: true, + [CoreConstants.FEATURE_GROUPINGS]: true, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, + [CoreConstants.FEATURE_COMPLETION_HAS_RULES]: true, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: false, + [CoreConstants.FEATURE_GRADE_OUTCOMES]: false, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true + }; + constructor(private courseProvider: CoreCourseProvider) { } /** diff --git a/src/addon/mod/data/providers/module-handler.ts b/src/addon/mod/data/providers/module-handler.ts index b741ec975..3fb8f5c7e 100644 --- a/src/addon/mod/data/providers/module-handler.ts +++ b/src/addon/mod/data/providers/module-handler.ts @@ -18,6 +18,7 @@ import { AddonModDataIndexComponent } from '../components/index/index'; import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/course/providers/module-delegate'; import { CoreCourseProvider } from '@core/course/providers/course'; import { AddonModDataProvider } from './data'; +import { CoreConstants } from '@core/constants'; /** * Handler to support data modules. @@ -27,6 +28,20 @@ export class AddonModDataModuleHandler implements CoreCourseModuleHandler { name = 'AddonModData'; modName = 'data'; + supportedFeatures = { + [CoreConstants.FEATURE_GROUPS]: true, + [CoreConstants.FEATURE_GROUPINGS]: true, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, + [CoreConstants.FEATURE_COMPLETION_HAS_RULES]: true, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: true, + [CoreConstants.FEATURE_GRADE_OUTCOMES]: true, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true, + [CoreConstants.FEATURE_RATE]: true, + [CoreConstants.FEATURE_COMMENT]: true + }; + constructor(private courseProvider: CoreCourseProvider, private dataProvider: AddonModDataProvider) { } /** diff --git a/src/addon/mod/feedback/providers/module-handler.ts b/src/addon/mod/feedback/providers/module-handler.ts index 59dbbdd67..26cc80e11 100644 --- a/src/addon/mod/feedback/providers/module-handler.ts +++ b/src/addon/mod/feedback/providers/module-handler.ts @@ -18,6 +18,7 @@ import { AddonModFeedbackIndexComponent } from '../components/index/index'; import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/course/providers/module-delegate'; import { CoreCourseProvider } from '@core/course/providers/course'; import { AddonModFeedbackProvider } from './feedback'; +import { CoreConstants } from '@core/constants'; /** * Handler to support feedback modules. @@ -27,6 +28,18 @@ export class AddonModFeedbackModuleHandler implements CoreCourseModuleHandler { name = 'AddonModFeedback'; modName = 'feedback'; + supportedFeatures = { + [CoreConstants.FEATURE_GROUPS]: true, + [CoreConstants.FEATURE_GROUPINGS]: true, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, + [CoreConstants.FEATURE_COMPLETION_HAS_RULES]: true, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: false, + [CoreConstants.FEATURE_GRADE_OUTCOMES]: false, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true + }; + constructor(private courseProvider: CoreCourseProvider, private feedbackProvider: AddonModFeedbackProvider) { } /** diff --git a/src/addon/mod/folder/providers/module-handler.ts b/src/addon/mod/folder/providers/module-handler.ts index 54899cb35..125cf11b9 100644 --- a/src/addon/mod/folder/providers/module-handler.ts +++ b/src/addon/mod/folder/providers/module-handler.ts @@ -17,6 +17,7 @@ import { NavController, NavOptions } from 'ionic-angular'; import { AddonModFolderIndexComponent } from '../components/index/index'; import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/course/providers/module-delegate'; import { CoreCourseProvider } from '@core/course/providers/course'; +import { CoreConstants } from '@core/constants'; /** * Handler to support folder modules. @@ -26,6 +27,18 @@ export class AddonModFolderModuleHandler implements CoreCourseModuleHandler { name = 'AddonModFolder'; modName = 'folder'; + supportedFeatures = { + [CoreConstants.FEATURE_MOD_ARCHETYPE]: CoreConstants.MOD_ARCHETYPE_RESOURCE, + [CoreConstants.FEATURE_GROUPS]: false, + [CoreConstants.FEATURE_GROUPINGS]: false, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: false, + [CoreConstants.FEATURE_GRADE_OUTCOMES]: false, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true + }; + constructor(private courseProvider: CoreCourseProvider) { } /** diff --git a/src/addon/mod/forum/providers/module-handler.ts b/src/addon/mod/forum/providers/module-handler.ts index fef8ce605..a44a05c3a 100644 --- a/src/addon/mod/forum/providers/module-handler.ts +++ b/src/addon/mod/forum/providers/module-handler.ts @@ -21,6 +21,7 @@ import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/cour import { CoreCourseProvider } from '@core/course/providers/course'; import { AddonModForumProvider } from './forum'; import { AddonModForumIndexComponent } from '../components/index/index'; +import { CoreConstants } from '@core/constants'; /** * Handler to support forum modules. @@ -30,6 +31,20 @@ export class AddonModForumModuleHandler implements CoreCourseModuleHandler { name = 'AddonModForum'; modName = 'forum'; + supportedFeatures = { + [CoreConstants.FEATURE_GROUPS]: true, + [CoreConstants.FEATURE_GROUPINGS]: true, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, + [CoreConstants.FEATURE_COMPLETION_HAS_RULES]: true, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: true, + [CoreConstants.FEATURE_GRADE_OUTCOMES]: true, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true, + [CoreConstants.FEATURE_RATE]: true, + [CoreConstants.FEATURE_PLAGIARISM]: true + }; + constructor(private courseProvider: CoreCourseProvider, private forumProvider: AddonModForumProvider, private translate: TranslateService, private eventsProvider: CoreEventsProvider, private sitesProvider: CoreSitesProvider) {} diff --git a/src/addon/mod/glossary/providers/module-handler.ts b/src/addon/mod/glossary/providers/module-handler.ts index ce81f445b..99f3b3a33 100644 --- a/src/addon/mod/glossary/providers/module-handler.ts +++ b/src/addon/mod/glossary/providers/module-handler.ts @@ -17,6 +17,7 @@ import { NavController, NavOptions } from 'ionic-angular'; import { AddonModGlossaryIndexComponent } from '../components/index/index'; import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/course/providers/module-delegate'; import { CoreCourseProvider } from '@core/course/providers/course'; +import { CoreConstants } from '@core/constants'; /** * Handler to support glossary modules. @@ -26,6 +27,20 @@ export class AddonModGlossaryModuleHandler implements CoreCourseModuleHandler { name = 'AddonModGlossary'; modName = 'glossary'; + supportedFeatures = { + [CoreConstants.FEATURE_GROUPS]: false, + [CoreConstants.FEATURE_GROUPINGS]: false, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, + [CoreConstants.FEATURE_COMPLETION_HAS_RULES]: true, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: true, + [CoreConstants.FEATURE_GRADE_OUTCOMES]: true, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true, + [CoreConstants.FEATURE_RATE]: true, + [CoreConstants.FEATURE_PLAGIARISM]: true + }; + constructor(private courseProvider: CoreCourseProvider) { } /** diff --git a/src/addon/mod/imscp/providers/module-handler.ts b/src/addon/mod/imscp/providers/module-handler.ts index 70cc43b6b..6f581bdc1 100644 --- a/src/addon/mod/imscp/providers/module-handler.ts +++ b/src/addon/mod/imscp/providers/module-handler.ts @@ -18,6 +18,7 @@ import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/cour import { CoreCourseProvider } from '@core/course/providers/course'; import { AddonModImscpIndexComponent } from '../components/index/index'; import { AddonModImscpProvider } from './imscp'; +import { CoreConstants } from '@core/constants'; /** * Handler to support IMSCP modules. @@ -27,6 +28,18 @@ export class AddonModImscpModuleHandler implements CoreCourseModuleHandler { name = 'AddonModImscp'; modName = 'imscp'; + supportedFeatures = { + [CoreConstants.FEATURE_MOD_ARCHETYPE]: CoreConstants.MOD_ARCHETYPE_RESOURCE, + [CoreConstants.FEATURE_GROUPS]: false, + [CoreConstants.FEATURE_GROUPINGS]: false, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: false, + [CoreConstants.FEATURE_GRADE_OUTCOMES]: false, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true + }; + constructor(private courseProvider: CoreCourseProvider, protected imscpProvider: AddonModImscpProvider) { } /** diff --git a/src/addon/mod/label/providers/module-handler.ts b/src/addon/mod/label/providers/module-handler.ts index f54871597..0e72fac14 100644 --- a/src/addon/mod/label/providers/module-handler.ts +++ b/src/addon/mod/label/providers/module-handler.ts @@ -14,6 +14,7 @@ import { Injectable, Injector } from '@angular/core'; import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/course/providers/module-delegate'; +import { CoreConstants } from '@core/constants'; /** * Handler to support label modules. @@ -23,6 +24,19 @@ export class AddonModLabelModuleHandler implements CoreCourseModuleHandler { name = 'AddonModLabel'; modName = 'label'; + supportedFeatures = { + [CoreConstants.FEATURE_MOD_ARCHETYPE]: CoreConstants.MOD_ARCHETYPE_RESOURCE, + [CoreConstants.FEATURE_IDNUMBER]: true, + [CoreConstants.FEATURE_GROUPS]: false, + [CoreConstants.FEATURE_GROUPINGS]: false, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: false, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: false, + [CoreConstants.FEATURE_GRADE_OUTCOMES]: false, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true + }; + constructor() { // Nothing to do. } diff --git a/src/addon/mod/lesson/providers/module-handler.ts b/src/addon/mod/lesson/providers/module-handler.ts index 6ff5f57f2..db384d8bf 100644 --- a/src/addon/mod/lesson/providers/module-handler.ts +++ b/src/addon/mod/lesson/providers/module-handler.ts @@ -18,6 +18,7 @@ import { AddonModLessonIndexComponent } from '../components/index/index'; import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/course/providers/module-delegate'; import { CoreCourseProvider } from '@core/course/providers/course'; import { AddonModLessonProvider } from './lesson'; +import { CoreConstants } from '@core/constants'; /** * Handler to support quiz modules. @@ -27,6 +28,18 @@ export class AddonModLessonModuleHandler implements CoreCourseModuleHandler { name = 'AddonModLesson'; modName = 'lesson'; + supportedFeatures = { + [CoreConstants.FEATURE_GROUPS]: true, + [CoreConstants.FEATURE_GROUPINGS]: true, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, + [CoreConstants.FEATURE_COMPLETION_HAS_RULES]: true, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: true, + [CoreConstants.FEATURE_GRADE_OUTCOMES]: true, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true + }; + constructor(private courseProvider: CoreCourseProvider, private lessonProvider: AddonModLessonProvider) { } /** diff --git a/src/addon/mod/lti/providers/module-handler.ts b/src/addon/mod/lti/providers/module-handler.ts index dfd0b38b4..b8525572c 100644 --- a/src/addon/mod/lti/providers/module-handler.ts +++ b/src/addon/mod/lti/providers/module-handler.ts @@ -23,6 +23,7 @@ import { CoreFilepoolProvider } from '@providers/filepool'; import { CoreSitesProvider } from '@providers/sites'; import { AddonModLtiIndexComponent } from '../components/index/index'; import { AddonModLtiProvider } from './lti'; +import { CoreConstants } from '@core/constants'; /** * Handler to support LTI modules. @@ -32,6 +33,17 @@ export class AddonModLtiModuleHandler implements CoreCourseModuleHandler { name = 'AddonModLti'; modName = 'lti'; + supportedFeatures = { + [CoreConstants.FEATURE_GROUPS]: false, + [CoreConstants.FEATURE_GROUPINGS]: false, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: true, + [CoreConstants.FEATURE_GRADE_OUTCOMES]: true, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true + }; + constructor(private appProvider: CoreAppProvider, private courseProvider: CoreCourseProvider, private domUtils: CoreDomUtilsProvider, diff --git a/src/addon/mod/page/providers/module-handler.ts b/src/addon/mod/page/providers/module-handler.ts index 69e04dd5d..dc5dd21ff 100644 --- a/src/addon/mod/page/providers/module-handler.ts +++ b/src/addon/mod/page/providers/module-handler.ts @@ -18,6 +18,7 @@ import { AddonModPageProvider } from './page'; import { AddonModPageIndexComponent } from '../components/index/index'; import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/course/providers/module-delegate'; import { CoreCourseProvider } from '@core/course/providers/course'; +import { CoreConstants } from '@core/constants'; /** * Handler to support page modules. @@ -27,6 +28,18 @@ export class AddonModPageModuleHandler implements CoreCourseModuleHandler { name = 'AddonModPage'; modName = 'page'; + supportedFeatures = { + [CoreConstants.FEATURE_MOD_ARCHETYPE]: CoreConstants.MOD_ARCHETYPE_RESOURCE, + [CoreConstants.FEATURE_GROUPS]: false, + [CoreConstants.FEATURE_GROUPINGS]: false, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: false, + [CoreConstants.FEATURE_GRADE_OUTCOMES]: false, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true + }; + constructor(private courseProvider: CoreCourseProvider, protected pageProvider: AddonModPageProvider) { } /** diff --git a/src/addon/mod/quiz/providers/module-handler.ts b/src/addon/mod/quiz/providers/module-handler.ts index de7e2af28..3c4f27c60 100644 --- a/src/addon/mod/quiz/providers/module-handler.ts +++ b/src/addon/mod/quiz/providers/module-handler.ts @@ -17,6 +17,7 @@ import { NavController, NavOptions } from 'ionic-angular'; import { AddonModQuizIndexComponent } from '../components/index/index'; import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/course/providers/module-delegate'; import { CoreCourseProvider } from '@core/course/providers/course'; +import { CoreConstants } from '@core/constants'; /** * Handler to support quiz modules. @@ -26,6 +27,20 @@ export class AddonModQuizModuleHandler implements CoreCourseModuleHandler { name = 'AddonModQuiz'; modName = 'quiz'; + supportedFeatures = { + [CoreConstants.FEATURE_GROUPS]: true, + [CoreConstants.FEATURE_GROUPINGS]: true, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, + [CoreConstants.FEATURE_COMPLETION_HAS_RULES]: true, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: true, + [CoreConstants.FEATURE_GRADE_OUTCOMES]: true, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true, + [CoreConstants.FEATURE_CONTROLS_GRADE_VISIBILITY]: true, + [CoreConstants.FEATURE_USES_QUESTIONS]: true + }; + constructor(private courseProvider: CoreCourseProvider) { } /** diff --git a/src/addon/mod/resource/providers/module-handler.ts b/src/addon/mod/resource/providers/module-handler.ts index 8976ba2cf..a03592261 100644 --- a/src/addon/mod/resource/providers/module-handler.ts +++ b/src/addon/mod/resource/providers/module-handler.ts @@ -34,6 +34,18 @@ export class AddonModResourceModuleHandler implements CoreCourseModuleHandler { name = 'AddonModResource'; modName = 'resource'; + supportedFeatures = { + [CoreConstants.FEATURE_MOD_ARCHETYPE]: CoreConstants.MOD_ARCHETYPE_RESOURCE, + [CoreConstants.FEATURE_GROUPS]: false, + [CoreConstants.FEATURE_GROUPINGS]: false, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: false, + [CoreConstants.FEATURE_GRADE_OUTCOMES]: false, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true + }; + protected statusObserver; constructor(protected resourceProvider: AddonModResourceProvider, private courseProvider: CoreCourseProvider, diff --git a/src/addon/mod/scorm/providers/module-handler.ts b/src/addon/mod/scorm/providers/module-handler.ts index 217c0c432..f5d2a649b 100644 --- a/src/addon/mod/scorm/providers/module-handler.ts +++ b/src/addon/mod/scorm/providers/module-handler.ts @@ -17,6 +17,7 @@ import { NavController, NavOptions } from 'ionic-angular'; import { AddonModScormIndexComponent } from '../components/index/index'; import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/course/providers/module-delegate'; import { CoreCourseProvider } from '@core/course/providers/course'; +import { CoreConstants } from '@core/constants'; /** * Handler to support SCORM modules. @@ -26,6 +27,18 @@ export class AddonModScormModuleHandler implements CoreCourseModuleHandler { name = 'AddonModScorm'; modName = 'scorm'; + supportedFeatures = { + [CoreConstants.FEATURE_GROUPS]: true, + [CoreConstants.FEATURE_GROUPINGS]: true, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, + [CoreConstants.FEATURE_COMPLETION_HAS_RULES]: true, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: true, + [CoreConstants.FEATURE_GRADE_OUTCOMES]: true, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true + }; + constructor(private courseProvider: CoreCourseProvider) { } /** diff --git a/src/addon/mod/survey/providers/module-handler.ts b/src/addon/mod/survey/providers/module-handler.ts index 01a526702..cc84664c7 100644 --- a/src/addon/mod/survey/providers/module-handler.ts +++ b/src/addon/mod/survey/providers/module-handler.ts @@ -17,6 +17,7 @@ import { NavController, NavOptions } from 'ionic-angular'; import { AddonModSurveyIndexComponent } from '../components/index/index'; import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/course/providers/module-delegate'; import { CoreCourseProvider } from '@core/course/providers/course'; +import { CoreConstants } from '@core/constants'; /** * Handler to support survey modules. @@ -26,6 +27,18 @@ export class AddonModSurveyModuleHandler implements CoreCourseModuleHandler { name = 'AddonModSurvey'; modName = 'survey'; + supportedFeatures = { + [CoreConstants.FEATURE_GROUPS]: true, + [CoreConstants.FEATURE_GROUPINGS]: true, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, + [CoreConstants.FEATURE_COMPLETION_HAS_RULES]: true, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: false, + [CoreConstants.FEATURE_GRADE_OUTCOMES]: false, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true + }; + constructor(private courseProvider: CoreCourseProvider) { } /** diff --git a/src/addon/mod/url/providers/module-handler.ts b/src/addon/mod/url/providers/module-handler.ts index e182343fb..7043c23e1 100644 --- a/src/addon/mod/url/providers/module-handler.ts +++ b/src/addon/mod/url/providers/module-handler.ts @@ -31,6 +31,18 @@ export class AddonModUrlModuleHandler implements CoreCourseModuleHandler { name = 'AddonModUrl'; modName = 'url'; + supportedFeatures = { + [CoreConstants.FEATURE_MOD_ARCHETYPE]: CoreConstants.MOD_ARCHETYPE_RESOURCE, + [CoreConstants.FEATURE_GROUPS]: false, + [CoreConstants.FEATURE_GROUPINGS]: false, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: false, + [CoreConstants.FEATURE_GRADE_OUTCOMES]: false, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true + }; + constructor(private courseProvider: CoreCourseProvider, private urlProvider: AddonModUrlProvider, private urlHelper: AddonModUrlHelperProvider, private domUtils: CoreDomUtilsProvider, private contentLinksHelper: CoreContentLinksHelperProvider) { } diff --git a/src/addon/mod/wiki/providers/module-handler.ts b/src/addon/mod/wiki/providers/module-handler.ts index 80a514580..f36fc1bbb 100644 --- a/src/addon/mod/wiki/providers/module-handler.ts +++ b/src/addon/mod/wiki/providers/module-handler.ts @@ -17,6 +17,7 @@ import { NavController, NavOptions } from 'ionic-angular'; import { AddonModWikiIndexComponent } from '../components/index/index'; import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/course/providers/module-delegate'; import { CoreCourseProvider } from '@core/course/providers/course'; +import { CoreConstants } from '@core/constants'; /** * Handler to support wiki modules. @@ -26,6 +27,19 @@ export class AddonModWikiModuleHandler implements CoreCourseModuleHandler { name = 'AddonModWiki'; modName = 'wiki'; + supportedFeatures = { + [CoreConstants.FEATURE_GROUPS]: true, + [CoreConstants.FEATURE_GROUPINGS]: true, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: false, + [CoreConstants.FEATURE_GRADE_OUTCOMES]: false, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true, + [CoreConstants.FEATURE_RATE]: false, + [CoreConstants.FEATURE_COMMENT]: true + }; + constructor(private courseProvider: CoreCourseProvider) { } /** diff --git a/src/addon/mod/workshop/providers/module-handler.ts b/src/addon/mod/workshop/providers/module-handler.ts index bb275e5d9..56ed78ded 100644 --- a/src/addon/mod/workshop/providers/module-handler.ts +++ b/src/addon/mod/workshop/providers/module-handler.ts @@ -18,6 +18,7 @@ import { AddonModWorkshopIndexComponent } from '../components/index/index'; import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/course/providers/module-delegate'; import { CoreCourseProvider } from '@core/course/providers/course'; import { AddonModWorkshopProvider } from './workshop'; +import { CoreConstants } from '@core/constants'; /** * Handler to support workshop modules. @@ -27,6 +28,17 @@ export class AddonModWorkshopModuleHandler implements CoreCourseModuleHandler { name = 'AddonModWorkshop'; modName = 'workshop'; + supportedFeatures = { + [CoreConstants.FEATURE_GROUPS]: true, + [CoreConstants.FEATURE_GROUPINGS]: true, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: true, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true, + [CoreConstants.FEATURE_PLAGIARISM]: true + }; + constructor(private courseProvider: CoreCourseProvider, private workshopProvider: AddonModWorkshopProvider) { } /** diff --git a/src/core/constants.ts b/src/core/constants.ts index 4caf81a4d..79e131672 100644 --- a/src/core/constants.ts +++ b/src/core/constants.ts @@ -57,4 +57,31 @@ export class CoreConstants { static RESOURCELIB_DISPLAY_DOWNLOAD = 4; // Force download of file instead of display. static RESOURCELIB_DISPLAY_OPEN = 5; // Open directly. static RESOURCELIB_DISPLAY_POPUP = 6; // Open in "emulated" pop-up without navigation. + + // Feature constants. Used to report features that are, or are not, supported by a module. + static FEATURE_GRADE_HAS_GRADE = 'grade_has_grade'; // True if module can provide a grade. + static FEATURE_GRADE_OUTCOMES = 'outcomes'; // True if module supports outcomes. + static FEATURE_ADVANCED_GRADING = 'grade_advanced_grading'; // True if module supports advanced grading methods. + static FEATURE_CONTROLS_GRADE_VISIBILITY = 'controlsgradevisbility'; // True if module controls grade visibility over gradebook. + static FEATURE_PLAGIARISM = 'plagiarism'; // True if module supports plagiarism plugins. + static FEATURE_COMPLETION_TRACKS_VIEWS = 'completion_tracks_views'; // True if module tracks whether somebody viewed it. + static FEATURE_COMPLETION_HAS_RULES = 'completion_has_rules'; // True if module has custom completion rules. + static FEATURE_NO_VIEW_LINK = 'viewlink'; // True if module has no 'view' page (like label). + static FEATURE_IDNUMBER = 'idnumber'; // True if module wants support for setting the ID number for grade calculation purposes. + static FEATURE_GROUPS = 'groups'; // True if module supports groups. + static FEATURE_GROUPINGS = 'groupings'; // True if module supports groupings. + static FEATURE_MOD_ARCHETYPE = 'mod_archetype'; // Type of module. + static FEATURE_MOD_INTRO = 'mod_intro'; // True if module supports intro editor. + static FEATURE_MODEDIT_DEFAULT_COMPLETION = 'modedit_default_completion'; // True if module has default completion. + static FEATURE_COMMENT = 'comment'; + static FEATURE_RATE = 'rate'; + static FEATURE_BACKUP_MOODLE2 = 'backup_moodle2'; // True if module supports backup/restore of moodle2 format. + static FEATURE_SHOW_DESCRIPTION = 'showdescription'; // True if module can show description on course main page. + static FEATURE_USES_QUESTIONS = 'usesquestions'; // True if module uses the question bank. + + // Pssobile archetypes for modules. + static MOD_ARCHETYPE_OTHER = 0; // Unspecified module archetype. + static MOD_ARCHETYPE_RESOURCE = 1; // Resource-like type module. + static MOD_ARCHETYPE_ASSIGNMENT = 2; // Assignment module archetype. + static MOD_ARCHETYPE_SYSTEM = 3; // System (not user-addable) module archetype. } diff --git a/src/core/course/providers/module-delegate.ts b/src/core/course/providers/module-delegate.ts index 459110be2..5a95209f7 100644 --- a/src/core/course/providers/module-delegate.ts +++ b/src/core/course/providers/module-delegate.ts @@ -33,6 +33,14 @@ export interface CoreCourseModuleHandler extends CoreDelegateHandler { */ modName: string; + /** + * List of supported features. The keys should be the name of the feature. + * This is to replicate the "plugin_supports" function of Moodle. + * If you need some dynamic checks please implement the supportsFeature function. + * @type {{[name: string]: any}} + */ + supportedFeatures?: {[name: string]: any}; + /** * Get the data required to display the module in the course contents view. * @@ -62,6 +70,15 @@ export interface CoreCourseModuleHandler extends CoreDelegateHandler { * @return {boolean} Whether the refresher should be displayed. */ displayRefresherInSingleActivity?(): boolean; + + /** + * Check if this type of module supports a certain feature. + * If this function is implemented, the supportedFeatures object will be ignored. + * + * @param {string} feature The feature to check. + * @return {any} The result of the supports check. + */ + supportsFeature?(feature: string): any; } /** @@ -284,4 +301,34 @@ export class CoreCourseModuleDelegate extends CoreDelegate { displayRefresherInSingleActivity(modname: string): boolean { return this.executeFunctionOnEnabled(modname, 'displayRefresherInSingleActivity'); } + + /** + * Check if a certain type of module supports a certain feature. + * + * @param {string} modname The modname. + * @param {string} feature The feature to check. + * @param {any} defaultValue Value to return if the module is not supported or doesn't know if it's supported. + * @return {any} The result of the supports check. + */ + supportsFeature(modname: string, feature: string, defaultValue: any): any { + const handler = this.enabledHandlers[modname]; + let result; + + if (handler) { + if (handler['supportsFeature']) { + // The handler specified a function to determine the feature, use it. + result = handler['supportsFeature'].apply(handler, [feature]); + } else if (handler['supportedFeatures']) { + // Handler has an object to determine the feature, use it. + result = handler['supportedFeatures'][feature]; + } + } + + if (result === null || typeof result == 'undefined') { + // Not supported or doesn't know, return defaul. + return defaultValue; + } else { + return result; + } + } }