From 72205fcfda395c6cc3e73aec9815b865c274b456 Mon Sep 17 00:00:00 2001 From: Andreas Pfurtscheller <1051396+aplr@users.noreply.github.com> Date: Sat, 14 Oct 2023 12:52:52 +0200 Subject: [PATCH] Fix tests --- .../webapp/app/exam/manage/exams/exam-update.component.ts | 2 +- src/main/webapp/app/exam/participate/exam.utils.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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