Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/api/exercises/[id]/session/advance/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export async function POST(
return NextResponse.json({ error: 'Session closed' }, { status: 410 });
}

// Mark session as started on first interaction
await sql`
UPDATE sessions SET started_at = now()
WHERE id = ${row.id} AND started_at IS NULL
`;

const currentIndex: number = row.current_question_index as number;
const questionCount: number = row.question_count as number;

Expand Down
2 changes: 1 addition & 1 deletion app/api/exercises/[id]/session/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function GET(
SELECT
${exerciseId},
${userId},
now(),
NULL,
0,
e.end_time,
e.duration_limit
Expand Down
6 changes: 6 additions & 0 deletions app/api/submissions/[sessionId]/autosave/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ export async function POST(
);
}

// Mark session as started on first interaction
await sql`
UPDATE sessions SET started_at = now()
WHERE id = ${sessionId} AND started_at IS NULL
`;

// Upsert the submission
const upserted = await sql`
INSERT INTO submissions (session_id, question_index, response_text, submitted_at, status)
Expand Down
Loading