Merge pull request #3642 from NoelDeMartin/MOBILE-4287
MOBILE-4287 quiz: Improve grace period UXmain
commit
cfaa844414
|
@ -140,10 +140,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
// Stop auto save.
|
this.stopAutoSave();
|
||||||
this.autoSave.cancelAutoSave();
|
|
||||||
this.autoSave.stopCheckChangesProcess();
|
|
||||||
this.autoSaveErrorSubscription?.unsubscribe();
|
|
||||||
|
|
||||||
if (this.quiz) {
|
if (this.quiz) {
|
||||||
// Unblock the quiz so it can be synced.
|
// Unblock the quiz so it can be synced.
|
||||||
|
@ -423,9 +420,18 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
|
||||||
|
|
||||||
CoreEvents.trigger(CoreEvents.ACTIVITY_DATA_SENT, { module: 'quiz' });
|
CoreEvents.trigger(CoreEvents.ACTIVITY_DATA_SENT, { module: 'quiz' });
|
||||||
|
|
||||||
// Leave the player.
|
if (!timeUp || !this.quiz.graceperiod) {
|
||||||
this.forceLeave = true;
|
// Leave the player.
|
||||||
CoreNavigator.back();
|
this.forceLeave = true;
|
||||||
|
CoreNavigator.back();
|
||||||
|
} else {
|
||||||
|
// Stay in player to show summary.
|
||||||
|
this.stopAutoSave();
|
||||||
|
this.clearTimer();
|
||||||
|
|
||||||
|
await this.refreshAttempt();
|
||||||
|
await this.loadSummary();
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
CoreDomUtils.showErrorModalDefault(error, 'addon.mod_quiz.errorsaveattempt', true);
|
CoreDomUtils.showErrorModalDefault(error, 'addon.mod_quiz.errorsaveattempt', true);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -495,6 +501,13 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove timer info.
|
||||||
|
*/
|
||||||
|
protected clearTimer(): void {
|
||||||
|
delete this.endTime;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a page questions.
|
* Load a page questions.
|
||||||
*
|
*
|
||||||
|
@ -542,6 +555,22 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
|
||||||
this.autoSave.startCheckChangesProcess(this.quiz, this.attempt, this.preflightData, this.offline);
|
this.autoSave.startCheckChangesProcess(this.quiz, this.attempt, this.preflightData, this.offline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh attempt data.
|
||||||
|
*/
|
||||||
|
protected async refreshAttempt(): Promise<void> {
|
||||||
|
if (!this.quiz) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const attempts = await AddonModQuiz.getUserAttempts(this.quiz.id, {
|
||||||
|
cmId: this.quiz.coursemodule,
|
||||||
|
readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.attempt = attempts.find(attempt => attempt.id === this.attempt?.id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load attempt summary.
|
* Load attempt summary.
|
||||||
*
|
*
|
||||||
|
@ -810,6 +839,15 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
|
||||||
this.finishAttempt(false, true);
|
this.finishAttempt(false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop auto-saving answers.
|
||||||
|
*/
|
||||||
|
protected stopAutoSave(): void {
|
||||||
|
this.autoSave.cancelAutoSave();
|
||||||
|
this.autoSave.stopCheckChangesProcess();
|
||||||
|
this.autoSaveErrorSubscription?.unsubscribe();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue