forked from CIT/Vmeda.Online
		
	MOBILE-3833 dashboard: Fix WS exceptions on get_recent_courses and grace
This commit is contained in:
		
							parent
							
								
									725534ed12
								
							
						
					
					
						commit
						871e81774b
					
				@ -264,8 +264,13 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
 | 
			
		||||
 | 
			
		||||
        this.hasCourses = this.allCourses.length > 0;
 | 
			
		||||
 | 
			
		||||
        this.gradePeriodAfter = parseInt(await this.currentSite.getConfig('coursegraceperiodafter', refresh), 10) || 0;
 | 
			
		||||
        this.gradePeriodBefore = parseInt(await this.currentSite.getConfig('coursegraceperiodbefore', refresh), 10) || 0;
 | 
			
		||||
        try {
 | 
			
		||||
            this.gradePeriodAfter = parseInt(await this.currentSite.getConfig('coursegraceperiodafter', refresh), 10);
 | 
			
		||||
            this.gradePeriodBefore = parseInt(await this.currentSite.getConfig('coursegraceperiodbefore', refresh), 10);
 | 
			
		||||
        } catch {
 | 
			
		||||
            this.gradePeriodAfter = 0;
 | 
			
		||||
            this.gradePeriodBefore = 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        this.loadSort();
 | 
			
		||||
        this.loadLayouts(config?.layouts?.value.split(','));
 | 
			
		||||
 | 
			
		||||
@ -135,14 +135,16 @@ export class AddonBlockRecentlyAccessedCoursesComponent extends CoreBlockBaseCom
 | 
			
		||||
        const showCategories = this.block.configsRecord && this.block.configsRecord.displaycategories &&
 | 
			
		||||
            this.block.configsRecord.displaycategories.value == '1';
 | 
			
		||||
 | 
			
		||||
        // WS is failing on 3.7 and 3.6, use a fallback.
 | 
			
		||||
        if (!this.site.isVersionGreaterEqualThan('3.8')) {
 | 
			
		||||
        let recentCourses: CoreCourseSummaryData[] = [];
 | 
			
		||||
        try {
 | 
			
		||||
            recentCourses = await CoreCourses.getRecentCourses();
 | 
			
		||||
        } catch {
 | 
			
		||||
            // WS is failing on 3.7 and bellow, use a fallback.
 | 
			
		||||
            this.courses = await CoreCoursesHelper.getUserCoursesWithOptions('lastaccess', 10, undefined, showCategories);
 | 
			
		||||
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const recentCourses = await CoreCourses.getRecentCourses();
 | 
			
		||||
        const courseIds = recentCourses.map((course) => course.id);
 | 
			
		||||
 | 
			
		||||
        // Get the courses using getCoursesByField to get more info about each course.
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user