File size: 11,507 Bytes
68efe87
 
 
 
 
 
 
 
 
 
 
 
0514a09
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68efe87
 
 
 
 
 
0514a09
68efe87
 
0514a09
68efe87
 
 
 
 
0514a09
68efe87
 
 
0514a09
 
68efe87
 
0514a09
68efe87
 
 
0514a09
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68efe87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0514a09
68efe87
 
 
 
 
 
0514a09
68efe87
 
 
 
 
 
 
 
 
 
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# =========================
# 📚 DATA LAYER (CLEAN VERSION)
# =========================


class DataService:

    def __init__(self):
        # =========================
        # 📚 COURSES DATABASE
        # =========================
        self.courses_db_mock = {
            # === University Obligatory (إجباري جامعة) ===
            "English Language I": {
                "code": "02-24-00101", 
                "credits": 2, 
                "prereq": [], 
                "course_type": "university_obligatory",
                "department": "UR"
            },
            "Human Rights and Fighting Corruption": {
                "code": "02-24-00102", 
                "credits": 2, 
                "prereq": [], 
                "course_type": "university_obligatory",
                "department": "UR"
            },

            # === University Elective (اختياري جامعة) ===
            "Entrepreneurship and Innovation": {
                "code": "02-24-00103", 
                "credits": 2, 
                "prereq": [], 
                "course_type": "university_elective",
                "department": "UR"
            },
            "Critical Thinking Skills": {
                "code": "02-24-00104", 
                "credits": 2, 
                "prereq": [], 
                "course_type": "university_elective",
                "department": "UR"
            },

            # === Faculty Obligatory (إجباري كلية) ===
            "Programming I": {
                "code": "02-24-00105", 
                "credits": 3, 
                "prereq": [], 
                "course_type": "faculty_obligatory",
                "department": "CS"
            },
            "Calculus": {
                "code": "02-24-00102", 
                "credits": 3, 
                "prereq": [], 
                "course_type": "program_obligatory",
                "department": "DS"
            },
            "Linear Algebra": {
                "code": "02-24-00101", 
                "credits": 3, 
                "prereq": [], 
                "course_type": "faculty_obligatory",
                "department": "BS"
            },
            "Introduction to Computer Systems": {  # مادة مضافة لتجنب نقص المتطلبات السابقة
                "code": "02-24-00103", 
                "credits": 3, 
                "prereq": [], 
                "course_type": "faculty_obligatory",
                "department": "CS"
            },
            "Operating Systems": {
                "code": "02-24-00203", 
                "credits": 3, 
                "prereq": ["Introduction to Computer Systems"], 
                "course_type": "faculty_obligatory",
                "department": "CS"
            },

            # === Faculty Elective (اختياري كلية) ===
            "Discrete Structures": {
                "code": "02-24-00107", 
                "credits": 3, 
                "prereq": [], 
                "course_type": "faculty_elective",
                "department": "CS"
            },
            "Introduction to Data Sciences": {
                "code": "02-24-00104", 
                "credits": 3, 
                "prereq": [], 
                "course_type": "faculty_elective",
                "department": "DS"
            },

            # === Program Obligatory (إجباري تخصص) ===
            "Data Structures and Algorithms": {
                "code": "02-24-00108", 
                "credits": 3, 
                "prereq": ["Programming I"], 
                "course_type": "program_obligatory",
                "department": "CS"
            },
            "Probability and Statistics I": {
                "code": "02-24-00106", 
                "credits": 3, 
                "prereq": [], 
                "course_type": "program_obligatory",
                "department": "BS"
            },
            "Machine Learning": {
                "code": "02-24-00205", 
                "credits": 3, 
                "prereq": ["Data Structures and Algorithms", "Linear Algebra"], 
                "course_type": "program_obligatory",
                "department": "DS"
            },
            "Database Systems": {
                "code": "02-24-00202", 
                "credits": 3, 
                "prereq": ["Data Structures and Algorithms"], 
                "course_type": "program_obligatory",
                "department": "CS"
            },
            "Data Mining and Analytics": {
                "code": "02-24-00206", 
                "credits": 3, 
                "prereq": ["Probability and Statistics I"], 
                "course_type": "program_obligatory",
                "department": "DS"
            },
            "Computer Networks": {  # مادة مضافة لتجنب نقص المتطلبات السابقة
                "code": "02-24-00301", 
                "credits": 3, 
                "prereq": ["Introduction to Computer Systems"], 
                "course_type": "program_obligatory",
                "department": "DS"
            },

            # === Program Elective (اختياري تخصص) ===
            "Big Data Analytics": {
                "code": "02-24-01401", 
                "credits": 3, 
                "prereq": ["Machine Learning", "Data Mining and Analytics"], 
                "course_type": "program_elective",
                "department": "DS"
            },
            "Deep Learning": {
                "code": "02-24-03403", 
                "credits": 3, 
                "prereq": ["Machine Learning"], 
                "course_type": "program_elective",
                "department": "DS"
            },
            "Natural Language Understanding": {
                "code": "02-24-03410", 
                "credits": 3, 
                "prereq": ["Deep Learning"], 
                "course_type": "program_elective",
                "department": "DS"
            },
            "Social Networks Analytics": {
                "code": "02-24-06414", 
                "credits": 3, 
                "prereq": ["Linear Algebra", "Probability and Statistics I", "Machine Learning"], 
                "course_type": "program_elective",
                "department": "DS"
            },
            "Internet of Things": {
                "code": "02-24-06415", 
                "credits": 3, 
                "prereq": ["Computer Networks"], 
                "course_type": "program_elective",
                "department": "DS"
            },
            "Cloud Computing": {
                "code": "02-24-00204", 
                "credits": 3, 
                "prereq": ["Data Structures and Algorithms"], 
                "course_type": "program_elective",
                "department": "CS"
            }
        }

        # =========================
        # 👤 USERS MOCK DATABASE
        # =========================
        self.users_db_mock = {
            # === طالب في قسم علوم البيانات (Data Science - DS) ===
            "user_01": {
                "name": "Ahmed",
                "department": "DS",
                "records": {
                    "Programming I": {"grade": "B+", "credit_hours": 3},
                    "Linear Algebra": {"grade": "C", "credit_hours": 3},
                    "Probability and Statistics I": {"grade": "B", "credit_hours": 3},
                    "Data Structures and Algorithms": {"grade": "B", "credit_hours": 3},
                    "Introduction to Data Sciences": {"grade": "A-", "credit_hours": 3}
                },
                "chat_history": []
            },
            
            # === طالبة في قسم علوم البيانات (Data Science - DS) - في البداية ===
            "user_02": {
                "name": "Salma",
                "department": "CS",
                "records": {
                    "Programming I": {"grade": "B+", "credit_hours": 3},
                    "Linear Algebra": {"grade": "C", "credit_hours": 3},
                    "Calculus": {"grade": "A", "credit_hours": 3},
                    "English Language I": {"grade": "A", "credit_hours": 2}
                },
                "chat_history": []
            },

            # === طالب من قسم علوم الحاسب (Computer Science - CS) - مستوى متقدم ===
            "user_03": {
                "name": "Omar",
                "department": "CS",
                "records": {
                    "Programming I": {"grade": "A", "credit_hours": 3},
                    "Introduction to Computer Systems": {"grade": "B", "credit_hours": 3},
                    "Data Structures and Algorithms": {"grade": "B+", "credit_hours": 3},
                    "Discrete Structures": {"grade": "A-", "credit_hours": 3},
                    "Operating Systems": {"grade": "B", "credit_hours": 3},
                    "Computer Networks": {"grade": "B+", "credit_hours": 3},
                    "Cloud Computing": {"grade": "A-", "credit_hours": 3},
                    "Human Rights and Fighting Corruption": {"grade": "A", "credit_hours": 2}
                },
                "chat_history": []
            },

            # === طالب من قسم علوم البيانات (Data Science - DS) - مستوى متقدم وخريج ===
            "user_04": {
                "name": "Mariam",
                "department": "DS",
                "records": {
                    "Programming I": {"grade": "A", "credit_hours": 3},
                    "Linear Algebra": {"grade": "A-", "credit_hours": 3},
                    "Probability and Statistics I": {"grade": "A", "credit_hours": 3},
                    "Data Structures and Algorithms": {"grade": "B+", "credit_hours": 3},
                    "Machine Learning": {"grade": "A", "credit_hours": 3},
                    "Introduction to Computer Systems": {"grade": "B+", "credit_hours": 3},
                    "Deep Learning": {"grade": "A-", "credit_hours": 3},
                    "Internet of Things": {"grade": "B", "credit_hours": 3},
                    "Natural Language Understanding": {"grade": "A", "credit_hours": 3},
                    "Entrepreneurship and Innovation": {"grade": "A", "credit_hours": 2},
                    "Big Data Analytics": {"grade": "A", "credit_hours": 2}

                   
                },
                "chat_history": []
            }
        }

    # =========================
    # COURSES API
    # =========================
    def fetch_courses_catalog(self):
        return self.courses_db_mock

    # =========================
    # STUDENT API
    # =========================
    def fetch_student_data(self, user_id):

        student_info = self.users_db_mock.get(user_id)

        if not student_info:
            return {
                "name": "Guest",
                "department": None,
                "records": {},
                "chat_history": []
            }

        return {
            "name": student_info.get("name", "Unknown"),
            "department": student_info.get("department"),  # 👈 IMPORTANT FIX
            "records": student_info.get("records", {}),
            "chat_history": student_info.get("chat_history", [])
        }

    # =========================
    # COMPATIBILITY PROPS (to avoid breaking old code)
    # =========================
    @property
    def COURSES_CATALOG(self):
        return self.courses_db_mock