MOBILE-3833 module: Fix get course when non enrolled

main
Pau Ferrer Ocaña 2022-02-23 10:33:59 +01:00
parent 8ba7da0552
commit 452acd45e9
2 changed files with 8 additions and 2 deletions

View File

@ -37,7 +37,7 @@
{{ 'core.course' | translate}} {{ 'core.course' | translate}}
</p> </p>
<p> <p>
<core-format-text [text]="course.displayname || course.fullname" contextLevel="course" [contextInstanceId]="courseId"> <core-format-text [text]="course.fullname" contextLevel="course" [contextInstanceId]="courseId">
</core-format-text> </core-format-text>
</p> </p>
</ion-label> </ion-label>

View File

@ -249,7 +249,13 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy {
* Fetch course. * Fetch course.
*/ */
protected async fetchCourse(): Promise<void> { protected async fetchCourse(): Promise<void> {
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);
}
} }
/** /**