From 28e9fdc9d8d7ecc1e0f86bec3f6b88ca62fd09e7 Mon Sep 17 00:00:00 2001 From: dpalou Date: Thu, 18 Oct 2018 16:40:22 +0200 Subject: [PATCH] MOBILE-1874 assign: Allow admins view assignments in site home --- src/addon/mod/assign/providers/assign.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/addon/mod/assign/providers/assign.ts b/src/addon/mod/assign/providers/assign.ts index a1e3a329a..14568639c 100644 --- a/src/addon/mod/assign/providers/assign.ts +++ b/src/addon/mod/assign/providers/assign.ts @@ -136,13 +136,20 @@ export class AddonModAssignProvider { protected getAssignmentByField(courseId: number, key: string, value: any, siteId?: string): Promise { return this.sitesProvider.getSite(siteId).then((site) => { const params = { - courseids: [courseId] + courseids: [courseId], + includenotenrolledcourses: 1 }, preSets = { cacheKey: this.getAssignmentCacheKey(courseId) }; - return site.read('mod_assign_get_assignments', params, preSets).then((response) => { + return site.read('mod_assign_get_assignments', params, preSets).catch(() => { + // In 3.6 we added a new parameter includenotenrolledcourses that could cause offline data not to be found. + // Retry again without the param to check if the request is already cached. + delete params.includenotenrolledcourses; + + return site.read('mod_assign_get_assignments', params, preSets); + }).then((response) => { // Search the assignment to return. if (response.courses && response.courses.length) { const assignments = response.courses[0].assignments;