# quizlib

Generate quizzes from Python code.

## Features

- **Supported Question Types**: Essay (ES), Multiple Choice (MC), True/False (TF), Cloze (CZ).
- **Renderers**: Moodle XML, Markdown
- **Python-centric**: Define quiz structure and content using native Python classes.

## Installation

Install using uv:

```sh
uv add quizlib
```


**For development run**
```sh
uv pip install -e .
```

## Usage

```python
from quizlib import Quiz, Essay, MultipleChoice, TrueFalse, Cloze
from quizlib.renderers import MoodleXMLRenderer

# Initialize quiz
quiz = Quiz(category="Example", info="Sample quiz")

# Add questions
quiz.add(Essay(name="q1", defgrade=5, text="Explain the concept of recursion."))

quiz.add(MultipleChoice(
    name="q2",
    text="Which of these is a Python keyword?",
    answers=[(1, "yield"), (0, "function"), (0, "define")],
))

# Render to Moodle XML
renderer = MoodleXMLRenderer()
xml_output = renderer.render(quiz)
print(xml_output)
```
