Repository navigation
Homework
The Homework module gives you access to the student's textbook. It allows you to fetch homework, session content, and mark tasks as done (even when offline!).
Let's read all assignments scheduled for the coming days:
import { Litedirecte } from "litedirecte";
const ld = new Litedirecte();
await ld.auth.login("your_username", "your_password");
// Retrieve the homework index (one request)…
const calendar = await ld.homework.getHomework();
for (const [date, assignments] of Object.entries(calendar)) {
console.log(`\n📅 Assignments for ${date}:`);
// …then load details per date explicitly.
const detail = await ld.homework.getHomeworkForDate(date);
for (const task of detail.matieres ?? []) {
console.log(`- [${task.matiere}] ${task.aFaire?.contenu ?? "(see session content)"}`);
}
}Fetches a calendar index of homework due over the next few weeks, in exactly one request. There is no withContent option: call ld.homework.getHomeworkForDate(date) for each date you want details for.
ld.homework.getHomework(): Promise<any>A promise resolving to the raw EcoleDirecte API payload (treated as any), keyed by date strings ("YYYY-MM-DD") with arrays of assignment objects. Litedirecte preserves the API's original key names and only normalizes values (date strings become Date, base64 fields are decoded).
Loads detailed descriptions and resources for a specific day.
ld.homework.getHomeworkForDate(
date: string | Date,
): Promise<any>import { Litedirecte } from "litedirecte";
const ld = new Litedirecte();
await ld.auth.login("your_username", "your_password");
const assignments = await ld.homework.getHomeworkForDate("2025-09-15");
assignments.forEach(task => {
console.log(`Teacher: ${task.nomProf ?? "Unknown"}`);
console.log(`Content (HTML): ${task.aFaire?.contenu}`);
});Updates the state of one or more homework assignments to completed.
ld.homework.markAsDone(
homeworkIds: number[],
): Promise<any>Every id must be a positive integer, otherwise an EdValidationError is thrown and nothing is requested.
The inverse of markAsDone: moves one or more assignments back to not completed.
ld.homework.markAsUndone(
homeworkIds: number[],
): Promise<any>import { Litedirecte } from "litedirecte";
const ld = new Litedirecte();
await ld.auth.login("your_username", "your_password");
await ld.homework.markAsDone([11243]); // ticked by mistake…
await ld.homework.markAsUndone([11243]); // …and put back on the to-do listBoth calls hit the same endpoint and are queued, so they still work offline.
Post a comment under a homework assignment or a session content.
ld.homework.sendHomeworkComment(
idContenu: number,
message: string,
): Promise<{ id: number }>import { Litedirecte } from "litedirecte";
const ld = new Litedirecte();
await ld.auth.login("your_username", "your_password");
const result = await ld.homework.sendHomeworkComment(55442, "Here is my comment on the homework");
console.log(`Comment posted successfully with ID: ${result.id}`);ld.homework.getHomework, ld.homework.getHomeworkForDate, ld.homework.markAsDone, and ld.homework.markAsUndone resolve to the raw EcoleDirecte API payload (treated as any). Litedirecte preserves the API's original key names and only normalizes values (date strings become Date, base64 fields are decoded).
Requires the CAHIER_DE_TEXTES module on the current account (see Configuration): without it, an EdUnsupportedModuleError is thrown before any request.
getHomework() (the list) is maintained; getHomeworkForDate(date) is manual. markAsDone / markAsUndone patch the cached homework in place with no refetch; sendHomeworkComment marks the resource stale (maintained) or dead (manual). Every read accepts { force: true } to skip the cache. See Cache & sync.
© 2026 typeof (Scolup) | Licensed under AGPL 3.0