feat(exam): log time spent per scenario in exam report

Signed-off-by: Abhinav Sinha <[email protected]>
This commit is contained in:
Abhinav Sinha
2026-06-16 16:29:50 +05:30
parent 6766d772d1
commit 4acdb0df40
5 changed files with 56 additions and 0 deletions
+4
View File
@@ -344,12 +344,16 @@ app.post('/api/sessions/:id/submit', (req, res) => {
const examProgressMap = {};
for (const r of examProgressRows) examProgressMap[r.scenario_id] = r;
// Also pull time_spent_seconds from global progress (tracked per scenario during the exam)
const globalProgress = loadProgress();
const snapshot = bundleScenarios.map(s => ({
id: s.id, title: s.title, weight: s.weight,
category: s.category, type: s.type, difficulty: s.difficulty,
status: examProgressMap[s.id]?.status || 'not_started',
completed_at: examProgressMap[s.id]?.completed_at || null,
attempts: examProgressMap[s.id]?.attempts || 0,
time_spent_seconds: globalProgress[s.id]?.time_spent_seconds || 0,
}));
const startedAt = new Date(session.started_at + 'Z');
const durationSecs = Math.round((Date.now() - startedAt.getTime()) / 1000);