Add documentation and implementation report
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,6 +4,7 @@ __pycache__/
|
|||||||
.pytest_cache/
|
.pytest_cache/
|
||||||
.coverage
|
.coverage
|
||||||
htmlcov/
|
htmlcov/
|
||||||
|
*.egg-info/
|
||||||
.env
|
.env
|
||||||
quiz.db
|
quiz.db
|
||||||
*.db
|
*.db
|
||||||
|
|||||||
67
IMPLEMENTATION_REPORT.md
Normal file
67
IMPLEMENTATION_REPORT.md
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
# Implementation Report
|
||||||
|
|
||||||
|
## Built
|
||||||
|
|
||||||
|
Implemented the live in-lecture quiz portal per `SPEC.md`: FastAPI backend, SQLite schema with WAL, signed student and admin cookies, quiz pool validation, modular scoring, student/admin APIs, WebSocket state machine, auto-close, CSV export, vanilla student/admin frontends, example Week 9 question pool, docs, and tests.
|
||||||
|
|
||||||
|
File inventory and line counts:
|
||||||
|
|
||||||
|
```text
|
||||||
|
app/: 1400 lines
|
||||||
|
static/: 775 lines
|
||||||
|
tests/: 504 lines
|
||||||
|
examples/week9_pool.json: 127 lines
|
||||||
|
total across app, static, tests, examples: 2806 lines
|
||||||
|
```
|
||||||
|
|
||||||
|
## Test Results
|
||||||
|
|
||||||
|
`pytest -q`:
|
||||||
|
|
||||||
|
```text
|
||||||
|
31 passed, 33 warnings in 5.43s
|
||||||
|
```
|
||||||
|
|
||||||
|
`pytest --cov=app`:
|
||||||
|
|
||||||
|
```text
|
||||||
|
31 passed, 33 warnings in 5.48s
|
||||||
|
TOTAL 854 statements, 67 missed, 92.15% coverage
|
||||||
|
Required test coverage of 80.0% reached.
|
||||||
|
```
|
||||||
|
|
||||||
|
Smoke test:
|
||||||
|
|
||||||
|
```text
|
||||||
|
uvicorn app.main:app started successfully on 127.0.0.1:8001
|
||||||
|
GET /healthz returned {"ok":true,"version":"0.1.0","sessions_active":0,"ws_clients":0}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Run Locally
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python3 -m venv .venv
|
||||||
|
. .venv/bin/activate
|
||||||
|
pip install -e '.[dev]'
|
||||||
|
cp .env.example .env
|
||||||
|
uvicorn app.main:app --host 127.0.0.1 --port 8001 --reload
|
||||||
|
```
|
||||||
|
|
||||||
|
## Deviations and Notes
|
||||||
|
|
||||||
|
- Server-side QR SVG data URLs are used instead of a client-side QR library.
|
||||||
|
- `live_histogram` is pushed on every accepted submission, not throttled.
|
||||||
|
- Broadcast sends are queued so slow WebSocket clients do not block state changes.
|
||||||
|
- `static/observer.html` is a placeholder because the observer page is optional.
|
||||||
|
- FastAPI emits a non-fatal `on_event` deprecation warning with the installed package version.
|
||||||
|
|
||||||
|
## Open Issues
|
||||||
|
|
||||||
|
No known functional blockers. The admin UI is intentionally plain and should be reviewed with the instructor workflow in mind before classroom use.
|
||||||
|
|
||||||
|
## Review Carefully
|
||||||
|
|
||||||
|
- The late-join behavior and missed-submission rows.
|
||||||
|
- The session control flow from `lobby` through `finished`.
|
||||||
|
- CSV shape against the exact spreadsheet format wanted for class records.
|
||||||
|
- The generated example questions, because they are plausible placeholders.
|
||||||
14
NOTES.md
14
NOTES.md
@@ -1,3 +1,15 @@
|
|||||||
# Notes
|
# Notes
|
||||||
|
|
||||||
Implementation notes will be filled in as the application lands.
|
## Implementation Choices
|
||||||
|
|
||||||
|
- QR codes are generated server-side with the Python `qrcode` package and returned as an SVG data URL from session creation.
|
||||||
|
- `live_histogram` is pushed on every accepted submission. There is no throttling in v1 because the acceptance load is small and this keeps behavior simple.
|
||||||
|
- WebSocket broadcast sends are queued as background tasks. This prevents one slow classroom device from blocking state transitions or auto-close.
|
||||||
|
- The optional observer page exists as a placeholder only. The spec explicitly marks it optional.
|
||||||
|
- Tests use one FastAPI `TestClient` portal for multi-student WebSocket simulation. Each socket is opened after joining as that student, and the stored socket identity remains stable after the cookie is overwritten for the next simulated student.
|
||||||
|
- Python 3.14.4 was used locally. The project requires Python 3.11 or newer.
|
||||||
|
|
||||||
|
## Deviations
|
||||||
|
|
||||||
|
- The admin frontend includes a compact one-question sample in the Add Pool modal for convenience. The full 10-question Week 9 pool is in `examples/week9_pool.json`.
|
||||||
|
- FastAPI emits a deprecation warning for `on_event` under the installed version. Startup works correctly, and the warning is not user-facing.
|
||||||
|
|||||||
44
README.md
44
README.md
@@ -1,3 +1,45 @@
|
|||||||
# Live In-Lecture Quiz Portal
|
# Live In-Lecture Quiz Portal
|
||||||
|
|
||||||
Development notes will be filled in as the implementation lands.
|
FastAPI, SQLite, WebSocket, and vanilla frontend implementation for a live classroom quiz.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /home/ameer/RD/Projects/Apps/quiz
|
||||||
|
python3 -m venv .venv
|
||||||
|
. .venv/bin/activate
|
||||||
|
pip install -e '.[dev]'
|
||||||
|
cp .env.example .env
|
||||||
|
```
|
||||||
|
|
||||||
|
Edit `.env` and set real values for `QUIZ_SECRET_KEY` and `QUIZ_ADMIN_PASSWORD`.
|
||||||
|
|
||||||
|
## Run
|
||||||
|
|
||||||
|
```bash
|
||||||
|
. .venv/bin/activate
|
||||||
|
uvicorn app.main:app --host 127.0.0.1 --port 8001 --reload
|
||||||
|
```
|
||||||
|
|
||||||
|
Open `http://127.0.0.1:8001/admin/`, log in, create a quiz pool, then create a session. Use the displayed join URL in another browser or private window for the student view.
|
||||||
|
|
||||||
|
## Test
|
||||||
|
|
||||||
|
```bash
|
||||||
|
. .venv/bin/activate
|
||||||
|
pytest -q
|
||||||
|
pytest --cov=app
|
||||||
|
```
|
||||||
|
|
||||||
|
The load simulation test creates 50 student WebSocket clients and runs a 5-question quiz.
|
||||||
|
|
||||||
|
## Manual Smoke Test
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export QUIZ_DB_PATH=/tmp/quiz-smoke.db QUIZ_SECRET_KEY=smoke-secret QUIZ_ADMIN_PASSWORD=smoke-pass QUIZ_PUBLIC_URL=http://127.0.0.1:8001
|
||||||
|
. .venv/bin/activate
|
||||||
|
uvicorn app.main:app --host 127.0.0.1 --port 8001
|
||||||
|
curl http://127.0.0.1:8001/healthz
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected health response starts with `{"ok":true`.
|
||||||
|
|||||||
Reference in New Issue
Block a user