feat: add collections management and study coach features
Test / backend (push) Failing after 13s
Test / frontend (push) Successful in 25s

- Implemented collection repository with CRUD operations for user collections.
- Created routes for managing collections, including listing, creating, updating, and deleting collections.
- Added sharing functionality for exams, allowing users to share and clone exams.
- Developed a study coach service that analyzes exam results and provides study tips based on weak areas.
- Introduced frontend components for managing collections, sharing exams, and displaying study coach insights.
- Enhanced user experience with loading states and error handling in shared components.
This commit is contained in:
LaurensBartelds committed 2026-05-02 16:55:08 +02:00
1 parent 7755e77039
commit 1ec1633dd9
26 files changed
+2557 -127

No files matched your search

+59
View File
@@ -110,3 +110,62 @@ export function countResultsByUser(userId: number): number {
const row = db.prepare('SELECT COUNT(*) AS cnt FROM exam_results WHERE user_id = ?').get(userId) as { cnt: number }
return row.cnt
}
export function getResultsWithExamJson(userId: number, limit = 100): Array<{
title: string
score_points: number
total_points: number
correct_count: number
graded_count: number
completed_at: number
exam_json: string
exam_id: number | null
}> {
const db = getDb()
return db.prepare(`
SELECT title, score_points, total_points, correct_count, graded_count, completed_at, exam_json, exam_id
FROM exam_results
WHERE user_id = ?
ORDER BY completed_at DESC
LIMIT ?
`).all(userId, limit) as Array<{
title: string
score_points: number
total_points: number
correct_count: number
graded_count: number
completed_at: number
exam_json: string
exam_id: number | null
}>
}
export interface ScoreTrend {
completed_at: number
score_pct: number
title: string
exam_id: number | null
}
export function getScoreTrends(userId: number, limit = 30): Array<{
completed_at: number
score_points: number
total_points: number
title: string
exam_id: number | null
}> {
const db = getDb()
return db.prepare(`
SELECT completed_at, score_points, total_points, title, exam_id
FROM exam_results
WHERE user_id = ? AND total_points > 0
ORDER BY completed_at ASC
LIMIT ?
`).all(userId, limit) as Array<{
completed_at: number
score_points: number
total_points: number
title: string
exam_id: number | null
}>
}