AI Quiz Generator in 2026: Build a Free Self-Hosted Quiz App with Anki (30k Stars) + LangChain - 5 Working Patterns
Anki (29,543 stars) stores the questions, LangChain (143,470) generates them from any source material, and an LLM keeps difficulty calibrated - a free quiz system for teachers, tutors and self-learners.
💡 What You Will Learn
Anki (29,543 stars) stores the questions, LangChain (143,470) generates them from any source material, and an LLM keeps difficulty calibrated - a free quiz system for teachers, tutors and self-learner
## The short answer
The fastest way to build a quiz generator: use an LLM to create questions from your source material (lecture notes, textbook chapters, articles), store them in Anki (29,543 stars) for spaced repetition, and auto-grade with the same model. Everything is free and self-hosted.
## Pattern 1 - Generate questions from any text
```python
import openai
text = open("chapter3.txt").read()
resp = openai.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content":
"Create 10 multiple-choice questions from this text, 4 options each, "
"with correct answers. Return JSON. " + text[:8000]}])
print(resp.choices[0].message.content)
```
## Pattern 2 - Cloze deletion for memorization
Ask for fill-in-the-blank cards ("The capital of France is ___") - these are the most effective for spaced repetition in Anki.
## Pattern 3 - Auto-grading
```python
resp = openai.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content":
f"Grade this answer to '{question}' out of 10 with one-line feedback: {answer}"}])
```
## Pattern 4 - Difficulty calibration
Have the model tag each question 1-5 by difficulty, then schedule harder questions less frequently - Anki handles the scheduling.
## Pattern 5 - Import to Anki
Export questions as CSV (`Front,Back,Tags`) and import into Anki, or use AnkiConnect for scripted sync.
## Real numbers
- Generating 100 questions from a textbook chapter costs ~$0.05-0.2 with a mini-class model.
- Anki's spaced repetition lifts 30-day retention from ~30% (cramming) to 80%+.
- The full stack runs on a laptop - no cloud accounts needed.
## FAQ
**Q: Are the questions any good?** A: Mini-class models generate good MCQs from clear source text; review and edit the first batch, then calibrate your prompt.
**Q: Can students use it too?** A: Yes - feed it your notes, generate self-quizzes, and Anki handles review scheduling.
**Q: What about math questions?** A: LLMs handle basic arithmetic and algebra; for LaTeX-heavy questions, ask for LaTeX output and render with MathJax in Anki.
Related Articles
2026-06-29
The Mainline Dragon Strategy โ Chasing the Leader Without Paying for Data
2026-06-29
The AI Hiding in Your Laptop
2026-07-14
Free AI Coding Assistant Setup 2026: 5-Min VS Code Guide (Continue, Copilot, Windsurf)
