logistics-app-iqb0g9/endpoints/Outliners_exam.post.py
2025-03-20 21:08:04 +00:00

39 lines
1.0 KiB
Python

from fastapi import APIRouter, Depends, HTTPException
from core.database import fake_users_db
import uuid
import random
import string
router = APIRouter()
@router.post("/Outliners_exam")
async def generate_exam_code():
"""Generate a unique exam code"""
# Generate a random 8-character code
code_length = 8
characters = string.ascii_uppercase + string.digits
exam_code = ''.join(random.choice(characters) for _ in range(code_length))
# Store the generated code (demo)
code_id = str(uuid.uuid4())
fake_users_db[exam_code] = {
"id": code_id,
"created_at": "2024-01-01T00:00:00Z",
"status": "active",
"expires_in": 3600
}
return {
"message": "Exam code generated successfully",
"exam_code": exam_code,
"metadata": {
"id": code_id,
"validity": "1 hour",
"type": "standard"
},
"next_steps": [
"Share code with exam participants",
"Start exam within validity period"
]
}