MOBILE-4287 quiz: Go back when attempt is closed

main
Noel De Martin 2023-04-27 10:37:27 +02:00
parent e9fb8784b7
commit 58b9067803
1 changed files with 13 additions and 1 deletions

View File

@ -48,6 +48,7 @@ import { CoreForms } from '@singletons/form';
import { CoreDom } from '@singletons/dom';
import { CoreTime } from '@singletons/time';
import { CoreDirectivesRegistry } from '@singletons/directives-registry';
import { CoreWSError } from '@classes/errors/wserror';
/**
* Page that allows attempting a quiz.
@ -433,7 +434,18 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
await this.loadSummary();
}
} catch (error) {
CoreDomUtils.showErrorModalDefault(error, 'addon.mod_quiz.errorsaveattempt', true);
// eslint-disable-next-line promise/catch-or-return
CoreDomUtils
.showErrorModalDefault(error, 'addon.mod_quiz.errorsaveattempt', true)
.then(async alert => {
await alert?.onWillDismiss();
if (error instanceof CoreWSError && error.errorcode === 'attemptalreadyclosed') {
CoreNavigator.back();
}
return;
});
} finally {
modal?.dismiss();
}