MOBILE-2873 quiz: Avoid start new attempt if first synced
parent
d767b7514e
commit
bf23505864
|
@ -239,7 +239,16 @@ export class AddonModQuizPrefetchHandler extends CoreCourseActivityPrefetchHandl
|
|||
* @return {Promise<any>} Promise resolved when done.
|
||||
*/
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -559,16 +568,25 @@ export class AddonModQuizPrefetchHandler extends CoreCourseActivityPrefetchHandl
|
|||
* Sync a module.
|
||||
*
|
||||
* @param {any} module Module.
|
||||
* @param {number} courseId Course ID the module belongs to
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @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) {
|
||||
this.syncProvider = this.injector.get(AddonModQuizSyncProvider);
|
||||
}
|
||||
|
||||
return this.quizProvider.getQuiz(module.course, module.id).then((quiz) => {
|
||||
return this.syncProvider.syncQuiz(quiz, false, siteId);
|
||||
return this.quizProvider.getQuiz(courseId, module.id).then((quiz) => {
|
||||
return this.syncProvider.syncQuiz(quiz, false, siteId).then((results) => {
|
||||
module.attemptFinished = (results && results.attemptFinished) || false;
|
||||
|
||||
return results;
|
||||
}).catch(() => {
|
||||
// Ignore errors.
|
||||
|
||||
module.attemptFinished = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue