summaryrefslogtreecommitdiff
path: root/school/node_modules/pronote-api/src/fetch/pronote/evaluations.js
diff options
context:
space:
mode:
Diffstat (limited to 'school/node_modules/pronote-api/src/fetch/pronote/evaluations.js')
-rw-r--r--school/node_modules/pronote-api/src/fetch/pronote/evaluations.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/school/node_modules/pronote-api/src/fetch/pronote/evaluations.js b/school/node_modules/pronote-api/src/fetch/pronote/evaluations.js
new file mode 100644
index 0000000..c9065fd
--- /dev/null
+++ b/school/node_modules/pronote-api/src/fetch/pronote/evaluations.js
@@ -0,0 +1,49 @@
+const parse = require('../../data/types');
+const { toPronote } = require('../../data/objects');
+
+const navigate = require('./navigate');
+
+const PAGE_NAME = 'DernieresEvaluations';
+const TAB_ID = 201;
+const ACCOUNTS = ['student', 'parent'];
+
+async function getEvaluations(session, user, period)
+{
+ const evaluations = await navigate(session, user, PAGE_NAME, TAB_ID, ACCOUNTS, {
+ periode: period.name ? toPronote(period) : period
+ });
+
+ if (!evaluations) {
+ return null;
+ }
+
+ return parse(evaluations.listeEvaluations, ({
+ listeNiveauxDAcquisitions, listePaliers, matiere, individu, coefficient, descriptif, date, periode
+ }) => ({
+ title: descriptif,
+ acquisitionLevels: parse(listeNiveauxDAcquisitions, ({
+ abbreviation, ordre, pilier, coefficient, domaine, item
+ }) => ({
+ position: ordre,
+ value: abbreviation,
+ pillar: parse(pilier, ({ strPrefixes }) => ({
+ prefixes: strPrefixes.split(', ')
+ })),
+ coefficient,
+ domain: parse(domaine),
+ item: item && parse(item) || null
+ })),
+ levels: parse(listePaliers),
+ subject: parse(matiere, ({ couleur, ordre, serviceConcerne }) => ({
+ position: ordre,
+ service: parse(serviceConcerne),
+ color: couleur
+ })),
+ teacher: parse(individu),
+ coefficient,
+ date: parse(date),
+ period: parse(periode)
+ }));
+}
+
+module.exports = getEvaluations;