From 452acd45e9877f204526868d99d6f7bbd0e56469 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?=
Date: Wed, 23 Feb 2022 10:33:59 +0100
Subject: [PATCH] MOBILE-3833 module: Fix get course when non enrolled
---
.../course/components/module-summary/module-summary.html | 2 +-
.../course/components/module-summary/module-summary.ts | 8 +++++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/core/features/course/components/module-summary/module-summary.html b/src/core/features/course/components/module-summary/module-summary.html
index 6c60ba185..52dc0f284 100644
--- a/src/core/features/course/components/module-summary/module-summary.html
+++ b/src/core/features/course/components/module-summary/module-summary.html
@@ -37,7 +37,7 @@
{{ 'core.course' | translate}}
-
+
diff --git a/src/core/features/course/components/module-summary/module-summary.ts b/src/core/features/course/components/module-summary/module-summary.ts
index a82c4801c..f480c8469 100644
--- a/src/core/features/course/components/module-summary/module-summary.ts
+++ b/src/core/features/course/components/module-summary/module-summary.ts
@@ -249,7 +249,13 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy {
* Fetch course.
*/
protected async fetchCourse(): Promise {
- this.course = await CoreCourses.getUserCourse(this.courseId, true);
+ // Fix that.
+ try {
+ this.course = await CoreCourses.getUserCourse(this.courseId, true);
+ } catch {
+ // The user is not enrolled in the course. Use getCourses to see if it's an admin/manager and can see the course.
+ this.course = await CoreCourses.getCourse(this.courseId);
+ }
}
/**