diff --git a/src/addons/mod/feedback/feedback-lazy.module.ts b/src/addons/mod/feedback/feedback-lazy.module.ts index 9c15c101a..15bf99ecd 100644 --- a/src/addons/mod/feedback/feedback-lazy.module.ts +++ b/src/addons/mod/feedback/feedback-lazy.module.ts @@ -44,7 +44,7 @@ const mobileRoutes: Routes = [ component: AddonModFeedbackRespondentsPage, }, { - path: ':courseId/:cmId/attempt/:attemptId', + path: ':courseId/:cmId/respondents/attempt/:attemptId', loadChildren: () => import('./pages/attempt/attempt.module').then(m => m.AddonModFeedbackAttemptPageModule), }, ]; diff --git a/src/core/features/course/pages/contents/contents.ts b/src/core/features/course/pages/contents/contents.ts index 3cf7f8da6..0fafde5ef 100644 --- a/src/core/features/course/pages/contents/contents.ts +++ b/src/core/features/course/pages/contents/contents.ts @@ -477,7 +477,12 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy { * @param status Status to show. */ protected updateCourseStatus(status: string): void { - this.prefetchCourseData = CoreCourseHelper.getCourseStatusIconAndTitleFromStatus(status); + const statusData = CoreCourseHelper.getCoursePrefetchStatusInfo(status); + + this.prefetchCourseData.status = statusData.status; + this.prefetchCourseData.icon = statusData.icon; + this.prefetchCourseData.statusTranslatable = statusData.statusTranslatable; + this.prefetchCourseData.loading = statusData.loading; } /** diff --git a/src/core/features/course/pages/preview/preview.page.ts b/src/core/features/course/pages/preview/preview.page.ts index f235d620e..32ddc47e2 100644 --- a/src/core/features/course/pages/preview/preview.page.ts +++ b/src/core/features/course/pages/preview/preview.page.ts @@ -402,7 +402,12 @@ export class CoreCoursePreviewPage implements OnInit, OnDestroy { * @param status Status to show. */ protected updateCourseStatus(status: string): void { - this.prefetchCourseData = CoreCourseHelper.getCourseStatusIconAndTitleFromStatus(status); + const statusData = CoreCourseHelper.getCoursePrefetchStatusInfo(status); + + this.prefetchCourseData.status = statusData.status; + this.prefetchCourseData.icon = statusData.icon; + this.prefetchCourseData.statusTranslatable = statusData.statusTranslatable; + this.prefetchCourseData.loading = statusData.loading; } /** diff --git a/src/core/features/course/services/course-helper.ts b/src/core/features/course/services/course-helper.ts index 64d1d832d..7e7dcd319 100644 --- a/src/core/features/course/services/course-helper.ts +++ b/src/core/features/course/services/course-helper.ts @@ -1163,7 +1163,7 @@ export class CoreCourseHelperProvider { const status = await this.determineCoursesStatus(courses); - prefetch = this.getCourseStatusIconAndTitleFromStatus(status); + prefetch = this.getCoursePrefetchStatusInfo(status); if (prefetch.loading) { // It seems all courses are being downloaded, show a download button instead. @@ -1298,16 +1298,16 @@ export class CoreCourseHelperProvider { async getCourseStatusIconAndTitle(courseId: number, siteId?: string): Promise { const status = await CoreCourse.getCourseStatus(courseId, siteId); - return this.getCourseStatusIconAndTitleFromStatus(status); + return this.getCoursePrefetchStatusInfo(status); } /** * Get a course status icon and the langkey to use as a title from status. * * @param status Course status. - * @return Title and icon name. + * @return Prefetch status info. */ - getCourseStatusIconAndTitleFromStatus(status: string): CorePrefetchStatusInfo { + getCoursePrefetchStatusInfo(status: string): CorePrefetchStatusInfo { const prefetchStatus: CorePrefetchStatusInfo = { status: status, icon: this.getPrefetchStatusIcon(status, false), diff --git a/src/core/features/courses/components/course-progress/core-courses-course-progress.html b/src/core/features/courses/components/course-progress/core-courses-course-progress.html index b3c6edd41..9dd5128b4 100644 --- a/src/core/features/courses/components/course-progress/core-courses-course-progress.html +++ b/src/core/features/courses/components/course-progress/core-courses-course-progress.html @@ -49,6 +49,11 @@ + + + diff --git a/src/core/features/courses/components/course-progress/course-progress.ts b/src/core/features/courses/components/course-progress/course-progress.ts index de922c200..7109ad66c 100644 --- a/src/core/features/courses/components/course-progress/course-progress.ts +++ b/src/core/features/courses/components/course-progress/course-progress.ts @@ -107,7 +107,7 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy { // Determine course prefetch icon. const status = await CoreCourse.getCourseStatus(this.course.id); - this.prefetchCourseData = CoreCourseHelper.getCourseStatusIconAndTitleFromStatus(status); + this.prefetchCourseData = CoreCourseHelper.getCoursePrefetchStatusInfo(status); this.courseStatus = status; if (this.prefetchCourseData.loading) { @@ -184,9 +184,13 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy { * @param status Status to show. */ protected updateCourseStatus(status: string): void { - this.prefetchCourseData = CoreCourseHelper.getCourseStatusIconAndTitleFromStatus(status); + const statusData = CoreCourseHelper.getCoursePrefetchStatusInfo(status); this.courseStatus = status; + this.prefetchCourseData.status = statusData.status; + this.prefetchCourseData.icon = statusData.icon; + this.prefetchCourseData.statusTranslatable = statusData.statusTranslatable; + this.prefetchCourseData.loading = statusData.loading; } /** diff --git a/src/core/singletons/object.ts b/src/core/singletons/object.ts index 0b3dbbc38..b0dd856c3 100644 --- a/src/core/singletons/object.ts +++ b/src/core/singletons/object.ts @@ -16,6 +16,10 @@ export type CoreObjectWithoutEmpty = { [k in keyof T]: T[k] extends undefined | null ? never : T[k]; }; +export type CoreObjectWithoutUndefined = { + [k in keyof T]: T[k] extends undefined ? never : T[k]; +}; + /** * Singleton with helper functions for objects. */ @@ -79,4 +83,24 @@ export class CoreObject { return cleanObj as CoreObjectWithoutEmpty; } + /** + * Create a new object without undefined values. + * + * @param obj Objet. + * @return New object without undefined values. + */ + static withoutUndefined(obj: T): CoreObjectWithoutUndefined { + const cleanObj = {}; + + for (const [key, value] of Object.entries(obj)) { + if (value === undefined) { + continue; + } + + cleanObj[key] = value; + } + + return cleanObj as CoreObjectWithoutUndefined; + } + }