MOBILE-4653 course: Move CoreCourseProvider constants

main
Pau Ferrer Ocaña 2024-11-15 12:15:27 +01:00
parent 602c673e7c
commit dab0ea6c6e
32 changed files with 225 additions and 161 deletions

View File

@ -28,7 +28,7 @@ import { Routes } from '@angular/router';
import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module'; import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module';
import { CoreCourseIndexRoutingModule } from '@features/course/course-routing.module'; import { CoreCourseIndexRoutingModule } from '@features/course/course-routing.module';
import { PARTICIPANTS_PAGE_NAME } from '@features/user/constants'; import { PARTICIPANTS_PAGE_NAME } from '@features/user/constants';
import { COURSE_PAGE_NAME } from '@features/course/constants'; import { CORE_COURSE_PAGE_NAME } from '@features/course/constants';
import { ADDON_COMPETENCY_LEARNING_PLANS_PAGE, ADDON_COMPETENCY_COMPETENCIES_PAGE } from './constants'; import { ADDON_COMPETENCY_LEARNING_PLANS_PAGE, ADDON_COMPETENCY_COMPETENCIES_PAGE } from './constants';
/** /**
@ -52,11 +52,11 @@ const mainMenuChildrenRoutes: Routes = [
loadChildren: () => import('./competency-learning-plans-lazy.module'), loadChildren: () => import('./competency-learning-plans-lazy.module'),
}, },
{ {
path: `${COURSE_PAGE_NAME}/:courseId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`, path: `${CORE_COURSE_PAGE_NAME}/:courseId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`,
loadChildren: () => import('./competency-course-details-lazy.module'), loadChildren: () => import('./competency-course-details-lazy.module'),
}, },
{ {
path: `${COURSE_PAGE_NAME}/:courseId/${PARTICIPANTS_PAGE_NAME}/:userId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`, path: `${CORE_COURSE_PAGE_NAME}/:courseId/${PARTICIPANTS_PAGE_NAME}/:userId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`,
loadChildren: () => import('./competency-course-details-lazy.module'), loadChildren: () => import('./competency-course-details-lazy.module'),
}, },
]; ];

View File

@ -16,7 +16,7 @@ import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_LEARNING_PLANS_PAG
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
import { COURSE_PAGE_NAME } from '@features/course/constants'; import { CORE_COURSE_PAGE_NAME } from '@features/course/constants';
import { CoreNavigator } from '@services/navigator'; import { CoreNavigator } from '@services/navigator';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonCompetency } from '../competency'; import { AddonCompetency } from '../competency';
@ -41,7 +41,7 @@ export class AddonCompetencyCompetencyLinkHandlerService extends CoreContentLink
action: async (siteId: string): Promise<void> => { action: async (siteId: string): Promise<void> => {
if (courseId) { if (courseId) {
await CoreNavigator.navigateToSitePath( await CoreNavigator.navigateToSitePath(
`${COURSE_PAGE_NAME}/${courseId}/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`, `${CORE_COURSE_PAGE_NAME}/${courseId}/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`,
{ {
params: { userId: params.userid }, params: { userId: params.userid },
siteId, siteId,

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreCourseAccessDataType } from '@features/course/services/course'; import { CoreCourseAccessDataType } from '@features/course/constants';
import { import {
CoreCourseAccess, CoreCourseAccess,
CoreCourseOptionsHandler, CoreCourseOptionsHandler,

View File

@ -14,7 +14,7 @@
import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/constants'; import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/constants';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { COURSE_PAGE_NAME } from '@features/course/constants'; import { CORE_COURSE_PAGE_NAME } from '@features/course/constants';
import { CorePushNotificationsClickHandler } from '@features/pushnotifications/services/push-delegate'; import { CorePushNotificationsClickHandler } from '@features/pushnotifications/services/push-delegate';
import { CorePushNotificationsNotificationBasicData } from '@features/pushnotifications/services/pushnotifications'; import { CorePushNotificationsNotificationBasicData } from '@features/pushnotifications/services/pushnotifications';
import { CoreNavigator } from '@services/navigator'; import { CoreNavigator } from '@services/navigator';
@ -75,7 +75,7 @@ export class AddonCompetencyPushClickHandlerService implements CorePushNotificat
if (courseId) { if (courseId) {
await CoreNavigator.navigateToSitePath( await CoreNavigator.navigateToSitePath(
`${COURSE_PAGE_NAME}/${courseId}/${ADDON_COMPETENCY_COMPETENCIES_PAGE}/${competencyId}`, `${CORE_COURSE_PAGE_NAME}/${courseId}/${ADDON_COMPETENCY_COMPETENCIES_PAGE}/${competencyId}`,
{ {
params: { userId }, params: { userId },
siteId: notification.site, siteId: notification.site,

View File

@ -14,7 +14,7 @@
import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/constants'; import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/constants';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { COURSE_PAGE_NAME } from '@features/course/constants'; import { CORE_COURSE_PAGE_NAME } from '@features/course/constants';
import { CoreUserProfile } from '@features/user/services/user'; import { CoreUserProfile } from '@features/user/services/user';
import { import {
CoreUserProfileHandler, CoreUserProfileHandler,
@ -112,9 +112,13 @@ export class AddonCompetencyUserHandlerService implements CoreUserProfileHandler
action: (event, user, context, contextId): void => { action: (event, user, context, contextId): void => {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
CoreNavigator.navigateToSitePath( CoreNavigator.navigateToSitePath([
[COURSE_PAGE_NAME, contextId, PARTICIPANTS_PAGE_NAME, user.id, ADDON_COMPETENCY_COMPETENCIES_PAGE].join('/'), CORE_COURSE_PAGE_NAME,
); contextId,
PARTICIPANTS_PAGE_NAME,
user.id,
ADDON_COMPETENCY_COMPETENCIES_PAGE,
].join('/'));
}, },
}; };
} }

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreCourseAccessDataType } from '@features/course/services/course'; import { CoreCourseAccessDataType } from '@features/course/constants';
import { import {
CoreCourseAccess, CoreCourseAccess,
CoreCourseOptionsHandler, CoreCourseOptionsHandler,

View File

@ -37,7 +37,7 @@ import { CoreTagAreaDelegate } from '@features/tag/services/tag-area-delegate';
import { AddonModForumTagAreaHandler } from './services/handlers/tag-area'; import { AddonModForumTagAreaHandler } from './services/handlers/tag-area';
import { CorePushNotificationsDelegate } from '@features/pushnotifications/services/push-delegate'; import { CorePushNotificationsDelegate } from '@features/pushnotifications/services/push-delegate';
import { AddonModForumPushClickHandler } from './services/handlers/push-click'; import { AddonModForumPushClickHandler } from './services/handlers/push-click';
import { COURSE_CONTENTS_PATH } from '@features/course/constants'; import { CORE_COURSE_CONTENTS_PATH } from '@features/course/constants';
import { CoreCourseHelper } from '@features/course/services/course-helper'; import { CoreCourseHelper } from '@features/course/services/course-helper';
import { ADDON_MOD_FORUM_COMPONENT, ADDON_MOD_FORUM_PAGE_NAME, ADDON_MOD_FORUM_SEARCH_PAGE_NAME } from './constants'; import { ADDON_MOD_FORUM_COMPONENT, ADDON_MOD_FORUM_PAGE_NAME, ADDON_MOD_FORUM_SEARCH_PAGE_NAME } from './constants';
@ -58,12 +58,12 @@ const mainMenuRoutes: Routes = [
...conditionalRoutes( ...conditionalRoutes(
[ [
{ {
path: `${COURSE_CONTENTS_PATH}/${ADDON_MOD_FORUM_PAGE_NAME}/new/:timeCreated`, path: `${CORE_COURSE_CONTENTS_PATH}/${ADDON_MOD_FORUM_PAGE_NAME}/new/:timeCreated`,
loadChildren: () => import('./forum-new-discussion-lazy.module'), loadChildren: () => import('./forum-new-discussion-lazy.module'),
data: { discussionsPathPrefix: `${ADDON_MOD_FORUM_PAGE_NAME}/` }, data: { discussionsPathPrefix: `${ADDON_MOD_FORUM_PAGE_NAME}/` },
}, },
{ {
path: `${COURSE_CONTENTS_PATH}/${ADDON_MOD_FORUM_PAGE_NAME}/:discussionId`, path: `${CORE_COURSE_CONTENTS_PATH}/${ADDON_MOD_FORUM_PAGE_NAME}/:discussionId`,
loadChildren: () => import('./forum-discussion-lazy.module'), loadChildren: () => import('./forum-discussion-lazy.module'),
data: { discussionsPathPrefix: `${ADDON_MOD_FORUM_PAGE_NAME}/` }, data: { discussionsPathPrefix: `${ADDON_MOD_FORUM_PAGE_NAME}/` },
}, },

View File

@ -16,7 +16,7 @@ import { conditionalRoutes } from '@/app/app-routing.module';
import { APP_INITIALIZER, NgModule } from '@angular/core'; import { APP_INITIALIZER, NgModule } from '@angular/core';
import { Routes } from '@angular/router'; import { Routes } from '@angular/router';
import { CoreContentLinksDelegate } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreContentLinksDelegate } from '@features/contentlinks/services/contentlinks-delegate';
import { COURSE_CONTENTS_PATH } from '@features/course/constants'; import { CORE_COURSE_CONTENTS_PATH } from '@features/course/constants';
import { CoreCourseContentsRoutingModule } from '@features/course/course-contents-routing.module'; import { CoreCourseContentsRoutingModule } from '@features/course/course-contents-routing.module';
import { CoreCourseHelper } from '@features/course/services/course-helper'; import { CoreCourseHelper } from '@features/course/services/course-helper';
import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate'; import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate';
@ -52,18 +52,18 @@ const mainMenuRoutes: Routes = [
// Single Activity format navigation. // Single Activity format navigation.
{ {
path: `${COURSE_CONTENTS_PATH}/${ADDON_MOD_GLOSSARY_PAGE_NAME}/entry/new`, path: `${CORE_COURSE_CONTENTS_PATH}/${ADDON_MOD_GLOSSARY_PAGE_NAME}/entry/new`,
loadChildren: () => import('./glossary-edit-lazy.module'), loadChildren: () => import('./glossary-edit-lazy.module'),
data: { glossaryPathPrefix: `${ADDON_MOD_GLOSSARY_PAGE_NAME}/` }, data: { glossaryPathPrefix: `${ADDON_MOD_GLOSSARY_PAGE_NAME}/` },
}, },
{ {
path: `${COURSE_CONTENTS_PATH}/${ADDON_MOD_GLOSSARY_PAGE_NAME}/entry/:entrySlug/edit`, path: `${CORE_COURSE_CONTENTS_PATH}/${ADDON_MOD_GLOSSARY_PAGE_NAME}/entry/:entrySlug/edit`,
loadChildren: () => import('./glossary-edit-lazy.module'), loadChildren: () => import('./glossary-edit-lazy.module'),
data: { glossaryPathPrefix: `${ADDON_MOD_GLOSSARY_PAGE_NAME}/` }, data: { glossaryPathPrefix: `${ADDON_MOD_GLOSSARY_PAGE_NAME}/` },
}, },
...conditionalRoutes( ...conditionalRoutes(
[{ [{
path: `${COURSE_CONTENTS_PATH}/${ADDON_MOD_GLOSSARY_PAGE_NAME}/entry/:entrySlug`, path: `${CORE_COURSE_CONTENTS_PATH}/${ADDON_MOD_GLOSSARY_PAGE_NAME}/entry/:entrySlug`,
loadChildren: () => import('./glossary-entry-lazy.module'), loadChildren: () => import('./glossary-entry-lazy.module'),
data: { glossaryPathPrefix: `${ADDON_MOD_GLOSSARY_PAGE_NAME}/` }, data: { glossaryPathPrefix: `${ADDON_MOD_GLOSSARY_PAGE_NAME}/` },
}], }],

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreCourseAccessDataType } from '@features/course/services/course'; import { CoreCourseAccessDataType } from '@features/course/constants';
import { import {
CoreCourseAccess, CoreCourseAccess,
CoreCourseOptionsHandler, CoreCourseOptionsHandler,
@ -47,7 +47,7 @@ export class AddonNotesCourseOptionHandlerService implements CoreCourseOptionsHa
accessData: CoreCourseAccess, accessData: CoreCourseAccess,
navOptions?: CoreCourseUserAdminOrNavOptionIndexed, navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
): Promise<boolean> { ): Promise<boolean> {
if (accessData && accessData.type === CoreCourseAccessDataType.ACCESS_GUEST) { if (accessData?.type === CoreCourseAccessDataType.ACCESS_GUEST) {
return false; // Not enabled for guest access. return false; // Not enabled for guest access.
} }

View File

@ -14,7 +14,8 @@
import { CoreConstants, DownloadStatus } from '@/core/constants'; import { CoreConstants, DownloadStatus } from '@/core/constants';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, OnDestroy, OnInit } from '@angular/core'; import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, OnDestroy, OnInit } from '@angular/core';
import { CoreCourse, CoreCourseProvider, sectionContentIsModule } from '@features/course/services/course'; import { CORE_COURSE_ALL_COURSES_CLEARED, CORE_COURSE_ALL_SECTIONS_ID } from '@features/course/constants';
import { CoreCourse, sectionContentIsModule } from '@features/course/services/course';
import { import {
CoreCourseHelper, CoreCourseHelper,
CoreCourseModuleData, CoreCourseModuleData,
@ -181,7 +182,7 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy {
// Listen for changes in course status. // Listen for changes in course status.
this.courseStatusObserver = CoreEvents.on(CoreEvents.COURSE_STATUS_CHANGED, (data) => { this.courseStatusObserver = CoreEvents.on(CoreEvents.COURSE_STATUS_CHANGED, (data) => {
if (data.courseId === this.courseId || data.courseId === CoreCourseProvider.ALL_COURSES_CLEARED) { if (data.courseId === this.courseId || data.courseId === CORE_COURSE_ALL_COURSES_CLEARED) {
this.updateCourseStatus(data.status); this.updateCourseStatus(data.status);
} }
}, CoreSites.getCurrentSiteId()); }, CoreSites.getCurrentSiteId());
@ -723,7 +724,7 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy {
} }
await Promise.all(sections.map(async (section) => { await Promise.all(sections.map(async (section) => {
if (section.id === CoreCourseProvider.ALL_SECTIONS_ID) { if (section.id === CORE_COURSE_ALL_SECTIONS_ID) {
return; return;
} }

View File

@ -15,7 +15,8 @@
import { DownloadStatus } from '@/core/constants'; import { DownloadStatus } from '@/core/constants';
import { Component, OnDestroy, OnInit } from '@angular/core'; import { Component, OnDestroy, OnInit } from '@angular/core';
import { CoreQueueRunner } from '@classes/queue-runner'; import { CoreQueueRunner } from '@classes/queue-runner';
import { CoreCourse, CoreCourseProvider } from '@features/course/services/course'; import { CORE_COURSE_ALL_COURSES_CLEARED } from '@features/course/constants';
import { CoreCourse } from '@features/course/services/course';
import { CoreCourseHelper } from '@features/course/services/course-helper'; import { CoreCourseHelper } from '@features/course/services/course-helper';
import { CoreCourses, CoreEnrolledCourseData } from '@features/courses/services/courses'; import { CoreCourses, CoreEnrolledCourseData } from '@features/courses/services/courses';
import { CoreSettingsHelper, CoreSiteSpaceUsage } from '@features/settings/services/settings-helper'; import { CoreSettingsHelper, CoreSiteSpaceUsage } from '@features/settings/services/settings-helper';
@ -181,7 +182,7 @@ export class AddonStorageManagerCoursesStoragePage implements OnInit, OnDestroy
* @param courseId Updated course id. * @param courseId Updated course id.
*/ */
private async onCourseUpdated(courseId: number, status: DownloadStatus): Promise<void> { private async onCourseUpdated(courseId: number, status: DownloadStatus): Promise<void> {
if (courseId == CoreCourseProvider.ALL_COURSES_CLEARED) { if (courseId == CORE_COURSE_ALL_COURSES_CLEARED) {
await this.downloadedCoursesQueue.run(() => this.setDownloadedCourses([])); await this.downloadedCoursesQueue.run(() => this.setDownloadedCourses([]));
return; return;

View File

@ -30,7 +30,6 @@ import { CoreDynamicComponent } from '@components/dynamic-component/dynamic-comp
import { CoreCourseAnyCourseData } from '@features/courses/services/courses'; import { CoreCourseAnyCourseData } from '@features/courses/services/courses';
import { import {
CoreCourse, CoreCourse,
CoreCourseProvider,
sectionContentIsModule, sectionContentIsModule,
} from '@features/course/services/course'; } from '@features/course/services/course';
import { import {
@ -57,7 +56,12 @@ import { CoreModals } from '@services/modals';
import { CoreSharedModule } from '@/core/shared.module'; import { CoreSharedModule } from '@/core/shared.module';
import { CoreBlockComponentsModule } from '@features/block/components/components.module'; import { CoreBlockComponentsModule } from '@features/block/components/components.module';
import { CoreSites } from '@services/sites'; import { CoreSites } from '@services/sites';
import { COURSE_ALL_SECTIONS_PREFERRED_PREFIX, COURSE_EXPANDED_SECTIONS_PREFIX } from '@features/course/constants'; import {
CORE_COURSE_ALL_SECTIONS_ID,
CORE_COURSE_ALL_SECTIONS_PREFERRED_PREFIX,
CORE_COURSE_EXPANDED_SECTIONS_PREFIX,
CORE_COURSE_STEALTH_MODULES_SECTION_ID,
} from '@features/course/constants';
import { toBoolean } from '@/core/transforms/boolean'; import { toBoolean } from '@/core/transforms/boolean';
import { CoreInfiniteLoadingComponent } from '@components/infinite-loading/infinite-loading'; import { CoreInfiniteLoadingComponent } from '@components/infinite-loading/infinite-loading';
import { CoreSite } from '@classes/sites/site'; import { CoreSite } from '@classes/sites/site';
@ -129,8 +133,8 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
selectedSection?: CoreCourseSectionToDisplay; selectedSection?: CoreCourseSectionToDisplay;
previousSection?: CoreCourseSectionToDisplay; previousSection?: CoreCourseSectionToDisplay;
nextSection?: CoreCourseSectionToDisplay; nextSection?: CoreCourseSectionToDisplay;
allSectionsId = CoreCourseProvider.ALL_SECTIONS_ID; allSectionsId = CORE_COURSE_ALL_SECTIONS_ID;
stealthModulesSectionId = CoreCourseProvider.STEALTH_MODULES_SECTION_ID; stealthModulesSectionId = CORE_COURSE_STEALTH_MODULES_SECTION_ID;
loaded = false; loaded = false;
lastModuleViewed?: CoreCourseViewedModulesDBRecord; lastModuleViewed?: CoreCourseViewedModulesDBRecord;
viewedModules: Record<number, boolean> = {}; viewedModules: Record<number, boolean> = {};
@ -299,7 +303,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
* @param sections Sections to treat. * @param sections Sections to treat.
*/ */
protected async treatSections(sections: CoreCourseSectionToDisplay[]): Promise<void> { protected async treatSections(sections: CoreCourseSectionToDisplay[]): Promise<void> {
const hasAllSections = sections[0].id === CoreCourseProvider.ALL_SECTIONS_ID; const hasAllSections = sections[0].id === CORE_COURSE_ALL_SECTIONS_ID;
const hasSeveralSections = sections.length > 2 || (sections.length === 2 && !hasAllSections); const hasSeveralSections = sections.length > 2 || (sections.length === 2 && !hasAllSections);
await this.initializeViewedModules(); await this.initializeViewedModules();
@ -765,7 +769,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
* @param show Whether if all sections is preferred. * @param show Whether if all sections is preferred.
*/ */
protected async setAllSectionsPreferred(show: boolean): Promise<void> { protected async setAllSectionsPreferred(show: boolean): Promise<void> {
await this.currentSite?.setLocalSiteConfig(`${COURSE_ALL_SECTIONS_PREFERRED_PREFIX}${this.course.id}`, show ? 1 : 0); await this.currentSite?.setLocalSiteConfig(`${CORE_COURSE_ALL_SECTIONS_PREFERRED_PREFIX}${this.course.id}`, show ? 1 : 0);
} }
/** /**
@ -775,7 +779,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
*/ */
protected async isAllSectionsPreferred(): Promise<boolean> { protected async isAllSectionsPreferred(): Promise<boolean> {
const showAllSections = const showAllSections =
await this.currentSite?.getLocalSiteConfig<number>(`${COURSE_ALL_SECTIONS_PREFERRED_PREFIX}${this.course.id}`, 0); await this.currentSite?.getLocalSiteConfig<number>(`${CORE_COURSE_ALL_SECTIONS_PREFERRED_PREFIX}${this.course.id}`, 0);
return !!showAllSections; return !!showAllSections;
} }
@ -788,7 +792,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
.filter((section) => section.expanded && section.id > 0).map((section) => section.id); .filter((section) => section.expanded && section.id > 0).map((section) => section.id);
await this.currentSite?.setLocalSiteConfig( await this.currentSite?.setLocalSiteConfig(
`${COURSE_EXPANDED_SECTIONS_PREFIX}${this.course.id}`, `${CORE_COURSE_EXPANDED_SECTIONS_PREFIX}${this.course.id}`,
expandedSections.join(','), expandedSections.join(','),
); );
} }
@ -798,7 +802,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
*/ */
protected async initializeExpandedSections(): Promise<void> { protected async initializeExpandedSections(): Promise<void> {
const expandedSections = await CoreUtils.ignoreErrors( const expandedSections = await CoreUtils.ignoreErrors(
this.currentSite?.getLocalSiteConfig<string>(`${COURSE_EXPANDED_SECTIONS_PREFIX}${this.course.id}`), this.currentSite?.getLocalSiteConfig<string>(`${CORE_COURSE_EXPANDED_SECTIONS_PREFIX}${this.course.id}`),
); );
if (expandedSections === undefined) { if (expandedSections === undefined) {

View File

@ -16,8 +16,6 @@ import { CoreSharedModule } from '@/core/shared.module';
import { Component, ElementRef, Input, OnInit } from '@angular/core'; import { Component, ElementRef, Input, OnInit } from '@angular/core';
import { import {
CoreCourse, CoreCourse,
CoreCourseModuleCompletionStatus,
CoreCourseProvider,
sectionContentIsModule, sectionContentIsModule,
} from '@features/course/services/course'; } from '@features/course/services/course';
import { CoreCourseHelper, CoreCourseModuleData, CoreCourseSection } from '@features/course/services/course-helper'; import { CoreCourseHelper, CoreCourseModuleData, CoreCourseSection } from '@features/course/services/course-helper';
@ -28,6 +26,7 @@ import { CoreSites } from '@services/sites';
import { CoreWait } from '@singletons/wait'; import { CoreWait } from '@singletons/wait';
import { ModalController } from '@singletons'; import { ModalController } from '@singletons';
import { CoreDom } from '@singletons/dom'; import { CoreDom } from '@singletons/dom';
import { CoreCourseModuleCompletionStatus, CORE_COURSE_ALL_SECTIONS_ID } from '@features/course/constants';
/** /**
* Component to display course index modal. * Component to display course index modal.
@ -47,7 +46,7 @@ export class CoreCourseCourseIndexComponent implements OnInit {
@Input() selectedId?: number; @Input() selectedId?: number;
@Input() course?: CoreCourseAnyCourseData; @Input() course?: CoreCourseAnyCourseData;
allSectionId = CoreCourseProvider.ALL_SECTIONS_ID; allSectionId = CORE_COURSE_ALL_SECTIONS_ID;
highlighted?: string; highlighted?: string;
sectionsToRender: CourseIndexSection[] = []; sectionsToRender: CourseIndexSection[] = [];
loaded = false; loaded = false;

View File

@ -25,8 +25,9 @@ import { CoreCourseComponentsModule } from '../components.module';
import { toBoolean } from '@/core/transforms/boolean'; import { toBoolean } from '@/core/transforms/boolean';
import { CoreCourseAnyCourseData } from '@features/courses/services/courses'; import { CoreCourseAnyCourseData } from '@features/courses/services/courses';
import { CoreCourseViewedModulesDBRecord } from '@features/course/services/database/course'; import { CoreCourseViewedModulesDBRecord } from '@features/course/services/database/course';
import { CoreCourseModuleCompletionStatus, sectionContentIsModule } from '@features/course/services/course'; import { sectionContentIsModule } from '@features/course/services/course';
import { CoreCourseFormatDelegate } from '@features/course/services/format-delegate'; import { CoreCourseFormatDelegate } from '@features/course/services/format-delegate';
import { CoreCourseModuleCompletionStatus } from '@features/course/constants';
/** /**
* Component to display course section. * Component to display course section.

View File

@ -14,9 +14,9 @@
import { CoreSharedModule } from '@/core/shared.module'; import { CoreSharedModule } from '@/core/shared.module';
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { CoreCourseModuleCompletionStatus } from '@features/course/constants';
import { import {
CoreCourseModuleCompletionStatus,
CoreCourseModuleWSRuleDetails, CoreCourseModuleWSRuleDetails,
} from '@features/course/services/course'; } from '@features/course/services/course';
import { CoreCourseModuleCompletionData } from '@features/course/services/course-helper'; import { CoreCourseModuleCompletionData } from '@features/course/services/course-helper';

View File

@ -18,7 +18,7 @@ import { CoreUser } from '@features/user/services/user';
import { import {
CoreCourseModuleCompletionStatus, CoreCourseModuleCompletionStatus,
CoreCourseModuleCompletionTracking, CoreCourseModuleCompletionTracking,
} from '@features/course/services/course'; } from '@features/course/constants';
import { CoreFilterHelper } from '@features/filter/services/filter-helper'; import { CoreFilterHelper } from '@features/filter/services/filter-helper';
import { Translate } from '@singletons'; import { Translate } from '@singletons';
import { CoreCourseModuleCompletionBaseComponent } from '@features/course/classes/module-completion'; import { CoreCourseModuleCompletionBaseComponent } from '@features/course/classes/module-completion';
@ -76,7 +76,7 @@ export class CoreCourseModuleCompletionLegacyComponent extends CoreCourseModuleC
let langKey: string | undefined; let langKey: string | undefined;
let image: string | undefined; let image: string | undefined;
if (this.completion.tracking === CoreCourseModuleCompletionTracking.COMPLETION_TRACKING_MANUAL) { if (this.completion.tracking === CoreCourseModuleCompletionTracking.MANUAL) {
if (this.completion.state === CoreCourseModuleCompletionStatus.COMPLETION_INCOMPLETE) { if (this.completion.state === CoreCourseModuleCompletionStatus.COMPLETION_INCOMPLETE) {
image = 'completion-manual-n'; image = 'completion-manual-n';
langKey = 'core.completion-alt-manual-n'; langKey = 'core.completion-alt-manual-n';
@ -84,7 +84,7 @@ export class CoreCourseModuleCompletionLegacyComponent extends CoreCourseModuleC
image = 'completion-manual-y'; image = 'completion-manual-y';
langKey = 'core.completion-alt-manual-y'; langKey = 'core.completion-alt-manual-y';
} }
} else if (this.completion.tracking === CoreCourseModuleCompletionTracking.COMPLETION_TRACKING_AUTOMATIC) { } else if (this.completion.tracking === CoreCourseModuleCompletionTracking.AUTOMATIC) {
if (this.completion.state === CoreCourseModuleCompletionStatus.COMPLETION_INCOMPLETE) { if (this.completion.state === CoreCourseModuleCompletionStatus.COMPLETION_INCOMPLETE) {
image = 'completion-auto-n'; image = 'completion-auto-n';
langKey = 'core.completion-alt-auto-n'; langKey = 'core.completion-alt-auto-n';

View File

@ -15,9 +15,7 @@
import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChange } from '@angular/core'; import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChange } from '@angular/core';
import { CoreCourseModuleCompletionBaseComponent } from '@features/course/classes/module-completion'; import { CoreCourseModuleCompletionBaseComponent } from '@features/course/classes/module-completion';
import { import { CoreCourseModuleCompletionStatus } from '@features/course/constants';
CoreCourseModuleCompletionStatus,
} from '@features/course/services/course';
import { CorePopovers } from '@services/popovers'; import { CorePopovers } from '@services/popovers';
import { CoreCourseHelper } from '@features/course/services/course-helper'; import { CoreCourseHelper } from '@features/course/services/course-helper';
import { CoreUser } from '@features/user/services/user'; import { CoreUser } from '@features/user/services/user';

View File

@ -12,10 +12,52 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
export const COURSE_INDEX_PATH = ':courseId'; export const CORE_COURSE_INDEX_PATH = ':courseId';
export const COURSE_PAGE_NAME = 'course'; export const CORE_COURSE_PAGE_NAME = 'course';
export const CONTENTS_PAGE_NAME = 'contents'; export const CORE_COURSE_CONTENTS_PAGE_NAME = 'contents';
export const COURSE_CONTENTS_PATH = `${COURSE_PAGE_NAME}/${COURSE_INDEX_PATH}/${CONTENTS_PAGE_NAME}`; export const CORE_COURSE_CONTENTS_PATH = `${CORE_COURSE_PAGE_NAME}/${CORE_COURSE_INDEX_PATH}/${CORE_COURSE_CONTENTS_PAGE_NAME}`;
export const COURSE_ALL_SECTIONS_PREFERRED_PREFIX = 'CoreCourseFormatAllSectionsPreferred-'; export const CORE_COURSE_ALL_SECTIONS_PREFERRED_PREFIX = 'CoreCourseFormatAllSectionsPreferred-';
export const COURSE_EXPANDED_SECTIONS_PREFIX = 'CoreCourseFormatExpandedSections-'; export const CORE_COURSE_EXPANDED_SECTIONS_PREFIX = 'CoreCourseFormatExpandedSections-';
export const CORE_COURSE_ALL_SECTIONS_ID = -2;
export const CORE_COURSE_STEALTH_MODULES_SECTION_ID = -1;
export const CORE_COURSE_ALL_COURSES_CLEARED = -1;
export const CORE_COURSE_PROGRESS_UPDATED_EVENT = 'progress_updated';
export const CORE_COURSE_AUTO_SYNCED = 'core_course_autom_synced';
export const CORE_COURSE_COMPONENT = 'CoreCourse';
export const CORE_COURSE_CORE_MODULES = [
'assign', 'bigbluebuttonbn', 'book', 'chat', 'choice', 'data', 'feedback', 'folder', 'forum', 'glossary', 'h5pactivity',
'imscp', 'label', 'lesson', 'lti', 'page', 'quiz', 'resource', 'scorm', 'survey', 'url', 'wiki', 'workshop',
];
/**
* Course Module completion status enumeration.
*/
export const enum CoreCourseModuleCompletionStatus {
COMPLETION_INCOMPLETE = 0,
COMPLETION_COMPLETE = 1,
COMPLETION_COMPLETE_PASS = 2,
COMPLETION_COMPLETE_FAIL = 3,
}
/**
* Completion tracking valid values.
*/
export const enum CoreCourseModuleCompletionTracking {
NONE = 0,
MANUAL = 1,
AUTOMATIC = 2,
}
export const CoreCourseAccessDataType = {
ACCESS_GUEST: 'courses_access_guest', // eslint-disable-line @typescript-eslint/naming-convention
ACCESS_DEFAULT: 'courses_access_default', // eslint-disable-line @typescript-eslint/naming-convention
} as const;
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type CoreCourseAccessDataType = typeof CoreCourseAccessDataType[keyof typeof CoreCourseAccessDataType];

View File

@ -22,7 +22,7 @@ import { CoreCourseIndexPage } from '@features/course/pages/index';
import { CoreCourseListModTypePage } from '@features/course/pages/list-mod-type/list-mod-type'; import { CoreCourseListModTypePage } from '@features/course/pages/list-mod-type/list-mod-type';
import { CoreCourseModulePreviewPage } from '@features/course/pages/module-preview/module-preview'; import { CoreCourseModulePreviewPage } from '@features/course/pages/module-preview/module-preview';
import { CoreCourseHelper } from './services/course-helper'; import { CoreCourseHelper } from './services/course-helper';
import { COURSE_INDEX_PATH } from './constants'; import { CORE_COURSE_INDEX_PATH } from './constants';
/** /**
* Build module routes. * Build module routes.
@ -35,7 +35,7 @@ function buildRoutes(injector: Injector): Routes {
return [ return [
{ {
path: COURSE_INDEX_PATH, path: CORE_COURSE_INDEX_PATH,
children: [ children: [
{ {
path: '', path: '',

View File

@ -31,7 +31,7 @@ import { CoreCourseModulesTagAreaHandler } from './services/handlers/modules-tag
import { CoreCourse } from './services/course'; import { CoreCourse } from './services/course';
import { buildRegExpUrlMatcher } from '@/app/app-routing.module'; import { buildRegExpUrlMatcher } from '@/app/app-routing.module';
import { CoreCourseIndexRoutingModule } from '@features/course/course-routing.module'; import { CoreCourseIndexRoutingModule } from '@features/course/course-routing.module';
import { COURSE_PAGE_NAME, CONTENTS_PAGE_NAME } from './constants'; import { CORE_COURSE_PAGE_NAME, CORE_COURSE_CONTENTS_PAGE_NAME } from './constants';
/** /**
* Get course services. * Get course services.
@ -70,7 +70,15 @@ export async function getCourseServices(): Promise<Type<unknown>[]> {
export async function getCourseExportedObjects(): Promise<Record<string, unknown>> { export async function getCourseExportedObjects(): Promise<Record<string, unknown>> {
const { CoreCourseActivityPrefetchHandlerBase } = await import('@features/course/classes/activity-prefetch-handler'); const { CoreCourseActivityPrefetchHandlerBase } = await import('@features/course/classes/activity-prefetch-handler');
const { CoreCourseResourcePrefetchHandlerBase } = await import('@features/course/classes/resource-prefetch-handler'); const { CoreCourseResourcePrefetchHandlerBase } = await import('@features/course/classes/resource-prefetch-handler');
const { CoreCourseAccessDataType } = await import('@features/course/services/course'); const {
CoreCourseAccessDataType,
CORE_COURSE_ALL_SECTIONS_ID,
CORE_COURSE_STEALTH_MODULES_SECTION_ID,
CORE_COURSE_ALL_COURSES_CLEARED,
CORE_COURSE_PROGRESS_UPDATED_EVENT,
CORE_COURSE_COMPONENT,
CORE_COURSE_CORE_MODULES,
} = await import('@features/course/constants');
const { CoreCourseUnsupportedModuleComponent } = const { CoreCourseUnsupportedModuleComponent } =
await import ('@features/course/components/unsupported-module/unsupported-module'); await import ('@features/course/components/unsupported-module/unsupported-module');
const { CoreCourseFormatSingleActivityComponent } = const { CoreCourseFormatSingleActivityComponent } =
@ -83,6 +91,12 @@ export async function getCourseExportedObjects(): Promise<Record<string, unknown
CoreCourseUnsupportedModuleComponent, CoreCourseUnsupportedModuleComponent,
CoreCourseFormatSingleActivityComponent, CoreCourseFormatSingleActivityComponent,
CoreCourseAccessDataType, CoreCourseAccessDataType,
CORE_COURSE_ALL_SECTIONS_ID,
CORE_COURSE_STEALTH_MODULES_SECTION_ID,
CORE_COURSE_ALL_COURSES_CLEARED,
CORE_COURSE_PROGRESS_UPDATED_EVENT,
CORE_COURSE_COMPONENT,
CORE_COURSE_CORE_MODULES,
}; };
/* eslint-enable @typescript-eslint/naming-convention */ /* eslint-enable @typescript-eslint/naming-convention */
} }
@ -111,14 +125,14 @@ export async function getCourseStandaloneComponents(): Promise<Type<unknown>[]>
const routes: Routes = [ const routes: Routes = [
{ {
matcher: buildRegExpUrlMatcher(new RegExp(`^${COURSE_PAGE_NAME}(/deep)*`)), matcher: buildRegExpUrlMatcher(new RegExp(`^${CORE_COURSE_PAGE_NAME}(/deep)*`)),
loadChildren: () => import('@features/course/course-lazy.module'), loadChildren: () => import('@features/course/course-lazy.module'),
}, },
]; ];
const courseIndexRoutes: Routes = [ const courseIndexRoutes: Routes = [
{ {
path: CONTENTS_PAGE_NAME, path: CORE_COURSE_CONTENTS_PAGE_NAME,
loadChildren: () => import('@features/course/course-contents-lazy.module'), loadChildren: () => import('@features/course/course-contents-lazy.module'),
}, },
]; ];

View File

@ -21,8 +21,6 @@ import { CoreCourses, CoreCourseAnyCourseData } from '@features/courses/services
import { import {
CoreCourse, CoreCourse,
CoreCourseCompletionActivityStatus, CoreCourseCompletionActivityStatus,
CoreCourseModuleCompletionStatus,
CoreCourseProvider,
} from '@features/course/services/course'; } from '@features/course/services/course';
import { import {
CoreCourseHelper, CoreCourseHelper,
@ -32,7 +30,7 @@ import {
} from '@features/course/services/course-helper'; } from '@features/course/services/course-helper';
import { CoreCourseFormatDelegate } from '@features/course/services/format-delegate'; import { CoreCourseFormatDelegate } from '@features/course/services/format-delegate';
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate'; import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
import { CoreCourseSync, CoreCourseSyncProvider } from '@features/course/services/sync'; import { CoreCourseSync } from '@features/course/services/sync';
import { CoreCourseFormatComponent } from '../../components/course-format/course-format'; import { CoreCourseFormatComponent } from '../../components/course-format/course-format';
import { import {
CoreEvents, CoreEvents,
@ -43,6 +41,11 @@ import { CoreRefreshContext, CORE_REFRESH_CONTEXT } from '@/core/utils/refresh-c
import { CoreCoursesHelper } from '@features/courses/services/courses-helper'; import { CoreCoursesHelper } from '@features/courses/services/courses-helper';
import { CoreSites } from '@services/sites'; import { CoreSites } from '@services/sites';
import { CoreWait } from '@singletons/wait'; import { CoreWait } from '@singletons/wait';
import {
CoreCourseModuleCompletionStatus,
CORE_COURSE_AUTO_SYNCED,
CORE_COURSE_PROGRESS_UPDATED_EVENT,
} from '@features/course/constants';
/** /**
* Page that displays the contents of a course. * Page that displays the contents of a course.
@ -154,7 +157,7 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy, CoreRefreshCon
this.onCompletionChange(data.completion); this.onCompletionChange(data.completion);
}); });
this.syncObserver = CoreEvents.on(CoreCourseSyncProvider.AUTO_SYNCED, (data) => { this.syncObserver = CoreEvents.on(CORE_COURSE_AUTO_SYNCED, (data) => {
if (!data || data.courseId != this.course.id) { if (!data || data.courseId != this.course.id) {
return; return;
} }
@ -362,7 +365,7 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy, CoreRefreshCon
return; return;
} }
CoreEvents.trigger(CoreCourseProvider.PROGRESS_UPDATED, { CoreEvents.trigger(CORE_COURSE_PROGRESS_UPDATED_EVENT, {
courseId: this.course.id, progress: this.course.progress, courseId: this.course.id, progress: this.course.progress,
}, siteId); }, siteId);
} }

View File

@ -20,11 +20,11 @@ import { CoreCourseFormatDelegate } from '../../services/format-delegate';
import { CoreCourseOptionsDelegate } from '../../services/course-options-delegate'; import { CoreCourseOptionsDelegate } from '../../services/course-options-delegate';
import { CoreCourseAnyCourseData } from '@features/courses/services/courses'; import { CoreCourseAnyCourseData } from '@features/courses/services/courses';
import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { CoreCourse, CoreCourseProvider, CoreCourseWSSection } from '@features/course/services/course'; import { CoreCourse, CoreCourseWSSection } from '@features/course/services/course';
import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper'; import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreNavigationOptions, CoreNavigator } from '@services/navigator'; import { CoreNavigationOptions, CoreNavigator } from '@services/navigator';
import { CONTENTS_PAGE_NAME } from '@features/course/constants'; import { CORE_COURSE_CONTENTS_PAGE_NAME, CORE_COURSE_PROGRESS_UPDATED_EVENT } from '@features/course/constants';
import { CoreDomUtils } from '@services/utils/dom'; import { CoreDomUtils } from '@services/utils/dom';
import { CoreCoursesHelper, CoreCourseWithImageAndColor } from '@features/courses/services/courses-helper'; import { CoreCoursesHelper, CoreCourseWithImageAndColor } from '@features/courses/services/courses-helper';
import { CoreColors } from '@singletons/colors'; import { CoreColors } from '@singletons/colors';
@ -64,7 +64,7 @@ export class CoreCourseIndexPage implements OnInit, OnDestroy {
protected isGuest = false; protected isGuest = false;
protected openModule = true; protected openModule = true;
protected contentsTab: CoreTabsOutletTab & { pageParams: Params } = { protected contentsTab: CoreTabsOutletTab & { pageParams: Params } = {
page: CONTENTS_PAGE_NAME, page: CORE_COURSE_CONTENTS_PAGE_NAME,
title: 'core.course', title: 'core.course',
pageParams: {}, pageParams: {},
}; };
@ -93,7 +93,7 @@ export class CoreCourseIndexPage implements OnInit, OnDestroy {
const siteId = CoreSites.getCurrentSiteId(); const siteId = CoreSites.getCurrentSiteId();
this.progressObserver = CoreEvents.on(CoreCourseProvider.PROGRESS_UPDATED, (data) => { this.progressObserver = CoreEvents.on(CORE_COURSE_PROGRESS_UPDATED_EVENT, (data) => {
if (!this.course || this.course.id !== data.courseId || !('progress' in this.course)) { if (!this.course || this.course.id !== data.courseId || !('progress' in this.course)) {
return; return;
} }

View File

@ -22,10 +22,7 @@ import {
CoreCourseCompletionActivityStatus, CoreCourseCompletionActivityStatus,
CoreCourseModuleWSCompletionData, CoreCourseModuleWSCompletionData,
CoreCourseModuleContentFile, CoreCourseModuleContentFile,
CoreCourseProvider,
CoreCourseWSSection, CoreCourseWSSection,
CoreCourseModuleCompletionTracking,
CoreCourseModuleCompletionStatus,
CoreCourseGetContentsWSModule, CoreCourseGetContentsWSModule,
sectionContentIsModule, sectionContentIsModule,
CoreCourseAnyModuleData, CoreCourseAnyModuleData,
@ -78,6 +75,13 @@ import { CoreEnrolAction, CoreEnrolDelegate } from '@features/enrol/services/enr
import { LazyRoutesModule } from '@/app/app-routing.module'; import { LazyRoutesModule } from '@/app/app-routing.module';
import { CoreModals } from '@services/modals'; import { CoreModals } from '@services/modals';
import { CoreLoadings } from '@services/loadings'; import { CoreLoadings } from '@services/loadings';
import {
CoreCourseModuleCompletionTracking,
CoreCourseModuleCompletionStatus,
CORE_COURSE_ALL_SECTIONS_ID,
CORE_COURSE_STEALTH_MODULES_SECTION_ID,
CORE_COURSE_COMPONENT,
} from '../constants';
/** /**
* Prefetch info of a module. * Prefetch info of a module.
@ -255,7 +259,7 @@ export class CoreCourseHelperProvider {
* @returns Wether section is stealth (accessible but not visible to students). * @returns Wether section is stealth (accessible but not visible to students).
*/ */
isSectionStealth(section: CoreCourseWSSection): boolean { isSectionStealth(section: CoreCourseWSSection): boolean {
return section.hiddenbynumsections === 1 || section.id === CoreCourseProvider.STEALTH_MODULES_SECTION_ID; return section.hiddenbynumsections === 1 || section.id === CORE_COURSE_STEALTH_MODULES_SECTION_ID;
} }
/** /**
@ -283,7 +287,7 @@ export class CoreCourseHelperProvider {
refresh?: boolean, refresh?: boolean,
checkUpdates: boolean = true, checkUpdates: boolean = true,
): Promise<{statusData: CoreCourseModulesStatus; section: CoreCourseSectionWithStatus}> { ): Promise<{statusData: CoreCourseModulesStatus; section: CoreCourseSectionWithStatus}> {
if (section.id === CoreCourseProvider.ALL_SECTIONS_ID) { if (section.id === CORE_COURSE_ALL_SECTIONS_ID) {
throw new CoreError('Invalid section'); throw new CoreError('Invalid section');
} }
@ -462,7 +466,7 @@ export class CoreCourseHelperProvider {
}; };
const getSectionSize = async (section: CoreCourseWSSection): Promise<CoreFileSizeSum> => { const getSectionSize = async (section: CoreCourseWSSection): Promise<CoreFileSizeSum> => {
if (section.id === CoreCourseProvider.ALL_SECTIONS_ID) { if (section.id === CORE_COURSE_ALL_SECTIONS_ID) {
return { size: 0, total: true }; return { size: 0, total: true };
} }
@ -579,7 +583,7 @@ export class CoreCourseHelperProvider {
*/ */
createAllSectionsSection(): CoreCourseSection { createAllSectionsSection(): CoreCourseSection {
return { return {
id: CoreCourseProvider.ALL_SECTIONS_ID, id: CORE_COURSE_ALL_SECTIONS_ID,
name: Translate.instant('core.course.allsections'), name: Translate.instant('core.course.allsections'),
hasContent: true, hasContent: true,
summary: '', summary: '',
@ -1659,7 +1663,7 @@ export class CoreCourseHelperProvider {
if (updateAllSections) { if (updateAllSections) {
// Prefetch all the sections. If the first section is "All sections", use it. Otherwise, use a fake "All sections". // Prefetch all the sections. If the first section is "All sections", use it. Otherwise, use a fake "All sections".
allSectionsSection = sections[0]; allSectionsSection = sections[0];
if (sections[0].id !== CoreCourseProvider.ALL_SECTIONS_ID) { if (sections[0].id !== CORE_COURSE_ALL_SECTIONS_ID) {
allSectionsSection = this.createAllSectionsSection(); allSectionsSection = this.createAllSectionsSection();
} }
allSectionsSection.isDownloading = true; allSectionsSection.isDownloading = true;
@ -1667,7 +1671,7 @@ export class CoreCourseHelperProvider {
const promises = sections.map(async (section) => { const promises = sections.map(async (section) => {
// Download all the sections except "All sections". // Download all the sections except "All sections".
if (section.id === CoreCourseProvider.ALL_SECTIONS_ID) { if (section.id === CORE_COURSE_ALL_SECTIONS_ID) {
return; return;
} }
@ -1706,7 +1710,7 @@ export class CoreCourseHelperProvider {
* @returns Promise resolved when the section is prefetched. * @returns Promise resolved when the section is prefetched.
*/ */
protected async prefetchSingleSectionIfNeeded(section: CoreCourseSectionWithStatus, courseId: number): Promise<void> { protected async prefetchSingleSectionIfNeeded(section: CoreCourseSectionWithStatus, courseId: number): Promise<void> {
if (section.id === CoreCourseProvider.ALL_SECTIONS_ID || section.hiddenbynumsections) { if (section.id === CORE_COURSE_ALL_SECTIONS_ID || section.hiddenbynumsections) {
return; return;
} }
@ -1721,7 +1725,7 @@ export class CoreCourseHelperProvider {
// Download the files in the section description. // Download the files in the section description.
const introFiles = CoreFilepool.extractDownloadableFilesFromHtmlAsFakeFileObjects(section.summary); const introFiles = CoreFilepool.extractDownloadableFilesFromHtmlAsFakeFileObjects(section.summary);
promises.push(CoreUtils.ignoreErrors( promises.push(CoreUtils.ignoreErrors(
CoreFilepool.addFilesToQueue(siteId, introFiles, CoreCourseProvider.COMPONENT, courseId), CoreFilepool.addFilesToQueue(siteId, introFiles, CORE_COURSE_COMPONENT, courseId),
)); ));
try { try {
@ -1782,7 +1786,7 @@ export class CoreCourseHelperProvider {
result: CoreCourseModulesStatus, result: CoreCourseModulesStatus,
courseId: number, courseId: number,
): Promise<void> { ): Promise<void> {
if (section.id === CoreCourseProvider.ALL_SECTIONS_ID) { if (section.id === CORE_COURSE_ALL_SECTIONS_ID) {
return; return;
} }
@ -1881,7 +1885,7 @@ export class CoreCourseHelperProvider {
await Promise.all([ await Promise.all([
...modules.map((module) => this.removeModuleStoredData(module, courseId)), ...modules.map((module) => this.removeModuleStoredData(module, courseId)),
siteId && CoreFilepool.removeFilesByComponent(siteId, CoreCourseProvider.COMPONENT, courseId), siteId && CoreFilepool.removeFilesByComponent(siteId, CORE_COURSE_COMPONENT, courseId),
]); ]);
await CoreCourse.setCourseStatus(courseId, DownloadStatus.DOWNLOADABLE_NOT_DOWNLOADED); await CoreCourse.setCourseStatus(courseId, DownloadStatus.DOWNLOADABLE_NOT_DOWNLOADED);
@ -1922,7 +1926,7 @@ export class CoreCourseHelperProvider {
} }
if (completion.cmid === undefined || if (completion.cmid === undefined ||
completion.tracking !== CoreCourseModuleCompletionTracking.COMPLETION_TRACKING_MANUAL) { completion.tracking !== CoreCourseModuleCompletionTracking.MANUAL) {
return; return;
} }
@ -2087,7 +2091,7 @@ export class CoreCourseHelperProvider {
return undefined; return undefined;
} }
if (completion.tracking === CoreCourseModuleCompletionTracking.COMPLETION_TRACKING_NONE) { if (completion.tracking === CoreCourseModuleCompletionTracking.NONE) {
return undefined; return undefined;
} }

View File

@ -23,7 +23,7 @@ import {
CoreCourses, CoreCourses,
CoreCourseUserAdminOrNavOptionIndexed, CoreCourseUserAdminOrNavOptionIndexed,
} from '@features/courses/services/courses'; } from '@features/courses/services/courses';
import { CoreCourseAccessDataType } from './course'; import { CoreCourseAccessDataType } from '../constants';
import { Params } from '@angular/router'; import { Params } from '@angular/router';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { CorePromisedValue } from '@classes/promised-value'; import { CorePromisedValue } from '@classes/promised-value';

View File

@ -46,7 +46,7 @@ import { CoreCourseHelper, CoreCourseModuleData, CoreCourseModuleCompletionData
import { CoreCourseFormatDelegate } from './format-delegate'; import { CoreCourseFormatDelegate } from './format-delegate';
import { CoreCronDelegate } from '@services/cron'; import { CoreCronDelegate } from '@services/cron';
import { CoreCourseLogCronHandler } from './handlers/log-cron'; import { CoreCourseLogCronHandler } from './handlers/log-cron';
import { CoreCourseAutoSyncData, CoreCourseSyncProvider } from './sync'; import { CoreCourseAutoSyncData } from './sync';
import { CoreTagItem } from '@features/tag/services/tag'; import { CoreTagItem } from '@features/tag/services/tag';
import { CoreNavigationOptions, CoreNavigator } from '@services/navigator'; import { CoreNavigationOptions, CoreNavigator } from '@services/navigator';
import { CoreCourseModuleDelegate } from './module-delegate'; import { CoreCourseModuleDelegate } from './module-delegate';
@ -64,8 +64,18 @@ import { CoreArray } from '@singletons/array';
import { CoreText } from '@singletons/text'; import { CoreText } from '@singletons/text';
import { ArrayElement } from '@/core/utils/types'; import { ArrayElement } from '@/core/utils/types';
import { CORE_COURSES_MY_COURSES_UPDATED_EVENT, CoreCoursesMyCoursesUpdatedEventAction } from '@features/courses/constants'; import { CORE_COURSES_MY_COURSES_UPDATED_EVENT, CoreCoursesMyCoursesUpdatedEventAction } from '@features/courses/constants';
import {
const ROOT_CACHE_KEY = 'mmCourse:'; CoreCourseAccessDataType,
CoreCourseModuleCompletionStatus,
CoreCourseModuleCompletionTracking,
CORE_COURSE_ALL_COURSES_CLEARED,
CORE_COURSE_ALL_SECTIONS_ID,
CORE_COURSE_COMPONENT,
CORE_COURSE_CORE_MODULES,
CORE_COURSE_PROGRESS_UPDATED_EVENT,
CORE_COURSE_STEALTH_MODULES_SECTION_ID,
CORE_COURSE_AUTO_SYNCED,
} from '../constants';
export type CoreCourseProgressUpdated = { progress: number; courseId: number }; export type CoreCourseProgressUpdated = { progress: number; courseId: number };
@ -77,58 +87,18 @@ 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 {
[CoreCourseSyncProvider.AUTO_SYNCED]: CoreCourseAutoSyncData; [CORE_COURSE_AUTO_SYNCED]: CoreCourseAutoSyncData;
[CoreCourseProvider.PROGRESS_UPDATED]: CoreCourseProgressUpdated; [CORE_COURSE_PROGRESS_UPDATED_EVENT]: CoreCourseProgressUpdated;
} }
} }
/**
* Course Module completion status enumeration.
*/
export const enum CoreCourseModuleCompletionStatus {
COMPLETION_INCOMPLETE = 0,
COMPLETION_COMPLETE = 1,
COMPLETION_COMPLETE_PASS = 2,
COMPLETION_COMPLETE_FAIL = 3,
}
/**
* @deprecated since 4.3 Not used anymore.
*/
export const enum CoreCourseCompletionMode {
FULL = 'full',
BASIC = 'basic',
}
/**
* Completion tracking valid values.
*/
export const enum CoreCourseModuleCompletionTracking {
COMPLETION_TRACKING_NONE = 0,
COMPLETION_TRACKING_MANUAL = 1,
COMPLETION_TRACKING_AUTOMATIC = 2,
}
export const CoreCourseAccessDataType = {
ACCESS_GUEST: 'courses_access_guest', // eslint-disable-line @typescript-eslint/naming-convention
ACCESS_DEFAULT: 'courses_access_default', // eslint-disable-line @typescript-eslint/naming-convention
} as const;
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type CoreCourseAccessDataType = typeof CoreCourseAccessDataType[keyof typeof CoreCourseAccessDataType];
/** /**
* Service that provides some features regarding a course. * Service that provides some features regarding a course.
*/ */
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class CoreCourseProvider { export class CoreCourseProvider {
static readonly ALL_SECTIONS_ID = -2;
static readonly STEALTH_MODULES_SECTION_ID = -1;
static readonly ALL_COURSES_CLEARED = -1;
static readonly PROGRESS_UPDATED = 'progress_updated';
/** /**
* @deprecated since 4.4 Not used anymore. Use CoreCourseAccessDataType instead. * @deprecated since 4.4 Not used anymore. Use CoreCourseAccessDataType instead.
*/ */
@ -138,12 +108,32 @@ export class CoreCourseProvider {
*/ */
static readonly ACCESS_DEFAULT = CoreCourseAccessDataType.ACCESS_DEFAULT; static readonly ACCESS_DEFAULT = CoreCourseAccessDataType.ACCESS_DEFAULT;
static readonly COMPONENT = 'CoreCourse'; /**
* @deprecated since 5.0 Not used anymore. Use COURSE_ALL_SECTIONS_ID instead.
*/
static readonly ALL_SECTIONS_ID = CORE_COURSE_ALL_SECTIONS_ID;
/**
* @deprecated since 5.0 Not used anymore. Use COURSE_STEALTH_MODULES_SECTION_ID instead.
*/
static readonly STEALTH_MODULES_SECTION_ID = CORE_COURSE_STEALTH_MODULES_SECTION_ID;
/**
* @deprecated since 5.0 Not used anymore. Use COURSE_ALL_COURSES_CLEARED instead.
*/
static readonly ALL_COURSES_CLEARED = CORE_COURSE_ALL_COURSES_CLEARED;
/**
* @deprecated since 5.0 Not used anymore. Use COURSE_PROGRESS_UPDATED instead.
*/
static readonly PROGRESS_UPDATED = CORE_COURSE_PROGRESS_UPDATED_EVENT;
static readonly CORE_MODULES = [ /**
'assign', 'bigbluebuttonbn', 'book', 'chat', 'choice', 'data', 'feedback', 'folder', 'forum', 'glossary', 'h5pactivity', * @deprecated since 5.0 Not used anymore. Use COURSE_COMPONENT instead.
'imscp', 'label', 'lesson', 'lti', 'page', 'quiz', 'resource', 'scorm', 'survey', 'url', 'wiki', 'workshop', */
]; static readonly COMPONENT = CORE_COURSE_COMPONENT;
/**
* @deprecated since 5.0 Not used anymore. Use COURSE_CORE_MODULES instead.
*/
static readonly CORE_MODULES = CORE_COURSE_CORE_MODULES;
protected logger: CoreLogger; protected logger: CoreLogger;
protected statusTables: LazyMap<AsyncInstance<CoreDatabaseTable<CoreCourseStatusDBRecord>>>; protected statusTables: LazyMap<AsyncInstance<CoreDatabaseTable<CoreCourseStatusDBRecord>>>;
@ -151,6 +141,8 @@ export class CoreCourseProvider {
AsyncInstance<CoreDatabaseTable<CoreCourseViewedModulesDBRecord, CoreCourseViewedModulesDBPrimaryKeys, never>> AsyncInstance<CoreDatabaseTable<CoreCourseViewedModulesDBRecord, CoreCourseViewedModulesDBPrimaryKeys, never>>
>; >;
protected static readonly ROOT_CACHE_KEY = 'mmCourse:';
constructor() { constructor() {
this.logger = CoreLogger.getInstance('CoreCourseProvider'); this.logger = CoreLogger.getInstance('CoreCourseProvider');
this.statusTables = lazyMap( this.statusTables = lazyMap(
@ -253,7 +245,7 @@ export class CoreCourseProvider {
* @returns Whether it's an automatic completion that hasn't been completed yet. * @returns Whether it's an automatic completion that hasn't been completed yet.
*/ */
isIncompleteAutomaticCompletion(completion: CoreCourseModuleCompletionData): boolean { isIncompleteAutomaticCompletion(completion: CoreCourseModuleCompletionData): boolean {
return completion.tracking === CoreCourseModuleCompletionTracking.COMPLETION_TRACKING_AUTOMATIC && return completion.tracking === CoreCourseModuleCompletionTracking.AUTOMATIC &&
completion.state === CoreCourseModuleCompletionStatus.COMPLETION_INCOMPLETE; completion.state === CoreCourseModuleCompletionStatus.COMPLETION_INCOMPLETE;
} }
@ -291,7 +283,7 @@ export class CoreCourseProvider {
await this.statusTables[site.getId()].delete(); await this.statusTables[site.getId()].delete();
this.triggerCourseStatusChanged( this.triggerCourseStatusChanged(
CoreCourseProvider.ALL_COURSES_CLEARED, CORE_COURSE_ALL_COURSES_CLEARED,
DownloadStatus.DOWNLOADABLE_NOT_DOWNLOADED, DownloadStatus.DOWNLOADABLE_NOT_DOWNLOADED,
site.id, site.id,
); );
@ -378,7 +370,7 @@ export class CoreCourseProvider {
const onlineCompletion = completionStatus[offlineCompletion.cmid]; const onlineCompletion = completionStatus[offlineCompletion.cmid];
// If the activity uses manual completion, override the value with the offline one. // If the activity uses manual completion, override the value with the offline one.
if (onlineCompletion.tracking === CoreCourseModuleCompletionTracking.COMPLETION_TRACKING_MANUAL) { if (onlineCompletion.tracking === CoreCourseModuleCompletionTracking.MANUAL) {
onlineCompletion.state = offlineCompletion.completed; onlineCompletion.state = offlineCompletion.completed;
onlineCompletion.offline = true; onlineCompletion.offline = true;
} }
@ -400,7 +392,7 @@ export class CoreCourseProvider {
* @returns Cache key. * @returns Cache key.
*/ */
protected getActivitiesCompletionCacheKey(courseId: number, userId: number): string { protected getActivitiesCompletionCacheKey(courseId: number, userId: number): string {
return ROOT_CACHE_KEY + 'activitiescompletion:' + courseId + ':' + userId; return CoreCourseProvider.ROOT_CACHE_KEY + 'activitiescompletion:' + courseId + ':' + userId;
} }
/** /**
@ -472,7 +464,7 @@ export class CoreCourseProvider {
* @returns Cache key. * @returns Cache key.
*/ */
protected getCourseBlocksCacheKey(courseId: number): string { protected getCourseBlocksCacheKey(courseId: number): string {
return ROOT_CACHE_KEY + 'courseblocks:' + courseId; return CoreCourseProvider.ROOT_CACHE_KEY + 'courseblocks:' + courseId;
} }
/** /**
@ -669,7 +661,7 @@ export class CoreCourseProvider {
let foundModule: CoreCourseGetContentsWSModule | undefined; let foundModule: CoreCourseGetContentsWSModule | undefined;
const foundSection = sections.find((section) => { const foundSection = sections.find((section) => {
if (section.id != CoreCourseProvider.STEALTH_MODULES_SECTION_ID && if (section.id != CORE_COURSE_STEALTH_MODULES_SECTION_ID &&
sectionId !== undefined && sectionId !== undefined &&
sectionId != section.id sectionId != section.id
) { ) {
@ -820,7 +812,7 @@ export class CoreCourseProvider {
* @returns Cache key. * @returns Cache key.
*/ */
protected getModuleBasicInfoByInstanceCacheKey(instanceId: number, moduleName: string): string { protected getModuleBasicInfoByInstanceCacheKey(instanceId: number, moduleName: string): string {
return ROOT_CACHE_KEY + 'moduleByInstance:' + moduleName + ':' + instanceId; return CoreCourseProvider.ROOT_CACHE_KEY + 'moduleByInstance:' + moduleName + ':' + instanceId;
} }
/** /**
@ -830,7 +822,7 @@ export class CoreCourseProvider {
* @returns Cache key. * @returns Cache key.
*/ */
protected getModuleCacheKey(moduleId: number): string { protected getModuleCacheKey(moduleId: number): string {
return ROOT_CACHE_KEY + 'module:' + moduleId; return CoreCourseProvider.ROOT_CACHE_KEY + 'module:' + moduleId;
} }
/** /**
@ -840,7 +832,7 @@ export class CoreCourseProvider {
* @returns Cache key. * @returns Cache key.
*/ */
protected getModuleByModNameCacheKey(modName: string): string { protected getModuleByModNameCacheKey(modName: string): string {
return ROOT_CACHE_KEY + 'module:modName:' + modName; return CoreCourseProvider.ROOT_CACHE_KEY + 'module:modName:' + modName;
} }
/** /**
@ -1069,7 +1061,7 @@ export class CoreCourseProvider {
* @returns Cache key. * @returns Cache key.
*/ */
protected getSectionsCacheKey(courseId: number): string { protected getSectionsCacheKey(courseId: number): string {
return ROOT_CACHE_KEY + 'sections:' + courseId; return CoreCourseProvider.ROOT_CACHE_KEY + 'sections:' + courseId;
} }
/** /**
@ -1408,7 +1400,7 @@ export class CoreCourseProvider {
*/ */
isCoreModule(moduleName: string): boolean { isCoreModule(moduleName: string): boolean {
// If core modules are removed for a certain version we should check the version of the site. // If core modules are removed for a certain version we should check the version of the site.
return CoreCourseProvider.CORE_MODULES.includes(moduleName); return CORE_COURSE_CORE_MODULES.includes(moduleName);
} }
/** /**

View File

@ -29,6 +29,7 @@ import { CoreNetworkError } from '@classes/errors/network-error';
import { makeSingleton, Translate } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
import { CoreEvents } from '@singletons/events'; import { CoreEvents } from '@singletons/events';
import { CoreCourses } from '@features/courses/services/courses'; import { CoreCourses } from '@features/courses/services/courses';
import { CORE_COURSE_AUTO_SYNCED } from '../constants';
/** /**
* Service to sync course offline data. This only syncs the offline data of the course itself, not the offline data of * Service to sync course offline data. This only syncs the offline data of the course itself, not the offline data of
@ -37,8 +38,6 @@ import { CoreCourses } from '@features/courses/services/courses';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class CoreCourseSyncProvider extends CoreSyncBaseProvider<CoreCourseSyncResult> { export class CoreCourseSyncProvider extends CoreSyncBaseProvider<CoreCourseSyncResult> {
static readonly AUTO_SYNCED = 'core_course_autom_synced';
constructor() { constructor() {
super('CoreCourseSyncProvider'); super('CoreCourseSyncProvider');
} }
@ -96,7 +95,7 @@ export class CoreCourseSyncProvider extends CoreSyncBaseProvider<CoreCourseSyncR
} }
// Sync successful, send event. // Sync successful, send event.
CoreEvents.trigger(CoreCourseSyncProvider.AUTO_SYNCED, { CoreEvents.trigger(CORE_COURSE_AUTO_SYNCED, {
courseId: completion.courseid, courseId: completion.courseid,
warnings: result.warnings, warnings: result.warnings,
}, siteId); }, siteId);
@ -270,7 +269,7 @@ export type CoreCourseSyncResult = {
}; };
/** /**
* Data passed to AUTO_SYNCED event. * Data passed to CORE_COURSE_AUTO_SYNCED event.
*/ */
export type CoreCourseAutoSyncData = { export type CoreCourseAutoSyncData = {
courseId: number; courseId: number;

View File

@ -14,7 +14,7 @@
import { DownloadStatus } from '@/core/constants'; import { DownloadStatus } from '@/core/constants';
import { Component, ElementRef, Input, OnChanges, OnDestroy, OnInit } from '@angular/core'; import { Component, ElementRef, Input, OnChanges, OnDestroy, OnInit } from '@angular/core';
import { CoreCourseProvider, CoreCourse } from '@features/course/services/course'; import { CoreCourse } from '@features/course/services/course';
import { CoreCourseHelper, CorePrefetchStatusInfo } from '@features/course/services/course-helper'; import { CoreCourseHelper, CorePrefetchStatusInfo } from '@features/course/services/course-helper';
import { CoreUser } from '@features/user/services/user'; import { CoreUser } from '@features/user/services/user';
import { CoreNavigator } from '@services/navigator'; import { CoreNavigator } from '@services/navigator';
@ -36,6 +36,7 @@ import {
CORE_COURSES_STATE_HIDDEN, CORE_COURSES_STATE_HIDDEN,
CORE_COURSES_STATE_FAVOURITE, CORE_COURSES_STATE_FAVOURITE,
} from '@features/courses/constants'; } from '@features/courses/constants';
import { CORE_COURSE_ALL_COURSES_CLEARED, CORE_COURSE_PROGRESS_UPDATED_EVENT } from '@features/course/constants';
/** /**
* This directive is meant to display an item for a list of courses. * This directive is meant to display an item for a list of courses.
@ -85,7 +86,7 @@ export class CoreCoursesCourseListItemComponent implements OnInit, OnDestroy, On
constructor(element: ElementRef) { constructor(element: ElementRef) {
this.element = element.nativeElement; this.element = element.nativeElement;
const siteId = CoreSites.getCurrentSiteId(); const siteId = CoreSites.getCurrentSiteId();
this.progressObserver = CoreEvents.on(CoreCourseProvider.PROGRESS_UPDATED, (data) => { this.progressObserver = CoreEvents.on(CORE_COURSE_PROGRESS_UPDATED_EVENT, (data) => {
if (!this.course || this.course.id !== data.courseId || !('progress' in this.course)) { if (!this.course || this.course.id !== data.courseId || !('progress' in this.course)) {
return; return;
} }
@ -203,7 +204,7 @@ export class CoreCoursesCourseListItemComponent implements OnInit, OnDestroy, On
// Listen for status change in course. // Listen for status change in course.
this.courseStatusObserver = CoreEvents.on(CoreEvents.COURSE_STATUS_CHANGED, (data: CoreEventCourseStatusChanged) => { this.courseStatusObserver = CoreEvents.on(CoreEvents.COURSE_STATUS_CHANGED, (data: CoreEventCourseStatusChanged) => {
if (data.courseId == this.course.id || data.courseId == CoreCourseProvider.ALL_COURSES_CLEARED) { if (data.courseId == this.course.id || data.courseId == CORE_COURSE_ALL_COURSES_CLEARED) {
this.updateCourseStatus(data.status); this.updateCourseStatus(data.status);
} }
}, CoreSites.getCurrentSiteId()); }, CoreSites.getCurrentSiteId());

View File

@ -29,7 +29,7 @@ import { CoreGradesUserLinkHandler } from './services/handlers/user-link';
import { CoreGradesCourseParticipantsOptionHandler } from '@features/grades/services/handlers/course-participants-option'; import { CoreGradesCourseParticipantsOptionHandler } from '@features/grades/services/handlers/course-participants-option';
import { conditionalRoutes } from '@/app/app-routing.module'; import { conditionalRoutes } from '@/app/app-routing.module';
import { CoreScreen } from '@services/screen'; import { CoreScreen } from '@services/screen';
import { COURSE_PAGE_NAME, COURSE_INDEX_PATH } from '@features/course/constants'; import { CORE_COURSE_PAGE_NAME, CORE_COURSE_INDEX_PATH } from '@features/course/constants';
/** /**
* Get grades services. * Get grades services.
@ -53,12 +53,12 @@ const mainMenuChildrenRoutes: Routes = [
data: { swipeManagerSource: 'courses' }, data: { swipeManagerSource: 'courses' },
}, },
{ {
path: `${COURSE_PAGE_NAME}/:courseId/${PARTICIPANTS_PAGE_NAME}/:userId/${GRADES_PAGE_NAME}`, path: `${CORE_COURSE_PAGE_NAME}/:courseId/${PARTICIPANTS_PAGE_NAME}/:userId/${GRADES_PAGE_NAME}`,
loadChildren: () => import('./grades-course-lazy.module'), loadChildren: () => import('./grades-course-lazy.module'),
}, },
...conditionalRoutes([ ...conditionalRoutes([
{ {
path: `${COURSE_PAGE_NAME}/${COURSE_INDEX_PATH}/${GRADES_PARTICIPANTS_PAGE_NAME}/:userId`, path: `${CORE_COURSE_PAGE_NAME}/${CORE_COURSE_INDEX_PATH}/${GRADES_PARTICIPANTS_PAGE_NAME}/:userId`,
loadChildren: () => import('./grades-course-lazy.module'), loadChildren: () => import('./grades-course-lazy.module'),
data: { swipeManagerSource: 'participants' }, data: { swipeManagerSource: 'participants' },
}, },

View File

@ -22,7 +22,7 @@ import {
CoreCourseSearchedData, CoreCourseSearchedData,
CoreCourseUserAdminOrNavOptionIndexed, CoreCourseUserAdminOrNavOptionIndexed,
} from '@features/courses/services/courses'; } from '@features/courses/services/courses';
import { CoreCourse, CoreCourseAccessDataType } from '@features/course/services/course'; import { CoreCourse } from '@features/course/services/course';
import { import {
CoreGrades, CoreGrades,
CoreGradesGradeItem, CoreGradesGradeItem,
@ -45,6 +45,7 @@ import { CoreCourseModuleDelegate } from '@features/course/services/module-deleg
import { CoreCourseAccess } from '@features/course/services/course-options-delegate'; import { CoreCourseAccess } from '@features/course/services/course-options-delegate';
import { CoreLoadings } from '@services/loadings'; import { CoreLoadings } from '@services/loadings';
import { convertTextToHTMLElement } from '@/core/utils/create-html-element'; import { convertTextToHTMLElement } from '@/core/utils/create-html-element';
import { CoreCourseAccessDataType } from '@features/course/constants';
export const GRADES_PAGE_NAME = 'grades'; export const GRADES_PAGE_NAME = 'grades';
export const GRADES_PARTICIPANTS_PAGE_NAME = 'participant-grades'; export const GRADES_PARTICIPANTS_PAGE_NAME = 'participant-grades';

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { COURSE_PAGE_NAME } from '@features/course/constants'; import { CORE_COURSE_PAGE_NAME } from '@features/course/constants';
import { CoreGrades } from '@features/grades/services/grades'; import { CoreGrades } from '@features/grades/services/grades';
import { CoreUserProfile } from '@features/user/services/user'; import { CoreUserProfile } from '@features/user/services/user';
@ -99,7 +99,7 @@ export class CoreGradesUserHandlerService implements CoreUserProfileHandler {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
CoreNavigator.navigateToSitePath( CoreNavigator.navigateToSitePath(
[COURSE_PAGE_NAME, contextId, PARTICIPANTS_PAGE_NAME, user.id, GRADES_PAGE_NAME].join('/'), [CORE_COURSE_PAGE_NAME, contextId, PARTICIPANTS_PAGE_NAME, user.id, GRADES_PAGE_NAME].join('/'),
); );
}, },
}; };

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreCourseAccessDataType } from '@features/course/services/course'; import { CoreCourseAccessDataType } from '@features/course/constants';
import { import {
CoreCourseAccess, CoreCourseAccess,
CoreCourseOptionsHandler, CoreCourseOptionsHandler,

View File

@ -34,7 +34,7 @@ import { CoreUserHelper } from './services/user-helper';
import { AppRoutingModule, conditionalRoutes } from '@/app/app-routing.module'; import { AppRoutingModule, conditionalRoutes } from '@/app/app-routing.module';
import { CoreScreen } from '@services/screen'; import { CoreScreen } from '@services/screen';
import { CoreEvents } from '@singletons/events'; import { CoreEvents } from '@singletons/events';
import { COURSE_PAGE_NAME, COURSE_INDEX_PATH } from '@features/course/constants'; import { CORE_COURSE_PAGE_NAME, CORE_COURSE_INDEX_PATH } from '@features/course/constants';
import { PARTICIPANTS_PAGE_NAME } from './constants'; import { PARTICIPANTS_PAGE_NAME } from './constants';
/** /**
@ -74,7 +74,7 @@ const routes: Routes = [
}, },
...conditionalRoutes([ ...conditionalRoutes([
{ {
path: `${COURSE_PAGE_NAME}/${COURSE_INDEX_PATH}/${PARTICIPANTS_PAGE_NAME}/:userId`, path: `${CORE_COURSE_PAGE_NAME}/${CORE_COURSE_INDEX_PATH}/${PARTICIPANTS_PAGE_NAME}/:userId`,
loadChildren: () => import('@features/user/user-profile-lazy.module'), loadChildren: () => import('@features/user/user-profile-lazy.module'),
data: { data: {
swipeManagerSource: 'participants', swipeManagerSource: 'participants',