AI Quiz Generator
Adaptive Timed MCQ Engine
Overview
AI Quiz Generator is a full-stack educational assessment platform that creates comprehensive, multi-difficulty multiple choice assessments on any subject using Google Gemini 2.0 Flash. It pairs a React and TypeScript frontend with a high-concurrency FastAPI backend, enforcing strict JSON schemas to guarantee accurate question formatting and zero parsing errors.
The Problem
Creating balanced assessment quizzes manually is time-consuming for educators and students. Meanwhile, relying on standard LLM prompts often results in unstructured text, inconsistent answer keys, and invalid question formats that fail programmatic parsing.
The Solution
Constructed a specialized FastAPI generation service utilizing the Google GenAI SDK with structured output constraints (GenerateContentConfig with response_schema). The backend generates 15 balanced questions across 3 difficulty tiers (Simple, Moderate, Difficult) with per-question and aggregate countdown timers, immediate scoring, and automated question validation.
Technology
Frontend
- React 18
- Vite
- TypeScript
- Tailwind CSS
Backend
- Python 3.9+
- FastAPI
- Uvicorn
- Pydantic
AI & LLM
- Google Gemini 2.0 Flash
- Google GenAI SDK
Architecture
- REST API
- Structured JSON Schema
Parametrization
Topic & Difficulty Profile
Constrained LLM
Gemini 2.0 Flash + Schema
MCQ Calibration
Simple / Moderate / Hard
Dual Timers
Decoupled Countdown State
Key Capabilities
Structured Schema Generation
Leverages Gemini 2.0 Flash with response_schema to guarantee valid JSON formatting and consistent answer mapping.
Multi-Tier Difficulty Calibration
Automatically partitions 15 questions into calibrated Simple, Moderate, and Difficult tiers.
Dual Countdown Timers
Implements per-question allocation timers alongside global test timers to enforce real exam conditions.
Instant Performance Breakdown
Evaluates user selections in real time, calculating accuracy scores and review breakdowns.
Obstacles Faced
- Early prompt iterations occasionally returned answer strings that did not match the generated option array. Implemented programmatic validation and fallback repair logic on the backend before returning payloads to the client.
- Managing synchronized per-question and global countdown timers across state transitions without UI jitter required decoupling timer state from heavy component re-renders.
Key Takeaways
- Constrained schema generation with Google GenAI SDK is significantly more reliable than post-hoc regex parsing or hoping the LLM follows raw prompt instructions.
- Decoupling question generation from client evaluation provides a clean separation of concerns and prevents answer exposure in the DOM.
Future Improvements
- Export quiz results to PDF with detailed explanation cards for incorrect answers.
- Support for custom document/PDF uploads to generate quizzes directly from course syllabus or textbook chapters.
- Multiplayer challenge mode with real-time peer leaderboard via WebSockets.
