MOBILE-2431 courses: Fix webservice not available error

main
Dani Palou 2018-06-26 09:06:20 +02:00
parent 4cb669ee6a
commit 11013c69ab
5 changed files with 15 additions and 4 deletions

View File

@ -209,7 +209,7 @@ export class CoreCourseSectionPage implements OnDestroy {
// Get the overview files.
if (this.course.overviewfiles) {
this.course.imageThumb = this.course.overviewfiles[0] && this.course.overviewfiles[0].fileurl;
} else {
} else if (this.coursesProvider.isGetCoursesByFieldAvailable()) {
promises.push(this.coursesProvider.getCoursesByField('id', this.course.id).then((coursesInfo) => {
if (coursesInfo[0] && coursesInfo[0].overviewfiles && coursesInfo[0].overviewfiles[0]) {
this.course.imageThumb = coursesInfo[0].overviewfiles[0].fileurl;

View File

@ -97,6 +97,15 @@ export class CoreCourseFormatDefaultHandler implements CoreCourseFormatHandler {
* @return {any|Promise<any>} Current section (or promise resolved with current section).
*/
getCurrentSection(course: any, sections: any[]): any | Promise<any> {
if (!this.coursesProvider.isGetCoursesByFieldAvailable()) {
// Cannot get the current section, return the first one.
if (sections[0].id != CoreCourseProvider.ALL_SECTIONS_ID) {
return sections[0];
}
return sections[1];
}
// We need the "marker" to determine the current section.
return this.coursesProvider.getCoursesByField('id', course.id).catch(() => {
// Ignore errors.

View File

@ -1007,7 +1007,9 @@ export class CoreCourseHelperProvider {
});
// Prefetch other data needed to render the course.
promises.push(this.coursesProvider.getCoursesByField('id', course.id));
if (this.coursesProvider.isGetCoursesByFieldAvailable()) {
promises.push(this.coursesProvider.getCoursesByField('id', course.id));
}
promises.push(this.courseProvider.getActivitiesCompletionStatus(course.id));
return this.utils.allPromises(promises);

View File

@ -96,7 +96,7 @@ export class CoreCoursesMyCoursesPage implements OnDestroy {
this.courseIds = courseIds.join(',');
if (this.courseIds) {
if (this.courseIds && this.coursesProvider.isGetCoursesByFieldAvailable()) {
// Load course image of all the courses.
promises.push(this.coursesProvider.getCoursesByField('ids', this.courseIds).then((coursesInfo) => {
coursesInfo = this.utils.arrayToObject(coursesInfo, 'id');

View File

@ -233,7 +233,7 @@ export class CoreCoursesMyOverviewPage implements OnDestroy {
this.courseIds = courseIds.join(',');
if (this.courseIds) {
if (this.courseIds && this.coursesProvider.isGetCoursesByFieldAvailable()) {
// Load course image of all the courses.
promises.push(this.coursesProvider.getCoursesByField('ids', this.courseIds).then((coursesInfo) => {
coursesInfo = this.utils.arrayToObject(coursesInfo, 'id');