Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4690d02
Set up simple websocket connection and testing area
ulises0516 May 20, 2025
e811128
established websocket to send student responses to server/db
jochshen May 20, 2025
270a58b
got rid of debugging statements
jochshen May 20, 2025
5e84883
Set up simple websocket connection and testing area
ulises0516 May 20, 2025
5844fad
established websocket to send student responses to server/db
jochshen May 20, 2025
615abde
got rid of debugging statements
jochshen May 20, 2025
8e35933
feat: implement real-time poll updates with WebSocket
ulises0516 May 27, 2025
c7643e1
Finalized websocket for singular question updates
ulises0516 May 30, 2025
f8619d9
Implemented next question logic to work with websockets and set up pa…
ulises0516 May 30, 2025
9439cf8
Handled rebase conflicts, pause poll with websocket, and removed test…
ulises0516 May 30, 2025
e001efb
Merge branch 'feature/websocket' of https://github.com/CSES-Dev/webcl…
jochshen May 31, 2025
c5394b3
fixed linting issues
jochshen May 31, 2025
49089ae
Ran lint-fix and fixed manual refresh issue for updating chart throug…
ulises0516 Jun 3, 2025
92f7194
Addressed lint errors
ulises0516 Jun 3, 2025
81ae415
Removed testing file
ulises0516 Jun 3, 2025
bc61405
added auth to getResponseCount/route.ts
jochshen Jun 4, 2025
4a33a1a
moved livepoll.tsx imports to websockets.ts
jochshen Jun 4, 2025
3cd9bcf
moved start-session type definition to websocket.ts
jochshen Jun 4, 2025
9caf1a3
created custom hook for livepoll
jochshen Jun 4, 2025
decd76a
added custom hook to start session
jochshen Jun 4, 2025
420be4c
linted websocket.ts
jochshen Jun 4, 2025
b8e87ef
fixed linting in livepoll
jochshen Jun 4, 2025
d662cf5
lint start-session
jochshen Jun 4, 2025
da01d18
changed formatting for lint
jochshen Jun 4, 2025
877d831
Merge branch 'main' into feature/websocket
ulises0516 Jun 5, 2025
dfe13d1
minor refactors
j3rrythomas Jun 5, 2025
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
41 changes: 41 additions & 0 deletions app/api/getResponseCounts/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { NextRequest, NextResponse } from "next/server";
import { getServerSession } from "next-auth/next";
import { authOptions } from "@/lib/auth";
import prisma from "@/lib/prisma";

export async function GET(request: NextRequest) {
try {
// Authenticate the request
const session = await getServerSession(authOptions);
if (!session?.user) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}

const { searchParams } = new URL(request.url);
const questionId = searchParams.get("questionId");
if (!questionId || isNaN(Number(questionId))) {
return NextResponse.json(
{ error: "Invalid or missing questionId parameter" },
{ status: 400 },
);
}

const groups = await prisma.response.groupBy({
by: ["optionId"],
where: { questionId: Number(questionId) },
_count: { optionId: true },
});
const optionCounts = groups.reduce<Record<number, number>>((acc, g) => {
acc[g.optionId] = g._count.optionId;
return acc;
}, {});
const total = Object.values(optionCounts).reduce((sum, c) => sum + c, 0);
return NextResponse.json({ optionCounts, responseCount: total });
} catch (error) {
console.error("Error fetching response counts:", error);
return NextResponse.json(
{ error: "An error occurred while fetching response counts" },
{ status: 500 },
);
}
}
329 changes: 228 additions & 101 deletions app/dashboard/course/[courseId]/start-session/page.tsx

Large diffs are not rendered by default.

Loading