Skip to content

Commit b398b08

Browse files
committed
MOBILE-3833 module: Fix summary not loaded if cannot view grades
1 parent c644eeb commit b398b08

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

src/core/features/course/components/module-summary/module-summary.ts

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,21 +174,35 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy {
174174
this.componentId = this.module.id;
175175
this.externalUrl = this.module.url;
176176
this.courseId = this.courseId || this.module.course;
177-
178-
this.modicon = await CoreCourseModuleDelegate.getModuleIconSrc(this.module.modname, this.module.modicon, this.module);
179177
this.moduleNameTranslated = CoreCourse.translateModuleName(this.module.modname || '');
180178

181179
this.blog = await AddonBlog.isPluginEnabled();
182180

183-
await Promise.all([
184-
this.getPackageStatus(),
185-
this.fetchGrades(),
186-
this.fetchCourse(),
187-
]);
181+
try {
182+
await Promise.all([
183+
this.loadModIcon(),
184+
this.getPackageStatus(),
185+
this.fetchGrades(),
186+
this.fetchCourse(),
187+
]);
188+
} catch (error) {
189+
CoreDomUtils.showErrorModal(error);
190+
}
188191

189192
this.loaded = true;
190193
}
191194

195+
/**
196+
* Load the module icon.
197+
*/
198+
protected async loadModIcon(): Promise<void> {
199+
if (!this.module) {
200+
return;
201+
}
202+
203+
this.modicon = await CoreCourseModuleDelegate.getModuleIconSrc(this.module.modname, this.module.modicon, this.module);
204+
}
205+
192206
/**
193207
* Updage package status.
194208
*
@@ -235,7 +249,11 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy {
235249
return;
236250
}
237251

238-
this.grades = await CoreGradesHelper.getModuleGrades(this.courseId, this.moduleId);
252+
try {
253+
this.grades = await CoreGradesHelper.getModuleGrades(this.courseId, this.moduleId);
254+
} catch {
255+
// Cannot get grades, don't display them.
256+
}
239257
}
240258

241259
/**

0 commit comments

Comments
 (0)