-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/websocket #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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 e811128
established websocket to send student responses to server/db
jochshen 270a58b
got rid of debugging statements
jochshen 5e84883
Set up simple websocket connection and testing area
ulises0516 5844fad
established websocket to send student responses to server/db
jochshen 615abde
got rid of debugging statements
jochshen 8e35933
feat: implement real-time poll updates with WebSocket
ulises0516 c7643e1
Finalized websocket for singular question updates
ulises0516 f8619d9
Implemented next question logic to work with websockets and set up pa…
ulises0516 9439cf8
Handled rebase conflicts, pause poll with websocket, and removed test…
ulises0516 e001efb
Merge branch 'feature/websocket' of https://github.com/CSES-Dev/webcl…
jochshen c5394b3
fixed linting issues
jochshen 49089ae
Ran lint-fix and fixed manual refresh issue for updating chart throug…
ulises0516 92f7194
Addressed lint errors
ulises0516 81ae415
Removed testing file
ulises0516 bc61405
added auth to getResponseCount/route.ts
jochshen 4a33a1a
moved livepoll.tsx imports to websockets.ts
jochshen 3cd9bcf
moved start-session type definition to websocket.ts
jochshen 9caf1a3
created custom hook for livepoll
jochshen decd76a
added custom hook to start session
jochshen 420be4c
linted websocket.ts
jochshen b8e87ef
fixed linting in livepoll
jochshen d662cf5
lint start-session
jochshen da01d18
changed formatting for lint
jochshen 877d831
Merge branch 'main' into feature/websocket
ulises0516 dfe13d1
minor refactors
j3rrythomas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
329
app/dashboard/course/[courseId]/start-session/page.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.