sphinx-quiz
Sphinx extension that builds a static, Kahoot-style quiz website from reStructuredText — no JavaScript to write, no server to run.
A quiz project is a regular Sphinx project using the sphinx_quiz extension. The index page declares the quiz setup (level, category, number of questions and timer), and every question, with its choices, explanation and transition screens, is written as plain rst. The build produces a self-contained static site that even works over file://.
The example project, Know Your Python, lives in its own repository (know-your-python) and installs this package as a dependency.
Features
Author an entire quiz in plain reStructuredText — questions, choices, explanations, timers and results screens.
Kahoot-style SPA rendered client-side: setup screen, timed questions, A/B/C/D colour cards, verdict and results screens.
Single- or multiple-answer questions with client-side shuffling.
Per-question timer with time-based transition screens.
Results screen with per-category/per-level breakdown, a review of missed questions, a shareable results URL + image, and a podium gag.
Internationalization via Sphinx gettext, plus a UI-strings layer.
Ships a dark, sidebar-free HTML theme (html_theme = 'sphinx_quiz').
Zero runtime dependencies in the browser; static output works offline.
Install
If you have Pip installed on your system, you can use it to install the latest stable version:
$ pip install sphinx-quiz
Python 3.10+ is supported. Then enable it in your project’s conf.py:
extensions = ["sphinx_quiz"] html_theme = "sphinx_quiz"
Quick start
Install the extension, then build a quiz project that uses it. The example project, Know Your Python, lives in its own repository (know-your-python) and installs this package as a dependency:
pip install -e . # this extension
# the example quiz project, cloned next to this repo:
cd ../know-your-python
pip install -r requirements.txt # pulls in ../sphinx-quiz
make html
xdg-open _build/html/index.html
Directives
- quick-select-level / quick-select-category
Options for the setup form. Content lines are the choices; * derives them from the questions found in the project. :data-include-all: adds an all option; :data-default: preselects one. :data-weights: (e.g. easy=1, medium=2, hard=3 on quick-select-level) biases the random sampling when playing with all levels; unlisted values weigh 1.
- quick-select-num-questions
How many questions per game. Content lines are the choices.
- quick-timer
Timer multipliers. 0 disables the timer; 1 is 1x the recommended time (data-seconds) of each question.
- quiz-section
Attaches :data-category: and :data-level: to the enclosing section; all question sections inside inherit them.
- quiz-question
Marks the enclosing section as a question. :data-seconds: is the recommended time. Everything before quiz-choices is the question body; a nested section (e.g. Answer) is the explanation shown after answering.
- quiz-choices
Bullet list of answers. :data-correct: holds the 1-based indexes of the right answers in source order (4 or 1, 2, 4; more than one turns it into a multiple-answer question with a submit button); :data-randomize: shuffles them on screen.
- quiz-transition
Screen shown after a question. :data-status: is success or failure. :data-time-remaining: is a fraction of the question time still left: the transition with the highest threshold below the actual remaining time is picked; 0 matches only a timeout; with no value it is the default (and the only kind used without timer).
- quiz-podium
Results-screen gag. :data-percentage: is the score threshold: the entry with the highest threshold at or below the final score is shown, with its :data-title: headline, :data-image: (source-relative path, copied to _static/quiz-podium/) and :data-text:.
Internationalization
Question content is translated with Sphinx’s standard gettext workflow. Set locale_dirs = ['locale/'] and gettext_compact = False in conf.py, then:
pip install -e '.[i18n]' # sphinx-intl make gettext sphinx-intl update -p _build/gettext/gettext -l es # translate the msgstr in locale/es/LC_MESSAGES/*.po
Because :data-correct: lives in the .rst (positional), translating choices never changes which answer is right. UI chrome (button labels, level and category names) is translated inside quiz.js STRINGS, keyed by the build’s language.
Build one combined site with English at the root and another language nested under a sub-path (make site in the example project builds _build/html with Spanish under _build/html/es). A flag switcher in the top-right corner links between them.
Theme
The extension registers a dark, sidebar-free HTML theme; enable it with html_theme = 'sphinx_quiz' in conf.py. It provides a dark pygments_style (monokai) so code blocks match the quiz panel.
The results screen shows a per-category and per-level breakdown, a review of missed questions with their explanations, and keeps the best score per game configuration in the browser’s localStorage.
License
This software is under the MIT license. The author does not provide any warranty. Issues and pull requests are welcome — see CONTRIBUTING.rst.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sphinx_quiz-0.1.0.tar.gz.
File metadata
- Download URL: sphinx_quiz-0.1.0.tar.gz
- Upload date:
- Size: 32.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
957600824749b8d0f83678e1beb208c4b2cc631ca2242e628acbe930d56f8dfb
|
|
| MD5 |
45de497d64be190bef2618c0624b3ecd
|
|
| BLAKE2b-256 |
07ad923c6eedf53e738f0258285d052127dbb3d7e334434da69b72122ec4ed85
|
Provenance
The following attestation bundles were made for sphinx_quiz-0.1.0.tar.gz:
Publisher:
publish.yml on Nekmo/sphinx-quiz
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphinx_quiz-0.1.0.tar.gz -
Subject digest:
957600824749b8d0f83678e1beb208c4b2cc631ca2242e628acbe930d56f8dfb - Sigstore transparency entry: 2195141613
- Sigstore integration time:
-
Permalink:
Nekmo/sphinx-quiz@debaa922906e134b1b8736bc16d0866e641cb579 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Nekmo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@debaa922906e134b1b8736bc16d0866e641cb579 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sphinx_quiz-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sphinx_quiz-0.1.0-py3-none-any.whl
- Upload date:
- Size: 31.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6983b0d6df555f787b3c8c32d53942268cc9f4b7176a8e61a4e7cfc2700c7bc
|
|
| MD5 |
c5c0279ac4c0af6c8746c423ad65fc52
|
|
| BLAKE2b-256 |
453fba52576dbf0cd1f12f1f7a5b793c5bf1982bccfc5a47463b9aa07b1934b9
|
Provenance
The following attestation bundles were made for sphinx_quiz-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Nekmo/sphinx-quiz
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphinx_quiz-0.1.0-py3-none-any.whl -
Subject digest:
b6983b0d6df555f787b3c8c32d53942268cc9f4b7176a8e61a4e7cfc2700c7bc - Sigstore transparency entry: 2195141617
- Sigstore integration time:
-
Permalink:
Nekmo/sphinx-quiz@debaa922906e134b1b8736bc16d0866e641cb579 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Nekmo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@debaa922906e134b1b8736bc16d0866e641cb579 -
Trigger Event:
push
-
Statement type: