MOBILE-4616 feedback: Move feedback constants to a file
parent
bc1e3f00e7
commit
4934dcec99
|
@ -16,13 +16,13 @@ import { CoreRoutedItemsManagerSource } from '@classes/items-management/routed-i
|
|||
import { CoreGroupInfo, CoreGroups } from '@services/groups';
|
||||
import {
|
||||
AddonModFeedback,
|
||||
AddonModFeedbackProvider,
|
||||
AddonModFeedbackWSAnonAttempt,
|
||||
AddonModFeedbackWSAttempt,
|
||||
AddonModFeedbackWSFeedback,
|
||||
} from '../services/feedback';
|
||||
import { AddonModFeedbackHelper } from '../services/feedback-helper';
|
||||
import { Params } from '@angular/router';
|
||||
import { ADDON_MOD_FEEDBACK_PER_PAGE } from '../constants';
|
||||
|
||||
/**
|
||||
* Feedback attempts.
|
||||
|
@ -120,7 +120,7 @@ export class AddonModFeedbackAttemptsSource extends CoreRoutedItemsManagerSource
|
|||
* @inheritdoc
|
||||
*/
|
||||
protected getPageLength(): number {
|
||||
return AddonModFeedbackProvider.PER_PAGE;
|
||||
return ADDON_MOD_FEEDBACK_PER_PAGE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -146,10 +146,10 @@ export class AddonModFeedbackAttemptsSource extends CoreRoutedItemsManagerSource
|
|||
const pageAttempts: AddonModFeedbackAttemptItem[] = [
|
||||
// The page argument is ignored in the webservice when there is only one page,
|
||||
// so we should ignore the responses of pages beyond the first if that's the case.
|
||||
...(page === 0 || result.totalattempts > AddonModFeedbackProvider.PER_PAGE)
|
||||
...(page === 0 || result.totalattempts > ADDON_MOD_FEEDBACK_PER_PAGE)
|
||||
? result.attempts
|
||||
: [],
|
||||
...(page === 0 || result.totalanonattempts > AddonModFeedbackProvider.PER_PAGE)
|
||||
...(page === 0 || result.totalanonattempts > ADDON_MOD_FEEDBACK_PER_PAGE)
|
||||
? result.anonattempts
|
||||
: [],
|
||||
];
|
||||
|
|
|
@ -27,7 +27,6 @@ import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
|||
import {
|
||||
AddonModFeedback,
|
||||
AddonModFeedbackGetFeedbackAccessInformationWSResponse,
|
||||
AddonModFeedbackProvider,
|
||||
AddonModFeedbackWSFeedback,
|
||||
AddonModFeedbackWSItem,
|
||||
} from '../../services/feedback';
|
||||
|
@ -38,8 +37,8 @@ import {
|
|||
AddonModFeedbackSyncProvider,
|
||||
AddonModFeedbackSyncResult,
|
||||
} from '../../services/feedback-sync';
|
||||
import { AddonModFeedbackModuleHandlerService } from '../../services/handlers/module';
|
||||
import { AddonModFeedbackPrefetchHandler } from '../../services/handlers/prefetch';
|
||||
import { ADDON_MOD_FEEDBACK_COMPONENT, ADDON_MOD_FEEDBACK_FORM_SUBMITTED, ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants';
|
||||
|
||||
/**
|
||||
* Component that displays a feedback index page.
|
||||
|
@ -55,7 +54,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
|
|||
@Input() tab = 'overview';
|
||||
@Input() group = 0;
|
||||
|
||||
component = AddonModFeedbackProvider.COMPONENT;
|
||||
component = ADDON_MOD_FEEDBACK_COMPONENT;
|
||||
pluginName = 'feedback';
|
||||
feedback?: AddonModFeedbackWSFeedback;
|
||||
goPage?: number;
|
||||
|
@ -92,7 +91,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
|
|||
super('AddonModLessonIndexComponent', content, courseContentsPage);
|
||||
|
||||
// Listen for form submit events.
|
||||
this.submitObserver = CoreEvents.on(AddonModFeedbackProvider.FORM_SUBMITTED, async (data) => {
|
||||
this.submitObserver = CoreEvents.on(ADDON_MOD_FEEDBACK_FORM_SUBMITTED, async (data) => {
|
||||
if (!this.feedback || data.feedbackId != this.feedback.id) {
|
||||
return;
|
||||
}
|
||||
|
@ -374,7 +373,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
|
|||
*/
|
||||
gotoAnswerQuestions(preview: boolean = false): void {
|
||||
CoreNavigator.navigateToSitePath(
|
||||
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${this.courseId}/${this.module.id}/form`,
|
||||
ADDON_MOD_FEEDBACK_PAGE_NAME + `/${this.courseId}/${this.module.id}/form`,
|
||||
{
|
||||
params: {
|
||||
preview,
|
||||
|
@ -407,7 +406,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
|
|||
*/
|
||||
openNonRespondents(): void {
|
||||
CoreNavigator.navigateToSitePath(
|
||||
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${this.courseId}/${this.module.id}/nonrespondents`,
|
||||
ADDON_MOD_FEEDBACK_PAGE_NAME + `/${this.courseId}/${this.module.id}/nonrespondents`,
|
||||
{
|
||||
params: {
|
||||
group: this.group,
|
||||
|
@ -425,7 +424,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
|
|||
}
|
||||
|
||||
CoreNavigator.navigateToSitePath(
|
||||
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${this.courseId}/${this.module.id}/attempts`,
|
||||
ADDON_MOD_FEEDBACK_PAGE_NAME + `/${this.courseId}/${this.module.id}/attempts`,
|
||||
{
|
||||
params: {
|
||||
group: this.group,
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
// (C) Copyright 2015 Moodle Pty Ltd.
|
||||
//
|
||||
// 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.
|
||||
|
||||
export const ADDON_MOD_FEEDBACK_COMPONENT = 'mmaModFeedback';
|
||||
|
||||
export const ADDON_MOD_FEEDBACK_PAGE_NAME = 'mod_feedback';
|
||||
|
||||
export const ADDON_MOD_FEEDBACK_FORM_SUBMITTED = 'addon_mod_feedback_form_submitted';
|
||||
export const ADDON_MOD_FEEDBACK_LINE_SEP = '|';
|
||||
export const ADDON_MOD_FEEDBACK_MULTICHOICE_TYPE_SEP = '>>>>>';
|
||||
export const ADDON_MOD_FEEDBACK_MULTICHOICE_ADJUST_SEP = '<<<<<';
|
||||
export const ADDON_MOD_FEEDBACK_MULTICHOICE_HIDENOSELECT = 'h';
|
||||
export const ADDON_MOD_FEEDBACK_MULTICHOICERATED_VALUE_SEP = '####';
|
||||
|
||||
export const ADDON_MOD_FEEDBACK_PER_PAGE = 20;
|
|
@ -86,4 +86,4 @@ const routes: Routes = [
|
|||
AddonModFeedbackAttemptPage,
|
||||
],
|
||||
})
|
||||
export class AddonModFeedbackLazyModule {}
|
||||
export default class AddonModFeedbackLazyModule {}
|
||||
|
|
|
@ -23,23 +23,23 @@ import { CorePushNotificationsDelegate } from '@features/pushnotifications/servi
|
|||
import { CoreCronDelegate } from '@services/cron';
|
||||
import { CORE_SITE_SCHEMAS } from '@services/sites';
|
||||
import { OFFLINE_SITE_SCHEMA } from './services/database/feedback';
|
||||
import { AddonModFeedbackProvider } from './services/feedback';
|
||||
import { AddonModFeedbackAnalysisLinkHandler } from './services/handlers/analysis-link';
|
||||
import { AddonModFeedbackCompleteLinkHandler } from './services/handlers/complete-link';
|
||||
import { AddonModFeedbackIndexLinkHandler } from './services/handlers/index-link';
|
||||
import { AddonModFeedbackListLinkHandler } from './services/handlers/list-link';
|
||||
import { AddonModFeedbackModuleHandlerService, AddonModFeedbackModuleHandler } from './services/handlers/module';
|
||||
import { AddonModFeedbackModuleHandler } from './services/handlers/module';
|
||||
import { AddonModFeedbackPrefetchHandler } from './services/handlers/prefetch';
|
||||
import { AddonModFeedbackPrintLinkHandler } from './services/handlers/print-link';
|
||||
import { AddonModFeedbackPushClickHandler } from './services/handlers/push-click';
|
||||
import { AddonModFeedbackShowEntriesLinkHandler } from './services/handlers/show-entries-link';
|
||||
import { AddonModFeedbackShowNonRespondentsLinkHandler } from './services/handlers/show-non-respondents-link';
|
||||
import { AddonModFeedbackSyncCronHandler } from './services/handlers/sync-cron';
|
||||
import { ADDON_MOD_FEEDBACK_COMPONENT, ADDON_MOD_FEEDBACK_PAGE_NAME } from './constants';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: AddonModFeedbackModuleHandlerService.PAGE_NAME,
|
||||
loadChildren: () => import('./feedback-lazy.module').then(m => m.AddonModFeedbackLazyModule),
|
||||
path: ADDON_MOD_FEEDBACK_PAGE_NAME,
|
||||
loadChildren: () => import('./feedback-lazy.module'),
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -69,7 +69,7 @@ const routes: Routes = [
|
|||
CoreContentLinksDelegate.registerHandler(AddonModFeedbackShowNonRespondentsLinkHandler.instance);
|
||||
CorePushNotificationsDelegate.registerClickHandler(AddonModFeedbackPushClickHandler.instance);
|
||||
|
||||
CoreCourseHelper.registerModuleReminderClick(AddonModFeedbackProvider.COMPONENT);
|
||||
CoreCourseHelper.registerModuleReminderClick(ADDON_MOD_FEEDBACK_COMPONENT);
|
||||
},
|
||||
},
|
||||
],
|
||||
|
|
|
@ -22,13 +22,13 @@ import { CoreTextUtils } from '@services/utils/text';
|
|||
import { AddonModFeedbackAttemptsSource } from '../../classes/feedback-attempts-source';
|
||||
import {
|
||||
AddonModFeedback,
|
||||
AddonModFeedbackProvider,
|
||||
AddonModFeedbackWSAnonAttempt,
|
||||
AddonModFeedbackWSFeedback,
|
||||
} from '../../services/feedback';
|
||||
import { AddonModFeedbackAttempt, AddonModFeedbackFormItem, AddonModFeedbackHelper } from '../../services/feedback-helper';
|
||||
import { CoreTime } from '@singletons/time';
|
||||
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
||||
import { ADDON_MOD_FEEDBACK_COMPONENT } from '../../constants';
|
||||
|
||||
/**
|
||||
* Page that displays a feedback attempt review.
|
||||
|
@ -46,7 +46,7 @@ export class AddonModFeedbackAttemptPage implements OnInit, OnDestroy {
|
|||
attempts: AddonModFeedbackAttemptsSwipeManager;
|
||||
anonAttempt?: AddonModFeedbackWSAnonAttempt;
|
||||
items: AddonModFeedbackAttemptItem[] = [];
|
||||
component = AddonModFeedbackProvider.COMPONENT;
|
||||
component = ADDON_MOD_FEEDBACK_COMPONENT;
|
||||
loaded = false;
|
||||
|
||||
protected attemptId: number;
|
||||
|
|
|
@ -30,14 +30,13 @@ import {
|
|||
AddonModFeedback,
|
||||
AddonModFeedbackGetFeedbackAccessInformationWSResponse,
|
||||
AddonModFeedbackPageItems,
|
||||
AddonModFeedbackProvider,
|
||||
AddonModFeedbackResponseValue,
|
||||
AddonModFeedbackWSFeedback,
|
||||
} from '../../services/feedback';
|
||||
import { AddonModFeedbackFormItem, AddonModFeedbackHelper } from '../../services/feedback-helper';
|
||||
import { AddonModFeedbackSync } from '../../services/feedback-sync';
|
||||
import { AddonModFeedbackModuleHandlerService } from '../../services/handlers/module';
|
||||
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
||||
import { ADDON_MOD_FEEDBACK_COMPONENT, ADDON_MOD_FEEDBACK_FORM_SUBMITTED, ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants';
|
||||
|
||||
/**
|
||||
* Page that displays feedback form.
|
||||
|
@ -65,7 +64,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
|
|||
courseId!: number;
|
||||
feedback?: AddonModFeedbackWSFeedback;
|
||||
completionPageContents?: string;
|
||||
component = AddonModFeedbackProvider.COMPONENT;
|
||||
component = ADDON_MOD_FEEDBACK_COMPONENT;
|
||||
offline = false;
|
||||
feedbackLoaded = false;
|
||||
access?: AddonModFeedbackGetFeedbackAccessInformationWSResponse;
|
||||
|
@ -356,7 +355,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
|
|||
]);
|
||||
|
||||
// If form has been submitted, the info has been already invalidated but we should update index view.
|
||||
CoreEvents.trigger(AddonModFeedbackProvider.FORM_SUBMITTED, {
|
||||
CoreEvents.trigger(ADDON_MOD_FEEDBACK_FORM_SUBMITTED, {
|
||||
feedbackId: this.feedback!.id,
|
||||
tab: 'overview',
|
||||
offline: this.completedOffline,
|
||||
|
@ -373,7 +372,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
|
|||
// Invalidate access information so user will see home page updated (continue form).
|
||||
await AddonModFeedback.invalidateResumePageData(this.feedback!.id);
|
||||
|
||||
CoreEvents.trigger(AddonModFeedbackProvider.FORM_SUBMITTED, {
|
||||
CoreEvents.trigger(ADDON_MOD_FEEDBACK_FORM_SUBMITTED, {
|
||||
feedbackId: this.feedback!.id,
|
||||
tab: 'overview',
|
||||
offline: this.completedOffline,
|
||||
|
@ -395,7 +394,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
|
|||
showAnalysis(): void {
|
||||
if (this.fromIndex) {
|
||||
// Previous page is the index page, go back.
|
||||
CoreEvents.trigger(AddonModFeedbackProvider.FORM_SUBMITTED, {
|
||||
CoreEvents.trigger(ADDON_MOD_FEEDBACK_FORM_SUBMITTED, {
|
||||
feedbackId: this.feedback!.id,
|
||||
tab: 'analysis',
|
||||
offline: this.completedOffline,
|
||||
|
@ -406,7 +405,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
|
|||
return;
|
||||
}
|
||||
|
||||
CoreNavigator.navigateToSitePath(AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${this.courseId}/${this.cmId}`, {
|
||||
CoreNavigator.navigateToSitePath(ADDON_MOD_FEEDBACK_PAGE_NAME + `/${this.courseId}/${this.cmId}`, {
|
||||
params: {
|
||||
module: this.module,
|
||||
tab: 'analysis',
|
||||
|
|
|
@ -28,12 +28,18 @@ import {
|
|||
AddonModFeedbackGetResponsesAnalysisWSResponse,
|
||||
AddonModFeedbackGroupPaginatedOptions,
|
||||
AddonModFeedbackItem,
|
||||
AddonModFeedbackProvider,
|
||||
AddonModFeedbackResponseValue,
|
||||
AddonModFeedbackWSAttempt,
|
||||
AddonModFeedbackWSNonRespondent,
|
||||
} from './feedback';
|
||||
import { AddonModFeedbackModuleHandlerService } from './handlers/module';
|
||||
import {
|
||||
ADDON_MOD_FEEDBACK_LINE_SEP,
|
||||
ADDON_MOD_FEEDBACK_MULTICHOICE_TYPE_SEP,
|
||||
ADDON_MOD_FEEDBACK_MULTICHOICE_ADJUST_SEP,
|
||||
ADDON_MOD_FEEDBACK_MULTICHOICERATED_VALUE_SEP,
|
||||
ADDON_MOD_FEEDBACK_MULTICHOICE_HIDENOSELECT,
|
||||
ADDON_MOD_FEEDBACK_PAGE_NAME,
|
||||
} from '../constants';
|
||||
|
||||
const MODE_RESPONSETIME = 1;
|
||||
const MODE_COURSE = 2;
|
||||
|
@ -184,7 +190,7 @@ export class AddonModFeedbackHelperProvider {
|
|||
if (params.showcompleted === undefined) {
|
||||
// Param showcompleted not defined. Show entry list.
|
||||
await CoreNavigator.navigateToSitePath(
|
||||
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/attempts`,
|
||||
ADDON_MOD_FEEDBACK_PAGE_NAME + `/${module.course}/${module.id}/attempts`,
|
||||
{ siteId },
|
||||
);
|
||||
|
||||
|
@ -198,7 +204,7 @@ export class AddonModFeedbackHelperProvider {
|
|||
});
|
||||
|
||||
await CoreNavigator.navigateToSitePath(
|
||||
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/attempts/${attempt.id}`,
|
||||
ADDON_MOD_FEEDBACK_PAGE_NAME + `/${module.course}/${module.id}/attempts/${attempt.id}`,
|
||||
{
|
||||
params: {
|
||||
feedbackId: module.instance,
|
||||
|
@ -295,7 +301,7 @@ export class AddonModFeedbackHelperProvider {
|
|||
*/
|
||||
protected getItemFormNumeric(item: AddonModFeedbackItem): AddonModFeedbackNumericItem {
|
||||
|
||||
const range = item.presentation.split(AddonModFeedbackProvider.LINE_SEP) || [];
|
||||
const range = item.presentation.split(ADDON_MOD_FEEDBACK_LINE_SEP) || [];
|
||||
const rangeFrom = range.length > 0 ? parseInt(range[0], 10) : undefined;
|
||||
const rangeTo = range.length > 1 ? parseInt(range[1], 10) : undefined;
|
||||
|
||||
|
@ -320,7 +326,7 @@ export class AddonModFeedbackHelperProvider {
|
|||
protected getItemFormTextfield(item: AddonModFeedbackItem): AddonModFeedbackTextItem {
|
||||
return Object.assign(item, {
|
||||
templateName: 'textfield',
|
||||
length: Number(item.presentation.split(AddonModFeedbackProvider.LINE_SEP)[1]) || 255,
|
||||
length: Number(item.presentation.split(ADDON_MOD_FEEDBACK_LINE_SEP)[1]) || 255,
|
||||
value: item.rawValue !== undefined ? item.rawValue : '',
|
||||
slottedLabel: true,
|
||||
});
|
||||
|
@ -348,7 +354,7 @@ export class AddonModFeedbackHelperProvider {
|
|||
*/
|
||||
protected getItemFormMultichoice(item: AddonModFeedbackItem): AddonModFeedbackMultichoiceItem {
|
||||
|
||||
let parts = item.presentation.split(AddonModFeedbackProvider.MULTICHOICE_TYPE_SEP) || [];
|
||||
let parts = item.presentation.split(ADDON_MOD_FEEDBACK_MULTICHOICE_TYPE_SEP) || [];
|
||||
const subType = parts.length > 0 && parts[0] ? parts[0] : 'r';
|
||||
|
||||
const formItem: AddonModFeedbackMultichoiceItem = Object.assign(item, {
|
||||
|
@ -361,20 +367,20 @@ export class AddonModFeedbackHelperProvider {
|
|||
|
||||
formItem.presentation = parts.length > 1 ? parts[1] : '';
|
||||
if (formItem.subtype != 'd') {
|
||||
parts = formItem.presentation.split(AddonModFeedbackProvider.MULTICHOICE_ADJUST_SEP) || [];
|
||||
parts = formItem.presentation.split(ADDON_MOD_FEEDBACK_MULTICHOICE_ADJUST_SEP) || [];
|
||||
formItem.presentation = parts.length > 0 ? parts[0] : '';
|
||||
// Horizontal are not supported right now. item.horizontal = parts.length > 1 && !!parts[1];
|
||||
}
|
||||
|
||||
const choices = formItem.presentation.split(AddonModFeedbackProvider.LINE_SEP) || [];
|
||||
const choices = formItem.presentation.split(ADDON_MOD_FEEDBACK_LINE_SEP) || [];
|
||||
formItem.choices = choices.map((choice, index) => {
|
||||
const weightValue = choice.split(AddonModFeedbackProvider.MULTICHOICERATED_VALUE_SEP) || [''];
|
||||
const weightValue = choice.split(ADDON_MOD_FEEDBACK_MULTICHOICERATED_VALUE_SEP) || [''];
|
||||
choice = weightValue.length == 1 ? weightValue[0] : '(' + weightValue[0] + ') ' + weightValue[1];
|
||||
|
||||
return { value: index + 1, label: choice };
|
||||
});
|
||||
|
||||
if (formItem.subtype === 'r' && formItem.options.search(AddonModFeedbackProvider.MULTICHOICE_HIDENOSELECT) == -1) {
|
||||
if (formItem.subtype === 'r' && formItem.options.search(ADDON_MOD_FEEDBACK_MULTICHOICE_HIDENOSELECT) == -1) {
|
||||
formItem.choices.unshift({ value: 0, label: Translate.instant('addon.mod_feedback.not_selected') });
|
||||
formItem.value = formItem.rawValue !== undefined ? Number(formItem.rawValue) : 0;
|
||||
} else if (formItem.subtype === 'd') {
|
||||
|
@ -383,7 +389,7 @@ export class AddonModFeedbackHelperProvider {
|
|||
} else if (formItem.subtype === 'c') {
|
||||
if (formItem.rawValue !== undefined) {
|
||||
formItem.rawValue = String(formItem.rawValue);
|
||||
const values = formItem.rawValue.split(AddonModFeedbackProvider.LINE_SEP);
|
||||
const values = formItem.rawValue.split(ADDON_MOD_FEEDBACK_LINE_SEP);
|
||||
formItem.choices.forEach((choice) => {
|
||||
for (const x in values) {
|
||||
if (choice.value == Number(values[x])) {
|
||||
|
|
|
@ -24,9 +24,10 @@ import { CoreSync, CoreSyncResult } from '@services/sync';
|
|||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { makeSingleton, Translate } from '@singletons';
|
||||
import { CoreEvents } from '@singletons/events';
|
||||
import { AddonModFeedback, AddonModFeedbackProvider, AddonModFeedbackWSFeedback } from './feedback';
|
||||
import { AddonModFeedback, AddonModFeedbackWSFeedback } from './feedback';
|
||||
import { AddonModFeedbackOffline, AddonModFeedbackOfflineResponse } from './feedback-offline';
|
||||
import { AddonModFeedbackPrefetchHandler, AddonModFeedbackPrefetchHandlerService } from './handlers/prefetch';
|
||||
import { ADDON_MOD_FEEDBACK_COMPONENT } from '../constants';
|
||||
|
||||
/**
|
||||
* Service to sync feedbacks.
|
||||
|
@ -137,7 +138,7 @@ export class AddonModFeedbackSyncProvider extends CoreCourseActivitySyncBaseProv
|
|||
}
|
||||
|
||||
// Verify that feedback isn't blocked.
|
||||
if (CoreSync.isBlocked(AddonModFeedbackProvider.COMPONENT, feedbackId, siteId)) {
|
||||
if (CoreSync.isBlocked(ADDON_MOD_FEEDBACK_COMPONENT, feedbackId, siteId)) {
|
||||
this.logger.debug(`Cannot sync feedback '${feedbackId}' because it is blocked.`);
|
||||
|
||||
throw new CoreSyncBlockedError(Translate.instant('core.errorsyncblocked', { $a: this.componentTranslate }));
|
||||
|
@ -162,7 +163,7 @@ export class AddonModFeedbackSyncProvider extends CoreCourseActivitySyncBaseProv
|
|||
};
|
||||
|
||||
// Sync offline logs.
|
||||
await CoreUtils.ignoreErrors(CoreCourseLogHelper.syncActivity(AddonModFeedbackProvider.COMPONENT, feedbackId, siteId));
|
||||
await CoreUtils.ignoreErrors(CoreCourseLogHelper.syncActivity(ADDON_MOD_FEEDBACK_COMPONENT, feedbackId, siteId));
|
||||
|
||||
// Get offline responses to be sent.
|
||||
const responses = await CoreUtils.ignoreErrors(AddonModFeedbackOffline.getFeedbackResponses(feedbackId, siteId));
|
||||
|
|
|
@ -26,8 +26,15 @@ import { makeSingleton, Translate } from '@singletons';
|
|||
import { AddonModFeedbackOffline } from './feedback-offline';
|
||||
import { AddonModFeedbackAutoSyncData, AddonModFeedbackSyncProvider } from './feedback-sync';
|
||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
||||
|
||||
const ROOT_CACHE_KEY = 'AddonModFeedback:';
|
||||
import {
|
||||
ADDON_MOD_FEEDBACK_COMPONENT,
|
||||
ADDON_MOD_FEEDBACK_FORM_SUBMITTED,
|
||||
ADDON_MOD_FEEDBACK_LINE_SEP,
|
||||
ADDON_MOD_FEEDBACK_MULTICHOICE_ADJUST_SEP,
|
||||
ADDON_MOD_FEEDBACK_MULTICHOICE_TYPE_SEP,
|
||||
ADDON_MOD_FEEDBACK_MULTICHOICERATED_VALUE_SEP,
|
||||
ADDON_MOD_FEEDBACK_PER_PAGE,
|
||||
} from '../constants';
|
||||
|
||||
/**
|
||||
* Service that provides some features for feedbacks.
|
||||
|
@ -35,14 +42,7 @@ const ROOT_CACHE_KEY = 'AddonModFeedback:';
|
|||
@Injectable({ providedIn: 'root' })
|
||||
export class AddonModFeedbackProvider {
|
||||
|
||||
static readonly COMPONENT = 'mmaModFeedback';
|
||||
static readonly FORM_SUBMITTED = 'addon_mod_feedback_form_submitted';
|
||||
static readonly LINE_SEP = '|';
|
||||
static readonly MULTICHOICE_TYPE_SEP = '>>>>>';
|
||||
static readonly MULTICHOICE_ADJUST_SEP = '<<<<<';
|
||||
static readonly MULTICHOICE_HIDENOSELECT = 'h';
|
||||
static readonly MULTICHOICERATED_VALUE_SEP = '####';
|
||||
static readonly PER_PAGE = 20;
|
||||
protected static readonly ROOT_CACHE_KEY = 'AddonModFeedback:';
|
||||
|
||||
/**
|
||||
* Check dependency of a question item.
|
||||
|
@ -80,11 +80,11 @@ export class AddonModFeedbackProvider {
|
|||
* @returns Return true if dependency is acomplished and it can be shown. False, otherwise.
|
||||
*/
|
||||
protected compareDependItemMultichoice(item: AddonModFeedbackItem, dependValue: string): boolean {
|
||||
const parts = item.presentation.split(AddonModFeedbackProvider.MULTICHOICE_TYPE_SEP) || [];
|
||||
const parts = item.presentation.split(ADDON_MOD_FEEDBACK_MULTICHOICE_TYPE_SEP) || [];
|
||||
const subtype = parts.length > 0 && parts[0] ? parts[0] : 'r';
|
||||
|
||||
const choicesStr = (parts[1] || '').split(AddonModFeedbackProvider.MULTICHOICE_ADJUST_SEP)[0] || '';
|
||||
const choices = choicesStr.split(AddonModFeedbackProvider.LINE_SEP) || [];
|
||||
const choicesStr = (parts[1] || '').split(ADDON_MOD_FEEDBACK_MULTICHOICE_ADJUST_SEP)[0] || '';
|
||||
const choices = choicesStr.split(ADDON_MOD_FEEDBACK_LINE_SEP) || [];
|
||||
let values: AddonModFeedbackResponseValue[];
|
||||
|
||||
if (subtype === 'c') {
|
||||
|
@ -92,7 +92,7 @@ export class AddonModFeedbackProvider {
|
|||
values = [''];
|
||||
} else {
|
||||
item.rawValue = '' + item.rawValue;
|
||||
values = item.rawValue.split(AddonModFeedbackProvider.LINE_SEP);
|
||||
values = item.rawValue.split(ADDON_MOD_FEEDBACK_LINE_SEP);
|
||||
}
|
||||
} else {
|
||||
values = [item.rawValue || ''];
|
||||
|
@ -104,7 +104,7 @@ export class AddonModFeedbackProvider {
|
|||
let value = choices[index];
|
||||
|
||||
if (item.typ == 'multichoicerated') {
|
||||
value = value.split(AddonModFeedbackProvider.MULTICHOICERATED_VALUE_SEP)[1] || '';
|
||||
value = value.split(ADDON_MOD_FEEDBACK_MULTICHOICERATED_VALUE_SEP)[1] || '';
|
||||
}
|
||||
|
||||
if (value.trim() == dependValue) {
|
||||
|
@ -195,10 +195,10 @@ export class AddonModFeedbackProvider {
|
|||
}
|
||||
|
||||
// Treat multichoice checkboxes.
|
||||
if (item.typ === 'multichoice' && item.presentation.split(AddonModFeedbackProvider.MULTICHOICE_TYPE_SEP)[0] === 'c') {
|
||||
if (item.typ === 'multichoice' && item.presentation.split(ADDON_MOD_FEEDBACK_MULTICHOICE_TYPE_SEP)[0] === 'c') {
|
||||
|
||||
offlineValues[item.id] = offlineValues[item.id].filter((value) => Number(value) > 0);
|
||||
item.rawValue = offlineValues[item.id].join(AddonModFeedbackProvider.LINE_SEP);
|
||||
item.rawValue = offlineValues[item.id].join(ADDON_MOD_FEEDBACK_LINE_SEP);
|
||||
} else {
|
||||
item.rawValue = offlineValues[item.id][0];
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ export class AddonModFeedbackProvider {
|
|||
};
|
||||
const preSets: CoreSiteWSPreSets = {
|
||||
cacheKey: this.getAnalysisDataCacheKey(feedbackId, options.groupId),
|
||||
component: AddonModFeedbackProvider.COMPONENT,
|
||||
component: ADDON_MOD_FEEDBACK_COMPONENT,
|
||||
componentId: options.cmId,
|
||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||
};
|
||||
|
@ -429,7 +429,7 @@ export class AddonModFeedbackProvider {
|
|||
};
|
||||
const preSets: CoreSiteWSPreSets = {
|
||||
cacheKey: this.getCurrentCompletedTimeModifiedDataCacheKey(feedbackId),
|
||||
component: AddonModFeedbackProvider.COMPONENT,
|
||||
component: ADDON_MOD_FEEDBACK_COMPONENT,
|
||||
componentId: options.cmId,
|
||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||
};
|
||||
|
@ -476,7 +476,7 @@ export class AddonModFeedbackProvider {
|
|||
};
|
||||
const preSets: CoreSiteWSPreSets = {
|
||||
cacheKey: this.getCurrentValuesDataCacheKey(feedbackId),
|
||||
component: AddonModFeedbackProvider.COMPONENT,
|
||||
component: ADDON_MOD_FEEDBACK_COMPONENT,
|
||||
componentId: options.cmId,
|
||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||
};
|
||||
|
@ -529,7 +529,7 @@ export class AddonModFeedbackProvider {
|
|||
};
|
||||
const preSets: CoreSiteWSPreSets = {
|
||||
cacheKey: this.getFeedbackAccessInformationDataCacheKey(feedbackId),
|
||||
component: AddonModFeedbackProvider.COMPONENT,
|
||||
component: ADDON_MOD_FEEDBACK_COMPONENT,
|
||||
componentId: options.cmId,
|
||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||
};
|
||||
|
@ -554,7 +554,7 @@ export class AddonModFeedbackProvider {
|
|||
* @returns Cache key.
|
||||
*/
|
||||
protected getFeedbackCacheKey(courseId: number): string {
|
||||
return ROOT_CACHE_KEY + 'feedback:' + courseId;
|
||||
return AddonModFeedbackProvider.ROOT_CACHE_KEY + 'feedback:' + courseId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -564,7 +564,7 @@ export class AddonModFeedbackProvider {
|
|||
* @returns Cache key.
|
||||
*/
|
||||
protected getFeedbackDataPrefixCacheKey(feedbackId: number): string {
|
||||
return ROOT_CACHE_KEY + feedbackId;
|
||||
return AddonModFeedbackProvider.ROOT_CACHE_KEY + feedbackId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -590,7 +590,7 @@ export class AddonModFeedbackProvider {
|
|||
const preSets: CoreSiteWSPreSets = {
|
||||
cacheKey: this.getFeedbackCacheKey(courseId),
|
||||
updateFrequency: CoreSite.FREQUENCY_RARELY,
|
||||
component: AddonModFeedbackProvider.COMPONENT,
|
||||
component: ADDON_MOD_FEEDBACK_COMPONENT,
|
||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||
};
|
||||
|
||||
|
@ -648,7 +648,7 @@ export class AddonModFeedbackProvider {
|
|||
const preSets: CoreSiteWSPreSets = {
|
||||
cacheKey: this.getItemsDataCacheKey(feedbackId),
|
||||
updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
|
||||
component: AddonModFeedbackProvider.COMPONENT,
|
||||
component: ADDON_MOD_FEEDBACK_COMPONENT,
|
||||
componentId: options.cmId,
|
||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||
};
|
||||
|
@ -686,11 +686,11 @@ export class AddonModFeedbackProvider {
|
|||
feedbackid: feedbackId,
|
||||
groupid: options.groupId,
|
||||
page: options.page,
|
||||
perpage: AddonModFeedbackProvider.PER_PAGE,
|
||||
perpage: ADDON_MOD_FEEDBACK_PER_PAGE,
|
||||
};
|
||||
const preSets: CoreSiteWSPreSets = {
|
||||
cacheKey: this.getNonRespondentsDataCacheKey(feedbackId, options.groupId),
|
||||
component: AddonModFeedbackProvider.COMPONENT,
|
||||
component: ADDON_MOD_FEEDBACK_COMPONENT,
|
||||
componentId: options.cmId,
|
||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||
};
|
||||
|
@ -862,11 +862,11 @@ export class AddonModFeedbackProvider {
|
|||
feedbackid: feedbackId,
|
||||
groupid: options.groupId,
|
||||
page: options.page,
|
||||
perpage: AddonModFeedbackProvider.PER_PAGE,
|
||||
perpage: ADDON_MOD_FEEDBACK_PER_PAGE,
|
||||
};
|
||||
const preSets: CoreSiteWSPreSets = {
|
||||
cacheKey: this.getResponsesAnalysisDataCacheKey(feedbackId, options.groupId),
|
||||
component: AddonModFeedbackProvider.COMPONENT,
|
||||
component: ADDON_MOD_FEEDBACK_COMPONENT,
|
||||
componentId: options.cmId,
|
||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||
};
|
||||
|
@ -910,7 +910,7 @@ export class AddonModFeedbackProvider {
|
|||
};
|
||||
const preSets = {
|
||||
cacheKey: this.getResumePageDataCacheKey(feedbackId),
|
||||
component: AddonModFeedbackProvider.COMPONENT,
|
||||
component: ADDON_MOD_FEEDBACK_COMPONENT,
|
||||
componentId: options.cmId,
|
||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||
};
|
||||
|
@ -1024,7 +1024,7 @@ export class AddonModFeedbackProvider {
|
|||
* @returns Promise resolved when the files are invalidated.
|
||||
*/
|
||||
async invalidateFiles(moduleId: number, siteId?: string): Promise<void> {
|
||||
return CoreFilepool.invalidateFilesByComponent(siteId, AddonModFeedbackProvider.COMPONENT, moduleId);
|
||||
return CoreFilepool.invalidateFilesByComponent(siteId, ADDON_MOD_FEEDBACK_COMPONENT, moduleId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1082,7 +1082,7 @@ export class AddonModFeedbackProvider {
|
|||
const preSets: CoreSiteWSPreSets = {
|
||||
cacheKey: this.getCompletedDataCacheKey(feedbackId),
|
||||
updateFrequency: CoreSite.FREQUENCY_RARELY,
|
||||
component: AddonModFeedbackProvider.COMPONENT,
|
||||
component: ADDON_MOD_FEEDBACK_COMPONENT,
|
||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||
};
|
||||
|
||||
|
@ -1106,7 +1106,7 @@ export class AddonModFeedbackProvider {
|
|||
await CoreCourseLogHelper.log(
|
||||
'mod_feedback_view_feedback',
|
||||
params,
|
||||
AddonModFeedbackProvider.COMPONENT,
|
||||
ADDON_MOD_FEEDBACK_COMPONENT,
|
||||
id,
|
||||
siteId,
|
||||
);
|
||||
|
@ -1252,7 +1252,7 @@ declare module '@singletons/events' {
|
|||
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
|
||||
*/
|
||||
export interface CoreEventsData {
|
||||
[AddonModFeedbackProvider.FORM_SUBMITTED]: AddonModFeedbackFormSubmittedData;
|
||||
[ADDON_MOD_FEEDBACK_FORM_SUBMITTED]: AddonModFeedbackFormSubmittedData;
|
||||
[AddonModFeedbackSyncProvider.AUTO_SYNCED]: AddonModFeedbackAutoSyncData;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import { CoreCourse } from '@features/course/services/course';
|
|||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModFeedbackModuleHandlerService } from './module';
|
||||
import { ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants';
|
||||
|
||||
/**
|
||||
* Content links handler for a feedback analysis.
|
||||
|
@ -54,7 +54,7 @@ export class AddonModFeedbackAnalysisLinkHandlerService extends CoreContentLinks
|
|||
);
|
||||
|
||||
await CoreNavigator.navigateToSitePath(
|
||||
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}`,
|
||||
ADDON_MOD_FEEDBACK_PAGE_NAME + `/${module.course}/${module.id}`,
|
||||
{
|
||||
params: {
|
||||
module,
|
||||
|
|
|
@ -20,7 +20,7 @@ import { CoreNavigator } from '@services/navigator';
|
|||
import { CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModFeedbackModuleHandlerService } from './module';
|
||||
import { ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants';
|
||||
|
||||
/**
|
||||
* Content links handler for feedback complete questions.
|
||||
|
@ -50,7 +50,7 @@ export class AddonModFeedbackCompleteLinkHandlerService extends CoreContentLinks
|
|||
);
|
||||
|
||||
await CoreNavigator.navigateToSitePath(
|
||||
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/form`,
|
||||
ADDON_MOD_FEEDBACK_PAGE_NAME + `/${module.course}/${module.id}/form`,
|
||||
{
|
||||
params: {
|
||||
page: params.gopage !== undefined ? Number(params.gopage) : undefined,
|
||||
|
|
|
@ -17,6 +17,7 @@ import { Injectable, Type } from '@angular/core';
|
|||
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
||||
import { ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants';
|
||||
|
||||
/**
|
||||
* Handler to support feedback modules.
|
||||
|
@ -24,11 +25,9 @@ import { CoreModuleHandlerBase } from '@features/course/classes/module-base-hand
|
|||
@Injectable({ providedIn: 'root' })
|
||||
export class AddonModFeedbackModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler {
|
||||
|
||||
static readonly PAGE_NAME = 'mod_feedback';
|
||||
|
||||
name = 'AddonModFeedback';
|
||||
modName = 'feedback';
|
||||
protected pageName = AddonModFeedbackModuleHandlerService.PAGE_NAME;
|
||||
protected pageName = ADDON_MOD_FEEDBACK_PAGE_NAME;
|
||||
|
||||
supportedFeatures = {
|
||||
[CoreConstants.FEATURE_GROUPS]: true,
|
||||
|
|
|
@ -25,10 +25,10 @@ import { makeSingleton } from '@singletons';
|
|||
import {
|
||||
AddonModFeedback,
|
||||
AddonModFeedbackGetFeedbackAccessInformationWSResponse,
|
||||
AddonModFeedbackProvider,
|
||||
AddonModFeedbackWSFeedback,
|
||||
} from '../feedback';
|
||||
import { AddonModFeedbackSync, AddonModFeedbackSyncResult } from '../feedback-sync';
|
||||
import { ADDON_MOD_FEEDBACK_COMPONENT } from '../../constants';
|
||||
|
||||
/**
|
||||
* Handler to prefetch feedbacks.
|
||||
|
@ -38,7 +38,7 @@ export class AddonModFeedbackPrefetchHandlerService extends CoreCourseActivityPr
|
|||
|
||||
name = 'AddonModFeedback';
|
||||
modName = 'feedback';
|
||||
component = AddonModFeedbackProvider.COMPONENT;
|
||||
component = ADDON_MOD_FEEDBACK_COMPONENT;
|
||||
updatesNames = /^configuration$|^.*files$|^attemptsfinished|^attemptsunfinished$/;
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,7 +20,7 @@ import { CoreNavigator } from '@services/navigator';
|
|||
import { CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModFeedbackModuleHandlerService } from './module';
|
||||
import { ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants';
|
||||
|
||||
/**
|
||||
* Content links handler for feedback print questions.
|
||||
|
@ -50,7 +50,7 @@ export class AddonModFeedbackPrintLinkHandlerService extends CoreContentLinksHan
|
|||
);
|
||||
|
||||
await CoreNavigator.navigateToSitePath(
|
||||
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/form`,
|
||||
ADDON_MOD_FEEDBACK_PAGE_NAME + `/${module.course}/${module.id}/form`,
|
||||
{
|
||||
params: {
|
||||
preview: true,
|
||||
|
|
|
@ -20,7 +20,7 @@ import { CoreNavigator } from '@services/navigator';
|
|||
import { CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModFeedbackModuleHandlerService } from './module';
|
||||
import { ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants';
|
||||
/**
|
||||
* Content links handler for feedback show non respondents.
|
||||
* Match mod/feedback/show_nonrespondents.php with a valid feedback id.
|
||||
|
@ -49,7 +49,7 @@ export class AddonModFeedbackShowNonRespondentsLinkHandlerService extends CoreCo
|
|||
);
|
||||
|
||||
await CoreNavigator.navigateToSitePath(
|
||||
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/nonrespondents`,
|
||||
ADDON_MOD_FEEDBACK_PAGE_NAME + `/${module.course}/${module.id}/nonrespondents`,
|
||||
{ siteId },
|
||||
);
|
||||
} catch (error) {
|
||||
|
|
Loading…
Reference in New Issue