diff --git a/src/api/user/grades/types.ts b/src/api/user/grades/types.ts index 0b6ec59..6c163e9 100644 --- a/src/api/user/grades/types.ts +++ b/src/api/user/grades/types.ts @@ -141,7 +141,7 @@ export interface PronoteApiUserGrades { V: unknown[] } - moyenne: { + moyenne?: { _T: 10 /** Overall grade on this exam. */ V: string diff --git a/src/parser/grade.ts b/src/parser/grade.ts index c8da98b..aba1975 100644 --- a/src/parser/grade.ts +++ b/src/parser/grade.ts @@ -14,7 +14,7 @@ export class StudentGrade { readonly #defaultOutOf?: number | PronoteApiGradeType; readonly #date: Date; readonly #subject: StudentSubject; - readonly #average: number | PronoteApiGradeType; + readonly #average?: number | PronoteApiGradeType; readonly #max: number | PronoteApiGradeType; readonly #min: number | PronoteApiGradeType; readonly #coefficient: number; @@ -33,7 +33,11 @@ export class StudentGrade { this.#defaultOutOf = readPronoteApiGrade(grade.baremeParDefaut.V); this.#date = readPronoteApiDate(grade.date.V); this.#subject = new StudentSubject(grade.service.V); - this.#average = readPronoteApiGrade(grade.moyenne.V); + + if (grade.moyenne) { + this.#average = readPronoteApiGrade(grade.moyenne.V); + } + this.#max = readPronoteApiGrade(grade.noteMax.V); this.#min = readPronoteApiGrade(grade.noteMin.V); this.#coefficient = grade.coefficient; @@ -94,7 +98,7 @@ export class StudentGrade { } /** the average of the class */ - get average (): number | PronoteApiGradeType { + get average (): number | PronoteApiGradeType | undefined { return this.#average; }