Merge pull request #2956 from dpalou/MOBILE-3877
MOBILE-3877 quiz: Fix review not opened after finish offline quizmain
commit
3fa0136cbc
|
@ -208,7 +208,8 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
await AddonModQuizSync.setSyncWarnings(quiz.id, []);
|
await AddonModQuizSync.setSyncWarnings(quiz.id, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AddonModQuiz.isQuizOffline(quiz) && sync) {
|
if (AddonModQuiz.isQuizOffline(quiz)) {
|
||||||
|
if (sync) {
|
||||||
// Try to sync the quiz.
|
// Try to sync the quiz.
|
||||||
try {
|
try {
|
||||||
await this.syncActivity(showErrors);
|
await this.syncActivity(showErrors);
|
||||||
|
@ -216,6 +217,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
// Ignore errors, keep getting data even if sync fails.
|
// Ignore errors, keep getting data even if sync fails.
|
||||||
this.autoReview = undefined;
|
this.autoReview = undefined;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.autoReview = undefined;
|
this.autoReview = undefined;
|
||||||
this.showStatusSpinner = false;
|
this.showStatusSpinner = false;
|
||||||
|
|
|
@ -664,11 +664,21 @@ export class AddonModQuizProvider {
|
||||||
/**
|
/**
|
||||||
* Given a list of attempts, returns the last finished attempt.
|
* 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.
|
* @return Last finished attempt.
|
||||||
*/
|
*/
|
||||||
getLastFinishedAttemptFromList(attempts?: AddonModQuizAttemptWSData[]): AddonModQuizAttemptWSData | undefined {
|
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