Add Private Lessons (Özel Ders İstek) page and advisory teacher filtering in Syllabus

This commit is contained in:
tyuXX 2026-10-21 19:22:21 +00:00
parent 573a249580
commit 455baa6aa4
11 changed files with 1489 additions and 9 deletions

View file

@ -1,6 +1,6 @@
import fs from 'fs';
import path from 'path';
import { DatabaseSchema, StudentStore, Assignment } from '../types';
import { DatabaseSchema, StudentStore, Assignment, PrivateLesson, PrivateLessonFormMeta, PrivateLessonsStore } from '../types';
const DB_FILE = path.resolve(process.cwd(), 'data', 'db.json');
@ -182,4 +182,49 @@ export class LocalDatabase {
const student = this.cache.students[studentId];
return student?.syllabus || null;
}
public savePrivateLessons(
studentId: string,
lessons: PrivateLesson[],
formMeta?: PrivateLessonFormMeta,
detectedAdvisor?: string
): void {
const student = this.getStudentStore(studentId);
const existing = student.privateLessons;
student.privateLessons = {
lastSynced: new Date().toISOString(),
lessons,
formMeta: formMeta || existing?.formMeta,
detectedAdvisor: detectedAdvisor || existing?.detectedAdvisor
};
if (detectedAdvisor && !student.advisoryTeacher) {
student.advisoryTeacher = detectedAdvisor;
if (student.syllabus) {
student.syllabus.advisoryTeacher = detectedAdvisor;
}
}
this.save();
}
public getPrivateLessons(studentId: string): PrivateLessonsStore | null {
const student = this.cache.students[studentId];
return student?.privateLessons || null;
}
public setStudentAdvisoryTeacher(studentId: string, teacher: string | null): void {
const student = this.getStudentStore(studentId);
student.advisoryTeacher = teacher;
if (student.syllabus) {
student.syllabus.advisoryTeacher = teacher;
}
this.save();
}
public getStudentAdvisoryTeacher(studentId: string): string | null {
const student = this.cache.students[studentId];
return student?.advisoryTeacher || student?.privateLessons?.detectedAdvisor || null;
}
}