Skip to content

BE_7 - Question Creation Events #13

@notjackl3

Description

@notjackl3

Summary

Implement real-time question creation with rate limiting, validation, and broadcasting to all session participants.
[Estimated hours: 9-10]

Objectives

  • Create question:create event handler
  • Implement rate limiting (10 questions per minute)
  • Validate question content and visibility
  • Save question to database
  • Broadcast new question to session room
  • Handle anonymous questions properly

Description

When a student asks a question, it should appear instantly for all users in the session (respecting visibility rules). This ticket handles the most critical real-time feature of AskEasy.

User Flow

  1. Student types question and clicks "Ask"
  2. Frontend emits question:create event
  3. Backend validates content and checks rate limit
  4. Question saved to database
  5. Backend broadcasts question:created to all users in session
  6. All clients update their question list

Technical Details

File Structure

src/socket/handlers/
└── questionHandlers.ts

Functions:
- handleQuestionCreate(socket, io)
- validateQuestionContent(content)
- checkQuestionRateLimit(userId)
- broadcastQuestion(io, sessionId, question)

Acceptance Criteria

  • Student can create question → appears for all users
  • Anonymous question doesn't reveal author
  • Rate limit blocks after 10 questions in 1 minute
  • Rate limit error message shown to user
  • Question with visibility "TA" only appears for TAs and professors
  • Question with visibility "PROFESSOR" only appears for professors
  • Invalid content (too short/long) rejected with error
  • Cannot create question when submissions disabled
  • Question linked to correct slide if slideId provided

Resources

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions