diff --git a/src/addon/mod/feedback/components/index/index.html b/src/addon/mod/feedback/components/index/index.html index 12040b63d..ccefec125 100644 --- a/src/addon/mod/feedback/components/index/index.html +++ b/src/addon/mod/feedback/components/index/index.html @@ -144,8 +144,8 @@ -

{{item.number}}. {{ item.name }}

-

{{ item.label }}

+

{{item.number}}.

+

    diff --git a/src/addon/mod/feedback/feedback.module.ts b/src/addon/mod/feedback/feedback.module.ts index 3a1f67923..494e1769d 100644 --- a/src/addon/mod/feedback/feedback.module.ts +++ b/src/addon/mod/feedback/feedback.module.ts @@ -24,6 +24,8 @@ import { AddonModFeedbackLinkHandler } from './providers/link-handler'; import { AddonModFeedbackAnalysisLinkHandler } from './providers/analysis-link-handler'; import { AddonModFeedbackShowEntriesLinkHandler } from './providers/show-entries-link-handler'; import { AddonModFeedbackShowNonRespondentsLinkHandler } from './providers/show-non-respondents-link-handler'; +import { AddonModFeedbackCompleteLinkHandler } from './providers/complete-link-handler'; +import { AddonModFeedbackPrintLinkHandler } from './providers/print-link-handler'; import { AddonModFeedbackHelperProvider } from './providers/helper'; import { AddonModFeedbackPrefetchHandler } from './providers/prefetch-handler'; import { AddonModFeedbackSyncProvider } from './providers/sync'; @@ -45,6 +47,8 @@ import { AddonModFeedbackOfflineProvider } from './providers/offline'; AddonModFeedbackAnalysisLinkHandler, AddonModFeedbackShowEntriesLinkHandler, AddonModFeedbackShowNonRespondentsLinkHandler, + AddonModFeedbackCompleteLinkHandler, + AddonModFeedbackPrintLinkHandler, AddonModFeedbackSyncCronHandler, AddonModFeedbackSyncProvider, AddonModFeedbackOfflineProvider @@ -57,13 +61,17 @@ export class AddonModFeedbackModule { cronDelegate: CoreCronDelegate, syncHandler: AddonModFeedbackSyncCronHandler, analysisLinkHandler: AddonModFeedbackAnalysisLinkHandler, showEntriesLinkHandler: AddonModFeedbackShowEntriesLinkHandler, - showNonRespondentsLinkHandler: AddonModFeedbackShowNonRespondentsLinkHandler) { + showNonRespondentsLinkHandler: AddonModFeedbackShowNonRespondentsLinkHandler, + completeLinkHandler: AddonModFeedbackCompleteLinkHandler, + printLinkHandler: AddonModFeedbackPrintLinkHandler) { moduleDelegate.registerHandler(moduleHandler); prefetchDelegate.registerHandler(prefetchHandler); contentLinksDelegate.registerHandler(linkHandler); contentLinksDelegate.registerHandler(analysisLinkHandler); contentLinksDelegate.registerHandler(showEntriesLinkHandler); contentLinksDelegate.registerHandler(showNonRespondentsLinkHandler); + contentLinksDelegate.registerHandler(completeLinkHandler); + contentLinksDelegate.registerHandler(printLinkHandler); cronDelegate.register(syncHandler); } } diff --git a/src/addon/mod/feedback/pages/attempt/attempt.html b/src/addon/mod/feedback/pages/attempt/attempt.html index f3e10d3ff..40df1356b 100644 --- a/src/addon/mod/feedback/pages/attempt/attempt.html +++ b/src/addon/mod/feedback/pages/attempt/attempt.html @@ -23,7 +23,7 @@

    - {{item.itemnumber}}. {{ item.name }} + {{item.itemnumber}}.

    diff --git a/src/addon/mod/feedback/pages/form/form.html b/src/addon/mod/feedback/pages/form/form.html index 22a9b8689..591b17a1d 100644 --- a/src/addon/mod/feedback/pages/form/form.html +++ b/src/addon/mod/feedback/pages/form/form.html @@ -16,7 +16,8 @@ - {{item.itemnumber}}. {{ item.name }} + {{item.itemnumber}}. +
    @@ -36,20 +37,20 @@ - {{option.label}} + - {{option.label}} + - {{option.label}} + diff --git a/src/addon/mod/feedback/providers/analysis-link-handler.ts b/src/addon/mod/feedback/providers/analysis-link-handler.ts index 12f03a387..8f8fa3c39 100644 --- a/src/addon/mod/feedback/providers/analysis-link-handler.ts +++ b/src/addon/mod/feedback/providers/analysis-link-handler.ts @@ -27,7 +27,7 @@ import { CoreDomUtilsProvider } from '@providers/utils/dom'; @Injectable() export class AddonModFeedbackAnalysisLinkHandler extends CoreContentLinksHandlerBase { name = 'AddonModFeedbackAnalysisLinkHandler'; - featureName = '$mmCourseDelegate_mmaModFeedback'; + featureName = 'CoreCourseModuleDelegate_AddonModFeedback'; pattern = /\/mod\/feedback\/analysis\.php.*([\&\?]id=\d+)/; constructor(private linkHelper: CoreContentLinksHelperProvider, private feedbackProvider: AddonModFeedbackProvider, diff --git a/src/addon/mod/feedback/providers/complete-link-handler.ts b/src/addon/mod/feedback/providers/complete-link-handler.ts new file mode 100644 index 000000000..af4b1153a --- /dev/null +++ b/src/addon/mod/feedback/providers/complete-link-handler.ts @@ -0,0 +1,89 @@ +// (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 { CoreContentLinksHandlerBase } from '@core/contentlinks/classes/base-handler'; +import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate'; +import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper'; +import { AddonModFeedbackProvider } from './feedback'; +import { CoreCourseProvider } from '@core/course/providers/course'; +import { CoreDomUtilsProvider } from '@providers/utils/dom'; + +/** + * Content links handler for feedback complete questions. + * Match mod/feedback/complete.php with a valid feedback id. + */ +@Injectable() +export class AddonModFeedbackCompleteLinkHandler extends CoreContentLinksHandlerBase { + name = 'AddonModFeedbackCompleteLinkHandler'; + featureName = 'CoreCourseModuleDelegate_AddonModFeedback'; + pattern = /\/mod\/feedback\/complete\.php.*([\?\&](id|gopage)=\d+)/; + + constructor(private linkHelper: CoreContentLinksHelperProvider, private feedbackProvider: AddonModFeedbackProvider, + private courseProvider: CoreCourseProvider, private domUtils: CoreDomUtilsProvider) { + super(); + } + + /** + * Get the list of actions for a link (url). + * + * @param {string[]} siteIds List of sites the URL belongs to. + * @param {string} url The URL to treat. + * @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1} + * @param {number} [courseId] Course ID related to the URL. Optional but recommended. + * @return {CoreContentLinksAction[]|Promise} List of (or promise resolved with list of) actions. + */ + getActions(siteIds: string[], url: string, params: any, courseId?: number): + CoreContentLinksAction[] | Promise { + return [{ + action: (siteId, navCtrl?): void => { + const modal = this.domUtils.showModalLoading(), + moduleId = params.id; + + this.courseProvider.getModuleBasicInfo(moduleId, siteId).then((module) => { + const stateParams = { + module: module, + moduleId: module.id, + courseId: module.course + }; + if (typeof params.gopage == 'undefined') { + stateParams['page'] = parseInt(params.gopage, 10); + } + + return this.linkHelper.goInSite(navCtrl, 'AddonModFeedbackFormPage', stateParams, siteId); + }).finally(() => { + modal.dismiss(); + }); + } + }]; + } + + /** + * Check if the handler is enabled for a certain site (site + user) and a URL. + * If not defined, defaults to true. + * + * @param {string} siteId The site ID. + * @param {string} url The URL to treat. + * @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1} + * @param {number} [courseId] Course ID related to the URL. Optional but recommended. + * @return {boolean|Promise} Whether the handler is enabled for the URL and site. + */ + isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise { + if (typeof params.id == 'undefined') { + return false; + } + + return this.feedbackProvider.isPluginEnabled(siteId); + } +} diff --git a/src/addon/mod/feedback/providers/module-handler.ts b/src/addon/mod/feedback/providers/module-handler.ts index 725565779..59dbbdd67 100644 --- a/src/addon/mod/feedback/providers/module-handler.ts +++ b/src/addon/mod/feedback/providers/module-handler.ts @@ -24,7 +24,8 @@ import { AddonModFeedbackProvider } from './feedback'; */ @Injectable() export class AddonModFeedbackModuleHandler implements CoreCourseModuleHandler { - name = 'feedback'; + name = 'AddonModFeedback'; + modName = 'feedback'; constructor(private courseProvider: CoreCourseProvider, private feedbackProvider: AddonModFeedbackProvider) { } diff --git a/src/addon/mod/feedback/providers/print-link-handler.ts b/src/addon/mod/feedback/providers/print-link-handler.ts new file mode 100644 index 000000000..3be523950 --- /dev/null +++ b/src/addon/mod/feedback/providers/print-link-handler.ts @@ -0,0 +1,87 @@ +// (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 { CoreContentLinksHandlerBase } from '@core/contentlinks/classes/base-handler'; +import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate'; +import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper'; +import { AddonModFeedbackProvider } from './feedback'; +import { CoreCourseProvider } from '@core/course/providers/course'; +import { CoreDomUtilsProvider } from '@providers/utils/dom'; + +/** + * Content links handler for feedback print questions. + * Match mod/feedback/print.php with a valid feedback id. + */ +@Injectable() +export class AddonModFeedbackPrintLinkHandler extends CoreContentLinksHandlerBase { + name = 'AddonModFeedbackPrintLinkHandler'; + featureName = 'CoreCourseModuleDelegate_AddonModFeedback'; + pattern = /\/mod\/feedback\/print\.php.*([\?\&](id)=\d+)/; + + constructor(private linkHelper: CoreContentLinksHelperProvider, private feedbackProvider: AddonModFeedbackProvider, + private courseProvider: CoreCourseProvider, private domUtils: CoreDomUtilsProvider) { + super(); + } + + /** + * Get the list of actions for a link (url). + * + * @param {string[]} siteIds List of sites the URL belongs to. + * @param {string} url The URL to treat. + * @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1} + * @param {number} [courseId] Course ID related to the URL. Optional but recommended. + * @return {CoreContentLinksAction[]|Promise} List of (or promise resolved with list of) actions. + */ + getActions(siteIds: string[], url: string, params: any, courseId?: number): + CoreContentLinksAction[] | Promise { + return [{ + action: (siteId, navCtrl?): void => { + const modal = this.domUtils.showModalLoading(), + moduleId = params.id; + + this.courseProvider.getModuleBasicInfo(moduleId, siteId).then((module) => { + const stateParams = { + module: module, + moduleId: module.id, + courseId: module.course, + preview: true + }; + + return this.linkHelper.goInSite(navCtrl, 'AddonModFeedbackFormPage', stateParams, siteId); + }).finally(() => { + modal.dismiss(); + }); + } + }]; + } + + /** + * Check if the handler is enabled for a certain site (site + user) and a URL. + * If not defined, defaults to true. + * + * @param {string} siteId The site ID. + * @param {string} url The URL to treat. + * @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1} + * @param {number} [courseId] Course ID related to the URL. Optional but recommended. + * @return {boolean|Promise} Whether the handler is enabled for the URL and site. + */ + isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise { + if (typeof params.id == 'undefined') { + return false; + } + + return this.feedbackProvider.isPluginEnabled(siteId); + } +} diff --git a/src/addon/mod/feedback/providers/show-entries-link-handler.ts b/src/addon/mod/feedback/providers/show-entries-link-handler.ts index 74e61ff5e..f640c9163 100644 --- a/src/addon/mod/feedback/providers/show-entries-link-handler.ts +++ b/src/addon/mod/feedback/providers/show-entries-link-handler.ts @@ -27,7 +27,7 @@ import { CoreDomUtilsProvider } from '@providers/utils/dom'; @Injectable() export class AddonModFeedbackShowEntriesLinkHandler extends CoreContentLinksHandlerBase { name = 'AddonModFeedbackShowEntriesLinkHandler'; - featureName = '$mmCourseDelegate_mmaModFeedback'; + featureName = 'CoreCourseModuleDelegate_AddonModFeedback'; pattern = /\/mod\/feedback\/show_entries\.php.*([\?\&](id|showcompleted)=\d+)/; constructor(private linkHelper: CoreContentLinksHelperProvider, private feedbackProvider: AddonModFeedbackProvider, diff --git a/src/addon/mod/feedback/providers/show-non-respondents-link-handler.ts b/src/addon/mod/feedback/providers/show-non-respondents-link-handler.ts index 5d1ab4cb3..cb88ecaa3 100644 --- a/src/addon/mod/feedback/providers/show-non-respondents-link-handler.ts +++ b/src/addon/mod/feedback/providers/show-non-respondents-link-handler.ts @@ -27,7 +27,7 @@ import { CoreDomUtilsProvider } from '@providers/utils/dom'; @Injectable() export class AddonModFeedbackShowNonRespondentsLinkHandler extends CoreContentLinksHandlerBase { name = 'AddonModFeedbackShowNonRespondentsLinkHandler'; - featureName = '$mmCourseDelegate_mmaModFeedback'; + featureName = 'CoreCourseModuleDelegate_AddonModFeedback'; pattern = /\/mod\/feedback\/show_nonrespondents\.php.*([\?\&](id)=\d+)/; constructor(private linkHelper: CoreContentLinksHelperProvider, private feedbackProvider: AddonModFeedbackProvider,