summaryrefslogtreecommitdiff
path: root/alarm/node_modules/pronote-api/src/fetch/pronote/marks.js
diff options
context:
space:
mode:
Diffstat (limited to 'alarm/node_modules/pronote-api/src/fetch/pronote/marks.js')
-rw-r--r--alarm/node_modules/pronote-api/src/fetch/pronote/marks.js71
1 files changed, 71 insertions, 0 deletions
diff --git a/alarm/node_modules/pronote-api/src/fetch/pronote/marks.js b/alarm/node_modules/pronote-api/src/fetch/pronote/marks.js
new file mode 100644
index 0000000..dcb7644
--- /dev/null
+++ b/alarm/node_modules/pronote-api/src/fetch/pronote/marks.js
@@ -0,0 +1,71 @@
+const parse = require('../../data/types');
+const { toPronote } = require('../../data/objects');
+
+const navigate = require('./navigate');
+
+const PAGE_NAME = 'DernieresNotes';
+const TAB_ID = 198;
+const ACCOUNTS = ['student', 'parent'];
+
+async function getMarks(session, user, period)
+{
+ const marks = await navigate(session, user, PAGE_NAME, TAB_ID, ACCOUNTS, {
+ Periode: period.name ? toPronote(period) : period
+ });
+
+ if (!marks) {
+ return null;
+ }
+
+ const result = {};
+
+ if (marks.moyGenerale) {
+ result.studentAverage = parse(marks.moyGenerale);
+ result.studentAverageScale = parse(marks.baremeMoyGenerale);
+ result.defaultStudentAverageScale = parse(marks.baremeMoyGeneraleParDefaut);
+ }
+
+ if (marks.moyGeneraleClasse) {
+ result.studentClassAverage = parse(marks.moyGeneraleClasse);
+ }
+
+ return {
+ ...result,
+ subjects: marks.avecDetailService && parse(marks.listeServices, ({
+ ordre, estServiceEnGroupe,
+ moyEleve, baremeMoyEleve, baremeMoyEleveParDefaut, moyClasse, moyMax, moyMin,
+ couleur
+ }) => ({
+ position: ordre,
+ isGroupSubject: estServiceEnGroupe,
+ studentAverage: parse(moyEleve),
+ studentAverageScale: parse(baremeMoyEleve),
+ defaultStudentAverageScale: parse(baremeMoyEleveParDefaut),
+ studentClassAverage: parse(moyClasse),
+ maxAverage: parse(moyMax),
+ minAverage: parse(moyMin),
+ color: couleur
+ })) || [],
+ marks: marks.avecDetailDevoir && parse(marks.listeDevoirs, ({
+ note, bareme, baremeParDefaut, date, service, periode, moyenne, estEnGroupe, noteMax, noteMin,
+ commentaire, coefficient
+ }) => ({
+ subject: parse(service, ({ couleur }) => ({
+ color: couleur
+ })),
+ title: commentaire,
+ value: parse(note),
+ scale: parse(bareme),
+ average: parse(moyenne),
+ defaultScale: parse(baremeParDefaut),
+ coefficient,
+ min: parse(noteMin) || -1,
+ max: parse(noteMax) || -1,
+ date: parse(date),
+ period: parse(periode),
+ isGroupMark: estEnGroupe
+ })) || []
+ };
+}
+
+module.exports = getMarks;