diff --git a/src/addons/badges/pages/issued-badge/issued-badge.page.ts b/src/addons/badges/pages/issued-badge/issued-badge.page.ts index 4a9285995..1fc7a21be 100644 --- a/src/addons/badges/pages/issued-badge/issued-badge.page.ts +++ b/src/addons/badges/pages/issued-badge/issued-badge.page.ts @@ -43,29 +43,30 @@ export class AddonBadgesIssuedBadgePage implements OnInit { user?: CoreUserProfile; course?: CoreEnrolledCourseData; badge?: AddonBadgesUserBadge; - badges?: CoreSwipeNavigationItemsManager; + badges: CoreSwipeNavigationItemsManager; badgeLoaded = false; currentTime = 0; - constructor(protected route: ActivatedRoute) { } - - /** - * View loaded. - */ - ngOnInit(): void { + constructor(protected route: ActivatedRoute) { this.courseId = CoreNavigator.getRouteNumberParam('courseId') || this.courseId; // Use 0 for site badges. this.userId = CoreNavigator.getRouteNumberParam('userId') || CoreSites.getRequiredCurrentSite().getUserId(); this.badgeHash = CoreNavigator.getRouteParam('badgeHash') || ''; - this.fetchIssuedBadge().finally(() => { - this.badgeLoaded = true; - }); - const source = CoreRoutedItemsManagerSourcesTracker.getOrCreateSource( AddonBadgesUserBadgesSource, [this.courseId, this.userId], ); + this.badges = new CoreSwipeNavigationItemsManager(source); + } + + /** + * View loaded. + */ + ngOnInit(): void { + this.fetchIssuedBadge().finally(() => { + this.badgeLoaded = true; + }); this.badges.start(); } diff --git a/src/addons/mod/feedback/pages/attempt/attempt.ts b/src/addons/mod/feedback/pages/attempt/attempt.ts index f406be269..35733c4ed 100644 --- a/src/addons/mod/feedback/pages/attempt/attempt.ts +++ b/src/addons/mod/feedback/pages/attempt/attempt.ts @@ -38,34 +38,36 @@ import { AddonModFeedbackFormItem, AddonModFeedbackHelper } from '../../services }) export class AddonModFeedbackAttemptPage implements OnInit, OnDestroy { - protected attemptId!: number; - - cmId!: number; - courseId!: number; + cmId: number; + courseId: number; feedback?: AddonModFeedbackWSFeedback; attempt?: AddonModFeedbackWSAttempt; - attempts?: AddonModFeedbackAttemptsSwipeManager; + attempts: AddonModFeedbackAttemptsSwipeManager; anonAttempt?: AddonModFeedbackWSAnonAttempt; items: AddonModFeedbackAttemptItem[] = []; component = AddonModFeedbackProvider.COMPONENT; loaded = false; + protected attemptId: number; + + constructor() { + this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId'); + this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId'); + this.attemptId = CoreNavigator.getRequiredRouteNumberParam('attemptId'); + + const source = CoreRoutedItemsManagerSourcesTracker.getOrCreateSource( + AddonModFeedbackAttemptsSource, + [this.courseId, this.cmId], + ); + + this.attempts = new AddonModFeedbackAttemptsSwipeManager(source); + } + /** * @inheritdoc */ ngOnInit(): void { try { - this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId'); - this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId'); - this.attemptId = CoreNavigator.getRequiredRouteNumberParam('attemptId'); - - const source = CoreRoutedItemsManagerSourcesTracker.getOrCreateSource( - AddonModFeedbackAttemptsSource, - [this.courseId, this.cmId], - ); - - this.attempts = new AddonModFeedbackAttemptsSwipeManager(source); - this.attempts.start(); } catch (error) { CoreDomUtils.showErrorModal(error); @@ -82,7 +84,7 @@ export class AddonModFeedbackAttemptPage implements OnInit, OnDestroy { * @inheritdoc */ ngOnDestroy(): void { - this.attempts?.destroy(); + this.attempts.destroy(); } /**