Commit graph

82 commits

Author SHA1 Message Date
035ea57274
Fix host reconnection losing player state and first-answer bonus
- Persist firstCorrectPlayerId to backend during state sync
- Restore full players array (not just host) on host reconnect
- Add default values to WELCOME payload for new/unmatched players
- Add migration for first_correct_player_id column in game_sessions
2026-01-14 10:04:51 -07:00
32696ad33d
Fix stuff 2026-01-14 09:07:20 -07:00
fc270d437f
Redesign scoreboard 2026-01-14 01:55:49 -07:00
af21f2bcdc
feat: add comprehensive game configuration system
Add a centralized game configuration system that allows customizable
scoring mechanics and game rules. Users can now set default game
configurations that persist across sessions, and individual quizzes
can have their own configuration overrides.

## New Features

### Game Configuration Options
- Shuffle Questions: Randomize question order when starting a game
- Shuffle Answers: Randomize answer positions for each question
- Host Participates: Toggle whether the host plays as a competitor
  or spectates (host now shows as 'Spectator' when not participating)
- Streak Bonus: Multiplied points for consecutive correct answers,
  with configurable threshold and multiplier values
- Comeback Bonus: Extra points for players ranked below top 3
- Wrong Answer Penalty: Deduct percentage of max points for incorrect
  answers (configurable percentage)
- First Correct Bonus: Extra points for the first player to answer
  correctly on each question

### Default Settings Management
- New Settings icon in landing page header (authenticated users only)
- DefaultConfigModal for editing user-wide default game settings
- Default configs are loaded when creating new quizzes
- Defaults persist to database via new user API endpoints

### Reusable UI Components
- GameConfigPanel: Comprehensive toggle-based settings panel with
  expandable sub-options, tooltips, and suggested values based on
  question count
- DefaultConfigModal: Modal wrapper for editing default configurations

## Technical Changes

### Frontend
- New useUserConfig hook for fetching/saving user default configurations
- QuizEditor now uses GameConfigPanel instead of inline toggle checkboxes
- GameScreen handles spectator mode with disabled answer buttons
- Updated useGame hook with new scoring calculations and config state
- Improved useAuthenticatedFetch with deduped silent refresh and
  redirect-once pattern to prevent multiple auth redirects

### Backend
- Added game_config column to quizzes table (JSON storage)
- Added default_game_config column to users table
- New PATCH endpoint for quiz config updates: /api/quizzes/:id/config
- New PUT endpoint for user defaults: /api/users/me/default-config
- Auto-migration in connection.ts for existing databases

### Scoring System
- New calculatePoints() function in constants.ts handles all scoring
  logic including streaks, comebacks, penalties, and first-correct bonus
- New calculateBasePoints() for time-based point calculation
- New getPlayerRank() helper for comeback bonus eligibility

### Tests
- Added tests for DefaultConfigModal component
- Added tests for GameConfigPanel component
- Added tests for QuizEditor config integration
- Added tests for useUserConfig hook
- Updated API tests for new endpoints

## Type Changes
- Added GameConfig interface with all configuration options
- Added DEFAULT_GAME_CONFIG constant with sensible defaults
- Quiz type now includes optional config property
2026-01-14 01:43:23 -07:00
90fba17a1e
Add shuffle options 2026-01-14 00:16:23 -07:00
683cd039e7
Fix modal scrolling 2026-01-13 23:56:21 -07:00
bc4b0e2df7
Add tests and edit works 2026-01-13 23:52:04 -07:00
bfbba7b5ab
Add ability to edit AI generated content 2026-01-13 23:37:08 -07:00
846ba2a69c
Add time sync 2026-01-13 22:56:56 -07:00
028bab23fd
Add document AI gen support 2026-01-13 22:48:43 -07:00
16007cc3aa
feat(landing): add document upload and quiz customization options
- Added collapsible advanced options section
- Implemented file upload with drag-and-drop support (PDF, TXT, MD, DOCX, Images)
- Added question count slider (5-30)
- Updated Generate button logic to support document-based generation
2026-01-13 20:44:11 -07:00
1f88e291a9
Complete stage 7 2026-01-13 20:21:47 -07:00
3e7b89bcad
Stay on reason screen 2026-01-13 17:10:54 -07:00
a7e37024f5
Finer granularity points 2026-01-13 17:03:35 -07:00
3a22b42492
Phase 6 complete 2026-01-13 16:52:57 -07:00
93ea01525e
Phase 5 complete 2026-01-13 16:38:25 -07:00
342ff60b70
Add user setup config 2026-01-13 16:18:46 -07:00
66f15b49b2
Phase 4 complete 2026-01-13 15:39:02 -07:00
0cc099c00c
Fix tests 2026-01-13 15:27:46 -07:00
6d24f3c112
Phase 2 + 3 complete 2026-01-13 15:20:46 -07:00
9a3fc97a34
Phase 1 done 2026-01-13 14:14:30 -07:00
5cdafc7a4d
Implementation plan 2026-01-13 13:57:06 -07:00
eb4ea30404
Add animations to points on scoreboard 2026-01-13 11:40:53 -07:00
2aafe8fce9
Update UI 2026-01-13 11:28:39 -07:00
838013fb9a
Fix ui bug on why is this correct box 2026-01-13 11:11:40 -07:00
ec318e9e9a
Configurable theme, change default to blue 2026-01-13 11:04:52 -07:00
8a8ec9bc0e
Rebrand to kaboot 2026-01-13 10:59:50 -07:00
156c210dea
Animate points 2026-01-13 10:46:56 -07:00
c38a3e1fdf
Fix shapes 2026-01-13 08:06:47 -07:00
2c7ca237a3
List incorrect reason as well 2026-01-13 08:04:11 -07:00
845e3ab3d6
Reason working 2026-01-13 07:55:17 -07:00
c87ebf0a74
Initial commit 2026-01-13 07:23:30 -07:00