| class SubmitAnswersResponse: | |
| def __init__(self, username: str, score: float, correct_count: int, total_attempted: int, message: str, timestamp: str): | |
| self.username = username | |
| self.score = score | |
| self.correct_count = correct_count | |
| self.total_attempted = total_attempted | |
| self.message = message | |
| self.timestamp = timestamp | |
| def to_submit_answers_response(json_data) -> SubmitAnswersResponse: | |
| print(f"Original Response:\n {json_data}") | |
| return SubmitAnswersResponse( | |
| username=json_data['username'] or '<unknown>', | |
| score=json_data['score'] or 0.0, | |
| correct_count=json_data['correct_count'] or 0, | |
| total_attempted=json_data['total_attempted'] or 0, | |
| message=json_data['message'] or 'No message received.', | |
| timestamp=json_data['timestamp'] or '<unknown>' | |
| ) | |