Skip to content

vmitkov/quiz_project

Repository files navigation

Quiz Project

This project is a quiz system that works both as a Python console application and as a web-based JavaScript app.

Features

  • Store questions and answers in one or more .txt files (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)

File Structure

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

Usage

Python Version

  1. Make sure you have Python 3 installed.
  2. Run the script:
    python quiz_script.py
    
  3. Select the file with questions and enter how many questions you want to answer when prompted (all prompts are in Russian).

Web Version

Recommended: Use a Local Web Server

Browsers block file access for security. To use the web version:

Direct File Opening (Not Recommended)

Opening HTML files directly (file://) will not work due to browser security restrictions.

DOCX/Image Quiz Workflow

To use questions and answers with images (from a Word file):

  1. Place your questions, answers, and images in db-questions.docx using the following tags:
    • <question> before each question
    • <variant> before each answer
    • Place images immediately after the question or answer they belong to
  2. Run the parser to extract questions and images:
    python docx_quiz_parser.py
    
    This will generate db_questions.json and a db_images/ folder.
  3. Start a local web server (see above).
  4. Open db_quiz.html in your browser to take the quiz with images.

Question File Formats

Plain Text Format

Each line in a questions file (e.g., questions.txt):

Question text|variant1;variant2;variant3;variant4;variant5|correct_index
  • correct_index is 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
    

DOCX Format (for images)

  • 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.py to generate the JSON and images for the web quiz.

Adding Questions

  • Add new questions to questions.txt in the same format.
  • Both the Python and web versions will use the updated file automatically.

Troubleshooting

  • 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.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published