diff --git a/src/main/webapp/app/exam/manage/exams/exam-update.component.ts b/src/main/webapp/app/exam/manage/exams/exam-update.component.ts index 78ac39e5a86e..55642d60eb60 100644 --- a/src/main/webapp/app/exam/manage/exams/exam-update.component.ts +++ b/src/main/webapp/app/exam/manage/exams/exam-update.component.ts @@ -130,7 +130,7 @@ export class ExamUpdateComponent implements OnInit, OnDestroy { updateExamWorkingTime() { if (this.exam.testExam) return; - this.exam.workingTime = examWorkingTime(this.exam); + this.exam.workingTime = examWorkingTime(this.exam) ?? 0; } /** diff --git a/src/main/webapp/app/exam/participate/exam.utils.ts b/src/main/webapp/app/exam/participate/exam.utils.ts index 87f512833a79..d3038851c1b0 100644 --- a/src/main/webapp/app/exam/participate/exam.utils.ts +++ b/src/main/webapp/app/exam/participate/exam.utils.ts @@ -21,7 +21,8 @@ export const endTime = (exam: Exam, studentExam: StudentExam): dayjs.Dayjs | und }; /** - * Calculates the working time of the exam in seconds + * Calculates the working time of the exam in seconds. + * If either the exam or the exam dates are not set, undefined is returned. * * @param exam * @return {number | undefined} @@ -29,7 +30,8 @@ export const endTime = (exam: Exam, studentExam: StudentExam): dayjs.Dayjs | und export const examWorkingTime = (exam?: Exam): number | undefined => normalWorkingTime(exam?.startDate, exam?.endDate); /** - * Calculates the time between start and end date in seconds + * Calculates the time between start and end date in seconds. + * If either the start or end date is not set, undefined is returned. * * @param startDate * @param endDate