MOBILE-4616 choice: Move choice constants to a file
parent
eb2555e5ad
commit
f65d640999
|
@ -35,4 +35,4 @@ const routes: Routes = [
|
||||||
AddonModChoiceIndexPage,
|
AddonModChoiceIndexPage,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class AddonModChoiceLazyModule {}
|
export default class AddonModChoiceLazyModule {}
|
||||||
|
|
|
@ -25,15 +25,15 @@ import { CORE_SITE_SCHEMAS } from '@services/sites';
|
||||||
import { OFFLINE_SITE_SCHEMA } from './services/database/choice';
|
import { OFFLINE_SITE_SCHEMA } from './services/database/choice';
|
||||||
import { AddonModChoiceIndexLinkHandler } from './services/handlers/index-link';
|
import { AddonModChoiceIndexLinkHandler } from './services/handlers/index-link';
|
||||||
import { AddonModChoiceListLinkHandler } from './services/handlers/list-link';
|
import { AddonModChoiceListLinkHandler } from './services/handlers/list-link';
|
||||||
import { AddonModChoiceModuleHandler, AddonModChoiceModuleHandlerService } from './services/handlers/module';
|
import { AddonModChoiceModuleHandler } from './services/handlers/module';
|
||||||
import { AddonModChoicePrefetchHandler } from './services/handlers/prefetch';
|
import { AddonModChoicePrefetchHandler } from './services/handlers/prefetch';
|
||||||
import { AddonModChoiceSyncCronHandler } from './services/handlers/sync-cron';
|
import { AddonModChoiceSyncCronHandler } from './services/handlers/sync-cron';
|
||||||
import { ADDON_MOD_CHOICE_COMPONENT } from './constants';
|
import { ADDON_MOD_CHOICE_COMPONENT, ADDON_MOD_CHOICE_PAGE_NAME } from './constants';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: AddonModChoiceModuleHandlerService.PAGE_NAME,
|
path: ADDON_MOD_CHOICE_PAGE_NAME,
|
||||||
loadChildren: () => import('./choice-lazy.module').then(m => m.AddonModChoiceLazyModule),
|
loadChildren: () => import('./choice-lazy.module'),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -32,11 +32,15 @@ import { AddonModChoiceOffline } from '../../services/choice-offline';
|
||||||
import {
|
import {
|
||||||
AddonModChoiceAutoSyncData,
|
AddonModChoiceAutoSyncData,
|
||||||
AddonModChoiceSync,
|
AddonModChoiceSync,
|
||||||
AddonModChoiceSyncProvider,
|
|
||||||
AddonModChoiceSyncResult,
|
AddonModChoiceSyncResult,
|
||||||
} from '../../services/choice-sync';
|
} from '../../services/choice-sync';
|
||||||
import { AddonModChoicePrefetchHandler } from '../../services/handlers/prefetch';
|
import { AddonModChoicePrefetchHandler } from '../../services/handlers/prefetch';
|
||||||
import { ADDON_MOD_CHOICE_COMPONENT, ADDON_MOD_CHOICE_PUBLISH_ANONYMOUS, AddonModChoiceShowResults } from '../../constants';
|
import {
|
||||||
|
ADDON_MOD_CHOICE_AUTO_SYNCED,
|
||||||
|
ADDON_MOD_CHOICE_COMPONENT,
|
||||||
|
ADDON_MOD_CHOICE_PUBLISH_ANONYMOUS,
|
||||||
|
AddonModChoiceShowResults,
|
||||||
|
} from '../../constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that displays a choice.
|
* Component that displays a choice.
|
||||||
|
@ -64,7 +68,7 @@ export class AddonModChoiceIndexComponent extends CoreCourseModuleMainActivityCo
|
||||||
publishInfo?: string; // Message explaining the user what will happen with his choices.
|
publishInfo?: string; // Message explaining the user what will happen with his choices.
|
||||||
|
|
||||||
protected userId?: number;
|
protected userId?: number;
|
||||||
protected syncEventName = AddonModChoiceSyncProvider.AUTO_SYNCED;
|
protected syncEventName = ADDON_MOD_CHOICE_AUTO_SYNCED;
|
||||||
protected hasAnsweredOnline = false;
|
protected hasAnsweredOnline = false;
|
||||||
protected now = CoreTimeUtils.timestamp();
|
protected now = CoreTimeUtils.timestamp();
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
export const ADDON_MOD_CHOICE_COMPONENT = 'mmaModChoice';
|
export const ADDON_MOD_CHOICE_COMPONENT = 'mmaModChoice';
|
||||||
|
export const ADDON_MOD_CHOICE_PAGE_NAME = 'mod_choice';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Possible show results values.
|
* Possible show results values.
|
||||||
|
@ -27,3 +28,5 @@ export const enum AddonModChoiceShowResults {
|
||||||
// Possible choice publish values.
|
// Possible choice publish values.
|
||||||
export const ADDON_MOD_CHOICE_PUBLISH_ANONYMOUS = false;
|
export const ADDON_MOD_CHOICE_PUBLISH_ANONYMOUS = false;
|
||||||
export const ADDON_MOD_CHOICE_PUBLISH_NAMES = true;
|
export const ADDON_MOD_CHOICE_PUBLISH_NAMES = true;
|
||||||
|
|
||||||
|
export const ADDON_MOD_CHOICE_AUTO_SYNCED = 'addon_mod_choice_autom_synced';
|
||||||
|
|
|
@ -26,7 +26,7 @@ import { CoreEvents } from '@singletons/events';
|
||||||
import { AddonModChoice } from './choice';
|
import { AddonModChoice } from './choice';
|
||||||
import { AddonModChoiceOffline } from './choice-offline';
|
import { AddonModChoiceOffline } from './choice-offline';
|
||||||
import { AddonModChoicePrefetchHandler } from './handlers/prefetch';
|
import { AddonModChoicePrefetchHandler } from './handlers/prefetch';
|
||||||
import { ADDON_MOD_CHOICE_COMPONENT } from '../constants';
|
import { ADDON_MOD_CHOICE_AUTO_SYNCED, ADDON_MOD_CHOICE_COMPONENT } from '../constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service to sync choices.
|
* Service to sync choices.
|
||||||
|
@ -34,8 +34,6 @@ import { ADDON_MOD_CHOICE_COMPONENT } from '../constants';
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class AddonModChoiceSyncProvider extends CoreCourseActivitySyncBaseProvider<AddonModChoiceSyncResult> {
|
export class AddonModChoiceSyncProvider extends CoreCourseActivitySyncBaseProvider<AddonModChoiceSyncResult> {
|
||||||
|
|
||||||
static readonly AUTO_SYNCED = 'addon_mod_choice_autom_synced';
|
|
||||||
|
|
||||||
protected componentTranslatableString = 'choice';
|
protected componentTranslatableString = 'choice';
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -82,7 +80,7 @@ export class AddonModChoiceSyncProvider extends CoreCourseActivitySyncBaseProvid
|
||||||
|
|
||||||
if (result?.updated) {
|
if (result?.updated) {
|
||||||
// Sync successful, send event.
|
// Sync successful, send event.
|
||||||
CoreEvents.trigger(AddonModChoiceSyncProvider.AUTO_SYNCED, {
|
CoreEvents.trigger(ADDON_MOD_CHOICE_AUTO_SYNCED, {
|
||||||
choiceId: response.choiceid,
|
choiceId: response.choiceid,
|
||||||
userId: response.userid,
|
userId: response.userid,
|
||||||
warnings: result.warnings,
|
warnings: result.warnings,
|
||||||
|
|
|
@ -25,9 +25,9 @@ import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
||||||
import { makeSingleton, Translate } from '@singletons';
|
import { makeSingleton, Translate } from '@singletons';
|
||||||
import { AddonModChoiceOffline } from './choice-offline';
|
import { AddonModChoiceOffline } from './choice-offline';
|
||||||
import { AddonModChoiceAutoSyncData, AddonModChoiceSyncProvider } from './choice-sync';
|
import { AddonModChoiceAutoSyncData } from './choice-sync';
|
||||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
||||||
import { ADDON_MOD_CHOICE_COMPONENT, AddonModChoiceShowResults } from '../constants';
|
import { ADDON_MOD_CHOICE_AUTO_SYNCED, ADDON_MOD_CHOICE_COMPONENT, AddonModChoiceShowResults } from '../constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service that provides some features for choices.
|
* Service that provides some features for choices.
|
||||||
|
@ -611,7 +611,7 @@ declare module '@singletons/events' {
|
||||||
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
|
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
|
||||||
*/
|
*/
|
||||||
export interface CoreEventsData {
|
export interface CoreEventsData {
|
||||||
[AddonModChoiceSyncProvider.AUTO_SYNCED]: AddonModChoiceAutoSyncData;
|
[ADDON_MOD_CHOICE_AUTO_SYNCED]: AddonModChoiceAutoSyncData;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import { Injectable, Type } from '@angular/core';
|
||||||
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
||||||
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
|
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
|
import { ADDON_MOD_CHOICE_PAGE_NAME } from '../../constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler to support choice modules.
|
* Handler to support choice modules.
|
||||||
|
@ -24,11 +25,9 @@ import { makeSingleton } from '@singletons';
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class AddonModChoiceModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler {
|
export class AddonModChoiceModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler {
|
||||||
|
|
||||||
static readonly PAGE_NAME = 'mod_choice';
|
|
||||||
|
|
||||||
name = 'AddonModChoice';
|
name = 'AddonModChoice';
|
||||||
modName = 'choice';
|
modName = 'choice';
|
||||||
protected pageName = AddonModChoiceModuleHandlerService.PAGE_NAME;
|
protected pageName = ADDON_MOD_CHOICE_PAGE_NAME;
|
||||||
|
|
||||||
supportedFeatures = {
|
supportedFeatures = {
|
||||||
[CoreConstants.FEATURE_GROUPS]: true,
|
[CoreConstants.FEATURE_GROUPS]: true,
|
||||||
|
|
Loading…
Reference in New Issue