summaryrefslogtreecommitdiff
path: root/alarm/node_modules/pronote-api/src/fetch/pronote/evaluations.js
blob: c9065fd103dd53f3566477d8f6140472162e0f79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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;