forked from CIT/Vmeda.Online
		
	MOBILE-2873 quiz: Avoid start new attempt if first synced
This commit is contained in:
		
							parent
							
								
									d767b7514e
								
							
						
					
					
						commit
						bf23505864
					
				| @ -239,7 +239,16 @@ export class AddonModQuizPrefetchHandler extends CoreCourseActivityPrefetchHandl | |||||||
|      * @return {Promise<any>} Promise resolved when done. |      * @return {Promise<any>} Promise resolved when done. | ||||||
|      */ |      */ | ||||||
|     prefetch(module: any, courseId?: number, single?: boolean, dirPath?: string, canStart: boolean = true): Promise<any> { |     prefetch(module: any, courseId?: number, single?: boolean, dirPath?: string, canStart: boolean = true): Promise<any> { | ||||||
|  |         if (module.attemptFinished) { | ||||||
|  |             // Delete the value so it does not block anything if true.
 | ||||||
|  |             delete module.attemptFinished; | ||||||
|  | 
 | ||||||
|  |             // Quiz got synced recently and an attempt has finished. Do not prefetch.
 | ||||||
|  |             return Promise.resolve(); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         return this.prefetchPackage(module, courseId, single, this.prefetchQuiz.bind(this), undefined, canStart); |         return this.prefetchPackage(module, courseId, single, this.prefetchQuiz.bind(this), undefined, canStart); | ||||||
|  | 
 | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -559,16 +568,25 @@ export class AddonModQuizPrefetchHandler extends CoreCourseActivityPrefetchHandl | |||||||
|      * Sync a module. |      * Sync a module. | ||||||
|      * |      * | ||||||
|      * @param {any} module Module. |      * @param {any} module Module. | ||||||
|  |      * @param {number} courseId Course ID the module belongs to | ||||||
|      * @param {string} [siteId] Site ID. If not defined, current site. |      * @param {string} [siteId] Site ID. If not defined, current site. | ||||||
|      * @return {Promise<any>} Promise resolved when done. |      * @return {Promise<any>} Promise resolved when done. | ||||||
|      */ |      */ | ||||||
|     sync(module: any, siteId?: string): Promise<any> { |     sync(module: any, courseId: number, siteId?: any): Promise<any> { | ||||||
|         if (!this.syncProvider) { |         if (!this.syncProvider) { | ||||||
|             this.syncProvider = this.injector.get(AddonModQuizSyncProvider); |             this.syncProvider = this.injector.get(AddonModQuizSyncProvider); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return this.quizProvider.getQuiz(module.course, module.id).then((quiz) => { |         return this.quizProvider.getQuiz(courseId, module.id).then((quiz) => { | ||||||
|             return this.syncProvider.syncQuiz(quiz, false, siteId); |             return this.syncProvider.syncQuiz(quiz, false, siteId).then((results) => { | ||||||
|  |                 module.attemptFinished = (results && results.attemptFinished) || false; | ||||||
|  | 
 | ||||||
|  |                 return results; | ||||||
|  |             }).catch(() => { | ||||||
|  |                 // Ignore errors.
 | ||||||
|  | 
 | ||||||
|  |                 module.attemptFinished = false; | ||||||
|  |             }); | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user