MOBILE-3833 course: Review course module optional property
parent
5794b66cd9
commit
27c7a7a952
|
@ -28,7 +28,6 @@ import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/
|
|||
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
||||
import { CoreWSFile } from '@services/ws';
|
||||
import { AddonModAssignHelper, AddonModAssignSubmissionFormatted } from '../assign-helper';
|
||||
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreGroups } from '@services/groups';
|
||||
|
@ -243,7 +242,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
|
|||
|
||||
promises.push(this.prefetchSubmissions(assign, courseId, module.id, userId, siteId));
|
||||
|
||||
promises.push(CoreCourseHelper.getModuleCourseIdByInstance(assign.id, 'assign', siteId));
|
||||
promises.push(CoreCourse.getModuleBasicInfoByInstance(assign.id, 'assign', siteId));
|
||||
// Get course data, needed to determine upload max size if it's configured to be course limit.
|
||||
promises.push(CoreUtils.ignoreErrors(CoreCourses.getCourseByField('id', courseId, siteId)));
|
||||
|
||||
|
@ -515,7 +514,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
|
|||
* @return Promise resolved when done.
|
||||
*/
|
||||
sync(module: CoreCourseAnyModuleData, courseId: number, siteId?: string): Promise<AddonModAssignSyncResult> {
|
||||
return AddonModAssignSync.syncAssign(module.instance!, siteId);
|
||||
return AddonModAssignSync.syncAssign(module.instance, siteId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ export class AddonModChoicePrefetchHandlerService extends CoreCourseActivityPref
|
|||
* @return Promise resolved when done.
|
||||
*/
|
||||
sync(module: CoreCourseAnyModuleData, courseId: number, siteId?: string): Promise<AddonModChoiceSyncResult> {
|
||||
return AddonModChoiceSync.syncChoice(module.instance!, undefined, siteId);
|
||||
return AddonModChoiceSync.syncChoice(module.instance, undefined, siteId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet
|
|||
async invalidateModule(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
|
||||
const promises: Promise<void>[] = [];
|
||||
promises.push(AddonModData.invalidateDatabaseData(courseId));
|
||||
promises.push(AddonModData.invalidateDatabaseAccessInformationData(module.instance!));
|
||||
promises.push(AddonModData.invalidateDatabaseAccessInformationData(module.instance));
|
||||
|
||||
await Promise.all(promises);
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet
|
|||
*/
|
||||
async sync(module: CoreCourseAnyModuleData, courseId: number, siteId?: string): Promise<AddonModDataSyncResult> {
|
||||
const promises = [
|
||||
AddonModDataSync.syncDatabase(module.instance!, siteId),
|
||||
AddonModDataSync.syncDatabase(module.instance, siteId),
|
||||
AddonModDataSync.syncRatings(module.id, true, siteId),
|
||||
];
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ export class AddonModFeedbackPrefetchHandlerService extends CoreCourseActivityPr
|
|||
* @inheritdoc
|
||||
*/
|
||||
sync(module: CoreCourseAnyModuleData, courseId: number, siteId?: string): Promise<AddonModFeedbackSyncResult> {
|
||||
return AddonModFeedbackSync.syncFeedback(module.instance!, siteId);
|
||||
return AddonModFeedbackSync.syncFeedback(module.instance, siteId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ export class AddonModFolderIndexComponent extends CoreCourseModuleMainResourceCo
|
|||
await this.loadContent();
|
||||
|
||||
try {
|
||||
await AddonModFolder.logView(this.module.instance!, this.module.name);
|
||||
await AddonModFolder.logView(this.module.instance, this.module.name);
|
||||
CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata);
|
||||
} catch {
|
||||
// Ignore errors.
|
||||
|
|
|
@ -320,8 +320,8 @@ export class AddonModForumPrefetchHandlerService extends CoreCourseActivityPrefe
|
|||
): Promise<AddonModForumSyncResult> {
|
||||
const promises: Promise<AddonModForumSyncResult>[] = [];
|
||||
|
||||
promises.push(AddonModForumSync.syncForumDiscussions(module.instance!, undefined, siteId));
|
||||
promises.push(AddonModForumSync.syncForumReplies(module.instance!, undefined, siteId));
|
||||
promises.push(AddonModForumSync.syncForumDiscussions(module.instance, undefined, siteId));
|
||||
promises.push(AddonModForumSync.syncForumReplies(module.instance, undefined, siteId));
|
||||
promises.push(AddonModForumSync.syncRatings(module.id, undefined, true, siteId));
|
||||
|
||||
const results = await Promise.all(promises);
|
||||
|
|
|
@ -219,7 +219,7 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr
|
|||
*/
|
||||
async sync(module: CoreCourseAnyModuleData, courseId: number, siteId?: string): Promise<AddonModGlossarySyncResult> {
|
||||
const results = await Promise.all([
|
||||
AddonModGlossarySync.syncGlossaryEntries(module.instance!, undefined, siteId),
|
||||
AddonModGlossarySync.syncGlossaryEntries(module.instance, undefined, siteId),
|
||||
AddonModGlossarySync.syncRatings(module.id, undefined, siteId),
|
||||
]);
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ export class AddonModImscpIndexComponent extends CoreCourseModuleMainResourceCom
|
|||
await this.loadContent();
|
||||
|
||||
try {
|
||||
await AddonModImscp.logView(this.module.instance!, this.module.name);
|
||||
await AddonModImscp.logView(this.module.instance, this.module.name);
|
||||
CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata);
|
||||
} catch {
|
||||
// Ignore errors.
|
||||
|
|
|
@ -537,7 +537,7 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref
|
|||
* @return Promise resolved when done.
|
||||
*/
|
||||
sync(module: CoreCourseAnyModuleData, courseId: number, siteId?: string): Promise<AddonModLessonSyncResult> {
|
||||
return AddonModLessonSync.syncLesson(module.instance!, false, false, siteId);
|
||||
return AddonModLessonSync.syncLesson(module.instance, false, false, siteId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComp
|
|||
await this.loadContent();
|
||||
|
||||
try {
|
||||
await AddonModPage.logView(this.module.instance!, this.module.name);
|
||||
await AddonModPage.logView(this.module.instance, this.module.name);
|
||||
CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata);
|
||||
} catch {
|
||||
// Ignore errors.
|
||||
|
|
|
@ -208,7 +208,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
|
|||
// Invalidate the calls required to check if a quiz is downloadable.
|
||||
await Promise.all([
|
||||
AddonModQuiz.invalidateQuizData(courseId),
|
||||
AddonModQuiz.invalidateUserAttemptsForUser(module.instance!),
|
||||
AddonModQuiz.invalidateUserAttemptsForUser(module.instance),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource
|
|||
|
||||
await this.loadContent();
|
||||
try {
|
||||
await AddonModResource.logView(this.module.instance!, this.module.name);
|
||||
await AddonModResource.logView(this.module.instance, this.module.name);
|
||||
CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata);
|
||||
} catch {
|
||||
// Ignore errors.
|
||||
|
|
|
@ -202,7 +202,7 @@ export class AddonModResourceHelperProvider {
|
|||
);
|
||||
|
||||
try {
|
||||
await AddonModResource.logView(module.instance!, module.name);
|
||||
await AddonModResource.logView(module.instance, module.name);
|
||||
CoreCourse.checkModuleCompletion(courseId, module.completiondata);
|
||||
} catch {
|
||||
// Ignore errors.
|
||||
|
|
|
@ -107,7 +107,7 @@ export class AddonModSurveyPrefetchHandlerService extends CoreCourseActivityPref
|
|||
* @inheritdoc
|
||||
*/
|
||||
sync(module: CoreCourseAnyModuleData, courseId: number, siteId?: string): Promise<AddonModSurveySyncResult> {
|
||||
return AddonModSurveySync.syncSurvey(module.instance!, undefined, siteId);
|
||||
return AddonModSurveySync.syncSurvey(module.instance, undefined, siteId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo
|
|||
*/
|
||||
protected async logView(): Promise<void> {
|
||||
try {
|
||||
await AddonModUrl.logView(this.module.instance!, this.module.name);
|
||||
await AddonModUrl.logView(this.module.instance, this.module.name);
|
||||
CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata);
|
||||
} catch {
|
||||
// Ignore errors.
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/activity-prefetch-handler';
|
||||
import { CoreCourseAnyModuleData } from '@features/course/services/course';
|
||||
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
||||
import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreGroups } from '@services/groups';
|
||||
import { CoreFileSizeSum, CorePluginFileDelegate } from '@services/plugin-file-delegate';
|
||||
|
@ -190,7 +189,7 @@ export class AddonModWikiPrefetchHandlerService extends CoreCourseActivityPrefet
|
|||
|
||||
// Fetch info to provide wiki links.
|
||||
promises.push(AddonModWiki.getWiki(courseId, module.id, { siteId }).then((wiki) =>
|
||||
CoreCourseHelper.getModuleCourseIdByInstance(wiki.id, 'wiki', siteId)));
|
||||
CoreCourse.getModuleBasicInfoByInstance(wiki.id, 'wiki', siteId)));
|
||||
|
||||
// Get related page files and fetch them.
|
||||
promises.push(this.getFiles(module, courseId, single, siteId).then((files) =>
|
||||
|
@ -203,7 +202,7 @@ export class AddonModWikiPrefetchHandlerService extends CoreCourseActivityPrefet
|
|||
* @inheritdoc
|
||||
*/
|
||||
sync(module: CoreCourseAnyModuleData, courseId: number, siteId?: string): Promise<AddonModWikiSyncWikiResult> {
|
||||
return AddonModWikiSync.syncWiki(module.instance!, module.course, module.id, siteId);
|
||||
return AddonModWikiSync.syncWiki(module.instance, module.course, module.id, siteId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca
|
|||
this.editorExtraParams.id = this.submissionId;
|
||||
}
|
||||
|
||||
this.workshopId = this.module.instance!;
|
||||
this.workshopId = this.module.instance;
|
||||
this.componentId = this.module.id;
|
||||
|
||||
if (!this.isDestroyed) {
|
||||
|
|
|
@ -379,7 +379,7 @@ export class AddonModWorkshopPrefetchHandlerService extends CoreCourseActivityPr
|
|||
* @inheritdoc
|
||||
*/
|
||||
async sync(module: CoreCourseAnyModuleData, courseId: number, siteId?: string): Promise<AddonModDataSyncResult> {
|
||||
return AddonModWorkshopSync.syncWorkshop(module.instance!, siteId);
|
||||
return AddonModWorkshopSync.syncWorkshop(module.instance, siteId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreCourseAnyModuleData } from '../services/course';
|
||||
import { CoreCourseModuleData } from '../services/course-helper';
|
||||
import { CoreCourseModuleMainResourceComponent } from './main-resource-component';
|
||||
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@ export class CoreCourseModuleMainActivityPage<ActivityType extends CoreCourseMod
|
|||
activityComponent?: ActivityType;
|
||||
|
||||
title!: string;
|
||||
module!: CoreCourseAnyModuleData;
|
||||
module!: CoreCourseModuleData;
|
||||
courseId!: number;
|
||||
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@ export class CoreCourseModuleMainActivityPage<ActivityType extends CoreCourseMod
|
|||
*/
|
||||
ngOnInit(): void {
|
||||
try {
|
||||
this.module = CoreNavigator.getRequiredRouteParam<CoreCourseAnyModuleData>('module');
|
||||
this.module = CoreNavigator.getRequiredRouteParam<CoreCourseModuleData>('module');
|
||||
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||
} catch (error) {
|
||||
CoreDomUtils.showErrorModal(error);
|
||||
|
|
|
@ -1429,26 +1429,6 @@ export class CoreCourseHelperProvider {
|
|||
return CoreConstants.ICON_DOWNLOADING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the course ID from a module instance ID, showing an error message if it can't be retrieved.
|
||||
*
|
||||
* @param id Instance ID.
|
||||
* @param module Name of the module. E.g. 'glossary'.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with the module's course ID.
|
||||
*/
|
||||
async getModuleCourseIdByInstance(id: number, module: string, siteId?: string): Promise<number> {
|
||||
try {
|
||||
const cm = await CoreCourse.getModuleBasicInfoByInstance(id, module, siteId);
|
||||
|
||||
return cm.course;
|
||||
} catch (error) {
|
||||
CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true);
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get prefetch info for a module.
|
||||
*
|
||||
|
@ -1629,7 +1609,7 @@ export class CoreCourseHelperProvider {
|
|||
const site = await CoreSites.getSite(siteId);
|
||||
|
||||
// Get the module.
|
||||
const module = <CoreCourseModuleData>
|
||||
const module =
|
||||
await CoreCourse.getModule(moduleId, courseId, sectionId, false, false, siteId, modName);
|
||||
|
||||
if (CoreSites.getCurrentSiteId() == site.getId()) {
|
||||
|
@ -1649,13 +1629,11 @@ export class CoreCourseHelperProvider {
|
|||
}
|
||||
}
|
||||
|
||||
this.logger.warn('navCtrl was not passed to navigateToModule by the link handler for ' + module.modname);
|
||||
|
||||
const params: Params = {
|
||||
course: { id: courseId },
|
||||
module: module,
|
||||
sectionId: sectionId,
|
||||
modParams: modParams,
|
||||
module,
|
||||
sectionId,
|
||||
modParams,
|
||||
};
|
||||
|
||||
if (courseId == site.getSiteHomeId()) {
|
||||
|
|
|
@ -936,7 +936,7 @@ export class CoreCourseProvider {
|
|||
* Load module contents into module.contents if they aren't loaded already.
|
||||
*
|
||||
* @param module Module to load the contents.
|
||||
* @param courseId The course ID. Recommended to speed up the process and minimize data usage.
|
||||
* @param courseId Not used since 4.0.
|
||||
* @param sectionId The section ID.
|
||||
* @param preferCache True if shouldn't call WS if data is cached, false otherwise.
|
||||
* @param ignoreCache True if it should ignore cached data (it will always fail in offline or server down).
|
||||
|
@ -960,7 +960,7 @@ export class CoreCourseProvider {
|
|||
return;
|
||||
}
|
||||
|
||||
const mod = await this.getModule(module.id, courseId, sectionId, preferCache, ignoreCache, siteId, modName);
|
||||
const mod = await this.getModule(module.id, module.course, sectionId, preferCache, ignoreCache, siteId, modName);
|
||||
|
||||
if (!mod.contents) {
|
||||
throw new CoreError(Translate.instant('core.course.modulenotfound'));
|
||||
|
@ -1532,13 +1532,13 @@ export type CoreCourseGetContentsWSModule = {
|
|||
id: number; // Activity id.
|
||||
url?: string; // Activity url.
|
||||
name: string; // Activity module name.
|
||||
instance?: number; // Instance id.
|
||||
contextid?: number; // Activity context id.
|
||||
instance: number; // Instance id. Cannot be undefined.
|
||||
contextid?: number; // @since 3.10. Activity context id.
|
||||
description?: string; // Activity description.
|
||||
visible?: number; // Is the module visible.
|
||||
uservisible?: boolean; // Is the module visible for the user?.
|
||||
visible: number; // Is the module visible. Cannot be undefined.
|
||||
uservisible: boolean; // Is the module visible for the user?. Cannot be undefined.
|
||||
availabilityinfo?: string; // Availability information.
|
||||
visibleoncoursepage?: number; // Is the module visible on course page.
|
||||
visibleoncoursepage: number; // Is the module visible on course page. Cannot be undefined.
|
||||
modicon: string; // Activity icon url.
|
||||
modname: string; // Activity module type.
|
||||
modplural: string; // Activity module plural name.
|
||||
|
|
Loading…
Reference in New Issue