From 075b259bfb6b3f13d628349f8c50fb9081708550 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Thu, 20 Mar 2025 21:08:04 +0000 Subject: [PATCH] Update code in endpoints/Outliners_exam.post.py --- endpoints/Outliners_exam.post.py | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/endpoints/Outliners_exam.post.py b/endpoints/Outliners_exam.post.py index e69de29..5d9a749 100644 --- a/endpoints/Outliners_exam.post.py +++ b/endpoints/Outliners_exam.post.py @@ -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" + ] + } \ No newline at end of file