MOBILE-2431 courses: Fix webservice not available error
parent
4cb669ee6a
commit
11013c69ab
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in New Issue