forked from CIT/Vmeda.Online
		
	MOBILE-2969 quiz: Fix review attempt when it shouldn't
This commit is contained in:
		
							parent
							
								
									73f8b5a729
								
							
						
					
					
						commit
						072d6dde3e
					
				| @ -119,7 +119,12 @@ export class AddonModQuizAttemptPage implements OnInit { | ||||
|             accessInfo = quizAccessInfo; | ||||
| 
 | ||||
|             if (accessInfo.canreviewmyattempts) { | ||||
|                 return this.quizProvider.getAttemptReview(this.attemptId, -1).catch(() => { | ||||
|                 // Check if the user can review the attempt.
 | ||||
|                 return this.quizProvider.invalidateAttemptReviewForPage(this.attemptId, -1).catch(() => { | ||||
|                     // Ignore errors.
 | ||||
|                 }).then(() => { | ||||
|                     return this.quizProvider.getAttemptReview(this.attemptId, -1); | ||||
|                 }).catch(() => { | ||||
|                     // Error getting the review, assume the user cannot review the attempt.
 | ||||
|                     accessInfo.canreviewmyattempts = false; | ||||
|                 }); | ||||
|  | ||||
| @ -403,7 +403,8 @@ export class AddonModQuizProvider { | ||||
|                     page: page | ||||
|                 }, | ||||
|                 preSets: CoreSiteWSPreSets = { | ||||
|                     cacheKey: this.getAttemptReviewCacheKey(attemptId, page) | ||||
|                     cacheKey: this.getAttemptReviewCacheKey(attemptId, page), | ||||
|                     cacheErrors: ['noreview'] | ||||
|                 }; | ||||
| 
 | ||||
|             if (ignoreCache) { | ||||
|  | ||||
| @ -124,6 +124,11 @@ export interface CoreSiteWSPreSets { | ||||
|      * Whether the request will be be sent immediately as a single request. Defaults to false. | ||||
|      */ | ||||
|     skipQueue?: boolean; | ||||
| 
 | ||||
|     /** | ||||
|      * Cache the response if it returns an errorcode present in this list. | ||||
|      */ | ||||
|     cacheErrors?: string[]; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
| @ -713,6 +718,11 @@ export class CoreSite { | ||||
|                 } else if (typeof preSets.emergencyCache !== 'undefined' && !preSets.emergencyCache) { | ||||
|                     this.logger.debug(`WS call '${method}' failed. Emergency cache is forbidden, rejecting.`); | ||||
| 
 | ||||
|                     return Promise.reject(error); | ||||
|                 } 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.
 | ||||
|                     this.saveToCache(method, data, error, preSets); | ||||
| 
 | ||||
|                     return Promise.reject(error); | ||||
|                 } | ||||
| 
 | ||||
| @ -735,7 +745,7 @@ export class CoreSite { | ||||
|             }); | ||||
|         }).then((response) => { | ||||
|             // Check if the response is an error, this happens if the error was stored in the cache.
 | ||||
|             if (response && typeof response.exception !== 'undefined') { | ||||
|             if (response && (typeof response.exception != 'undefined' || typeof response.errorcode != 'undefined')) { | ||||
|                 return Promise.reject(response); | ||||
|             } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user