commit
b98146f83b
|
@ -68,8 +68,12 @@ export class AddonModAssignModuleHandler implements CoreCourseModuleHandler {
|
|||
title: module.name,
|
||||
class: 'addon-mod_assign-handler',
|
||||
showDownloadButton: true,
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
||||
navCtrl.push('AddonModAssignIndexPage', {module: module, courseId: courseId}, options);
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||
const pageParams = {module: module, courseId: courseId};
|
||||
if (params) {
|
||||
Object.assign(pageParams, params);
|
||||
}
|
||||
navCtrl.push('AddonModAssignIndexPage', pageParams, options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Component, Optional, Injector } from '@angular/core';
|
||||
import { Component, Optional, Injector, Input } from '@angular/core';
|
||||
import { Content, PopoverController } from 'ionic-angular';
|
||||
import { CoreAppProvider } from '@providers/app';
|
||||
import { CoreCourseProvider } from '@core/course/providers/course';
|
||||
|
@ -29,6 +29,8 @@ import { AddonModBookTocPopoverComponent } from '../../components/toc-popover/to
|
|||
templateUrl: 'addon-mod-book-index.html',
|
||||
})
|
||||
export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComponent {
|
||||
@Input() initialChapterId: string; // The initial chapter ID to load.
|
||||
|
||||
component = AddonModBookProvider.COMPONENT;
|
||||
chapterContent: string;
|
||||
previousChapter: string;
|
||||
|
@ -128,7 +130,19 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp
|
|||
this.contentsMap = this.bookProvider.getContentsMap(this.module.contents);
|
||||
this.chapters = this.bookProvider.getTocList(this.module.contents);
|
||||
|
||||
if (typeof this.currentChapter == 'undefined' && typeof this.initialChapterId != 'undefined' && this.chapters) {
|
||||
// Initial chapter set. Validate that the chapter exists.
|
||||
const chapter = this.chapters.find((chapter) => {
|
||||
return chapter.id == this.initialChapterId;
|
||||
});
|
||||
|
||||
if (chapter) {
|
||||
this.currentChapter = this.initialChapterId;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof this.currentChapter == 'undefined') {
|
||||
// Load the first chapter.
|
||||
this.currentChapter = this.bookProvider.getFirstChapter(this.chapters);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,5 +12,5 @@
|
|||
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
|
||||
</ion-refresher>
|
||||
|
||||
<addon-mod-book-index [module]="module" [courseId]="courseId" (dataRetrieved)="updateData($event)"></addon-mod-book-index>
|
||||
<addon-mod-book-index [module]="module" [courseId]="courseId" [initialChapterId]="chapterId" (dataRetrieved)="updateData($event)"></addon-mod-book-index>
|
||||
</ion-content>
|
||||
|
|
|
@ -30,10 +30,12 @@ export class AddonModBookIndexPage {
|
|||
title: string;
|
||||
module: any;
|
||||
courseId: number;
|
||||
chapterId: number;
|
||||
|
||||
constructor(navParams: NavParams) {
|
||||
this.module = navParams.get('module') || {};
|
||||
this.courseId = navParams.get('courseId');
|
||||
this.chapterId = navParams.get('chapterId');
|
||||
this.title = this.module.name;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { CoreContentLinksModuleIndexHandler } from '@core/contentlinks/classes/module-index-handler';
|
||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
||||
import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate';
|
||||
|
||||
/**
|
||||
* Handler to treat links to book.
|
||||
|
@ -26,4 +27,27 @@ export class AddonModBookLinkHandler extends CoreContentLinksModuleIndexHandler
|
|||
constructor(courseHelper: CoreCourseHelperProvider) {
|
||||
super(courseHelper, 'AddonModBook', 'book');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of actions for a link (url).
|
||||
*
|
||||
* @param {string[]} siteIds List of sites the URL belongs to.
|
||||
* @param {string} url The URL to treat.
|
||||
* @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param {number} [courseId] Course ID related to the URL. Optional but recommended.
|
||||
* @return {CoreContentLinksAction[]|Promise<CoreContentLinksAction[]>} List of (or promise resolved with list of) actions.
|
||||
*/
|
||||
getActions(siteIds: string[], url: string, params: any, courseId?: number):
|
||||
CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
||||
|
||||
const modParams = params.chapterid ? {chapterId: params.chapterid} : undefined;
|
||||
courseId = courseId || params.courseid || params.cid;
|
||||
|
||||
return [{
|
||||
action: (siteId, navCtrl?): void => {
|
||||
this.courseHelper.navigateToModule(parseInt(params.id, 10), siteId, courseId, undefined,
|
||||
this.useModNameToGetModule ? this.modName : undefined, modParams);
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,8 +65,12 @@ export class AddonModBookModuleHandler implements CoreCourseModuleHandler {
|
|||
title: module.name,
|
||||
class: 'addon-mod_book-handler',
|
||||
showDownloadButton: true,
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
||||
navCtrl.push('AddonModBookIndexPage', {module: module, courseId: courseId}, options);
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||
const pageParams = {module: module, courseId: courseId};
|
||||
if (params) {
|
||||
Object.assign(pageParams, params);
|
||||
}
|
||||
navCtrl.push('AddonModBookIndexPage', pageParams, options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -62,8 +62,12 @@ export class AddonModChatModuleHandler implements CoreCourseModuleHandler {
|
|||
icon: this.courseProvider.getModuleIconSrc(this.modName, module.modicon),
|
||||
title: module.name,
|
||||
class: 'addon-mod_chat-handler',
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
||||
navCtrl.push('AddonModChatIndexPage', {module: module, courseId: courseId}, options);
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||
const pageParams = {module: module, courseId: courseId};
|
||||
if (params) {
|
||||
Object.assign(pageParams, params);
|
||||
}
|
||||
navCtrl.push('AddonModChatIndexPage', pageParams, options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -64,8 +64,12 @@ export class AddonModChoiceModuleHandler implements CoreCourseModuleHandler {
|
|||
title: module.name,
|
||||
class: 'addon-mod_choice-handler',
|
||||
showDownloadButton: true,
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
||||
navCtrl.push('AddonModChoiceIndexPage', {module: module, courseId: courseId}, options);
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||
const pageParams = {module: module, courseId: courseId};
|
||||
if (params) {
|
||||
Object.assign(pageParams, params);
|
||||
}
|
||||
navCtrl.push('AddonModChoiceIndexPage', pageParams, options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -67,8 +67,12 @@ export class AddonModDataModuleHandler implements CoreCourseModuleHandler {
|
|||
title: module.name,
|
||||
class: 'addon-mod_data-handler',
|
||||
showDownloadButton: true,
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
||||
navCtrl.push('AddonModDataIndexPage', {module: module, courseId: courseId}, options);
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||
const pageParams = {module: module, courseId: courseId};
|
||||
if (params) {
|
||||
Object.assign(pageParams, params);
|
||||
}
|
||||
navCtrl.push('AddonModDataIndexPage', pageParams, options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -65,8 +65,12 @@ export class AddonModFeedbackModuleHandler implements CoreCourseModuleHandler {
|
|||
title: module.name,
|
||||
class: 'addon-mod_feedback-handler',
|
||||
showDownloadButton: true,
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
||||
navCtrl.push('AddonModFeedbackIndexPage', {module: module, courseId: courseId}, options);
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||
const pageParams = {module: module, courseId: courseId};
|
||||
if (params) {
|
||||
Object.assign(pageParams, params);
|
||||
}
|
||||
navCtrl.push('AddonModFeedbackIndexPage', pageParams, options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -64,8 +64,12 @@ export class AddonModFolderModuleHandler implements CoreCourseModuleHandler {
|
|||
title: module.name,
|
||||
class: 'addon-mod_folder-handler',
|
||||
showDownloadButton: true,
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
||||
navCtrl.push('AddonModFolderIndexPage', {module: module, courseId: courseId}, options);
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||
const pageParams = {module: module, courseId: courseId};
|
||||
if (params) {
|
||||
Object.assign(pageParams, params);
|
||||
}
|
||||
navCtrl.push('AddonModFolderIndexPage', pageParams, options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -72,8 +72,12 @@ export class AddonModForumModuleHandler implements CoreCourseModuleHandler {
|
|||
title: module.name,
|
||||
class: 'addon-mod_forum-handler',
|
||||
showDownloadButton: true,
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
||||
navCtrl.push('AddonModForumIndexPage', {module: module, courseId: courseId}, options);
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||
const pageParams = {module: module, courseId: courseId};
|
||||
if (params) {
|
||||
Object.assign(pageParams, params);
|
||||
}
|
||||
navCtrl.push('AddonModForumIndexPage', pageParams, options);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -66,8 +66,12 @@ export class AddonModGlossaryModuleHandler implements CoreCourseModuleHandler {
|
|||
title: module.name,
|
||||
class: 'addon-mod_glossary-handler',
|
||||
showDownloadButton: true,
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
||||
navCtrl.push('AddonModGlossaryIndexPage', {module: module, courseId: courseId}, options);
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||
const pageParams = {module: module, courseId: courseId};
|
||||
if (params) {
|
||||
Object.assign(pageParams, params);
|
||||
}
|
||||
navCtrl.push('AddonModGlossaryIndexPage', pageParams, options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -65,8 +65,12 @@ export class AddonModImscpModuleHandler implements CoreCourseModuleHandler {
|
|||
title: module.name,
|
||||
class: 'addon-mod_imscp-handler',
|
||||
showDownloadButton: true,
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
||||
navCtrl.push('AddonModImscpIndexPage', {module: module, courseId: courseId}, options);
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||
const pageParams = {module: module, courseId: courseId};
|
||||
if (params) {
|
||||
Object.assign(pageParams, params);
|
||||
}
|
||||
navCtrl.push('AddonModImscpIndexPage', pageParams, options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -65,8 +65,12 @@ export class AddonModLessonModuleHandler implements CoreCourseModuleHandler {
|
|||
title: module.name,
|
||||
class: 'addon-mod_lesson-handler',
|
||||
showDownloadButton: true,
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
||||
navCtrl.push('AddonModLessonIndexPage', {module: module, courseId: courseId}, options);
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||
const pageParams = {module: module, courseId: courseId};
|
||||
if (params) {
|
||||
Object.assign(pageParams, params);
|
||||
}
|
||||
navCtrl.push('AddonModLessonIndexPage', pageParams, options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -74,8 +74,12 @@ export class AddonModLtiModuleHandler implements CoreCourseModuleHandler {
|
|||
icon: this.courseProvider.getModuleIconSrc(this.modName, module.modicon),
|
||||
title: module.name,
|
||||
class: 'addon-mod_lti-handler',
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
||||
navCtrl.push('AddonModLtiIndexPage', {module: module, courseId: courseId}, options);
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||
const pageParams = {module: module, courseId: courseId};
|
||||
if (params) {
|
||||
Object.assign(pageParams, params);
|
||||
}
|
||||
navCtrl.push('AddonModLtiIndexPage', pageParams, options);
|
||||
},
|
||||
buttons: [{
|
||||
icon: 'link',
|
||||
|
|
|
@ -65,8 +65,12 @@ export class AddonModPageModuleHandler implements CoreCourseModuleHandler {
|
|||
title: module.name,
|
||||
class: 'addon-mod_page-handler',
|
||||
showDownloadButton: true,
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
||||
navCtrl.push('AddonModPageIndexPage', {module: module, courseId: courseId}, options);
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||
const pageParams = {module: module, courseId: courseId};
|
||||
if (params) {
|
||||
Object.assign(pageParams, params);
|
||||
}
|
||||
navCtrl.push('AddonModPageIndexPage', pageParams, options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -66,8 +66,12 @@ export class AddonModQuizModuleHandler implements CoreCourseModuleHandler {
|
|||
title: module.name,
|
||||
class: 'addon-mod_quiz-handler',
|
||||
showDownloadButton: true,
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
||||
navCtrl.push('AddonModQuizIndexPage', {module: module, courseId: courseId}, options);
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||
const pageParams = {module: module, courseId: courseId};
|
||||
if (params) {
|
||||
Object.assign(pageParams, params);
|
||||
}
|
||||
navCtrl.push('AddonModQuizIndexPage', pageParams, options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -82,8 +82,12 @@ export class AddonModResourceModuleHandler implements CoreCourseModuleHandler {
|
|||
title: module.name,
|
||||
class: 'addon-mod_resource-handler',
|
||||
showDownloadButton: true,
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
||||
navCtrl.push('AddonModResourceIndexPage', {module: module, courseId: courseId}, options);
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||
const pageParams = {module: module, courseId: courseId};
|
||||
if (params) {
|
||||
Object.assign(pageParams, params);
|
||||
}
|
||||
navCtrl.push('AddonModResourceIndexPage', pageParams, options);
|
||||
},
|
||||
updateStatus: updateStatus.bind(this),
|
||||
buttons: [ {
|
||||
|
|
|
@ -64,8 +64,12 @@ export class AddonModScormModuleHandler implements CoreCourseModuleHandler {
|
|||
title: module.name,
|
||||
class: 'addon-mod_scorm-handler',
|
||||
showDownloadButton: true,
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
||||
navCtrl.push('AddonModScormIndexPage', {module: module, courseId: courseId}, options);
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||
const pageParams = {module: module, courseId: courseId};
|
||||
if (params) {
|
||||
Object.assign(pageParams, params);
|
||||
}
|
||||
navCtrl.push('AddonModScormIndexPage', pageParams, options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -64,8 +64,12 @@ export class AddonModSurveyModuleHandler implements CoreCourseModuleHandler {
|
|||
title: module.name,
|
||||
class: 'addon-mod_survey-handler',
|
||||
showDownloadButton: true,
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
||||
navCtrl.push('AddonModSurveyIndexPage', {module: module, courseId: courseId}, options);
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||
const pageParams = {module: module, courseId: courseId};
|
||||
if (params) {
|
||||
Object.assign(pageParams, params);
|
||||
}
|
||||
navCtrl.push('AddonModSurveyIndexPage', pageParams, options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ export class AddonModUrlModuleHandler implements CoreCourseModuleHandler {
|
|||
title: module.name,
|
||||
class: 'addon-mod_url-handler',
|
||||
showDownloadButton: false,
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||
const modal = handler.domUtils.showModalLoading();
|
||||
|
||||
// First of all, check if the URL can be handled by the app. If so, always open it directly.
|
||||
|
@ -100,7 +100,11 @@ export class AddonModUrlModuleHandler implements CoreCourseModuleHandler {
|
|||
if (shouldOpen) {
|
||||
handler.openUrl(module, courseId);
|
||||
} else {
|
||||
navCtrl.push('AddonModUrlIndexPage', {module: module, courseId: courseId}, options);
|
||||
const pageParams = {module: module, courseId: courseId};
|
||||
if (params) {
|
||||
Object.assign(pageParams, params);
|
||||
}
|
||||
navCtrl.push('AddonModUrlIndexPage', pageParams, options);
|
||||
}
|
||||
}).finally(() => {
|
||||
modal.dismiss();
|
||||
|
|
|
@ -65,8 +65,12 @@ export class AddonModWikiModuleHandler implements CoreCourseModuleHandler {
|
|||
title: module.name,
|
||||
class: 'addon-mod_wiki-handler',
|
||||
showDownloadButton: true,
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
||||
navCtrl.push('AddonModWikiIndexPage', {module: module, courseId: courseId}, options);
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||
const pageParams = {module: module, courseId: courseId};
|
||||
if (params) {
|
||||
Object.assign(pageParams, params);
|
||||
}
|
||||
navCtrl.push('AddonModWikiIndexPage', pageParams, options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -64,8 +64,12 @@ export class AddonModWorkshopModuleHandler implements CoreCourseModuleHandler {
|
|||
title: module.name,
|
||||
class: 'addon-mod_workshop-handler',
|
||||
showDownloadButton: true,
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
||||
navCtrl.push('AddonModWorkshopIndexPage', {module: module, courseId: courseId}, options);
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||
const pageParams = {module: module, courseId: courseId};
|
||||
if (params) {
|
||||
Object.assign(pageParams, params);
|
||||
}
|
||||
navCtrl.push('AddonModWorkshopIndexPage', pageParams, options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ export class CoreCourseSectionPage implements OnDestroy {
|
|||
displayRefresher: boolean;
|
||||
|
||||
protected module: any;
|
||||
protected modParams: any;
|
||||
protected completionObserver;
|
||||
protected courseStatusObserver;
|
||||
protected syncObserver;
|
||||
|
@ -80,6 +81,7 @@ export class CoreCourseSectionPage implements OnDestroy {
|
|||
this.sectionNumber = navParams.get('sectionNumber');
|
||||
this.module = navParams.get('module');
|
||||
this.firstTabName = navParams.get('selectedTab');
|
||||
this.modParams = navParams.get('modParams');
|
||||
|
||||
// Get the title to display. We dont't have sections yet.
|
||||
this.title = courseFormatDelegate.getCourseTitle(this.course);
|
||||
|
@ -124,7 +126,7 @@ export class CoreCourseSectionPage implements OnDestroy {
|
|||
|
||||
if (this.module) {
|
||||
this.moduleId = this.module.id;
|
||||
this.courseHelper.openModule(this.navCtrl, this.module, this.course.id, this.sectionId);
|
||||
this.courseHelper.openModule(this.navCtrl, this.module, this.course.id, this.sectionId, this.modParams);
|
||||
}
|
||||
|
||||
this.loadData(false, true).finally(() => {
|
||||
|
|
|
@ -1007,9 +1007,11 @@ export class CoreCourseHelperProvider {
|
|||
* @param {number} [sectionId] Section the module belongs to. If not defined we'll try to retrieve it from the site.
|
||||
* @param {string} [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 {any} [modParams] Params to pass to the module
|
||||
* @return {Promise<void>} Promise resolved when done.
|
||||
*/
|
||||
navigateToModule(moduleId: number, siteId?: string, courseId?: number, sectionId?: number, modName?: string): Promise<void> {
|
||||
navigateToModule(moduleId: number, siteId?: string, courseId?: number, sectionId?: number, modName?: string, modParams?: any)
|
||||
: Promise<void> {
|
||||
siteId = siteId || this.sitesProvider.getCurrentSiteId();
|
||||
|
||||
const modal = this.domUtils.showModalLoading();
|
||||
|
@ -1048,7 +1050,8 @@ export class CoreCourseHelperProvider {
|
|||
const params = {
|
||||
course: { id: courseId },
|
||||
module: module,
|
||||
sectionId: sectionId
|
||||
sectionId: sectionId,
|
||||
modParams: modParams
|
||||
};
|
||||
|
||||
module.handlerData = this.moduleDelegate.getModuleDataFor(module.modname, module, courseId, sectionId);
|
||||
|
@ -1075,15 +1078,16 @@ export class CoreCourseHelperProvider {
|
|||
* @param {any} module The module to open.
|
||||
* @param {number} courseId The course ID of the module.
|
||||
* @param {number} [sectionId] The section ID of the module.
|
||||
* @param {any} [modParams] Params to pass to the module
|
||||
* @param {boolean} True if module can be opened, false otherwise.
|
||||
*/
|
||||
openModule(navCtrl: NavController, module: any, courseId: number, sectionId?: number): boolean {
|
||||
openModule(navCtrl: NavController, module: any, courseId: number, sectionId?: number, modParams?: any): boolean {
|
||||
if (!module.handlerData) {
|
||||
module.handlerData = this.moduleDelegate.getModuleDataFor(module.modname, module, courseId, sectionId);
|
||||
}
|
||||
|
||||
if (module.handlerData && module.handlerData.action) {
|
||||
module.handlerData.action(new Event('click'), navCtrl, module, courseId, { animate: false });
|
||||
module.handlerData.action(new Event('click'), navCtrl, module, courseId, { animate: false }, modParams);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -156,8 +156,9 @@ export interface CoreCourseModuleHandlerData {
|
|||
* @param {any} module The module object.
|
||||
* @param {number} courseId The course ID.
|
||||
* @param {NavOptions} [options] Options for the navigation.
|
||||
* @param {any} [params] Params for the new page.
|
||||
*/
|
||||
action?(event: Event, navCtrl: NavController, module: any, courseId: number, options?: NavOptions): void;
|
||||
action?(event: Event, navCtrl: NavController, module: any, courseId: number, options?: NavOptions, params?: any): void;
|
||||
|
||||
/**
|
||||
* Updates the status of the module.
|
||||
|
|
|
@ -31,9 +31,11 @@ export class CoreSiteHomeIndexPage {
|
|||
|
||||
constructor(navParams: NavParams, navCtrl: NavController, courseHelper: CoreCourseHelperProvider,
|
||||
sitesProvider: CoreSitesProvider) {
|
||||
const module = navParams.get('module');
|
||||
const module = navParams.get('module'),
|
||||
modParams = navParams.get('modParams');
|
||||
|
||||
if (module) {
|
||||
courseHelper.openModule(navCtrl, module, sitesProvider.getCurrentSite().getSiteHomeId());
|
||||
courseHelper.openModule(navCtrl, module, sitesProvider.getCurrentSite().getSiteHomeId(), undefined, modParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue