Transform PDF/Word documents into interactive multiple-choice quizzes using AI
Important
This project is created for educational purposes to help students and teachers generate quizzes quickly from documents.
Key Features:
- Automatic text extraction from PDF and Word files
- Smart quiz generation using Gemini AI
- Modern dark mode interface
- Completely free, no backend required
- Support for PDF, DOC, DOCX formats
- Automatic text extraction
- Content preview before generation
- Powered by Gemini 2.0 Flash
- Context-aware question generation
- Multiple choice format with 4 options
- Dark mode design
- Glassmorphism UI effects
- Smooth animations
- Fully responsive
- Instant answer reveal after selection
- Visual feedback for correct/incorrect answers
- One-time answer selection
- Auto-scroll to new questions
- Modern web browser (Chrome, Firefox, Edge, Safari)
- Internet connection for API calls
- No installation needed
Step 1: Get Gemini API Key
- Visit https://aistudio.google.com/app/apikey
- Sign in and create a free API key
Step 2: Configure
- Open
script.js - Replace line 4:
const GEMINI_API_KEY = 'YOUR_API_KEY_HERE';
- Paste your API key
Step 3: Run
- Open
index.htmlin your browser - Or use Live Server (VS Code)
- Or deploy to GitHub Pages/Netlify/Vercel
Upload Document
- Click "Choose File" button
- Select your PDF or Word file
- Wait for text extraction
Generate Questions
- Click "Create 1 question" for single question
- Click "Create 5 questions" for batch generation
- Wait 5-10 seconds for AI processing
Take Quiz
- Click on your answer choice
- System automatically shows:
- Correct answer in green
- Incorrect answer in red (if wrong)
- Explanation with correct answer
Reset
- Click "Upload new file" to start over
ai-quiz-generator/
├── index.html # Main interface
├── style.css # Dark mode styling
├── script.js # AI processing logic
└── README.md # Documentation
Edit script.js line 5:
const MODEL = "gemini-2.0-flash"; // Default
// Or try:
const MODEL = "gemini-pro"; // More stableIn generateQuestions function, line 150:
Text: ${extractedText.substring(0, 3000)}
// Increase for more content
Text: ${extractedText.substring(0, 5000)}Edit event listeners:
newQuestionBtn.addEventListener('click', () => generateQuestions(3)); // 3 questions
newBatchBtn.addEventListener('click', () => generateQuestions(10)); // 10 questionsError: "Please configure Gemini API Key"
- Get API key from https://aistudio.google.com/app/apikey
- Update
script.jsline 4 - Refresh page
Error: "Cannot parse JSON from response"
- Try generating again
- Or switch to
gemini-promodel - Check API key validity
Error: "File format not supported"
- Only PDF, DOC, DOCX are supported
- Check file extension
- Convert to supported format
CORS or API blocked
- Use Live Server instead of opening file directly
- Deploy to hosting service
- Verify API key is active
- 60 requests/minute
- 1,500 requests/day
- Free forever
- Generate in batches of 5 instead of single questions
- Avoid rapid clicking
- Keep documents under 5,000 characters
GitHub Pages
- Push code to GitHub repository
- Go to Settings > Pages
- Select branch
main> folder/root - Access at
https://username.github.io/repo-name
Netlify
- Drag and drop folder to https://app.netlify.com/drop
- Or connect GitHub repository
- Auto-deploy enabled
Vercel
npm i -g vercel
vercel- PDF and Word support
- Gemini AI integration
- Dark mode UI
- Auto answer reveal
- Export to Excel/PDF
- Timer mode for exams
- Score tracking and history
- Multi-language support
- Difficulty level customization
Contributions are welcome! Please:
- Fork the repository
- Create feature branch (
git checkout -b feature/NewFeature) - Commit changes (
git commit -m 'Add NewFeature') - Push to branch (
git push origin feature/NewFeature) - Open Pull Request
This project is licensed under the MIT License - see LICENSE file for details.
- Gemini AI - Google's AI model
- PDF.js - Mozilla's PDF reader
- Mammoth.js - Word document converter
- Issues: GitHub Issues
- Email: Moraxzongli28@example.com
This project is completely free and open-source. Created for the learning community.
Happy Learning!