Skip to content

Commit

Permalink
feat: add global averages
Browse files Browse the repository at this point in the history
  • Loading branch information
Vexcited committed Jan 17, 2024
1 parent 176720e commit d3a788d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions examples/grades-overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,11 @@ import { authenticatePronoteCredentials, PronoteApiAccountId, PronoteApiGradeTyp
});

console.groupEnd();

console.group("--- GLOBAL AVERAGE ---\n");

console.log("Student:", gradesOverview.overallAverage);
console.log("Class:", gradesOverview.classAverage);

console.groupEnd();
})();
7 changes: 6 additions & 1 deletion src/client/Pronote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { getUTCDate, setDayToEnd, setDayToStart } from "~/utils/dates";
import { callApiUserGrades } from "~/api/user/grades";
import { StudentGrade } from "~/parser/grade";
import { StudentAverage } from "~/parser/average";
import { readPronoteApiGrade } from "~/pronote/grades";

export default class Pronote {
/**
Expand Down Expand Up @@ -196,6 +197,7 @@ export default class Pronote {

/**
* Get grades overview for a specific period.
* Including student's grades with averages and the global averages.
*
* @remark Internally used in the `Period` class.
* @param period - Period the grades overview will be from.
Expand All @@ -211,7 +213,10 @@ export default class Pronote {
grades: data.listeDevoirs.V
.map((grade) => new StudentGrade(this, period, grade)),
averages: data.listeServices.V
.map((average) => new StudentAverage(average))
.map((average) => new StudentAverage(average)),

overallAverage: readPronoteApiGrade(data.moyGenerale.V),
classAverage: readPronoteApiGrade(data.moyGeneraleClasse.V)
};
}
}

0 comments on commit d3a788d

Please sign in to comment.