Skip to content

antonio-junior/exam-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Exam Generator

alt text

Upload any document and instantly get a multiple-choice exam generated by Claude AI. Answer the questions and get instant feedback on what you got right and wrong.

What it does

  1. Upload a document (PDF, DOCX, TXT, or Markdown)
  2. Configure how many questions and how many alternatives per question you want
  3. Start the exam — a countdown timer (1 minute per question) begins and stays visible as you scroll
  4. Answer the questions before time runs out — the exam auto-submits when the timer hits zero
  5. Review your results — score, which answers were correct, the correct answer for each wrong one, and a short explanation of why each answer is right or wrong

Tech stack

  • Node.js (v18+) with ES Modules
  • Express — HTTP server
  • Multer — file upload handling
  • pdf-parse — text extraction from PDFs
  • Mammoth — text extraction from DOCX files
  • Anthropic API (Claude) — exam question generation via native fetch

Project structure

exam-generator/
├── server.js          # Express server — upload, text extraction, AI call, grading
├── package.json
├── .env.example       # Environment variable template
└── public/
    └── index.html     # Single-page frontend (upload → exam → results)

Setup

1. Clone / navigate to the project

cd exam-generator

2. Install dependencies

npm install

3. Configure environment variables

cp .env.example .env

Open .env and fill in your Anthropic API key:

ANTHROPIC_API_KEY=sk-ant-...
PORT=3000

Getting an API key:

  • If your company has an Anthropic enterprise account, ask your Console admin to invite you and generate a key from console.anthropic.com
  • For personal use, sign up at console.anthropic.com, add billing, and create a key under API Keys

4. Run the server

# Production
npm start

# Development (auto-restarts on file changes, Node 18+)
npm run dev

The app will be available at http://localhost:3000

Usage

  1. Open http://localhost:3000 in your browser
  2. Upload a document (PDF, DOCX, TXT, or MD — up to 20 MB)
  3. Set the number of questions (1–50) and alternatives per question (2–6)
  4. Click Generate Exam and wait a few seconds while Claude reads the document
  5. Answer all questions and click Submit Answers
  6. Review your score and per-question breakdown

Configuration limits

Setting Min Max Default
Questions 1 50 10
Alternatives 2 6 4
File size 20 MB

Supported file types

Format Extension
PDF .pdf
Word Document .docx
Plain Text .txt
Markdown .md

Notes

  • Exam sessions are held in memory and expire after 2 hours
  • The correct answers are never sent to the browser until after submission, preventing cheating
  • Only the first ~40,000 characters of the document are sent to the AI to stay within token limits — for very long documents, the questions will be based on the beginning of the content

About

AI-powered exam generator from uploaded documents

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages