Merge pull request #2956 from dpalou/MOBILE-3877
MOBILE-3877 quiz: Fix review not opened after finish offline quizmain
commit
3fa0136cbc
|
@ -208,13 +208,15 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
await AddonModQuizSync.setSyncWarnings(quiz.id, []);
|
||||
}
|
||||
|
||||
if (AddonModQuiz.isQuizOffline(quiz) && sync) {
|
||||
// Try to sync the quiz.
|
||||
try {
|
||||
await this.syncActivity(showErrors);
|
||||
} catch {
|
||||
// Ignore errors, keep getting data even if sync fails.
|
||||
this.autoReview = undefined;
|
||||
if (AddonModQuiz.isQuizOffline(quiz)) {
|
||||
if (sync) {
|
||||
// Try to sync the quiz.
|
||||
try {
|
||||
await this.syncActivity(showErrors);
|
||||
} catch {
|
||||
// Ignore errors, keep getting data even if sync fails.
|
||||
this.autoReview = undefined;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.autoReview = undefined;
|
||||
|
|
|
@ -664,11 +664,21 @@ export class AddonModQuizProvider {
|
|||
/**
|
||||
* Given a list of attempts, returns the last finished attempt.
|
||||
*
|
||||
* @param attempts Attempts.
|
||||
* @param attempts Attempts sorted. First attempt should be the first on the list.
|
||||
* @return Last finished attempt.
|
||||
*/
|
||||
getLastFinishedAttemptFromList(attempts?: AddonModQuizAttemptWSData[]): AddonModQuizAttemptWSData | undefined {
|
||||
return attempts?.find(attempt => this.isAttemptFinished(attempt.state));
|
||||
if (!attempts) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let i = attempts.length - 1; i >= 0; i--) {
|
||||
const attempt = attempts[i];
|
||||
|
||||
if (this.isAttemptFinished(attempt.state)) {
|
||||
return attempt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue