diff --git a/src/addons/block/calendarupcoming/services/block-handler.ts b/src/addons/block/calendarupcoming/services/block-handler.ts index ac1c0dd77..4820df1f0 100644 --- a/src/addons/block/calendarupcoming/services/block-handler.ts +++ b/src/addons/block/calendarupcoming/services/block-handler.ts @@ -40,6 +40,7 @@ export class AddonBlockCalendarUpcomingHandlerService extends CoreBlockBaseHandl */ getDisplayData(block: CoreCourseBlock, contextLevel: string, instanceId: number): CoreBlockHandlerData { const linkParams: Params = contextLevel == 'course' ? { courseId: instanceId } : {}; + linkParams.upcoming = true; return { title: 'addon.block_calendarupcoming.pluginname', diff --git a/src/addons/blog/blog-lazy.module.ts b/src/addons/blog/blog-lazy.module.ts index ff61fe333..5fab11220 100644 --- a/src/addons/blog/blog-lazy.module.ts +++ b/src/addons/blog/blog-lazy.module.ts @@ -21,10 +21,14 @@ import { CoreCommentsComponentsModule } from '@features/comments/components/comp import { CoreTagComponentsModule } from '@features/tag/components/components.module'; import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module'; +import { AddonBlogMainMenuHandlerService } from './services/handlers/mainmenu'; function buildRoutes(injector: Injector): Routes { return [ ...buildTabMainRoutes(injector, { + data: { + mainMenuTabRoot: AddonBlogMainMenuHandlerService.PAGE_NAME, + }, component: AddonBlogEntriesPage, }), ]; diff --git a/src/addons/calendar/calendar-lazy.module.ts b/src/addons/calendar/calendar-lazy.module.ts index 1a925fbef..7c6e1658b 100644 --- a/src/addons/calendar/calendar-lazy.module.ts +++ b/src/addons/calendar/calendar-lazy.module.ts @@ -16,6 +16,7 @@ import { Injector, NgModule } from '@angular/core'; import { Route, RouterModule, ROUTES, Routes } from '@angular/router'; import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module'; +import { AddonCalendarMainMenuHandlerService } from './services/handlers/mainmenu'; export const AddonCalendarEditRoute: Route = { path: 'edit/:eventId', @@ -33,14 +34,14 @@ function buildRoutes(injector: Injector): Routes { { path: 'index', data: { - isMainMenuRoot: true, + mainMenuTabRoot: AddonCalendarMainMenuHandlerService.PAGE_NAME, }, loadChildren: () => import('@/addons/calendar/pages/index/index.module').then(m => m.AddonCalendarIndexPageModule), }, { path: 'list', data: { - isMainMenuRoot: true, + mainMenuTabRoot: AddonCalendarMainMenuHandlerService.PAGE_NAME, }, loadChildren: () => import('@/addons/calendar/pages/list/list.module').then(m => m.AddonCalendarListPageModule), }, diff --git a/src/addons/competency/competency-lazy.module.ts b/src/addons/competency/competency-lazy.module.ts index 09dce93a7..65be44eb5 100644 --- a/src/addons/competency/competency-lazy.module.ts +++ b/src/addons/competency/competency-lazy.module.ts @@ -25,11 +25,15 @@ import { AddonCompetencyCompetencyPage } from './pages/competency/competency'; import { AddonCompetencyCompetencySummaryPage } from './pages/competencysummary/competencysummary'; import { AddonCompetencyCourseCompetenciesPage } from './pages/coursecompetencies/coursecompetencies.page'; import { AddonCompetencyCourseCompetenciesPageModule } from './pages/coursecompetencies/coursecompetencies.module'; +import { AddonCompetencyMainMenuHandlerService } from './services/handlers/mainmenu'; const mobileRoutes: Routes = [ { path: '', pathMatch: 'full', + data: { + mainMenuTabRoot: AddonCompetencyMainMenuHandlerService.PAGE_NAME, + }, component: AddonCompetencyPlanListPage, }, { @@ -75,6 +79,9 @@ const tabletRoutes: Routes = [ }, { path: '', + data: { + mainMenuTabRoot: AddonCompetencyMainMenuHandlerService.PAGE_NAME, + }, component: AddonCompetencyPlanListPage, children: [ { diff --git a/src/addons/messages/pages/discussions-35/discussions.module.ts b/src/addons/messages/pages/discussions-35/discussions.module.ts index e5b0b56b1..15ec2604e 100644 --- a/src/addons/messages/pages/discussions-35/discussions.module.ts +++ b/src/addons/messages/pages/discussions-35/discussions.module.ts @@ -22,12 +22,13 @@ import { CoreSharedModule } from '@/core/shared.module'; import { CoreSearchComponentsModule } from '@features/search/components/components.module'; import { AddonMessagesDiscussions35Page } from './discussions.page'; +import { AddonMessagesMainMenuHandlerService } from '@addons/messages/services/handlers/mainmenu'; const mobileRoutes: Routes = [ { path: '', data: { - isMainMenuRoot: true, + mainMenuTabRoot: AddonMessagesMainMenuHandlerService.PAGE_NAME, }, component: AddonMessagesDiscussions35Page, }, @@ -38,7 +39,7 @@ const tabletRoutes: Routes = [ { path: '', data: { - isMainMenuRoot: true, + mainMenuTabRoot: AddonMessagesMainMenuHandlerService.PAGE_NAME, }, component: AddonMessagesDiscussions35Page, children: [ diff --git a/src/addons/messages/pages/group-conversations/group-conversations.module.ts b/src/addons/messages/pages/group-conversations/group-conversations.module.ts index 57b851b41..a4390583e 100644 --- a/src/addons/messages/pages/group-conversations/group-conversations.module.ts +++ b/src/addons/messages/pages/group-conversations/group-conversations.module.ts @@ -21,12 +21,13 @@ import { CoreScreen } from '@services/screen'; import { CoreSharedModule } from '@/core/shared.module'; import { AddonMessagesGroupConversationsPage } from './group-conversations.page'; +import { AddonMessagesMainMenuHandlerService } from '@addons/messages/services/handlers/mainmenu'; const mobileRoutes: Routes = [ { path: '', data: { - isMainMenuRoot: true, + mainMenuTabRoot: AddonMessagesMainMenuHandlerService.PAGE_NAME, }, component: AddonMessagesGroupConversationsPage, }, @@ -37,7 +38,7 @@ const tabletRoutes: Routes = [ { path: '', data: { - isMainMenuRoot: true, + mainMenuTabRoot: AddonMessagesMainMenuHandlerService.PAGE_NAME, }, component: AddonMessagesGroupConversationsPage, children: [ diff --git a/src/addons/mod/assign/services/handlers/prefetch.ts b/src/addons/mod/assign/services/handlers/prefetch.ts index ab3d2ff95..f924bb67b 100644 --- a/src/addons/mod/assign/services/handlers/prefetch.ts +++ b/src/addons/mod/assign/services/handlers/prefetch.ts @@ -211,13 +211,9 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref } /** - * Prefetch a module. - * - * @param module Module. - * @param courseId Course ID the module belongs to. - * @return Promise resolved when done. + * @inheritdoc */ - prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise { + prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise { return this.prefetchPackage(module, courseId, this.prefetchAssign.bind(this, module, courseId)); } @@ -226,12 +222,11 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref * * @param module Module. * @param courseId Course ID the module belongs to. + * @param siteId Site ID. * @return Promise resolved when done. */ - protected async prefetchAssign(module: CoreCourseAnyModuleData, courseId?: number): Promise { + protected async prefetchAssign(module: CoreCourseAnyModuleData, courseId: number, siteId: string): Promise { const userId = CoreSites.getCurrentSiteUserId(); - courseId = courseId || module.course || CoreSites.getCurrentSiteHomeId(); - const siteId = CoreSites.getCurrentSiteId(); const options: CoreSitesCommonWSOptions = { readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK, diff --git a/src/addons/mod/chat/services/handlers/prefetch.ts b/src/addons/mod/chat/services/handlers/prefetch.ts index d321a03a3..335d3a1b5 100644 --- a/src/addons/mod/chat/services/handlers/prefetch.ts +++ b/src/addons/mod/chat/services/handlers/prefetch.ts @@ -17,7 +17,7 @@ import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/ import { CoreCourse, CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course'; import { CoreUser } from '@features/user/services/user'; import { CoreGroups } from '@services/groups'; -import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; +import { CoreSitesReadingStrategy } from '@services/sites'; import { CoreUtils } from '@services/utils/utils'; import { makeSingleton } from '@singletons'; import { AddonModChat, AddonModChatProvider, AddonModChatSession } from '../chat'; @@ -64,7 +64,7 @@ export class AddonModChatPrefetchHandlerService extends CoreCourseActivityPrefet /** * @inheritdoc */ - prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise { + prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise { return this.prefetchPackage(module, courseId, this.prefetchChat.bind(this, module, courseId)); } @@ -73,10 +73,10 @@ export class AddonModChatPrefetchHandlerService extends CoreCourseActivityPrefet * * @param module The module object returned by WS. * @param courseId Course ID the module belongs to. + * @param siteId Site ID. * @return Promise resolved when done. */ - protected async prefetchChat(module: CoreCourseAnyModuleData, courseId: number): Promise { - const siteId = CoreSites.getCurrentSiteId(); + protected async prefetchChat(module: CoreCourseAnyModuleData, courseId: number, siteId: string): Promise { const options = { readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK, siteId, diff --git a/src/addons/mod/choice/services/handlers/prefetch.ts b/src/addons/mod/choice/services/handlers/prefetch.ts index 31721344d..0aa454612 100644 --- a/src/addons/mod/choice/services/handlers/prefetch.ts +++ b/src/addons/mod/choice/services/handlers/prefetch.ts @@ -17,7 +17,7 @@ import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/ import { CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course'; import { CoreUser } from '@features/user/services/user'; import { CoreFilepool } from '@services/filepool'; -import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; +import { CoreSitesReadingStrategy } from '@services/sites'; import { CoreUtils } from '@services/utils/utils'; import { CoreWSFile } from '@services/ws'; import { makeSingleton } from '@singletons'; @@ -38,7 +38,7 @@ export class AddonModChoicePrefetchHandlerService extends CoreCourseActivityPref /** * @inheritdoc */ - prefetch(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean): Promise { + prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise { return this.prefetchPackage(module, courseId, this.prefetchChoice.bind(this, module, courseId, !!single)); } @@ -55,10 +55,8 @@ export class AddonModChoicePrefetchHandlerService extends CoreCourseActivityPref module: CoreCourseAnyModuleData, courseId: number, single: boolean, - siteId?: string, + siteId: string, ): Promise { - siteId = siteId || CoreSites.getCurrentSiteId(); - const commonOptions = { readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK, siteId, diff --git a/src/addons/mod/data/services/handlers/prefetch.ts b/src/addons/mod/data/services/handlers/prefetch.ts index f10453d61..92844d596 100644 --- a/src/addons/mod/data/services/handlers/prefetch.ts +++ b/src/addons/mod/data/services/handlers/prefetch.ts @@ -212,7 +212,7 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet /** * @inheritdoc */ - prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise { + prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise { return this.prefetchPackage(module, courseId, this.prefetchDatabase.bind(this, module, courseId)); } @@ -221,12 +221,10 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet * * @param module Module. * @param courseId Course ID the module belongs to. + * @param siteId Site ID. * @return Promise resolved when done. */ - protected async prefetchDatabase(module: CoreCourseAnyModuleData, courseId?: number): Promise { - const siteId = CoreSites.getCurrentSiteId(); - courseId = courseId || module.course || CoreSites.getCurrentSiteHomeId(); - + protected async prefetchDatabase(module: CoreCourseAnyModuleData, courseId: number, siteId: string): Promise { const options = { cmId: module.id, readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK, diff --git a/src/addons/mod/feedback/services/handlers/prefetch.ts b/src/addons/mod/feedback/services/handlers/prefetch.ts index b2ac5d3e9..97faa96ac 100644 --- a/src/addons/mod/feedback/services/handlers/prefetch.ts +++ b/src/addons/mod/feedback/services/handlers/prefetch.ts @@ -17,7 +17,7 @@ import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/ import { CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course'; import { CoreFilepool } from '@services/filepool'; import { CoreGroups } from '@services/groups'; -import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; +import { CoreSitesReadingStrategy } from '@services/sites'; import { CoreTimeUtils } from '@services/utils/time'; import { CoreUtils } from '@services/utils/utils'; import { CoreWSFile } from '@services/ws'; @@ -122,7 +122,7 @@ export class AddonModFeedbackPrefetchHandlerService extends CoreCourseActivityPr /** * @inheritdoc */ - prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise { + prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise { return this.prefetchPackage(module, courseId, this.prefetchFeedback.bind(this, module, courseId)); } @@ -131,10 +131,10 @@ export class AddonModFeedbackPrefetchHandlerService extends CoreCourseActivityPr * * @param module Module. * @param courseId Course ID the module belongs to. + * @param siteId Site ID. * @return Promise resolved when done. */ - protected async prefetchFeedback(module: CoreCourseAnyModuleData, courseId: number): Promise { - const siteId = CoreSites.getCurrentSiteId(); + protected async prefetchFeedback(module: CoreCourseAnyModuleData, courseId: number, siteId: string): Promise { const commonOptions = { readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK, siteId, diff --git a/src/addons/mod/forum/services/handlers/prefetch.ts b/src/addons/mod/forum/services/handlers/prefetch.ts index 3e09810e0..722fd004b 100644 --- a/src/addons/mod/forum/services/handlers/prefetch.ts +++ b/src/addons/mod/forum/services/handlers/prefetch.ts @@ -171,15 +171,9 @@ export class AddonModForumPrefetchHandlerService extends CoreCourseActivityPrefe } /** - * Prefetch a module. - * - * @param module Module. - * @param courseId Course ID the module belongs to. - * @param single True if we're downloading a single module, false if we're downloading a whole section. - * @param dirPath Path of the directory where to store all the content files. - * @return Promise resolved when done. + * @inheritdoc */ - prefetch(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean): Promise { + prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise { return this.prefetchPackage(module, courseId, this.prefetchForum.bind(this, module, courseId, single)); } diff --git a/src/addons/mod/glossary/services/handlers/prefetch.ts b/src/addons/mod/glossary/services/handlers/prefetch.ts index 0c722bdce..3c29641d3 100644 --- a/src/addons/mod/glossary/services/handlers/prefetch.ts +++ b/src/addons/mod/glossary/services/handlers/prefetch.ts @@ -97,7 +97,7 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr /** * @inheritdoc */ - prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise { + prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise { return this.prefetchPackage(module, courseId, this.prefetchGlossary.bind(this, module, courseId)); } @@ -110,8 +110,6 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr * @return Promise resolved when done. */ protected async prefetchGlossary(module: CoreCourseAnyModuleData, courseId: number, siteId: string): Promise { - siteId = siteId || CoreSites.getCurrentSiteId(); - const options = { cmId: module.id, readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK, diff --git a/src/addons/mod/h5pactivity/services/handlers/prefetch.ts b/src/addons/mod/h5pactivity/services/handlers/prefetch.ts index 3d8375652..df1f199ef 100644 --- a/src/addons/mod/h5pactivity/services/handlers/prefetch.ts +++ b/src/addons/mod/h5pactivity/services/handlers/prefetch.ts @@ -76,7 +76,7 @@ export class AddonModH5PActivityPrefetchHandlerService extends CoreCourseActivit /** * @inheritdoc */ - prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise { + prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise { return this.prefetchPackage(module, courseId, this.prefetchActivity.bind(this, module, courseId)); } @@ -91,10 +91,8 @@ export class AddonModH5PActivityPrefetchHandlerService extends CoreCourseActivit protected async prefetchActivity( module: CoreCourseAnyModuleData, courseId: number, - siteId?: string, + siteId: string, ): Promise { - siteId = siteId || CoreSites.getCurrentSiteId(); - const h5pActivity = await AddonModH5PActivity.getH5PActivity(courseId, module.id, { readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK, siteId, diff --git a/src/addons/mod/lesson/services/handlers/prefetch.ts b/src/addons/mod/lesson/services/handlers/prefetch.ts index f99e844d8..8369dee99 100644 --- a/src/addons/mod/lesson/services/handlers/prefetch.ts +++ b/src/addons/mod/lesson/services/handlers/prefetch.ts @@ -231,17 +231,10 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref } /** - * Prefetch a module. - * - * @param module Module. - * @param courseId Course ID the module belongs to. - * @param single True if we're downloading a single module, false if we're downloading a whole section. - * @param dirPath Path of the directory where to store all the content files. - * @return Promise resolved when done. + * @inheritdoc */ - // eslint-disable-next-line @typescript-eslint/no-unused-vars - prefetch(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean, dirPath?: string): Promise { - return this.prefetchPackage(module, courseId, this.prefetchLesson.bind(this, module, courseId, single)); + prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise { + return this.prefetchPackage(module, courseId, this.prefetchLesson.bind(this, module, courseId, !!single)); } /** @@ -250,12 +243,15 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref * @param module Module. * @param courseId Course ID the module belongs to. * @param single True if we're downloading a single module, false if we're downloading a whole section. + * @param siteId Site ID. * @return Promise resolved when done. */ - protected async prefetchLesson(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean): Promise { - const siteId = CoreSites.getCurrentSiteId(); - courseId = courseId || module.course || CoreSites.getCurrentSiteHomeId(); - + protected async prefetchLesson( + module: CoreCourseAnyModuleData, + courseId: number, + single: boolean, + siteId: string, + ): Promise { const commonOptions = { readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK, siteId, diff --git a/src/addons/mod/quiz/services/handlers/prefetch.ts b/src/addons/mod/quiz/services/handlers/prefetch.ts index f5ca3f793..982b5920e 100644 --- a/src/addons/mod/quiz/services/handlers/prefetch.ts +++ b/src/addons/mod/quiz/services/handlers/prefetch.ts @@ -269,7 +269,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet */ async prefetch( module: SyncedModule, - courseId?: number, + courseId: number, single?: boolean, dirPath?: string, canStart: boolean = true, @@ -282,9 +282,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet return; } - const siteId = CoreSites.getCurrentSiteId(); - - return this.prefetchPackage(module, courseId, this.prefetchQuiz.bind(this, module, courseId, single, siteId, canStart)); + return this.prefetchPackage(module, courseId, this.prefetchQuiz.bind(this, module, courseId, !!single, canStart)); } /** @@ -293,16 +291,16 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet * @param module Module. * @param courseId Course ID the module belongs to. * @param single True if we're downloading a single module, false if we're downloading a whole section. - * @param siteId Site ID. * @param canStart If true, start a new attempt if needed. + * @param siteId Site ID. * @return Promise resolved when done. */ protected async prefetchQuiz( module: CoreCourseAnyModuleData, courseId: number, single: boolean, - siteId: string, canStart: boolean, + siteId: string, ): Promise { const commonOptions = { readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK, diff --git a/src/addons/mod/scorm/services/handlers/prefetch.ts b/src/addons/mod/scorm/services/handlers/prefetch.ts index f92274403..907622300 100644 --- a/src/addons/mod/scorm/services/handlers/prefetch.ts +++ b/src/addons/mod/scorm/services/handlers/prefetch.ts @@ -47,12 +47,10 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe dirPath?: string, onProgress?: AddonModScormProgressCallback, ): Promise { - const siteId = CoreSites.getCurrentSiteId(); - return this.prefetchPackage( module, courseId, - this.downloadOrPrefetchScorm.bind(this, module, courseId, true, siteId, false, onProgress), + this.downloadOrPrefetchScorm.bind(this, module, courseId, true, false, onProgress), ); } @@ -62,18 +60,18 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe * @param module Module. * @param courseId Course ID the module belongs to. * @param single True if we're downloading a single module, false if we're downloading a whole section. - * @param siteId Site ID. * @param prefetch True to prefetch, false to download right away. * @param onProgress Function to call on progress. + * @param siteId Site ID. * @return Promise resolved with the "extra" data to store: the hash of the file. */ protected async downloadOrPrefetchScorm( module: CoreCourseAnyModuleData, courseId: number, single: boolean, - siteId: string, prefetch: boolean, - onProgress?: AddonModScormProgressCallback, + onProgress: AddonModScormProgressCallback | undefined, + siteId: string, ): Promise { const scorm = await this.getScorm(module, courseId, siteId); @@ -370,12 +368,10 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe dirPath?: string, onProgress?: AddonModScormProgressCallback, ): Promise { - const siteId = CoreSites.getCurrentSiteId(); - return this.prefetchPackage( module, courseId, - this.downloadOrPrefetchScorm.bind(this, module, courseId, single, siteId, true, onProgress), + this.downloadOrPrefetchScorm.bind(this, module, courseId, single, true, onProgress), ); } diff --git a/src/addons/mod/survey/components/index/addon-mod-survey-index.html b/src/addons/mod/survey/components/index/addon-mod-survey-index.html index c3f2ea353..4278d0b91 100644 --- a/src/addons/mod/survey/components/index/addon-mod-survey-index.html +++ b/src/addons/mod/survey/components/index/addon-mod-survey-index.html @@ -78,38 +78,41 @@ - - + + + - - - - {{question.num}}. {{ question.text }} - - - + + + + {{question.num}}. {{ question.text }} + + + - - - - - - - - - {{ 'core.choose' | translate }} - - {{option}} - - - - - + + + + + + + + + {{ 'core.choose' | translate }} + + {{option}} + + + + + + diff --git a/src/addons/mod/survey/services/handlers/prefetch.ts b/src/addons/mod/survey/services/handlers/prefetch.ts index 6f75862d2..fca2d7852 100644 --- a/src/addons/mod/survey/services/handlers/prefetch.ts +++ b/src/addons/mod/survey/services/handlers/prefetch.ts @@ -67,7 +67,7 @@ export class AddonModSurveyPrefetchHandlerService extends CoreCourseActivityPref /** * @inheritdoc */ - prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise { + prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise { return this.prefetchPackage(module, courseId, this.prefetchSurvey.bind(this, module, courseId)); } diff --git a/src/addons/mod/wiki/services/handlers/prefetch.ts b/src/addons/mod/wiki/services/handlers/prefetch.ts index a8d9d0160..d6b3b4179 100644 --- a/src/addons/mod/wiki/services/handlers/prefetch.ts +++ b/src/addons/mod/wiki/services/handlers/prefetch.ts @@ -130,7 +130,7 @@ export class AddonModWikiPrefetchHandlerService extends CoreCourseActivityPrefet /** * @inheritdoc */ - async prefetch(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean): Promise { + async prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise { // Get the download time of the package before starting the download (otherwise we'd always get current time). const siteId = CoreSites.getCurrentSiteId(); @@ -138,7 +138,12 @@ export class AddonModWikiPrefetchHandlerService extends CoreCourseActivityPrefet const downloadTime = data?.downloadTime || 0; - return this.prefetchPackage(module, courseId, this.prefetchWiki.bind(this, module, courseId, single, downloadTime, siteId)); + return this.prefetchPackage( + module, + courseId, + this.prefetchWiki.bind(this, module, courseId, !!single, downloadTime), + siteId, + ); } /** diff --git a/src/addons/mod/workshop/services/handlers/prefetch.ts b/src/addons/mod/workshop/services/handlers/prefetch.ts index 0c62e0832..088002c86 100644 --- a/src/addons/mod/workshop/services/handlers/prefetch.ts +++ b/src/addons/mod/workshop/services/handlers/prefetch.ts @@ -210,7 +210,7 @@ export class AddonModWorkshopPrefetchHandlerService extends CoreCourseActivityPr /** * @inheritdoc */ - prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise { + prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise { return this.prefetchPackage(module, courseId, this.prefetchWorkshop.bind(this, module, courseId)); } @@ -258,9 +258,6 @@ export class AddonModWorkshopPrefetchHandlerService extends CoreCourseActivityPr * @return Promise resolved when done. */ protected async prefetchWorkshop(module: CoreCourseAnyModuleData, courseId: number, siteId: string): Promise { - - siteId = siteId || CoreSites.getCurrentSiteId(); - const userIds: number[] = []; const commonOptions = { readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK, diff --git a/src/addons/notifications/notifications-lazy.module.ts b/src/addons/notifications/notifications-lazy.module.ts index eac71a80f..2e0aa2445 100644 --- a/src/addons/notifications/notifications-lazy.module.ts +++ b/src/addons/notifications/notifications-lazy.module.ts @@ -16,13 +16,14 @@ import { Injector, NgModule } from '@angular/core'; import { RouterModule, ROUTES, Routes } from '@angular/router'; import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module'; +import { AddonNotificationsMainMenuHandlerService } from './services/handlers/mainmenu'; function buildRoutes(injector: Injector): Routes { return [ { path: 'list', data: { - isMainMenuRoot: true, + mainMenuTabRoot: AddonNotificationsMainMenuHandlerService.PAGE_NAME, }, loadChildren: () => import('./pages/list/list.module').then(m => m.AddonNotificationsListPageModule), }, diff --git a/src/addons/privatefiles/privatefiles-lazy.module.ts b/src/addons/privatefiles/privatefiles-lazy.module.ts index 79e5096b3..fa78f9da5 100644 --- a/src/addons/privatefiles/privatefiles-lazy.module.ts +++ b/src/addons/privatefiles/privatefiles-lazy.module.ts @@ -16,13 +16,14 @@ import { Injector, NgModule } from '@angular/core'; import { RouterModule, ROUTES, Routes } from '@angular/router'; import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module'; +import { AddonPrivateFilesMainMenuHandlerService } from './services/handlers/mainmenu'; function buildRoutes(injector: Injector): Routes { return [ { path: 'root', data: { - isMainMenuRoot: true, + mainMenuTabRoot: AddonPrivateFilesMainMenuHandlerService.PAGE_NAME, }, loadChildren: () => import('./pages/index/index.module').then(m => m.AddonPrivateFilesIndexPageModule), }, diff --git a/src/core/features/course/classes/activity-prefetch-handler.ts b/src/core/features/course/classes/activity-prefetch-handler.ts index 4b58dc5eb..1b8617b01 100644 --- a/src/core/features/course/classes/activity-prefetch-handler.ts +++ b/src/core/features/course/classes/activity-prefetch-handler.ts @@ -78,8 +78,8 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe */ async prefetchPackage( module: CoreCourseAnyModuleData, - courseId: number | undefined, - downloadFunction: () => Promise, + courseId: number, + downloadFunction: (siteId: string) => Promise, siteId?: string, ): Promise { siteId = siteId || CoreSites.getCurrentSiteId(); @@ -111,8 +111,8 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe protected async changeStatusAndPrefetch( module: CoreCourseAnyModuleData, courseId: number | undefined, - downloadFunction: () => Promise, - siteId?: string, + downloadFunction: (siteId: string) => Promise, + siteId: string, ): Promise { try { await this.setDownloading(module.id, siteId); @@ -125,7 +125,7 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe ]); // Call the download function. - let extra = await downloadFunction(); + let extra = await downloadFunction(siteId); // Only accept string types. if (typeof extra != 'string') { diff --git a/src/core/features/course/classes/resource-prefetch-handler.ts b/src/core/features/course/classes/resource-prefetch-handler.ts index 67880f2ae..a11108d27 100644 --- a/src/core/features/course/classes/resource-prefetch-handler.ts +++ b/src/core/features/course/classes/resource-prefetch-handler.ts @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { CoreError } from '@classes/errors/error'; import { CoreNetworkError } from '@classes/errors/network-error'; import { CoreFilterHelper } from '@features/filter/services/filter-helper'; import { CoreApp } from '@services/app'; @@ -191,12 +190,7 @@ export class CoreCourseResourcePrefetchHandlerBase extends CoreCourseModulePrefe * @param dirPath Path of the directory where to store all the content files. * @return Promise resolved when done. */ - prefetch(module: CoreCourseWSModule, courseId?: number, single?: boolean, dirPath?: string): Promise { - courseId = courseId || module.course; - if (!courseId) { - throw new CoreError('Course ID not supplied.'); - } - + prefetch(module: CoreCourseWSModule, courseId: number, single?: boolean, dirPath?: string): Promise { return this.downloadOrPrefetch(module, courseId, true, dirPath); } diff --git a/src/core/features/course/services/module-prefetch-delegate.ts b/src/core/features/course/services/module-prefetch-delegate.ts index bf2e33a06..04d7fbc4c 100644 --- a/src/core/features/course/services/module-prefetch-delegate.ts +++ b/src/core/features/course/services/module-prefetch-delegate.ts @@ -182,7 +182,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate; + prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean, dirPath?: string): Promise; /** * Download the module. diff --git a/src/core/features/grades/grades-lazy.module.ts b/src/core/features/grades/grades-lazy.module.ts index 64d960301..e60242302 100644 --- a/src/core/features/grades/grades-lazy.module.ts +++ b/src/core/features/grades/grades-lazy.module.ts @@ -23,10 +23,14 @@ import { CoreGradesCoursePage } from './pages/course/course.page'; import { CoreGradesCoursePageModule } from './pages/course/course.module'; import { CoreGradesCoursesPage } from './pages/courses/courses.page'; import { CoreGradesGradePage } from './pages/grade/grade.page'; +import { CoreGradesMainMenuHandlerService } from './services/handlers/mainmenu'; const mobileRoutes: Routes = [ { path: '', + data: { + mainMenuTabRoot: CoreGradesMainMenuHandlerService.PAGE_NAME, + }, component: CoreGradesCoursesPage, }, { @@ -42,6 +46,9 @@ const mobileRoutes: Routes = [ const tabletRoutes: Routes = [ { path: '', + data: { + mainMenuTabRoot: CoreGradesMainMenuHandlerService.PAGE_NAME, + }, component: CoreGradesCoursesPage, children: [ { diff --git a/src/core/features/mainmenu/pages/home/home.module.ts b/src/core/features/mainmenu/pages/home/home.module.ts index 2ad028009..c60828634 100644 --- a/src/core/features/mainmenu/pages/home/home.module.ts +++ b/src/core/features/mainmenu/pages/home/home.module.ts @@ -21,6 +21,7 @@ import { CoreSharedModule } from '@/core/shared.module'; import { CoreMainMenuHomePage } from './home'; import { MAIN_MENU_HOME_ROUTES } from './home-routing.module'; import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module'; +import { CoreMainMenuHomeHandlerService } from '@features/mainmenu/services/handlers/mainmenu'; function buildRoutes(injector: Injector): Routes { const routes = resolveModuleRoutes(injector, MAIN_MENU_HOME_ROUTES); @@ -29,7 +30,7 @@ function buildRoutes(injector: Injector): Routes { ...buildTabMainRoutes(injector, { path: '', data: { - isMainMenuRoot: true, + mainMenuTabRoot: CoreMainMenuHomeHandlerService.PAGE_NAME, }, component: CoreMainMenuHomePage, children: routes.children, diff --git a/src/core/features/mainmenu/pages/menu/menu.ts b/src/core/features/mainmenu/pages/menu/menu.ts index b2c968bbd..1eb2af34f 100644 --- a/src/core/features/mainmenu/pages/menu/menu.ts +++ b/src/core/features/mainmenu/pages/menu/menu.ts @@ -176,12 +176,12 @@ export class CoreMainMenuPage implements OnInit, OnDestroy { e.stopImmediatePropagation(); // Current tab was clicked. Check if user is already at root level. - const mainMenuRootRoute = CoreNavigator.getCurrentRoute({ routeData: { isMainMenuRoot: true } }); - if (mainMenuRootRoute) { + const isMainMenuRoot = await this.currentRouteIsMainMenuRoot(); + if (isMainMenuRoot) { return; // Already at root level, nothing to do. } - // Current route doesn't define isMainMenuRoot. Check if the current path is the tab one. + // Maybe the route isn't defined as it should. Check if the current path is the tab one. const currentPath = CoreNavigator.getCurrentPath(); if (currentPath == `/main/${page}`) { return; // Already at root level, nothing to do. @@ -227,8 +227,8 @@ export class CoreMainMenuPage implements OnInit, OnDestroy { event.detail.register(-10, async (processNextHandler: () => void) => { // This callback can be called at the same time as Ionic's back navigation callback. // Check if user is already at the root of a tab. - const mainMenuRootRoute = CoreNavigator.getCurrentRoute({ routeData: { isMainMenuRoot: true } }); - if (!mainMenuRootRoute) { + const isMainMenuRoot = await this.currentRouteIsMainMenuRoot(); + if (!isMainMenuRoot) { return; // Not at root level, let Ionic handle the navigation. } @@ -257,6 +257,16 @@ export class CoreMainMenuPage implements OnInit, OnDestroy { }); } + /** + * Check if current route is the root of the current main menu tab. + * + * @return Promise. + */ + protected async currentRouteIsMainMenuRoot(): Promise { + // Check if the current route is the root of the current main menu tab. + return !!CoreNavigator.getCurrentRoute({ routeData: { mainMenuTabRoot: CoreNavigator.getCurrentMainMenuTab() } }); + } + } /** diff --git a/src/core/features/mainmenu/pages/more/more.module.ts b/src/core/features/mainmenu/pages/more/more.module.ts index e1a10ac61..1999f1b49 100644 --- a/src/core/features/mainmenu/pages/more/more.module.ts +++ b/src/core/features/mainmenu/pages/more/more.module.ts @@ -18,6 +18,7 @@ import { RouterModule, ROUTES } from '@angular/router'; import { CoreSharedModule } from '@/core/shared.module'; import { CoreMainMenuMorePage } from './more'; import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module'; +import { CoreMainMenuProvider } from '@features/mainmenu/services/mainmenu'; @NgModule({ imports: [ @@ -31,7 +32,7 @@ import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.modu useFactory: (injector: Injector) => buildTabMainRoutes(injector, { component: CoreMainMenuMorePage, data: { - isMainMenuRoot: true, + mainMenuTabRoot: CoreMainMenuProvider.MORE_PAGE_NAME, }, }), }, diff --git a/src/core/features/siteplugins/classes/handlers/module-prefetch-handler.ts b/src/core/features/siteplugins/classes/handlers/module-prefetch-handler.ts index 5353cb0b3..24e58be5a 100644 --- a/src/core/features/siteplugins/classes/handlers/module-prefetch-handler.ts +++ b/src/core/features/siteplugins/classes/handlers/module-prefetch-handler.ts @@ -222,14 +222,11 @@ export class CoreSitePluginsModulePrefetchHandler extends CoreCourseActivityPref /** * @inheritdoc */ - prefetch(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean, dirPath?: string): Promise { - const siteId = CoreSites.getCurrentSiteId(); - + prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean, dirPath?: string): Promise { return this.prefetchPackage( module, courseId, - this.downloadPrefetchPlugin.bind(this, module, courseId, true, dirPath, siteId), - siteId, + this.downloadPrefetchPlugin.bind(this, module, courseId, true, dirPath), ); } diff --git a/src/core/features/tag/tag-lazy.module.ts b/src/core/features/tag/tag-lazy.module.ts index 3156dc8c6..e0c6f7b0e 100644 --- a/src/core/features/tag/tag-lazy.module.ts +++ b/src/core/features/tag/tag-lazy.module.ts @@ -16,6 +16,7 @@ import { Injector, NgModule } from '@angular/core'; import { Route, RouterModule, ROUTES, Routes } from '@angular/router'; import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module'; +import { CoreTagMainMenuHandlerService } from './services/handlers/mainmenu'; export const CoreTagIndexAreaRoute: Route = { path: 'index-area', @@ -32,7 +33,7 @@ function buildRoutes(injector: Injector): Routes { { path: 'search', data: { - isMainMenuRoot: true, + mainMenuTabRoot: CoreTagMainMenuHandlerService.PAGE_NAME, }, loadChildren: () => import('@features/tag//pages/search/search.page.module').then(m => m.CoreTagSearchPageModule), }, diff --git a/src/core/services/app.ts b/src/core/services/app.ts index 7febb968a..96454cc1b 100644 --- a/src/core/services/app.ts +++ b/src/core/services/app.ts @@ -629,6 +629,10 @@ export class CoreAppProvider { * @param color RGB color to use as status bar background. If not set the css variable will be read. */ setStatusBarColor(color?: string): void { + if (!this.isMobile()) { + return; + } + if (!color) { // Get the default color to change it. const element = document.querySelector('ion-header ion-toolbar');