5.7 KiB
5.7 KiB
User System Guide
✅ User System Implemented!
The exam system now includes complete user management with:
- User registration
- User login/logout
- Exam history tracking
- Ability to retake exams
- View previous exam results
Features
1. User Registration & Login
Registration
- Username (unique)
- Email (unique)
- Password (min 6 characters)
- Optional: First name, Last name
Login
- Username
- Password
2. Exam Management
Exam Status
- Available: Not yet started
- In Progress: Started but not submitted
- Finished: Submitted and completed
3. Exam History
- View all your exam attempts
- See submission timestamps
- View results for finished exams
- Retake any exam
4. Retake Functionality
- Click "Take Again" in history to retake any finished exam
- Creates a new attempt
- Previous attempts are preserved
Using the System
Step 1: Register or Login
Visit: http://localhost/login
Register a new account:
- Click "Register here"
- Fill in username, email, password
- Click "Register"
- Auto-login after registration
Or login with existing account:
- Username:
testuser - Password:
test123
Step 2: View Available Exams
Visit: http://localhost
You'll see:
- List of all published exams
- Status for each exam (Available, In Progress, Finished)
- "Start Exam" or "Continue" button
Step 3: Take an Exam
- Click "Start Exam" or "Continue"
- Answer questions
- System autosaves every 10 seconds
- Submit when done
Step 4: View History
Click "My History" in the header navigation
You'll see:
- All exams you've taken
- All attempts per exam
- Submission timestamps
- "View Results" button for finished attempts
- "Take Again" button to retake
Step 5: View Results
Click "View Results" on any finished attempt
You'll see:
- All questions and your answers
- Correct answers (for auto-gradable questions)
- Submission details
Step 6: Retake an Exam
- Go to "My History"
- Click "Take Again" on any exam
- System creates a new attempt
- Previous attempts are preserved
API Endpoints
Authentication
POST /api/auth/register/- Register new userPOST /api/auth/login/- LoginPOST /api/auth/logout/- LogoutGET /api/auth/me/- Get current user
Exams
GET /api/exams/- List exams (with status per user)GET /api/exams/{id}/- Get exam detailsPOST /api/exams/{id}/attempt/- Start/resume attemptPOST /api/exams/{id}/reset/- Reset to allow retake
Attempts
PUT /api/attempts/{id}/autosave/- Autosave answersPOST /api/attempts/{id}/submit/- Submit examGET /api/attempts/{id}/result/- Get results
History
GET /api/history/me/- Get exam history
Testing
Test User Created
- Username:
testuser - Password:
test123 - Email:
test@example.com
Test Flow
-
Login:
curl -c cookies.txt -X POST -H "Content-Type: application/json" \ -d '{"username":"testuser","password":"test123"}' \ http://localhost/api/auth/login/ -
List Exams:
curl -b cookies.txt http://localhost/api/exams/ -
Start Exam:
curl -b cookies.txt -X POST http://localhost/api/exams/python-basics-v1/attempt/ -
View History:
curl -b cookies.txt http://localhost/api/history/me/
Data Storage
User Data
- Stored in SQLite database:
exam_server/db.sqlite3 - User authentication via Django
Exam Attempts
- Stored in:
data/attempts/{userId}/{examId}/{attemptId}.json - Now uses numeric user IDs (1, 2, 3...) instead of "user_default"
Output Bundles
- Stored in:
data/output/{examId}_{attemptId}.json
Manifest
- Updated to track finished exams per numeric user ID
Browser Usage
Navigation
Header Menu:
- "Exam System" logo (click to go home)
- "Login" (if not logged in)
- Username + "My History" + "Logout" (if logged in)
Pages:
/- Exam list/login- Login/Register/history- Exam history/exam/:id- Exam player/result/:id- View results/done/:id- Submission confirmation
Features Implemented
- User registration
- User login/logout
- Session management
- Exam status tracking per user
- Exam history view
- View previous results
- Retake exams (unlimited)
- Continue in-progress exams
- Autosave with authentication
- Submit with authentication
- Protected API endpoints
Next Steps
- Create more exams in
data/input/ - Take exams with your user account
- View history to see all attempts
- Retake exams as many times as you want
- Compare results across attempts
Security Notes
- Passwords are hashed (Django's default)
- Session-based authentication
- CSRF protection enabled
- Authenticated endpoints check user ownership
Troubleshooting
Can't login
- Check username/password
- Verify user exists in database
- Check backend logs:
docker-compose logs exam_server
History is empty
- Take an exam first
- Verify exam was submitted successfully
- Check
data/attempts/folder for your user ID
Can't retake
- Click "Take Again" in history
- System creates new attempt automatically
- Previous attempts preserved
Database Management
List Users
docker-compose exec exam_server python manage.py shell
>>> from django.contrib.auth import get_user_model
>>> User = get_user_model()
>>> for u in User.objects.all():
>>> print(f"{u.id}: {u.username} ({u.email})")
Create Admin User
docker-compose exec exam_server python manage.py createsuperuser
Then access admin at: http://localhost/admin
Status: ✅ Fully Functional Features: Registration, Login, History, Retake, Results Ready to Use: Yes!