Add disinclude option for assignments from other classes

This commit is contained in:
tyuXX 2026-10-21 18:21:11 +00:00
parent 5577214005
commit 8acc77e441
8 changed files with 230 additions and 17 deletions

View file

@ -268,6 +268,37 @@ app.post('/api/toggle', requireAuth, (req: Request, res: Response) => {
});
});
/**
* POST /api/exclude
* Toggle assignment disinclude/exclude state
*/
app.post('/api/exclude', requireAuth, (req: Request, res: Response) => {
const studentId = req.session.studentId!;
const { assignmentId, excluded } = req.body;
if (!assignmentId) {
return res.status(400).json({ success: false, error: 'Assignment ID is required' });
}
const updated = db.toggleExcludeAssignment(studentId, assignmentId, excluded);
if (!updated) {
return res.status(404).json({ success: false, error: 'Assignment not found' });
}
const studentStore = db.getStudentStore(studentId);
const list = Object.values(studentStore.assignments).map(a => ({
...a,
status: InsightService.computeStatus(a)
}));
const stats = InsightService.calculateStats(list);
res.json({
success: true,
assignment: updated,
stats
});
});
/**
* POST /api/sync
* Sync recent pages (1-2)