4.6 KiB
Troubleshooting - Cannot Submit Exam
Issue
Getting "Not Found" errors when trying to autosave or submit exam.
Root Cause
The backend server needs to be properly initialized with migrations and sessions. When you start an exam before the backend is fully ready, the session may not persist correctly.
Solution 1: Refresh and Restart Exam (Recommended)
Step 1: Restart Backend
cd exam_system
docker-compose restart exam_server
Step 2: Clear Browser Data
- Open browser console (F12)
- Go to Application > Storage
- Clear all cookies and localStorage
- Or just open an incognito/private window
Step 3: Start Fresh
- Refresh the page (or open http://localhost in incognito)
- Click "Start Exam" again
- Answer questions
- Submit should work now
Solution 2: Complete Restart
cd exam_system
# Stop all containers
docker-compose down
# Start fresh
docker-compose up -d
# Wait 10 seconds for services to start
sleep 10
# Run migrations
docker-compose exec exam_server python manage.py migrate
# Now open browser to http://localhost
Solution 3: Manual Test via API
Test if the API is working:
# Get session cookie first
curl -c cookies.txt http://localhost/api/exams/
# Start attempt
curl -b cookies.txt -X POST http://localhost/api/exams/python-basics-v1/attempt/
# The response will show the attemptId
# Use it to test autosave (replace ATTEMPT_ID):
curl -b cookies.txt -X PUT \
-H "Content-Type: application/json" \
-d '{"answers":[{"questionId":"q1","response":"C","timeSec":30}]}' \
http://localhost/api/attempts/ATTEMPT_ID/autosave/
# Submit (replace ATTEMPT_ID):
curl -b cookies.txt -X POST \
http://localhost/api/attempts/ATTEMPT_ID/submit/
Verify System is Ready
Before starting an exam, check:
# All containers running
docker-compose ps
# Backend healthy
curl http://localhost/api/health/
# Exams available
curl http://localhost/api/exams/
# Check logs for errors
docker-compose logs --tail=20 exam_server
All should return valid responses with no errors.
Common Issues
1. "Not Found" for autosave/submit
Symptom: Console shows 404 errors for /api/attempts/.../autosave/
Fix:
- Backend wasn't ready when you started
- Restart backend:
docker-compose restart exam_server - Clear browser cookies
- Try again
2. "django.db.utils.OperationalError: no such table"
Symptom: Logs show database table errors
Fix:
docker-compose exec exam_server python manage.py migrate
docker-compose restart exam_server
3. Session expired
Symptom: Autosave stops working after some time
Fix:
- Sessions expire after 24 hours
- Refresh page and start new attempt
- Or increase SESSION_COOKIE_AGE in settings
4. CORS errors
Symptom: Console shows CORS policy errors
Fix:
- Check nginx is routing correctly
- Verify all containers are running
- Restart:
docker-compose restart
Debug Mode
Enable detailed logging:
# Edit docker-compose.yml
# Change DEBUG=True (it's already True in dev)
# View live logs
docker-compose logs -f exam_server
docker-compose logs -f exam_web
Manual Submission
If all else fails, you can manually create the output:
# Your attempt file
ATTEMPT_FILE="data/attempts/user_default/python-basics-v1/[YOUR_ATTEMPT_ID].json"
# Your exam file
EXAM_FILE="data/input/python-basics-v1.json"
# Create output manually
python3 << 'EOF'
import json
with open('ATTEMPT_FILE') as f:
attempt = json.load(f)
with open('EXAM_FILE') as f:
exam = json.load(f)
bundle = {"exam": exam, "attempt": attempt}
with open(f"data/output/{exam['examId']}_{attempt['attemptId']}.json", 'w') as f:
json.dump(bundle, f, indent=2)
print("Bundle created!")
EOF
Prevention
To avoid this issue:
-
Always wait for services to be ready
docker-compose up -d sleep 10 # Wait for startup docker-compose exec exam_server python manage.py migrate -
Check health before using
curl http://localhost/api/health/ -
Use incognito window for clean sessions
-
Don't restart backend while taking an exam
Test Submission Working
After fixing, test with:
- Open http://localhost
- Open browser console (F12)
- Start exam
- Watch Network tab
- You should see:
POST /api/exams/python-basics-v1/attempt/→ 200 or 201PUT /api/attempts/.../autosave/→ 200 (every 10 sec)POST /api/attempts/.../submit/→ 200
All should return 200 status codes.
Still Not Working?
Contact support or check:
docker-compose logs exam_serverdocker-compose logs nginx- Browser console errors
- Network tab in dev tools