File size: 566 Bytes
9a6b7dc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from pydantic import BaseModel
from typing import List, Dict
from datetime import datetime


class Response(BaseModel):
    q_id: str
    ans: int
    feedback_text: str | None = None


class Feedback(BaseModel):
    id: int
    user_id: str
    time_stamp: datetime
    responses: List[Response]

    # Override the method to serialize datetime
    def dict(self, *args, **kwargs):
        feedback_data = super().dict(*args, **kwargs)
        feedback_data['time_stamp'] = self.time_stamp.isoformat()  # Convert datetime to ISO string
        return feedback_data