MOBILE-4616 workshop: Move workshop constants to a file

main
Pau Ferrer Ocaña 2024-07-11 22:43:26 +02:00
parent ba80f1ce05
commit 65a5659d47
16 changed files with 149 additions and 114 deletions

View File

@ -29,8 +29,6 @@ import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { CoreFormFields, CoreForms } from '@singletons/form';
import { AddonWorkshopAssessmentStrategyDelegate } from '../../services/assessment-strategy-delegate';
import {
AddonModWorkshopProvider,
AddonModWorkshopOverallFeedbackMode,
AddonModWorkshop,
AddonModWorkshopData,
AddonModWorkshopGetWorkshopAccessInformationWSResponse,
@ -38,7 +36,12 @@ import {
} from '../../services/workshop';
import { AddonModWorkshopHelper, AddonModWorkshopSubmissionAssessmentWithFormData } from '../../services/workshop-helper';
import { AddonModWorkshopOffline } from '../../services/workshop-offline';
import { ADDON_MOD_WORKSHOP_COMPONENT } from '@addons/mod/workshop/constants';
import {
ADDON_MOD_WORKSHOP_ASSESSMENT_INVALIDATED,
ADDON_MOD_WORKSHOP_ASSESSMENT_SAVED,
ADDON_MOD_WORKSHOP_COMPONENT,
AddonModWorkshopOverallFeedbackMode,
} from '@addons/mod/workshop/constants';
/**
* Component that displays workshop assessment strategy form.
@ -135,7 +138,7 @@ export class AddonModWorkshopAssessmentStrategyComponent implements OnInit, OnDe
try {
await this.load();
this.obsInvalidated = CoreEvents.on(
AddonModWorkshopProvider.ASSESSMENT_INVALIDATED,
ADDON_MOD_WORKSHOP_ASSESSMENT_INVALIDATED,
() => this.load(),
CoreSites.getCurrentSiteId(),
);
@ -382,7 +385,7 @@ export class AddonModWorkshopAssessmentStrategyComponent implements OnInit, OnDe
await CoreUtils.ignoreErrors(Promise.all(promises));
CoreEvents.trigger(AddonModWorkshopProvider.ASSESSMENT_SAVED, {
CoreEvents.trigger(ADDON_MOD_WORKSHOP_ASSESSMENT_SAVED, {
workshopId: this.workshop.id,
assessmentId: this.assessmentId,
userId: CoreSites.getCurrentSiteUserId(),

View File

@ -26,8 +26,6 @@ import { CoreUtils } from '@services/utils/utils';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { Subscription } from 'rxjs';
import {
AddonModWorkshopProvider,
AddonModWorkshopPhase,
AddonModWorkshop,
AddonModWorkshopData,
AddonModWorkshopGetWorkshopAccessInformationWSResponse,
@ -46,13 +44,20 @@ import {
} from '../../services/workshop-helper';
import { AddonModWorkshopOffline, AddonModWorkshopOfflineSubmission } from '../../services/workshop-offline';
import {
AddonModWorkshopSyncProvider,
AddonModWorkshopSync,
AddonModWorkshopAutoSyncData,
AddonModWorkshopSyncResult,
} from '../../services/workshop-sync';
import { AddonModWorkshopPhaseInfoComponent } from '../phase/phase';
import { ADDON_MOD_WORKSHOP_COMPONENT, ADDON_MOD_WORKSHOP_PAGE_NAME } from '@addons/mod/workshop/constants';
import {
ADDON_MOD_WORKSHOP_ASSESSMENT_SAVED,
ADDON_MOD_WORKSHOP_AUTO_SYNCED,
ADDON_MOD_WORKSHOP_COMPONENT,
ADDON_MOD_WORKSHOP_PAGE_NAME,
ADDON_MOD_WORKSHOP_PER_PAGE,
ADDON_MOD_WORKSHOP_SUBMISSION_CHANGED,
AddonModWorkshopPhase,
} from '@addons/mod/workshop/constants';
/**
* Component that displays a workshop index page.
@ -101,7 +106,7 @@ export class AddonModWorkshopIndexComponent extends CoreCourseModuleMainActivity
protected obsAssessmentSaved: CoreEventObserver;
protected appResumeSubscription: Subscription;
protected syncObserver?: CoreEventObserver;
protected syncEventName = AddonModWorkshopSyncProvider.AUTO_SYNCED;
protected syncEventName = ADDON_MOD_WORKSHOP_AUTO_SYNCED;
constructor (
@Optional() content: IonContent,
@ -110,12 +115,12 @@ export class AddonModWorkshopIndexComponent extends CoreCourseModuleMainActivity
super('AddonModWorkshopIndexComponent', content, courseContentsPage);
// Listen to submission and assessment changes.
this.obsSubmissionChanged = CoreEvents.on(AddonModWorkshopProvider.SUBMISSION_CHANGED, (data) => {
this.obsSubmissionChanged = CoreEvents.on(ADDON_MOD_WORKSHOP_SUBMISSION_CHANGED, (data) => {
this.eventReceived(data);
}, this.siteId);
// Listen to submission and assessment changes.
this.obsAssessmentSaved = CoreEvents.on(AddonModWorkshopProvider.ASSESSMENT_SAVED, (data) => {
this.obsAssessmentSaved = CoreEvents.on(ADDON_MOD_WORKSHOP_ASSESSMENT_SAVED, (data) => {
this.eventReceived(data);
}, this.siteId);
@ -125,7 +130,7 @@ export class AddonModWorkshopIndexComponent extends CoreCourseModuleMainActivity
});
// Refresh workshop on sync.
this.syncObserver = CoreEvents.on(AddonModWorkshopSyncProvider.AUTO_SYNCED, (data) => {
this.syncObserver = CoreEvents.on(ADDON_MOD_WORKSHOP_AUTO_SYNCED, (data) => {
// Update just when all database is synced.
this.eventReceived(data);
}, this.siteId);
@ -282,8 +287,8 @@ export class AddonModWorkshopIndexComponent extends CoreCourseModuleMainActivity
this.page = page;
this.hasNextPage = numEntries >= AddonModWorkshopProvider.PER_PAGE && ((this.page + 1) *
AddonModWorkshopProvider.PER_PAGE) < report.totalcount;
this.hasNextPage = numEntries >= ADDON_MOD_WORKSHOP_PER_PAGE && ((this.page + 1) *
ADDON_MOD_WORKSHOP_PER_PAGE) < report.totalcount;
const grades: AddonModWorkshopGradesData[] = report.grades || [];

View File

@ -15,7 +15,8 @@
import { Component, Input, OnInit } from '@angular/core';
import { CoreUtils } from '@services/utils/utils';
import { ModalController } from '@singletons';
import { AddonModWorkshopPhaseData, AddonModWorkshopPhase, AddonModWorkshopPhaseTaskData } from '../../services/workshop';
import { AddonModWorkshopPhaseData, AddonModWorkshopPhaseTaskData } from '../../services/workshop';
import { AddonModWorkshopPhase } from '../../constants';
/**
* Page that displays the phase info modal.

View File

@ -20,7 +20,6 @@ import { CoreNavigator } from '@services/navigator';
import { CoreSites } from '@services/sites';
import { AddonModWorkshopSubmissionPage } from '../../pages/submission/submission';
import {
AddonModWorkshopPhase,
AddonModWorkshopData,
AddonModWorkshopGetWorkshopAccessInformationWSResponse,
} from '../../services/workshop';
@ -30,7 +29,7 @@ import {
AddonModWorkshopSubmissionDataWithOfflineData,
} from '../../services/workshop-helper';
import { AddonModWorkshopOffline } from '../../services/workshop-offline';
import { ADDON_MOD_WORKSHOP_COMPONENT, ADDON_MOD_WORKSHOP_PAGE_NAME } from '@addons/mod/workshop/constants';
import { ADDON_MOD_WORKSHOP_COMPONENT, ADDON_MOD_WORKSHOP_PAGE_NAME, AddonModWorkshopPhase } from '@addons/mod/workshop/constants';
/**
* Component that displays workshop submission.

View File

@ -14,6 +14,8 @@
export const ADDON_MOD_WORKSHOP_COMPONENT = 'mmaModWorkshop';
export const ADDON_MOD_WORKSHOP_PER_PAGE = 10;
// Routing.
export const ADDON_MOD_WORKSHOP_PAGE_NAME = 'mod_workshop';
@ -41,3 +43,46 @@ export const ADDON_MOD_WORKSHOP_PREFETCH_UPDATE_NAMES = new RegExp(
export const ADDON_MOD_WORKSHOP_SYNC_CRON_NAME = 'AddonModWorkshopSyncCronHandler';
export const ADDON_MOD_WORKSHOP_FEATURE_NAME = 'CoreCourseModuleDelegate_AddonModWorkshop';
// Events.
export const ADDON_MOD_WORKSHOP_SUBMISSION_CHANGED = 'addon_mod_workshop_submission_changed';
export const ADDON_MOD_WORKSHOP_ASSESSMENT_SAVED = 'addon_mod_workshop_assessment_saved';
export const ADDON_MOD_WORKSHOP_ASSESSMENT_INVALIDATED = 'addon_mod_workshop_assessment_invalidated';
export const ADDON_MOD_WORKSHOP_AUTO_SYNCED = 'addon_mod_workshop_autom_synced';
export const enum AddonModWorkshopPhase {
PHASE_SETUP = 10,
PHASE_SUBMISSION = 20,
PHASE_ASSESSMENT = 30,
PHASE_EVALUATION = 40,
PHASE_CLOSED = 50,
}
export const enum AddonModWorkshopSubmissionType {
SUBMISSION_TYPE_DISABLED = 0,
SUBMISSION_TYPE_AVAILABLE = 1,
SUBMISSION_TYPE_REQUIRED = 2,
}
export const enum AddonModWorkshopExampleMode {
EXAMPLES_VOLUNTARY = 0,
EXAMPLES_BEFORE_SUBMISSION = 1,
EXAMPLES_BEFORE_ASSESSMENT = 2,
}
export const enum AddonModWorkshopAction {
ADD = 'add',
DELETE = 'delete',
UPDATE = 'update',
}
export const enum AddonModWorkshopAssessmentMode {
ASSESSMENT = 'assessment',
PREVIEW = 'preview',
}
export const enum AddonModWorkshopOverallFeedbackMode {
DISABLED = 0,
ENABLED_OPTIONAL = 1,
ENABLED_REQUIRED = 2,
}

View File

@ -31,16 +31,19 @@ import {
AddonModWorkshopAssessmentSavedChangedEventData,
AddonModWorkshopData,
AddonModWorkshopGetWorkshopAccessInformationWSResponse,
AddonModWorkshopPhase,
AddonModWorkshopProvider,
AddonModWorkshopSubmissionData,
} from '../../services/workshop';
import { AddonModWorkshopHelper, AddonModWorkshopSubmissionAssessmentWithFormData } from '../../services/workshop-helper';
import { AddonModWorkshopOffline } from '../../services/workshop-offline';
import { AddonModWorkshopSyncProvider } from '../../services/workshop-sync';
import { CoreTime } from '@singletons/time';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { ADDON_MOD_WORKSHOP_COMPONENT } from '@addons/mod/workshop/constants';
import {
ADDON_MOD_WORKSHOP_ASSESSMENT_INVALIDATED,
ADDON_MOD_WORKSHOP_ASSESSMENT_SAVED,
ADDON_MOD_WORKSHOP_AUTO_SYNCED,
ADDON_MOD_WORKSHOP_COMPONENT,
AddonModWorkshopPhase,
} from '@addons/mod/workshop/constants';
/**
* Page that displays a workshop assessment.
@ -107,7 +110,7 @@ export class AddonModWorkshopAssessmentPage implements OnInit, OnDestroy, CanLea
this.evaluateForm.addControl('text', this.fb.control(''));
// Refresh workshop on sync.
this.syncObserver = CoreEvents.on(AddonModWorkshopSyncProvider.AUTO_SYNCED, (data) => {
this.syncObserver = CoreEvents.on(ADDON_MOD_WORKSHOP_AUTO_SYNCED, (data) => {
// Update just when all database is synced.
if (this.workshopId === data.workshopId) {
this.loaded = false;
@ -331,7 +334,7 @@ export class AddonModWorkshopAssessmentPage implements OnInit, OnDestroy, CanLea
try {
await Promise.all(promises);
} finally {
CoreEvents.trigger(AddonModWorkshopProvider.ASSESSMENT_INVALIDATED, null, this.siteId);
CoreEvents.trigger(ADDON_MOD_WORKSHOP_ASSESSMENT_INVALIDATED, null, this.siteId);
await this.fetchAssessmentData();
}
@ -396,7 +399,7 @@ export class AddonModWorkshopAssessmentPage implements OnInit, OnDestroy, CanLea
};
return AddonModWorkshop.invalidateAssessmentData(this.workshopId, this.assessmentId).finally(() => {
CoreEvents.trigger(AddonModWorkshopProvider.ASSESSMENT_SAVED, data, this.siteId);
CoreEvents.trigger(ADDON_MOD_WORKSHOP_ASSESSMENT_SAVED, data, this.siteId);
});
} catch (error) {
CoreDomUtils.showErrorModalDefault(error, 'Cannot save assessment evaluation');

View File

@ -30,18 +30,20 @@ import { Translate } from '@singletons';
import { CoreEvents } from '@singletons/events';
import { CoreForms } from '@singletons/form';
import {
AddonModWorkshopProvider,
AddonModWorkshop,
AddonModWorkshopSubmissionType,
AddonModWorkshopSubmissionChangedEventData,
AddonModWorkshopAction,
AddonModWorkshopGetWorkshopAccessInformationWSResponse,
AddonModWorkshopData,
} from '../../services/workshop';
import { AddonModWorkshopHelper, AddonModWorkshopSubmissionDataWithOfflineData } from '../../services/workshop-helper';
import { AddonModWorkshopOffline } from '../../services/workshop-offline';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { ADDON_MOD_WORKSHOP_COMPONENT } from '@addons/mod/workshop/constants';
import {
ADDON_MOD_WORKSHOP_COMPONENT,
ADDON_MOD_WORKSHOP_SUBMISSION_CHANGED,
AddonModWorkshopAction,
AddonModWorkshopSubmissionType,
} from '@addons/mod/workshop/constants';
/**
* Page that displays the workshop edit submission.
@ -473,7 +475,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca
Promise.resolve();
await promise.finally(() => {
CoreEvents.trigger(AddonModWorkshopProvider.SUBMISSION_CHANGED, data, this.siteId);
CoreEvents.trigger(ADDON_MOD_WORKSHOP_SUBMISSION_CHANGED, data, this.siteId);
// Delete the local files from the tmp folder.
CoreFileUploader.clearTmpFiles(inputData.attachmentfiles);

View File

@ -31,11 +31,8 @@ import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { CoreForms } from '@singletons/form';
import { AddonModWorkshopAssessmentStrategyComponent } from '../../components/assessment-strategy/assessment-strategy';
import {
AddonModWorkshopProvider,
AddonModWorkshop,
AddonModWorkshopPhase,
AddonModWorkshopSubmissionChangedEventData,
AddonModWorkshopAction,
AddonModWorkshopData,
AddonModWorkshopGetWorkshopAccessInformationWSResponse,
AddonModWorkshopAssessmentSavedChangedEventData,
@ -46,10 +43,18 @@ import {
AddonModWorkshopSubmissionDataWithOfflineData,
} from '../../services/workshop-helper';
import { AddonModWorkshopOffline } from '../../services/workshop-offline';
import { AddonModWorkshopSyncProvider, AddonModWorkshopAutoSyncData } from '../../services/workshop-sync';
import { AddonModWorkshopAutoSyncData } from '../../services/workshop-sync';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { CoreTime } from '@singletons/time';
import { ADDON_MOD_WORKSHOP_COMPONENT } from '@addons/mod/workshop/constants';
import {
ADDON_MOD_WORKSHOP_ASSESSMENT_INVALIDATED,
ADDON_MOD_WORKSHOP_ASSESSMENT_SAVED,
ADDON_MOD_WORKSHOP_AUTO_SYNCED,
ADDON_MOD_WORKSHOP_COMPONENT,
ADDON_MOD_WORKSHOP_SUBMISSION_CHANGED,
AddonModWorkshopAction,
AddonModWorkshopPhase,
} from '@addons/mod/workshop/constants';
/**
* Page that displays a workshop submission.
@ -119,12 +124,12 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy, CanLea
this.feedbackForm.addControl('grade', this.fb.control(''));
this.feedbackForm.addControl('text', this.fb.control(''));
this.obsAssessmentSaved = CoreEvents.on(AddonModWorkshopProvider.ASSESSMENT_SAVED, (data) => {
this.obsAssessmentSaved = CoreEvents.on(ADDON_MOD_WORKSHOP_ASSESSMENT_SAVED, (data) => {
this.eventReceived(data);
}, this.siteId);
// Refresh workshop on sync.
this.syncObserver = CoreEvents.on(AddonModWorkshopSyncProvider.AUTO_SYNCED, (data) => {
this.syncObserver = CoreEvents.on(ADDON_MOD_WORKSHOP_AUTO_SYNCED, (data) => {
// Update just when all database is synced.
this.eventReceived(data);
}, this.siteId);
@ -447,7 +452,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy, CanLea
try {
await Promise.all(promises);
} finally {
CoreEvents.trigger(AddonModWorkshopProvider.ASSESSMENT_INVALIDATED, null, this.siteId);
CoreEvents.trigger(ADDON_MOD_WORKSHOP_ASSESSMENT_INVALIDATED, null, this.siteId);
await this.fetchSubmissionData();
@ -535,7 +540,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy, CanLea
submissionId: this.submissionId,
};
CoreEvents.trigger(AddonModWorkshopProvider.SUBMISSION_CHANGED, data, this.siteId);
CoreEvents.trigger(ADDON_MOD_WORKSHOP_SUBMISSION_CHANGED, data, this.siteId);
});
} catch (message) {
CoreDomUtils.showErrorModalDefault(message, 'Cannot save submission evaluation');
@ -572,7 +577,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy, CanLea
submissionId: this.submissionId,
};
CoreEvents.trigger(AddonModWorkshopProvider.SUBMISSION_CHANGED, data, this.siteId);
CoreEvents.trigger(ADDON_MOD_WORKSHOP_SUBMISSION_CHANGED, data, this.siteId);
this.forceLeavePage();
}
@ -595,7 +600,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy, CanLea
submissionId: this.submissionId,
};
CoreEvents.trigger(AddonModWorkshopProvider.SUBMISSION_CHANGED, data, this.siteId);
CoreEvents.trigger(ADDON_MOD_WORKSHOP_SUBMISSION_CHANGED, data, this.siteId);
await this.refreshAllData();
});

View File

@ -13,7 +13,7 @@
// limitations under the License.
import { CoreSiteSchema } from '@services/sites';
import { AddonModWorkshopAction } from '../workshop';
import { AddonModWorkshopAction } from '../../constants';
/**
* Database variables for AddonModWorkshopOfflineProvider.

View File

@ -25,7 +25,6 @@ import { CoreWSExternalFile, CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import {
AddonModWorkshop,
AddonModWorkshopPhase,
AddonModWorkshopGradesData,
AddonModWorkshopData,
AddonModWorkshopGetWorkshopAccessInformationWSResponse,
@ -33,6 +32,7 @@ import {
import { AddonModWorkshopHelper } from '../workshop-helper';
import { AddonModWorkshopSync } from '../workshop-sync';
import { AddonModWorkshopPrefetchHandlerService } from '@addons/mod/workshop/services/handlers/prefetch';
import { AddonModWorkshopPhase } from '../../constants';
/**
* Handler to prefetch workshops.

View File

@ -26,8 +26,6 @@ import { CoreFormFields } from '@singletons/form';
import { AddonModWorkshopAssessmentStrategyFieldErrors } from '../components/assessment-strategy/assessment-strategy';
import { AddonWorkshopAssessmentStrategyDelegate } from './assessment-strategy-delegate';
import {
AddonModWorkshopExampleMode,
AddonModWorkshopPhase,
AddonModWorkshopUserOptions,
AddonModWorkshopData,
AddonModWorkshop,
@ -36,12 +34,16 @@ import {
AddonModWorkshopPhaseTaskData,
AddonModWorkshopSubmissionAssessmentData,
AddonModWorkshopGetAssessmentFormDefinitionData,
AddonModWorkshopAction,
AddonModWorkshopOverallFeedbackMode,
AddonModWorkshopGetAssessmentFormFieldsParsedData,
} from './workshop';
import { AddonModWorkshopOffline, AddonModWorkshopOfflineSubmission } from './workshop-offline';
import { ADDON_MOD_WORKSHOP_COMPONENT } from '@addons/mod/workshop/constants';
import {
ADDON_MOD_WORKSHOP_COMPONENT,
AddonModWorkshopAction,
AddonModWorkshopExampleMode,
AddonModWorkshopOverallFeedbackMode,
AddonModWorkshopPhase,
} from '@addons/mod/workshop/constants';
/**
* Helper to gather some common functions for workshop.

View File

@ -31,7 +31,7 @@ import {
EVALUATE_SUBMISSIONS_TABLE,
SUBMISSIONS_TABLE,
} from './database/workshop';
import { AddonModWorkshopAction } from './workshop';
import { AddonModWorkshopAction } from '../constants';
/**
* Service to handle offline workshop.

View File

@ -26,9 +26,7 @@ import { CoreUtils } from '@services/utils/utils';
import { Translate, makeSingleton } from '@singletons';
import { CoreEvents } from '@singletons/events';
import { AddonModWorkshop,
AddonModWorkshopAction,
AddonModWorkshopData,
AddonModWorkshopSubmissionType,
} from './workshop';
import { AddonModWorkshopHelper } from './workshop-helper';
import { AddonModWorkshopOffline,
@ -37,7 +35,12 @@ import { AddonModWorkshopOffline,
AddonModWorkshopOfflineEvaluateSubmission,
AddonModWorkshopOfflineSubmission,
} from './workshop-offline';
import { ADDON_MOD_WORKSHOP_COMPONENT } from '@addons/mod/workshop/constants';
import {
ADDON_MOD_WORKSHOP_AUTO_SYNCED,
ADDON_MOD_WORKSHOP_COMPONENT,
AddonModWorkshopAction,
AddonModWorkshopSubmissionType,
} from '@addons/mod/workshop/constants';
/**
* Service to sync workshops.
@ -45,9 +48,6 @@ import { ADDON_MOD_WORKSHOP_COMPONENT } from '@addons/mod/workshop/constants';
@Injectable({ providedIn: 'root' })
export class AddonModWorkshopSyncProvider extends CoreSyncBaseProvider<AddonModWorkshopSyncResult> {
static readonly AUTO_SYNCED = 'addon_mod_workshop_autom_synced';
static readonly MANUAL_SYNCED = 'addon_mod_workshop_manual_synced';
protected componentTranslatableString = 'workshop';
constructor() {
@ -94,7 +94,7 @@ export class AddonModWorkshopSyncProvider extends CoreSyncBaseProvider<AddonModW
if (data && data.updated) {
// Sync done. Send event.
CoreEvents.trigger(AddonModWorkshopSyncProvider.AUTO_SYNCED, {
CoreEvents.trigger(ADDON_MOD_WORKSHOP_AUTO_SYNCED, {
workshopId: workshopId,
warnings: data.warnings,
}, siteId);

View File

@ -26,49 +26,23 @@ import { CoreStatusWithWarningsWSResponse, CoreWS, CoreWSExternalFile, CoreWSExt
import { makeSingleton, Translate } from '@singletons';
import { CoreFormFields } from '@singletons/form';
import { AddonModWorkshopOffline } from './workshop-offline';
import { AddonModWorkshopAutoSyncData, AddonModWorkshopSyncProvider } from './workshop-sync';
import { ADDON_MOD_WORKSHOP_COMPONENT } from '@addons/mod/workshop/constants';
import { AddonModWorkshopAutoSyncData } from './workshop-sync';
import {
ADDON_MOD_WORKSHOP_ASSESSMENT_INVALIDATED,
ADDON_MOD_WORKSHOP_ASSESSMENT_SAVED,
ADDON_MOD_WORKSHOP_AUTO_SYNCED,
ADDON_MOD_WORKSHOP_COMPONENT,
ADDON_MOD_WORKSHOP_PER_PAGE,
ADDON_MOD_WORKSHOP_SUBMISSION_CHANGED,
AddonModWorkshopAction,
AddonModWorkshopAssessmentMode,
AddonModWorkshopExampleMode,
AddonModWorkshopOverallFeedbackMode,
AddonModWorkshopPhase,
AddonModWorkshopSubmissionType,
} from '@addons/mod/workshop/constants';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'mmaModWorkshop:';
export enum AddonModWorkshopPhase {
PHASE_SETUP = 10,
PHASE_SUBMISSION = 20,
PHASE_ASSESSMENT = 30,
PHASE_EVALUATION = 40,
PHASE_CLOSED = 50,
}
export enum AddonModWorkshopSubmissionType {
SUBMISSION_TYPE_DISABLED = 0,
SUBMISSION_TYPE_AVAILABLE = 1,
SUBMISSION_TYPE_REQUIRED = 2,
}
export enum AddonModWorkshopExampleMode {
EXAMPLES_VOLUNTARY = 0,
EXAMPLES_BEFORE_SUBMISSION = 1,
EXAMPLES_BEFORE_ASSESSMENT = 2,
}
export enum AddonModWorkshopAction {
ADD = 'add',
DELETE = 'delete',
UPDATE = 'update',
}
export enum AddonModWorkshopAssessmentMode {
ASSESSMENT = 'assessment',
PREVIEW = 'preview',
}
export enum AddonModWorkshopOverallFeedbackMode {
DISABLED = 0,
ENABLED_OPTIONAL = 1,
ENABLED_REQUIRED = 2,
}
declare module '@singletons/events' {
/**
@ -77,10 +51,10 @@ declare module '@singletons/events' {
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
*/
export interface CoreEventsData {
[AddonModWorkshopSyncProvider.AUTO_SYNCED]: AddonModWorkshopAutoSyncData;
[AddonModWorkshopProvider.SUBMISSION_CHANGED]: AddonModWorkshopSubmissionChangedEventData;
[AddonModWorkshopProvider.ASSESSMENT_SAVED]: AddonModWorkshopAssessmentSavedChangedEventData;
[AddonModWorkshopProvider.ASSESSMENT_INVALIDATED]: AddonModWorkshopAssessmentInvalidatedChangedEventData;
[ADDON_MOD_WORKSHOP_AUTO_SYNCED]: AddonModWorkshopAutoSyncData;
[ADDON_MOD_WORKSHOP_SUBMISSION_CHANGED]: AddonModWorkshopSubmissionChangedEventData;
[ADDON_MOD_WORKSHOP_ASSESSMENT_SAVED]: AddonModWorkshopAssessmentSavedChangedEventData;
[ADDON_MOD_WORKSHOP_ASSESSMENT_INVALIDATED]: AddonModWorkshopAssessmentInvalidatedChangedEventData;
}
}
@ -90,11 +64,7 @@ declare module '@singletons/events' {
@Injectable({ providedIn: 'root' })
export class AddonModWorkshopProvider {
static readonly PER_PAGE = 10;
static readonly SUBMISSION_CHANGED = 'addon_mod_workshop_submission_changed';
static readonly ASSESSMENT_SAVED = 'addon_mod_workshop_assessment_saved';
static readonly ASSESSMENT_INVALIDATED = 'addon_mod_workshop_assessment_invalidated';
protected static readonly ROOT_CACHE_KEY = 'mmaModWorkshop:';
/**
* Get cache key for workshop data WS calls.
@ -103,7 +73,7 @@ export class AddonModWorkshopProvider {
* @returns Cache key.
*/
protected getWorkshopDataCacheKey(courseId: number): string {
return ROOT_CACHE_KEY + 'workshop:' + courseId;
return AddonModWorkshopProvider.ROOT_CACHE_KEY + 'workshop:' + courseId;
}
/**
@ -113,7 +83,7 @@ export class AddonModWorkshopProvider {
* @returns Cache key.
*/
protected getWorkshopDataPrefixCacheKey(workshopId: number): string {
return ROOT_CACHE_KEY + workshopId;
return AddonModWorkshopProvider.ROOT_CACHE_KEY + workshopId;
}
/**
@ -562,7 +532,7 @@ export class AddonModWorkshopProvider {
workshopid: workshopId,
groupid: options.groupId,
page: options.page || 0,
perpage: options.perPage || AddonModWorkshopProvider.PER_PAGE,
perpage: options.perPage || ADDON_MOD_WORKSHOP_PER_PAGE,
};
const preSets: CoreSiteWSPreSets = {
@ -593,7 +563,7 @@ export class AddonModWorkshopProvider {
return this.fetchGradeReportsRecursive(workshopId, [], {
...options, // Include all options.
page: 0,
perPage: options.perPage || AddonModWorkshopProvider.PER_PAGE,
perPage: options.perPage || ADDON_MOD_WORKSHOP_PER_PAGE,
siteId: options.siteId || CoreSites.getCurrentSiteId(),
});
}
@ -612,7 +582,7 @@ export class AddonModWorkshopProvider {
options: AddonModWorkshopGetGradesReportOptions = {},
): Promise<AddonModWorkshopGradesData[]> {
options.page = options.page ?? 0;
options.perPage = options.perPage ?? AddonModWorkshopProvider.PER_PAGE;
options.perPage = options.perPage ?? ADDON_MOD_WORKSHOP_PER_PAGE;
const report = await this.getGradesReport(workshopId, options);
@ -1933,7 +1903,7 @@ export type AddonModWorkshopGetSubmissionsOptions = AddonModWorkshopUserOptions
* Options to pass to fetchAllGradeReports.
*/
export type AddonModWorkshopFetchAllGradesReportOptions = AddonModWorkshopGroupOptions & {
perPage?: number; // Records per page to return. Default AddonModWorkshopProvider.PER_PAGE.
perPage?: number; // Records per page to return. Default ADDON_MOD_WORKSHOP_PER_PAGE.
};
/**

View File

@ -60,4 +60,4 @@ const routes: Routes = [
AddonModWorkshopEditSubmissionPage,
],
})
export class AddonModWorkshopLazyModule {}
export default class AddonModWorkshopLazyModule {}

View File

@ -66,7 +66,7 @@ export async function getModWorkshopComponentModules(): Promise<unknown[]> {
const routes: Routes = [
{
path: ADDON_MOD_WORKSHOP_PAGE_NAME,
loadChildren: () => import('./workshop-lazy.module').then(m => m.AddonModWorkshopLazyModule),
loadChildren: () => import('./workshop-lazy.module'),
},
];