Merge pull request #3023 from crazyserver/MOBILE-3833
MOBILE-3833 dashboard: Fix WS exceptions on get_recent_courses and gracemain
commit
09a8d8fead
|
@ -264,8 +264,13 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
|
||||||
|
|
||||||
this.hasCourses = this.allCourses.length > 0;
|
this.hasCourses = this.allCourses.length > 0;
|
||||||
|
|
||||||
this.gradePeriodAfter = parseInt(await this.currentSite.getConfig('coursegraceperiodafter', refresh), 10) || 0;
|
try {
|
||||||
this.gradePeriodBefore = parseInt(await this.currentSite.getConfig('coursegraceperiodbefore', refresh), 10) || 0;
|
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.loadSort();
|
||||||
this.loadLayouts(config?.layouts?.value.split(','));
|
this.loadLayouts(config?.layouts?.value.split(','));
|
||||||
|
|
|
@ -135,14 +135,16 @@ export class AddonBlockRecentlyAccessedCoursesComponent extends CoreBlockBaseCom
|
||||||
const showCategories = this.block.configsRecord && this.block.configsRecord.displaycategories &&
|
const showCategories = this.block.configsRecord && this.block.configsRecord.displaycategories &&
|
||||||
this.block.configsRecord.displaycategories.value == '1';
|
this.block.configsRecord.displaycategories.value == '1';
|
||||||
|
|
||||||
// WS is failing on 3.7 and 3.6, use a fallback.
|
let recentCourses: CoreCourseSummaryData[] = [];
|
||||||
if (!this.site.isVersionGreaterEqualThan('3.8')) {
|
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);
|
this.courses = await CoreCoursesHelper.getUserCoursesWithOptions('lastaccess', 10, undefined, showCategories);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const recentCourses = await CoreCourses.getRecentCourses();
|
|
||||||
const courseIds = recentCourses.map((course) => course.id);
|
const courseIds = recentCourses.map((course) => course.id);
|
||||||
|
|
||||||
// Get the courses using getCoursesByField to get more info about each course.
|
// Get the courses using getCoursesByField to get more info about each course.
|
||||||
|
|
Loading…
Reference in New Issue