Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update des values de quasiment tout #19

Open
wants to merge 58 commits into
base: js
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
0ce3b3b
Update grades-overview.ts
JyhuKo Jan 12, 2025
e61b12a
Update grades-overview.ts
JyhuKo Jan 12, 2025
c8cc060
Update grades-overview.ts
JyhuKo Jan 12, 2025
534e9f2
Update grade.ts
JyhuKo Jan 12, 2025
b94686f
Update grade.ts
JyhuKo Jan 12, 2025
9434ce8
fix messages
JyhuKo Jan 12, 2025
365595a
Update account.ts
JyhuKo Jan 12, 2025
3625556
Update account.ts
JyhuKo Jan 12, 2025
8d142e6
Update document.ts
JyhuKo Jan 12, 2025
3a566e7
Update document.ts
JyhuKo Jan 12, 2025
0014efd
Update homepage-timeline-item.ts
JyhuKo Jan 12, 2025
dd2ed63
Update homepage-timeline-item.ts
JyhuKo Jan 12, 2025
bbb0ea1
Update account.ts
JyhuKo Jan 12, 2025
c75c0ab
ig
JyhuKo Jan 12, 2025
7586a95
revert
JyhuKo Jan 12, 2025
fc7db50
support module ig
JyhuKo Jan 12, 2025
a9609b9
Update account.ts
JyhuKo Jan 12, 2025
3f77e15
revert
JyhuKo Jan 12, 2025
c87f4c7
Update message.ts
JyhuKo Jan 12, 2025
682c2e9
Update messages-list.ts
JyhuKo Jan 12, 2025
b0f18b8
Update messages-list.ts
JyhuKo Jan 12, 2025
677452c
Update period.ts
JyhuKo Jan 12, 2025
2101a43
Update period.ts
JyhuKo Jan 12, 2025
4c8b64b
Update period.ts
JyhuKo Jan 12, 2025
4ea4bf2
Update account.ts
JyhuKo Jan 12, 2025
7ed2a84
Update account.ts
JyhuKo Jan 12, 2025
93d5143
Update account.ts
JyhuKo Jan 12, 2025
fe8246a
Update messages.ts
JyhuKo Jan 12, 2025
e627f3e
replaceall au lieu de replce mb
JyhuKo Jan 12, 2025
eb94b7b
Update account-kind.ts
JyhuKo Jan 12, 2025
c221e7d
Update grade.ts
JyhuKo Jan 12, 2025
ad72a06
y avais 3 sdonc je remet pour l instant
JyhuKo Jan 12, 2025
30e8bfd
revert
JyhuKo Jan 12, 2025
8f693ad
still todo
JyhuKo Jan 12, 2025
f58f0d7
still TODO
JyhuKo Jan 12, 2025
4cb37f3
Update account-kind.ts
JyhuKo Jan 12, 2025
b766013
removeuseless s
JyhuKo Jan 12, 2025
1dbc48d
remove third s
JyhuKo Jan 12, 2025
7fa8aed
remove notes
JyhuKo Jan 12, 2025
32ecdce
update timetable
JyhuKo Jan 12, 2025
7428304
Update timetable-item.ts
JyhuKo Jan 12, 2025
fc39471
Update workspace-item.ts
JyhuKo Jan 12, 2025
5ccf6dd
Update workspace-item.ts
JyhuKo Jan 12, 2025
a6c35f4
update version pcq c est mieux je pense quand mm
JyhuKo Jan 13, 2025
ad34caf
Update session-token-required.ts
JyhuKo Jan 13, 2025
5ca3696
Update unknown-enum.ts
JyhuKo Jan 13, 2025
8e213db
Update double-auth-required.ts
JyhuKo Jan 13, 2025
a623e02
Update bad-double-auth.ts
JyhuKo Jan 13, 2025
686ddb6
Update bad-credentials.ts
JyhuKo Jan 13, 2025
23d1b40
fix error
JyhuKo Jan 13, 2025
2122a15
Update messages-list.ts
JyhuKo Jan 13, 2025
798b1ee
revert
JyhuKo Jan 13, 2025
a4f1fbd
indentation du json
JyhuKo Jan 13, 2025
0b51bae
new homeworks date
JyhuKo Jan 13, 2025
f834a6b
custom date input
JyhuKo Jan 13, 2025
7279c61
ajout de valeurs
JyhuKo Jan 13, 2025
1b3b485
check i b64 in content to avoid big log
JyhuKo Jan 13, 2025
1c80c93
custom date input ig
JyhuKo Jan 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/student-grades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ void (async function main() {
credentials.student_password
);
const grades = await studentGrades(session, account, ""); // sensitive NOT ALL ACCOUNTS CAN GO BACK
console.log(JSON.stringify(grades));
console.log(JSON.stringify(grades, null, 2));
})();
4 changes: 3 additions & 1 deletion examples/student-homeworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ void (async function main() {
credentials.student_username,
credentials.student_password
);
const assignments = await studentHomeworks(session, account, "2024-10-14");
const Date = prompt("Enter date in the format YYYY-MM-DD:");
const assignmentsDate = Date ? Date : '2025-01-14';
const assignments = await studentHomeworks(session, account, assignmentsDate);

console.log(JSON.stringify(assignments.subjects));
})();
22 changes: 16 additions & 6 deletions examples/student-timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,23 @@ void (async function main() {
homepageTimeline.forEach((item) => {
console.log("---");

console.log("Creation date:", item.creationDate.toLocaleString());
console.log("Start date:", item.startDate.toLocaleString());
console.log("End date:", item.endDate.toLocaleString());
console.log("Written by:", item.authorName);
console.log("Written By:", item.authorName);
console.log("Author ID:", item.authorId);
console.log("Author First Name:", item.authorFirstName);
console.log("Author Title:", item.authorTitle);
console.log("Creation Date:", item.creationDate.toLocaleString());
console.log("Start Date:", item.startDate.toLocaleString());
console.log("End Date:", item.endDate.toLocaleString());
console.log("Target:", item.target);
console.log("Target Schools:", item.targetSchools);
console.log("Color Name:", item.colorName);

console.log("Content:\n");
console.log(item.content || "(no content)");
console.log("Content: ");
if (item.content.includes('data:image/jpeg;base64')) {
console.log('Contient une image en base64');
} else {
console.log(item.content || '(no content)');
}
});
}
else {
Expand Down
5 changes: 3 additions & 2 deletions examples/student-timetable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ void (async function main() {
credentials.student_username,
credentials.student_password
);
const startDate = new Date("2024-01-12");
const StartDate = prompt("Enter date in the format YYYY-MM-DD:");
const CheckStartDate = StartDate ? new Date(StartDate) : new Date('2025-01-14');

const timetable = await studentTimetable(session, account, startDate);
const timetable = await studentTimetable(session, account, CheckStartDate);

timetable.forEach((item) => {
console.log("---");
Expand Down
21 changes: 18 additions & 3 deletions src/api/student/messages.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { decode } from "js-base64";
import { Request } from "~/core/request";
import { decodeMesssagesList } from "~/decoders/messages-list";
import { decodeMessagesList } from "~/decoders/messages-list";
import {
type Account,
type FileKind,
Expand All @@ -10,6 +10,21 @@ import {
import type { APIReceivedMessage, ReceivedMessage } from "~/models/message";
import type { APIReceivedMessagesList } from "~/models/messages-list";


const getSchoolYear = (): string => {
const currentDate = new Date();
const currentYear = currentDate.getFullYear();
const currentMonth = currentDate.getMonth(); //janvier= 0 / ddecembre = 11

// si le mois est apres aout ca ajoute + 1 a l'année actuelle sinon ca retire 1 a l'année actuelle
if (currentMonth >= 7) {
return `${currentYear}-${currentYear + 1}`;
} else {
return `${currentYear - 1}-${currentYear}`;
}
};


export const studentReceivedMessages = async (
session: Session,
account: Account
Expand All @@ -22,7 +37,7 @@ export const studentReceivedMessages = async (
.addVersionURL()
.setToken(session.token)
.setFormData({
anneeMessages: `${(new Date()).getFullYear()}-${new Date().getFullYear() + 1}`
anneeMessages: getSchoolYear()
});

const response: APIReceivedMessagesList = await request.send(session.fetcher);
Expand All @@ -36,7 +51,7 @@ export const studentReceivedMessages = async (
response.data.parametrage.destFamille ||
response.data.parametrage.destProf,
chats: response.data.messages.received
.map(decodeMesssagesList)
.map(decodeMessagesList)
.sort((m1: ReceivedMessage, m2: ReceivedMessage) => {
if (m1.date < m2.date) return 1;
if (m1.date > m2.date) return -1;
Expand Down
27 changes: 17 additions & 10 deletions src/decoders/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ import type { Account } from "~/models/account";

export const decodeAccount = (account: any): Account => {
const gender =
typeof account.profile.sexe !== "undefined" && account.profile.sexe !== null
? account.profile.sexe
: account.civilite === "Mme"
? "F"
: "M";
account.profile?.sexe ??
(account.civilite === "Mme" ? "F" : "M");

return {
loginID: account.idLogin,
Expand All @@ -17,7 +14,7 @@ export const decodeAccount = (account: any): Account => {
kind: decodeAccountKind(account.typeCompte),
ogecID: account.codeOgec,
main: account.main,
lastConnection: account.lastConnexion,
lastConnection: new Date(account.lastConnexion),
firstName: account.prenom,
lastName: account.nom,
email: account.email,
Expand All @@ -30,11 +27,21 @@ export const decodeAccount = (account: any): Account => {
socket_token: account.socketToken,
gender,
profilePictureURL: account.profile.photo,
modules: account.modules,
modules: account.modules,//TODO
currentSchoolCycle: account.anneeScolaireCourante,
class: {
short: account.profile.classe.code,
long: account.profile.classe.libelle
}
short: account.profile?.classe.code,
long: account.profile?.classe.libelle,
isGraded: !!account.profile.classe?.estNote,
},
individualParameters: {
visualAccessibility: !!account.parametresIndividuels?.accessibiliteVisuelle,
secureAuthentication: !!account.parametresIndividuels?.checkAuthentificationSecure,
defaultNoteEntryMode: account.parametresIndividuels?.typeSaisieNotesDefaut,
maxDaysBeforeAssignmentDue: account.parametresIndividuels?.nbJoursMaxRenduDevoirCDT,
defaultClassViewType: account.parametresIndividuels?.typeViewCDTDefaut,
blockPMOnHomePage: !!account.parametresIndividuels?.blocPMAccueil,
blockNewsOnHomePage: !!account.parametresIndividuels?.blocActuAccueil,
},
};
};
4 changes: 3 additions & 1 deletion src/decoders/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export const decodeDocument = (item: any): Document => {
date: new Date(item.date),
kind: decodeDocumentKind(item.type),
signatureRequired: item.signatureDemandee ?? false,
signature: item.signature ?? void 0
signature: item.signature ?? void 0,
studentId: item.idEleve,
statusSignatures: item.etatSignatures
};
};
12 changes: 9 additions & 3 deletions src/decoders/grade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ import type { Grade } from "~/models";

export const decodeGrade = (item: any): Grade => {
return {
id: item.id,
comment: item.devoir,
average: decodeGradeValue(item.moyenneClasse),
isOptional: item.valeurisee,
skills: item.elementsProgramme.map(decodeSkill),
coefficient: Number(item.coef),
date: new Date(item.date),
dateRecorded: item.dateSaisie ? new Date(item.dateSaisie) : undefined,
examType: item.typeDevoir,
max: decodeGradeValue(item.maxClasse),
min: decodeGradeValue(item.minClasse),
outOf: item.noteSur.replaceAll(",", "."),
outOf: Number(item.noteSur.replaceAll(",", ".")),
period: {
id: item.codePeriode,
// TODO: fill name
name: ""
name: ""
},
subject: {
id: item.codeMatiere,
Expand All @@ -26,6 +28,10 @@ export const decodeGrade = (item: any): Grade => {
},
subjectFilePath: item.uncSujet,
correctionFilePath: item.uncCorrige,
value: decodeGradeValue(item.valeur)
value: decodeGradeValue(item.valeur),
remarks: item.commentaire,
isSignificant: !item.nonSignificatif,
inLetters: item.enLettre
};
};

15 changes: 10 additions & 5 deletions src/decoders/grades-overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,21 @@ export const buildOverview = (data: any): GradesOverview => {
id: subject.codeMatiere,
childSubjectId: subject.codeSousMatiere,
isChildSubject: subject.sousMatiere,
// TODO
// TODO
color: "string",
coefficient: Number(subject.coef),
classAverage: decodeGradeValue(
subject.moyenneClasse?.replace(",", ".")
),
classAverage: decodeGradeValue(subject.moyenneClasse?.replace(",", ".")),
maxAverage: decodeGradeValue(subject.moyenneMax?.replace(",", ".")),
minAverage: decodeGradeValue(subject.moyenneMin?.replace(",", ".")),
studentAverage: decodeGradeValue(subject.moyenne?.replace(",", ".")),
outOf: decodeGradeValue(outOf.toString())
outOf: decodeGradeValue(outOf.toString()),
classSize: subject.effectif,
rank: subject.rang,
teachers: subject.professeurs?.map((prof: any) => ({
id: prof.id,
name: prof.nom
})),
comments: subject.appreciations
});
}
}
Expand Down
15 changes: 10 additions & 5 deletions src/decoders/homepage-timeline-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ import { decodeFrenchDate } from "./dates";

export const decodeHomepageTimelineItem = (item: any): HomepageTimelineItem => {
return {
authorName: item.auteur.nom,
creationDate: decodeFrenchDate(item.dateCreation),
startDate: decodeFrenchDate(item.dateDebut),
endDate: decodeFrenchDate(item.dateFin),
id: item.id,
content: decode(item.contenu),
colorName: item.type
authorName: item.auteur.nom,
authorId: item.auteur.id,
authorFirstName: item.auteur.prenom,
authorTitle: item.auteur.civilite,
creationDate: decodeFrenchDate(item.dateCreation),
startDate: decodeFrenchDate(item.dateDebut),
endDate: decodeFrenchDate(item.dateFin),
target: item.cible || [],
targetSchools: item.ciblesEtab || [],
colorName: item.type
};
};
2 changes: 1 addition & 1 deletion src/decoders/messages-list.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { FileKind } from "~/models";
import type { APIReceivedMessageType, ReceivedMessage } from "~/models/message";

export const decodeMesssagesList = (
export const decodeMessagesList = (
message: APIReceivedMessageType
): ReceivedMessage => {
return {
Expand Down
20 changes: 19 additions & 1 deletion src/decoders/period.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Period } from "~/models";
export const decodePeriod = (item: any): Period => {
return {
id: item.idPeriode,
name: item.periode,
startDate: new Date(item.dateDebut),
endDate: new Date(item.dateFin),
isEnded: item.cloture,
Expand All @@ -12,6 +13,23 @@ export const decodePeriod = (item: any): Period => {
councilEndHour: item.heureFinConseil,
isMockExam: item.examenBlanc,
yearly: item.annuel,
name: item.periode
ensembleSubjects: {
calculationDate: item.ensembleMatieres.dateCalcul,
overallAverage: item.ensembleMatieres.moyenneGenerale,
classAverage: item.ensembleMatieres.moyenneClasse,
minAverage: item.ensembleMatieres.moyenneMin,
maxAverage: item.ensembleMatieres.moyenneMax,
classRepresentativeName: item.ensembleMatieres.nomPP,
classRepresentativeAppreciation: item.ensembleMatieres.appreciationPP,
classSupervisorName: item.ensembleMatieres.nomCE,
classSupervisorAppreciation: item.ensembleMatieres.appreciationCE,
supervisorAppreciation: item.ensembleMatieres.appreciationVS,
councilDecision: item.ensembleMatieres.decisionDuConseil,
rank: item.ensembleMatieres.rang,
classStrength: item.ensembleMatieres.effectif,
overallClassAppreciation: item.ensembleMatieres.appreciationGeneraleClasse,
subjects: item.ensembleMatieres.disciplines,
simulatedSubjects: item.ensembleMatieres.disciplinesSimulation
}
};
};
11 changes: 10 additions & 1 deletion src/decoders/timetable-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ export const decodeTimetableItem = (item: any): TimetableItem => {
kind: item.typeCours,
cancelled: item.isAnnule,
updated: item.isModifie,
notes: item.text
notes: item.text,
className: item.classe,
classId: item.classeId,
groupName: item.groupe,
groupCode: item.groupeCode,
isFlexible: item.isFlexible,
hasSessionContent: item.contenuDeSeance,
hasHomework: item.devoirAFaire,
dispensable: item.dispensable,
dispense: item.dispense
};
};
4 changes: 3 additions & 1 deletion src/decoders/workspace-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export const decodeWorkspace = (item: any): WorkspaceItem => {
permissions: item.droitUtilisateur,
nbMembers: item.nbMembres,
colorEventAgenda: item.couleurEvenementAgenda,
createdAt: item.creeLe
createdAt: item.creeLe,
messagerieEleve: item.messagerieEleve,
messagerieFamille: item.messagerieFamille,
};
};
15 changes: 14 additions & 1 deletion src/models/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,18 @@ export type Account = Readonly<{
* @example "2023-2024"
*/
currentSchoolCycle: string;
class: { short: string; long: string };
class: {
short: string;
long: string;
isGraded: boolean;
};
individualParameters: {
visualAccessibility: boolean;
secureAuthentication: boolean;
defaultNoteEntryMode: string;
maxDaysBeforeAssignmentDue: string;
defaultClassViewType: string;
blockPMOnHomePage: boolean;
blockNewsOnHomePage: boolean;
};
}>;
2 changes: 2 additions & 0 deletions src/models/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ export type Document = Readonly<{
kind: DocumentKind;
signatureRequired: boolean;
signature: any;
studentId: number;
statusSignatures: any[];
}>;
2 changes: 1 addition & 1 deletion src/models/errors/bad-credentials.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export class BadCredentials extends Error {
public constructor() {
super("Bad credentials, no token found in response");
super("Bad credentials, no token found in response.");
this.name = "BadCredentials";
}
}
2 changes: 1 addition & 1 deletion src/models/errors/bad-double-auth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export class BadDoubleAuth extends Error {
public constructor() {
super("Bad double auth response");
super("Bad double auth response.");
this.name = "BadDoubleAuth";
}
}
2 changes: 1 addition & 1 deletion src/models/errors/double-auth-required.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export class DoubleAuthRequired extends Error {
public constructor() {
super("Double authentication required");
super("Double authentication required.");
this.name = "DoubleAuthRequired";
}
}
2 changes: 1 addition & 1 deletion src/models/errors/session-token-required.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export class SessionTokenRequired extends Error {
public constructor() {
super("Session token is required to do this action");
super("Session token is required to do this action.");
this.name = "SessionTokenRequired";
}
}
2 changes: 1 addition & 1 deletion src/models/errors/unknown-enum.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export class UnknownEnumValue extends Error {
public constructor(label: string, value: string) {
super(`Expected a value from the enum '${label}', but got '${value}'`);
super(`Expected a value from the enum '${label}', but got '${value}'.`);
this.name = "UnknownEnumValue";
}
}
Loading