MOBILE-3833 course: Merge Course Module with calculated data types
parent
7d7f738d05
commit
49a1d1d806
|
@ -15,7 +15,7 @@
|
||||||
import { CoreConstants } from '@/core/constants';
|
import { CoreConstants } from '@/core/constants';
|
||||||
import { Injectable, Type } from '@angular/core';
|
import { Injectable, Type } from '@angular/core';
|
||||||
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
||||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
|
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
|
||||||
import { CoreSitePluginsModuleHandler } from '@features/siteplugins/classes/handlers/module-handler';
|
import { CoreSitePluginsModuleHandler } from '@features/siteplugins/classes/handlers/module-handler';
|
||||||
import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins';
|
import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins';
|
||||||
|
@ -72,7 +72,7 @@ export class AddonModBBBModuleHandlerService extends CoreModuleHandlerBase imple
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async getData(
|
async getData(
|
||||||
module: CoreCourseModule,
|
module: CoreCourseModuleData,
|
||||||
courseId: number,
|
courseId: number,
|
||||||
sectionId?: number,
|
sectionId?: number,
|
||||||
forCoursePage?: boolean,
|
forCoursePage?: boolean,
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreCourseResourcePrefetchHandlerBase } from '@features/course/classes/resource-prefetch-handler';
|
import { CoreCourseResourcePrefetchHandlerBase } from '@features/course/classes/resource-prefetch-handler';
|
||||||
import { CoreCourseAnyModuleData, CoreCourseWSModule } from '@features/course/services/course';
|
import { CoreCourseAnyModuleData } from '@features/course/services/course';
|
||||||
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreWSFile } from '@services/ws';
|
import { CoreWSFile } from '@services/ws';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
|
@ -39,7 +40,7 @@ export class AddonModBookPrefetchHandlerService extends CoreCourseResourcePrefet
|
||||||
* @param prefetch True to prefetch, false to download right away.
|
* @param prefetch True to prefetch, false to download right away.
|
||||||
* @return Promise resolved when all content is downloaded. Data returned is not reliable.
|
* @return Promise resolved when all content is downloaded. Data returned is not reliable.
|
||||||
*/
|
*/
|
||||||
async downloadOrPrefetch(module: CoreCourseWSModule, courseId: number, prefetch?: boolean): Promise<void> {
|
async downloadOrPrefetch(module: CoreCourseModuleData, courseId: number, prefetch?: boolean): Promise<void> {
|
||||||
const promises: Promise<unknown>[] = [];
|
const promises: Promise<unknown>[] = [];
|
||||||
|
|
||||||
promises.push(super.downloadOrPrefetch(module, courseId, prefetch));
|
promises.push(super.downloadOrPrefetch(module, courseId, prefetch));
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
import { Params } from '@angular/router';
|
import { Params } from '@angular/router';
|
||||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreTag } from '@features/tag/services/tag';
|
import { CoreTag } from '@features/tag/services/tag';
|
||||||
import { CoreUser } from '@features/user/services/user';
|
import { CoreUser } from '@features/user/services/user';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
|
@ -44,7 +44,7 @@ export class AddonModDataActionComponent implements OnInit {
|
||||||
@Input() action!: AddonModDataAction; // The field to render.
|
@Input() action!: AddonModDataAction; // The field to render.
|
||||||
@Input() entry!: AddonModDataEntry; // The value of the field.
|
@Input() entry!: AddonModDataEntry; // The value of the field.
|
||||||
@Input() database!: AddonModDataData; // Database object.
|
@Input() database!: AddonModDataData; // Database object.
|
||||||
@Input() module!: CoreCourseModule; // Module object.
|
@Input() module!: CoreCourseModuleData; // Module object.
|
||||||
@Input() group = 0; // Module object.
|
@Input() group = 0; // Module object.
|
||||||
@Input() offset?: number; // Offset of the entry.
|
@Input() offset?: number; // Offset of the entry.
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,9 @@ import { Component, OnDestroy, OnInit, Optional, Type } from '@angular/core';
|
||||||
import { Params } from '@angular/router';
|
import { Params } from '@angular/router';
|
||||||
import { CoreCommentsProvider } from '@features/comments/services/comments';
|
import { CoreCommentsProvider } from '@features/comments/services/comments';
|
||||||
import { CoreCourseModuleMainActivityComponent } from '@features/course/classes/main-activity-component';
|
import { CoreCourseModuleMainActivityComponent } from '@features/course/classes/main-activity-component';
|
||||||
import { CoreCourseModule } from '@features/course/course.module';
|
|
||||||
import { CoreCourseContentsPage } from '@features/course/pages/contents/contents';
|
import { CoreCourseContentsPage } from '@features/course/pages/contents/contents';
|
||||||
import { CoreCourse } from '@features/course/services/course';
|
import { CoreCourse } from '@features/course/services/course';
|
||||||
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreRatingProvider } from '@features/rating/services/rating';
|
import { CoreRatingProvider } from '@features/rating/services/rating';
|
||||||
import { CoreRatingSyncProvider } from '@features/rating/services/rating-sync';
|
import { CoreRatingSyncProvider } from '@features/rating/services/rating-sync';
|
||||||
import { IonContent } from '@ionic/angular';
|
import { IonContent } from '@ionic/angular';
|
||||||
|
@ -95,7 +95,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
fields: Record<number, AddonModDataField>;
|
fields: Record<number, AddonModDataField>;
|
||||||
entries: Record<number, AddonModDataEntry>;
|
entries: Record<number, AddonModDataEntry>;
|
||||||
database: AddonModDataData;
|
database: AddonModDataData;
|
||||||
module: CoreCourseModule;
|
module: CoreCourseModuleData;
|
||||||
group: number;
|
group: number;
|
||||||
gotoEntry: (a: number) => void;
|
gotoEntry: (a: number) => void;
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { Component, OnInit, ViewChild, ElementRef, Type } from '@angular/core';
|
import { Component, OnInit, ViewChild, ElementRef, Type } from '@angular/core';
|
||||||
import { FormGroup } from '@angular/forms';
|
import { FormGroup } from '@angular/forms';
|
||||||
import { CoreError } from '@classes/errors/error';
|
import { CoreError } from '@classes/errors/error';
|
||||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
|
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
|
||||||
import { CoreTag } from '@features/tag/services/tag';
|
import { CoreTag } from '@features/tag/services/tag';
|
||||||
import { IonContent } from '@ionic/angular';
|
import { IonContent } from '@ionic/angular';
|
||||||
|
@ -66,7 +66,7 @@ export class AddonModDataEditPage implements OnInit {
|
||||||
entry?: AddonModDataEntry;
|
entry?: AddonModDataEntry;
|
||||||
fields: Record<number, AddonModDataField> = {};
|
fields: Record<number, AddonModDataField> = {};
|
||||||
courseId!: number;
|
courseId!: number;
|
||||||
module!: CoreCourseModule;
|
module!: CoreCourseModuleData;
|
||||||
database?: AddonModDataData;
|
database?: AddonModDataData;
|
||||||
title = '';
|
title = '';
|
||||||
component = AddonModDataProvider.COMPONENT;
|
component = AddonModDataProvider.COMPONENT;
|
||||||
|
@ -97,7 +97,7 @@ export class AddonModDataEditPage implements OnInit {
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
try {
|
try {
|
||||||
this.module = CoreNavigator.getRequiredRouteParam<CoreCourseModule>('module');
|
this.module = CoreNavigator.getRequiredRouteParam<CoreCourseModuleData>('module');
|
||||||
this.entryId = CoreNavigator.getRouteNumberParam('entryId') || undefined;
|
this.entryId = CoreNavigator.getRouteNumberParam('entryId') || undefined;
|
||||||
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.selectedGroup = CoreNavigator.getRouteNumberParam('group') || 0;
|
this.selectedGroup = CoreNavigator.getRouteNumberParam('group') || 0;
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { Component, OnDestroy, ViewChild, ChangeDetectorRef, OnInit, Type } from
|
||||||
import { CoreCommentsCommentsComponent } from '@features/comments/components/comments/comments';
|
import { CoreCommentsCommentsComponent } from '@features/comments/components/comments/comments';
|
||||||
import { CoreComments } from '@features/comments/services/comments';
|
import { CoreComments } from '@features/comments/services/comments';
|
||||||
import { CoreCourse } from '@features/course/services/course';
|
import { CoreCourse } from '@features/course/services/course';
|
||||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreRatingInfo } from '@features/rating/services/rating';
|
import { CoreRatingInfo } from '@features/rating/services/rating';
|
||||||
import { IonContent, IonRefresher } from '@ionic/angular';
|
import { IonContent, IonRefresher } from '@ionic/angular';
|
||||||
import { CoreGroups, CoreGroupInfo } from '@services/groups';
|
import { CoreGroups, CoreGroupInfo } from '@services/groups';
|
||||||
|
@ -57,7 +57,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
|
||||||
protected fields: Record<number, AddonModDataField> = {};
|
protected fields: Record<number, AddonModDataField> = {};
|
||||||
protected fieldsArray: AddonModDataField[] = [];
|
protected fieldsArray: AddonModDataField[] = [];
|
||||||
|
|
||||||
module!: CoreCourseModule;
|
module!: CoreCourseModuleData;
|
||||||
courseId!: number;
|
courseId!: number;
|
||||||
offset?: number;
|
offset?: number;
|
||||||
title = '';
|
title = '';
|
||||||
|
@ -82,7 +82,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
|
||||||
fields: Record<number, AddonModDataField>;
|
fields: Record<number, AddonModDataField>;
|
||||||
entries: Record<number, AddonModDataEntry>;
|
entries: Record<number, AddonModDataEntry>;
|
||||||
database: AddonModDataData;
|
database: AddonModDataData;
|
||||||
module: CoreCourseModule;
|
module: CoreCourseModuleData;
|
||||||
group: number;
|
group: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
this.module = CoreNavigator.getRequiredRouteParam<CoreCourseModule>('module');
|
this.module = CoreNavigator.getRequiredRouteParam<CoreCourseModuleData>('module');
|
||||||
this.entryId = CoreNavigator.getRouteNumberParam('entryId') || undefined;
|
this.entryId = CoreNavigator.getRouteNumberParam('entryId') || undefined;
|
||||||
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.selectedGroup = CoreNavigator.getRouteNumberParam('group') || 0;
|
this.selectedGroup = CoreNavigator.getRouteNumberParam('group') || 0;
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||||
import { CoreSite } from '@classes/site';
|
import { CoreSite } from '@classes/site';
|
||||||
import { CoreContentLinksHelper } from '@features/contentlinks/services/contentlinks-helper';
|
import { CoreContentLinksHelper } from '@features/contentlinks/services/contentlinks-helper';
|
||||||
import { CoreCourse, CoreCourseCommonModWSOptions, CoreCourseWSModule } from '@features/course/services/course';
|
import { CoreCourse, CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
||||||
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CanLeave } from '@guards/can-leave';
|
import { CanLeave } from '@guards/can-leave';
|
||||||
import { IonContent } from '@ionic/angular';
|
import { IonContent } from '@ionic/angular';
|
||||||
import { CoreApp } from '@services/app';
|
import { CoreApp } from '@services/app';
|
||||||
|
@ -51,7 +51,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
|
||||||
|
|
||||||
@ViewChild(IonContent) content?: IonContent;
|
@ViewChild(IonContent) content?: IonContent;
|
||||||
|
|
||||||
protected module?: CoreCourseWSModule;
|
protected module?: CoreCourseModuleData;
|
||||||
protected currentPage?: number;
|
protected currentPage?: number;
|
||||||
protected siteAfterSubmit?: string;
|
protected siteAfterSubmit?: string;
|
||||||
protected onlineObserver: Subscription;
|
protected onlineObserver: Subscription;
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreCourseResourcePrefetchHandlerBase } from '@features/course/classes/resource-prefetch-handler';
|
import { CoreCourseResourcePrefetchHandlerBase } from '@features/course/classes/resource-prefetch-handler';
|
||||||
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseWSModule } from '@features/course/services/course';
|
import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course';
|
||||||
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonModFolder, AddonModFolderProvider } from '../folder';
|
import { AddonModFolder, AddonModFolderProvider } from '../folder';
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ export class AddonModFolderPrefetchHandlerService extends CoreCourseResourcePref
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async downloadOrPrefetch(module: CoreCourseWSModule, courseId: number, prefetch?: boolean): Promise<void> {
|
async downloadOrPrefetch(module: CoreCourseModuleData, courseId: number, prefetch?: boolean): Promise<void> {
|
||||||
const promises: Promise<unknown>[] = [];
|
const promises: Promise<unknown>[] = [];
|
||||||
|
|
||||||
promises.push(super.downloadOrPrefetch(module, courseId, prefetch));
|
promises.push(super.downloadOrPrefetch(module, courseId, prefetch));
|
||||||
|
|
|
@ -22,7 +22,7 @@ import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/
|
||||||
import { CoreConstants } from '@/core/constants';
|
import { CoreConstants } from '@/core/constants';
|
||||||
import { AddonModForumIndexComponent } from '../../components/index';
|
import { AddonModForumIndexComponent } from '../../components/index';
|
||||||
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
||||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler to support forum modules.
|
* Handler to support forum modules.
|
||||||
|
@ -53,7 +53,7 @@ export class AddonModForumModuleHandlerService extends CoreModuleHandlerBase imp
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async getData(module: CoreCourseModule, courseId: number): Promise<CoreCourseModuleHandlerData> {
|
async getData(module: CoreCourseModuleData, courseId: number): Promise<CoreCourseModuleHandlerData> {
|
||||||
const data = await super.getData(module, courseId);
|
const data = await super.getData(module, courseId);
|
||||||
|
|
||||||
if ('afterlink' in module && !!module.afterlink) {
|
if ('afterlink' in module && !!module.afterlink) {
|
||||||
|
|
|
@ -18,8 +18,8 @@ import {
|
||||||
CoreCourse,
|
CoreCourse,
|
||||||
CoreCourseAnyModuleData,
|
CoreCourseAnyModuleData,
|
||||||
CoreCourseModuleContentFile,
|
CoreCourseModuleContentFile,
|
||||||
CoreCourseWSModule,
|
|
||||||
} from '@features/course/services/course';
|
} from '@features/course/services/course';
|
||||||
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreFilepool } from '@services/filepool';
|
import { CoreFilepool } from '@services/filepool';
|
||||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
|
@ -40,7 +40,7 @@ export class AddonModImscpPrefetchHandlerService extends CoreCourseResourcePrefe
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async downloadOrPrefetch(module: CoreCourseWSModule, courseId: number, prefetch?: boolean): Promise<void> {
|
async downloadOrPrefetch(module: CoreCourseModuleData, courseId: number, prefetch?: boolean): Promise<void> {
|
||||||
const siteId = CoreSites.getCurrentSiteId();
|
const siteId = CoreSites.getCurrentSiteId();
|
||||||
|
|
||||||
const dirPath = await CoreFilepool.getPackageDirPathByUrl(siteId, module.url!);
|
const dirPath = await CoreFilepool.getPackageDirPathByUrl(siteId, module.url!);
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
||||||
import { CoreError } from '@classes/errors/error';
|
import { CoreError } from '@classes/errors/error';
|
||||||
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
|
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
|
||||||
import { CoreCourse, CoreCourseModuleContentFile } from '@features/course/services/course';
|
import { CoreCourse, CoreCourseModuleContentFile } from '@features/course/services/course';
|
||||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||||
import { CoreApp } from '@services/app';
|
import { CoreApp } from '@services/app';
|
||||||
import { CoreFilepool } from '@services/filepool';
|
import { CoreFilepool } from '@services/filepool';
|
||||||
|
@ -171,7 +171,7 @@ export class AddonModImscpProvider {
|
||||||
* @param itemHref Href of item to get. If not defined, gets src of main item.
|
* @param itemHref Href of item to get. If not defined, gets src of main item.
|
||||||
* @return Promise resolved with the item src.
|
* @return Promise resolved with the item src.
|
||||||
*/
|
*/
|
||||||
async getIframeSrc(module: CoreCourseModule, itemHref?: string): Promise<string> {
|
async getIframeSrc(module: CoreCourseModuleData, itemHref?: string): Promise<string> {
|
||||||
const contents = await CoreCourse.getModuleContents(module);
|
const contents = await CoreCourse.getModuleContents(module);
|
||||||
|
|
||||||
if (!itemHref) {
|
if (!itemHref) {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { CoreConstants } from '@/core/constants';
|
import { CoreConstants } from '@/core/constants';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
||||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
|
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ export class AddonModLabelModuleHandlerService extends CoreModuleHandlerBase imp
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async getData(module: CoreCourseModule): Promise<CoreCourseModuleHandlerData> {
|
async getData(module: CoreCourseModuleData): Promise<CoreCourseModuleHandlerData> {
|
||||||
// Remove the description from the module so it isn't rendered twice.
|
// Remove the description from the module so it isn't rendered twice.
|
||||||
const title = module.description || '';
|
const title = module.description || '';
|
||||||
module.description = '';
|
module.description = '';
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable, Type } from '@angular/core';
|
||||||
|
|
||||||
import { CoreConstants } from '@/core/constants';
|
import { CoreConstants } from '@/core/constants';
|
||||||
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
|
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
|
||||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonModLtiHelper } from '../lti-helper';
|
import { AddonModLtiHelper } from '../lti-helper';
|
||||||
import { AddonModLtiIndexComponent } from '../../components/index';
|
import { AddonModLtiIndexComponent } from '../../components/index';
|
||||||
|
@ -49,7 +49,7 @@ export class AddonModLtiModuleHandlerService extends CoreModuleHandlerBase imple
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async getData(
|
async getData(
|
||||||
module: CoreCourseModule,
|
module: CoreCourseModuleData,
|
||||||
courseId: number,
|
courseId: number,
|
||||||
sectionId?: number,
|
sectionId?: number,
|
||||||
forCoursePage?: boolean,
|
forCoursePage?: boolean,
|
||||||
|
@ -63,7 +63,7 @@ export class AddonModLtiModuleHandlerService extends CoreModuleHandlerBase imple
|
||||||
data.buttons = [{
|
data.buttons = [{
|
||||||
icon: 'fas-external-link-alt',
|
icon: 'fas-external-link-alt',
|
||||||
label: 'addon.mod_lti.launchactivity',
|
label: 'addon.mod_lti.launchactivity',
|
||||||
action: (event: Event, module: CoreCourseModule, courseId: number): void => {
|
action: (event: Event, module: CoreCourseModuleData, courseId: number): void => {
|
||||||
// Launch the LTI.
|
// Launch the LTI.
|
||||||
AddonModLtiHelper.getDataAndLaunch(courseId, module);
|
AddonModLtiHelper.getDataAndLaunch(courseId, module);
|
||||||
},
|
},
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { CoreCourse } from '@features/course/services/course';
|
import { CoreCourse } from '@features/course/services/course';
|
||||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { makeSingleton, Platform } from '@singletons';
|
import { makeSingleton, Platform } from '@singletons';
|
||||||
|
@ -28,7 +28,7 @@ import { AddonModLti, AddonModLtiLti } from './lti';
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class AddonModLtiHelperProvider {
|
export class AddonModLtiHelperProvider {
|
||||||
|
|
||||||
protected pendingCheckCompletion: {[moduleId: string]: {courseId: number; module: CoreCourseModule}} = {};
|
protected pendingCheckCompletion: {[moduleId: string]: {courseId: number; module: CoreCourseModuleData}} = {};
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
// Clear pending completion on logout.
|
// Clear pending completion on logout.
|
||||||
|
@ -57,7 +57,7 @@ export class AddonModLtiHelperProvider {
|
||||||
* @param siteId Site ID. If not defined, current site.
|
* @param siteId Site ID. If not defined, current site.
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
async getDataAndLaunch(courseId: number, module: CoreCourseModule, lti?: AddonModLtiLti, siteId?: string): Promise<void> {
|
async getDataAndLaunch(courseId: number, module: CoreCourseModuleData, lti?: AddonModLtiLti, siteId?: string): Promise<void> {
|
||||||
siteId = siteId || CoreSites.getCurrentSiteId();
|
siteId = siteId || CoreSites.getCurrentSiteId();
|
||||||
|
|
||||||
const modal = await CoreDomUtils.showModalLoading();
|
const modal = await CoreDomUtils.showModalLoading();
|
||||||
|
@ -108,7 +108,7 @@ export class AddonModLtiHelperProvider {
|
||||||
*/
|
*/
|
||||||
async logViewAndCheckCompletion(
|
async logViewAndCheckCompletion(
|
||||||
courseId: number,
|
courseId: number,
|
||||||
module: CoreCourseModule,
|
module: CoreCourseModuleData,
|
||||||
ltiId: number,
|
ltiId: number,
|
||||||
name?: string,
|
name?: string,
|
||||||
siteId?: string,
|
siteId?: string,
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreCourseResourcePrefetchHandlerBase } from '@features/course/classes/resource-prefetch-handler';
|
import { CoreCourseResourcePrefetchHandlerBase } from '@features/course/classes/resource-prefetch-handler';
|
||||||
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseWSModule } from '@features/course/services/course';
|
import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course';
|
||||||
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonModPage, AddonModPageProvider } from '../page';
|
import { AddonModPage, AddonModPageProvider } from '../page';
|
||||||
|
@ -38,7 +39,7 @@ export class AddonModPagePrefetchHandlerService extends CoreCourseResourcePrefet
|
||||||
* @param prefetch True to prefetch, false to download right away.
|
* @param prefetch True to prefetch, false to download right away.
|
||||||
* @return Promise resolved when all content is downloaded. Data returned is not reliable.
|
* @return Promise resolved when all content is downloaded. Data returned is not reliable.
|
||||||
*/
|
*/
|
||||||
async downloadOrPrefetch(module: CoreCourseWSModule, courseId: number, prefetch?: boolean): Promise<void> {
|
async downloadOrPrefetch(module: CoreCourseModuleData, courseId: number, prefetch?: boolean): Promise<void> {
|
||||||
const promises: Promise<unknown>[] = [];
|
const promises: Promise<unknown>[] = [];
|
||||||
|
|
||||||
promises.push(super.downloadOrPrefetch(module, courseId, prefetch));
|
promises.push(super.downloadOrPrefetch(module, courseId, prefetch));
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
import { CoreConstants } from '@/core/constants';
|
import { CoreConstants } from '@/core/constants';
|
||||||
import { Injectable, Type } from '@angular/core';
|
import { Injectable, Type } from '@angular/core';
|
||||||
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
||||||
import { CoreCourse, CoreCourseWSModule } from '@features/course/services/course';
|
import { CoreCourse } from '@features/course/services/course';
|
||||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
|
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } 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 { CoreFileHelper } from '@services/file-helper';
|
import { CoreFileHelper } from '@services/file-helper';
|
||||||
|
@ -63,7 +63,7 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async getData(
|
async getData(
|
||||||
module: CoreCourseModule,
|
module: CoreCourseModuleData,
|
||||||
courseId: number,
|
courseId: number,
|
||||||
sectionId?: number,
|
sectionId?: number,
|
||||||
forCoursePage?: boolean,
|
forCoursePage?: boolean,
|
||||||
|
@ -84,7 +84,7 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase
|
||||||
hidden: true,
|
hidden: true,
|
||||||
icon: openWithPicker ? 'fas-share-square' : 'fas-file',
|
icon: openWithPicker ? 'fas-share-square' : 'fas-file',
|
||||||
label: module.name + ': ' + Translate.instant(openWithPicker ? 'core.openwith' : 'addon.mod_resource.openthefile'),
|
label: module.name + ': ' + Translate.instant(openWithPicker ? 'core.openwith' : 'addon.mod_resource.openthefile'),
|
||||||
action: async (event: Event, module: CoreCourseModule, courseId: number): Promise<void> => {
|
action: async (event: Event, module: CoreCourseModuleData, courseId: number): Promise<void> => {
|
||||||
const hide = await this.hideOpenButton(module, courseId);
|
const hide = await this.hideOpenButton(module, courseId);
|
||||||
if (!hide) {
|
if (!hide) {
|
||||||
AddonModResourceHelper.openModuleFile(module, courseId);
|
AddonModResourceHelper.openModuleFile(module, courseId);
|
||||||
|
@ -112,7 +112,7 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase
|
||||||
* @param courseId The course ID.
|
* @param courseId The course ID.
|
||||||
* @return Resolved when done.
|
* @return Resolved when done.
|
||||||
*/
|
*/
|
||||||
protected async hideOpenButton(module: CoreCourseModule, courseId: number): Promise<boolean> {
|
protected async hideOpenButton(module: CoreCourseModuleData, courseId: number): Promise<boolean> {
|
||||||
if (!('contentsinfo' in module) || !module.contentsinfo) {
|
if (!('contentsinfo' in module) || !module.contentsinfo) {
|
||||||
await CoreCourse.loadModuleContents(module, courseId, undefined, false, false, undefined, this.modName);
|
await CoreCourse.loadModuleContents(module, courseId, undefined, false, false, undefined, this.modName);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase
|
||||||
* @return Resource data.
|
* @return Resource data.
|
||||||
*/
|
*/
|
||||||
protected async getResourceData(
|
protected async getResourceData(
|
||||||
module: CoreCourseModule,
|
module: CoreCourseModuleData,
|
||||||
courseId: number,
|
courseId: number,
|
||||||
handlerData: CoreCourseModuleHandlerData,
|
handlerData: CoreCourseModuleHandlerData,
|
||||||
): Promise<AddonResourceHandlerData> {
|
): Promise<AddonResourceHandlerData> {
|
||||||
|
@ -229,7 +229,7 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async getIconSrc(module?: CoreCourseWSModule): Promise<string | undefined> {
|
async getIconSrc(module?: CoreCourseModuleData): Promise<string | undefined> {
|
||||||
if (!module) {
|
if (!module) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
import { CoreConstants } from '@/core/constants';
|
import { CoreConstants } from '@/core/constants';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreCourseResourcePrefetchHandlerBase } from '@features/course/classes/resource-prefetch-handler';
|
import { CoreCourseResourcePrefetchHandlerBase } from '@features/course/classes/resource-prefetch-handler';
|
||||||
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseWSModule } from '@features/course/services/course';
|
import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course';
|
||||||
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreFilepool } from '@services/filepool';
|
import { CoreFilepool } from '@services/filepool';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
|
@ -57,7 +58,7 @@ export class AddonModResourcePrefetchHandlerService extends CoreCourseResourcePr
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async downloadOrPrefetch(module: CoreCourseWSModule, courseId: number, prefetch?: boolean): Promise<void> {
|
async downloadOrPrefetch(module: CoreCourseModuleData, courseId: number, prefetch?: boolean): Promise<void> {
|
||||||
let dirPath: string | undefined;
|
let dirPath: string | undefined;
|
||||||
|
|
||||||
if (AddonModResourceHelper.isDisplayedInIframe(module)) {
|
if (AddonModResourceHelper.isDisplayedInIframe(module)) {
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
import { CoreConstants } from '@/core/constants';
|
import { CoreConstants } from '@/core/constants';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreError } from '@classes/errors/error';
|
import { CoreError } from '@classes/errors/error';
|
||||||
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseWSModule } from '@features/course/services/course';
|
import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course';
|
||||||
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreApp } from '@services/app';
|
import { CoreApp } from '@services/app';
|
||||||
import { CoreFile } from '@services/file';
|
import { CoreFile } from '@services/file';
|
||||||
import { CoreFileHelper } from '@services/file-helper';
|
import { CoreFileHelper } from '@services/file-helper';
|
||||||
|
@ -42,7 +42,7 @@ export class AddonModResourceHelperProvider {
|
||||||
* @param courseId The course ID.
|
* @param courseId The course ID.
|
||||||
* @return Promise resolved with the HTML.
|
* @return Promise resolved with the HTML.
|
||||||
*/
|
*/
|
||||||
async getEmbeddedHtml(module: CoreCourseWSModule, courseId: number): Promise<string> {
|
async getEmbeddedHtml(module: CoreCourseModuleData, courseId: number): Promise<string> {
|
||||||
const contents = await CoreCourse.getModuleContents(module, courseId);
|
const contents = await CoreCourse.getModuleContents(module, courseId);
|
||||||
|
|
||||||
const result = await CoreCourseHelper.downloadModuleWithMainFileIfNeeded(
|
const result = await CoreCourseHelper.downloadModuleWithMainFileIfNeeded(
|
||||||
|
@ -62,7 +62,7 @@ export class AddonModResourceHelperProvider {
|
||||||
* @param module The module object.
|
* @param module The module object.
|
||||||
* @return Promise resolved with the iframe src.
|
* @return Promise resolved with the iframe src.
|
||||||
*/
|
*/
|
||||||
async getIframeSrc(module: CoreCourseWSModule): Promise<string> {
|
async getIframeSrc(module: CoreCourseModuleData): Promise<string> {
|
||||||
if (!module.contents?.length) {
|
if (!module.contents?.length) {
|
||||||
throw new CoreError('No contents available in module');
|
throw new CoreError('No contents available in module');
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ export class AddonModResourceHelperProvider {
|
||||||
* @param display The display mode (if available).
|
* @param display The display mode (if available).
|
||||||
* @return Whether the resource should be displayed embeded.
|
* @return Whether the resource should be displayed embeded.
|
||||||
*/
|
*/
|
||||||
isDisplayedEmbedded(module: CoreCourseWSModule, display: number): boolean {
|
isDisplayedEmbedded(module: CoreCourseModuleData, display: number): boolean {
|
||||||
const currentSite = CoreSites.getCurrentSite();
|
const currentSite = CoreSites.getCurrentSite();
|
||||||
|
|
||||||
if (!CoreFile.isAvailable() ||
|
if (!CoreFile.isAvailable() ||
|
||||||
|
@ -150,7 +150,7 @@ export class AddonModResourceHelperProvider {
|
||||||
* @param siteId Site ID. If not defined, current site.
|
* @param siteId Site ID. If not defined, current site.
|
||||||
* @return Promise resolved with boolean: whether main file is downloadable.
|
* @return Promise resolved with boolean: whether main file is downloadable.
|
||||||
*/
|
*/
|
||||||
async isMainFileDownloadable(module: CoreCourseWSModule, siteId?: string): Promise<boolean> {
|
async isMainFileDownloadable(module: CoreCourseModuleData, siteId?: string): Promise<boolean> {
|
||||||
const contents = await CoreCourse.getModuleContents(module);
|
const contents = await CoreCourse.getModuleContents(module);
|
||||||
if (!contents.length) {
|
if (!contents.length) {
|
||||||
throw new CoreError(Translate.instant('core.filenotfound'));
|
throw new CoreError(Translate.instant('core.filenotfound'));
|
||||||
|
@ -186,7 +186,7 @@ export class AddonModResourceHelperProvider {
|
||||||
* @param options Options to open the file.
|
* @param options Options to open the file.
|
||||||
* @return Resolved when done.
|
* @return Resolved when done.
|
||||||
*/
|
*/
|
||||||
async openModuleFile(module: CoreCourseWSModule, courseId: number, options: CoreUtilsOpenFileOptions = {}): Promise<void> {
|
async openModuleFile(module: CoreCourseModuleData, courseId: number, options: CoreUtilsOpenFileOptions = {}): Promise<void> {
|
||||||
const modal = await CoreDomUtils.showModalLoading();
|
const modal = await CoreDomUtils.showModalLoading();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { Injectable, Type } from '@angular/core';
|
||||||
import { CoreContentLinksHelper } from '@features/contentlinks/services/contentlinks-helper';
|
import { CoreContentLinksHelper } from '@features/contentlinks/services/contentlinks-helper';
|
||||||
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
||||||
import { CoreCourse } from '@features/course/services/course';
|
import { CoreCourse } from '@features/course/services/course';
|
||||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
|
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
|
||||||
import { CoreNavigationOptions } from '@services/navigator';
|
import { CoreNavigationOptions } from '@services/navigator';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
|
@ -54,7 +54,7 @@ export class AddonModUrlModuleHandlerService extends CoreModuleHandlerBase imple
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async getData(module: CoreCourseModule, courseId: number): Promise<CoreCourseModuleHandlerData> {
|
async getData(module: CoreCourseModuleData, courseId: number): Promise<CoreCourseModuleHandlerData> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open the URL.
|
* Open the URL.
|
||||||
|
@ -62,7 +62,7 @@ export class AddonModUrlModuleHandlerService extends CoreModuleHandlerBase imple
|
||||||
* @param module The module object.
|
* @param module The module object.
|
||||||
* @param courseId The course ID.
|
* @param courseId The course ID.
|
||||||
*/
|
*/
|
||||||
const openUrl = async (module: CoreCourseModule, courseId: number): Promise<void> => {
|
const openUrl = async (module: CoreCourseModuleData, courseId: number): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
if (module.instance) {
|
if (module.instance) {
|
||||||
await AddonModUrl.logView(module.instance, module.name);
|
await AddonModUrl.logView(module.instance, module.name);
|
||||||
|
@ -81,7 +81,7 @@ export class AddonModUrlModuleHandlerService extends CoreModuleHandlerBase imple
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_url-handler',
|
class: 'addon-mod_url-handler',
|
||||||
showDownloadButton: false,
|
showDownloadButton: false,
|
||||||
action: async (event: Event, module: CoreCourseModule, courseId: number, options?: CoreNavigationOptions) => {
|
action: async (event: Event, module: CoreCourseModuleData, courseId: number, options?: CoreNavigationOptions) => {
|
||||||
const modal = await CoreDomUtils.showModalLoading();
|
const modal = await CoreDomUtils.showModalLoading();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -100,7 +100,7 @@ export class AddonModUrlModuleHandlerService extends CoreModuleHandlerBase imple
|
||||||
hidden: true, // Hide it until we calculate if it should be displayed or not.
|
hidden: true, // Hide it until we calculate if it should be displayed or not.
|
||||||
icon: 'fas-link',
|
icon: 'fas-link',
|
||||||
label: 'core.openmodinbrowser',
|
label: 'core.openmodinbrowser',
|
||||||
action: (event: Event, module: CoreCourseModule, courseId: number): void => {
|
action: (event: Event, module: CoreCourseModuleData, courseId: number): void => {
|
||||||
openUrl(module, courseId);
|
openUrl(module, courseId);
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
|
@ -135,7 +135,7 @@ export class AddonModUrlModuleHandlerService extends CoreModuleHandlerBase imple
|
||||||
* @param courseId The course ID.
|
* @param courseId The course ID.
|
||||||
* @return Resolved when done.
|
* @return Resolved when done.
|
||||||
*/
|
*/
|
||||||
protected async hideLinkButton(module: CoreCourseModule, courseId: number): Promise<boolean> {
|
protected async hideLinkButton(module: CoreCourseModuleData, courseId: number): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
const contents = await CoreCourse.getModuleContents(module, courseId, undefined, false, false, undefined, this.modName);
|
const contents = await CoreCourse.getModuleContents(module, courseId, undefined, false, false, undefined, this.modName);
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ export class AddonModUrlModuleHandlerService extends CoreModuleHandlerBase imple
|
||||||
* @param courseId Course ID.
|
* @param courseId Course ID.
|
||||||
* @return Promise resolved with boolean.
|
* @return Promise resolved with boolean.
|
||||||
*/
|
*/
|
||||||
protected async shouldOpenLink(module: CoreCourseModule, courseId?: number): Promise<boolean> {
|
protected async shouldOpenLink(module: CoreCourseModuleData, courseId?: number): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
const contents = await CoreCourse.getModuleContents(module, courseId, undefined, false, false, undefined, this.modName);
|
const contents = await CoreCourse.getModuleContents(module, courseId, undefined, false, false, undefined, this.modName);
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ export class AddonModUrlModuleHandlerService extends CoreModuleHandlerBase imple
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
manualCompletionAlwaysShown(module: CoreCourseModule): Promise<boolean> {
|
manualCompletionAlwaysShown(module: CoreCourseModuleData): Promise<boolean> {
|
||||||
return this.shouldOpenLink(module, module.course);
|
return this.shouldOpenLink(module, module.course);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
import { Component, Input, OnInit } from '@angular/core';
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
import { Params } from '@angular/router';
|
import { Params } from '@angular/router';
|
||||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreUser, CoreUserProfile } from '@features/user/services/user';
|
import { CoreUser, CoreUserProfile } from '@features/user/services/user';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
|
@ -41,7 +41,7 @@ export class AddonModWorkshopAssessmentComponent implements OnInit {
|
||||||
@Input() workshop!: AddonModWorkshopData;
|
@Input() workshop!: AddonModWorkshopData;
|
||||||
@Input() access!: AddonModWorkshopGetWorkshopAccessInformationWSResponse;
|
@Input() access!: AddonModWorkshopGetWorkshopAccessInformationWSResponse;
|
||||||
@Input() submission!: AddonModWorkshopSubmissionDataWithOfflineData;
|
@Input() submission!: AddonModWorkshopSubmissionDataWithOfflineData;
|
||||||
@Input() module!: CoreCourseModule;
|
@Input() module!: CoreCourseModuleData;
|
||||||
|
|
||||||
canViewAssessment = false;
|
canViewAssessment = false;
|
||||||
canSelfAssess = false;
|
canSelfAssess = false;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
import { Component, Input, OnInit } from '@angular/core';
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
import { Params } from '@angular/router';
|
import { Params } from '@angular/router';
|
||||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreUser, CoreUserProfile } from '@features/user/services/user';
|
import { CoreUser, CoreUserProfile } from '@features/user/services/user';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
|
@ -44,7 +44,7 @@ import { AddonModWorkshopOffline } from '../../services/workshop-offline';
|
||||||
export class AddonModWorkshopSubmissionComponent implements OnInit {
|
export class AddonModWorkshopSubmissionComponent implements OnInit {
|
||||||
|
|
||||||
@Input() submission!: AddonModWorkshopSubmissionDataWithOfflineData;
|
@Input() submission!: AddonModWorkshopSubmissionDataWithOfflineData;
|
||||||
@Input() module!: CoreCourseModule;
|
@Input() module!: CoreCourseModuleData;
|
||||||
@Input() workshop!: AddonModWorkshopData;
|
@Input() workshop!: AddonModWorkshopData;
|
||||||
@Input() access!: AddonModWorkshopGetWorkshopAccessInformationWSResponse;
|
@Input() access!: AddonModWorkshopGetWorkshopAccessInformationWSResponse;
|
||||||
@Input() courseId!: number;
|
@Input() courseId!: number;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { Component, OnInit, OnDestroy, ViewChild, ElementRef } from '@angular/core';
|
import { Component, OnInit, OnDestroy, ViewChild, ElementRef } from '@angular/core';
|
||||||
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
||||||
import { CoreError } from '@classes/errors/error';
|
import { CoreError } from '@classes/errors/error';
|
||||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
|
import { CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
|
||||||
import { CanLeave } from '@guards/can-leave';
|
import { CanLeave } from '@guards/can-leave';
|
||||||
import { CoreFile } from '@services/file';
|
import { CoreFile } from '@services/file';
|
||||||
|
@ -51,7 +51,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca
|
||||||
|
|
||||||
@ViewChild('editFormEl') formElement!: ElementRef;
|
@ViewChild('editFormEl') formElement!: ElementRef;
|
||||||
|
|
||||||
module!: CoreCourseModule;
|
module!: CoreCourseModuleData;
|
||||||
courseId!: number;
|
courseId!: number;
|
||||||
access!: AddonModWorkshopGetWorkshopAccessInformationWSResponse;
|
access!: AddonModWorkshopGetWorkshopAccessInformationWSResponse;
|
||||||
submission?: AddonModWorkshopSubmissionDataWithOfflineData;
|
submission?: AddonModWorkshopSubmissionDataWithOfflineData;
|
||||||
|
@ -100,7 +100,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
try {
|
try {
|
||||||
this.module = CoreNavigator.getRequiredRouteParam<CoreCourseModule>('module');
|
this.module = CoreNavigator.getRequiredRouteParam<CoreCourseModuleData>('module');
|
||||||
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.access = CoreNavigator.getRequiredRouteParam<AddonModWorkshopGetWorkshopAccessInformationWSResponse>('access');
|
this.access = CoreNavigator.getRequiredRouteParam<AddonModWorkshopGetWorkshopAccessInformationWSResponse>('access');
|
||||||
this.submissionId = CoreNavigator.getRouteNumberParam('submissionId') || 0;
|
this.submissionId = CoreNavigator.getRouteNumberParam('submissionId') || 0;
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { Component, OnInit, OnDestroy, Optional, ViewChild, ElementRef } from '@
|
||||||
import { FormGroup, FormBuilder } from '@angular/forms';
|
import { FormGroup, FormBuilder } from '@angular/forms';
|
||||||
import { Params } from '@angular/router';
|
import { Params } from '@angular/router';
|
||||||
import { CoreCourse } from '@features/course/services/course';
|
import { CoreCourse } from '@features/course/services/course';
|
||||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreGradesHelper, CoreGradesMenuItem } from '@features/grades/services/grades-helper';
|
import { CoreGradesHelper, CoreGradesMenuItem } from '@features/grades/services/grades-helper';
|
||||||
import { CoreUser, CoreUserProfile } from '@features/user/services/user';
|
import { CoreUser, CoreUserProfile } from '@features/user/services/user';
|
||||||
import { CanLeave } from '@guards/can-leave';
|
import { CanLeave } from '@guards/can-leave';
|
||||||
|
@ -61,7 +61,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy, CanLea
|
||||||
|
|
||||||
@ViewChild('feedbackFormEl') formElement?: ElementRef;
|
@ViewChild('feedbackFormEl') formElement?: ElementRef;
|
||||||
|
|
||||||
module!: CoreCourseModule;
|
module!: CoreCourseModuleData;
|
||||||
workshop!: AddonModWorkshopData;
|
workshop!: AddonModWorkshopData;
|
||||||
access!: AddonModWorkshopGetWorkshopAccessInformationWSResponse;
|
access!: AddonModWorkshopGetWorkshopAccessInformationWSResponse;
|
||||||
assessment?: AddonModWorkshopSubmissionAssessmentWithFormData;
|
assessment?: AddonModWorkshopSubmissionAssessmentWithFormData;
|
||||||
|
@ -132,7 +132,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy, CanLea
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
this.submissionId = CoreNavigator.getRequiredRouteNumberParam('submissionId');
|
this.submissionId = CoreNavigator.getRequiredRouteNumberParam('submissionId');
|
||||||
this.module = CoreNavigator.getRequiredRouteParam<CoreCourseModule>('module');
|
this.module = CoreNavigator.getRequiredRouteParam<CoreCourseModuleData>('module');
|
||||||
this.workshop = CoreNavigator.getRequiredRouteParam<AddonModWorkshopData>('workshop');
|
this.workshop = CoreNavigator.getRequiredRouteParam<AddonModWorkshopData>('workshop');
|
||||||
this.access = CoreNavigator.getRequiredRouteParam<AddonModWorkshopGetWorkshopAccessInformationWSResponse>('access');
|
this.access = CoreNavigator.getRequiredRouteParam<AddonModWorkshopGetWorkshopAccessInformationWSResponse>('access');
|
||||||
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { CoreConstants } from '@/core/constants';
|
import { CoreConstants } from '@/core/constants';
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { CoreCourse } from '@features/course/services/course';
|
import { CoreCourse } from '@features/course/services/course';
|
||||||
import { CoreCourseHelper, CoreCourseModule, CoreCourseSection } from '@features/course/services/course-helper';
|
import { CoreCourseHelper, CoreCourseModuleData, CoreCourseSection } from '@features/course/services/course-helper';
|
||||||
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
|
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
|
||||||
import { CoreEnrolledCourseData } from '@features/courses/services/courses';
|
import { CoreEnrolledCourseData } from '@features/courses/services/courses';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
|
@ -52,8 +52,8 @@ export class AddonStorageManagerCourseStoragePage implements OnInit {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sections = await CoreCourse.getSections(this.course.id, false, true);
|
const sections = await CoreCourse.getSections(this.course.id, false, true);
|
||||||
CoreCourseHelper.addHandlerDataForModules(this.sections, this.course.id);
|
this.sections = CoreCourseHelper.addHandlerDataForModules(sections, this.course.id).sections;
|
||||||
|
|
||||||
this.totalSize = 0;
|
this.totalSize = 0;
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ type AddonStorageManagerCourseSection = Omit<CoreCourseSection, 'modules'> & {
|
||||||
modules: AddonStorageManagerModule[];
|
modules: AddonStorageManagerModule[];
|
||||||
};
|
};
|
||||||
|
|
||||||
type AddonStorageManagerModule = CoreCourseModule & {
|
type AddonStorageManagerModule = CoreCourseModuleData & {
|
||||||
parentSection?: AddonStorageManagerCourseSection;
|
parentSection?: AddonStorageManagerCourseSection;
|
||||||
totalSize?: number;
|
totalSize?: number;
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,7 +30,7 @@ import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
import { CoreLogger } from '@singletons/logger';
|
import { CoreLogger } from '@singletons/logger';
|
||||||
import { CoreCourseContentsPage } from '../pages/contents/contents';
|
import { CoreCourseContentsPage } from '../pages/contents/contents';
|
||||||
import { CoreCourse } from '../services/course';
|
import { CoreCourse } from '../services/course';
|
||||||
import { CoreCourseHelper, CoreCourseModule } from '../services/course-helper';
|
import { CoreCourseHelper, CoreCourseModuleData } from '../services/course-helper';
|
||||||
import { CoreCourseModuleDelegate, CoreCourseModuleMainComponent } from '../services/module-delegate';
|
import { CoreCourseModuleDelegate, CoreCourseModuleMainComponent } from '../services/module-delegate';
|
||||||
import { CoreCourseModulePrefetchDelegate } from '../services/module-prefetch-delegate';
|
import { CoreCourseModulePrefetchDelegate } from '../services/module-prefetch-delegate';
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ export type CoreCourseResourceDownloadResult = {
|
||||||
})
|
})
|
||||||
export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy, CoreCourseModuleMainComponent {
|
export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy, CoreCourseModuleMainComponent {
|
||||||
|
|
||||||
@Input() module!: CoreCourseModule; // The module of the component.
|
@Input() module!: CoreCourseModuleData; // The module of the component.
|
||||||
@Input() courseId!: number; // Course ID the component belongs to.
|
@Input() courseId!: number; // Course ID the component belongs to.
|
||||||
@Output() dataRetrieved = new EventEmitter<unknown>(); // Called to notify changes the index page from the main component.
|
@Output() dataRetrieved = new EventEmitter<unknown>(); // Called to notify changes the index page from the main component.
|
||||||
|
|
||||||
|
@ -100,7 +100,6 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
|
||||||
this.showCompletion = !!CoreSites.getRequiredCurrentSite().isVersionGreaterEqualThan('3.11');
|
this.showCompletion = !!CoreSites.getRequiredCurrentSite().isVersionGreaterEqualThan('3.11');
|
||||||
|
|
||||||
if (this.showCompletion) {
|
if (this.showCompletion) {
|
||||||
CoreCourseHelper.calculateModuleCompletionData(this.module);
|
|
||||||
CoreCourseHelper.loadModuleOfflineCompletion(this.courseId, this.module);
|
CoreCourseHelper.loadModuleOfflineCompletion(this.courseId, this.module);
|
||||||
|
|
||||||
this.completionObserver = CoreEvents.on(CoreEvents.COMPLETION_MODULE_VIEWED, async (data) => {
|
this.completionObserver = CoreEvents.on(CoreEvents.COMPLETION_MODULE_VIEWED, async (data) => {
|
||||||
|
@ -428,8 +427,6 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
|
||||||
protected async fetchModule(): Promise<void> {
|
protected async fetchModule(): Promise<void> {
|
||||||
const module = await CoreCourse.getModule(this.module.id, this.courseId);
|
const module = await CoreCourse.getModule(this.module.id, this.courseId);
|
||||||
|
|
||||||
CoreCourseHelper.calculateModuleCompletionData(module);
|
|
||||||
|
|
||||||
await CoreCourseHelper.loadModuleOfflineCompletion(this.courseId, module);
|
await CoreCourseHelper.loadModuleOfflineCompletion(this.courseId, module);
|
||||||
|
|
||||||
this.module = module;
|
this.module = module;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
import { CoreNavigationOptions, CoreNavigator } from '@services/navigator';
|
import { CoreNavigationOptions, CoreNavigator } from '@services/navigator';
|
||||||
import { CoreCourse } from '../services/course';
|
import { CoreCourse } from '../services/course';
|
||||||
import { CoreCourseModule } from '../services/course-helper';
|
import { CoreCourseModuleData } from '../services/course-helper';
|
||||||
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '../services/module-delegate';
|
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '../services/module-delegate';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +35,7 @@ export class CoreModuleHandlerBase implements Partial<CoreCourseModuleHandler> {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async getData(
|
async getData(
|
||||||
module: CoreCourseModule,
|
module: CoreCourseModuleData,
|
||||||
courseId: number, // eslint-disable-line @typescript-eslint/no-unused-vars
|
courseId: number, // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
sectionId?: number, // eslint-disable-line @typescript-eslint/no-unused-vars
|
sectionId?: number, // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
forCoursePage?: boolean, // eslint-disable-line @typescript-eslint/no-unused-vars
|
forCoursePage?: boolean, // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
@ -47,7 +47,7 @@ export class CoreModuleHandlerBase implements Partial<CoreCourseModuleHandler> {
|
||||||
showDownloadButton: true,
|
showDownloadButton: true,
|
||||||
action: async (
|
action: async (
|
||||||
event: Event,
|
event: Event,
|
||||||
module: CoreCourseModule,
|
module: CoreCourseModuleData,
|
||||||
courseId: number,
|
courseId: number,
|
||||||
options?: CoreNavigationOptions,
|
options?: CoreNavigationOptions,
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
|
@ -64,7 +64,7 @@ export class CoreModuleHandlerBase implements Partial<CoreCourseModuleHandler> {
|
||||||
* @param options Options for the navigation.
|
* @param options Options for the navigation.
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
async openActivityPage(module: CoreCourseModule, courseId: number, options?: CoreNavigationOptions): Promise<void> {
|
async openActivityPage(module: CoreCourseModuleData, courseId: number, options?: CoreNavigationOptions): Promise<void> {
|
||||||
if (!CoreCourse.moduleHasView(module)) {
|
if (!CoreCourse.moduleHasView(module)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,8 @@ import { CoreApp } from '@services/app';
|
||||||
import { CoreFilepool } from '@services/filepool';
|
import { CoreFilepool } from '@services/filepool';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreWSFile } from '@services/ws';
|
import { CoreWSFile } from '@services/ws';
|
||||||
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseWSModule } from '../services/course';
|
import { CoreCourse, CoreCourseAnyModuleData } from '../services/course';
|
||||||
|
import { CoreCourseModuleData } from '../services/course-helper';
|
||||||
import { CoreCourseModulePrefetchHandlerBase } from './module-prefetch-handler';
|
import { CoreCourseModulePrefetchHandlerBase } from './module-prefetch-handler';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,7 +41,7 @@ export class CoreCourseResourcePrefetchHandlerBase extends CoreCourseModulePrefe
|
||||||
* @param dirPath Path of the directory where to store all the content files.
|
* @param dirPath Path of the directory where to store all the content files.
|
||||||
* @return Promise resolved when all content is downloaded.
|
* @return Promise resolved when all content is downloaded.
|
||||||
*/
|
*/
|
||||||
download(module: CoreCourseWSModule, courseId: number, dirPath?: string): Promise<void> {
|
download(module: CoreCourseModuleData, courseId: number, dirPath?: string): Promise<void> {
|
||||||
return this.downloadOrPrefetch(module, courseId, false, dirPath);
|
return this.downloadOrPrefetch(module, courseId, false, dirPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ export class CoreCourseResourcePrefetchHandlerBase extends CoreCourseModulePrefe
|
||||||
* in the filepool root folder.
|
* in the filepool root folder.
|
||||||
* @return Promise resolved when all content is downloaded.
|
* @return Promise resolved when all content is downloaded.
|
||||||
*/
|
*/
|
||||||
async downloadOrPrefetch(module: CoreCourseWSModule, courseId: number, prefetch?: boolean, dirPath?: string): Promise<void> {
|
async downloadOrPrefetch(module: CoreCourseModuleData, courseId: number, prefetch?: boolean, dirPath?: string): Promise<void> {
|
||||||
if (!CoreApp.isOnline()) {
|
if (!CoreApp.isOnline()) {
|
||||||
// Cannot download in offline.
|
// Cannot download in offline.
|
||||||
throw new CoreNetworkError();
|
throw new CoreNetworkError();
|
||||||
|
@ -85,7 +86,7 @@ export class CoreCourseResourcePrefetchHandlerBase extends CoreCourseModulePrefe
|
||||||
*/
|
*/
|
||||||
protected async performDownloadOrPrefetch(
|
protected async performDownloadOrPrefetch(
|
||||||
siteId: string,
|
siteId: string,
|
||||||
module: CoreCourseWSModule,
|
module: CoreCourseModuleData,
|
||||||
courseId: number,
|
courseId: number,
|
||||||
prefetch: boolean,
|
prefetch: boolean,
|
||||||
dirPath?: string,
|
dirPath?: string,
|
||||||
|
@ -143,7 +144,7 @@ export class CoreCourseResourcePrefetchHandlerBase extends CoreCourseModulePrefe
|
||||||
* @return Promise resolved with the list of files.
|
* @return Promise resolved with the list of files.
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
async getFiles(module: CoreCourseWSModule, courseId: number, single?: boolean): Promise<CoreWSFile[]> {
|
async getFiles(module: CoreCourseModuleData, courseId: number, single?: boolean): Promise<CoreWSFile[]> {
|
||||||
// Load module contents if needed.
|
// Load module contents if needed.
|
||||||
await this.loadContents(module, courseId);
|
await this.loadContents(module, courseId);
|
||||||
|
|
||||||
|
@ -190,7 +191,7 @@ export class CoreCourseResourcePrefetchHandlerBase extends CoreCourseModulePrefe
|
||||||
* @param dirPath Path of the directory where to store all the content files.
|
* @param dirPath Path of the directory where to store all the content files.
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
prefetch(module: CoreCourseWSModule, courseId: number, single?: boolean, dirPath?: string): Promise<void> {
|
prefetch(module: CoreCourseModuleData, courseId: number, single?: boolean, dirPath?: string): Promise<void> {
|
||||||
return this.downloadOrPrefetch(module, courseId, true, dirPath);
|
return this.downloadOrPrefetch(module, courseId, true, dirPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ import {
|
||||||
} from '@features/course/services/course';
|
} from '@features/course/services/course';
|
||||||
import {
|
import {
|
||||||
CoreCourseHelper,
|
CoreCourseHelper,
|
||||||
CoreCourseModule,
|
CoreCourseModuleData,
|
||||||
CoreCourseModuleCompletionData,
|
CoreCourseModuleCompletionData,
|
||||||
CoreCourseSection,
|
CoreCourseSection,
|
||||||
CoreCourseSectionWithStatus,
|
CoreCourseSectionWithStatus,
|
||||||
|
@ -637,7 +637,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the completion value is not used, the page won't be reloaded, so update the progress bar.
|
// If the completion value is not used, the page won't be reloaded, so update the progress bar.
|
||||||
const completionModules = (<CoreCourseModule[]> [])
|
const completionModules = (<CoreCourseModuleData[]> [])
|
||||||
.concat(...this.sections!.map((section) => section.modules))
|
.concat(...this.sections!.map((section) => section.modules))
|
||||||
.map((module) => module.completion && module.completion > 0 ? 1 : module.completion)
|
.map((module) => module.completion && module.completion > 0 ? 1 : module.completion)
|
||||||
.reduce((accumulator, currentValue) => (accumulator || 0) + (currentValue || 0), 0);
|
.reduce((accumulator, currentValue) => (accumulator || 0) + (currentValue || 0), 0);
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||||
import { CoreCourse } from '@features/course/services/course';
|
import { CoreCourse } from '@features/course/services/course';
|
||||||
import { CoreCourseModule, CoreCourseModuleCompletionData } from '@features/course/services/course-helper';
|
import { CoreCourseModuleData, CoreCourseModuleCompletionData } from '@features/course/services/course-helper';
|
||||||
import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate';
|
import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ import { CoreSites } from '@services/sites';
|
||||||
})
|
})
|
||||||
export class CoreCourseModuleInfoComponent implements OnInit {
|
export class CoreCourseModuleInfoComponent implements OnInit {
|
||||||
|
|
||||||
@Input() module!: CoreCourseModule; // The module to render.
|
@Input() module!: CoreCourseModuleData; // The module to render.
|
||||||
@Input() showManualCompletion = true; // Whether to show manual completion, true by default.
|
@Input() showManualCompletion = true; // Whether to show manual completion, true by default.
|
||||||
@Input() courseId!: number; // The courseId the module belongs to.
|
@Input() courseId!: number; // The courseId the module belongs to.
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
import { Component, ElementRef, Input, OnDestroy, OnInit } from '@angular/core';
|
import { Component, ElementRef, Input, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { CoreCourse, CoreCourseProvider, CoreCourseWSSection } from '@features/course/services/course';
|
import { CoreCourse, CoreCourseProvider, CoreCourseWSSection } from '@features/course/services/course';
|
||||||
import { CoreCourseModule, CoreCourseSection } from '@features/course/services/course-helper';
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate';
|
import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate';
|
||||||
import { IonContent } from '@ionic/angular';
|
import { IonContent } from '@ionic/angular';
|
||||||
import { ScrollDetail } from '@ionic/core';
|
import { ScrollDetail } from '@ionic/core';
|
||||||
|
@ -41,10 +41,10 @@ export class CoreCourseModuleNavigationComponent implements OnInit, OnDestroy {
|
||||||
@Input() courseId!: number; // Course ID.
|
@Input() courseId!: number; // Course ID.
|
||||||
@Input() currentModuleId!: number; // Current module ID.
|
@Input() currentModuleId!: number; // Current module ID.
|
||||||
|
|
||||||
nextModule?: CoreCourseModule;
|
nextModule?: CoreCourseModuleData;
|
||||||
previousModule?: CoreCourseModule;
|
previousModule?: CoreCourseModuleData;
|
||||||
nextModuleSection?: CoreCourseSection;
|
nextModuleSection?: CoreCourseWSSection;
|
||||||
previousModuleSection?: CoreCourseSection;
|
previousModuleSection?: CoreCourseWSSection;
|
||||||
loaded = false;
|
loaded = false;
|
||||||
|
|
||||||
protected element: HTMLElement;
|
protected element: HTMLElement;
|
||||||
|
@ -184,7 +184,7 @@ export class CoreCourseModuleNavigationComponent implements OnInit, OnDestroy {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentModuleIndex = section.modules.findIndex((module: CoreCourseModule) => module.id == this.currentModuleId);
|
currentModuleIndex = section.modules.findIndex((module: CoreCourseModuleData) => module.id == this.currentModuleId);
|
||||||
|
|
||||||
return currentModuleIndex >= 0;
|
return currentModuleIndex >= 0;
|
||||||
});
|
});
|
||||||
|
@ -250,7 +250,7 @@ export class CoreCourseModuleNavigationComponent implements OnInit, OnDestroy {
|
||||||
* @param module Module to check.
|
* @param module Module to check.
|
||||||
* @return Wether the module is available to the user or not.
|
* @return Wether the module is available to the user or not.
|
||||||
*/
|
*/
|
||||||
protected async isModuleAvailable(module: CoreCourseModule): Promise<boolean> {
|
protected async isModuleAvailable(module: CoreCourseModuleData): Promise<boolean> {
|
||||||
return CoreCourse.instance.moduleHasView(module);
|
return CoreCourse.instance.moduleHasView(module);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
import {
|
import {
|
||||||
CoreCourseHelper,
|
CoreCourseHelper,
|
||||||
CoreCourseModule,
|
CoreCourseModuleData,
|
||||||
CoreCourseModuleCompletionData,
|
CoreCourseModuleCompletionData,
|
||||||
CoreCourseSection,
|
CoreCourseSection,
|
||||||
} from '@features/course/services/course-helper';
|
} from '@features/course/services/course-helper';
|
||||||
|
@ -44,7 +44,7 @@ import {
|
||||||
})
|
})
|
||||||
export class CoreCourseModuleComponent implements OnInit, OnDestroy {
|
export class CoreCourseModuleComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
@Input() module!: CoreCourseModule; // The module to render.
|
@Input() module!: CoreCourseModuleData; // The module to render.
|
||||||
@Input() courseId?: number; // The course the module belongs to.
|
@Input() courseId?: number; // The course the module belongs to.
|
||||||
@Input() section?: CoreCourseSection; // The section the module belongs to.
|
@Input() section?: CoreCourseSection; // The section the module belongs to.
|
||||||
@Input() showActivityDates = false; // Whether to show activity dates.
|
@Input() showActivityDates = false; // Whether to show activity dates.
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
|
|
||||||
import { Component, Input, OnInit } from '@angular/core';
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
|
|
||||||
import { CoreCourse, CoreCourseWSModule } from '@features/course/services/course';
|
import { CoreCourse } from '@features/course/services/course';
|
||||||
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate';
|
import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +28,7 @@ import { CoreCourseModuleDelegate } from '@features/course/services/module-deleg
|
||||||
export class CoreCourseUnsupportedModuleComponent implements OnInit {
|
export class CoreCourseUnsupportedModuleComponent implements OnInit {
|
||||||
|
|
||||||
@Input() courseId?: number; // The course to module belongs to.
|
@Input() courseId?: number; // The course to module belongs to.
|
||||||
@Input() module?: CoreCourseWSModule; // The module to render.
|
@Input() module?: CoreCourseModuleData; // The module to render.
|
||||||
|
|
||||||
isDisabledInSite?: boolean;
|
isDisabledInSite?: boolean;
|
||||||
isSupportedByTheApp?: boolean;
|
isSupportedByTheApp?: boolean;
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
import { Directive, Input, OnInit, ElementRef } from '@angular/core';
|
import { Directive, Input, OnInit, ElementRef } from '@angular/core';
|
||||||
|
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreCourse, CoreCourseModuleContentFile, CoreCourseWSModule } from '@features/course/services/course';
|
import { CoreCourse, CoreCourseModuleContentFile } from '@features/course/services/course';
|
||||||
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreUtilsOpenFileOptions } from '@services/utils/utils';
|
import { CoreUtilsOpenFileOptions } from '@services/utils/utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +31,7 @@ import { CoreUtilsOpenFileOptions } from '@services/utils/utils';
|
||||||
})
|
})
|
||||||
export class CoreCourseDownloadModuleMainFileDirective implements OnInit {
|
export class CoreCourseDownloadModuleMainFileDirective implements OnInit {
|
||||||
|
|
||||||
@Input() module?: CoreCourseWSModule; // The module.
|
@Input() module?: CoreCourseModuleData; // The module.
|
||||||
@Input() moduleId?: string | number; // The module ID. Required if module is not supplied.
|
@Input() moduleId?: string | number; // The module ID. Required if module is not supplied.
|
||||||
@Input() courseId?: string | number; // The course ID.
|
@Input() courseId?: string | number; // The course ID.
|
||||||
@Input() component?: string; // Component to link the file to.
|
@Input() component?: string; // Component to link the file to.
|
||||||
|
|
|
@ -20,8 +20,8 @@ import { CoreCourseFormatDelegate } from '../../services/format-delegate';
|
||||||
import { CoreCourseOptionsDelegate } from '../../services/course-options-delegate';
|
import { CoreCourseOptionsDelegate } from '../../services/course-options-delegate';
|
||||||
import { CoreCourseAnyCourseData } from '@features/courses/services/courses';
|
import { CoreCourseAnyCourseData } from '@features/courses/services/courses';
|
||||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
import { CoreCourse, CoreCourseWSModule } from '@features/course/services/course';
|
import { CoreCourse } from '@features/course/services/course';
|
||||||
import { CoreCourseHelper } 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 { CoreNavigator } from '@services/navigator';
|
||||||
|
@ -46,7 +46,7 @@ export class CoreCourseIndexPage implements OnInit, OnDestroy {
|
||||||
protected currentPagePath = '';
|
protected currentPagePath = '';
|
||||||
protected selectTabObserver: CoreEventObserver;
|
protected selectTabObserver: CoreEventObserver;
|
||||||
protected firstTabName?: string;
|
protected firstTabName?: string;
|
||||||
protected module?: CoreCourseWSModule;
|
protected module?: CoreCourseModuleData;
|
||||||
protected modParams?: Params;
|
protected modParams?: Params;
|
||||||
protected isGuest?: boolean;
|
protected isGuest?: boolean;
|
||||||
protected contentsTab: CoreTabsOutletTab = {
|
protected contentsTab: CoreTabsOutletTab = {
|
||||||
|
@ -90,7 +90,7 @@ export class CoreCourseIndexPage implements OnInit, OnDestroy {
|
||||||
// Get params.
|
// Get params.
|
||||||
this.course = CoreNavigator.getRouteParam('course');
|
this.course = CoreNavigator.getRouteParam('course');
|
||||||
this.firstTabName = CoreNavigator.getRouteParam('selectedTab');
|
this.firstTabName = CoreNavigator.getRouteParam('selectedTab');
|
||||||
this.module = CoreNavigator.getRouteParam<CoreCourseWSModule>('module');
|
this.module = CoreNavigator.getRouteParam<CoreCourseModuleData>('module');
|
||||||
this.modParams = CoreNavigator.getRouteParam<Params>('modParams');
|
this.modParams = CoreNavigator.getRouteParam<Params>('modParams');
|
||||||
this.isGuest = CoreNavigator.getRouteBooleanParam('isGuest');
|
this.isGuest = CoreNavigator.getRouteBooleanParam('isGuest');
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { CoreCourse } from '@features/course/services/course';
|
import { CoreCourse } from '@features/course/services/course';
|
||||||
import { CoreCourseHelper, CoreCourseModule, CoreCourseSection } from '@features/course/services/course-helper';
|
import { CoreCourseHelper, CoreCourseModuleData, CoreCourseSection } from '@features/course/services/course-helper';
|
||||||
import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate';
|
import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate';
|
||||||
import { IonRefresher } from '@ionic/angular';
|
import { IonRefresher } from '@ionic/angular';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
|
@ -31,7 +31,7 @@ import { CoreUtils } from '@services/utils/utils';
|
||||||
export class CoreCourseModulePreviewPage implements OnInit {
|
export class CoreCourseModulePreviewPage implements OnInit {
|
||||||
|
|
||||||
title!: string;
|
title!: string;
|
||||||
module!: CoreCourseModule;
|
module!: CoreCourseModuleData;
|
||||||
section?: CoreCourseSection; // The section the module belongs to.
|
section?: CoreCourseSection; // The section the module belongs to.
|
||||||
courseId!: number;
|
courseId!: number;
|
||||||
loaded = false;
|
loaded = false;
|
||||||
|
@ -45,7 +45,7 @@ export class CoreCourseModulePreviewPage implements OnInit {
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
this.module = CoreNavigator.getRequiredRouteParam<CoreCourseModule>('module');
|
this.module = CoreNavigator.getRequiredRouteParam<CoreCourseModuleData>('module');
|
||||||
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.section = CoreNavigator.getRouteParam<CoreCourseSection>('section');
|
this.section = CoreNavigator.getRouteParam<CoreCourseSection>('section');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -73,8 +73,6 @@ export class CoreCourseModulePreviewPage implements OnInit {
|
||||||
this.module = await CoreCourse.getModule(this.module.id, this.courseId);
|
this.module = await CoreCourse.getModule(this.module.id, this.courseId);
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreCourseHelper.calculateModuleCompletionData(this.module);
|
|
||||||
|
|
||||||
await CoreCourseHelper.loadModuleOfflineCompletion(this.courseId, this.module);
|
await CoreCourseHelper.loadModuleOfflineCompletion(this.courseId, this.module);
|
||||||
|
|
||||||
this.unsupported = !CoreCourseModuleDelegate.getHandlerName(this.module.modname);
|
this.unsupported = !CoreCourseModuleDelegate.getHandlerName(this.module.modname);
|
||||||
|
|
|
@ -22,11 +22,11 @@ import {
|
||||||
CoreCourseCompletionActivityStatus,
|
CoreCourseCompletionActivityStatus,
|
||||||
CoreCourseModuleWSCompletionData,
|
CoreCourseModuleWSCompletionData,
|
||||||
CoreCourseModuleContentFile,
|
CoreCourseModuleContentFile,
|
||||||
CoreCourseWSModule,
|
|
||||||
CoreCourseProvider,
|
CoreCourseProvider,
|
||||||
CoreCourseWSSection,
|
CoreCourseWSSection,
|
||||||
CoreCourseModuleCompletionTracking,
|
CoreCourseModuleCompletionTracking,
|
||||||
CoreCourseModuleCompletionStatus,
|
CoreCourseModuleCompletionStatus,
|
||||||
|
CoreCourseGetContentsWSModule,
|
||||||
} from './course';
|
} from './course';
|
||||||
import { CoreConstants } from '@/core/constants';
|
import { CoreConstants } from '@/core/constants';
|
||||||
import { CoreLogger } from '@singletons/logger';
|
import { CoreLogger } from '@singletons/logger';
|
||||||
|
@ -176,18 +176,16 @@ export class CoreCourseHelperProvider {
|
||||||
forCoursePage = false,
|
forCoursePage = false,
|
||||||
): { hasContent: boolean; sections: CoreCourseSection[] } {
|
): { hasContent: boolean; sections: CoreCourseSection[] } {
|
||||||
|
|
||||||
const formattedSections: CoreCourseSection[] = sections;
|
|
||||||
let hasContent = false;
|
let hasContent = false;
|
||||||
|
|
||||||
formattedSections.forEach((section) => {
|
const formattedSections = sections.map<CoreCourseSection>((courseSection) => {
|
||||||
if (!section || !section.modules) {
|
const section = {
|
||||||
return;
|
...courseSection,
|
||||||
}
|
hasContent: this.sectionHasContent(courseSection),
|
||||||
|
};
|
||||||
section.hasContent = this.sectionHasContent(section);
|
|
||||||
|
|
||||||
if (!section.hasContent) {
|
if (!section.hasContent) {
|
||||||
return;
|
return section;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasContent = true;
|
hasContent = true;
|
||||||
|
@ -201,9 +199,7 @@ export class CoreCourseHelperProvider {
|
||||||
forCoursePage,
|
forCoursePage,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (module.completiondata) {
|
if (!module.completiondata && completionStatus && completionStatus[module.id] !== undefined) {
|
||||||
this.calculateModuleCompletionData(module, undefined, courseName);
|
|
||||||
} else if (completionStatus && completionStatus[module.id] !== undefined) {
|
|
||||||
// Should not happen on > 3.6. Check if activity has completions and if it's marked.
|
// Should not happen on > 3.6. Check if activity has completions and if it's marked.
|
||||||
const activityStatus = completionStatus[module.id];
|
const activityStatus = completionStatus[module.id];
|
||||||
|
|
||||||
|
@ -222,6 +218,8 @@ export class CoreCourseHelperProvider {
|
||||||
// Check if the module is stealth.
|
// Check if the module is stealth.
|
||||||
module.isStealth = module.visibleoncoursepage === 0 || (!!module.visible && !section.visible);
|
module.isStealth = module.visibleoncoursepage === 0 || (!!module.visible && !section.visible);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return section;
|
||||||
});
|
});
|
||||||
|
|
||||||
return { hasContent, sections: formattedSections };
|
return { hasContent, sections: formattedSections };
|
||||||
|
@ -230,11 +228,10 @@ export class CoreCourseHelperProvider {
|
||||||
/**
|
/**
|
||||||
* Calculate completion data of a module.
|
* Calculate completion data of a module.
|
||||||
*
|
*
|
||||||
|
* @deprecated since 4.0.
|
||||||
* @param module Module.
|
* @param module Module.
|
||||||
* @param courseId Not used since 4.0
|
|
||||||
* @param courseName Course name.
|
|
||||||
*/
|
*/
|
||||||
calculateModuleCompletionData(module: CoreCourseModule, courseId?: number, courseName?: string): void {
|
calculateModuleCompletionData(module: CoreCourseModuleData): void {
|
||||||
if (!module.completiondata || !module.completion) {
|
if (!module.completiondata || !module.completion) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +239,6 @@ export class CoreCourseHelperProvider {
|
||||||
module.completiondata.courseId = module.course;
|
module.completiondata.courseId = module.course;
|
||||||
module.completiondata.tracking = module.completion;
|
module.completiondata.tracking = module.completion;
|
||||||
module.completiondata.cmid = module.id;
|
module.completiondata.cmid = module.id;
|
||||||
module.completiondata.courseName = courseName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -497,7 +493,7 @@ export class CoreCourseHelperProvider {
|
||||||
* @param done Function to call when done. It will close the context menu.
|
* @param done Function to call when done. It will close the context menu.
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
async confirmAndRemoveFiles(module: CoreCourseWSModule, courseId: number, done?: () => void): Promise<void> {
|
async confirmAndRemoveFiles(module: CoreCourseModuleData, courseId: number, done?: () => void): Promise<void> {
|
||||||
let modal: CoreIonLoadingElement | undefined;
|
let modal: CoreIonLoadingElement | undefined;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -586,7 +582,7 @@ export class CoreCourseHelperProvider {
|
||||||
*/
|
*/
|
||||||
async contextMenuPrefetch(
|
async contextMenuPrefetch(
|
||||||
instance: ComponentWithContextMenu,
|
instance: ComponentWithContextMenu,
|
||||||
module: CoreCourseWSModule,
|
module: CoreCourseModuleData,
|
||||||
courseId: number,
|
courseId: number,
|
||||||
done?: () => void,
|
done?: () => void,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
@ -718,7 +714,7 @@ export class CoreCourseHelperProvider {
|
||||||
* @return Resolved on success.
|
* @return Resolved on success.
|
||||||
*/
|
*/
|
||||||
async downloadModuleAndOpenFile(
|
async downloadModuleAndOpenFile(
|
||||||
module: CoreCourseWSModule,
|
module: CoreCourseModuleData,
|
||||||
courseId: number,
|
courseId: number,
|
||||||
component?: string,
|
component?: string,
|
||||||
componentId?: string | number,
|
componentId?: string | number,
|
||||||
|
@ -810,7 +806,7 @@ export class CoreCourseHelperProvider {
|
||||||
protected async openModuleFileInBrowser(
|
protected async openModuleFileInBrowser(
|
||||||
fileUrl: string,
|
fileUrl: string,
|
||||||
site: CoreSite,
|
site: CoreSite,
|
||||||
module: CoreCourseWSModule,
|
module: CoreCourseModuleData,
|
||||||
courseId: number,
|
courseId: number,
|
||||||
component?: string,
|
component?: string,
|
||||||
componentId?: string | number,
|
componentId?: string | number,
|
||||||
|
@ -861,7 +857,7 @@ export class CoreCourseHelperProvider {
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
async downloadModuleWithMainFileIfNeeded(
|
async downloadModuleWithMainFileIfNeeded(
|
||||||
module: CoreCourseWSModule,
|
module: CoreCourseModuleData,
|
||||||
courseId: number,
|
courseId: number,
|
||||||
component: string,
|
component: string,
|
||||||
componentId?: string | number,
|
componentId?: string | number,
|
||||||
|
@ -944,7 +940,7 @@ export class CoreCourseHelperProvider {
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
protected async downloadModuleWithMainFile(
|
protected async downloadModuleWithMainFile(
|
||||||
module: CoreCourseWSModule,
|
module: CoreCourseModuleData,
|
||||||
courseId: number,
|
courseId: number,
|
||||||
fixedUrl: string,
|
fixedUrl: string,
|
||||||
files: CoreCourseModuleContentFile[],
|
files: CoreCourseModuleContentFile[],
|
||||||
|
@ -1009,7 +1005,7 @@ export class CoreCourseHelperProvider {
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
async downloadModule(
|
async downloadModule(
|
||||||
module: CoreCourseWSModule,
|
module: CoreCourseModuleData,
|
||||||
courseId: number,
|
courseId: number,
|
||||||
component?: string,
|
component?: string,
|
||||||
componentId?: string | number,
|
componentId?: string | number,
|
||||||
|
@ -1047,7 +1043,7 @@ export class CoreCourseHelperProvider {
|
||||||
*/
|
*/
|
||||||
async fillContextMenu(
|
async fillContextMenu(
|
||||||
instance: ComponentWithContextMenu,
|
instance: ComponentWithContextMenu,
|
||||||
module: CoreCourseWSModule,
|
module: CoreCourseModuleData,
|
||||||
courseId: number,
|
courseId: number,
|
||||||
invalidateCache?: boolean,
|
invalidateCache?: boolean,
|
||||||
component?: string,
|
component?: string,
|
||||||
|
@ -1230,7 +1226,7 @@ export class CoreCourseHelperProvider {
|
||||||
* @param siteId Site ID. If not defined, current site.
|
* @param siteId Site ID. If not defined, current site.
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
async loadOfflineCompletion(courseId: number, sections: CoreCourseSection[], siteId?: string): Promise<void> {
|
async loadOfflineCompletion(courseId: number, sections: CoreCourseWSSection[], siteId?: string): Promise<void> {
|
||||||
const offlineCompletions = await CoreCourseOffline.getCourseManualCompletions(courseId, siteId);
|
const offlineCompletions = await CoreCourseOffline.getCourseManualCompletions(courseId, siteId);
|
||||||
|
|
||||||
if (!offlineCompletions || !offlineCompletions.length) {
|
if (!offlineCompletions || !offlineCompletions.length) {
|
||||||
|
@ -1278,7 +1274,7 @@ export class CoreCourseHelperProvider {
|
||||||
* @param siteId Site ID. If not defined, current site.
|
* @param siteId Site ID. If not defined, current site.
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
async loadModuleOfflineCompletion(courseId: number, module: CoreCourseModule, siteId?: string): Promise<void> {
|
async loadModuleOfflineCompletion(courseId: number, module: CoreCourseModuleData, siteId?: string): Promise<void> {
|
||||||
if (!module.completiondata) {
|
if (!module.completiondata) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1464,7 +1460,7 @@ export class CoreCourseHelperProvider {
|
||||||
* @return Promise resolved with the info.
|
* @return Promise resolved with the info.
|
||||||
*/
|
*/
|
||||||
async getModulePrefetchInfo(
|
async getModulePrefetchInfo(
|
||||||
module: CoreCourseWSModule,
|
module: CoreCourseModuleData,
|
||||||
courseId: number,
|
courseId: number,
|
||||||
invalidateCache?: boolean,
|
invalidateCache?: boolean,
|
||||||
component?: string,
|
component?: string,
|
||||||
|
@ -1634,7 +1630,7 @@ export class CoreCourseHelperProvider {
|
||||||
const site = await CoreSites.getSite(siteId);
|
const site = await CoreSites.getSite(siteId);
|
||||||
|
|
||||||
// Get the module.
|
// Get the module.
|
||||||
const module = <CoreCourseModule>
|
const module = <CoreCourseModuleData>
|
||||||
await CoreCourse.getModule(moduleId, courseId, sectionId, false, false, siteId, modName);
|
await CoreCourse.getModule(moduleId, courseId, sectionId, false, false, siteId, modName);
|
||||||
|
|
||||||
if (CoreSites.getCurrentSiteId() == site.getId()) {
|
if (CoreSites.getCurrentSiteId() == site.getId()) {
|
||||||
|
@ -1693,7 +1689,7 @@ export class CoreCourseHelperProvider {
|
||||||
* @param modParams Params to pass to the module
|
* @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: CoreCourseModule, courseId: number, sectionId?: number, modParams?: Params): Promise<boolean> {
|
async openModule(module: CoreCourseModuleData, courseId: number, sectionId?: number, modParams?: Params): Promise<boolean> {
|
||||||
if (!module.handlerData) {
|
if (!module.handlerData) {
|
||||||
module.handlerData = await CoreCourseModuleDelegate.getModuleDataFor(
|
module.handlerData = await CoreCourseModuleDelegate.getModuleDataFor(
|
||||||
module.modname,
|
module.modname,
|
||||||
|
@ -1749,7 +1745,7 @@ export class CoreCourseHelperProvider {
|
||||||
const promises: Promise<unknown>[] = [];
|
const promises: Promise<unknown>[] = [];
|
||||||
|
|
||||||
// Prefetch all the sections. If the first section is "All sections", use it. Otherwise, use a fake "All sections".
|
// Prefetch all the sections. If the first section is "All sections", use it. Otherwise, use a fake "All sections".
|
||||||
let allSectionsSection: CoreCourseSection = sections[0];
|
let allSectionsSection: CoreCourseWSSection = sections[0];
|
||||||
if (sections[0].id != CoreCourseProvider.ALL_SECTIONS_ID) {
|
if (sections[0].id != CoreCourseProvider.ALL_SECTIONS_ID) {
|
||||||
allSectionsSection = this.createAllSectionsSection();
|
allSectionsSection = this.createAllSectionsSection();
|
||||||
}
|
}
|
||||||
|
@ -1806,7 +1802,7 @@ export class CoreCourseHelperProvider {
|
||||||
*/
|
*/
|
||||||
async prefetchModule(
|
async prefetchModule(
|
||||||
handler: CoreCourseModulePrefetchHandler,
|
handler: CoreCourseModulePrefetchHandler,
|
||||||
module: CoreCourseWSModule,
|
module: CoreCourseModuleData,
|
||||||
size: CoreFileSizeSum,
|
size: CoreFileSizeSum,
|
||||||
courseId: number,
|
courseId: number,
|
||||||
refresh?: boolean,
|
refresh?: boolean,
|
||||||
|
@ -1984,6 +1980,10 @@ export class CoreCourseHelperProvider {
|
||||||
* @return Whether the section has content.
|
* @return Whether the section has content.
|
||||||
*/
|
*/
|
||||||
sectionHasContent(section: CoreCourseWSSection): boolean {
|
sectionHasContent(section: CoreCourseWSSection): boolean {
|
||||||
|
if (!section.modules) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (section.hiddenbynumsections) {
|
if (section.hiddenbynumsections) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2042,7 +2042,7 @@ export class CoreCourseHelperProvider {
|
||||||
* @param courseId Course ID the module belongs to.
|
* @param courseId Course ID the module belongs to.
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
async removeModuleStoredData(module: CoreCourseWSModule, courseId: number): Promise<void> {
|
async removeModuleStoredData(module: CoreCourseModuleData, courseId: number): Promise<void> {
|
||||||
const promises: Promise<void>[] = [];
|
const promises: Promise<void>[] = [];
|
||||||
|
|
||||||
promises.push(CoreCourseModulePrefetchDelegate.removeModuleFiles(module, courseId));
|
promises.push(CoreCourseModulePrefetchDelegate.removeModuleFiles(module, courseId));
|
||||||
|
@ -2088,7 +2088,7 @@ export class CoreCourseHelperProvider {
|
||||||
const response = await CoreCourse.markCompletedManually(
|
const response = await CoreCourse.markCompletedManually(
|
||||||
completion.cmid,
|
completion.cmid,
|
||||||
completion.state === CoreCourseModuleCompletionStatus.COMPLETION_COMPLETE,
|
completion.state === CoreCourseModuleCompletionStatus.COMPLETION_COMPLETE,
|
||||||
completion.courseId!,
|
completion.courseId,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.offline) {
|
if (response.offline) {
|
||||||
|
@ -2115,9 +2115,8 @@ export const CoreCourseHelper = makeSingleton(CoreCourseHelperProvider);
|
||||||
/**
|
/**
|
||||||
* Section with calculated data.
|
* Section with calculated data.
|
||||||
*/
|
*/
|
||||||
export type CoreCourseSection = Omit<CoreCourseWSSection, 'modules'> & {
|
export type CoreCourseSection = CoreCourseWSSection & {
|
||||||
hasContent?: boolean;
|
hasContent?: boolean;
|
||||||
modules: CoreCourseModule[];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2135,20 +2134,27 @@ export type CoreCourseSectionWithStatus = CoreCourseSection & {
|
||||||
/**
|
/**
|
||||||
* Module with calculated data.
|
* Module with calculated data.
|
||||||
*/
|
*/
|
||||||
export type CoreCourseModule = Omit<CoreCourseWSModule, 'completiondata'> & {
|
export type CoreCourseModuleData = Omit<CoreCourseGetContentsWSModule, 'completiondata'> & {
|
||||||
|
course: number; // The course id.
|
||||||
isStealth?: boolean;
|
isStealth?: boolean;
|
||||||
handlerData?: CoreCourseModuleHandlerData;
|
handlerData?: CoreCourseModuleHandlerData;
|
||||||
completiondata?: CoreCourseModuleCompletionData;
|
completiondata?: CoreCourseModuleCompletionData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module with calculated data.
|
||||||
|
*
|
||||||
|
* @deprecated since 4.0. Use CoreCourseModuleData instead.
|
||||||
|
*/
|
||||||
|
export type CoreCourseModule = CoreCourseModuleData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module completion with calculated data.
|
* Module completion with calculated data.
|
||||||
*/
|
*/
|
||||||
export type CoreCourseModuleCompletionData = CoreCourseModuleWSCompletionData & {
|
export type CoreCourseModuleCompletionData = CoreCourseModuleWSCompletionData & {
|
||||||
courseId?: number;
|
courseId: number;
|
||||||
courseName?: string;
|
tracking: CoreCourseModuleCompletionTracking;
|
||||||
tracking?: CoreCourseModuleCompletionTracking;
|
cmid: number;
|
||||||
cmid?: number;
|
|
||||||
offline?: boolean;
|
offline?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ import {
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreWSError } from '@classes/errors/wserror';
|
import { CoreWSError } from '@classes/errors/wserror';
|
||||||
import { CorePushNotifications } from '@features/pushnotifications/services/pushnotifications';
|
import { CorePushNotifications } from '@features/pushnotifications/services/pushnotifications';
|
||||||
import { CoreCourseHelper, CoreCourseModuleCompletionData } from './course-helper';
|
import { CoreCourseHelper, CoreCourseModuleData, CoreCourseModuleCompletionData } from './course-helper';
|
||||||
import { CoreCourseFormatDelegate } from './format-delegate';
|
import { CoreCourseFormatDelegate } from './format-delegate';
|
||||||
import { CoreCronDelegate } from '@services/cron';
|
import { CoreCronDelegate } from '@services/cron';
|
||||||
import { CoreCourseLogCronHandler } from './handlers/log-cron';
|
import { CoreCourseLogCronHandler } from './handlers/log-cron';
|
||||||
|
@ -431,7 +431,7 @@ export class CoreCourseProvider {
|
||||||
ignoreCache: boolean = false,
|
ignoreCache: boolean = false,
|
||||||
siteId?: string,
|
siteId?: string,
|
||||||
modName?: string,
|
modName?: string,
|
||||||
): Promise<CoreCourseWSModule> {
|
): Promise<CoreCourseModuleData> {
|
||||||
siteId = siteId || CoreSites.getCurrentSiteId();
|
siteId = siteId || CoreSites.getCurrentSiteId();
|
||||||
|
|
||||||
// Helper function to do the WS request without processing the result.
|
// Helper function to do the WS request without processing the result.
|
||||||
|
@ -544,15 +544,43 @@ export class CoreCourseProvider {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (foundSection && foundModule) {
|
if (foundSection && foundModule) {
|
||||||
return {
|
return this.addAdditionalModuleData(foundModule, courseId);
|
||||||
...foundModule,
|
|
||||||
course: courseId,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new CoreError(Translate.instant('core.course.modulenotfound'));
|
throw new CoreError(Translate.instant('core.course.modulenotfound'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add some additional info to course module.
|
||||||
|
*
|
||||||
|
* @param module Module.
|
||||||
|
* @param courseId Course ID of the module.
|
||||||
|
* @return Module with additional info.
|
||||||
|
*/
|
||||||
|
protected addAdditionalModuleData(
|
||||||
|
module: CoreCourseGetContentsWSModule,
|
||||||
|
courseId: number,
|
||||||
|
): CoreCourseModuleData {
|
||||||
|
let completionData: CoreCourseModuleCompletionData | undefined = undefined;
|
||||||
|
|
||||||
|
if (module.completiondata && module.completion) {
|
||||||
|
completionData = {
|
||||||
|
...module.completiondata,
|
||||||
|
tracking: module.completion,
|
||||||
|
cmid: module.id,
|
||||||
|
courseId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const moduleWithCourse: CoreCourseModuleData = {
|
||||||
|
...module,
|
||||||
|
course: courseId,
|
||||||
|
completiondata: completionData,
|
||||||
|
};
|
||||||
|
|
||||||
|
return moduleWithCourse;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a module basic info by module ID.
|
* Gets a module basic info by module ID.
|
||||||
*
|
*
|
||||||
|
@ -808,10 +836,7 @@ export class CoreCourseProvider {
|
||||||
// Add course to all modules.
|
// Add course to all modules.
|
||||||
return sections.map((section) => ({
|
return sections.map((section) => ({
|
||||||
...section,
|
...section,
|
||||||
modules: section.modules.map((module) => ({
|
modules: section.modules.map((module) => this.addAdditionalModuleData(module, courseId)),
|
||||||
...module,
|
|
||||||
course: courseId,
|
|
||||||
})),
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -831,12 +856,12 @@ export class CoreCourseProvider {
|
||||||
* @param sections Sections.
|
* @param sections Sections.
|
||||||
* @return Modules.
|
* @return Modules.
|
||||||
*/
|
*/
|
||||||
getSectionsModules(sections: CoreCourseWSSection[]): CoreCourseWSModule[] {
|
getSectionsModules(sections: CoreCourseWSSection[]): CoreCourseModuleData[] {
|
||||||
if (!sections || !sections.length) {
|
if (!sections || !sections.length) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return sections.reduce((previous: CoreCourseWSModule[], section) => previous.concat(section.modules || []), []);
|
return sections.reduce((previous: CoreCourseModuleData[], section) => previous.concat(section.modules || []), []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1103,7 +1128,7 @@ export class CoreCourseProvider {
|
||||||
* @param module The module object.
|
* @param module The module object.
|
||||||
* @return Whether the module has a view page.
|
* @return Whether the module has a view page.
|
||||||
*/
|
*/
|
||||||
moduleHasView(module: CoreCourseModuleSummary | CoreCourseWSModule): boolean {
|
moduleHasView(module: CoreCourseModuleSummary | CoreCourseModuleData): boolean {
|
||||||
if ('modname' in module) {
|
if ('modname' in module) {
|
||||||
// noviewlink was introduced in 3.8.5, use supports feature as a fallback.
|
// noviewlink was introduced in 3.8.5, use supports feature as a fallback.
|
||||||
if (module.noviewlink ||
|
if (module.noviewlink ||
|
||||||
|
@ -1503,7 +1528,7 @@ type CoreCourseGetContentsWSSection = {
|
||||||
/**
|
/**
|
||||||
* Module data returned by core_course_get_contents WS.
|
* Module data returned by core_course_get_contents WS.
|
||||||
*/
|
*/
|
||||||
type CoreCourseGetContentsWSModule = {
|
export type CoreCourseGetContentsWSModule = {
|
||||||
id: number; // Activity id.
|
id: number; // Activity id.
|
||||||
url?: string; // Activity url.
|
url?: string; // Activity url.
|
||||||
name: string; // Activity module name.
|
name: string; // Activity module name.
|
||||||
|
@ -1544,7 +1569,7 @@ type CoreCourseGetContentsWSModule = {
|
||||||
* Data returned by core_course_get_contents WS.
|
* Data returned by core_course_get_contents WS.
|
||||||
*/
|
*/
|
||||||
export type CoreCourseWSSection = Omit<CoreCourseGetContentsWSSection, 'modules'> & {
|
export type CoreCourseWSSection = Omit<CoreCourseGetContentsWSSection, 'modules'> & {
|
||||||
modules: CoreCourseWSModule[]; // List of module.
|
modules: CoreCourseModuleData[]; // List of module.
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1572,6 +1597,8 @@ type CoreCourseGetCourseModuleWSResponse = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Course module data returned by the WS with course added.
|
* Course module data returned by the WS with course added.
|
||||||
|
*
|
||||||
|
* @deprecated since 4.0. Use CoreCourseModuleData instead.
|
||||||
*/
|
*/
|
||||||
export type CoreCourseWSModule = CoreCourseGetContentsWSModule & {
|
export type CoreCourseWSModule = CoreCourseGetContentsWSModule & {
|
||||||
course: number; // The course id.
|
course: number; // The course id.
|
||||||
|
@ -1703,6 +1730,6 @@ type CoreCompletionUpdateActivityCompletionStatusManuallyWSParams = {
|
||||||
/**
|
/**
|
||||||
* Any of the possible module WS data.
|
* Any of the possible module WS data.
|
||||||
*/
|
*/
|
||||||
export type CoreCourseAnyModuleData = CoreCourseWSModule | CoreCourseModuleBasicInfo & {
|
export type CoreCourseAnyModuleData = CoreCourseModuleData | CoreCourseModuleBasicInfo & {
|
||||||
contents?: CoreCourseModuleContentFile[]; // If needed, calculated in the app in loadModuleContents.
|
contents?: CoreCourseModuleContentFile[]; // If needed, calculated in the app in loadModuleContents.
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { Injectable, Type } from '@angular/core';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '../module-delegate';
|
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '../module-delegate';
|
||||||
import { CoreCourse } from '../course';
|
import { CoreCourse } from '../course';
|
||||||
import { CoreCourseModule } from '../course-helper';
|
import { CoreCourseModuleData } from '../course-helper';
|
||||||
import { CoreCourseUnsupportedModuleComponent } from '@features/course/components/unsupported-module/unsupported-module';
|
import { CoreCourseUnsupportedModuleComponent } from '@features/course/components/unsupported-module/unsupported-module';
|
||||||
import { CoreNavigationOptions, CoreNavigator } from '@services/navigator';
|
import { CoreNavigationOptions, CoreNavigator } from '@services/navigator';
|
||||||
|
|
||||||
|
@ -42,14 +42,14 @@ export class CoreCourseModuleDefaultHandler implements CoreCourseModuleHandler {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async getData(
|
async getData(
|
||||||
module: CoreCourseModule,
|
module: CoreCourseModuleData,
|
||||||
): Promise<CoreCourseModuleHandlerData> {
|
): Promise<CoreCourseModuleHandlerData> {
|
||||||
// Return the default data.
|
// Return the default data.
|
||||||
const defaultData: CoreCourseModuleHandlerData = {
|
const defaultData: CoreCourseModuleHandlerData = {
|
||||||
icon: await CoreCourse.getModuleIconSrc(module.modname, module.modicon),
|
icon: await CoreCourse.getModuleIconSrc(module.modname, module.modicon),
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'core-course-default-handler core-course-module-' + module.modname + '-handler',
|
class: 'core-course-default-handler core-course-module-' + module.modname + '-handler',
|
||||||
action: async (event: Event, module: CoreCourseModule, courseId: number, options?: CoreNavigationOptions) => {
|
action: async (event: Event, module: CoreCourseModuleData, courseId: number, options?: CoreNavigationOptions) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ export class CoreCourseModuleDefaultHandler implements CoreCourseModuleHandler {
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async openActivityPage(module: CoreCourseModule, courseId: number, options?: CoreNavigationOptions): Promise<void> {
|
async openActivityPage(module: CoreCourseModuleData, courseId: number, options?: CoreNavigationOptions): Promise<void> {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
options.params = options.params || {};
|
options.params = options.params || {};
|
||||||
Object.assign(options.params, { module });
|
Object.assign(options.params, { module });
|
||||||
|
|
|
@ -20,10 +20,10 @@ import { CoreSite } from '@classes/site';
|
||||||
import { CoreCourseModuleDefaultHandler } from './handlers/default-module';
|
import { CoreCourseModuleDefaultHandler } from './handlers/default-module';
|
||||||
import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
|
import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
|
||||||
import { CoreCourseAnyCourseData } from '@features/courses/services/courses';
|
import { CoreCourseAnyCourseData } from '@features/courses/services/courses';
|
||||||
import { CoreCourse, CoreCourseWSModule } from './course';
|
import { CoreCourse } from './course';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { CoreCourseModule } from './course-helper';
|
import { CoreCourseModuleData } from './course-helper';
|
||||||
import { CoreNavigationOptions } from '@services/navigator';
|
import { CoreNavigationOptions } from '@services/navigator';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +52,7 @@ export interface CoreCourseModuleHandler extends CoreDelegateHandler {
|
||||||
* @return Data to render the module.
|
* @return Data to render the module.
|
||||||
*/
|
*/
|
||||||
getData(
|
getData(
|
||||||
module: CoreCourseModule,
|
module: CoreCourseModuleData,
|
||||||
courseId: number,
|
courseId: number,
|
||||||
sectionId?: number,
|
sectionId?: number,
|
||||||
forCoursePage?: boolean,
|
forCoursePage?: boolean,
|
||||||
|
@ -67,7 +67,7 @@ export interface CoreCourseModuleHandler extends CoreDelegateHandler {
|
||||||
* @param module The module object.
|
* @param module The module object.
|
||||||
* @return Promise resolved with component to use, undefined if not found.
|
* @return Promise resolved with component to use, undefined if not found.
|
||||||
*/
|
*/
|
||||||
getMainComponent(course: CoreCourseAnyCourseData, module: CoreCourseWSModule): Promise<Type<unknown> | undefined>;
|
getMainComponent(course: CoreCourseAnyCourseData, module: CoreCourseModuleData): Promise<Type<unknown> | undefined>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to display the course refresher in single activity course format. If it returns false, a refresher must be
|
* Whether to display the course refresher in single activity course format. If it returns false, a refresher must be
|
||||||
|
@ -83,7 +83,7 @@ export interface CoreCourseModuleHandler extends CoreDelegateHandler {
|
||||||
* @param module: Module to get the icon from.
|
* @param module: Module to get the icon from.
|
||||||
* @return The icon src.
|
* @return The icon src.
|
||||||
*/
|
*/
|
||||||
getIconSrc?(module?: CoreCourseWSModule): Promise<string | undefined> | string | undefined;
|
getIconSrc?(module?: CoreCourseModuleData): Promise<string | undefined> | string | undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this type of module supports a certain feature.
|
* Check if this type of module supports a certain feature.
|
||||||
|
@ -101,7 +101,7 @@ export interface CoreCourseModuleHandler extends CoreDelegateHandler {
|
||||||
* @param module Module.
|
* @param module Module.
|
||||||
* @return Promise resolved with boolean: whether the manual completion should always be displayed.
|
* @return Promise resolved with boolean: whether the manual completion should always be displayed.
|
||||||
*/
|
*/
|
||||||
manualCompletionAlwaysShown?(module: CoreCourseModule): Promise<boolean>;
|
manualCompletionAlwaysShown?(module: CoreCourseModuleData): Promise<boolean>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens the activity page.
|
* Opens the activity page.
|
||||||
|
@ -111,7 +111,7 @@ export interface CoreCourseModuleHandler extends CoreDelegateHandler {
|
||||||
* @param options Options for the navigation.
|
* @param options Options for the navigation.
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
openActivityPage(module: CoreCourseModule, courseId: number, options?: CoreNavigationOptions): Promise<void>;
|
openActivityPage(module: CoreCourseModuleData, courseId: number, options?: CoreNavigationOptions): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -179,7 +179,7 @@ export interface CoreCourseModuleHandlerData {
|
||||||
* @param options Options for the navigation.
|
* @param options Options for the navigation.
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
action?(event: Event, module: CoreCourseModule, courseId: number, options?: CoreNavigationOptions): Promise<void> | void;
|
action?(event: Event, module: CoreCourseModuleData, courseId: number, options?: CoreNavigationOptions): Promise<void> | void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the status of the module.
|
* Updates the status of the module.
|
||||||
|
@ -250,7 +250,7 @@ export interface CoreCourseModuleHandlerButton {
|
||||||
* @param options Options for the navigation.
|
* @param options Options for the navigation.
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
action(event: Event, module: CoreCourseModule, courseId: number, options?: CoreNavigationOptions): Promise<void> | void;
|
action(event: Event, module: CoreCourseModuleData, courseId: number, options?: CoreNavigationOptions): Promise<void> | void;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -273,7 +273,7 @@ export class CoreCourseModuleDelegateService extends CoreDelegate<CoreCourseModu
|
||||||
* @param module The module object.
|
* @param module The module object.
|
||||||
* @return Promise resolved with component to use, undefined if not found.
|
* @return Promise resolved with component to use, undefined if not found.
|
||||||
*/
|
*/
|
||||||
async getMainComponent(course: CoreCourseAnyCourseData, module: CoreCourseWSModule): Promise<Type<unknown> | undefined> {
|
async getMainComponent(course: CoreCourseAnyCourseData, module: CoreCourseModuleData): Promise<Type<unknown> | undefined> {
|
||||||
try {
|
try {
|
||||||
return await this.executeFunctionOnEnabled<Type<unknown>>(module.modname, 'getMainComponent', [course, module]);
|
return await this.executeFunctionOnEnabled<Type<unknown>>(module.modname, 'getMainComponent', [course, module]);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -293,7 +293,7 @@ export class CoreCourseModuleDelegateService extends CoreDelegate<CoreCourseModu
|
||||||
*/
|
*/
|
||||||
async getModuleDataFor(
|
async getModuleDataFor(
|
||||||
modname: string,
|
modname: string,
|
||||||
module: CoreCourseModule,
|
module: CoreCourseModuleData,
|
||||||
courseId: number,
|
courseId: number,
|
||||||
sectionId?: number,
|
sectionId?: number,
|
||||||
forCoursePage?: boolean,
|
forCoursePage?: boolean,
|
||||||
|
@ -315,7 +315,7 @@ export class CoreCourseModuleDelegateService extends CoreDelegate<CoreCourseModu
|
||||||
*/
|
*/
|
||||||
async openActivityPage(
|
async openActivityPage(
|
||||||
modname: string,
|
modname: string,
|
||||||
module: CoreCourseModule,
|
module: CoreCourseModuleData,
|
||||||
courseId: number,
|
courseId: number,
|
||||||
options?: CoreNavigationOptions,
|
options?: CoreNavigationOptions,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
@ -381,7 +381,7 @@ export class CoreCourseModuleDelegateService extends CoreDelegate<CoreCourseModu
|
||||||
* @param module The module to use.
|
* @param module The module to use.
|
||||||
* @return Promise resolved with the icon src.
|
* @return Promise resolved with the icon src.
|
||||||
*/
|
*/
|
||||||
async getModuleIconSrc(modname: string, modicon?: string, module?: CoreCourseWSModule): Promise<string> {
|
async getModuleIconSrc(modname: string, modicon?: string, module?: CoreCourseModuleData): Promise<string> {
|
||||||
const icon = await this.executeFunctionOnEnabled<Promise<string>>(modname, 'getIconSrc', [module]);
|
const icon = await this.executeFunctionOnEnabled<Promise<string>>(modname, 'getIconSrc', [module]);
|
||||||
|
|
||||||
return icon || await CoreCourse.getModuleIconSrc(modname, modicon) || '';
|
return icon || await CoreCourse.getModuleIconSrc(modname, modicon) || '';
|
||||||
|
@ -419,7 +419,7 @@ export class CoreCourseModuleDelegateService extends CoreDelegate<CoreCourseModu
|
||||||
* @param module Module.
|
* @param module Module.
|
||||||
* @return Promise resolved with boolean: whether the manual completion should always be displayed.
|
* @return Promise resolved with boolean: whether the manual completion should always be displayed.
|
||||||
*/
|
*/
|
||||||
async manualCompletionAlwaysShown(module: CoreCourseModule): Promise<boolean> {
|
async manualCompletionAlwaysShown(module: CoreCourseModuleData): Promise<boolean> {
|
||||||
const result = await this.executeFunctionOnEnabled<boolean>(module.modname, 'manualCompletionAlwaysShown', [module]);
|
const result = await this.executeFunctionOnEnabled<boolean>(module.modname, 'manualCompletionAlwaysShown', [module]);
|
||||||
|
|
||||||
return !!result;
|
return !!result;
|
||||||
|
|
|
@ -22,7 +22,7 @@ import { CoreFilepool } from '@services/filepool';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseModuleContentFile, CoreCourseWSModule } from './course';
|
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseModuleContentFile } from './course';
|
||||||
import { CoreCache } from '@classes/cache';
|
import { CoreCache } from '@classes/cache';
|
||||||
import { CoreSiteWSPreSets } from '@classes/site';
|
import { CoreSiteWSPreSets } from '@classes/site';
|
||||||
import { CoreConstants } from '@/core/constants';
|
import { CoreConstants } from '@/core/constants';
|
||||||
|
@ -33,6 +33,7 @@ import { CoreError } from '@classes/errors/error';
|
||||||
import { CoreWSFile, CoreWSExternalWarning } from '@services/ws';
|
import { CoreWSFile, CoreWSExternalWarning } from '@services/ws';
|
||||||
import { CHECK_UPDATES_TIMES_TABLE, CoreCourseCheckUpdatesDBRecord } from './database/module-prefetch';
|
import { CHECK_UPDATES_TIMES_TABLE, CoreCourseCheckUpdatesDBRecord } from './database/module-prefetch';
|
||||||
import { CoreFileSizeSum } from '@services/plugin-file-delegate';
|
import { CoreFileSizeSum } from '@services/plugin-file-delegate';
|
||||||
|
import { CoreCourseModuleData } from './course-helper';
|
||||||
|
|
||||||
const ROOT_CACHE_KEY = 'mmCourse:';
|
const ROOT_CACHE_KEY = 'mmCourse:';
|
||||||
|
|
||||||
|
@ -123,7 +124,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
* @param courseId Course ID the modules belong to.
|
* @param courseId Course ID the modules belong to.
|
||||||
* @return Promise resolved with the lists.
|
* @return Promise resolved with the lists.
|
||||||
*/
|
*/
|
||||||
protected async createToCheckList(modules: CoreCourseWSModule[], courseId: number): Promise<ToCheckList> {
|
protected async createToCheckList(modules: CoreCourseModuleData[], courseId: number): Promise<ToCheckList> {
|
||||||
const result: ToCheckList = {
|
const result: ToCheckList = {
|
||||||
toCheck: [],
|
toCheck: [],
|
||||||
cannotUse: [],
|
cannotUse: [],
|
||||||
|
@ -221,7 +222,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
* @return Promise resolved with the updates. If a module is set to false, it means updates cannot be
|
* @return Promise resolved with the updates. If a module is set to false, it means updates cannot be
|
||||||
* checked for that module in the current site.
|
* checked for that module in the current site.
|
||||||
*/
|
*/
|
||||||
async getCourseUpdates(modules: CoreCourseWSModule[], courseId: number): Promise<CourseUpdates> {
|
async getCourseUpdates(modules: CoreCourseModuleData[], courseId: number): Promise<CourseUpdates> {
|
||||||
// Check if there's already a getCourseUpdates in progress.
|
// Check if there's already a getCourseUpdates in progress.
|
||||||
const id = <string> Md5.hashAsciiStr(courseId + '#' + JSON.stringify(modules));
|
const id = <string> Md5.hashAsciiStr(courseId + '#' + JSON.stringify(modules));
|
||||||
const siteId = CoreSites.getCurrentSiteId();
|
const siteId = CoreSites.getCurrentSiteId();
|
||||||
|
@ -253,7 +254,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
* checked for that module in the site.
|
* checked for that module in the site.
|
||||||
*/
|
*/
|
||||||
protected async fetchCourseUpdates(
|
protected async fetchCourseUpdates(
|
||||||
modules: CoreCourseWSModule[],
|
modules: CoreCourseModuleData[],
|
||||||
courseId: number,
|
courseId: number,
|
||||||
siteId: string,
|
siteId: string,
|
||||||
): Promise<CourseUpdates> {
|
): Promise<CourseUpdates> {
|
||||||
|
@ -351,7 +352,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
* @param courseId Course ID the modules belong to.
|
* @param courseId Course ID the modules belong to.
|
||||||
* @return Promise resolved with the size.
|
* @return Promise resolved with the size.
|
||||||
*/
|
*/
|
||||||
async getDownloadSize(modules: CoreCourseWSModule[], courseId: number): Promise<CoreFileSizeSum> {
|
async getDownloadSize(modules: CoreCourseModuleData[], courseId: number): Promise<CoreFileSizeSum> {
|
||||||
// Get the status of each module.
|
// Get the status of each module.
|
||||||
const data = await this.getModulesStatus(modules, courseId);
|
const data = await this.getModulesStatus(modules, courseId);
|
||||||
|
|
||||||
|
@ -683,7 +684,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
* @return Promise resolved with the data.
|
* @return Promise resolved with the data.
|
||||||
*/
|
*/
|
||||||
async getModulesStatus(
|
async getModulesStatus(
|
||||||
modules: CoreCourseWSModule[],
|
modules: CoreCourseModuleData[],
|
||||||
courseId: number,
|
courseId: number,
|
||||||
sectionId?: number,
|
sectionId?: number,
|
||||||
refresh?: boolean,
|
refresh?: boolean,
|
||||||
|
@ -891,7 +892,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
* @param courseId Course ID.
|
* @param courseId Course ID.
|
||||||
* @return Promise resolved when modules are invalidated.
|
* @return Promise resolved when modules are invalidated.
|
||||||
*/
|
*/
|
||||||
async invalidateModules(modules: CoreCourseWSModule[], courseId: number): Promise<void> {
|
async invalidateModules(modules: CoreCourseModuleData[], courseId: number): Promise<void> {
|
||||||
|
|
||||||
const promises = modules.map(async (module) => {
|
const promises = modules.map(async (module) => {
|
||||||
const handler = this.getPrefetchHandlerFor(module);
|
const handler = this.getPrefetchHandlerFor(module);
|
||||||
|
@ -1049,7 +1050,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
* @param courseId Course ID the module belongs to.
|
* @param courseId Course ID the module belongs to.
|
||||||
* @return Promise resolved when finished.
|
* @return Promise resolved when finished.
|
||||||
*/
|
*/
|
||||||
syncModules(modules: CoreCourseWSModule[], courseId: number): Promise<unknown> {
|
syncModules(modules: CoreCourseModuleData[], courseId: number): Promise<unknown> {
|
||||||
return Promise.all(modules.map(async (module) => {
|
return Promise.all(modules.map(async (module) => {
|
||||||
await this.syncModule(module, courseId);
|
await this.syncModule(module, courseId);
|
||||||
|
|
||||||
|
@ -1091,7 +1092,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
*/
|
*/
|
||||||
async prefetchModules(
|
async prefetchModules(
|
||||||
id: string,
|
id: string,
|
||||||
modules: CoreCourseWSModule[],
|
modules: CoreCourseModuleData[],
|
||||||
courseId: number,
|
courseId: number,
|
||||||
onProgress?: CoreCourseModulesProgressFunction,
|
onProgress?: CoreCourseModulesProgressFunction,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
@ -1512,7 +1513,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler {
|
||||||
|
|
||||||
type ToCheckList = {
|
type ToCheckList = {
|
||||||
toCheck: CheckUpdatesToCheckWSParam[];
|
toCheck: CheckUpdatesToCheckWSParam[];
|
||||||
cannotUse: CoreCourseWSModule[];
|
cannotUse: CoreCourseModuleData[];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1526,10 +1527,10 @@ type CourseUpdates = Record<number, false | CheckUpdatesWSInstance>;
|
||||||
export type CoreCourseModulesStatus = {
|
export type CoreCourseModulesStatus = {
|
||||||
total: number; // Number of modules.
|
total: number; // Number of modules.
|
||||||
status: string; // Status of the list of modules.
|
status: string; // Status of the list of modules.
|
||||||
[CoreConstants.NOT_DOWNLOADED]: CoreCourseWSModule[]; // Modules with state NOT_DOWNLOADED.
|
[CoreConstants.NOT_DOWNLOADED]: CoreCourseModuleData[]; // Modules with state NOT_DOWNLOADED.
|
||||||
[CoreConstants.DOWNLOADED]: CoreCourseWSModule[]; // Modules with state DOWNLOADED.
|
[CoreConstants.DOWNLOADED]: CoreCourseModuleData[]; // Modules with state DOWNLOADED.
|
||||||
[CoreConstants.DOWNLOADING]: CoreCourseWSModule[]; // Modules with state DOWNLOADING.
|
[CoreConstants.DOWNLOADING]: CoreCourseModuleData[]; // Modules with state DOWNLOADING.
|
||||||
[CoreConstants.OUTDATED]: CoreCourseWSModule[]; // Modules with state OUTDATED.
|
[CoreConstants.OUTDATED]: CoreCourseModuleData[]; // Modules with state OUTDATED.
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,14 +17,14 @@ import { IonRefresher } from '@ionic/angular';
|
||||||
import { Params } from '@angular/router';
|
import { Params } from '@angular/router';
|
||||||
|
|
||||||
import { CoreSite, CoreSiteConfig } from '@classes/site';
|
import { CoreSite, CoreSiteConfig } from '@classes/site';
|
||||||
import { CoreCourse, CoreCourseWSModule, CoreCourseWSSection } from '@features/course/services/course';
|
import { CoreCourse, CoreCourseWSSection } from '@features/course/services/course';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreSiteHome } from '@features/sitehome/services/sitehome';
|
import { CoreSiteHome } from '@features/sitehome/services/sitehome';
|
||||||
import { CoreCourses, CoreCoursesProvider } from '@features//courses/services/courses';
|
import { CoreCourses, CoreCoursesProvider } from '@features//courses/services/courses';
|
||||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
import { CoreCourseHelper, CoreCourseModule } from '@features/course/services/course-helper';
|
import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreCourseModuleDelegate, CoreCourseModuleHandlerData } 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 { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreBlockHelper } from '@features/block/services/block-helper';
|
import { CoreBlockHelper } from '@features/block/services/block-helper';
|
||||||
|
@ -52,7 +52,7 @@ export class CoreSiteHomeIndexPage implements OnInit, OnDestroy {
|
||||||
searchEnabled = false;
|
searchEnabled = false;
|
||||||
displayEnableDownload = false;
|
displayEnableDownload = false;
|
||||||
downloadEnabled = false;
|
downloadEnabled = false;
|
||||||
newsForumModule?: NewsForum;
|
newsForumModule?: CoreCourseModuleData;
|
||||||
|
|
||||||
protected updateSiteObserver: CoreEventObserver;
|
protected updateSiteObserver: CoreEventObserver;
|
||||||
protected downloadEnabledObserver: CoreEventObserver;
|
protected downloadEnabledObserver: CoreEventObserver;
|
||||||
|
@ -79,7 +79,7 @@ export class CoreSiteHomeIndexPage implements OnInit, OnDestroy {
|
||||||
this.currentSite = CoreSites.getRequiredCurrentSite();
|
this.currentSite = CoreSites.getRequiredCurrentSite();
|
||||||
this.siteHomeId = CoreSites.getCurrentSiteHomeId();
|
this.siteHomeId = CoreSites.getCurrentSiteHomeId();
|
||||||
|
|
||||||
const module = CoreNavigator.getRouteParam<CoreCourseModule>('module');
|
const module = CoreNavigator.getRouteParam<CoreCourseModuleData>('module');
|
||||||
if (module) {
|
if (module) {
|
||||||
const modParams = CoreNavigator.getRouteParam<Params>('modParams');
|
const modParams = CoreNavigator.getRouteParam<Params>('modParams');
|
||||||
CoreCourseHelper.openModule(module, this.siteHomeId, undefined, modParams);
|
CoreCourseHelper.openModule(module, this.siteHomeId, undefined, modParams);
|
||||||
|
@ -235,7 +235,3 @@ export class CoreSiteHomeIndexPage implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type NewsForum = CoreCourseWSModule & {
|
|
||||||
handlerData?: CoreCourseModuleHandlerData;
|
|
||||||
};
|
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
import { Type } from '@angular/core';
|
import { Type } from '@angular/core';
|
||||||
|
|
||||||
import { CoreConstants } from '@/core/constants';
|
import { CoreConstants } from '@/core/constants';
|
||||||
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseWSModule } from '@features/course/services/course';
|
import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course';
|
||||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
|
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
|
||||||
import { CoreSitePluginsModuleIndexComponent } from '@features/siteplugins/components/module-index/module-index';
|
import { CoreSitePluginsModuleIndexComponent } from '@features/siteplugins/components/module-index/module-index';
|
||||||
import {
|
import {
|
||||||
|
@ -94,7 +94,7 @@ export class CoreSitePluginsModuleHandler extends CoreSitePluginsBaseHandler imp
|
||||||
// There is a method, add an action.
|
// There is a method, add an action.
|
||||||
handlerData.action = async (
|
handlerData.action = async (
|
||||||
event: Event,
|
event: Event,
|
||||||
module: CoreCourseModule,
|
module: CoreCourseModuleData,
|
||||||
courseId: number,
|
courseId: number,
|
||||||
options?: CoreNavigationOptions,
|
options?: CoreNavigationOptions,
|
||||||
) => {
|
) => {
|
||||||
|
@ -190,7 +190,7 @@ export class CoreSitePluginsModuleHandler extends CoreSitePluginsBaseHandler imp
|
||||||
|
|
||||||
// Use the html returned.
|
// Use the html returned.
|
||||||
handlerData.title = result.templates[0]?.html ?? '';
|
handlerData.title = result.templates[0]?.html ?? '';
|
||||||
(<CoreCourseWSModule> module).description = '';
|
(<CoreCourseModuleData> module).description = '';
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error('Error calling course page method:', error);
|
this.logger.error('Error calling course page method:', error);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -215,7 +215,7 @@ export class CoreSitePluginsModuleHandler extends CoreSitePluginsBaseHandler imp
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async manualCompletionAlwaysShown(module: CoreCourseModule): Promise<boolean> {
|
async manualCompletionAlwaysShown(module: CoreCourseModuleData): Promise<boolean> {
|
||||||
if (this.handlerSchema.manualcompletionalwaysshown !== undefined) {
|
if (this.handlerSchema.manualcompletionalwaysshown !== undefined) {
|
||||||
return this.handlerSchema.manualcompletionalwaysshown;
|
return this.handlerSchema.manualcompletionalwaysshown;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ export class CoreSitePluginsModuleHandler extends CoreSitePluginsBaseHandler imp
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async openActivityPage(module: CoreCourseModule, courseId: number, options?: CoreNavigationOptions): Promise<void> {
|
async openActivityPage(module: CoreCourseModuleData, courseId: number, options?: CoreNavigationOptions): Promise<void> {
|
||||||
if (!CoreCourse.moduleHasView(module)) {
|
if (!CoreCourse.moduleHasView(module)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { CoreConstants } from '@/core/constants';
|
||||||
import { Component, OnInit, OnDestroy, Input, ViewChild } from '@angular/core';
|
import { Component, OnInit, OnDestroy, Input, ViewChild } from '@angular/core';
|
||||||
|
|
||||||
import { CoreSiteWSPreSets } from '@classes/site';
|
import { CoreSiteWSPreSets } from '@classes/site';
|
||||||
import { CoreCourseHelper, CoreCourseModule } from '@features/course/services/course-helper';
|
import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import {
|
import {
|
||||||
CoreCourseModuleDelegate,
|
CoreCourseModuleDelegate,
|
||||||
CoreCourseModuleMainComponent,
|
CoreCourseModuleMainComponent,
|
||||||
|
@ -44,7 +44,7 @@ import { CoreSitePluginsPluginContentComponent } from '../plugin-content/plugin-
|
||||||
})
|
})
|
||||||
export class CoreSitePluginsModuleIndexComponent implements OnInit, OnDestroy, CoreCourseModuleMainComponent {
|
export class CoreSitePluginsModuleIndexComponent implements OnInit, OnDestroy, CoreCourseModuleMainComponent {
|
||||||
|
|
||||||
@Input() module!: CoreCourseModule; // The module.
|
@Input() module!: CoreCourseModuleData; // The module.
|
||||||
@Input() courseId!: number; // Course ID the module belongs to.
|
@Input() courseId!: number; // Course ID the module belongs to.
|
||||||
@Input() pageTitle?: string; // Current page title. It can be used by the "new-content" directives.
|
@Input() pageTitle?: string; // Current page title. It can be used by the "new-content" directives.
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||||
import { IonRefresher } from '@ionic/angular';
|
import { IonRefresher } from '@ionic/angular';
|
||||||
|
|
||||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CanLeave } from '@guards/can-leave';
|
import { CanLeave } from '@guards/can-leave';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreSitePluginsModuleIndexComponent } from '../../components/module-index/module-index';
|
import { CoreSitePluginsModuleIndexComponent } from '../../components/module-index/module-index';
|
||||||
|
@ -32,7 +32,7 @@ export class CoreSitePluginsModuleIndexPage implements OnInit, CanLeave {
|
||||||
@ViewChild(CoreSitePluginsModuleIndexComponent) content?: CoreSitePluginsModuleIndexComponent;
|
@ViewChild(CoreSitePluginsModuleIndexComponent) content?: CoreSitePluginsModuleIndexComponent;
|
||||||
|
|
||||||
title?: string; // Page title.
|
title?: string; // Page title.
|
||||||
module?: CoreCourseModule;
|
module?: CoreCourseModuleData;
|
||||||
courseId?: number;
|
courseId?: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue