2026-11-14 08:51:34 +01:00

Quizalarm Logo

Quizalarm

Hybrid quiz platform (Competition, Solo Learning, and Live WebSocket Multiplayer) powered by a Baserow backend.

🇬🇧 English · 🇩🇪 Deutsch


Overview

Quizalarm is a full-stack hybrid quiz platform designed for fire department and youth fire brigade training and competitions (e.g., JLM 2026 AK A/B/C). It uses Baserow as its database for question sets, answers, participants, and teams, and serves three distinct quiz modes alongside a real-time WebSocket presenter view (/present) and an admin control panel (/admin).

For the full Baserow database schema and setup instructions, see BASEROW-SETUP.md.

Architecture

+-----------------------------------+       HTTP / WebSocket (Port 7849)
| Browser Clients (React 18 + CDN)  | <----------------------------------+
| - /          Player App (app.js)  |                                    |
| - /admin     Admin Panel          |                                    v
| - /present   Beamer / Presenter   |                      +-----------------------------+
+-----------------------------------+                      | Quizalarm Node.js Server    |
                                                           | - Express REST API          |
                                                           | - ws Live Session Engine    |
                                                           | - /api/img Baserow Proxy    |
                                                           | - /data/config.json         |
                                                           +--------------+--------------+
                                                                          |
                                             +----------------------------+----------------------------+
                                             v                                                         v
                              +-----------------------------+                           +-----------------------------+
                              | Baserow REST API            |                           | ntfy Server                 |
                              | - Question Set Tables       |                           | Feedback push alerts        |
                              | - Answers (Antworten)       |                           +-----------------------------+
                              | - Participants & Teams      |
                              +-----------------------------+

Features

  • Three Quiz Modes:
    • ⚔️ Wettkampf (Competition): Exam-style mode with a configured question count (wettkampfCount) and optional countdown timer in minutes (wettkampfTimer) per question set. Saves answers live (POST /api/results/single, PUT /api/results/update), supports resuming incomplete runs (GET /api/wettkampf-progress/:name/:setId) or abandoning (POST /api/results/abandon), and finalizes points/correctness at completion (PUT /api/results/finalize) without immediate per-question feedback.
    • 📚 Solo-Lernen (Solo Learning): Self-paced study mode with immediate per-question feedback, optional question shuffling, randomized answer order, image zoom modal, and automatic resume for incomplete sessions (GET /api/progress/:name/:setId).
    • 🎮 Live-Quiz (Multiplayer): Real-time WebSocket sessions created in /admin with auto-generated 6-character or custom alphanumeric room codes (3–20 chars), optional question shuffling, binary (1000 / 0) or time-based (500–1000 pts) scoring, and a dedicated Beamer/Presentation screen (/present).
  • Four Question Types & Smart Grading:
    • SingleChoice, MultipleChoice (supports partial credit and wrong-pick penalties), Wahr/Falsch, and Freitext.
    • Freitext Tolerance: Automatically normalizes input by lowercasing, converting German umlauts (ä→ae, ö→oe, ü→ue, ß→ss), and stripping non-alphanumeric characters.
  • Privacy-Preserving Live Sessions & Names:
    • Privacy hint on name input plus random free-name generator (🎲, GET /api/names/random) backed by the Baserow participants table.
    • Seamless WebSocket reconnect for players using the same name.
    • During live sessions, players only receive participant counts and their own scores/results; full leaderboards and player lists are shown only to admins and /present.
  • Teams & Participant Tracking: Links answers automatically to Baserow Teilnehmer records (enrichAnswerRows), assigns teams (POST /api/names/assign-team), supports Baserow password authentication for teams (POST /api/teams/auth), and links to the external teamleader statistics view (https://quizalarm-stat.orfel.de).
  • Feedback via ntfy: Built-in feedback modal (POST /api/feedback) supporting URL prefill (?feedback=1&team=...) to forward messages to an ntfy topic.
  • Admin Dashboard (/admin): Protected by ADMIN_PASSWORD; manages Baserow question sets (name, Table ID, color, wettkampfCount, wettkampfTimer), answersTableId, ntfyUrl, connection diagnostics (/api/admin/debug-baserow), live session creation/control/reconnection, and session/participant statistics (/api/admin/stats).
  • Secure Baserow Image Proxy (/api/img): Proxies question images exclusively from the configured BASEROW_URL host with an in-memory LRU-style cache (up to 50 images).
  • Baserow Category Sync Script: Includes Baserow Kategorie Updater JLM.ps1 for synchronizing Kategorie single-select options across multiple Baserow fields via PowerShell 5.1.

How It Works & Tech Stack

Internal Architecture

  1. Configuration (server/config.js): Combines environment variables (getEnvConfig()) with persistent JSON configuration (CONFIG_PATH, default /data/config.json) holding configured question sets (sets), answersTableId, participantsTableId, teamsTableId, and ntfyUrl.
  2. Baserow Integration (server/baserow.js):
    • Paginates row queries (size=200) with user_field_names=true.
    • Caches table field metadata and participant IDs for 60 seconds (CACHE_TTL_MS).
    • Resolves or creates Teilnehmer records when storing answers (enrichAnswerRows).
    • Filters out rows marked Inaktiv === true for participants and teams.
  3. Quiz & Scoring Logic (server/quiz-logic.js):
    • Resolves correct answers whether entered as keys (A, A,C) or matching option text (Stuttgart, Falsch).
    • Binary mode awards 1000 base points; time mode awards 500 + Math.round((timeRemaining / totalTime) * 500).
    • MultipleChoice partial scoring: (rightPicked / totalCorrect) * basis - (wrongPicked / totalIncorrect) * (basis / 2), clamped to >= 0.
  4. WebSocket Live Engine (server/live-session.js):
    • Uses ws on the same HTTP server with 30-second ping/pong heartbeats.
    • Generates a 24-byte hex presentToken per session for /present authentication.
    • Automatically displays question results once all connected players have submitted an answer, writes all live answers in batches of 200 to Baserow on session end, and cleans up ended sessions from memory after 5 minutes (300000 ms).

Tech Stack & Ports

Component Technology / Version Details
Runtime Node.js 22 (node:22-alpine) CommonJS server (server/index.js)
Backend Express ^4.21.0, ws ^8.18.0 REST API, static files, WebSockets
Frontend React 18, Babel Standalone, Tailwind CSS (CDN) public/index.html, admin.html, present.html
Database Baserow REST API External Baserow instance (e.g., https://br.orfel.de)
Notifications ntfy HTTP API Feedback alerts
Default Port 7849 Configurable via PORT

Prerequisites & Installation

Prerequisites

  • Local Development: Node.js 22 (or v18+ with native fetch) and npm.
  • Database: A running Baserow instance with tables set up according to BASEROW-SETUP.md and a Baserow API token.
  • Docker Deployment: Docker.

Local Installation

  1. Clone the repository:

    git clone https://git.orfel.de/Jannik/Quizalarm.git
    cd Quizalarm
    
  2. Install dependencies:

    npm install
    
  3. Set the required environment variables (see Configuration) and start the server:

    npm start
    
  4. Open the application:

    • Player UI: http://localhost:7849/
    • Admin Panel: http://localhost:7849/admin
    • Presenter View: Opened from Admin Panel (/present?pt=<token>#<CODE>)

Docker Setup

Build and run the container (mounting a persistent volume for /data/config.json):

docker build -t quizalarm .
docker run -d \
  --name quizalarm \
  -p 7849:7849 \
  -v quizalarm_data:/data \
  -e ADMIN_PASSWORD=your_secure_password \
  -e BASEROW_URL=https://br.orfel.de \
  -e BASEROW_TOKEN=your_baserow_api_token \
  quizalarm

Configuration

Environment Variables (server/config.js)

Variable Description Default
PORT HTTP and WebSocket server port 7849
CONFIG_PATH Path to persistent JSON configuration file /data/config.json
ADMIN_PASSWORD Password for /admin login and x-admin-token API auth admin
BASEROW_URL Base URL of your Baserow instance http://baserow:80
BASEROW_TOKEN Baserow API token (Token ...) with read/create/update rights ""
PARTICIPANTS_TABLE_ID Baserow table ID for Teilnehmer 10
TEAMS_TABLE_ID Baserow table ID for Teams 11
NTFY_URL Full ntfy URL for feedback notifications (overrides NTFY_TOPIC) https://ntfy.orfel.de/Quizalarm
NTFY_TOPIC Topic name appended to https://ntfy.orfel.de/ if NTFY_URL is unset —
NTFY_TOKEN Optional Bearer token for authenticated ntfy topics ""

Baserow Schema

Follow BASEROW-SETUP.md for full step-by-step instructions. Summary of required tables:

  • Antworten (Answers): Stores all Live, Solo, and Wettkampf answers (Nutzername, Frage_ID, Fragenset, Antwort, Richtig, Punkte, Session_ID, Modus, Zeitstempel, Teilnehmer).
  • Question Set Tables: One table per question set (Frage, Typ, Bild, Antwort A–D, Richtige Antwort, Kategorie).
  • Teilnehmer & Teams Tables: Used for random name suggestions (Name, Aktiv seit, Aktiv, Inaktiv, Teamleiter) and team assignment/password auth (Name, Passwort, Inaktiv, Teilnehmer).

Persistent Storage

  • /data (specifically /data/config.json or CONFIG_PATH) stores configured question sets, answersTableId, and optional ntfyUrl overrides set via /admin.

Usage

Workflows

  1. Configure Baserow & Question Sets:
    • Create tables in Baserow per BASEROW-SETUP.md.
    • Log into /admin with ADMIN_PASSWORD, add each question set (Name, Baserow Table ID, card color, optional wettkampfCount and wettkampfTimer), set the Antworten Table ID, and verify via Baserow-Verbindung testen.
  2. Host a Live Quiz:
    • In /admin → Live-Session, select a question set, optionally enter a custom room code, choose shuffling and scoring mode (binary or time), and create the session.
    • Open the generated Präsentations-Fenster (/present) on a projector/screen and share the room code with players.
    • Control question flow (▶ Quiz starten, Ergebnis zeigen ➜, Nächste Frage ➜, ⏹ Session beenden) from /admin (or reconnect to an ongoing session by code).
  3. Play Solo or Wettkampf:
    • Players visit /, choose ⚔️ Wettkampf or 📚 Solo-Lernen, enter or roll (🎲) a nickname, select their team/youth leader if prompted, and complete or resume their session.

REST API & WebSocket Endpoints

  • Public Endpoints:
    • GET /api/sets — List configured question sets.
    • GET /api/sets/:id/questions — Fetch questions with rewritten /api/img URLs.
    • GET /api/sets/:id/count — Question count for a set.
    • GET /api/img?url=... — Cached image proxy (restricted to BASEROW_URL host).
    • POST /api/results/single | POST /api/results | PUT /api/results/update | PUT /api/results/finalize | POST /api/results/abandon — Save and finalize Solo/Wettkampf/Live answers.
    • GET /api/progress/:name/:setId | GET /api/wettkampf-progress/:name/:setId — Check for incomplete sessions.
    • GET /api/results/:name — Fetch answer history for a user.
    • GET /api/names/random | POST /api/names/claim | POST /api/names/assign-team — Participant name & team management.
    • GET /api/teams | POST /api/teams/auth — List active teams & verify team password (field_id: 63).
    • POST /api/feedback — Forward feedback to ntfy.
  • Admin Endpoints (require x-admin-token header):
    • POST /api/admin/login
    • GET /api/admin/config | POST /api/admin/config
    • GET /api/admin/sessions
    • GET /api/admin/stats
    • GET /api/admin/debug-baserow
  • WebSocket Messages: admin-create, admin-join, admin-start, admin-show-result, admin-next, admin-end, present-join, join, answer.

Baserow Category Updater Script (Windows PowerShell 5.1)

Run Baserow Kategorie Updater JLM.ps1 to inspect table fields ([1]), add a new colored Kategorie select option across configured field IDs 28, 37, 46, 55 ([2]), or test GET/PATCH permissions ([3]) against https://br.orfel.de.


Project Structure

Quizalarm/
├── public/
│   ├── img/
│   │   ├── bg.png                          # Dark background image
│   │   ├── logo.png                        # Quizalarm logo
│   │   ├── logo_full.png                   # Full logo variant
│   │   ├── qr.png                          # QR code asset
│   │   └── wappen.png                      # Fire brigade crest
│   ├── js/
│   │   ├── admin.js                        # React admin panel UI
│   │   ├── app.js                          # React player UI (Wettkampf, Solo, Live, Results)
│   │   └── present.js                      # React beamer / presentation UI
│   ├── admin.html                          # Admin page shell
│   ├── index.html                          # Player app shell
│   └── present.html                        # Presentation page shell
├── server/
│   ├── baserow.js                          # Baserow REST client, caching & participant enrichment
│   ├── config.js                           # Env & /data/config.json loader/writer
│   ├── index.js                            # Express server, API routes & image proxy
│   ├── live-session.js                     # WebSocket live multiplayer session manager
│   └── quiz-logic.js                       # Text normalization, answer parsing & scoring
├── BASEROW-SETUP.md                        # Step-by-step Baserow schema & setup guide
├── Baserow Kategorie Updater JLM.ps1       # PowerShell 5.1 Baserow select-option sync tool
├── Dockerfile                              # Node 22 Alpine container (non-root user node)
├── export - Antworten.csv                  # Sample/exported Baserow answers CSV
├── export - JLM 2026 AK A.csv              # Exported question set CSV (AK A)
├── export - JLM 2026 AK B.csv              # Exported question set CSV (AK B)
├── export - JLM 2026 AK C.csv              # Exported question set CSV (AK C)
├── feuerwehr_namen_500.txt                 # Predefined participant nickname list
├── ortsnamen.txt                           # Town/location name list
└── package.json                            # Dependencies and start script

License

This project's own code and configuration are dedicated to the public domain under CC0 1.0 Universal — see LICENSE.

External dependencies installed via package managers or Docker images retain their respective open-source licenses.

S
Description
Echtzeit-Hybrid-Quiz-Plattform (Live-Show + Solo-Modus) mit WebSockets, Presenter-Ansicht und Baserow-Backend.
Readme CC0-1.0
3 MiB
0 Stars 1 Watchers 0 Forks
Languages
JavaScript 93.8%
PowerShell 4.1%
HTML 2%
Dockerfile 0.1%