From 4a10f1a0683ea5f0a3d90e92a3116fa3852cb136 Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Tue, 6 Jun 2023 11:29:54 +0200 Subject: [PATCH] MOBILE-4345 quiz: Fix sequential navigation --- src/addons/mod/quiz/pages/player/player.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/addons/mod/quiz/pages/player/player.ts b/src/addons/mod/quiz/pages/player/player.ts index 56852bcfa..b70daf5f8 100644 --- a/src/addons/mod/quiz/pages/player/player.ts +++ b/src/addons/mod/quiz/pages/player/player.ts @@ -531,6 +531,14 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave { return; } + // @todo MOBILE-4350: This is called before getting the attempt data in sequential quizzes as a workaround for a bug + // in the LMS. Once the bug has been fixed, this should be reverted. + if (this.isSequential) { + await CoreUtils.ignoreErrors( + AddonModQuiz.logViewAttempt(this.attempt.id, page, this.preflightData, this.offline, this.quiz), + ); + } + const data = await AddonModQuiz.getAttemptData(this.attempt.id, page, this.preflightData, { cmId: this.quiz.coursemodule, readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK, @@ -559,9 +567,12 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave { }); // Mark the page as viewed. - CoreUtils.ignoreErrors( - AddonModQuiz.logViewAttempt(this.attempt.id, page, this.preflightData, this.offline, this.quiz), - ); + if (!this.isSequential) { + // @todo MOBILE-4350: Undo workaround. + CoreUtils.ignoreErrors( + AddonModQuiz.logViewAttempt(this.attempt.id, page, this.preflightData, this.offline, this.quiz), + ); + } // Start looking for changes. this.autoSave.startCheckChangesProcess(this.quiz, this.attempt, this.preflightData, this.offline);