+ [contextInstanceId]="module.id" [courseId]="courseId">
diff --git a/src/addons/mod/page/components/index/index.ts b/src/addons/mod/page/components/index/index.ts
index 7cf5feb5a..d8d3cdb61 100644
--- a/src/addons/mod/page/components/index/index.ts
+++ b/src/addons/mod/page/components/index/index.ts
@@ -59,8 +59,8 @@ export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComp
await this.loadContent();
try {
- await AddonModPage.logView(this.module!.instance!, this.module!.name);
- CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata);
+ await AddonModPage.logView(this.module.instance!, this.module.name);
+ CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata);
} catch {
// Ignore errors.
}
@@ -72,7 +72,7 @@ export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComp
* @return Resolved when done.
*/
protected async invalidateContent(): Promise {
- await AddonModPage.invalidateContent(this.module!.id, this.courseId!);
+ await AddonModPage.invalidateContent(this.module.id, this.courseId);
}
/**
@@ -92,9 +92,9 @@ export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComp
// Get the module to get the latest title and description. Data should've been updated in download.
if (this.canGetPage) {
- getPagePromise = AddonModPage.getPageData(this.courseId!, this.module!.id);
+ getPagePromise = AddonModPage.getPageData(this.courseId, this.module.id);
} else {
- getPagePromise = CoreCourse.getModule(this.module!.id, this.courseId!);
+ getPagePromise = CoreCourse.getModule(this.module.id, this.courseId);
}
promises.push(getPagePromise.then((page) => {
@@ -133,7 +133,7 @@ export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComp
}));
// Get the page HTML.
- promises.push(AddonModPageHelper.getPageHtml(this.module!.contents, this.module!.id).then((content) => {
+ promises.push(AddonModPageHelper.getPageHtml(this.module.contents, this.module.id).then((content) => {
this.contents = content;
this.warning = downloadResult?.failed ? this.getErrorDownloadingSomeFilesMessage(downloadResult.error!) : '';
diff --git a/src/addons/mod/quiz/components/index/addon-mod-quiz-index.html b/src/addons/mod/quiz/components/index/addon-mod-quiz-index.html
index 87dd74a24..18d2667bc 100644
--- a/src/addons/mod/quiz/components/index/addon-mod-quiz-index.html
+++ b/src/addons/mod/quiz/components/index/addon-mod-quiz-index.html
@@ -28,7 +28,7 @@
+ contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId">
@@ -117,7 +117,7 @@
{{ 'addon.mod_quiz.comment' | translate }}
+ contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId">
@@ -125,7 +125,7 @@
{{ 'addon.mod_quiz.overallfeedback' | translate }}
+ contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId">
diff --git a/src/addons/mod/quiz/components/index/index.ts b/src/addons/mod/quiz/components/index/index.ts
index 46b9c15e7..8f10dcc82 100644
--- a/src/addons/mod/quiz/components/index/index.ts
+++ b/src/addons/mod/quiz/components/index/index.ts
@@ -129,7 +129,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
try {
await AddonModQuiz.logViewQuiz(this.quiz.id, this.quiz.name);
- CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata);
+ CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata);
} catch {
// Ignore errors.
}
@@ -162,7 +162,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
this.showStatusSpinner = true;
try {
- await AddonModQuizPrefetchHandler.prefetch(this.module!, this.courseId, true);
+ await AddonModQuizPrefetchHandler.prefetch(this.module, this.courseId, true);
// Success downloading, open quiz.
this.openQuiz();
@@ -190,7 +190,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
protected async fetchContent(refresh: boolean = false, sync: boolean = false, showErrors: boolean = false): Promise {
try {
// First get the quiz instance.
- const quiz = await AddonModQuiz.getQuiz(this.courseId!, this.module!.id);
+ const quiz = await AddonModQuiz.getQuiz(this.courseId, this.module.id);
this.gradeMethodReadable = AddonModQuiz.getQuizGradeMethod(quiz.grademethod);
this.now = Date.now();
@@ -231,7 +231,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
}
// Get quiz access info.
- this.quizAccessInfo = await AddonModQuiz.getQuizAccessInformation(quiz.id, { cmId: this.module!.id });
+ this.quizAccessInfo = await AddonModQuiz.getQuizAccessInformation(quiz.id, { cmId: this.module.id });
this.showReviewColumn = this.quizAccessInfo.canreviewmyattempts;
this.accessRules = this.quizAccessInfo.accessrules;
@@ -242,7 +242,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
}
// Get question types in the quiz.
- const types = await AddonModQuiz.getQuizRequiredQtypes(quiz.id, { cmId: this.module!.id });
+ const types = await AddonModQuiz.getQuizRequiredQtypes(quiz.id, { cmId: this.module.id });
this.unsupportedQuestions = AddonModQuiz.getUnsupportedQuestions(types);
this.hasSupportedQuestions = !!types.find((type) => type != 'random' && this.unsupportedQuestions.indexOf(type) == -1);
@@ -265,10 +265,10 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
protected async getAttempts(quiz: AddonModQuizQuizData): Promise {
// Get access information of last attempt (it also works if no attempts made).
- this.attemptAccessInfo = await AddonModQuiz.getAttemptAccessInformation(quiz.id, 0, { cmId: this.module!.id });
+ this.attemptAccessInfo = await AddonModQuiz.getAttemptAccessInformation(quiz.id, 0, { cmId: this.module.id });
// Get attempts.
- const attempts = await AddonModQuiz.getUserAttempts(quiz.id, { cmId: this.module!.id });
+ const attempts = await AddonModQuiz.getUserAttempts(quiz.id, { cmId: this.module.id });
this.attempts = await this.treatAttempts(quiz, attempts);
@@ -386,7 +386,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
if (quiz.showFeedbackColumn) {
// Get the quiz overall feedback.
const response = await AddonModQuiz.getFeedbackForGrade(quiz.id, this.gradebookData.grade, {
- cmId: this.module!.id,
+ cmId: this.module.id,
});
this.overallFeedback = response.feedbacktext;
@@ -404,14 +404,14 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
}
// If we go to auto review it means an attempt was finished. Check completion status.
- CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata);
+ CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata);
// Verify that user can see the review.
const attemptId = this.autoReview.attemptId;
if (this.quizAccessInfo?.canreviewmyattempts) {
try {
- await AddonModQuiz.getAttemptReview(attemptId, { page: -1, cmId: this.module!.id });
+ await AddonModQuiz.getAttemptReview(attemptId, { page: -1, cmId: this.module.id });
await CoreNavigator.navigate(`review/${attemptId}`);
} catch {
@@ -429,7 +429,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
protected hasSyncSucceed(result: AddonModQuizSyncResult): boolean {
if (result.attemptFinished) {
// An attempt was finished, check completion status.
- CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata);
+ CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata);
}
// If the sync call isn't rejected it means the sync was successful.
@@ -488,7 +488,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
protected async invalidateContent(): Promise {
const promises: Promise[] = [];
- promises.push(AddonModQuiz.invalidateQuizData(this.courseId!));
+ promises.push(AddonModQuiz.invalidateQuizData(this.courseId));
if (this.quiz) {
promises.push(AddonModQuiz.invalidateUserAttemptsForUser(this.quiz.id));
@@ -497,7 +497,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
promises.push(AddonModQuiz.invalidateAttemptAccessInformation(this.quiz.id));
promises.push(AddonModQuiz.invalidateCombinedReviewOptionsForUser(this.quiz.id));
promises.push(AddonModQuiz.invalidateUserBestGradeForUser(this.quiz.id));
- promises.push(AddonModQuiz.invalidateGradeFromGradebook(this.courseId!));
+ promises.push(AddonModQuiz.invalidateGradeFromGradebook(this.courseId));
}
await Promise.all(promises);
@@ -536,7 +536,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
CoreNavigator.navigate('player', {
params: {
- moduleUrl: this.module?.url,
+ moduleUrl: this.module.url,
},
});
}
@@ -594,7 +594,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
}
// Get combined review options.
- promises.push(AddonModQuiz.getCombinedReviewOptions(quiz.id, { cmId: this.module!.id }).then((options) => {
+ promises.push(AddonModQuiz.getCombinedReviewOptions(quiz.id, { cmId: this.module.id }).then((options) => {
this.options = options;
return;
@@ -633,11 +633,11 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
* @return Promise resolved when done.
*/
protected async getQuizGrade(quiz: AddonModQuizQuizData): Promise {
- this.bestGrade = await AddonModQuiz.getUserBestGrade(quiz.id, { cmId: this.module!.id });
+ this.bestGrade = await AddonModQuiz.getUserBestGrade(quiz.id, { cmId: this.module.id });
try {
// Get gradebook grade.
- const data = await AddonModQuiz.getGradeFromGradebook(this.courseId!, this.module!.id);
+ const data = await AddonModQuiz.getGradeFromGradebook(this.courseId, this.module.id);
if (data) {
this.gradebookData = {
diff --git a/src/addons/mod/resource/components/index/addon-mod-resource-index.html b/src/addons/mod/resource/components/index/addon-mod-resource-index.html
index 56757e8d1..9c5f81c23 100644
--- a/src/addons/mod/resource/components/index/addon-mod-resource-index.html
+++ b/src/addons/mod/resource/components/index/addon-mod-resource-index.html
@@ -22,7 +22,7 @@
+ [contextInstanceId]="module.id" [courseId]="courseId">
diff --git a/src/addons/mod/resource/components/index/index.ts b/src/addons/mod/resource/components/index/index.ts
index 4b1c9b8cf..c6afd4d61 100644
--- a/src/addons/mod/resource/components/index/index.ts
+++ b/src/addons/mod/resource/components/index/index.ts
@@ -64,8 +64,8 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource
await this.loadContent();
try {
- await AddonModResource.logView(this.module!.instance!, this.module!.name);
- CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata);
+ await AddonModResource.logView(this.module.instance!, this.module.name);
+ CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata);
} catch {
// Ignore errors.
}
@@ -77,7 +77,7 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource
* @return Resolved when done.
*/
protected async invalidateContent(): Promise {
- return AddonModResource.invalidateContent(this.module!.id, this.courseId!);
+ return AddonModResource.invalidateContent(this.module.id, this.courseId);
}
/**
@@ -88,9 +88,9 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource
*/
protected async fetchContent(refresh?: boolean): Promise {
// Load module contents if needed. Passing refresh is needed to force reloading contents.
- await CoreCourse.loadModuleContents(this.module!, this.courseId, undefined, false, refresh);
+ await CoreCourse.loadModuleContents(this.module, this.courseId, undefined, false, refresh);
- if (!this.module!.contents || !this.module!.contents.length) {
+ if (!this.module.contents || !this.module.contents.length) {
throw new CoreError(Translate.instant('core.filenotfound'));
}
@@ -99,11 +99,11 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource
// Get the resource instance to get the latest name/description and to know if it's embedded.
if (this.canGetResource) {
- resource = await CoreUtils.ignoreErrors(AddonModResource.getResourceData(this.courseId!, this.module!.id));
+ resource = await CoreUtils.ignoreErrors(AddonModResource.getResourceData(this.courseId, this.module.id));
this.description = resource?.intro || '';
options = resource?.displayoptions ? CoreTextUtils.unserialize(resource.displayoptions) : {};
} else {
- resource = await CoreUtils.ignoreErrors(CoreCourse.getModule(this.module!.id, this.courseId));
+ resource = await CoreUtils.ignoreErrors(CoreCourse.getModule(this.module.id, this.courseId));
this.description = resource?.description || '';
options = resource?.customdata ? CoreTextUtils.unserialize(CoreTextUtils.parseJSON(resource.customdata)) : {};
}
@@ -114,9 +114,9 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource
this.dataRetrieved.emit(resource);
}
- if (AddonModResourceHelper.isDisplayedInIframe(this.module!)) {
+ if (AddonModResourceHelper.isDisplayedInIframe(this.module)) {
const downloadResult = await this.downloadResourceIfNeeded(refresh, true);
- const src = await AddonModResourceHelper.getIframeSrc(this.module!);
+ const src = await AddonModResourceHelper.getIframeSrc(this.module);
this.mode = 'iframe';
if (this.src && src.toString() == this.src.toString()) {
@@ -137,11 +137,11 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource
return;
}
- if (resource && 'display' in resource && AddonModResourceHelper.isDisplayedEmbedded(this.module!, resource.display)) {
+ if (resource && 'display' in resource && AddonModResourceHelper.isDisplayedEmbedded(this.module, resource.display)) {
this.mode = 'embedded';
this.warning = '';
- this.contentText = await AddonModResourceHelper.getEmbeddedHtml(this.module!, this.courseId!);
+ this.contentText = await AddonModResourceHelper.getEmbeddedHtml(this.module, this.courseId);
this.mode = this.contentText.length > 0 ? 'embedded' : 'external';
} else {
this.mode = 'external';
@@ -158,20 +158,20 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource
* @return Promise resolved when done.
*/
async open(): Promise {
- let downloadable = await CoreCourseModulePrefetchDelegate.isModuleDownloadable(this.module!, this.courseId!);
+ let downloadable = await CoreCourseModulePrefetchDelegate.isModuleDownloadable(this.module, this.courseId);
if (downloadable) {
// Check if the main file is downloadle.
// This isn't done in "isDownloadable" to prevent extra WS calls in the course page.
- downloadable = await AddonModResourceHelper.isMainFileDownloadable(this.module!);
+ downloadable = await AddonModResourceHelper.isMainFileDownloadable(this.module);
if (downloadable) {
- return AddonModResourceHelper.openModuleFile(this.module!, this.courseId!);
+ return AddonModResourceHelper.openModuleFile(this.module, this.courseId);
}
}
// The resource cannot be downloaded, open the activity in browser.
- await CoreSites.getCurrentSite()?.openInBrowserWithAutoLoginIfSameSite(this.module!.url!);
+ await CoreSites.getCurrentSite()?.openInBrowserWithAutoLoginIfSameSite(this.module.url!);
}
}
diff --git a/src/addons/mod/url/components/index/addon-mod-url-index.html b/src/addons/mod/url/components/index/addon-mod-url-index.html
index 11392ce43..10bc4fbc2 100644
--- a/src/addons/mod/url/components/index/addon-mod-url-index.html
+++ b/src/addons/mod/url/components/index/addon-mod-url-index.html
@@ -16,7 +16,7 @@
+ [componentId]="componentId" contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId">
diff --git a/src/addons/mod/url/components/index/index.ts b/src/addons/mod/url/components/index/index.ts
index 75b80f768..0409c7e4c 100644
--- a/src/addons/mod/url/components/index/index.ts
+++ b/src/addons/mod/url/components/index/index.ts
@@ -75,7 +75,7 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo
* @return Resolved when done.
*/
protected async invalidateContent(): Promise {
- await AddonModUrl.invalidateContent(this.module!.id, this.courseId!);
+ await AddonModUrl.invalidateContent(this.module.id, this.courseId);
}
/**
@@ -90,7 +90,7 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo
throw null;
}
// Fetch the module data.
- const url = await AddonModUrl.getUrl(this.courseId!, this.module!.id);
+ const url = await AddonModUrl.getUrl(this.courseId, this.module.id);
this.name = url.name;
this.description = url.intro;
@@ -102,17 +102,17 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo
}
// Try to load module contents, it's needed to get the URL with parameters.
- await CoreCourse.loadModuleContents(this.module!, this.courseId, undefined, false, refresh, undefined, 'url');
+ await CoreCourse.loadModuleContents(this.module, this.courseId, undefined, false, refresh, undefined, 'url');
// Always use the URL from the module because it already includes the parameters.
- this.url = this.module!.contents[0] && this.module!.contents[0].fileurl ? this.module!.contents[0].fileurl : undefined;
+ this.url = this.module.contents[0] && this.module.contents[0].fileurl ? this.module.contents[0].fileurl : undefined;
await this.calculateDisplayOptions(url);
} catch {
// Fallback in case is not prefetched or not available.
const mod =
- await CoreCourse.getModule(this.module!.id, this.courseId, undefined, false, false, undefined, 'url');
+ await CoreCourse.getModule(this.module.id, this.courseId, undefined, false, false, undefined, 'url');
this.name = mod.name;
this.description = mod.description;
@@ -167,8 +167,8 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo
*/
protected async logView(): Promise {
try {
- await AddonModUrl.logView(this.module!.instance!, this.module!.name);
- CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata);
+ await AddonModUrl.logView(this.module.instance!, this.module.name);
+ CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata);
} catch {
// Ignore errors.
}
diff --git a/src/core/features/course/classes/main-resource-component.ts b/src/core/features/course/classes/main-resource-component.ts
index 0b849707c..c28628247 100644
--- a/src/core/features/course/classes/main-resource-component.ts
+++ b/src/core/features/course/classes/main-resource-component.ts
@@ -50,8 +50,8 @@ export type CoreCourseResourceDownloadResult = {
})
export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy, CoreCourseModuleMainComponent {
- @Input() module?: CoreCourseModule; // The module of the component.
- @Input() courseId?: number; // Course ID the component belongs to.
+ @Input() module!: CoreCourseModule; // The module of the component.
+ @Input() courseId!: number; // Course ID the component belongs to.
@Output() dataRetrieved = new EventEmitter(); // Called to notify changes the index page from the main component.
loaded = false; // If the component has been loaded.
@@ -90,10 +90,10 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
*/
async ngOnInit(): Promise {
this.siteId = CoreSites.getCurrentSiteId();
- this.description = this.module?.description;
- this.componentId = this.module?.id;
- this.externalUrl = this.module?.url;
- this.courseId = this.courseId || this.module?.course;
+ this.description = this.module.description;
+ this.componentId = this.module.id;
+ this.externalUrl = this.module.url;
+ this.courseId = this.courseId || this.module.course!;
this.blog = await AddonBlog.isPluginEnabled();
}
@@ -107,6 +107,7 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
*/
async doRefresh(refresher?: CustomEvent | null, done?: () => void, showErrors: boolean = false): Promise {
if (!this.loaded || !this.module) {
+ // Module can be undefined if course format changes from single activity to weekly/topics.
return;
}
@@ -193,12 +194,8 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
* Fill the context menu options
*/
protected fillContextMenu(refresh: boolean = false): void {
- if (!this.module) {
- return;
- }
-
// All data obtained, now fill the context menu.
- CoreCourseHelper.fillContextMenu(this, this.module, this.courseId!, refresh, this.component);
+ CoreCourseHelper.fillContextMenu(this, this.module, this.courseId, refresh, this.component);
}
/**
@@ -215,10 +212,10 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
expandDescription(): void {
CoreTextUtils.viewText(Translate.instant('core.description'), this.description!, {
component: this.component,
- componentId: this.module?.id,
+ componentId: this.module.id,
filter: true,
contextLevel: 'module',
- instanceId: this.module?.id,
+ instanceId: this.module.id,
courseId: this.courseId,
});
}
@@ -227,7 +224,7 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
* Go to blog posts.
*/
async gotoBlog(): Promise {
- const params: Params = { cmId: this.module?.id };
+ const params: Params = { cmId: this.module.id };
CoreNavigator.navigateToSitePath(AddonBlogMainMenuHandlerService.PAGE_NAME, { params });
}
@@ -238,11 +235,7 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
* @param done Function to call when done.
*/
prefetch(done?: () => void): void {
- if (!this.module) {
- return;
- }
-
- CoreCourseHelper.contextMenuPrefetch(this, this.module, this.courseId!, done);
+ CoreCourseHelper.contextMenuPrefetch(this, this.module, this.courseId, done);
}
/**
@@ -251,17 +244,13 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
* @param done Function to call when done.
*/
removeFiles(done?: () => void): void {
- if (!this.module) {
- return;
- }
-
if (this.prefetchStatus == CoreConstants.DOWNLOADING) {
CoreDomUtils.showAlertTranslated(undefined, 'core.course.cannotdeletewhiledownloading');
return;
}
- CoreCourseHelper.confirmAndRemoveFiles(this.module, this.courseId!, done);
+ CoreCourseHelper.confirmAndRemoveFiles(this.module, this.courseId, done);
}
/**
@@ -309,13 +298,13 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
* @return Promise resolved when done.
*/
protected async setStatusListener(): Promise {
- if (typeof this.statusObserver != 'undefined' || !this.module) {
+ if (typeof this.statusObserver != 'undefined') {
return;
}
// Listen for changes on this module status.
this.statusObserver = CoreEvents.on(CoreEvents.PACKAGE_STATUS_CHANGED, (data) => {
- if (!this.module || data.componentId != this.module.id || data.component != this.component) {
+ if (data.componentId != this.module.id || data.component != this.component) {
return;
}
@@ -327,7 +316,7 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
}, this.siteId);
// Also, get the current status.
- const status = await CoreCourseModulePrefetchDelegate.getModuleStatus(this.module, this.courseId!);
+ const status = await CoreCourseModulePrefetchDelegate.getModuleStatus(this.module, this.courseId);
this.currentStatus = status;
this.showStatus(status);
@@ -350,17 +339,13 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
failed: false,
};
- if (!this.module) {
- return result;
- }
-
// Get module status to determine if it needs to be downloaded.
await this.setStatusListener();
if (this.currentStatus != CoreConstants.DOWNLOADED) {
// Download content. This function also loads module contents if needed.
try {
- await CoreCourseModulePrefetchDelegate.downloadModule(this.module, this.courseId!);
+ await CoreCourseModulePrefetchDelegate.downloadModule(this.module, this.courseId);
// If we reach here it means the download process already loaded the contents, no need to do it again.
contentsAlreadyLoaded = true;