forked from CIT/Vmeda.Online
		
	Merge pull request #2064 from dpalou/MOBILE-3068
MOBILE-3068 course: Fix not enrolled error when prefetch course
This commit is contained in:
		
						commit
						587a8e4114
					
				| @ -97,6 +97,12 @@ export class AddonCourseCompletionCourseOptionHandler implements CoreCourseOptio | |||||||
|         return this.courseCompletionProvider.getCompletion(course.id, undefined, { |         return this.courseCompletionProvider.getCompletion(course.id, undefined, { | ||||||
|             getFromCache: false, |             getFromCache: false, | ||||||
|             emergencyCache: false |             emergencyCache: false | ||||||
|  |         }).catch((error) => { | ||||||
|  |             if (error && error.errorcode == 'notenroled') { | ||||||
|  |                 // Not enrolled error, probably a teacher. Ignore error.
 | ||||||
|  |             } else { | ||||||
|  |                 return Promise.reject(error); | ||||||
|  |             } | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -110,6 +110,7 @@ export class AddonCourseCompletionProvider { | |||||||
| 
 | 
 | ||||||
|             preSets.cacheKey = this.getCompletionCacheKey(courseId, userId); |             preSets.cacheKey = this.getCompletionCacheKey(courseId, userId); | ||||||
|             preSets.updateFrequency = preSets.updateFrequency || CoreSite.FREQUENCY_SOMETIMES; |             preSets.updateFrequency = preSets.updateFrequency || CoreSite.FREQUENCY_SOMETIMES; | ||||||
|  |             preSets.cacheErrors = ['notenroled']; | ||||||
| 
 | 
 | ||||||
|             return site.read('core_completion_get_course_completion_status', data, preSets).then((data) => { |             return site.read('core_completion_get_course_completion_status', data, preSets).then((data) => { | ||||||
|                 if (data.completionstatus) { |                 if (data.completionstatus) { | ||||||
|  | |||||||
| @ -750,15 +750,15 @@ export class CoreSite { | |||||||
|                     // Save the error instead of deleting the cache entry so the same content is displayed in offline.
 |                     // Save the error instead of deleting the cache entry so the same content is displayed in offline.
 | ||||||
|                     this.saveToCache(method, data, error, preSets); |                     this.saveToCache(method, data, error, preSets); | ||||||
| 
 | 
 | ||||||
|                     return Promise.reject(error); |  | ||||||
|                 } else if (typeof preSets.emergencyCache !== 'undefined' && !preSets.emergencyCache) { |  | ||||||
|                     this.logger.debug(`WS call '${method}' failed. Emergency cache is forbidden, rejecting.`); |  | ||||||
| 
 |  | ||||||
|                     return Promise.reject(error); |                     return Promise.reject(error); | ||||||
|                 } else if (preSets.cacheErrors && preSets.cacheErrors.indexOf(error.errorcode) != -1) { |                 } else if (preSets.cacheErrors && preSets.cacheErrors.indexOf(error.errorcode) != -1) { | ||||||
|                     // Save the error instead of deleting the cache entry so the same content is displayed in offline.
 |                     // Save the error instead of deleting the cache entry so the same content is displayed in offline.
 | ||||||
|                     this.saveToCache(method, data, error, preSets); |                     this.saveToCache(method, data, error, preSets); | ||||||
| 
 | 
 | ||||||
|  |                     return Promise.reject(error); | ||||||
|  |                 } else if (typeof preSets.emergencyCache !== 'undefined' && !preSets.emergencyCache) { | ||||||
|  |                     this.logger.debug(`WS call '${method}' failed. Emergency cache is forbidden, rejecting.`); | ||||||
|  | 
 | ||||||
|                     return Promise.reject(error); |                     return Promise.reject(error); | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user