summaryrefslogtreecommitdiff
path: root/school/node_modules/pronote-api/src/fetch/pronote/timetable.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2023-01-10 14:54:04 +0100
committerMinteck <contact@minteck.org>2023-01-10 14:54:04 +0100
commit99c1d9af689e5325f3cf535c4007b3aeb8325229 (patch)
treee663b3c2ebdbd67c818ac0c5147f0ce1d2463cda /school/node_modules/pronote-api/src/fetch/pronote/timetable.js
parent9871b03912fc28ad38b4037ebf26a78aa937baba (diff)
downloadpluralconnect-99c1d9af689e5325f3cf535c4007b3aeb8325229.tar.gz
pluralconnect-99c1d9af689e5325f3cf535c4007b3aeb8325229.tar.bz2
pluralconnect-99c1d9af689e5325f3cf535c4007b3aeb8325229.zip
Update - This is an automated commit
Diffstat (limited to 'school/node_modules/pronote-api/src/fetch/pronote/timetable.js')
-rw-r--r--school/node_modules/pronote-api/src/fetch/pronote/timetable.js81
1 files changed, 81 insertions, 0 deletions
diff --git a/school/node_modules/pronote-api/src/fetch/pronote/timetable.js b/school/node_modules/pronote-api/src/fetch/pronote/timetable.js
new file mode 100644
index 0000000..a98b9ce
--- /dev/null
+++ b/school/node_modules/pronote-api/src/fetch/pronote/timetable.js
@@ -0,0 +1,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
+};