MOBILE-3659 course: Change naming of calculated types
parent
031f238117
commit
adf8a1f481
|
@ -14,8 +14,8 @@
|
|||
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreCourse, CoreCourseSection } from '@features/course/services/course';
|
||||
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreCourseHelper, CoreCourseSection } from '@features/course/services/course-helper';
|
||||
import { CoreSiteHome, FrontPageItemNames } from '@features/sitehome/services/sitehome';
|
||||
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
|
||||
import { CoreBlockBaseComponent } from '@features/block/classes/base-block-component';
|
||||
|
@ -77,8 +77,8 @@ export class AddonBlockSiteMainMenuComponent extends CoreBlockBaseComponent impl
|
|||
protected async fetchContent(): Promise<void> {
|
||||
const sections = await CoreCourse.instance.getSections(this.siteHomeId, false, true);
|
||||
|
||||
this.mainMenuBlock = sections.find((section) => section.section == 0);
|
||||
if (!this.mainMenuBlock) {
|
||||
const mainMenuBlock = sections.find((section) => section.section == 0);
|
||||
if (!mainMenuBlock) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -91,10 +91,17 @@ export class AddonBlockSiteMainMenuComponent extends CoreBlockBaseComponent impl
|
|||
const items = config.frontpageloggedin.split(',');
|
||||
const hasNewsItem = items.find((item) => parseInt(item, 10) == FrontPageItemNames['NEWS_ITEMS']);
|
||||
|
||||
const hasContent = CoreCourseHelper.instance.sectionHasContent(this.mainMenuBlock);
|
||||
CoreCourseHelper.instance.addHandlerDataForModules([this.mainMenuBlock], this.siteHomeId, undefined, undefined, true);
|
||||
const result = await CoreCourseHelper.instance.addHandlerDataForModules(
|
||||
[mainMenuBlock],
|
||||
this.siteHomeId,
|
||||
undefined,
|
||||
undefined,
|
||||
true,
|
||||
);
|
||||
|
||||
if (!hasNewsItem || !hasContent) {
|
||||
this.mainMenuBlock = result.sections[0];
|
||||
|
||||
if (!hasNewsItem || !this.mainMenuBlock.hasContent) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,11 +33,15 @@ import { CoreDynamicComponent } from '@components/dynamic-component/dynamic-comp
|
|||
import { CoreCourseAnyCourseData } from '@features/courses/services/courses';
|
||||
import {
|
||||
CoreCourse,
|
||||
CoreCourseModuleCompletionData,
|
||||
CoreCourseModuleData,
|
||||
CoreCourseProvider,
|
||||
} from '@features/course/services/course';
|
||||
import { CoreCourseHelper, CoreCourseSectionFormatted, CoreCourseSectionWithStatus } from '@features/course/services/course-helper';
|
||||
import {
|
||||
CoreCourseHelper,
|
||||
CoreCourseModule,
|
||||
CoreCourseModuleCompletionData,
|
||||
CoreCourseSection,
|
||||
CoreCourseSectionWithStatus,
|
||||
} from '@features/course/services/course-helper';
|
||||
import { CoreCourseFormatDelegate } from '@features/course/services/format-delegate';
|
||||
import { CoreEventObserver, CoreEvents, CoreEventSectionStatusChangedData, CoreEventSelectCourseTabData } from '@singletons/events';
|
||||
import { IonContent, IonRefresher } from '@ionic/angular';
|
||||
|
@ -91,9 +95,9 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
|
|||
|
||||
displaySectionSelector?: boolean;
|
||||
displayBlocks?: boolean;
|
||||
selectedSection?: CoreCourseSectionFormatted;
|
||||
previousSection?: CoreCourseSectionFormatted;
|
||||
nextSection?: CoreCourseSectionFormatted;
|
||||
selectedSection?: CoreCourseSection;
|
||||
previousSection?: CoreCourseSection;
|
||||
nextSection?: CoreCourseSection;
|
||||
allSectionsId: number = CoreCourseProvider.ALL_SECTIONS_ID;
|
||||
stealthModulesSectionId: number = CoreCourseProvider.STEALTH_MODULES_SECTION_ID;
|
||||
loaded = false;
|
||||
|
@ -154,7 +158,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
|
|||
return;
|
||||
}
|
||||
|
||||
let section: CoreCourseSectionFormatted | undefined;
|
||||
let section: CoreCourseSection | undefined;
|
||||
|
||||
if (typeof data.sectionId != 'undefined' && data.sectionId != null && this.sections) {
|
||||
section = this.sections.find((section) => section.id == data.sectionId);
|
||||
|
@ -280,7 +284,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
|
|||
* @param sections Sections to treat.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected async treatSections(sections: CoreCourseSectionFormatted[]): Promise<void> {
|
||||
protected async treatSections(sections: CoreCourseSection[]): Promise<void> {
|
||||
const hasAllSections = sections[0].id == CoreCourseProvider.ALL_SECTIONS_ID;
|
||||
this.hasSeveralSections = sections.length > 2 || (sections.length == 2 && !hasAllSections);
|
||||
|
||||
|
@ -362,7 +366,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
|
|||
*
|
||||
* @param newSection The new selected section.
|
||||
*/
|
||||
sectionChanged(newSection: CoreCourseSectionFormatted): void {
|
||||
sectionChanged(newSection: CoreCourseSection): void {
|
||||
const previousValue = this.selectedSection;
|
||||
this.selectedSection = newSection;
|
||||
this.data.section = this.selectedSection;
|
||||
|
@ -419,7 +423,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
|
|||
* @param section2 Second section.
|
||||
* @return Whether they're equal.
|
||||
*/
|
||||
compareSections(section1: CoreCourseSectionFormatted, section2: CoreCourseSectionFormatted): boolean {
|
||||
compareSections(section1: CoreCourseSection, section2: CoreCourseSection): boolean {
|
||||
return section1 && section2 ? section1.id === section2.id : section1 === section2;
|
||||
}
|
||||
|
||||
|
@ -583,7 +587,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
|
|||
* @param section The section to check.
|
||||
* @return Whether the section can be viewed.
|
||||
*/
|
||||
canViewSection(section: CoreCourseSectionFormatted): boolean {
|
||||
canViewSection(section: CoreCourseSection): boolean {
|
||||
return section.uservisible !== false && !section.hiddenbynumsections &&
|
||||
section.id != CoreCourseProvider.STEALTH_MODULES_SECTION_ID;
|
||||
}
|
||||
|
@ -601,7 +605,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.
|
||||
const completionModules = (<CoreCourseModuleData[]> [])
|
||||
const completionModules = (<CoreCourseModule[]> [])
|
||||
.concat(...this.sections!.map((section) => section.modules))
|
||||
.map((module) => module.completion && module.completion > 0 ? 1 : module.completion)
|
||||
.reduce((accumulator, currentValue) => (accumulator || 0) + (currentValue || 0));
|
||||
|
|
|
@ -18,7 +18,7 @@ import { CoreDomUtils } from '@services/utils/dom';
|
|||
import { CoreUser } from '@features/user/services/user';
|
||||
import { CoreCourse, CoreCourseProvider } from '@features/course/services/course';
|
||||
import { CoreFilterHelper } from '@features/filter/services/filter-helper';
|
||||
import { CoreCourseModuleCompletionDataFormatted } from '@features/course/services/course-helper';
|
||||
import { CoreCourseModuleCompletionData } from '@features/course/services/course-helper';
|
||||
import { Translate } from '@singletons';
|
||||
|
||||
/**
|
||||
|
@ -37,10 +37,10 @@ import { Translate } from '@singletons';
|
|||
})
|
||||
export class CoreCourseModuleCompletionComponent implements OnChanges {
|
||||
|
||||
@Input() completion?: CoreCourseModuleCompletionDataFormatted; // The completion status.
|
||||
@Input() completion?: CoreCourseModuleCompletionData; // The completion status.
|
||||
@Input() moduleId?: number; // The name of the module this completion affects.
|
||||
@Input() moduleName?: string; // The name of the module this completion affects.
|
||||
@Output() completionChanged = new EventEmitter<CoreCourseModuleCompletionDataFormatted>(); // Notify when completion changes.
|
||||
@Output() completionChanged = new EventEmitter<CoreCourseModuleCompletionData>(); // Notify when completion changes.
|
||||
|
||||
completionImage?: string;
|
||||
completionDescription?: string;
|
||||
|
|
|
@ -19,10 +19,11 @@ import { CoreDomUtils } from '@services/utils/dom';
|
|||
import { CoreEventObserver, CoreEventPackageStatusChanged, CoreEvents } from '@singletons/events';
|
||||
import {
|
||||
CoreCourseHelper,
|
||||
CoreCourseModuleDataFormatted,
|
||||
CoreCourseSectionFormatted,
|
||||
CoreCourseModule,
|
||||
CoreCourseModuleCompletionData,
|
||||
CoreCourseSection,
|
||||
} from '@features/course/services/course-helper';
|
||||
import { CoreCourse, CoreCourseModuleCompletionData } from '@features/course/services/course';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreCourseModuleHandlerButton } from '@features/course/services/module-delegate';
|
||||
import {
|
||||
CoreCourseModulePrefetchDelegate,
|
||||
|
@ -43,9 +44,9 @@ import {
|
|||
})
|
||||
export class CoreCourseModuleComponent implements OnInit, OnDestroy {
|
||||
|
||||
@Input() module?: CoreCourseModuleDataFormatted; // The module to render.
|
||||
@Input() module?: CoreCourseModule; // The module to render.
|
||||
@Input() courseId?: number; // The course the module belongs to.
|
||||
@Input() section?: CoreCourseSectionFormatted; // The section the module belongs to.
|
||||
@Input() section?: CoreCourseSection; // The section the module belongs to.
|
||||
// eslint-disable-next-line @angular-eslint/no-input-rename
|
||||
@Input('downloadEnabled') set enabled(value: boolean) {
|
||||
this.downloadEnabled = value;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
|
||||
import { CoreCourseSectionFormatted } from '@features/course/services/course-helper';
|
||||
import { CoreCourseSection } from '@features/course/services/course-helper';
|
||||
import { CoreCourseProvider } from '@features/course/services/course';
|
||||
import { CoreCourseAnyCourseData } from '@features/courses/services/courses';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
|
@ -30,7 +30,7 @@ import { ModalController } from '@singletons';
|
|||
export class CoreCourseSectionSelectorComponent implements OnInit {
|
||||
|
||||
@Input() sections?: SectionWithProgress[];
|
||||
@Input() selected?: CoreCourseSectionFormatted;
|
||||
@Input() selected?: CoreCourseSection;
|
||||
@Input() course?: CoreCourseAnyCourseData;
|
||||
|
||||
stealthModulesSectionId = CoreCourseProvider.STEALTH_MODULES_SECTION_ID;
|
||||
|
@ -93,6 +93,6 @@ export class CoreCourseSectionSelectorComponent implements OnInit {
|
|||
|
||||
}
|
||||
|
||||
type SectionWithProgress = CoreCourseSectionFormatted & {
|
||||
type SectionWithProgress = CoreCourseSection & {
|
||||
progress?: number;
|
||||
};
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
|
||||
import { CoreCourse, CoreCourseModuleData } from '@features/course/services/course';
|
||||
import { CoreCourse, CoreCourseWSModule } from '@features/course/services/course';
|
||||
import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate';
|
||||
|
||||
/**
|
||||
|
@ -27,7 +27,7 @@ import { CoreCourseModuleDelegate } from '@features/course/services/module-deleg
|
|||
export class CoreCourseUnsupportedModuleComponent implements OnInit {
|
||||
|
||||
@Input() courseId?: number; // The course to module belongs to.
|
||||
@Input() module?: CoreCourseModuleData; // The module to render.
|
||||
@Input() module?: CoreCourseWSModule; // The module to render.
|
||||
|
||||
isDisabledInSite?: boolean;
|
||||
isSupportedByTheApp?: boolean;
|
||||
|
|
|
@ -18,8 +18,8 @@ import { CoreCourseModuleDelegate } from '@features/course/services/module-deleg
|
|||
import { CoreCourseUnsupportedModuleComponent } from '@features/course/components/unsupported-module/unsupported-module';
|
||||
import { CoreDynamicComponent } from '@components/dynamic-component/dynamic-component';
|
||||
import { CoreCourseAnyCourseData } from '@features/courses/services/courses';
|
||||
import { CoreCourseSection } from '@features/course/services/course';
|
||||
import { IonRefresher } from '@ionic/angular';
|
||||
import { CoreCourseModuleCompletionData, CoreCourseSectionWithStatus } from '@features/course/services/course-helper';
|
||||
|
||||
/**
|
||||
* Component to display single activity format. It will determine the right component to use and instantiate it.
|
||||
|
@ -33,12 +33,12 @@ import { IonRefresher } from '@ionic/angular';
|
|||
export class CoreCourseFormatSingleActivityComponent implements OnChanges {
|
||||
|
||||
@Input() course?: CoreCourseAnyCourseData; // The course to render.
|
||||
@Input() sections?: CoreCourseSection[]; // List of course sections.
|
||||
@Input() sections?: CoreCourseSectionWithStatus[]; // List of course sections.
|
||||
@Input() downloadEnabled?: boolean; // Whether the download of sections and modules is enabled.
|
||||
@Input() initialSectionId?: number; // The section to load first (by ID).
|
||||
@Input() initialSectionNumber?: number; // The section to load first (by number).
|
||||
@Input() moduleId?: number; // The module ID to scroll to. Must be inside the initial selected section.
|
||||
@Output() completionChanged?: EventEmitter<void>; // Will emit an event when any module completion changes.
|
||||
@Output() completionChanged = new EventEmitter<CoreCourseModuleCompletionData>(); // Notify when any module completion changes.
|
||||
|
||||
@ViewChild(CoreDynamicComponent) dynamicComponent?: CoreDynamicComponent;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Injectable, Type } from '@angular/core';
|
||||
|
||||
import { CoreCourseSection } from '@features/course/services/course';
|
||||
import { CoreCourseWSSection } from '@features/course/services/course';
|
||||
import { CoreCourseFormatHandler } from '@features/course/services/format-delegate';
|
||||
import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate';
|
||||
import { CoreCourseAnyCourseData } from '@features/courses/services/courses';
|
||||
|
@ -69,7 +69,7 @@ export class CoreCourseFormatSingleActivityHandlerService implements CoreCourseF
|
|||
* @param sections List of sections.
|
||||
* @return Title.
|
||||
*/
|
||||
getCourseTitle(course: CoreCourseAnyCourseData, sections?: CoreCourseSection[]): string {
|
||||
getCourseTitle(course: CoreCourseAnyCourseData, sections?: CoreCourseWSSection[]): string {
|
||||
if (sections?.[0]?.modules?.[0]) {
|
||||
return sections[0].modules[0].name;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ export class CoreCourseFormatSingleActivityHandlerService implements CoreCourseF
|
|||
* @param sections List of course sections.
|
||||
* @return Whether the refresher should be displayed.
|
||||
*/
|
||||
displayRefresher(course: CoreCourseAnyCourseData, sections: CoreCourseSection[]): boolean {
|
||||
displayRefresher(course: CoreCourseAnyCourseData, sections: CoreCourseWSSection[]): boolean {
|
||||
if (sections?.[0]?.modules?.[0]) {
|
||||
return CoreCourseModuleDelegate.instance.displayRefresherInSingleActivity(sections[0].modules[0].modname);
|
||||
} else {
|
||||
|
|
|
@ -18,8 +18,9 @@ import { CoreTimeUtils } from '@services/utils/time';
|
|||
import { CoreCourseFormatHandler } from '@features/course/services/format-delegate';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { CoreCourseAnyCourseData } from '@features/courses/services/courses';
|
||||
import { CoreCourseSection } from '@features/course/services/course';
|
||||
import { CoreCourseWSSection } from '@features/course/services/course';
|
||||
import { CoreConstants } from '@/core/constants';
|
||||
import { CoreCourseSection } from '@features/course/services/course-helper';
|
||||
|
||||
/**
|
||||
* Handler to support weeks course format.
|
||||
|
@ -77,7 +78,7 @@ export class CoreCourseFormatWeeksHandlerService implements CoreCourseFormatHand
|
|||
* @param startDate The course start date (in seconds).
|
||||
* @return An object with the start and end date of the section.
|
||||
*/
|
||||
protected getSectionDates(section: CoreCourseSection, startDate: number): { start: number; end: number } {
|
||||
protected getSectionDates(section: CoreCourseWSSection, startDate: number): { start: number; end: number } {
|
||||
// Hack alert. We add 2 hours to avoid possible DST problems. (e.g. we go into daylight savings and the date changes).
|
||||
startDate = startDate + 7200;
|
||||
|
||||
|
|
|
@ -23,10 +23,14 @@ import { CoreCourses, CoreCourseAnyCourseData } from '@features/courses/services
|
|||
import {
|
||||
CoreCourse,
|
||||
CoreCourseCompletionActivityStatus,
|
||||
CoreCourseModuleCompletionData,
|
||||
CoreCourseProvider,
|
||||
} from '@features/course/services/course';
|
||||
import { CoreCourseHelper, CoreCourseSectionFormatted, CorePrefetchStatusInfo } from '@features/course/services/course-helper';
|
||||
import {
|
||||
CoreCourseHelper,
|
||||
CoreCourseModuleCompletionData,
|
||||
CoreCourseSection,
|
||||
CorePrefetchStatusInfo,
|
||||
} from '@features/course/services/course-helper';
|
||||
import { CoreCourseFormatDelegate } from '@features/course/services/format-delegate';
|
||||
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
|
||||
import {
|
||||
|
@ -56,7 +60,7 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy {
|
|||
@ViewChild(CoreCourseFormatComponent) formatComponent?: CoreCourseFormatComponent;
|
||||
|
||||
course!: CoreCourseAnyCourseData;
|
||||
sections?: CoreCourseSectionFormatted[];
|
||||
sections?: CoreCourseSection[];
|
||||
sectionId?: number;
|
||||
sectionNumber?: number;
|
||||
courseMenuHandlers: CoreCourseOptionsMenuHandlerToDisplay[] = [];
|
||||
|
|
|
@ -20,7 +20,7 @@ import { CoreCourseFormatDelegate } from '../../services/format-delegate';
|
|||
import { CoreCourseOptionsDelegate } from '../../services/course-options-delegate';
|
||||
import { CoreCourseAnyCourseData } from '@features/courses/services/courses';
|
||||
import { CoreEventObserver, CoreEvents, CoreEventSelectCourseTabData } from '@singletons/events';
|
||||
import { CoreCourse, CoreCourseModuleData } from '@features/course/services/course';
|
||||
import { CoreCourse, CoreCourseWSModule } from '@features/course/services/course';
|
||||
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
|
@ -84,7 +84,7 @@ export class CoreCourseIndexPage implements OnInit, OnDestroy {
|
|||
// Get params.
|
||||
this.course = this.route.snapshot.queryParams['course'];
|
||||
this.firstTabName = this.route.snapshot.queryParams['selectedTab'];
|
||||
const module: CoreCourseModuleData | undefined = this.route.snapshot.queryParams['module'];
|
||||
const module: CoreCourseWSModule | undefined = this.route.snapshot.queryParams['module'];
|
||||
const modParams: Params | undefined = this.route.snapshot.queryParams['modParams'];
|
||||
|
||||
this.currentPagePath = CoreNavHelper.instance.getCurrentPage();
|
||||
|
|
|
@ -20,11 +20,11 @@ import { CoreSites } from '@services/sites';
|
|||
import {
|
||||
CoreCourse,
|
||||
CoreCourseCompletionActivityStatus,
|
||||
CoreCourseModuleCompletionData,
|
||||
CoreCourseModuleWSCompletionData,
|
||||
CoreCourseModuleContentFile,
|
||||
CoreCourseModuleData,
|
||||
CoreCourseWSModule,
|
||||
CoreCourseProvider,
|
||||
CoreCourseSection,
|
||||
CoreCourseWSSection,
|
||||
} from './course';
|
||||
import { CoreConstants } from '@/core/constants';
|
||||
import { CoreLogger } from '@singletons/logger';
|
||||
|
@ -158,14 +158,14 @@ export class CoreCourseHelperProvider {
|
|||
* @return Whether the sections have content.
|
||||
*/
|
||||
addHandlerDataForModules(
|
||||
sections: CoreCourseSection[],
|
||||
sections: CoreCourseWSSection[],
|
||||
courseId: number,
|
||||
completionStatus?: Record<string, CoreCourseCompletionActivityStatus>,
|
||||
courseName?: string,
|
||||
forCoursePage = false,
|
||||
): { hasContent: boolean; sections: CoreCourseSectionFormatted[] } {
|
||||
): { hasContent: boolean; sections: CoreCourseSection[] } {
|
||||
|
||||
const formattedSections: CoreCourseSectionFormatted[] = sections;
|
||||
const formattedSections: CoreCourseSection[] = sections;
|
||||
let hasContent = false;
|
||||
|
||||
formattedSections.forEach((section) => {
|
||||
|
@ -229,7 +229,7 @@ export class CoreCourseHelperProvider {
|
|||
* @return Promise resolved when the status is calculated.
|
||||
*/
|
||||
async calculateSectionStatus(
|
||||
section: CoreCourseSectionFormatted,
|
||||
section: CoreCourseSection,
|
||||
courseId: number,
|
||||
refresh?: boolean,
|
||||
checkUpdates: boolean = true,
|
||||
|
@ -285,7 +285,7 @@ export class CoreCourseHelperProvider {
|
|||
* @return Promise resolved when the states are calculated.
|
||||
*/
|
||||
async calculateSectionsStatus(
|
||||
sections: CoreCourseSectionFormatted[],
|
||||
sections: CoreCourseSection[],
|
||||
courseId: number,
|
||||
refresh?: boolean,
|
||||
checkUpdates: boolean = true,
|
||||
|
@ -346,7 +346,7 @@ export class CoreCourseHelperProvider {
|
|||
async confirmAndPrefetchCourse(
|
||||
data: CorePrefetchStatusInfo,
|
||||
course: CoreCourseAnyCourseData,
|
||||
sections?: CoreCourseSection[],
|
||||
sections?: CoreCourseWSSection[],
|
||||
courseHandlers?: CoreCourseOptionsHandlerToDisplay[],
|
||||
menuHandlers?: CoreCourseOptionsMenuHandlerToDisplay[],
|
||||
): Promise<void> {
|
||||
|
@ -410,7 +410,7 @@ export class CoreCourseHelperProvider {
|
|||
|
||||
const promises = courses.map((course) => {
|
||||
const subPromises: Promise<void>[] = [];
|
||||
let sections: CoreCourseSection[];
|
||||
let sections: CoreCourseWSSection[];
|
||||
let handlers: CoreCourseOptionsHandlerToDisplay[] = [];
|
||||
let menuHandlers: CoreCourseOptionsMenuHandlerToDisplay[] = [];
|
||||
let success = true;
|
||||
|
@ -463,7 +463,7 @@ export class CoreCourseHelperProvider {
|
|||
* @param done Function to call when done. It will close the context menu.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
async confirmAndRemoveFiles(module: CoreCourseModuleData, courseId: number, done?: () => void): Promise<void> {
|
||||
async confirmAndRemoveFiles(module: CoreCourseWSModule, courseId: number, done?: () => void): Promise<void> {
|
||||
let modal: CoreIonLoadingElement | undefined;
|
||||
|
||||
try {
|
||||
|
@ -496,8 +496,8 @@ export class CoreCourseHelperProvider {
|
|||
*/
|
||||
async confirmDownloadSizeSection(
|
||||
courseId: number,
|
||||
section?: CoreCourseSection,
|
||||
sections?: CoreCourseSection[],
|
||||
section?: CoreCourseWSSection,
|
||||
sections?: CoreCourseWSSection[],
|
||||
alwaysConfirm?: boolean,
|
||||
): Promise<void> {
|
||||
let hasEmbeddedFiles = false;
|
||||
|
@ -554,7 +554,7 @@ export class CoreCourseHelperProvider {
|
|||
*/
|
||||
async contextMenuPrefetch(
|
||||
instance: ComponentWithContextMenu,
|
||||
module: CoreCourseModuleData,
|
||||
module: CoreCourseWSModule,
|
||||
courseId: number,
|
||||
done?: () => void,
|
||||
): Promise<void> {
|
||||
|
@ -585,7 +585,7 @@ export class CoreCourseHelperProvider {
|
|||
*
|
||||
* @return Created section.
|
||||
*/
|
||||
createAllSectionsSection(): CoreCourseSectionFormatted {
|
||||
createAllSectionsSection(): CoreCourseSection {
|
||||
return {
|
||||
id: CoreCourseProvider.ALL_SECTIONS_ID,
|
||||
name: Translate.instance.instant('core.course.allsections'),
|
||||
|
@ -636,7 +636,7 @@ export class CoreCourseHelperProvider {
|
|||
* @return Resolved on success.
|
||||
*/
|
||||
async downloadModuleAndOpenFile(
|
||||
module: CoreCourseModuleData,
|
||||
module: CoreCourseWSModule,
|
||||
courseId: number,
|
||||
component?: string,
|
||||
componentId?: string | number,
|
||||
|
@ -720,7 +720,7 @@ export class CoreCourseHelperProvider {
|
|||
protected async openModuleFileInBrowser(
|
||||
fileUrl: string,
|
||||
site: CoreSite,
|
||||
module: CoreCourseModuleData,
|
||||
module: CoreCourseWSModule,
|
||||
courseId: number,
|
||||
component?: string,
|
||||
componentId?: string | number,
|
||||
|
@ -769,7 +769,7 @@ export class CoreCourseHelperProvider {
|
|||
* @return Promise resolved when done.
|
||||
*/
|
||||
async downloadModuleWithMainFileIfNeeded(
|
||||
module: CoreCourseModuleData,
|
||||
module: CoreCourseWSModule,
|
||||
courseId: number,
|
||||
component: string,
|
||||
componentId?: string | number,
|
||||
|
@ -840,7 +840,7 @@ export class CoreCourseHelperProvider {
|
|||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected async downloadModuleWithMainFile(
|
||||
module: CoreCourseModuleData,
|
||||
module: CoreCourseWSModule,
|
||||
courseId: number,
|
||||
fixedUrl: string,
|
||||
files: CoreCourseModuleContentFile[],
|
||||
|
@ -904,7 +904,7 @@ export class CoreCourseHelperProvider {
|
|||
* @return Promise resolved when done.
|
||||
*/
|
||||
async downloadModule(
|
||||
module: CoreCourseModuleData,
|
||||
module: CoreCourseWSModule,
|
||||
courseId: number,
|
||||
component?: string,
|
||||
componentId?: string | number,
|
||||
|
@ -942,7 +942,7 @@ export class CoreCourseHelperProvider {
|
|||
*/
|
||||
async fillContextMenu(
|
||||
instance: ComponentWithContextMenu,
|
||||
module: CoreCourseModuleData,
|
||||
module: CoreCourseWSModule,
|
||||
courseId: number,
|
||||
invalidateCache?: boolean,
|
||||
component?: string,
|
||||
|
@ -1133,7 +1133,7 @@ export class CoreCourseHelperProvider {
|
|||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
async loadOfflineCompletion(courseId: number, sections: CoreCourseSectionFormatted[], siteId?: string): Promise<void> {
|
||||
async loadOfflineCompletion(courseId: number, sections: CoreCourseSection[], siteId?: string): Promise<void> {
|
||||
const offlineCompletions = await CoreCourseOffline.instance.getCourseManualCompletions(courseId, siteId);
|
||||
|
||||
if (!offlineCompletions || !offlineCompletions.length) {
|
||||
|
@ -1305,7 +1305,7 @@ export class CoreCourseHelperProvider {
|
|||
* @return Promise resolved with the info.
|
||||
*/
|
||||
async getModulePrefetchInfo(
|
||||
module: CoreCourseModuleData,
|
||||
module: CoreCourseWSModule,
|
||||
courseId: number,
|
||||
invalidateCache?: boolean,
|
||||
component?: string,
|
||||
|
@ -1425,7 +1425,7 @@ export class CoreCourseHelperProvider {
|
|||
* @param modParams Params to pass to the module
|
||||
* @param True if module can be opened, false otherwise.
|
||||
*/
|
||||
openModule(module: CoreCourseModuleDataFormatted, courseId: number, sectionId?: number, modParams?: Params): boolean {
|
||||
openModule(module: CoreCourseModule, courseId: number, sectionId?: number, modParams?: Params): boolean {
|
||||
if (!module.handlerData) {
|
||||
module.handlerData = CoreCourseModuleDelegate.instance.getModuleDataFor(
|
||||
module.modname,
|
||||
|
@ -1457,7 +1457,7 @@ export class CoreCourseHelperProvider {
|
|||
*/
|
||||
async prefetchCourse(
|
||||
course: CoreCourseAnyCourseData,
|
||||
sections: CoreCourseSection[],
|
||||
sections: CoreCourseWSSection[],
|
||||
courseHandlers: CoreCourseOptionsHandlerToDisplay[],
|
||||
courseMenuHandlers: CoreCourseOptionsMenuHandlerToDisplay[],
|
||||
siteId?: string,
|
||||
|
@ -1540,7 +1540,7 @@ export class CoreCourseHelperProvider {
|
|||
*/
|
||||
async prefetchModule(
|
||||
handler: CoreCourseModulePrefetchHandler,
|
||||
module: CoreCourseModuleData,
|
||||
module: CoreCourseWSModule,
|
||||
size: CoreFileSizeSum,
|
||||
courseId: number,
|
||||
refresh?: boolean,
|
||||
|
@ -1717,7 +1717,7 @@ export class CoreCourseHelperProvider {
|
|||
* @param section Section to check.
|
||||
* @return Whether the section has content.
|
||||
*/
|
||||
sectionHasContent(section: CoreCourseSection): boolean {
|
||||
sectionHasContent(section: CoreCourseWSSection): boolean {
|
||||
if (section.hiddenbynumsections) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1778,7 +1778,7 @@ export class CoreCourseHelperProvider {
|
|||
* @param courseId Course ID the module belongs to.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
async removeModuleStoredData(module: CoreCourseModuleData, courseId: number): Promise<void> {
|
||||
async removeModuleStoredData(module: CoreCourseWSModule, courseId: number): Promise<void> {
|
||||
const promises: Promise<void>[] = [];
|
||||
|
||||
promises.push(CoreCourseModulePrefetchDelegate.instance.removeModuleFiles(module, courseId));
|
||||
|
@ -1799,15 +1799,15 @@ export class CoreCourseHelper extends makeSingleton(CoreCourseHelperProvider) {}
|
|||
/**
|
||||
* Section with calculated data.
|
||||
*/
|
||||
export type CoreCourseSectionFormatted = Omit<CoreCourseSection, 'modules'> & {
|
||||
export type CoreCourseSection = Omit<CoreCourseWSSection, 'modules'> & {
|
||||
hasContent?: boolean;
|
||||
modules: CoreCourseModuleDataFormatted[];
|
||||
modules: CoreCourseModule[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Section with data about prefetch.
|
||||
*/
|
||||
export type CoreCourseSectionWithStatus = CoreCourseSectionFormatted & {
|
||||
export type CoreCourseSectionWithStatus = CoreCourseSection & {
|
||||
downloadStatus?: string; // Section status.
|
||||
canCheckUpdates?: boolean; // Whether can check updates.
|
||||
isDownloading?: boolean; // Whether section is being downloaded.
|
||||
|
@ -1819,16 +1819,16 @@ export type CoreCourseSectionWithStatus = CoreCourseSectionFormatted & {
|
|||
/**
|
||||
* Module with calculated data.
|
||||
*/
|
||||
export type CoreCourseModuleDataFormatted = Omit<CoreCourseModuleData, 'completiondata'> & {
|
||||
export type CoreCourseModule = Omit<CoreCourseWSModule, 'completiondata'> & {
|
||||
isStealth?: boolean;
|
||||
handlerData?: CoreCourseModuleHandlerData;
|
||||
completiondata?: CoreCourseModuleCompletionDataFormatted;
|
||||
completiondata?: CoreCourseModuleCompletionData;
|
||||
};
|
||||
|
||||
/**
|
||||
* Module completion with calculated data.
|
||||
*/
|
||||
export type CoreCourseModuleCompletionDataFormatted = CoreCourseModuleCompletionData & {
|
||||
export type CoreCourseModuleCompletionData = CoreCourseModuleWSCompletionData & {
|
||||
courseId?: number;
|
||||
courseName?: string;
|
||||
tracking?: number;
|
||||
|
|
|
@ -37,7 +37,7 @@ import {
|
|||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreWSError } from '@classes/errors/wserror';
|
||||
import { CorePushNotifications } from '@features/pushnotifications/services/pushnotifications';
|
||||
import { CoreCourseHelper, CoreCourseModuleCompletionDataFormatted } from './course-helper';
|
||||
import { CoreCourseHelper, CoreCourseModuleCompletionData } from './course-helper';
|
||||
import { CoreCourseFormatDelegate } from './format-delegate';
|
||||
|
||||
const ROOT_CACHE_KEY = 'mmCourse:';
|
||||
|
@ -110,7 +110,7 @@ export class CoreCourseProvider {
|
|||
* @param courseId Course ID.
|
||||
* @param completion Completion status of the module.
|
||||
*/
|
||||
checkModuleCompletion(courseId: number, completion: CoreCourseModuleCompletionDataFormatted): void {
|
||||
checkModuleCompletion(courseId: number, completion: CoreCourseModuleCompletionData): void {
|
||||
if (completion && completion.tracking === 2 && completion.state === 0) {
|
||||
this.invalidateSections(courseId).finally(() => {
|
||||
CoreEvents.trigger(CoreEvents.COMPLETION_MODULE_VIEWED, { courseId: courseId });
|
||||
|
@ -345,7 +345,7 @@ export class CoreCourseProvider {
|
|||
ignoreCache: boolean = false,
|
||||
siteId?: string,
|
||||
modName?: string,
|
||||
): Promise<CoreCourseModuleData> {
|
||||
): Promise<CoreCourseWSModule> {
|
||||
siteId = siteId || CoreSites.instance.getCurrentSiteId();
|
||||
|
||||
// Helper function to do the WS request without processing the result.
|
||||
|
@ -355,7 +355,7 @@ export class CoreCourseProvider {
|
|||
modName: string | undefined,
|
||||
includeStealth: boolean,
|
||||
preferCache: boolean,
|
||||
): Promise<CoreCourseSection[]> => {
|
||||
): Promise<CoreCourseWSSection[]> => {
|
||||
const params: CoreCourseGetContentsParams = {
|
||||
courseid: courseId!,
|
||||
options: [],
|
||||
|
@ -393,7 +393,7 @@ export class CoreCourseProvider {
|
|||
}
|
||||
|
||||
try {
|
||||
const sections: CoreCourseSection[] = await site.read('core_course_get_contents', params, preSets);
|
||||
const sections = await site.read<CoreCourseWSSection[]>('core_course_get_contents', params, preSets);
|
||||
|
||||
return sections;
|
||||
} catch {
|
||||
|
@ -418,7 +418,7 @@ export class CoreCourseProvider {
|
|||
courseId = module.course;
|
||||
}
|
||||
|
||||
let sections: CoreCourseSection[];
|
||||
let sections: CoreCourseWSSection[];
|
||||
try {
|
||||
const site = await CoreSites.instance.getSite(siteId);
|
||||
// We have courseId, we can use core_course_get_contents for compatibility.
|
||||
|
@ -439,7 +439,7 @@ export class CoreCourseProvider {
|
|||
sections = await this.getSections(courseId, false, false, preSets, siteId);
|
||||
}
|
||||
|
||||
let foundModule: CoreCourseModuleData | undefined;
|
||||
let foundModule: CoreCourseWSModule | undefined;
|
||||
|
||||
const foundSection = sections.some((section) => {
|
||||
if (sectionId != null &&
|
||||
|
@ -636,7 +636,7 @@ export class CoreCourseProvider {
|
|||
excludeModules?: boolean,
|
||||
excludeContents?: boolean,
|
||||
siteId?: string,
|
||||
): Promise<CoreCourseSection> {
|
||||
): Promise<CoreCourseWSSection> {
|
||||
|
||||
if (sectionId < 0) {
|
||||
throw new CoreError('Invalid section ID');
|
||||
|
@ -670,7 +670,7 @@ export class CoreCourseProvider {
|
|||
preSets?: CoreSiteWSPreSets,
|
||||
siteId?: string,
|
||||
includeStealthModules: boolean = true,
|
||||
): Promise<CoreCourseSection[]> {
|
||||
): Promise<CoreCourseWSSection[]> {
|
||||
|
||||
const site = await CoreSites.instance.getSite(siteId);
|
||||
preSets = preSets || {};
|
||||
|
@ -697,7 +697,7 @@ export class CoreCourseProvider {
|
|||
});
|
||||
}
|
||||
|
||||
let sections: CoreCourseSection[];
|
||||
let sections: CoreCourseWSSection[];
|
||||
try {
|
||||
sections = await site.read('core_course_get_contents', params, preSets);
|
||||
} catch {
|
||||
|
@ -739,12 +739,12 @@ export class CoreCourseProvider {
|
|||
* @param sections Sections.
|
||||
* @return Modules.
|
||||
*/
|
||||
getSectionsModules(sections: CoreCourseSection[]): CoreCourseModuleData[] {
|
||||
getSectionsModules(sections: CoreCourseWSSection[]): CoreCourseWSModule[] {
|
||||
if (!sections || !sections.length) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return sections.reduce((previous: CoreCourseModuleData[], section) => previous.concat(section.modules || []), []);
|
||||
return sections.reduce((previous: CoreCourseWSModule[], section) => previous.concat(section.modules || []), []);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -829,7 +829,7 @@ export class CoreCourseProvider {
|
|||
* @return Promise resolved when loaded.
|
||||
*/
|
||||
async loadModuleContents(
|
||||
module: CoreCourseModuleData,
|
||||
module: CoreCourseWSModule,
|
||||
courseId?: number,
|
||||
sectionId?: number,
|
||||
preferCache?: boolean,
|
||||
|
@ -974,7 +974,7 @@ export class CoreCourseProvider {
|
|||
* @param module The module object.
|
||||
* @return Whether the module has a view page.
|
||||
*/
|
||||
moduleHasView(module: CoreCourseModuleSummary | CoreCourseModuleData): boolean {
|
||||
moduleHasView(module: CoreCourseModuleSummary | CoreCourseWSModule): boolean {
|
||||
return !!module.url;
|
||||
}
|
||||
|
||||
|
@ -1324,7 +1324,7 @@ export type CoreCourseGetContentsParams = {
|
|||
/**
|
||||
* Data returned by core_course_get_contents WS.
|
||||
*/
|
||||
export type CoreCourseSection = {
|
||||
export type CoreCourseWSSection = {
|
||||
id: number; // Section ID.
|
||||
name: string; // Section name.
|
||||
visible?: number; // Is the section visible.
|
||||
|
@ -1334,7 +1334,7 @@ export type CoreCourseSection = {
|
|||
hiddenbynumsections?: number; // Whether is a section hidden in the course format.
|
||||
uservisible?: boolean; // Is the section visible for the user?.
|
||||
availabilityinfo?: string; // Availability information.
|
||||
modules: CoreCourseModuleData[];
|
||||
modules: CoreCourseWSModule[];
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1361,9 +1361,9 @@ export type CoreCourseGetCourseModuleWSResponse = {
|
|||
};
|
||||
|
||||
/**
|
||||
* Course module type.
|
||||
* Course module data returned by the WS.
|
||||
*/
|
||||
export type CoreCourseModuleData = {
|
||||
export type CoreCourseWSModule = {
|
||||
id: number; // Activity id.
|
||||
course?: number; // The course id.
|
||||
url?: string; // Activity url.
|
||||
|
@ -1385,7 +1385,7 @@ export type CoreCourseModuleData = {
|
|||
customdata?: string; // Custom data (JSON encoded).
|
||||
noviewlink?: boolean; // Whether the module has no view page.
|
||||
completion?: number; // Type of completion tracking: 0 means none, 1 manual, 2 automatic.
|
||||
completiondata?: CoreCourseModuleCompletionData; // Module completion data.
|
||||
completiondata?: CoreCourseModuleWSCompletionData; // Module completion data.
|
||||
contents: CoreCourseModuleContentFile[];
|
||||
contentsinfo?: { // Contents summary information.
|
||||
filescount: number; // Total number of files.
|
||||
|
@ -1399,7 +1399,7 @@ export type CoreCourseModuleData = {
|
|||
/**
|
||||
* Module completion data.
|
||||
*/
|
||||
export type CoreCourseModuleCompletionData = {
|
||||
export type CoreCourseModuleWSCompletionData = {
|
||||
state: number; // Completion state value: 0 means incomplete, 1 complete, 2 complete pass, 3 complete fail.
|
||||
timecompleted: number; // Timestamp for completion status.
|
||||
overrideby: number; // The user id who has overriden the status.
|
||||
|
|
|
@ -18,7 +18,8 @@ import { Params } from '@angular/router';
|
|||
import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
|
||||
import { CoreCourseAnyCourseData } from '@features/courses/services/courses';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { CoreCourseSection } from './course';
|
||||
import { CoreCourseWSSection } from './course';
|
||||
import { CoreCourseSection } from './course-helper';
|
||||
import { CoreCourseFormatDefaultHandler } from './handlers/default-format';
|
||||
|
||||
/**
|
||||
|
@ -38,7 +39,7 @@ export interface CoreCourseFormatHandler extends CoreDelegateHandler {
|
|||
* @param sections List of sections.
|
||||
* @return Title.
|
||||
*/
|
||||
getCourseTitle?(course: CoreCourseAnyCourseData, sections?: CoreCourseSection[]): string;
|
||||
getCourseTitle?(course: CoreCourseAnyCourseData, sections?: CoreCourseWSSection[]): string;
|
||||
|
||||
/**
|
||||
* Whether it allows seeing all sections at the same time. Defaults to true.
|
||||
|
@ -80,7 +81,7 @@ export interface CoreCourseFormatHandler extends CoreDelegateHandler {
|
|||
* @param sections List of course sections.
|
||||
* @return Whether the refresher should be displayed.
|
||||
*/
|
||||
displayRefresher?(course: CoreCourseAnyCourseData, sections: CoreCourseSection[]): boolean;
|
||||
displayRefresher?(course: CoreCourseAnyCourseData, sections: CoreCourseWSSection[]): boolean;
|
||||
|
||||
/**
|
||||
* Given a list of sections, get the "current" section that should be displayed first. Defaults to first section.
|
||||
|
@ -158,7 +159,7 @@ export interface CoreCourseFormatHandler extends CoreDelegateHandler {
|
|||
* @param sections List of sections.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateData?(course: CoreCourseAnyCourseData, sections: CoreCourseSection[]): Promise<void>;
|
||||
invalidateData?(course: CoreCourseAnyCourseData, sections: CoreCourseWSSection[]): Promise<void>;
|
||||
|
||||
/**
|
||||
* Whether the view should be refreshed when completion changes. If your course format doesn't display
|
||||
|
@ -221,7 +222,7 @@ export class CoreCourseFormatDelegateService extends CoreDelegate<CoreCourseForm
|
|||
* @param sections List of course sections.
|
||||
* @return Whether the refresher should be displayed.
|
||||
*/
|
||||
displayRefresher(course: CoreCourseAnyCourseData, sections: CoreCourseSection[]): boolean {
|
||||
displayRefresher(course: CoreCourseAnyCourseData, sections: CoreCourseWSSection[]): boolean {
|
||||
return !!this.executeFunctionOnEnabled<boolean>(course.format || '', 'displayRefresher', [course, sections]);
|
||||
}
|
||||
|
||||
|
@ -284,7 +285,7 @@ export class CoreCourseFormatDelegateService extends CoreDelegate<CoreCourseForm
|
|||
* @param sections List of sections.
|
||||
* @return Course title.
|
||||
*/
|
||||
getCourseTitle(course: CoreCourseAnyCourseData, sections?: CoreCourseSection[]): string | undefined {
|
||||
getCourseTitle(course: CoreCourseAnyCourseData, sections?: CoreCourseWSSection[]): string | undefined {
|
||||
return this.executeFunctionOnEnabled(course.format || '', 'getCourseTitle', [course, sections]);
|
||||
}
|
||||
|
||||
|
@ -346,7 +347,7 @@ export class CoreCourseFormatDelegateService extends CoreDelegate<CoreCourseForm
|
|||
* @param sections List of sections.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
async invalidateData(course: CoreCourseAnyCourseData, sections: CoreCourseSection[]): Promise<void> {
|
||||
async invalidateData(course: CoreCourseAnyCourseData, sections: CoreCourseWSSection[]): Promise<void> {
|
||||
await this.executeFunctionOnEnabled(course.format || '', 'invalidateData', [course, sections]);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,8 @@ import { Params } from '@angular/router';
|
|||
import { CoreCourseAnyCourseData, CoreCourses } from '@features/courses/services/courses';
|
||||
import { CoreNavHelper } from '@services/nav-helper';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreCourseSection } from '../course';
|
||||
import { CoreCourseWSSection } from '../course';
|
||||
import { CoreCourseSection } from '../course-helper';
|
||||
import { CoreCourseFormatHandler } from '../format-delegate';
|
||||
|
||||
/**
|
||||
|
@ -108,7 +109,7 @@ export class CoreCourseFormatDefaultHandler implements CoreCourseFormatHandler {
|
|||
* @return Whether the refresher should be displayed.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
displayRefresher?(course: CoreCourseAnyCourseData, sections: CoreCourseSection[]): boolean {
|
||||
displayRefresher?(course: CoreCourseAnyCourseData, sections: CoreCourseWSSection[]): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -157,7 +158,7 @@ export class CoreCourseFormatDefaultHandler implements CoreCourseFormatHandler {
|
|||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async invalidateData(course: CoreCourseAnyCourseData, sections: CoreCourseSection[]): Promise<void> {
|
||||
async invalidateData(course: CoreCourseAnyCourseData, sections: CoreCourseWSSection[]): Promise<void> {
|
||||
await CoreCourses.instance.invalidateCoursesByField('id', course.id);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,10 @@ import { NavigationOptions } from '@ionic/angular/providers/nav-controller';
|
|||
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '../module-delegate';
|
||||
import { CoreCourse, CoreCourseModuleBasicInfo, CoreCourseModuleData } from '../course';
|
||||
import { CoreCourse, CoreCourseModuleBasicInfo, CoreCourseWSModule } from '../course';
|
||||
import { CoreCourseAnyCourseData } from '@features/courses/services/courses';
|
||||
import { CoreCourseModule } from '../course-helper';
|
||||
import { CoreCourseUnsupportedModuleComponent } from '@features/course/components/unsupported-module/unsupported-module';
|
||||
|
||||
/**
|
||||
* Default handler used when the module doesn't have a specific implementation.
|
||||
|
@ -47,7 +49,7 @@ export class CoreCourseModuleDefaultHandler implements CoreCourseModuleHandler {
|
|||
* @return Data to render the module.
|
||||
*/
|
||||
getData(
|
||||
module: CoreCourseModuleData | CoreCourseModuleBasicInfo,
|
||||
module: CoreCourseWSModule | CoreCourseModuleBasicInfo,
|
||||
courseId: 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
|
||||
|
@ -58,7 +60,7 @@ export class CoreCourseModuleDefaultHandler implements CoreCourseModuleHandler {
|
|||
title: module.name,
|
||||
class: 'core-course-default-handler core-course-module-' + module.modname + '-handler',
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
action: (event: Event, module: CoreCourseModuleData, courseId: number, options?: NavigationOptions): void => {
|
||||
action: (event: Event, module: CoreCourseModule, courseId: number, options?: NavigationOptions): void => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
|
@ -92,10 +94,8 @@ export class CoreCourseModuleDefaultHandler implements CoreCourseModuleHandler {
|
|||
* @return The component (or promise resolved with component) to use, undefined if not found.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async getMainComponent(course: CoreCourseAnyCourseData, module: CoreCourseModuleData): Promise<Type<unknown> | undefined> {
|
||||
// We can't inject CoreCourseUnsupportedModuleComponent here due to circular dependencies.
|
||||
// Don't return anything, by default it will use CoreCourseUnsupportedModuleComponent.
|
||||
return;
|
||||
async getMainComponent(course: CoreCourseAnyCourseData, module: CoreCourseWSModule): Promise<Type<unknown> | undefined> {
|
||||
return CoreCourseUnsupportedModuleComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,10 +21,11 @@ import { CoreSite } from '@classes/site';
|
|||
import { CoreCourseModuleDefaultHandler } from './handlers/default-module';
|
||||
import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
|
||||
import { CoreCourseAnyCourseData } from '@features/courses/services/courses';
|
||||
import { CoreCourse, CoreCourseModuleBasicInfo, CoreCourseModuleData } from './course';
|
||||
import { CoreCourse, CoreCourseModuleBasicInfo, CoreCourseWSModule } from './course';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { NavigationOptions } from '@ionic/angular/providers/nav-controller';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { CoreCourseModule } from './course-helper';
|
||||
|
||||
/**
|
||||
* Interface that all course module handlers must implement.
|
||||
|
@ -52,7 +53,7 @@ export interface CoreCourseModuleHandler extends CoreDelegateHandler {
|
|||
* @return Data to render the module.
|
||||
*/
|
||||
getData(
|
||||
module: CoreCourseModuleData | CoreCourseModuleBasicInfo,
|
||||
module: CoreCourseWSModule | CoreCourseModuleBasicInfo,
|
||||
courseId: number,
|
||||
sectionId?: number,
|
||||
forCoursePage?: boolean,
|
||||
|
@ -67,7 +68,7 @@ export interface CoreCourseModuleHandler extends CoreDelegateHandler {
|
|||
* @param module The module object.
|
||||
* @return Promise resolved with component to use, undefined if not found.
|
||||
*/
|
||||
getMainComponent(course: CoreCourseAnyCourseData, module: CoreCourseModuleData): Promise<Type<unknown> | undefined>;
|
||||
getMainComponent(course: CoreCourseAnyCourseData, module: CoreCourseWSModule): Promise<Type<unknown> | undefined>;
|
||||
|
||||
/**
|
||||
* Whether to display the course refresher in single activity course format. If it returns false, a refresher must be
|
||||
|
@ -159,7 +160,7 @@ export interface CoreCourseModuleHandlerData {
|
|||
* @param options Options for the navigation.
|
||||
* @param params Params for the new page.
|
||||
*/
|
||||
action?(event: Event, module: CoreCourseModuleData, courseId: number, options?: NavigationOptions, params?: Params): void;
|
||||
action?(event: Event, module: CoreCourseModule, courseId: number, options?: NavigationOptions, params?: Params): void;
|
||||
|
||||
/**
|
||||
* Updates the status of the module.
|
||||
|
@ -229,7 +230,7 @@ export interface CoreCourseModuleHandlerButton {
|
|||
* @param module The module object.
|
||||
* @param courseId The course ID.
|
||||
*/
|
||||
action(event: Event, module: CoreCourseModuleData, courseId: number): void;
|
||||
action(event: Event, module: CoreCourseModule, courseId: number): void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -252,7 +253,7 @@ export class CoreCourseModuleDelegateService extends CoreDelegate<CoreCourseModu
|
|||
* @param module The module object.
|
||||
* @return Promise resolved with component to use, undefined if not found.
|
||||
*/
|
||||
async getMainComponent(course: CoreCourseAnyCourseData, module: CoreCourseModuleData): Promise<Type<unknown> | undefined> {
|
||||
async getMainComponent(course: CoreCourseAnyCourseData, module: CoreCourseWSModule): Promise<Type<unknown> | undefined> {
|
||||
try {
|
||||
return await this.executeFunctionOnEnabled<Type<unknown>>(module.modname, 'getMainComponent', [course, module]);
|
||||
} catch (error) {
|
||||
|
@ -272,7 +273,7 @@ export class CoreCourseModuleDelegateService extends CoreDelegate<CoreCourseModu
|
|||
*/
|
||||
getModuleDataFor(
|
||||
modname: string,
|
||||
module: CoreCourseModuleData | CoreCourseModuleBasicInfo,
|
||||
module: CoreCourseWSModule | CoreCourseModuleBasicInfo,
|
||||
courseId: number,
|
||||
sectionId?: number,
|
||||
forCoursePage?: boolean,
|
||||
|
|
|
@ -22,7 +22,7 @@ import { CoreFilepool, CoreFilepoolComponentFileEventData } from '@services/file
|
|||
import { CoreSites } from '@services/sites';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreCourse, CoreCourseModuleContentFile, CoreCourseModuleData } from './course';
|
||||
import { CoreCourse, CoreCourseModuleContentFile, CoreCourseWSModule } from './course';
|
||||
import { CoreCache } from '@classes/cache';
|
||||
import { CoreSiteWSPreSets } from '@classes/site';
|
||||
import { CoreConstants } from '@/core/constants';
|
||||
|
@ -92,7 +92,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* @param courseId Course ID the module belongs to.
|
||||
* @return Promise resolved with boolean: whether the module can use check updates WS.
|
||||
*/
|
||||
async canModuleUseCheckUpdates(module: CoreCourseModuleData, courseId: number): Promise<boolean> {
|
||||
async canModuleUseCheckUpdates(module: CoreCourseWSModule, courseId: number): Promise<boolean> {
|
||||
const handler = this.getPrefetchHandlerFor(module);
|
||||
|
||||
if (!handler) {
|
||||
|
@ -122,7 +122,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* @param courseId Course ID the modules belong to.
|
||||
* @return Promise resolved with the lists.
|
||||
*/
|
||||
protected async createToCheckList(modules: CoreCourseModuleData[], courseId: number): Promise<ToCheckList> {
|
||||
protected async createToCheckList(modules: CoreCourseWSModule[], courseId: number): Promise<ToCheckList> {
|
||||
const result: ToCheckList = {
|
||||
toCheck: [],
|
||||
cannotUse: [],
|
||||
|
@ -169,7 +169,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* @param canCheck True if updates can be checked using core_course_check_updates.
|
||||
* @return Module status.
|
||||
*/
|
||||
determineModuleStatus(module: CoreCourseModuleData, status: string, canCheck?: boolean): string {
|
||||
determineModuleStatus(module: CoreCourseWSModule, status: string, canCheck?: boolean): string {
|
||||
const handler = this.getPrefetchHandlerFor(module);
|
||||
const siteId = CoreSites.instance.getCurrentSiteId();
|
||||
|
||||
|
@ -202,7 +202,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* @param dirPath Path of the directory where to store all the content files.
|
||||
* @return Promise resolved when finished.
|
||||
*/
|
||||
async downloadModule(module: CoreCourseModuleData, courseId: number, dirPath?: string): Promise<void> {
|
||||
async downloadModule(module: CoreCourseWSModule, courseId: number, dirPath?: string): Promise<void> {
|
||||
// Check if the module has a prefetch handler.
|
||||
const handler = this.getPrefetchHandlerFor(module);
|
||||
|
||||
|
@ -223,7 +223,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
|
||||
* checked for that module in the current site.
|
||||
*/
|
||||
async getCourseUpdates(modules: CoreCourseModuleData[], courseId: number): Promise<CourseUpdates> {
|
||||
async getCourseUpdates(modules: CoreCourseWSModule[], courseId: number): Promise<CourseUpdates> {
|
||||
if (!this.canCheckUpdates()) {
|
||||
throw new CoreError('Cannot check course updates.');
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* checked for that module in the site.
|
||||
*/
|
||||
protected async fetchCourseUpdates(
|
||||
modules: CoreCourseModuleData[],
|
||||
modules: CoreCourseWSModule[],
|
||||
courseId: number,
|
||||
siteId: string,
|
||||
): Promise<CourseUpdates> {
|
||||
|
@ -361,7 +361,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* @param courseId Course ID the modules belong to.
|
||||
* @return Promise resolved with the size.
|
||||
*/
|
||||
async getDownloadSize(modules: CoreCourseModuleData[], courseId: number): Promise<CoreFileSizeSum> {
|
||||
async getDownloadSize(modules: CoreCourseWSModule[], courseId: number): Promise<CoreFileSizeSum> {
|
||||
// Get the status of each module.
|
||||
const data = await this.getModulesStatus(modules, courseId);
|
||||
|
||||
|
@ -389,7 +389,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* @param single True if we're downloading a single module, false if we're downloading a whole section.
|
||||
* @return Promise resolved with the size.
|
||||
*/
|
||||
async getModuleDownloadSize(module: CoreCourseModuleData, courseId: number, single?: boolean): Promise<CoreFileSizeSum> {
|
||||
async getModuleDownloadSize(module: CoreCourseWSModule, courseId: number, single?: boolean): Promise<CoreFileSizeSum> {
|
||||
const handler = this.getPrefetchHandlerFor(module);
|
||||
|
||||
if (!handler) {
|
||||
|
@ -427,7 +427,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* @param courseId Course ID the module belongs to.
|
||||
* @return Promise resolved with the size.
|
||||
*/
|
||||
async getModuleDownloadedSize(module: CoreCourseModuleData, courseId: number): Promise<number> {
|
||||
async getModuleDownloadedSize(module: CoreCourseWSModule, courseId: number): Promise<number> {
|
||||
const handler = this.getPrefetchHandlerFor(module);
|
||||
if (!handler) {
|
||||
return 0;
|
||||
|
@ -493,7 +493,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* @param courseId Course ID the module belongs to.
|
||||
* @return Promise resolved with the total size (0 if unknown)
|
||||
*/
|
||||
async getModuleStoredSize(module: CoreCourseModuleData, courseId: number): Promise<number> {
|
||||
async getModuleStoredSize(module: CoreCourseWSModule, courseId: number): Promise<number> {
|
||||
let downloadedSize = await this.getModuleDownloadedSize(module, courseId);
|
||||
|
||||
if (isNaN(downloadedSize)) {
|
||||
|
@ -522,7 +522,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* @return Promise resolved with the list of files.
|
||||
*/
|
||||
async getModuleFiles(
|
||||
module: CoreCourseModuleData,
|
||||
module: CoreCourseWSModule,
|
||||
courseId: number,
|
||||
): Promise<(CoreWSExternalFile | CoreCourseModuleContentFile)[]> {
|
||||
const handler = this.getPrefetchHandlerFor(module);
|
||||
|
@ -552,7 +552,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* @return Promise resolved with the status.
|
||||
*/
|
||||
async getModuleStatus(
|
||||
module: CoreCourseModuleData,
|
||||
module: CoreCourseWSModule,
|
||||
courseId: number,
|
||||
updates?: CourseUpdates | false,
|
||||
refresh?: boolean,
|
||||
|
@ -597,7 +597,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
*/
|
||||
protected async calculateModuleStatus(
|
||||
handler: CoreCourseModulePrefetchHandler,
|
||||
module: CoreCourseModuleData,
|
||||
module: CoreCourseWSModule,
|
||||
courseId: number,
|
||||
updates?: CourseUpdates | false,
|
||||
sectionId?: number,
|
||||
|
@ -696,7 +696,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* @return Promise resolved with the data.
|
||||
*/
|
||||
async getModulesStatus(
|
||||
modules: CoreCourseModuleData[],
|
||||
modules: CoreCourseWSModule[],
|
||||
courseId: number,
|
||||
sectionId?: number,
|
||||
refresh?: boolean,
|
||||
|
@ -767,7 +767,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* @return Promise resolved with the data.
|
||||
*/
|
||||
protected async getModuleStatusAndDownloadTime(
|
||||
module: CoreCourseModuleData,
|
||||
module: CoreCourseWSModule,
|
||||
courseId: number,
|
||||
): Promise<{ status: string; downloadTime?: number }> {
|
||||
const handler = this.getPrefetchHandlerFor(module);
|
||||
|
@ -813,7 +813,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* @return Promise resolved with the updates.
|
||||
*/
|
||||
async getModuleUpdates(
|
||||
module: CoreCourseModuleData,
|
||||
module: CoreCourseWSModule,
|
||||
courseId: number,
|
||||
ignoreCache?: boolean,
|
||||
siteId?: string,
|
||||
|
@ -878,7 +878,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* @param module The module to work on.
|
||||
* @return Prefetch handler.
|
||||
*/
|
||||
getPrefetchHandlerFor(module: CoreCourseModuleData): CoreCourseModulePrefetchHandler | undefined {
|
||||
getPrefetchHandlerFor(module: CoreCourseWSModule): CoreCourseModulePrefetchHandler | undefined {
|
||||
return this.getHandler(module.modname, true);
|
||||
}
|
||||
|
||||
|
@ -904,7 +904,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* @param courseId Course ID.
|
||||
* @return Promise resolved when modules are invalidated.
|
||||
*/
|
||||
async invalidateModules(modules: CoreCourseModuleData[], courseId: number): Promise<void> {
|
||||
async invalidateModules(modules: CoreCourseWSModule[], courseId: number): Promise<void> {
|
||||
|
||||
const promises = modules.map(async (module) => {
|
||||
const handler = this.getPrefetchHandlerFor(module);
|
||||
|
@ -930,7 +930,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
*
|
||||
* @param module Module to be invalidated.
|
||||
*/
|
||||
invalidateModuleStatusCache(module: CoreCourseModuleData): void {
|
||||
invalidateModuleStatusCache(module: CoreCourseWSModule): void {
|
||||
const handler = this.getPrefetchHandlerFor(module);
|
||||
if (handler) {
|
||||
this.statusCache.invalidate(CoreFilepool.instance.getPackageId(handler.component, module.id));
|
||||
|
@ -970,7 +970,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* @param courseId Course ID the module belongs to.
|
||||
* @return Promise resolved with true if downloadable, false otherwise.
|
||||
*/
|
||||
async isModuleDownloadable(module: CoreCourseModuleData, courseId: number): Promise<boolean> {
|
||||
async isModuleDownloadable(module: CoreCourseWSModule, courseId: number): Promise<boolean> {
|
||||
if (module.uservisible === false) {
|
||||
// Module isn't visible by the user, cannot be downloaded.
|
||||
return false;
|
||||
|
@ -1011,7 +1011,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* @param updates Result of getCourseUpdates.
|
||||
* @return Promise resolved with boolean: whether the module has updates.
|
||||
*/
|
||||
async moduleHasUpdates(module: CoreCourseModuleData, courseId: number, updates: CourseUpdates): Promise<boolean> {
|
||||
async moduleHasUpdates(module: CoreCourseWSModule, courseId: number, updates: CourseUpdates): Promise<boolean> {
|
||||
const handler = this.getPrefetchHandlerFor(module);
|
||||
const moduleUpdates = updates[module.id];
|
||||
|
||||
|
@ -1044,7 +1044,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* @param single True if we're downloading a single module, false if we're downloading a whole section.
|
||||
* @return Promise resolved when finished.
|
||||
*/
|
||||
async prefetchModule(module: CoreCourseModuleData, courseId: number, single?: boolean): Promise<void> {
|
||||
async prefetchModule(module: CoreCourseWSModule, courseId: number, single?: boolean): Promise<void> {
|
||||
const handler = this.getPrefetchHandlerFor(module);
|
||||
if (!handler) {
|
||||
return;
|
||||
|
@ -1062,7 +1062,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* @param courseId Course ID the module belongs to.
|
||||
* @return Promise resolved when finished.
|
||||
*/
|
||||
syncModules(modules: CoreCourseModuleData[], courseId: number): Promise<unknown> {
|
||||
syncModules(modules: CoreCourseWSModule[], courseId: number): Promise<unknown> {
|
||||
return Promise.all(modules.map(async (module) => {
|
||||
await this.syncModule(module, courseId);
|
||||
|
||||
|
@ -1078,7 +1078,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* @param courseId Course ID the module belongs to.
|
||||
* @return Promise resolved when finished.
|
||||
*/
|
||||
async syncModule<T = unknown>(module: CoreCourseModuleData, courseId: number): Promise<T | undefined> {
|
||||
async syncModule<T = unknown>(module: CoreCourseWSModule, courseId: number): Promise<T | undefined> {
|
||||
const handler = this.getPrefetchHandlerFor(module);
|
||||
if (!handler?.sync) {
|
||||
return;
|
||||
|
@ -1104,7 +1104,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
*/
|
||||
async prefetchModules(
|
||||
id: string,
|
||||
modules: CoreCourseModuleData[],
|
||||
modules: CoreCourseWSModule[],
|
||||
courseId: number,
|
||||
onProgress?: CoreCourseModulesProgressFunction,
|
||||
): Promise<void> {
|
||||
|
@ -1181,7 +1181,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
|||
* @param courseId Course ID the module belongs to.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
async removeModuleFiles(module: CoreCourseModuleData, courseId: number): Promise<void> {
|
||||
async removeModuleFiles(module: CoreCourseWSModule, courseId: number): Promise<void> {
|
||||
const handler = this.getPrefetchHandlerFor(module);
|
||||
const siteId = CoreSites.instance.getCurrentSiteId();
|
||||
|
||||
|
@ -1393,7 +1393,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler {
|
|||
* @param single True if we're downloading a single module, false if we're downloading a whole section.
|
||||
* @return Promise resolved with the size.
|
||||
*/
|
||||
getDownloadSize(module: CoreCourseModuleData, courseId: number, single?: boolean): Promise<CoreFileSizeSum>;
|
||||
getDownloadSize(module: CoreCourseWSModule, courseId: number, single?: boolean): Promise<CoreFileSizeSum>;
|
||||
|
||||
/**
|
||||
* Prefetch a module.
|
||||
|
@ -1404,7 +1404,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler {
|
|||
* @param dirPath Path of the directory where to store all the content files.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
prefetch(module: CoreCourseModuleData, courseId?: number, single?: boolean, dirPath?: string): Promise<void>;
|
||||
prefetch(module: CoreCourseWSModule, courseId?: number, single?: boolean, dirPath?: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Download the module.
|
||||
|
@ -1414,7 +1414,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler {
|
|||
* @param dirPath Path of the directory where to store all the content files.
|
||||
* @return Promise resolved when all content is downloaded.
|
||||
*/
|
||||
download(module: CoreCourseModuleData, courseId: number, dirPath?: string): Promise<void>;
|
||||
download(module: CoreCourseWSModule, courseId: number, dirPath?: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Invalidate the prefetched content.
|
||||
|
@ -1434,7 +1434,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler {
|
|||
* @param courseId Course ID the module belongs to.
|
||||
* @return Whether the module can use check_updates. The promise should never be rejected.
|
||||
*/
|
||||
canUseCheckUpdates?(module: CoreCourseModuleData, courseId: number): Promise<boolean>;
|
||||
canUseCheckUpdates?(module: CoreCourseWSModule, courseId: number): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Return the status to show based on current status. E.g. a module might want to show outdated instead of downloaded.
|
||||
|
@ -1445,7 +1445,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler {
|
|||
* @param canCheck Whether the site allows checking for updates.
|
||||
* @return Status to display.
|
||||
*/
|
||||
determineStatus?(module: CoreCourseModuleData, status: string, canCheck: boolean): string;
|
||||
determineStatus?(module: CoreCourseWSModule, status: string, canCheck: boolean): string;
|
||||
|
||||
/**
|
||||
* Get the downloaded size of a module. If not defined, we'll use getFiles to calculate it (it can be slow).
|
||||
|
@ -1454,7 +1454,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler {
|
|||
* @param courseId Course ID the module belongs to.
|
||||
* @return Size, or promise resolved with the size.
|
||||
*/
|
||||
getDownloadedSize?(module: CoreCourseModuleData, courseId: number): Promise<number>;
|
||||
getDownloadedSize?(module: CoreCourseWSModule, courseId: number): Promise<number>;
|
||||
|
||||
/**
|
||||
* Get the list of files of the module. If not defined, we'll assume they are in module.contents.
|
||||
|
@ -1463,7 +1463,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler {
|
|||
* @param courseId Course ID the module belongs to.
|
||||
* @return List of files, or promise resolved with the files.
|
||||
*/
|
||||
getFiles?(module: CoreCourseModuleData, courseId: number): Promise<(CoreWSExternalFile | CoreCourseModuleContentFile)[]>;
|
||||
getFiles?(module: CoreCourseWSModule, courseId: number): Promise<(CoreWSExternalFile | CoreCourseModuleContentFile)[]>;
|
||||
|
||||
/**
|
||||
* Check if a certain module has updates based on the result of check updates.
|
||||
|
@ -1473,7 +1473,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler {
|
|||
* @param moduleUpdates List of updates for the module.
|
||||
* @return Whether the module has updates. The promise should never be rejected.
|
||||
*/
|
||||
hasUpdates?(module: CoreCourseModuleData, courseId: number, moduleUpdates: false | CheckUpdatesWSInstance): Promise<boolean>;
|
||||
hasUpdates?(module: CoreCourseWSModule, courseId: number, moduleUpdates: false | CheckUpdatesWSInstance): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Invalidate WS calls needed to determine module status (usually, to check if module is downloadable).
|
||||
|
@ -1483,7 +1483,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler {
|
|||
* @param courseId Course ID the module belongs to.
|
||||
* @return Promise resolved when invalidated.
|
||||
*/
|
||||
invalidateModule?(module: CoreCourseModuleData, courseId: number): Promise<void>;
|
||||
invalidateModule?(module: CoreCourseWSModule, courseId: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* Check if a module can be downloaded. If the function is not defined, we assume that all modules are downloadable.
|
||||
|
@ -1492,7 +1492,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler {
|
|||
* @param courseId Course ID the module belongs to.
|
||||
* @return Whether the module can be downloaded. The promise should never be rejected.
|
||||
*/
|
||||
isDownloadable?(module: CoreCourseModuleData, courseId: number): Promise<boolean>;
|
||||
isDownloadable?(module: CoreCourseWSModule, courseId: number): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Load module contents in module.contents if they aren't loaded already. This is meant for resources.
|
||||
|
@ -1501,7 +1501,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler {
|
|||
* @param courseId Course ID the module belongs to.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
loadContents?(module: CoreCourseModuleData, courseId: number): Promise<void>;
|
||||
loadContents?(module: CoreCourseWSModule, courseId: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* Remove module downloaded files. If not defined, we'll use getFiles to remove them (slow).
|
||||
|
@ -1510,7 +1510,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler {
|
|||
* @param courseId Course ID the module belongs to.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
removeFiles?(module: CoreCourseModuleData, courseId: number): Promise<void>;
|
||||
removeFiles?(module: CoreCourseWSModule, courseId: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* Sync a module.
|
||||
|
@ -1520,12 +1520,12 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler {
|
|||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
sync?<T = unknown>(module: CoreCourseModuleData, courseId: number, siteId?: string): Promise<T>;
|
||||
sync?<T = unknown>(module: CoreCourseWSModule, courseId: number, siteId?: string): Promise<T>;
|
||||
}
|
||||
|
||||
type ToCheckList = {
|
||||
toCheck: CheckUpdatesToCheckWSParam[];
|
||||
cannotUse: CoreCourseModuleData[];
|
||||
cannotUse: CoreCourseWSModule[];
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1539,10 +1539,10 @@ type CourseUpdates = Record<number, false | CheckUpdatesWSInstance>;
|
|||
export type CoreCourseModulesStatus = {
|
||||
total: number; // Number of modules.
|
||||
status: string; // Status of the list of modules.
|
||||
[CoreConstants.NOT_DOWNLOADED]: CoreCourseModuleData[]; // Modules with state NOT_DOWNLOADED.
|
||||
[CoreConstants.DOWNLOADED]: CoreCourseModuleData[]; // Modules with state DOWNLOADED.
|
||||
[CoreConstants.DOWNLOADING]: CoreCourseModuleData[]; // Modules with state DOWNLOADING.
|
||||
[CoreConstants.OUTDATED]: CoreCourseModuleData[]; // Modules with state OUTDATED.
|
||||
[CoreConstants.NOT_DOWNLOADED]: CoreCourseWSModule[]; // Modules with state NOT_DOWNLOADED.
|
||||
[CoreConstants.DOWNLOADED]: CoreCourseWSModule[]; // Modules with state DOWNLOADED.
|
||||
[CoreConstants.DOWNLOADING]: CoreCourseWSModule[]; // Modules with state DOWNLOADING.
|
||||
[CoreConstants.OUTDATED]: CoreCourseWSModule[]; // Modules with state OUTDATED.
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,7 @@ import { ActivatedRoute } from '@angular/router';
|
|||
import { IonRefresher, NavController } from '@ionic/angular';
|
||||
|
||||
import { CoreSite, CoreSiteConfig } from '@classes/site';
|
||||
import { CoreCourse, CoreCourseModuleBasicInfo, CoreCourseSection } from '@features/course/services/course';
|
||||
import { CoreCourse, CoreCourseModuleBasicInfo, CoreCourseWSSection } from '@features/course/services/course';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreSiteHome } from '@features/sitehome/services/sitehome';
|
||||
|
@ -40,7 +40,7 @@ export class CoreSiteHomeIndexPage implements OnInit, OnDestroy {
|
|||
@ViewChild(CoreBlockCourseBlocksComponent) courseBlocksComponent?: CoreBlockCourseBlocksComponent;
|
||||
|
||||
dataLoaded = false;
|
||||
section?: CoreCourseSection & {
|
||||
section?: CoreCourseWSSection & {
|
||||
hasContent?: boolean;
|
||||
};
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import { Injectable } from '@angular/core';
|
|||
import { CoreSites } from '@services/sites';
|
||||
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { CoreCourse, CoreCourseSection } from '../../course/services/course';
|
||||
import { CoreCourse } from '../../course/services/course';
|
||||
import { CoreCourses } from '../../courses/services/courses';
|
||||
import { AddonModForum, AddonModForumData } from '@/addons/mod/forum/services/forum';
|
||||
|
||||
|
@ -90,8 +90,7 @@ export class CoreSiteHomeProvider {
|
|||
const preSets: CoreSiteWSPreSets = { emergencyCache: false };
|
||||
|
||||
try {
|
||||
const sections: CoreCourseSection[] =
|
||||
await CoreCourse.instance.getSections(siteHomeId, false, true, preSets, site.id);
|
||||
const sections = await CoreCourse.instance.getSections(siteHomeId, false, true, preSets, site.id);
|
||||
|
||||
if (!sections || !sections.length) {
|
||||
throw Error('No sections found');
|
||||
|
|
Loading…
Reference in New Issue