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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
const parse = require('../../data/types');
const { toPronote, fromPronote } = require('../../data/objects');
const navigate = require('./navigate');
const PAGE_NAME = 'PageEmploiDuTemps';
const TAB_ID = 16;
const ACCOUNTS = ['student', 'parent'];
async function getTimetable(session, user, week)
{
const student = toPronote(session.user);
const timetable = await navigate(session, user, PAGE_NAME, TAB_ID, ACCOUNTS, {
avecAbsencesEleve: false, // TODO: Test what those parameters do
avecAbsencesRessource: true,
avecConseilDeClasse: true,
avecDisponibilites: true,
avecInfosPrefsGrille: true,
avecRessourceLibrePiedHoraire: false,
estEDTPermanence: false,
numeroSemaine: week, // *Clown emoji*
NumeroSemaine: week,
ressource: student,
Ressource: student
});
if (!timetable || !timetable.ListeCours) {
return null;
}
let iCalURL = null;
if (timetable.avecExportICal) {
const id = timetable.ParametreExportiCal;
iCalURL = `${session.server}ical/Edt.ics?icalsecurise=${id}&version=${session.params.version}`;
}
return {
hasCancelledLessons: timetable.avecCoursAnnule,
iCalURL,
lessons: timetable.ListeCours.map(o => fromPronote(o, ({
place, duree, DateDuCours, CouleurFond, ListeContenus, AvecTafPublie, Statut, estAnnule, estRetenue,
dispenseEleve
}) => ({
position: place,
duration: duree,
date: parse(DateDuCours),
status: Statut,
color: CouleurFond,
content: parse(ListeContenus),
hasHomework: AvecTafPublie,
isCancelled: !!estAnnule,
isDetention: !!estRetenue,
remoteLesson: !!dispenseEleve && dispenseEleve.V.maison
}))),
// I was unable to witness a filled "absences.joursCycle", so didn't include it
breaks: parse(timetable.recreations, ({ place }) => ({
position: place
}))
};
}
async function getFilledDaysAndWeeks(session, user)
{
const daysData = await navigate(session, user, PAGE_NAME + '_DomainePresence', TAB_ID, ACCOUNTS, {
Ressource: toPronote(session.user)
});
if (!daysData) {
return null;
}
return {
filledWeeks: parse(daysData.Domaine),
filledDays: parse(daysData.joursPresence)
}
}
module.exports = {
getTimetable,
getFilledDaysAndWeeks
};
|