File size: 816 Bytes
a7afc62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# app/models.py

from pydantic import BaseModel, Field
from typing import Any, Optional

class QuizRequest(BaseModel):
    """Model for the incoming POST request to the API."""
    email: str = Field(..., description="Student email ID")
    secret: str = Field(..., description="Student-provided secret")
    url: str = Field(..., description="A unique task URL")

class QuizSubmitPayload(BaseModel):
    """Model for the payload sent to the submit endpoint."""
    email: str
    secret: str
    url: str
    answer: Any # The answer type varies (str, int, bool, JSON object, etc.)

class QuizSubmitResponse(BaseModel):
    """Model for the response received from the submit endpoint."""
    correct: bool
    url: Optional[str] = Field(None, description="New quiz URL if provided")
    reason: Optional[str] = None