File size: 1,495 Bytes
092e3d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from pydantic import BaseModel
from typing import List, Optional, Dict

class TestCase(BaseModel):
    test_id: str
    input_data: str          # stdin input to feed the program
    expected_output: str     # expected stdout output (stripped for comparison)
    is_hidden: bool = False  # True = hidden from students, used only for judging

class Room(BaseModel):
    room_id: str
    room_code: str
    room_name: str
    teacher_name: str
    language: str
    duration_minutes: int
    start_time: Optional[str] = None
    end_time: Optional[str] = None
    students: List[str] = []
    student_names: Dict[str, str] = {}
    student_red_flags: Dict[str, int] = {}
    questions: List[dict] = []
    status: str = "active"

class Question(BaseModel):
    question_id: str
    question_text: str
    language: str
    test_cases: List[TestCase] = []

class Worksheet(BaseModel):
    worksheet_id: str
    room_id: str
    student_id: str
    question_id: str
    code: str = ""
    language: str
    status: str = "working"
    last_updated: str

class ExecutionResult(BaseModel):
    success: bool
    output: Optional[str] = None
    error: Optional[str] = None

class CodeExecutionRequest(BaseModel):
    code: str
    language: str

class SubmissionResult(BaseModel):
    question_id: str
    total_cases: int
    passed_cases: int
    results: List[dict] = []  # per-case verdict details
    overall: str              # "Accepted" / "Wrong Answer" / "Runtime Error" / "Compilation Error"