-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpythonTypes.ts
More file actions
158 lines (149 loc) · 3.96 KB
/
pythonTypes.ts
File metadata and controls
158 lines (149 loc) · 3.96 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// Python-specific types for Python Lab exercises
import { Difficulty } from "./types";
// Python Topic IDs
export enum PythonTopicId {
Operators = "operators",
InputOutput = "input_output",
Conditions = "conditions",
Loops = "loops",
Collections = "collections",
Lists = "lists",
Tuples = "tuples",
Sets = "sets",
Dictionaries = "dictionaries",
Pandas = "pandas",
Seaborn = "seaborn",
Libraries = "libraries",
}
// Python Topic metadata
export interface PythonTopic {
id: PythonTopicId;
label: string;
subtitle?: string;
description?: string;
icon?: string;
}
// Test case for validating Python output
export interface PythonTestCase {
input?: string; // Input to provide to the program
expectedOutput: string; // Expected stdout
description?: string; // Description of what this test checks
}
// Python Exercise structure
export interface PythonExercise {
id: string;
topicId: PythonTopicId;
difficulty: Difficulty;
title: string;
description: string;
starterCode: string; // Initial code shown to user
solutionCode: string; // Correct solution
expectedOutput: string; // Expected program output
testCases?: PythonTestCase[]; // Additional test cases
hints: string[];
explanation: string;
brokenCode?: string; // For Debug Mode: code with error
debugHint?: string; // For Debug Mode: hint about error
}
// Result from running Python code
export interface PythonResult {
success: boolean;
output: string; // stdout
error?: string; // stderr or exception
executionTime?: number; // ms
}
// Validation result for exercise
export interface PythonValidationResult {
isCorrect: boolean;
message: string;
userOutput: string;
expectedOutput: string;
hints?: string[];
}
// Python exercise blueprint for generator
export interface PythonExerciseBlueprint {
titleTemplate: string;
descTemplate: string;
starterCode: string;
solutionCode: string;
expectedOutput: string;
hints: string[];
explanation: string;
brokenCode?: string;
debugHint?: string;
}
// Topics configuration
export const PYTHON_TOPICS: PythonTopic[] = [
{
id: PythonTopicId.Operators,
label: "Operatori",
subtitle: "+, -, *, /, //, %, **",
description: "Operatori aritmetici, precedenza e funzioni matematiche",
},
{
id: PythonTopicId.InputOutput,
label: "Input/Output",
subtitle: "input(), print()",
description: "Input utente e output formattato",
},
{
id: PythonTopicId.Conditions,
label: "Condizioni",
subtitle: "if, elif, else",
description: "Strutture condizionali e operatori logici",
},
{
id: PythonTopicId.Loops,
label: "Cicli",
subtitle: "for, while, range()",
description: "Cicli, iterazione e controllo flusso",
},
{
id: PythonTopicId.Collections,
label: "Collezioni",
subtitle: "Teoria",
description: "Concetti: ordinato, indicizzato, modificabile",
},
{
id: PythonTopicId.Lists,
label: "Liste",
subtitle: "list[], append, slice",
description: "Creazione, modifica e iterazione su liste",
},
{
id: PythonTopicId.Tuples,
label: "Tuple",
subtitle: "tuple(), immutabili",
description: "Tuple, unpacking e immutabilità",
},
{
id: PythonTopicId.Sets,
label: "Set",
subtitle: "set{}, union, intersection",
description: "Insiemi e operazioni insiemistiche",
},
{
id: PythonTopicId.Dictionaries,
label: "Dizionari",
subtitle: "dict{}, keys, values",
description: "Coppie chiave-valore e accesso dati",
},
{
id: PythonTopicId.Pandas,
label: "Pandas",
subtitle: "DataFrame, Series, groupby",
description: "Analisi dati con DataFrame e Series",
},
{
id: PythonTopicId.Seaborn,
label: "Seaborn",
subtitle: "barplot, scatter, heatmap",
description: "Visualizzazione dati e grafici statistici",
},
{
id: PythonTopicId.Libraries,
label: "Librerie",
subtitle: "dotenv, sqlalchemy, pymysql",
description: "Librerie per database e configurazione",
},
];