MOBILE-3043 lesson: Improve error message when viewing old retakes
parent
6557793227
commit
db0fe2052a
|
@ -1383,6 +1383,7 @@
|
|||
"core.erroropenfilenoextension": "local_moodlemobileapp",
|
||||
"core.erroropenpopup": "local_moodlemobileapp",
|
||||
"core.errorrenamefile": "local_moodlemobileapp",
|
||||
"core.errorsomedatanotdownloaded": "local_moodlemobileapp",
|
||||
"core.errorsync": "local_moodlemobileapp",
|
||||
"core.errorsyncblocked": "local_moodlemobileapp",
|
||||
"core.explanationdigitalminor": "moodle",
|
||||
|
|
|
@ -19,6 +19,7 @@ import { CoreSitesProvider } from '@providers/sites';
|
|||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { CoreUserProvider } from '@core/user/providers/user';
|
||||
import { AddonModLessonProvider } from '../../providers/lesson';
|
||||
import { AddonModLessonHelperProvider } from '../../providers/helper';
|
||||
|
@ -44,11 +45,13 @@ export class AddonModLessonUserRetakePage implements OnInit {
|
|||
protected lessonId: number; // The lesson ID the retake belongs to.
|
||||
protected userId: number; // User ID to see the retakes.
|
||||
protected retakeNumber: number; // Number of the initial retake to see.
|
||||
protected previousSelectedRetake: number; // To be able to detect the previous selected retake when it has changed.
|
||||
|
||||
constructor(navParams: NavParams, sitesProvider: CoreSitesProvider, protected textUtils: CoreTextUtilsProvider,
|
||||
protected translate: TranslateService, protected domUtils: CoreDomUtilsProvider,
|
||||
protected userProvider: CoreUserProvider, protected timeUtils: CoreTimeUtilsProvider,
|
||||
protected lessonProvider: AddonModLessonProvider, protected lessonHelper: AddonModLessonHelperProvider) {
|
||||
protected lessonProvider: AddonModLessonProvider, protected lessonHelper: AddonModLessonHelperProvider,
|
||||
protected utils: CoreUtilsProvider) {
|
||||
|
||||
this.lessonId = navParams.get('lessonId');
|
||||
this.courseId = navParams.get('courseId');
|
||||
|
@ -75,7 +78,8 @@ export class AddonModLessonUserRetakePage implements OnInit {
|
|||
this.loaded = false;
|
||||
|
||||
this.setRetake(retakeNumber).catch((error) => {
|
||||
this.domUtils.showErrorModalDefault(error, 'Error getting attempt.');
|
||||
this.selectedRetake = this.previousSelectedRetake;
|
||||
this.domUtils.showErrorModal(this.utils.addDataNotDownloadedError(error, 'Error getting attempt.'));
|
||||
}).finally(() => {
|
||||
this.loaded = true;
|
||||
});
|
||||
|
@ -128,7 +132,7 @@ export class AddonModLessonUserRetakePage implements OnInit {
|
|||
|
||||
student.bestgrade = this.textUtils.roundToDecimals(student.bestgrade, 2);
|
||||
student.attempts.forEach((retake) => {
|
||||
if (this.retakeNumber == retake.try) {
|
||||
if (!this.selectedRetake && this.retakeNumber == retake.try) {
|
||||
// The retake specified as parameter exists. Use it.
|
||||
this.selectedRetake = this.retakeNumber;
|
||||
}
|
||||
|
@ -223,6 +227,7 @@ export class AddonModLessonUserRetakePage implements OnInit {
|
|||
}
|
||||
|
||||
this.retake = data;
|
||||
this.previousSelectedRetake = this.selectedRetake;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1383,6 +1383,7 @@
|
|||
"core.erroropenfilenoextension": "Error opening file: the file doesn't have an extension.",
|
||||
"core.erroropenpopup": "This activity is trying to open a popup. This is not supported in the app.",
|
||||
"core.errorrenamefile": "Error renaming file. Please try again.",
|
||||
"core.errorsomedatanotdownloaded": "If you downloaded this activity, please notice that some data isn't downloaded during the download process for performance and data usage reasons.",
|
||||
"core.errorsync": "An error occurred while synchronising. Please try again.",
|
||||
"core.errorsyncblocked": "This {{$a}} cannot be synchronised right now because of an ongoing process. Please try again later. If the problem persists, try restarting the app.",
|
||||
"core.explanationdigitalminor": "This information is required to determine if your age is over the digital age of consent. This is the age when an individual can consent to terms and conditions and their data being legally stored and processed.",
|
||||
|
|
|
@ -91,6 +91,7 @@
|
|||
"erroropenfilenoextension": "Error opening file: the file doesn't have an extension.",
|
||||
"erroropenpopup": "This activity is trying to open a popup. This is not supported in the app.",
|
||||
"errorrenamefile": "Error renaming file. Please try again.",
|
||||
"errorsomedatanotdownloaded": "If you downloaded this activity, please notice that some data isn't downloaded during the download process for performance and data usage reasons.",
|
||||
"errorsync": "An error occurred while synchronising. Please try again.",
|
||||
"errorsyncblocked": "This {{$a}} cannot be synchronised right now because of an ongoing process. Please try again later. If the problem persists, try restarting the app.",
|
||||
"explanationdigitalminor": "This information is required to determine if your age is over the digital age of consent. This is the age when an individual can consent to terms and conditions and their data being legally stored and processed.",
|
||||
|
|
|
@ -21,6 +21,7 @@ import { WebIntent } from '@ionic-native/web-intent';
|
|||
import { CoreAppProvider } from '../app';
|
||||
import { CoreDomUtilsProvider } from './dom';
|
||||
import { CoreMimetypeUtilsProvider } from './mimetype';
|
||||
import { CoreTextUtilsProvider } from './text';
|
||||
import { CoreEventsProvider } from '../events';
|
||||
import { CoreLoggerProvider } from '../logger';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
@ -66,10 +67,36 @@ export class CoreUtilsProvider {
|
|||
private domUtils: CoreDomUtilsProvider, logger: CoreLoggerProvider, private translate: TranslateService,
|
||||
private platform: Platform, private langProvider: CoreLangProvider, private eventsProvider: CoreEventsProvider,
|
||||
private fileOpener: FileOpener, private mimetypeUtils: CoreMimetypeUtilsProvider, private webIntent: WebIntent,
|
||||
private wsProvider: CoreWSProvider, private zone: NgZone) {
|
||||
private wsProvider: CoreWSProvider, private zone: NgZone, private textUtils: CoreTextUtilsProvider) {
|
||||
this.logger = logger.getInstance('CoreUtilsProvider');
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an error, add an extra warning to the error message and return the new error message.
|
||||
*
|
||||
* @param {any} error Error object or message.
|
||||
* @param {any} [defaultError] Message to show if the error is not a string.
|
||||
* @return {string} New error message.
|
||||
*/
|
||||
addDataNotDownloadedError(error: any, defaultError?: string): string {
|
||||
let errorMessage = error;
|
||||
|
||||
if (error && typeof error != 'string') {
|
||||
errorMessage = this.textUtils.getErrorMessageFromError(error);
|
||||
}
|
||||
|
||||
if (typeof errorMessage != 'string') {
|
||||
errorMessage = defaultError || '';
|
||||
}
|
||||
|
||||
if (!this.isWebServiceError(error)) {
|
||||
// Local error. Add an extra warning.
|
||||
errorMessage += '<br><br>' + this.translate.instant('core.errorsomedatanotdownloaded');
|
||||
}
|
||||
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to Promise.all, but if a promise fails this function's promise won't be rejected until ALL promises have finished.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue