Automate Google Forms quiz creation from JSON files via CLI.
- 📋 Create quizzes from JSON with automatic grading
- 💡 Support for hints and answer explanations
- 📁 Organize forms in Google Drive folders
- 🔐 OAuth2 authentication (one-time setup)
git clone <repo-url>
cd quiz-crafter
yarn install- Create project at Google Cloud Console
- Enable Forms API and Drive API
- Create OAuth2 credentials (Web application)
- Add redirect URI:
http://localhost:8080/oauth2callback - Download credentials JSON
- Add redirect URI:
- Add yourself as test user in OAuth consent screen
cp .env.example .env
# Edit .env with your credentials path{
"title": "Math Quiz",
"description": "Test your math skills",
"sections": [
{
"title": "Addition",
"description": "Solve these problems",
"questions": [
{
"title": "Question 1",
"question": "What is 5 + 3?",
"hint": "Use your fingers!",
"type": "MULTIPLE_CHOICE",
"required": true,
"options": [
{ "value": "7", "label": "A" },
{ "value": "8", "label": "B", "isCorrect": true },
{ "value": "9", "label": "C" }
],
"feedback": "5 + 3 = 8"
}
]
}
]
}node src/createForm.js --quiz my-quiz.jsonFirst time: Browser opens → Sign in → Allow permissions → Done!
Output:
✅ Form created successfully!
🔗 Edit URL: https://docs.google.com/forms/d/.../edit
Click the URL to view your form in Google Forms.
# Basic
node src/createForm.js -q quiz.json
# Save to specific folder
node src/createForm.js -q quiz.json -f <folder-id>
# Try example
node src/createForm.js -q ./src/config/examples/sample-quiz.jsonGet folder ID: Open folder in Drive → Copy ID from URL: drive.google.com/drive/folders/<ID>
title: Quiz titlesections[]: Array of sectionstitle: Section titlequestions[]: Array of questionstitle: Question identifierquestion: Question texttype:MULTIPLE_CHOICE,CHECKBOX, orDROPDOWNoptions[]: Answer optionsvalue: Option textlabel: Option letter (A, B, C...)isCorrect: Mark correct answer(s)
description: Quiz/section descriptionhint: Question hintfeedback: Answer explanationrequired: Make question mandatory (default: true)
See examples for complete samples.
| Issue | Solution |
|---|---|
| Access blocked | Add your email as test user in OAuth consent screen |
| Connection refused | Add http://localhost:8080/oauth2callback to redirect URIs |
| Token expired | rm token.json and run command again |
Never commit:
token.json- OAuth tokens.env- Configurationclient_secret_*.json- Credentials
Store credentials outside repository (e.g., ~/.config/).
src/
├── createForm.js # CLI entry point
├── authUser.js # OAuth2 flow
├── config/
│ ├── quiz-schema.json # JSON schema
│ └── examples/ # Sample quizzes
└── utils/
├── quizLoader.js # Validation
├── quizParser.js # API transformation
├── questionBuilder.js # Question builder
└── ...
MIT
Happy Crafting! 🎉