6.3 KiB
6.3 KiB
Exam System - Complete Setup Guide
✅ System Overview
A complete exam system with:
- exam_server: Django REST API backend
- exam_web: Angular SPA frontend
- nginx: Reverse proxy
- data: File-based storage for exams, attempts, and results
📁 Project Structure
exam_system/
├── exam_server/ # Django backend
│ ├── manage.py
│ ├── exam_server/ # Django project
│ │ ├── settings.py
│ │ ├── urls.py
│ │ └── wsgi.py
│ ├── api/ # API app
│ │ ├── views.py
│ │ ├── urls.py
│ │ └── storage.py
│ ├── Dockerfile
│ └── requirements.txt
│
├── exam_web/ # Angular frontend
│ ├── src/
│ │ ├── app/
│ │ │ ├── components/
│ │ │ │ ├── exam-list/
│ │ │ │ ├── exam-player/
│ │ │ │ └── exam-done/
│ │ │ ├── services/
│ │ │ │ └── api.service.ts
│ │ │ ├── app.module.ts
│ │ │ └── app-routing.module.ts
│ │ ├── index.html
│ │ └── main.ts
│ ├── angular.json
│ ├── package.json
│ └── Dockerfile
│
├── data/ # File-based storage
│ ├── input/ # Exam JSON files
│ │ └── python-basics-v1.json
│ ├── attempts/ # Active attempts
│ ├── output/ # Final bundles
│ ├── progress/ # Progress snapshots
│ └── manifest.json # Exam registry
│
├── nginx.conf # Nginx config
├── Dockerfile.nginx # Nginx Dockerfile
├── docker-compose.yml # Docker orchestration
└── README.md
🚀 Quick Start
1. Start the System
cd exam_system
docker-compose up --build
This starts three services:
- exam_server: Django API on port 8000 (internal)
- exam_web: Angular app on port 4200 (internal)
- nginx: Reverse proxy on port 80 (external)
2. Access the Application
Open your browser to: http://localhost
You should see the exam list with "Python Basics Exam" available.
3. Test the Flow
- Click "Start Exam" on the Python Basics exam
- Answer the questions (multiple choice, true/false, essay, code)
- The system autosaves every 10 seconds
- Submit when done
- Check
data/output/for the bundled result JSON
🔧 Development
Backend (Django)
# Shell access
docker-compose exec exam_server bash
# Run migrations
docker-compose exec exam_server python manage.py migrate
# Create superuser for admin
docker-compose exec exam_server python manage.py createsuperuser
# Access admin
http://localhost/admin
Frontend (Angular)
# Shell access
docker-compose exec exam_web sh
# Install new packages
docker-compose exec exam_web npm install <package>
# View logs
docker-compose logs -f exam_web
Add a New Exam
-
Create exam JSON in
data/input/your-exam.jsonfollowing the format indocs/exam-format.md -
Update
data/manifest.json:
{
"version": "1.0.0",
"exams": [
{
"examId": "your-exam",
"path": "input/your-exam.json",
"published": true,
"version": "1.0.0"
}
],
"users": {}
}
- Refresh the browser - the new exam will appear
📊 Data Flow
- Exam Load: Angular calls
/api/exams/→ Django readsdata/input/andmanifest.json - Start Exam: POST
/api/exams/{id}/attempt/→ Creates attempt indata/attempts/{userId}/{examId}/ - Autosave: PUT
/api/attempts/{id}/autosave/→ Updates attempt JSON every 10 seconds - Submit: POST
/api/attempts/{id}/submit/→ Creates bundle indata/output/{examId}_{attemptId}.json
🧪 Testing
Test with Sample Exam
The system comes with a sample Python exam. To test:
- Start the system:
docker-compose up - Go to http://localhost
- Click "Start Exam" on "Python Basics Exam"
- Answer a few questions
- Wait for autosave (watch for "Saved" status)
- Submit the exam
- Check
data/attempts/anddata/output/for saved files
Verify API Endpoints
# List exams
curl http://localhost/api/exams/
# Health check
curl http://localhost/api/health/
🐛 Troubleshooting
Port 80 Already in Use
Edit docker-compose.yml:
nginx:
ports:
- "8080:80" # Change from 80:80
Then access via http://localhost:8080
Container Won't Start
# Check logs
docker-compose logs exam_server
docker-compose logs exam_web
docker-compose logs nginx
# Rebuild from scratch
docker-compose down -v
docker-compose up --build
Permission Errors on Data Folder
chmod -R 755 data/
Angular Build Issues
# Clear node_modules and rebuild
docker-compose down
rm -rf exam_web/node_modules
docker-compose up --build
📝 Question Types Supported
- single_choice: Multiple choice with one correct answer
- true_false: Boolean questions
- essay: Open-ended text responses
- code_simple: Simple coding problems
- code_exercise: Complex coding exercises with test cases
See docs/exam-format.md for complete format specification.
🔐 Security Notes
- This is a development setup. For production:
- Change
SECRET_KEYinexam_server/env.example - Set
DEBUG=False - Use HTTPS with proper SSL certificates
- Add authentication/authorization
- Secure file permissions on data folder
- Change
📚 Documentation
docs/exam-format.md- Exam JSON format specificationdocs/stack-architecture.md- System architecturedocs/django-backend-spec.md- Backend API detailsdocs/angular-frontend-spec.md- Frontend behaviordocs/json-io-and-state.md- State machine and file structure
🎯 Next Steps
- Create your own exam JSON files
- Customize the Angular UI styling
- Add grading/scoring logic
- Implement user authentication
- Deploy to production
💡 Tips
- Use the sample exam as a template for creating new exams
- The system autosaves every 10 seconds, so progress is never lost
- Check
data/output/for submitted exam bundles - All data is stored as JSON files for easy inspection and backup