Skip to main content
← Back to All Posts

AI Tutor - Built with AI Assistance

March 16, 2026 • 12 min read
AI Tutor

AI Tutor is an intelligent study tool that converts documents (PDFs, textbooks, lecture notes) into chapter-level quizzes with adaptive difficulty. The system uses AI to extract key concepts and generate relevant questions, helping students learn more effectively.

The Goal

Create a tool that:

  1. Reads educational documents
  2. Extracts key concepts and facts
  3. Generates quiz questions at different difficulty levels
  4. Provides explanations for answers
  5. Tracks progress over time

AI Tools Used

  • Claude Code: Document parsing, question generation logic, quiz engine
  • Qwen: NLP concepts, embedding strategies, answer validation

How AI Helped

Document Parsing

Claude helped implement robust PDF parsing with PyMuPDF:

import fitz  # PyMuPDF
from typing import List, Dict

class DocumentParser:
    def __init__(self, filepath: str):
        self.doc = fitz.open(filepath)
        self.text_blocks: List[Dict] = []

    def extract_text(self) -> str:
        full_text = []
        for page_num in range(len(self.doc)):
            page = self.doc[page_num]
            blocks = page.get_text("dict")["blocks"]

            for block in blocks:
                if "lines" in block:
                    for line in block["lines"]:
                        for span in line["spans"]:
                            full_text.append(span["text"])
        return " ".join(full_text)

Chapter Extraction

AI designed a flexible chapter detection system:

def extract_chapters(self) -> List[Dict]:
    """Extract chapter boundaries and content."""
    chapters = []
    current_chapter = {
        "title": "Introduction",
        "content": "",
        "start_page": 0
    }

    for page_num, page in enumerate(self.doc):
        text = page.get_text()
        lines = text.split("\n")

        for line in lines:
            # Detect chapter headings (uppercase, short lines)
            if self._is_chapter_heading(line):
                if current_chapter["content"].strip():
                    chapters.append(current_chapter)
                current_chapter = {
                    "title": line.strip(),
                    "content": "",
                    "start_page": page_num
                }
            else:
                current_chapter["content"] += line + "\n"

    if current_chapter["content"].strip():
        chapters.append(current_chapter)

    return chapters

Quiz Generator Class

AI designed a flexible quiz generation system with dataclasses:

from enum import Enum
from dataclasses import dataclass
from typing import List, Optional

class Difficulty(Enum):
    EASY = "easy"
    MEDIUM = "medium"
    HARD = "hard"

@dataclass
class Question:
    text: str
    options: List[str]
    correct_answer: int
    explanation: str
    difficulty: Difficulty
    topic: str

@dataclass
class Quiz:
    title: str
    questions: List[Question]
    total_score: int = 0

Quiz Runner

AI helped build the quiz execution engine:

class QuizRunner:
    def __init__(self, quiz: Quiz):
        self.quiz = quiz
        self.current_question = 0
        self.score = 0
        self.answers: List[Tuple[int, int, float]] = []
        self.start_time = datetime.now()

    def get_current_question(self) -> Question:
        return self.quiz.questions[self.current_question]

    def submit_answer(self, answer_idx: int) -> bool:
        question = self.quiz.questions[self.current_question]
        is_correct = answer_idx == question.correct_answer

        if is_correct:
            self.score += self._calculate_points(question)

        self.answers.append((
            self.current_question,
            answer_idx,
            (datetime.now() - self.start_time).total_seconds()
        ))

        self.current_question += 1
        return is_correct

The Process

Prompting Strategy

  • Define data models first (Question, Quiz, Difficulty)
  • Build parsing layer
  • Implement question generation
  • Create quiz runner
  • Add results tracking

Example Prompt

I need a Python class structure for a quiz system.
It should have:
1. Question dataclass with text, options, correct_answer, explanation
2. Quiz class that contains multiple questions
3. Difficulty enum (easy, medium, hard)
4. Methods to calculate score based on difficulty

Start with the dataclasses and enums.

Challenges

What AI Couldn't Help With

  • Semantic understanding: AI couldn't truly understand document content
  • Question quality: Human review needed for accurate questions
  • Educational value: Pedagogical decisions required human expertise

Unexpected Issues

  • PDF formatting varies widely across documents
  • Some documents have poor OCR quality
  • Handling images and formulas in PDFs

Results

Quantitative

  • Development time: 3 days with AI vs estimated 5-7 days without
  • Document support: Works with various PDF formats
  • Question generation: Can generate 50+ questions per document

Key Learnings

  1. AI helps with structure - Data models and class design
  2. Human oversight needed - Question accuracy requires review
  3. Modular design is key - Separate parsing, generation, and execution
  4. Type hints help - Catch errors early with static analysis
  5. Testing is crucial - Validate with real documents
AI-Assisted Education Python NLP

Built with AI Tutor • Back to Portfolio

This project was built with AI pair programming assistance using Claude Code and Qwen.