ecoledirecte.js
Version:
Good-looking client for EcoleDirecte's private API.
126 lines (125 loc) • 4.5 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Subject = exports.Period = void 0;
const classes_1 = require("../classes");
class Period {
constructor(o) {
this.code = o.idPeriode;
this.name = o.periode;
this.yearly = o.annuel;
this.closed = o.cloture;
this.start = new Date(o.dateDebut);
this.end = new Date(o.dateFin);
this.mockExam = o.examenBlanc;
this.headcount = o.ensembleMatieres.effectif
? +o.ensembleMatieres.effectif
: undefined;
this.rank = o.ensembleMatieres.rang ? +o.ensembleMatieres.rang : undefined;
this.headTeacher = o.ensembleMatieres.nomPP;
this.appraisals = {
CE: o.ensembleMatieres.appreciationCE,
PP: o.ensembleMatieres.appreciationPP,
VS: o.ensembleMatieres.appreciationVS,
};
this.class = {
appraisal: o.ensembleMatieres.appreciationGeneraleClasse,
averageGrade: o.ensembleMatieres.moyenneClasse
? +o.ensembleMatieres.moyenneClasse.replace(/,/, ".")
: undefined,
};
this.council = {
start: o.dateConseil
? new Date(o.dateConseil + " " + (o.heureConseil || ""))
: undefined,
end: o.dateConseil && o.heureFinConseil
? new Date(o.dateConseil + " " + o.heureFinConseil)
: undefined,
room: o.salleConseil,
verdict: o.ensembleMatieres.decisionDuConseil || undefined,
};
this.calcDate = o.ensembleMatieres.dateCalcul
? new Date(o.ensembleMatieres.dateCalcul)
: undefined;
this.subjects = o.ensembleMatieres.disciplines.map(d => new Subject(d));
this._raw = o;
}
toJSON() {
return {
code: this.code,
name: this.name,
yearly: this.yearly,
closed: this.closed,
start: this.start,
end: this.end,
mockExam: this.mockExam,
headcount: this.headcount,
rank: this.rank,
headTeacher: this.headTeacher,
appraisals: this.appraisals,
class: this.class,
council: this.council,
calcDate: this.calcDate,
subjects: this.subjects.map(s => s.toJSON()),
_raw: this._raw,
};
}
}
exports.Period = Period;
class Subject {
constructor(o) {
this.id = o.id;
this.code = o.codeMatiere;
this.name = o.discipline;
this.weight = o.coef;
this.headcount = o.effectif;
this.rank = o.rang;
this.minorSubject = o.sousMatiere;
this.minorSubjectCode = o.codeSousMatiere || undefined;
this.group = o.groupeMatiere;
this.groupId = o.idGroupeMatiere;
this.appraisals = o.appreciations
? o.appreciations.filter(a => !!a).map(a => new classes_1.ExpandedBase64(a))
: [];
this.option = o.option;
this.teachers = o.professeurs.map(p => ({
id: p.id,
name: p.nom,
}));
this.class = {
appraisal: o.appreciationClasse
? new classes_1.ExpandedBase64(o.appreciationClasse)
: undefined,
max: o.moyenneMax ? +o.moyenneMax.replace(/,/, ".") : undefined,
avg: o.moyenneClasse ? +o.moyenneClasse.replace(/,/, ".") : undefined,
min: o.moyenneMin ? +o.moyenneMin.replace(/,/, ".") : undefined,
};
this._raw = o;
}
toJSON() {
var _a;
const toReturn = {
id: this.id,
code: this.code,
name: this.name,
weight: this.weight,
headcount: this.headcount,
rank: this.rank,
minorSubject: this.minorSubject,
minorSubjectCode: this.minorSubjectCode,
group: this.group,
groupId: this.groupId,
appraisals: this.appraisals.map(a => a.toJSON()),
option: this.option,
teachers: this.teachers,
class: {
appraisal: (_a = this.class.appraisal) === null || _a === void 0 ? void 0 : _a.toJSON(),
max: this.class.max,
avg: this.class.avg,
min: this.class.min,
},
_raw: this._raw,
};
return toReturn;
}
}
exports.Subject = Subject;