MOBILE-3980 book: Open book contents when clicking link
parent
f4cb040aa0
commit
52e10ea15d
|
@ -54,7 +54,10 @@ export class AddonModAssignPushClickHandlerService implements CorePushNotificati
|
||||||
const moduleId = Number(contextUrlParams.id);
|
const moduleId = Number(contextUrlParams.id);
|
||||||
|
|
||||||
await CoreUtils.ignoreErrors(AddonModAssign.invalidateContent(moduleId, courseId, notification.site));
|
await CoreUtils.ignoreErrors(AddonModAssign.invalidateContent(moduleId, courseId, notification.site));
|
||||||
await CoreCourseHelper.navigateToModule(moduleId, notification.site, courseId);
|
await CoreCourseHelper.navigateToModule(moduleId, {
|
||||||
|
courseId,
|
||||||
|
siteId: notification.site,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Params } from '@angular/router';
|
import { Params } from '@angular/router';
|
||||||
import { CoreContentLinksModuleIndexHandler } from '@features/contentlinks/classes/module-index-handler';
|
import { CoreContentLinksModuleIndexHandler } from '@features/contentlinks/classes/module-index-handler';
|
||||||
|
import { CoreNavigationOptions } from '@services/navigator';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonModBook } from '../book';
|
import { AddonModBook } from '../book';
|
||||||
|
|
||||||
|
@ -31,20 +32,32 @@ export class AddonModBookIndexLinkHandlerService extends CoreContentLinksModuleI
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the mod params necessary to open an activity.
|
* @inheritdoc
|
||||||
*
|
*/
|
||||||
* @param url The URL to treat.
|
getModNavOptions(url: string, params: Record<string, string>): CoreNavigationOptions {
|
||||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
const chapterId = params.chapterid ? parseInt(params.chapterid, 10) : undefined;
|
||||||
* @return List of params to pass to navigateToModule / navigateToModuleByInstance.
|
|
||||||
|
return {
|
||||||
|
nextNavigation: {
|
||||||
|
path: 'contents',
|
||||||
|
options: {
|
||||||
|
params: {
|
||||||
|
chapterId,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
getPageParams(url: string, params: Record<string, string>): Params {
|
getPageParams(url: string, params: Record<string, string>): Params {
|
||||||
return params.chapterid ? { chapterId: parseInt(params.chapterid, 10) } : {};
|
return params.chapterid ? { chapterId: parseInt(params.chapterid, 10) } : {};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the handler is enabled for a certain site (site + user) and a URL.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @return Whether the handler is enabled for the URL and site.
|
|
||||||
*/
|
*/
|
||||||
isEnabled(siteId: string): Promise<boolean> {
|
isEnabled(siteId: string): Promise<boolean> {
|
||||||
return AddonModBook.isPluginEnabled(siteId);
|
return AddonModBook.isPluginEnabled(siteId);
|
||||||
|
|
|
@ -55,7 +55,10 @@ export class AddonModFeedbackPushClickHandlerService implements CorePushNotifica
|
||||||
if (notification.name == 'submission') {
|
if (notification.name == 'submission') {
|
||||||
return AddonModFeedbackHelper.handleShowEntriesLink(contextUrlParams, notification.site);
|
return AddonModFeedbackHelper.handleShowEntriesLink(contextUrlParams, notification.site);
|
||||||
} else {
|
} else {
|
||||||
return CoreCourseHelper.navigateToModule(moduleId, notification.site, courseId);
|
return CoreCourseHelper.navigateToModule(moduleId, {
|
||||||
|
courseId,
|
||||||
|
siteId: notification.site,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,11 @@ export class AddonModLessonGradeLinkHandlerService extends CoreContentLinksModul
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// User cannot view the report, go to lesson index.
|
// User cannot view the report, go to lesson index.
|
||||||
CoreCourseHelper.navigateToModule(moduleId, siteId, module.course, module.section);
|
CoreCourseHelper.navigateToModule(moduleId, {
|
||||||
|
courseId: module.course,
|
||||||
|
sectionId: module.section,
|
||||||
|
siteId,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true);
|
CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true);
|
||||||
|
|
|
@ -61,7 +61,10 @@ export class AddonModLessonIndexLinkHandlerService extends CoreContentLinksModul
|
||||||
if (params.userpassword) {
|
if (params.userpassword) {
|
||||||
this.navigateToModuleWithPassword(parseInt(params.id, 10), courseId!, params.userpassword, siteId);
|
this.navigateToModuleWithPassword(parseInt(params.id, 10), courseId!, params.userpassword, siteId);
|
||||||
} else {
|
} else {
|
||||||
CoreCourseHelper.navigateToModule(parseInt(params.id, 10), siteId, courseId);
|
CoreCourseHelper.navigateToModule(parseInt(params.id, 10), {
|
||||||
|
courseId,
|
||||||
|
siteId,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}];
|
}];
|
||||||
|
@ -94,10 +97,17 @@ export class AddonModLessonIndexLinkHandlerService extends CoreContentLinksModul
|
||||||
// Store the password so it's automatically used.
|
// Store the password so it's automatically used.
|
||||||
await CoreUtils.ignoreErrors(AddonModLesson.storePassword(module.instance, password, siteId));
|
await CoreUtils.ignoreErrors(AddonModLesson.storePassword(module.instance, password, siteId));
|
||||||
|
|
||||||
await CoreCourseHelper.navigateToModule(moduleId, siteId, module.course, module.section);
|
await CoreCourseHelper.navigateToModule(moduleId, {
|
||||||
|
courseId: module.course,
|
||||||
|
sectionId: module.section,
|
||||||
|
siteId,
|
||||||
|
});
|
||||||
} catch {
|
} catch {
|
||||||
// Error, go to index page.
|
// Error, go to index page.
|
||||||
await CoreCourseHelper.navigateToModule(moduleId, siteId, courseId);
|
await CoreCourseHelper.navigateToModule(moduleId, {
|
||||||
|
courseId,
|
||||||
|
siteId,
|
||||||
|
});
|
||||||
} finally {
|
} finally {
|
||||||
modal.dismiss();
|
modal.dismiss();
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,10 @@ export class AddonModQuizPushClickHandlerService implements CorePushNotification
|
||||||
|
|
||||||
await CoreUtils.ignoreErrors(AddonModQuiz.invalidateContent(moduleId, courseId, notification.site));
|
await CoreUtils.ignoreErrors(AddonModQuiz.invalidateContent(moduleId, courseId, notification.site));
|
||||||
|
|
||||||
return CoreCourseHelper.navigateToModule(moduleId, notification.site, courseId);
|
return CoreCourseHelper.navigateToModule(moduleId, {
|
||||||
|
courseId,
|
||||||
|
siteId: notification.site,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,10 +78,11 @@ export class CoreContentLinksModuleGradeHandler extends CoreContentLinksHandlerB
|
||||||
// No user specified or current user. Navigate to module.
|
// No user specified or current user. Navigate to module.
|
||||||
CoreCourseHelper.navigateToModule(
|
CoreCourseHelper.navigateToModule(
|
||||||
Number(params.id),
|
Number(params.id),
|
||||||
siteId,
|
{
|
||||||
courseId,
|
courseId,
|
||||||
undefined,
|
modName: this.useModNameToGetModule ? this.modName : undefined,
|
||||||
this.useModNameToGetModule ? this.modName : undefined,
|
siteId,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
} else if (this.canReview) {
|
} else if (this.canReview) {
|
||||||
// Use the goToReview function.
|
// Use the goToReview function.
|
||||||
|
|
|
@ -16,6 +16,7 @@ import { CoreContentLinksHandlerBase } from './base-handler';
|
||||||
import { Params } from '@angular/router';
|
import { Params } from '@angular/router';
|
||||||
import { CoreContentLinksAction } from '../services/contentlinks-delegate';
|
import { CoreContentLinksAction } from '../services/contentlinks-delegate';
|
||||||
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
||||||
|
import { CoreNavigationOptions } from '@services/navigator';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler to handle URLs pointing to the index of a module.
|
* Handler to handle URLs pointing to the index of a module.
|
||||||
|
@ -58,12 +59,27 @@ export class CoreContentLinksModuleIndexHandler extends CoreContentLinksHandlerB
|
||||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||||
* @return List of params to pass to navigateToModule / navigateToModuleByInstance.
|
* @return List of params to pass to navigateToModule / navigateToModuleByInstance.
|
||||||
|
* @deprecated since 4.0
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
getPageParams(url: string, params: Record<string, string>, courseId?: number): Params {
|
getPageParams(url: string, params: Record<string, string>, courseId?: number): Params {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the navigation options to open the module.
|
||||||
|
*
|
||||||
|
* @param url The URL to treat.
|
||||||
|
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||||
|
* @param siteId The site ID.
|
||||||
|
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||||
|
* @return Navigation options to open the module.
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
getModNavOptions(url: string, params: Record<string, string>, siteId: string, courseId?: number): CoreNavigationOptions {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of actions for a link (url).
|
* Get the list of actions for a link (url).
|
||||||
*
|
*
|
||||||
|
@ -81,7 +97,18 @@ export class CoreContentLinksModuleIndexHandler extends CoreContentLinksHandlerB
|
||||||
): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
||||||
|
|
||||||
courseId = Number(courseId || params.courseid || params.cid);
|
courseId = Number(courseId || params.courseid || params.cid);
|
||||||
const pageParams = this.getPageParams(url, params, courseId);
|
const getModNavOptions = (siteId: string): CoreNavigationOptions => {
|
||||||
|
let modNavOptions = this.getModNavOptions(url, params, siteId, courseId);
|
||||||
|
if (!modNavOptions) {
|
||||||
|
// Use the old function, currently deprecated.
|
||||||
|
const pageParams = this.getPageParams(url, params, courseId);
|
||||||
|
if (pageParams && Object.keys(pageParams).length > 0) {
|
||||||
|
modNavOptions = { params: pageParams };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return modNavOptions;
|
||||||
|
};
|
||||||
|
|
||||||
if (this.instanceIdParam && params[this.instanceIdParam] !== undefined) {
|
if (this.instanceIdParam && params[this.instanceIdParam] !== undefined) {
|
||||||
const instanceId = parseInt(params[this.instanceIdParam], 10);
|
const instanceId = parseInt(params[this.instanceIdParam], 10);
|
||||||
|
@ -91,11 +118,12 @@ export class CoreContentLinksModuleIndexHandler extends CoreContentLinksHandlerB
|
||||||
CoreCourseHelper.navigateToModuleByInstance(
|
CoreCourseHelper.navigateToModuleByInstance(
|
||||||
instanceId,
|
instanceId,
|
||||||
this.modName,
|
this.modName,
|
||||||
siteId,
|
{
|
||||||
courseId,
|
courseId,
|
||||||
undefined,
|
useModNameToGetModule: this.useModNameToGetModule,
|
||||||
this.useModNameToGetModule,
|
modNavOptions: getModNavOptions(siteId),
|
||||||
pageParams,
|
siteId,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
}];
|
}];
|
||||||
|
@ -105,11 +133,12 @@ export class CoreContentLinksModuleIndexHandler extends CoreContentLinksHandlerB
|
||||||
action: (siteId) => {
|
action: (siteId) => {
|
||||||
CoreCourseHelper.navigateToModule(
|
CoreCourseHelper.navigateToModule(
|
||||||
parseInt(params.id, 10),
|
parseInt(params.id, 10),
|
||||||
siteId,
|
{
|
||||||
courseId,
|
courseId,
|
||||||
undefined,
|
modName: this.useModNameToGetModule ? this.modName : undefined,
|
||||||
this.useModNameToGetModule ? this.modName : undefined,
|
modNavOptions: getModNavOptions(siteId),
|
||||||
pageParams,
|
siteId,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
}];
|
}];
|
||||||
|
|
|
@ -24,7 +24,7 @@ import { CoreCourse, CoreCourseModuleCompletionStatus, CoreCourseWSSection } fro
|
||||||
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 { CoreTextUtils } from '@services/utils/text';
|
import { CoreTextUtils } from '@services/utils/text';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigationOptions, CoreNavigator } from '@services/navigator';
|
||||||
import { CONTENTS_PAGE_NAME } from '@features/course/course.module';
|
import { CONTENTS_PAGE_NAME } from '@features/course/course.module';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreCollapsibleHeaderDirective } from '@directives/collapsible-header';
|
import { CoreCollapsibleHeaderDirective } from '@directives/collapsible-header';
|
||||||
|
@ -57,7 +57,7 @@ export class CoreCourseIndexPage implements OnInit, OnDestroy {
|
||||||
protected sections: CoreCourseWSSection[] = []; // List of course sections.
|
protected sections: CoreCourseWSSection[] = []; // List of course sections.
|
||||||
protected firstTabName?: string;
|
protected firstTabName?: string;
|
||||||
protected module?: CoreCourseModuleData;
|
protected module?: CoreCourseModuleData;
|
||||||
protected modParams?: Params;
|
protected modNavOptions?: CoreNavigationOptions;
|
||||||
protected isGuest = false;
|
protected isGuest = false;
|
||||||
protected contentsTab: CoreTabsOutletTab & { pageParams: Params } = {
|
protected contentsTab: CoreTabsOutletTab & { pageParams: Params } = {
|
||||||
page: CONTENTS_PAGE_NAME,
|
page: CONTENTS_PAGE_NAME,
|
||||||
|
@ -136,8 +136,15 @@ export class CoreCourseIndexPage implements OnInit, OnDestroy {
|
||||||
|
|
||||||
this.firstTabName = CoreNavigator.getRouteParam('selectedTab');
|
this.firstTabName = CoreNavigator.getRouteParam('selectedTab');
|
||||||
this.module = CoreNavigator.getRouteParam<CoreCourseModuleData>('module');
|
this.module = CoreNavigator.getRouteParam<CoreCourseModuleData>('module');
|
||||||
this.modParams = CoreNavigator.getRouteParam<Params>('modParams');
|
|
||||||
this.isGuest = !!CoreNavigator.getRouteBooleanParam('isGuest');
|
this.isGuest = !!CoreNavigator.getRouteBooleanParam('isGuest');
|
||||||
|
this.modNavOptions = CoreNavigator.getRouteParam<CoreNavigationOptions>('modNavOptions');
|
||||||
|
if (!this.modNavOptions) {
|
||||||
|
// Fallback to old way of passing params. @deprecated since 4.0.
|
||||||
|
const modParams = CoreNavigator.getRouteParam<Params>('modParams');
|
||||||
|
if (modParams) {
|
||||||
|
this.modNavOptions = { params: modParams };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.currentPagePath = CoreNavigator.getCurrentPath();
|
this.currentPagePath = CoreNavigator.getCurrentPath();
|
||||||
this.contentsTab.page = CoreTextUtils.concatenatePaths(this.currentPagePath, this.contentsTab.page);
|
this.contentsTab.page = CoreTextUtils.concatenatePaths(this.currentPagePath, this.contentsTab.page);
|
||||||
|
@ -171,7 +178,10 @@ export class CoreCourseIndexPage implements OnInit, OnDestroy {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Now that the first tab has been selected we can load the module.
|
// Now that the first tab has been selected we can load the module.
|
||||||
CoreCourseHelper.openModule(this.module, this.course.id, this.contentsTab.pageParams.sectionId, this.modParams);
|
CoreCourseHelper.openModule(this.module, this.course.id, {
|
||||||
|
sectionId: this.contentsTab.pageParams.sectionId,
|
||||||
|
modNavOptions: this.modNavOptions,
|
||||||
|
});
|
||||||
|
|
||||||
delete this.module;
|
delete this.module;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1573,36 +1573,27 @@ export class CoreCourseHelperProvider {
|
||||||
*
|
*
|
||||||
* @param instanceId Activity instance ID.
|
* @param instanceId Activity instance ID.
|
||||||
* @param modName Module name of the activity.
|
* @param modName Module name of the activity.
|
||||||
* @param siteId Site ID. If not defined, current site.
|
* @param options Other options.
|
||||||
* @param courseId Course ID. If not defined we'll try to retrieve it from the site.
|
|
||||||
* @param sectionId Section the module belongs to. If not defined we'll try to retrieve it from the site.
|
|
||||||
* @param useModNameToGetModule If true, the app will retrieve all modules of this type with a single WS call. This reduces the
|
|
||||||
* number of WS calls, but it isn't recommended for modules that can return a lot of contents.
|
|
||||||
* @param modParams Params to pass to the module
|
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
async navigateToModuleByInstance(
|
async navigateToModuleByInstance(
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
modName: string,
|
modName: string,
|
||||||
siteId?: string,
|
options: CoreCourseNavigateToModuleByInstanceOptions = {},
|
||||||
courseId?: number,
|
|
||||||
sectionId?: number,
|
|
||||||
useModNameToGetModule: boolean = false,
|
|
||||||
modParams?: Params,
|
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
|
||||||
const modal = await CoreDomUtils.showModalLoading();
|
const modal = await CoreDomUtils.showModalLoading();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const module = await CoreCourse.getModuleBasicInfoByInstance(instanceId, modName, { siteId });
|
const module = await CoreCourse.getModuleBasicInfoByInstance(instanceId, modName, { siteId: options.siteId });
|
||||||
|
|
||||||
this.navigateToModule(
|
this.navigateToModule(
|
||||||
module.id,
|
module.id,
|
||||||
siteId,
|
{
|
||||||
module.course,
|
...options,
|
||||||
sectionId,
|
courseId: module.course,
|
||||||
useModNameToGetModule ? modName : undefined,
|
modName: options.useModNameToGetModule ? modName : undefined,
|
||||||
modParams,
|
},
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true);
|
CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true);
|
||||||
|
@ -1616,23 +1607,16 @@ export class CoreCourseHelperProvider {
|
||||||
* Navigate to a module.
|
* Navigate to a module.
|
||||||
*
|
*
|
||||||
* @param moduleId Module's ID.
|
* @param moduleId Module's ID.
|
||||||
* @param siteId Site ID. If not defined, current site.
|
* @param options Other options.
|
||||||
* @param courseId Course ID. If not defined we'll try to retrieve it from the site.
|
|
||||||
* @param sectionId Section the module belongs to. If not defined we'll try to retrieve it from the site.
|
|
||||||
* @param modName If set, the app will retrieve all modules of this type with a single WS call. This reduces the
|
|
||||||
* number of WS calls, but it isn't recommended for modules that can return a lot of contents.
|
|
||||||
* @param modParams Params to pass to the module
|
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
async navigateToModule(
|
async navigateToModule(
|
||||||
moduleId: number,
|
moduleId: number,
|
||||||
siteId?: string,
|
options: CoreCourseNavigateToModuleOptions = {},
|
||||||
courseId?: number,
|
|
||||||
sectionId?: number,
|
|
||||||
modName?: string,
|
|
||||||
modParams?: Params,
|
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
siteId = siteId || CoreSites.getCurrentSiteId();
|
const siteId = options.siteId || CoreSites.getCurrentSiteId();
|
||||||
|
let courseId = options.courseId;
|
||||||
|
let sectionId = options.sectionId;
|
||||||
|
|
||||||
const modal = await CoreDomUtils.showModalLoading();
|
const modal = await CoreDomUtils.showModalLoading();
|
||||||
|
|
||||||
|
@ -1651,10 +1635,9 @@ export class CoreCourseHelperProvider {
|
||||||
const site = await CoreSites.getSite(siteId);
|
const site = await CoreSites.getSite(siteId);
|
||||||
|
|
||||||
// Get the module.
|
// Get the module.
|
||||||
const module =
|
const module = await CoreCourse.getModule(moduleId, courseId, sectionId, false, false, siteId, options.modName);
|
||||||
await CoreCourse.getModule(moduleId, courseId, sectionId, false, false, siteId, modName);
|
|
||||||
|
|
||||||
if (CoreSites.getCurrentSiteId() == site.getId()) {
|
if (CoreSites.getCurrentSiteId() === site.getId()) {
|
||||||
// Try to use the module's handler to navigate cleanly.
|
// Try to use the module's handler to navigate cleanly.
|
||||||
module.handlerData = await CoreCourseModuleDelegate.getModuleDataFor(
|
module.handlerData = await CoreCourseModuleDelegate.getModuleDataFor(
|
||||||
module.modname,
|
module.modname,
|
||||||
|
@ -1667,7 +1650,7 @@ export class CoreCourseHelperProvider {
|
||||||
if (module.handlerData?.action) {
|
if (module.handlerData?.action) {
|
||||||
modal.dismiss();
|
modal.dismiss();
|
||||||
|
|
||||||
return module.handlerData.action(new Event('click'), module, courseId, { params: modParams });
|
return module.handlerData.action(new Event('click'), module, courseId, options.modNavOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1675,7 +1658,7 @@ export class CoreCourseHelperProvider {
|
||||||
course: { id: courseId },
|
course: { id: courseId },
|
||||||
module,
|
module,
|
||||||
sectionId,
|
sectionId,
|
||||||
modParams,
|
modNavOptions: options.modNavOptions,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (courseId == site.getSiteHomeId()) {
|
if (courseId == site.getSiteHomeId()) {
|
||||||
|
@ -1704,23 +1687,25 @@ export class CoreCourseHelperProvider {
|
||||||
*
|
*
|
||||||
* @param module The module to open.
|
* @param module The module to open.
|
||||||
* @param courseId The course ID of the module.
|
* @param courseId The course ID of the module.
|
||||||
* @param sectionId The section ID of the module.
|
* @param options Other options.
|
||||||
* @param modParams Params to pass to the module
|
|
||||||
* @param True if module can be opened, false otherwise.
|
* @param True if module can be opened, false otherwise.
|
||||||
*/
|
*/
|
||||||
async openModule(module: CoreCourseModuleData, courseId: number, sectionId?: number, modParams?: Params): Promise<boolean> {
|
async openModule(module: CoreCourseModuleData, courseId: number, options: CoreCourseOpenModuleOptions = {}): Promise<boolean> {
|
||||||
if (!module.handlerData) {
|
if (!module.handlerData) {
|
||||||
module.handlerData = await CoreCourseModuleDelegate.getModuleDataFor(
|
module.handlerData = await CoreCourseModuleDelegate.getModuleDataFor(
|
||||||
module.modname,
|
module.modname,
|
||||||
module,
|
module,
|
||||||
courseId,
|
courseId,
|
||||||
sectionId,
|
options.sectionId,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (module.handlerData?.action) {
|
if (module.handlerData?.action) {
|
||||||
module.handlerData.action(new Event('click'), module, courseId, { animated: false, params: modParams });
|
module.handlerData.action(new Event('click'), module, courseId, {
|
||||||
|
animated: false,
|
||||||
|
...options.modNavOptions,
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2206,6 +2191,39 @@ export type CoreCourseConfirmPrefetchCoursesOptions = CoreCoursePrefetchCoursesO
|
||||||
onProgress?: (data: CoreCourseCoursesProgress) => void;
|
onProgress?: (data: CoreCourseCoursesProgress) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common options for navigate to module functions.
|
||||||
|
*/
|
||||||
|
type CoreCourseNavigateToModuleCommonOptions = {
|
||||||
|
courseId?: number; // Course ID. If not defined we'll try to retrieve it from the site.
|
||||||
|
sectionId?: number; // Section the module belongs to. If not defined we'll try to retrieve it from the site.
|
||||||
|
modNavOptions?: CoreNavigationOptions; // Navigation options to open the module, including params to pass to the module.
|
||||||
|
siteId?: string; // Site ID. If not defined, current site.
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options for navigate to module by instance function.
|
||||||
|
*/
|
||||||
|
export type CoreCourseNavigateToModuleByInstanceOptions = CoreCourseNavigateToModuleCommonOptions & {
|
||||||
|
// True to retrieve all instances with a single WS call. Not recommended if can return a lot of contents.
|
||||||
|
useModNameToGetModule?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options for navigate to module function.
|
||||||
|
*/
|
||||||
|
export type CoreCourseNavigateToModuleOptions = CoreCourseNavigateToModuleCommonOptions & {
|
||||||
|
modName?: string; // To retrieve all instances with a single WS call. Not recommended if can return a lot of contents.
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options for open module function.
|
||||||
|
*/
|
||||||
|
export type CoreCourseOpenModuleOptions = {
|
||||||
|
sectionId?: number; // Section the module belongs to.
|
||||||
|
modNavOptions?: CoreNavigationOptions; // Navigation options to open the module, including params to pass to the module.
|
||||||
|
};
|
||||||
|
|
||||||
type ComponentWithContextMenu = {
|
type ComponentWithContextMenu = {
|
||||||
prefetchStatusIcon?: string;
|
prefetchStatusIcon?: string;
|
||||||
isDestroyed?: boolean;
|
isDestroyed?: boolean;
|
||||||
|
|
|
@ -26,7 +26,7 @@ import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper';
|
import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate';
|
import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate';
|
||||||
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
|
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigationOptions, CoreNavigator } from '@services/navigator';
|
||||||
import { CoreBlockHelper } from '@features/block/services/block-helper';
|
import { CoreBlockHelper } from '@features/block/services/block-helper';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
|
|
||||||
|
@ -73,8 +73,15 @@ export class CoreSiteHomeIndexPage implements OnInit, OnDestroy {
|
||||||
|
|
||||||
const module = CoreNavigator.getRouteParam<CoreCourseModuleData>('module');
|
const module = CoreNavigator.getRouteParam<CoreCourseModuleData>('module');
|
||||||
if (module) {
|
if (module) {
|
||||||
const modParams = CoreNavigator.getRouteParam<Params>('modParams');
|
let modNavOptions = CoreNavigator.getRouteParam<CoreNavigationOptions>('modNavOptions');
|
||||||
CoreCourseHelper.openModule(module, this.siteHomeId, undefined, modParams);
|
if (!modNavOptions) {
|
||||||
|
// Fallback to old way of passing params. @deprecated since 4.0.
|
||||||
|
const modParams = CoreNavigator.getRouteParam<Params>('modParams');
|
||||||
|
if (modParams) {
|
||||||
|
modNavOptions = { params: modParams };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CoreCourseHelper.openModule(module, this.siteHomeId, { modNavOptions });
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loadContent().finally(() => {
|
this.loadContent().finally(() => {
|
||||||
|
|
|
@ -19,6 +19,7 @@ information provided here is intended especially for developers.
|
||||||
- displaySectionSelector has been deprecated on CoreCourseFormatHandler, use displayCourseIndex instead.
|
- displaySectionSelector has been deprecated on CoreCourseFormatHandler, use displayCourseIndex instead.
|
||||||
- Most of the functions or callbacks that handle redirects/deeplinks have been modified to accept an object instead of just path + options. E.g.: CoreLoginHelper.isSiteLoggedOut, CoreLoginHelper.openBrowserForSSOLogin, CoreLoginHelper.openBrowserForOAuthLogin, CoreLoginHelper.prepareForSSOLogin, CoreApp.storeRedirect, CoreSites.loadSite.
|
- Most of the functions or callbacks that handle redirects/deeplinks have been modified to accept an object instead of just path + options. E.g.: CoreLoginHelper.isSiteLoggedOut, CoreLoginHelper.openBrowserForSSOLogin, CoreLoginHelper.openBrowserForOAuthLogin, CoreLoginHelper.prepareForSSOLogin, CoreApp.storeRedirect, CoreSites.loadSite.
|
||||||
- Course preview page route has changed from course/:courseId/preview to course/:courseId/summary to match with the page name and characteristics.
|
- Course preview page route has changed from course/:courseId/preview to course/:courseId/summary to match with the page name and characteristics.
|
||||||
|
- The parameters of the following functions in CoreCourseHelper have changed: navigateToModuleByInstance, navigateToModule, openModule.
|
||||||
|
|
||||||
=== 3.9.5 ===
|
=== 3.9.5 ===
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue