MOBILE-3320 core: Always pass initial value to reduce function
parent
b36051d5d0
commit
a3b35a9619
|
@ -29,6 +29,7 @@ import {
|
|||
AddonModAssignSubmission,
|
||||
AddonModAssignProvider,
|
||||
AddonModAssign,
|
||||
AddonModAssignGrade,
|
||||
} from '../../services/assign';
|
||||
import { AddonModAssignHelper, AddonModAssignSubmissionFormatted } from '../../services/assign-helper';
|
||||
import { AddonModAssignOffline } from '../../services/assign-offline';
|
||||
|
@ -252,7 +253,10 @@ export class AddonModAssignSubmissionListPage implements AfterViewInit, OnDestro
|
|||
// Get the last grade of the submission.
|
||||
const grade = grades
|
||||
.filter((grade) => grade.userid == submission.userid)
|
||||
.reduce((a, b) => (a.timemodified > b.timemodified ? a : b));
|
||||
.reduce(
|
||||
(a, b) => (a && a.timemodified > b.timemodified ? a : b),
|
||||
<AddonModAssignGrade | undefined> undefined,
|
||||
);
|
||||
|
||||
if (grade && grade.timemodified < submission.timemodified) {
|
||||
submission.gradingstatus = AddonModAssignProvider.GRADED_FOLLOWUP_SUBMIT;
|
||||
|
|
|
@ -190,7 +190,10 @@ export class AddonModLessonOfflineProvider {
|
|||
const attempts = await this.getRetakeAttemptsForPage(lessonId, retake, retakeData.lastquestionpage, siteId);
|
||||
|
||||
// Return the attempt with highest timemodified.
|
||||
return attempts.reduce((a, b) => a.timemodified > b.timemodified ? a : b);
|
||||
return attempts.reduce(
|
||||
(a, b) => a && a.timemodified > b.timemodified ? a : b,
|
||||
<AddonModLessonPageAttemptRecord | undefined> undefined,
|
||||
);
|
||||
} catch {
|
||||
// Error, return undefined.
|
||||
}
|
||||
|
|
|
@ -632,7 +632,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
|
|||
const completionModules = (<CoreCourseModule[]> [])
|
||||
.concat(...this.sections!.map((section) => section.modules))
|
||||
.map((module) => module.completion && module.completion > 0 ? 1 : module.completion)
|
||||
.reduce((accumulator, currentValue) => (accumulator || 0) + (currentValue || 0));
|
||||
.reduce((accumulator, currentValue) => (accumulator || 0) + (currentValue || 0), 0);
|
||||
|
||||
const moduleProgressPercent = 100 / (completionModules || 1);
|
||||
// Use min/max here to avoid floating point rounding errors over/under-flowing the progress bar.
|
||||
|
|
Loading…
Reference in New Issue