Update code in endpoints/Outliners_exam.post.py
This commit is contained in:
parent
a7a61ac961
commit
075b259bfb
@ -0,0 +1,39 @@
|
|||||||
|
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"
|
||||||
|
]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user