MOBILE-4616 quiz: Move quiz constants to a file
parent
e115e840c1
commit
d3b02b07e4
|
@ -26,7 +26,6 @@ import { CoreTextUtils } from '@services/utils/text';
|
|||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { Translate } from '@singletons';
|
||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
import { AddonModQuizModuleHandlerService } from '../../services/handlers/module';
|
||||
import { AddonModQuizPrefetchHandler } from '../../services/handlers/prefetch';
|
||||
import {
|
||||
AddonModQuiz,
|
||||
|
@ -42,10 +41,15 @@ import { AddonModQuizAttempt, AddonModQuizHelper, AddonModQuizQuizData } from '.
|
|||
import {
|
||||
AddonModQuizAutoSyncData,
|
||||
AddonModQuizSync,
|
||||
AddonModQuizSyncProvider,
|
||||
AddonModQuizSyncResult,
|
||||
} from '../../services/quiz-sync';
|
||||
import { ADDON_MOD_QUIZ_ATTEMPT_FINISHED_EVENT, ADDON_MOD_QUIZ_COMPONENT, AddonModQuizAttemptStates } from '../../constants';
|
||||
import {
|
||||
ADDON_MOD_QUIZ_ATTEMPT_FINISHED_EVENT,
|
||||
ADDON_MOD_QUIZ_AUTO_SYNCED,
|
||||
ADDON_MOD_QUIZ_COMPONENT,
|
||||
ADDON_MOD_QUIZ_PAGE_NAME,
|
||||
AddonModQuizAttemptStates,
|
||||
} from '../../constants';
|
||||
import { QuestionDisplayOptionsMarks } from '@features/question/constants';
|
||||
|
||||
/**
|
||||
|
@ -83,7 +87,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
bestGrade?: AddonModQuizGetUserBestGradeWSResponse; // Best grade data.
|
||||
|
||||
protected fetchContentDefaultError = 'addon.mod_quiz.errorgetquiz'; // Default error to show when loading contents.
|
||||
protected syncEventName = AddonModQuizSyncProvider.AUTO_SYNCED;
|
||||
protected syncEventName = ADDON_MOD_QUIZ_AUTO_SYNCED;
|
||||
|
||||
protected autoReview?: AddonModQuizAttemptFinishedData; // Data to auto-review an attempt after finishing.
|
||||
protected quizAccessInfo?: AddonModQuizGetQuizAccessInformationWSResponse; // Quiz access info.
|
||||
|
@ -505,7 +509,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
this.hasPlayed = true;
|
||||
|
||||
CoreNavigator.navigateToSitePath(
|
||||
`${AddonModQuizModuleHandlerService.PAGE_NAME}/${this.courseId}/${this.module.id}/player`,
|
||||
`${ADDON_MOD_QUIZ_PAGE_NAME}/${this.courseId}/${this.module.id}/player`,
|
||||
{
|
||||
params: {
|
||||
moduleUrl: this.module.url,
|
||||
|
@ -657,7 +661,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
*/
|
||||
async reviewAttempt(attemptId: number): Promise<void> {
|
||||
await CoreNavigator.navigateToSitePath(
|
||||
`${AddonModQuizModuleHandlerService.PAGE_NAME}/${this.courseId}/${this.module.id}/review/${attemptId}`,
|
||||
`${ADDON_MOD_QUIZ_PAGE_NAME}/${this.courseId}/${this.module.id}/review/${attemptId}`,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,10 +14,14 @@
|
|||
|
||||
export const ADDON_MOD_QUIZ_COMPONENT = 'mmaModQuiz';
|
||||
|
||||
export const ADDON_MOD_QUIZ_PAGE_NAME = 'mod_quiz';
|
||||
|
||||
export const ADDON_MOD_QUIZ_FEATURE_NAME = 'CoreCourseModuleDelegate_AddonModQuiz';
|
||||
|
||||
export const ADDON_MOD_QUIZ_ATTEMPT_FINISHED_EVENT = 'addon_mod_quiz_attempt_finished';
|
||||
|
||||
export const ADDON_MOD_QUIZ_AUTO_SYNCED = 'addon_mod_quiz_autom_synced';
|
||||
|
||||
export const ADDON_MOD_QUIZ_SHOW_TIME_BEFORE_DEADLINE = 3600;
|
||||
export const ADDON_MOD_QUIZ_IMMEDIATELY_AFTER_PERIOD = 120; // Time considered 'immedately after the attempt', in seconds.
|
||||
|
||||
|
|
|
@ -53,4 +53,4 @@ const routes: Routes = [
|
|||
AddonModQuizReviewPage,
|
||||
],
|
||||
})
|
||||
export class AddonModQuizLazyModule {}
|
||||
export default class AddonModQuizLazyModule {}
|
||||
|
|
|
@ -28,12 +28,12 @@ import { SITE_SCHEMA } from './services/database/quiz';
|
|||
import { AddonModQuizGradeLinkHandler } from './services/handlers/grade-link';
|
||||
import { AddonModQuizIndexLinkHandler } from './services/handlers/index-link';
|
||||
import { AddonModQuizListLinkHandler } from './services/handlers/list-link';
|
||||
import { AddonModQuizModuleHandler, AddonModQuizModuleHandlerService } from './services/handlers/module';
|
||||
import { AddonModQuizModuleHandler } from './services/handlers/module';
|
||||
import { AddonModQuizPrefetchHandler } from './services/handlers/prefetch';
|
||||
import { AddonModQuizPushClickHandler } from './services/handlers/push-click';
|
||||
import { AddonModQuizReviewLinkHandler } from './services/handlers/review-link';
|
||||
import { AddonModQuizSyncCronHandler } from './services/handlers/sync-cron';
|
||||
import { ADDON_MOD_QUIZ_COMPONENT } from './constants';
|
||||
import { ADDON_MOD_QUIZ_COMPONENT, ADDON_MOD_QUIZ_PAGE_NAME } from './constants';
|
||||
|
||||
/**
|
||||
* Get mod Quiz services.
|
||||
|
@ -69,8 +69,8 @@ export async function getModQuizComponentModules(): Promise<unknown[]> {
|
|||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: AddonModQuizModuleHandlerService.PAGE_NAME,
|
||||
loadChildren: () => import('./quiz-lazy.module').then(m => m.AddonModQuizLazyModule),
|
||||
path: ADDON_MOD_QUIZ_PAGE_NAME,
|
||||
loadChildren: () => import('./quiz-lazy.module'),
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import { CoreConstants, ModPurpose } from '@/core/constants';
|
|||
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
||||
import { ADDON_MOD_QUIZ_PAGE_NAME } from '../../constants';
|
||||
|
||||
/**
|
||||
* Handler to support quiz modules.
|
||||
|
@ -25,11 +26,9 @@ import { CoreModuleHandlerBase } from '@features/course/classes/module-base-hand
|
|||
@Injectable({ providedIn: 'root' })
|
||||
export class AddonModQuizModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler {
|
||||
|
||||
static readonly PAGE_NAME = 'mod_quiz';
|
||||
|
||||
name = 'AddonModQuiz';
|
||||
modName = 'quiz';
|
||||
protected pageName = AddonModQuizModuleHandlerService.PAGE_NAME;
|
||||
protected pageName = ADDON_MOD_QUIZ_PAGE_NAME;
|
||||
|
||||
supportedFeatures = {
|
||||
[CoreConstants.FEATURE_GROUPS]: true,
|
||||
|
|
|
@ -23,7 +23,6 @@ import { CoreDomUtils } from '@services/utils/dom';
|
|||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { makeSingleton, Translate } from '@singletons';
|
||||
import { AddonModQuizAccessRuleDelegate } from './access-rules-delegate';
|
||||
import { AddonModQuizModuleHandlerService } from './handlers/module';
|
||||
import {
|
||||
AddonModQuiz,
|
||||
AddonModQuizAttemptWSData,
|
||||
|
@ -34,6 +33,7 @@ import {
|
|||
import { AddonModQuizOffline } from './quiz-offline';
|
||||
import {
|
||||
ADDON_MOD_QUIZ_IMMEDIATELY_AFTER_PERIOD,
|
||||
ADDON_MOD_QUIZ_PAGE_NAME,
|
||||
AddonModQuizAttemptStates,
|
||||
AddonModQuizDisplayOptionsAttemptStates,
|
||||
} from '../constants';
|
||||
|
@ -349,7 +349,7 @@ export class AddonModQuizHelperProvider {
|
|||
|
||||
// Go to the review page.
|
||||
await CoreNavigator.navigateToSitePath(
|
||||
`${AddonModQuizModuleHandlerService.PAGE_NAME}/${module.course}/${module.id}/review/${attemptId}`,
|
||||
`${ADDON_MOD_QUIZ_PAGE_NAME}/${module.course}/${module.id}/review/${attemptId}`,
|
||||
{
|
||||
params: {
|
||||
page: page == undefined || isNaN(page) ? -1 : page,
|
||||
|
|
|
@ -31,7 +31,7 @@ import { AddonModQuizAttemptDBRecord } from './database/quiz';
|
|||
import { AddonModQuizPrefetchHandler } from './handlers/prefetch';
|
||||
import { AddonModQuiz, AddonModQuizAttemptWSData, AddonModQuizQuizWSData } from './quiz';
|
||||
import { AddonModQuizOffline, AddonModQuizQuestionsWithAnswers } from './quiz-offline';
|
||||
import { ADDON_MOD_QUIZ_COMPONENT } from '../constants';
|
||||
import { ADDON_MOD_QUIZ_AUTO_SYNCED, ADDON_MOD_QUIZ_COMPONENT } from '../constants';
|
||||
|
||||
/**
|
||||
* Service to sync quizzes.
|
||||
|
@ -39,8 +39,6 @@ import { ADDON_MOD_QUIZ_COMPONENT } from '../constants';
|
|||
@Injectable({ providedIn: 'root' })
|
||||
export class AddonModQuizSyncProvider extends CoreCourseActivitySyncBaseProvider<AddonModQuizSyncResult> {
|
||||
|
||||
static readonly AUTO_SYNCED = 'addon_mod_quiz_autom_synced';
|
||||
|
||||
protected componentTranslatableString = 'quiz';
|
||||
|
||||
constructor() {
|
||||
|
@ -221,7 +219,7 @@ export class AddonModQuizSyncProvider extends CoreCourseActivitySyncBaseProvider
|
|||
|
||||
if (data) {
|
||||
// Sync successful. Send event.
|
||||
CoreEvents.trigger(AddonModQuizSyncProvider.AUTO_SYNCED, {
|
||||
CoreEvents.trigger(ADDON_MOD_QUIZ_AUTO_SYNCED, {
|
||||
quizId: quiz.id,
|
||||
attemptFinished: data.attemptFinished,
|
||||
warnings: data.warnings,
|
||||
|
|
|
@ -37,7 +37,7 @@ import { makeSingleton, Translate } from '@singletons';
|
|||
import { CoreLogger } from '@singletons/logger';
|
||||
import { AddonModQuizAccessRuleDelegate } from './access-rules-delegate';
|
||||
import { AddonModQuizOffline, AddonModQuizQuestionsWithAnswers } from './quiz-offline';
|
||||
import { AddonModQuizAutoSyncData, AddonModQuizSyncProvider } from './quiz-sync';
|
||||
import { AddonModQuizAutoSyncData } from './quiz-sync';
|
||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
||||
import {
|
||||
QUESTION_INVALID_STATE_CLASSES,
|
||||
|
@ -52,6 +52,7 @@ import {
|
|||
AddonModQuizGradeMethods,
|
||||
AddonModQuizDisplayOptionsAttemptStates,
|
||||
ADDON_MOD_QUIZ_IMMEDIATELY_AFTER_PERIOD,
|
||||
ADDON_MOD_QUIZ_AUTO_SYNCED,
|
||||
} from '../constants';
|
||||
import { CoreIonicColorNames } from '@singletons/colors';
|
||||
|
||||
|
@ -64,7 +65,7 @@ declare module '@singletons/events' {
|
|||
*/
|
||||
export interface CoreEventsData {
|
||||
[ADDON_MOD_QUIZ_ATTEMPT_FINISHED_EVENT]: AddonModQuizAttemptFinishedData;
|
||||
[AddonModQuizSyncProvider.AUTO_SYNCED]: AddonModQuizAutoSyncData;
|
||||
[ADDON_MOD_QUIZ_AUTO_SYNCED]: AddonModQuizAutoSyncData;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue