This project is a quiz system that works both as a Python console application and as a web-based JavaScript app.
- Store questions and answers in one or more
.txtfiles (e.g.,kaz-questions.txt,web-questions.txt) - Python script (
quiz_script.py) for command-line quizzes - Web version (
quiz.html) for browser-based quizzes - Both versions support:
- Randomized questions and answer order
- Limiting the number of questions per session
- Detailed report of wrong answers
- Russian-language prompts and interface
- File selection for the question set
- Support for escaping the
|symbol in questions and answers (use\|for a literal pipe)
quiz_project/
├── kaz-questions.txt # Quiz questions and answers (UTF-8, pipe-separated)
├── web-questions.txt # Alternative or additional question set
├── quiz_script.py # Python quiz script
├── quiz.html # Web-based quiz app (open in browser)
├── quiz_loader.js # JS module to load questions for the web app
├── db-questions.docx # DOCX file with questions, answers, and images
├── docx_quiz_parser.py # Python script to extract questions/images from DOCX
├── db_questions.json # JSON generated from DOCX for image-based quiz
├── db_images/ # Folder with images extracted from DOCX
├── db_quiz.html # Web-based quiz app for DOCX/image quizzes
- Make sure you have Python 3 installed.
- Run the script:
python quiz_script.py - Select the file with questions and enter how many questions you want to answer when prompted (all prompts are in Russian).
Browsers block file access for security. To use the web version:
-
Option 1: Python built-in server
python -m http.server 8000Then open http://localhost:8000/quiz.html or http://localhost:8000/db_quiz.html in Chrome or another browser.
-
Option 2: VS Code Live Server
- Install the "Live Server" extension in VS Code.
- Right-click
quiz.htmlordb_quiz.htmland select "Open with Live Server".
Opening HTML files directly (file://) will not work due to browser security restrictions.
To use questions and answers with images (from a Word file):
- Place your questions, answers, and images in
db-questions.docxusing the following tags:<question>before each question<variant>before each answer- Place images immediately after the question or answer they belong to
- Run the parser to extract questions and images:
This will generate
python docx_quiz_parser.pydb_questions.jsonand adb_images/folder. - Start a local web server (see above).
- Open
db_quiz.htmlin your browser to take the quiz with images.
Each line in a questions file (e.g., questions.txt):
Question text|variant1;variant2;variant3;variant4;variant5|correct_index
correct_indexis zero-based (0 = first variant is correct)- To include a literal
|in a question or answer, use\|. - Example:
Choose the correct conjunction.|either;although;let;so;therefore|0
- Use
<question>before each question and<variant>before each answer in the Word file. - Place images immediately after the question or answer they belong to.
- Run
python docx_quiz_parser.pyto generate the JSON and images for the web quiz.
- Add new questions to
questions.txtin the same format. - Both the Python and web versions will use the updated file automatically.
- If the web version doesn't load questions, make sure you are using a local web server.
- If you see errors in the console, check that the relevant files (
questions.txt,db_questions.json,db_images/) are in the same directory as the HTML file.
MIT